Skip to content

Added editor option to disable nested blocks#408

Open
abasse wants to merge 7 commits intoTypeCellOS:mainfrom
abasse:main
Open

Added editor option to disable nested blocks#408
abasse wants to merge 7 commits intoTypeCellOS:mainfrom
abasse:main

Conversation

@abasse
Copy link
Copy Markdown

@abasse abasse commented Nov 6, 2023

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> }>;

@vercel
Copy link
Copy Markdown

vercel bot commented Nov 6, 2023

Someone is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel bot commented Nov 6, 2023

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

@matthewlipski
Copy link
Copy Markdown
Collaborator

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:

  1. Prevent nesting at the schema level - the blockContainer node currently has content: "blockContent blockGroup?", meaning you can place a blockContent node in it, and optionally a blockGroup node for nested blocks. If the canNestBlock option is true, we should change this to content: "blockContent" and make sure everything still works.
  2. Edit the definitions of editor.canNestBlock and editor.canUnnestBlock to just return false if the canNestBlock option is true.

@abasse
Copy link
Copy Markdown
Author

abasse commented Nov 9, 2023

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:

  1. Prevent nesting at the schema level - the blockContainer node currently has content: "blockContent blockGroup?", meaning you can place a blockContent node in it, and optionally a blockGroup node for nested blocks. If the canNestBlock option is true, we should change this to content: "blockContent" and make sure everything still works.
  2. Edit the definitions of editor.canNestBlock and editor.canUnnestBlock to just return false if the canNestBlock option 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?

@abasse
Copy link
Copy Markdown
Author

abasse commented Nov 14, 2023

The editor option is now called "enableNestedBlocks" to avoid conflicts with the existing function with the same name.

@NicHaley
Copy link
Copy Markdown

I'm looking to disable nesting as well

@jueinin
Copy link
Copy Markdown

jueinin commented Jun 27, 2024

@NicHaley #876 maybe you can view this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants