Skip to content

how to disable nest or unnest feature? #876

@jueinin

Description

@jueinin

Due to some special reasons, I need to disable the nest feature.

I customized the toolbar to remove the nest unNest button. However, I still can't get rid of the Tab and Shift Tab shortcuts.
I found that the shortcut code is written in the blockContainer, and I intended to disable it through the extend method, with the code as follows:

import {BlockContainer} from "@blocknote/core/src/pm-nodes";

const newBlockContainer = BlockContainer.extend({
  addKeyboardShortcuts() {
    const obj = this.parent?.() || {};
    delete obj.Tab
    delete obj['Shift-Tab']
    return obj
  }
})
export default function App() {

  const editor = useCreateBlockNote({
    _tiptapOptions: {
      extensions: [
        newBlockContainer.configure({
          editor, // the editor has not been initialized
          domAttributes: {},
        })
      ]
    },
    disableExtensions: ['blockContainer'],


  });
  return <BlockNoteView editor={editor} />;
}

However, the issue lies in the fact that the configure method requires the editor object, which, at this point, has not been fully initialized, leading to an error. In this scenario, perhaps the tiptapOptions could be a function instead?

_tiptapOptions: (editor) => Partial<EditorOptions>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions