BlockNote
BlockNote copied to clipboard
Added editor option to disable nested blocks
This PR adds an option to the editor to disable nested blocks. (on tab command or via formatting toolbar)
example configuration "canNestBlock":
export type BlockNoteEditorOptions = Partial<{ editable: boolean; canNestBlock: boolean; initialContent: PartialBlock[]; editorDOMAttributes: Record<string, string>; onEditorReady: (editor: BlockNoteEditor) => void; onEditorContentChange: (editor: BlockNoteEditor) => void; onTextCursorPositionChange: (editor: BlockNoteEditor) => void; slashMenuItems: ReactSlashMenuItem[]; defaultStyles: boolean; uploadFile: (file: File) => Promise<string> }>;
Someone is attempting to deploy a commit to the TypeCell Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated (UTC) |
|---|---|---|---|
| blocknote | ❌ Failed (Inspect) | Nov 6, 2023 3:28pm |
Looks good! Though these changes will still let you nest/unnest blocks programatically, e.g. using the formatting toolbar. I think we need 2 more things before we merge this:
- Prevent nesting at the schema level - the
blockContainernode currently hascontent: "blockContent blockGroup?", meaning you can place ablockContentnode in it, and optionally ablockGroupnode for nested blocks. If thecanNestBlockoption is true, we should change this tocontent: "blockContent"and make sure everything still works. - Edit the definitions of
editor.canNestBlockandeditor.canUnnestBlockto just return false if thecanNestBlockoption is true.
Looks good! Though these changes will still let you nest/unnest blocks programatically, e.g. using the formatting toolbar. I think we need 2 more things before we merge this:
- Prevent nesting at the schema level - the
blockContainernode currently hascontent: "blockContent blockGroup?", meaning you can place ablockContentnode in it, and optionally ablockGroupnode for nested blocks. If thecanNestBlockoption is true, we should change this tocontent: "blockContent"and make sure everything still works.- Edit the definitions of
editor.canNestBlockandeditor.canUnnestBlockto just return false if thecanNestBlockoption is true.
Thanks for the feedback! I had a look at the code, but I'm not really sure where to start. Is that something you would be able to look at?
The editor option is now called "enableNestedBlocks" to avoid conflicts with the existing function with the same name.
I'm looking to disable nesting as well
@NicHaley https://github.com/TypeCellOS/BlockNote/issues/876 maybe you can view this