soumaeda 2 лет назад
Родитель
Сommit
054d86c993

+ 1 - 1
apps/app/src/components/PageEditor/DrawioCommunicationHelper.ts

@@ -29,7 +29,7 @@ export class DrawioCommunicationHelper {
     this.callbackOpts = callbackOpts;
   }
 
-  onReceiveMessage(event: MessageEvent, drawioMxFile: string): void {
+  onReceiveMessage(event: MessageEvent, drawioMxFile: string | null): void {
 
     // check origin
     if (event.origin != null && this.drawioUri != null) {

+ 3 - 3
apps/app/src/components/PageEditor/DrawioModal.tsx

@@ -12,7 +12,7 @@ import {
 } from 'reactstrap';
 
 import { getDiagramsNetLangCode } from '~/client/util/locale-utils';
-import mdu from '~/components/PageEditor/MarkdownDrawioUtil';
+import { replaceFocusedDrawioWithEditor, getMarkdownDrawioMxfile } from '~/components/PageEditor/markdown-drawio-util-for-editor';
 import { useRendererConfig } from '~/stores/context';
 import { useDrawioModal } from '~/stores/modal';
 import { usePersonalSettings } from '~/stores/personal-settings';
@@ -87,7 +87,7 @@ export const DrawioModal = (): JSX.Element => {
     }
 
     const save = editor != null ? (drawioMxFile: string) => {
-      mdu.replaceFocusedDrawioWithEditor(editor, drawioMxFile);
+      replaceFocusedDrawioWithEditor(editor, drawioMxFile);
     } : drawioModalData?.onSave;
 
     return new DrawioCommunicationHelper(
@@ -102,7 +102,7 @@ export const DrawioModal = (): JSX.Element => {
       return;
     }
 
-    const drawioMxFile = editor != null ? mdu.getMarkdownDrawioMxfile(editor) : drawioModalData.drawioMxFile;
+    const drawioMxFile = editor != null ? getMarkdownDrawioMxfile(editor) : drawioModalData.drawioMxFile;
     drawioCommunicationHelper?.onReceiveMessage(event, drawioMxFile);
   }, [drawioCommunicationHelper, drawioModalData, editor]);
 

+ 2 - 2
apps/app/src/components/PageEditor/markdown-drawio-util-for-editor.ts

@@ -115,12 +115,12 @@ const isInDrawioBlock = (editor: EditorView) => {
    * return drawioData instance where the cursor is
    * (If the cursor is not in a drawio block, return null)
    */
-export const getMarkdownDrawioMxfile = (editor: EditorView): string | undefined | null => {
+export const getMarkdownDrawioMxfile = (editor: EditorView): string | null => {
   if (isInDrawioBlock(editor)) {
     const bod = getBod(editor);
     const eod = getEod(editor);
     if (bod == null || eod == null) {
-      return;
+      return null;
     }
 
     // skip block begin sesion("``` drawio")