Disable RichEditor on non draft version
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -31,6 +31,7 @@ export const documentDescriptionPageQuery = graphql`
|
|||||||
... on DocumentVersion {
|
... on DocumentVersion {
|
||||||
id
|
id
|
||||||
content
|
content
|
||||||
|
status
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document: node(id: $documentId) {
|
document: node(id: $documentId) {
|
||||||
@@ -42,6 +43,7 @@ export const documentDescriptionPageQuery = graphql`
|
|||||||
node {
|
node {
|
||||||
id
|
id
|
||||||
content
|
content
|
||||||
|
status
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,6 +120,7 @@ export function DocumentDescriptionPage(props: { queryRef: PreloadedQuery<Docume
|
|||||||
<div>
|
<div>
|
||||||
<RichEditor
|
<RichEditor
|
||||||
content={currentVersion.content}
|
content={currentVersion.content}
|
||||||
|
disabled={currentVersion.status !== "DRAFT"}
|
||||||
onChange={handleUpdate}
|
onChange={handleUpdate}
|
||||||
/>
|
/>
|
||||||
{/* <Markdown content={currentVersion.content} /> */}
|
{/* <Markdown content={currentVersion.content} /> */}
|
||||||
|
|||||||
@@ -79,13 +79,15 @@ function MenuButton({ label, active, onClick }: MenuButtonProps) {
|
|||||||
|
|
||||||
interface RichEditorProps {
|
interface RichEditorProps {
|
||||||
content: string;
|
content: string;
|
||||||
|
disabled?: boolean;
|
||||||
onChange: (content: string) => void;
|
onChange: (content: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RichEditor(props: RichEditorProps) {
|
export function RichEditor(props: RichEditorProps) {
|
||||||
const { content, onChange } = props;
|
const { content, disabled = false, onChange } = props;
|
||||||
|
|
||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
|
editable: !disabled,
|
||||||
extensions,
|
extensions,
|
||||||
content: (content ? JSON.parse(content) : "") as Content,
|
content: (content ? JSON.parse(content) : "") as Content,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user