TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.
https://www.blocknotejs.org/
Mozilla Public License 2.0
5.9k stars 384 forks source link

architecture: fix contentcomponent mounting #832

Open YousefED opened 3 weeks ago

YousefED commented 3 weeks ago

Our EditorContent is a replacement for Tiptaps editorcontent. Although it cleans the original implementation quite a bit, there still seem to be some problems in how it's setup. See:

closes https://github.com/TypeCellOS/BlockNote/issues/750 closes https://github.com/TypeCellOS/BlockNote/issues/732

(Note that a workaround has been implemented here (#788), but I think that should actually be reverted when working on this issue (contentComponent should not be undefined whenever we call renderToDOMSpec).

My first thoughts are that we should clean the way the contentcomponent is set on the tiptap editor.

Ideas of better approach (open to suggestions): a) useImperativeHandle instead of useEffect in EditorContent b) when this EditorContent ref is available (in BlockNoteView) set it on the editor (as contentComponent) c) only calleditor._tiptapEditor.mount` after step (b)

Of course, also need to take cleanup into account