Skip to content

How do I control the 'editable: boolean' state via a button? #209

@jerrycompal

Description

@jerrycompal

How can I control the 'editable: boolean' state in real-time on an HTML page through a button?
Are there any sample codes related to this?
Here is my code, where did I make a mistake?

function App() { const [isEditable, setIsEditable] = useState(true); const editor: BlockNoteEditor | null = useBlockNote({ theme: "light", editable: isEditable, // ... }); const toggleEditable = () => { setIsEditable(!isEditable); } useEffect(() => { console.log(isEditable: ${isEditable}); console.log(editor); }, [isEditable, editor]); // ... return ( <div> <BlockNoteView editor={editor} /> <button onClick={toggleEditable}> {isEditable ? "Lock Editor" : "Unlock Editor"} </button> </div> );

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions