-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cursor not following to new node when using a react node view (#3331
) * 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.
- Loading branch information
Showing
3 changed files
with
54 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters