BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

How to disable sideMenu at top block (index 0)

Open Gr4vity4 opened this issue 1 year ago • 1 comments

inspiration from notion title, at the top can't delete or change props, I tried to use getTextCursorPosition() method with simple watching instance with setInterval() then setState but still doesn't work

<BlockNoteView
  editor={editor}
  theme={"light"}
  onChange={() => {
    syncToCloud(editor.document);
  }}
  slashMenu={false}
  sideMenu={false}
>
  {/* {controlSideMenu && (
    <SideMenuController
      sideMenu={(props) => (
        <SideMenu {...props}>
          <DragHandleButton {...props} />
        </SideMenu>
      )}
    />
  )} */}

  {/* Replaces the default Slash Menu. */}
  <SuggestionMenuController
    triggerCharacter={"/"}
    getItems={async (query) =>
      // Gets all default slash menu items and `insertMarkdown` item.
      filterSuggestionItems(
        [
          ...getDefaultReactSlashMenuItems(editor),
          insertMarkdown(editor),
          insertMarkdownCompact(editor),
          insertAsk(editor),
        ],
        query
      )
    }
  />
</BlockNoteView>

Gr4vity4 avatar Apr 20 '24 11:04 Gr4vity4

Would love a solution for this

virus2016 avatar May 16 '24 11:05 virus2016

This should work:

<BlockNoteView editor={editor} sideMenu={false}>
  <SideMenuController
    sideMenu={(props) => {
      if (props.block.id === editor.document[0].id) {
        return null;
      }

      return (
        <SideMenu {...props}>
          <AddBlockButton {...props} />
          <DragHandleButton {...props} />
        </SideMenu>
      );
    }}
  />
</BlockNoteView>

matthewlipski avatar Jun 11 '24 11:06 matthewlipski

You can use something similar for the other menus, just have to use editor.getTextCursorPosition().block instead of props.block.

matthewlipski avatar Jun 11 '24 11:06 matthewlipski