Handle disabled editor after version publishing
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -64,7 +64,13 @@ const extensions = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const richEditorVariants = tv({
|
const richEditorVariants = tv({
|
||||||
base: ["relative h-full pl-14"],
|
base: ["relative h-full"],
|
||||||
|
variants: {
|
||||||
|
disabled: {
|
||||||
|
true: "",
|
||||||
|
false: "pl-14",
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
type RichEditorProps = ComponentProps<"div"> & {
|
type RichEditorProps = ComponentProps<"div"> & {
|
||||||
@@ -103,10 +109,18 @@ export function RichEditor(props: RichEditorProps) {
|
|||||||
}
|
}
|
||||||
}, [content, watchedContent, onChangeContent]);
|
}, [content, watchedContent, onChangeContent]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!editor) return;
|
||||||
|
editor.setEditable(!disabled);
|
||||||
|
}, [editor, disabled]);
|
||||||
|
|
||||||
if (!editor) return null;
|
if (!editor) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={richEditorVariants({ className })}>
|
<div className={richEditorVariants({ className, disabled })}>
|
||||||
|
{!disabled
|
||||||
|
&& (
|
||||||
|
<>
|
||||||
<BubbleMenu editor={editor} />
|
<BubbleMenu editor={editor} />
|
||||||
<BlockMenu editor={editor} />
|
<BlockMenu editor={editor} />
|
||||||
<OptionsMenu editor={editor} />
|
<OptionsMenu editor={editor} />
|
||||||
@@ -114,6 +128,9 @@ export function RichEditor(props: RichEditorProps) {
|
|||||||
<TableCellMenu editor={editor} />
|
<TableCellMenu editor={editor} />
|
||||||
<TableColumnMenu editor={editor} />
|
<TableColumnMenu editor={editor} />
|
||||||
<TableRowMenu editor={editor} />
|
<TableRowMenu editor={editor} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<EditorContent className="h-full" editor={editor} />
|
<EditorContent className="h-full" editor={editor} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user