Skip to content

Commit

Permalink
Normalize editor on connect
Browse files Browse the repository at this point in the history
  • Loading branch information
BitPhinix committed Oct 15, 2022
1 parent 12fdb18 commit aa10864
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rotten-months-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@slate-yjs/core': patch
---

Normalize editor on connect to avoid rendering denormalized state
6 changes: 5 additions & 1 deletion packages/core/src/plugins/withYjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ export function withYjs<T extends Editor>(
const content = yTextToSlateElement(e.sharedRoot);
e.children = content.children;
CONNECTED.add(e);
e.onChange();

Editor.normalize(editor, { force: true });
if (!editor.operations.length) {
editor.onChange();
}
};

e.disconnect = () => {
Expand Down

0 comments on commit aa10864

Please sign in to comment.