mirror of
https://github.com/docmost/docmost.git
synced 2026-05-17 23:14:07 +08:00
fix editable state
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
onAuthenticationFailedParameters,
|
onAuthenticationFailedParameters,
|
||||||
WebSocketStatus,
|
WebSocketStatus,
|
||||||
} from "@hocuspocus/provider";
|
} from "@hocuspocus/provider";
|
||||||
import { EditorContent, EditorProvider, useEditor } from "@tiptap/react";
|
import { EditorContent, EditorProvider, useEditor, useEditorState } from "@tiptap/react";
|
||||||
import {
|
import {
|
||||||
collabExtensions,
|
collabExtensions,
|
||||||
mainExtensions,
|
mainExtensions,
|
||||||
@@ -257,6 +257,14 @@ export default function PageEditor({
|
|||||||
},
|
},
|
||||||
[pageId, editable, remoteProvider],
|
[pageId, editable, remoteProvider],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Track editor's editable state since shouldRerenderOnTransaction is false
|
||||||
|
const editorIsEditable = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: ctx => {
|
||||||
|
return ctx.editor?.isEditable ?? false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const debouncedUpdateContent = useDebouncedCallback((newContent: any) => {
|
const debouncedUpdateContent = useDebouncedCallback((newContent: any) => {
|
||||||
const pageData = queryClient.getQueryData<IPage>(["pages", slugId]);
|
const pageData = queryClient.getQueryData<IPage>(["pages", slugId]);
|
||||||
@@ -390,7 +398,7 @@ export default function PageEditor({
|
|||||||
<SearchAndReplaceDialog editor={editor} editable={editable} />
|
<SearchAndReplaceDialog editor={editor} editable={editable} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{editor && editor.isEditable && (
|
{editor && editorIsEditable && (
|
||||||
<div>
|
<div>
|
||||||
<EditorBubbleMenu editor={editor} />
|
<EditorBubbleMenu editor={editor} />
|
||||||
<TableMenu editor={editor} />
|
<TableMenu editor={editor} />
|
||||||
|
|||||||
Reference in New Issue
Block a user