How can you change editable
after initialisation?
#966
-
I know we can set My question is: How can we change this value after initialisation? I use React and I've passed a state variable into editable but it doesn't update automatically. Ideally I'm looking for a command such as: |
Beta Was this translation helpful? Give feedback.
Answered by
abhinandshibu
Apr 6, 2023
Replies: 1 comment 2 replies
-
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]) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
abhinandshibu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found a solution: