kaori 3 yıl önce
ebeveyn
işleme
1461f1e03b

+ 17 - 16
packages/app/src/components/Page.tsx

@@ -141,20 +141,20 @@ class PageSubstance extends React.Component<PageSubstanceProps> {
   //   } = this.props;
   //   const optionsToSave = getOptionsToSave(isSlackEnabled, slackChannels, grant, grantGroupId, grantGroupName, pageTags);
 
-  //   const newMarkdown = mdu.replaceDrawioInMarkdown(
-  //     drawioData,
-  //     this.props.pageContainer.state.markdown,
-  //     this.state.currentTargetDrawioArea.beginLineNumber,
-  //     this.state.currentTargetDrawioArea.endLineNumber,
-  //   );
+    //   const newMarkdown = mdu.replaceDrawioInMarkdown(
+    //     drawioData,
+    //     this.props.pageContainer.state.markdown,
+    //     this.state.currentTargetDrawioArea.beginLineNumber,
+    //     this.state.currentTargetDrawioArea.endLineNumber,
+    //   );
 
-  //   try {
-  //     // disable unsaved warning
-  //     mutateIsEnabledUnsavedWarning(false);
+    //   try {
+    //     // disable unsaved warning
+    //     mutateIsEnabledUnsavedWarning(false);
 
-  //     // eslint-disable-next-line no-unused-vars
-  //     const { page, tags } = await pageContainer.save(newMarkdown, this.props.editorMode, optionsToSave);
-  //     logger.debug('success to save');
+    //     // eslint-disable-next-line no-unused-vars
+    //     const { page, tags } = await pageContainer.save(newMarkdown, this.props.editorMode, optionsToSave);
+    //     logger.debug('success to save');
 
   //     pageContainer.showSuccessToastr();
   //   }
@@ -186,6 +186,7 @@ class PageSubstance extends React.Component<PageSubstanceProps> {
             <GridEditModal ref={this.gridEditModal} />
             <LinkEditModal ref={this.linkEditModal} />
             {/* <HandsontableModal ref={this.handsontableModal} onSave={this.saveHandlerForHandsontableModal} /> */}
+            {/* TODO: use global DrawioModal https://redmine.weseek.co.jp/issues/105981 */}
             {/* <DrawioModal
               ref={this.drawioModal}
               onSave={this.saveHandlerForDrawioModal}
@@ -233,10 +234,10 @@ export const Page = (props) => {
   //       pageRef.current.launchDrawioModal(beginLineNumber, endLineNumber);
   //     }
   //   };
-  //   globalEmitter.on('launchDrawioModal', handler);
+  //   window.globalEmitter.on('launchDrawioModal', handler);
 
   //   return function cleanup() {
-  //     globalEmitter.removeListener('launchDrawioModal', handler);
+  //     window.globalEmitter.removeListener('launchDrawioModal', handler);
   //   };
   // }, []);
 
@@ -247,10 +248,10 @@ export const Page = (props) => {
   //       pageRef.current.launchHandsontableModal(beginLineNumber, endLineNumber);
   //     }
   //   };
-  //   globalEmitter.on('launchHandsontableModal', handler);
+  //   window.globalEmitter.on('launchHandsontableModal', handler);
 
   //   return function cleanup() {
-  //     globalEmitter.removeListener('launchHandsontableModal', handler);
+  //     window.globalEmitter.removeListener('launchHandsontableModal', handler);
   //   };
   // }, []);
 

+ 0 - 11
packages/app/src/components/PageEditor/CodeMirrorEditor.jsx

@@ -143,7 +143,6 @@ class CodeMirrorEditor extends AbstractEditor {
     this.showGridEditorHandler = this.showGridEditorHandler.bind(this);
     this.showLinkEditHandler = this.showLinkEditHandler.bind(this);
     this.showHandsonTableHandler = this.showHandsonTableHandler.bind(this);
-    // this.clickDrawioHandler = this.clickDrawioHandler.bind(this);
 
     this.foldDrawioSection = this.foldDrawioSection.bind(this);
     this.onSaveForDrawio = this.onSaveForDrawio.bind(this);
@@ -800,11 +799,6 @@ class CodeMirrorEditor extends AbstractEditor {
     // this.handsontableModal.current.show(mtu.getMarkdownTable(this.getCodeMirror()));
   }
 
-  // clickDrawioHandler() {
-  //   this.props.onClickDrawioBtn(mdu.getMarkdownDrawioMxfile(this.getCodeMirror()));
-  //   // this.drawioModal.current.show(mdu.getMarkdownDrawioMxfile(this.getCodeMirror()));
-  // }
-
 
   // fold draw.io section (::: drawio ~ :::)
   foldDrawioSection() {
@@ -956,7 +950,6 @@ class CodeMirrorEditor extends AbstractEditor {
         color={null}
         bssize="small"
         title="draw.io"
-        // onClick={this.clickDrawioHandler}
         onClick={() => this.props.onClickDrawioBtn(mdu.getMarkdownDrawioMxfile(this.getCodeMirror()))}
       >
         <EditorIcon icon="Drawio" />
@@ -1067,10 +1060,6 @@ class CodeMirrorEditor extends AbstractEditor {
           onSave={(table) => { return mtu.replaceFocusedMarkdownTableWithEditor(this.getCodeMirror(), table) }}
           autoFormatMarkdownTable={this.props.editorSettings.autoFormatMarkdownTable}
         /> */}
-        {/* <DrawioModal
-          ref={this.drawioModal}
-          onSave={this.onSaveForDrawio}
-        /> */}
       </div>
     );
   }

+ 4 - 14
packages/app/src/stores/modal.tsx

@@ -462,12 +462,10 @@ export const useDrawioModal = (status?: DrawioModalStatus): SWRResponse<DrawioMo
   };
   const swrResponse = useStaticSWR<DrawioModalStatus, Error>('drawioModalStatus', status, { fallbackData: initialData });
 
-
-  // const init = (drawioMxFile) => {
-  //   const initDrawioMxFile = drawioMxFile;
-  //   // setDrawioMxFile(initDrawioMxFile);
-  //   swrResponse.mutate({ isOpened: false, drawioMxFile: initDrawioMxFile });
-  // };
+  const close = (): void => {
+    swrResponse.mutate({ isOpened: false, drawioMxFile: '' });
+    window.removeEventListener('message', e => receiveFromDrawio(e, ''));
+  };
 
   const receiveFromDrawio = (event, drawioMxFile: string) => {
     const headerColor = '#334455';
@@ -518,15 +516,12 @@ export const useDrawioModal = (status?: DrawioModalStatus): SWRResponse<DrawioMo
       }
 
       window.removeEventListener('message', () => receiveFromDrawio);
-      // hide();
       close();
 
       return;
     }
 
     if (typeof event.data === 'string' && event.data.length === 0) {
-      // window.removeEventListener('message', () => receiveFromDrawio);
-      // hide();
       close();
 
       return;
@@ -542,11 +537,6 @@ export const useDrawioModal = (status?: DrawioModalStatus): SWRResponse<DrawioMo
     swrResponse.mutate({ isOpened: true, drawioMxFile });
   };
 
-  const close = (): void => {
-    swrResponse.mutate({ isOpened: false, drawioMxFile: '' });
-    window.removeEventListener('message', e => receiveFromDrawio(e, ''));
-  };
-
   return {
     ...swrResponse,
     open,