Skip to content

Putting a watcher on blocks add / edition / removal #1541

Closed
1 of 2 issues completed
Closed
@ClementEXWiki

Description

@ClementEXWiki

Is your feature request related to a problem? Please describe.
For a current project, I need to create some custom blocks that automatically change depending on the editor's content. One such block is a table of contents, which should be updated dynamically in real time as soon as headings are added / removed / modified anywhere in the editor.

Describe the solution you'd like
It would be extremely useful to have a way to observe some changes in the editor, specifically related to some block types. For instance, an API on the editor that runs a function as soon as a block of type heading is added / removed / modified.

Describe alternatives you've considered
There are alternatives but none are ideal:

  • Re-implementing the heading types (or other blocks if needed) and trigger an event manually when they are updated
  • Putting a listener on the editor to watch for any change, which would require to traverse the entire AST to find headings and make a diff against the previous state
  • Showing a button to manually refresh the ToC block's content, but this requires manual user interaction

Additional context
I gave an example with headings but it could really be anything else.

I have absolutely no idea how hard such a feature would be to implement in BlockNote

Sub-issues

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions