Skip to content

feat: React re-architecture - #270

Merged
matthewlipski merged 44 commits into
mainfrom
react-rearchitecture
Aug 1, 2023
Merged

matthewlipski merged 44 commits into
mainfrom
react-rearchitecture

Conversation

@matthewlipski

@matthewlipski matthewlipski commented Jul 10, 2023 •

Copy link
Copy Markdown
Collaborator

There are a number of issues with the current rendering implementation in React:

  • Each menu/toolbar is rendered under a separate root.
  • The editor is not immediately initialized upon calling useBlocknote, causing issues.
  • Each menu is attached to document.body instead of being a sibling to the editor.
  • The way in which factories are designed makes sense for a vanilla implementation, but using them for React is unintuitive.
  • Plugins have too much responsibility - they should only provide information for UI elements to render, but instead they also render the UI elements themselves.
  • Supplying custom menu/formatting components is done using the uiFactories option, which is kind of clunky.

This PR is a major rethink of how we create, render, and pass elements to the editor in React (also changes the vanilla implementation a bit).

@vercel

vercel Bot commented Jul 10, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote-website ✅ Ready (Inspect) Visit Preview Aug 1, 2023 7:47pm

@matthewlipski matthewlipski changed the title React re-architecture feat: React re-architecture Jul 10, 2023

@YousefED YousefED left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added number of comments. Will also create a separate PR with some fixes / changes.

About the overall architecture, I have following questions:

  • does it make sense that "static" things like "freezeMenu" are part of "state"? (sorry for opening up this discussion again, seems we're going a bit back and forth)
  • Plugin views are recreated indeed when other plugins are changed / added. This is by design in prosemirror, probably so that plugins can react to changes to the view that other plugins make. Although it works (see my separate PR that fixes the issues you ran into with this), I think it will be nicer (and faster) to register all plugins on editor instantation

After the comments have been addressed, lets discussed this including your bullets above that haven't been addressed yet

Comment thread packages/core/src/BlockNoteEditor.ts Resolved
Comment thread packages/website/docs/docs/side-menu.md Resolved
Comment thread packages/website/docs/docs/side-menu.md Resolved
Comment thread packages/website/docs/docs/side-menu.md Resolved
* fix initialcontent and uniqueid

* fix

* Removed ready check in `BlockNoteView`

---------

Co-authored-by: Matthew Lipski <matthewlipski@gmail.com>
Comment thread packages/website/docs/docs/side-menu.md Resolved

This branch was successfully deployed

1 active deployment
Preview – blocknote-website — c034cd1d Deployed Aug 1, 2023 by vercel[bot]
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.

2 participants