|
@@ -11,7 +11,7 @@ import {
|
|
|
import { debounce } from 'throttle-debounce';
|
|
import { debounce } from 'throttle-debounce';
|
|
|
|
|
|
|
|
import MarkdownTable from '~/client/models/MarkdownTable';
|
|
import MarkdownTable from '~/client/models/MarkdownTable';
|
|
|
-import { replaceFocusedMarkdownTableWithEditor } from '~/components/PageEditor/markdown-table-util-for-editor';
|
|
|
|
|
|
|
+import { replaceFocusedMarkdownTableWithEditor, getMarkdownTable } from '~/components/PageEditor/markdown-table-util-for-editor';
|
|
|
import { useHandsontableModal } from '~/stores/modal';
|
|
import { useHandsontableModal } from '~/stores/modal';
|
|
|
|
|
|
|
|
import ExpandOrContractButton from '../ExpandOrContractButton';
|
|
import ExpandOrContractButton from '../ExpandOrContractButton';
|
|
@@ -105,8 +105,9 @@ export const HandsontableModal = (): JSX.Element => {
|
|
|
const debouncedHandleWindowExpandedChange = debounce(100, handleWindowExpandedChange);
|
|
const debouncedHandleWindowExpandedChange = debounce(100, handleWindowExpandedChange);
|
|
|
|
|
|
|
|
const handleModalOpen = () => {
|
|
const handleModalOpen = () => {
|
|
|
- const initTableInstance = table == null ? defaultMarkdownTable : table.clone();
|
|
|
|
|
- setMarkdownTable(table ?? defaultMarkdownTable);
|
|
|
|
|
|
|
+ const markdownTableState = table == null && editor != null ? getMarkdownTable(editor) : table;
|
|
|
|
|
+ const initTableInstance = markdownTableState == null ? defaultMarkdownTable : markdownTableState.clone();
|
|
|
|
|
+ setMarkdownTable(markdownTableState ?? defaultMarkdownTable);
|
|
|
setMarkdownTableOnInit(initTableInstance);
|
|
setMarkdownTableOnInit(initTableInstance);
|
|
|
debouncedHandleWindowExpandedChange();
|
|
debouncedHandleWindowExpandedChange();
|
|
|
};
|
|
};
|