BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Support for excluding any block

Open i-am-chitti opened this issue 10 months ago • 1 comments

Is your feature request related to a problem? Please describe. Currently, defaultBlockSpecs has heading, paragraph, bulletListItem, numberedListItem, image and table. So, when a editor is rendered, one can choose any of these blocks. But it would be great to provide ability to exclude some of the default blocks. For example, exclude the image block. A user should not be able to use an image block.

Describe the solution you'd like Haven't thought. Let's discuss and deduce a solution.

Describe alternatives you've considered Tried the schema with excluded image block in defaultBlockSpecs but it didn't work.

Additional context None

i-am-chitti avatar Apr 06 '24 11:04 i-am-chitti

I thought your listed alternative should work. We'll check this out and add a related example.

Related: https://github.com/TypeCellOS/BlockNote/issues/401

YousefED avatar Apr 08 '24 07:04 YousefED

I'm using lodash's omit to remove checkListItem block from my definition:

const schema = BlockNoteSchema.create({
  blockSpecs: {
    ...omit(defaultBlockSpecs, ["checkListItem"]),
    ...moreTypes
  }
})

This prevents check list blocks from being included. You could achieve the same thing w/o omit

sb8244 avatar Jul 20 '24 22:07 sb8244

See this example: https://www.blocknotejs.org/examples/basic/removing-default-blocks

YousefED avatar Jul 29 '24 13:07 YousefED