Skip to content

How can you change editable after initialisation? #966

Closed Answered by abhinandshibu
abhinandshibu asked this question in Q&A
Discussion options

You must be logged in to vote

Found a solution:

const editableRef = React.useRef(editable);
const { get } = useEditor((root) =>
    Editor.make()
      .config(nord)
      .config(async (ctx) => {
        ctx.set(rootCtx, root);
        ctx.set(editorViewOptionsCtx, { editable: () => editableRef.current });
      }));

useEffect(() => {
    editableRef.current = editable;
 }, [editable])

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@adaboese
Comment options

@abhinandshibu
Comment options

Answer selected by abhinandshibu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants