|
@@ -19,6 +19,7 @@ import { throttle, debounce } from 'throttle-debounce';
|
|
|
import { useUpdateStateAfterSave, useSaveOrUpdate } from '~/client/services/page-operation';
|
|
import { useUpdateStateAfterSave, useSaveOrUpdate } from '~/client/services/page-operation';
|
|
|
import { apiGet, apiPostForm } from '~/client/util/apiv1-client';
|
|
import { apiGet, apiPostForm } from '~/client/util/apiv1-client';
|
|
|
import { toastError, toastSuccess } from '~/client/util/toastr';
|
|
import { toastError, toastSuccess } from '~/client/util/toastr';
|
|
|
|
|
+import mtu from '~/components/PageEditor/MarkdownTableUtil';
|
|
|
import { OptionsToSave } from '~/interfaces/page-operation';
|
|
import { OptionsToSave } from '~/interfaces/page-operation';
|
|
|
import { SocketEventName } from '~/interfaces/websocket';
|
|
import { SocketEventName } from '~/interfaces/websocket';
|
|
|
import {
|
|
import {
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
useEditingMarkdown,
|
|
useEditingMarkdown,
|
|
|
useWaitingSaveProcessing,
|
|
useWaitingSaveProcessing,
|
|
|
} from '~/stores/editor';
|
|
} from '~/stores/editor';
|
|
|
-import { useConflictDiffModal } from '~/stores/modal';
|
|
|
|
|
|
|
+import { useConflictDiffModal, useHandsontableModal } from '~/stores/modal';
|
|
|
import {
|
|
import {
|
|
|
useCurrentPagePath, useSWRMUTxCurrentPage, useSWRxCurrentPage, useSWRxTagsInfo, useCurrentPageId, useIsNotFound, useIsLatestRevision, useTemplateBodyData,
|
|
useCurrentPagePath, useSWRMUTxCurrentPage, useSWRxCurrentPage, useSWRxTagsInfo, useCurrentPageId, useIsNotFound, useIsLatestRevision, useTemplateBodyData,
|
|
|
} from '~/stores/page';
|
|
} from '~/stores/page';
|
|
@@ -127,6 +128,8 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
const { mutate: mutateResolvedTheme } = useResolvedThemeForEditor();
|
|
const { mutate: mutateResolvedTheme } = useResolvedThemeForEditor();
|
|
|
|
|
|
|
|
|
|
+ const { open: openHandsontableModal } = useHandsontableModal();
|
|
|
|
|
+
|
|
|
const saveOrUpdate = useSaveOrUpdate();
|
|
const saveOrUpdate = useSaveOrUpdate();
|
|
|
const updateStateAfterSave = useUpdateStateAfterSave(pageId, { supressEditingMarkdownMutation: true });
|
|
const updateStateAfterSave = useUpdateStateAfterSave(pageId, { supressEditingMarkdownMutation: true });
|
|
|
|
|
|
|
@@ -183,6 +186,15 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(GlobalCodeMirrorEditorKey.MAIN);
|
|
const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(GlobalCodeMirrorEditorKey.MAIN);
|
|
|
|
|
|
|
|
|
|
+ const openTableModalHandler = useCallback(() => {
|
|
|
|
|
+ const editor = codeMirrorEditor?.view;
|
|
|
|
|
+ const markdownTable = mtu.getMarkdownTable(editor);
|
|
|
|
|
+ if (markdownTable == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ openHandsontableModal(markdownTable, editor);
|
|
|
|
|
+ }, [openHandsontableModal]);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
const checkIsConflict = useCallback((data) => {
|
|
const checkIsConflict = useCallback((data) => {
|
|
|
const { s2cMessagePageUpdated } = data;
|
|
const { s2cMessagePageUpdated } = data;
|
|
@@ -586,6 +598,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
onUpload={uploadHandler}
|
|
onUpload={uploadHandler}
|
|
|
indentSize={currentIndentSize ?? defaultIndentSize}
|
|
indentSize={currentIndentSize ?? defaultIndentSize}
|
|
|
acceptedFileType={acceptedFileType}
|
|
acceptedFileType={acceptedFileType}
|
|
|
|
|
+ openTabelModal={openTableModalHandler}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="page-editor-preview-container flex-expand-vert d-none d-lg-flex">
|
|
<div className="page-editor-preview-container flex-expand-vert d-none d-lg-flex">
|