diff --git a/apps/app/src/client/services/page-operation.ts b/apps/app/src/client/services/page-operation.ts index 24b385bf3ea..c5f94bf5a2c 100644 --- a/apps/app/src/client/services/page-operation.ts +++ b/apps/app/src/client/services/page-operation.ts @@ -176,7 +176,11 @@ export const useSaveOrUpdate = (): SaveOrUpdateFunction => { }, [mutateIsEnabledUnsavedWarning]); }; -export const useUpdateStateAfterSave = (pageId: string|undefined|null): (() => Promise) | undefined => { +export type UpdateStateAfterSaveOption = { + supressEditingMarkdownMutation: boolean, +} + +export const useUpdateStateAfterSave = (pageId: string|undefined|null, opts?: UpdateStateAfterSaveOption): (() => Promise) | undefined => { const { mutate: mutateCurrentPageId } = useCurrentPageId(); const { trigger: mutateCurrentPage } = useSWRMUTxCurrentPage(); const { setRemoteLatestPageData } = useSetRemoteLatestPageData(); @@ -198,7 +202,12 @@ export const useUpdateStateAfterSave = (pageId: string|undefined|null): (() => P if (updatedPage == null) { return } - mutateEditingMarkdown(updatedPage.revision.body); + // supress to mutate only when updated from built-in editor + // and see: https://github.com/weseek/growi/pull/7118 + const supressEditingMarkdownMutation = opts?.supressEditingMarkdownMutation ?? false; + if (!supressEditingMarkdownMutation) { + mutateEditingMarkdown(updatedPage.revision.body); + } const remoterevisionData = { remoteRevisionId: updatedPage.revision._id, @@ -210,7 +219,9 @@ export const useUpdateStateAfterSave = (pageId: string|undefined|null): (() => P }; setRemoteLatestPageData(remoterevisionData); - }, [mutateCurrentPage, mutateCurrentPageId, mutateEditingMarkdown, mutateTagsInfo, pageId, setRemoteLatestPageData, syncTagsInfoForEditor]); + }, + // eslint-disable-next-line max-len + [pageId, mutateTagsInfo, syncTagsInfoForEditor, mutateCurrentPageId, mutateCurrentPage, opts?.supressEditingMarkdownMutation, setRemoteLatestPageData, mutateEditingMarkdown]); }; export const unlink = async(path: string): Promise => { diff --git a/apps/app/src/components/PageEditor.tsx b/apps/app/src/components/PageEditor.tsx index ecea4c872e0..93c9b7dd4d4 100644 --- a/apps/app/src/components/PageEditor.tsx +++ b/apps/app/src/components/PageEditor.tsx @@ -108,7 +108,7 @@ const PageEditor = React.memo((): JSX.Element => { const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning(); const saveOrUpdate = useSaveOrUpdate(); - const updateStateAfterSave = useUpdateStateAfterSave(pageId); + const updateStateAfterSave = useUpdateStateAfterSave(pageId, { supressEditingMarkdownMutation: true }); const currentRevisionId = currentPage?.revision?._id;