Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable sideMenu at top block (index 0) #709

Closed
Gr4vity4 opened this issue Apr 20, 2024 · 3 comments
Closed

How to disable sideMenu at top block (index 0) #709

Gr4vity4 opened this issue Apr 20, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Gr4vity4
Copy link

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 Gr4vity4 added the enhancement New feature or request label Apr 20, 2024
@virus2016
Copy link

Would love a solution for this

@matthewlipski
Copy link
Collaborator

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants