* Refactor: extract `setRenderer` and `removeRenderer` methods
* Refactor: avoid using a mutable ES6 Map in React component state
The React docs recommend treating the `state` as immutable. See e.g.:
https://reactjs.org/docs/react-component.html#state
* Fix: flush EditorContent state changes immediately once initialized
This fixes the cursor problem described in tiptap#3200
Node views need to be rendered immediately when they're created so that
the editor can correctly position the cursor. That's achieved using
`flushSync` whenever a new node view renderer is added.
However, `flushSync` cannot be used from inside a React component
lifecycle method.
By keeping an instance variable to determine if initialization has
happened, we can avoid using `flushSync` from inside the `componentDidMount`
and `componentDidUpdate` methods, and still call it whenever a new node view
is created afterwards.
To avoid seeing the `Warning: flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.` error, we need to move the `flushSync()` code that avoids automatic batching to a microtask to not fire a lifecycle event `setState()` during rendering.
Fixes warning introduced in #2985
* refactor: upgrade prosemirror packages to new typescript versions
* refactor: migrate to new typings from prosemirror
* style: fix linting issues
* style: fix linting issues
* style: fix linting issues
* fix(ci): fix build process by reimplement filterTransaction
* fix(extension-test): fix broken build because of wrong output file names
* fix: fix prosemirror-tables not being bundled correctly for ES6
* fix: move to prosemirror-tables-contently until es6 build is working
* fix: fix tests for youtube
* fix: fix youtube test
* fix(demos): fix demos build
* Remove `element.current` from `useEffect` dependencies
Changes to the `element.current` don't trigger `useEffect` rerender and shouldn't be used in the dependency array.
One discussion about is this is for example here: https://stackoverflow.com/questions/60476155/is-it-safe-to-use-ref-current-as-useeffects-dependency-when-ref-points-to-a-dom
It's also causing some subtle bugs when mounting and unmounting editors.
* Fix `FloatingMenu` and `BubbleMenu` element references
* Fix linting errors
* Don't register plugin when the editor is already destroyed; Simplify `HTMLElement` reference handling
* Fix lint error
* Add `editor` dependency when registering `BubbleMenuPlugin`
When we are initializing editor via the `useEditor` hook with dependencies the `BubbleMenu` component is only registered the first time the editor is initialized.
Adding editor to the dependency array registering/unregistering the `BubbleMenuPlugin` fixes this. (I tested exactly this code in our project.)
I also added a check that ensures that the menu element referenced via the `useRef` is defined when registering the plugin - otherwise, there is no point in registering the plugin.
* Add `editor` dependency when registering `FloatingMenuPlugin`
* add key option to bubble menu
* ignore react for now
* add shouldShow option to bubble menu extension
* improve types
* remove BubbleMenuPluginKey
* add key and shouldShow option to floating menu extension
* fix: don’t show floating menu within code block
* docs: add new menu options