TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.
https://www.blocknotejs.org/
Mozilla Public License 2.0
5.9k stars 384 forks source link

In custom blocks , how can I disable the menu when editable is false. #823

Closed Akshdhiwar closed 3 weeks ago

Akshdhiwar commented 3 weeks ago

I am trying to make a custom block as per the docs and now I want when the editable is false I don't want the user to access any of the input fields of the custom block.

As of now I'm referring to this docs to create custom block ( Alert block that is shown in docs)

So their is a menu which is been implemented which I don't want user to interact when editable is false.

image

<BlockNoteView
          editor={editor}
          editable={false}
          onChange={() => {
            // Saves the document JSON to state.
            setBlocks(editor.document);
          }}
        />

So is their anything I'm missing out ? Is there any way I can know the editable is false and disable the menu ??

So need help regarding this , any leads would be appreciated! Thanks.

matthewlipski commented 3 weeks ago

In the render function of your component you have access to block and editor, so you can use editor.isEditable to check whether you want to show or hide the block's menus or input fields. Hope that helps!

Akshdhiwar commented 3 weeks ago

Thanks @matthewlipski for helping , working fine with props.editor.editable .