Просмотр исходного кода

135766 get table state from view and editor

soumaeda 2 лет назад
Родитель
Сommit
8b82fef95c
1 измененных файлов с 12 добавлено и 2 удалено
  1. 12 2
      apps/app/src/components/PageEditor/HandsontableModal.tsx

+ 12 - 2
apps/app/src/components/PageEditor/HandsontableModal.tsx

@@ -105,12 +105,22 @@ export const HandsontableModal = (): JSX.Element => {
   const debouncedHandleWindowExpandedChange = debounce(100, handleWindowExpandedChange);
 
   const handleModalOpen = () => {
-    const initTableInstance = table == null ? defaultMarkdownTable : table.clone();
-    setMarkdownTable(table ?? defaultMarkdownTable);
+    let markdownTableState;
+    if (table == null) {
+      // markdowntable state from Editor
+      markdownTableState = mtu.getMarkdownTable(editor);
+    }
+    else {
+      // markdowntable state from View
+      markdownTableState = table;
+    }
+    const initTableInstance = markdownTableState == null ? defaultMarkdownTable : markdownTableState.clone();
+    setMarkdownTable(markdownTableState ?? defaultMarkdownTable);
     setMarkdownTableOnInit(initTableInstance);
     debouncedHandleWindowExpandedChange();
   };
 
+
   const expandWindow = () => {
     setIsWindowExpanded(true);
     debouncedHandleWindowExpandedChange();