Include final retain in tree deltas - #27809
Conversation
…ug with last new line
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (460 lines, 12 files), I've queued these reviewers:
How this works
|
Bundle size comparisonBase commit: Notable changesNo bundles changed by ≥ 500 bytes parsed. Per-bundle deltas
|
| }; | ||
| } | ||
|
|
||
| function lineAtomToQuillAttributes( |
| if (remainingQuillContent.length > 0) { | ||
| assert( | ||
| remainingQuillContent === "\n", | ||
| "Expected only Quill's mandatory terminal newline to remain", | ||
| ); | ||
| quillOps.push({ delete: 1 }); | ||
| } | ||
| if (!root.fullString().endsWith("\n")) { | ||
| quillOps.push({ insert: "\n" }); | ||
| } |
There was a problem hiding this comment.
Nit: some docs here would probably be useful
| function getArrayLength(arrayNodeKernel: TreeNodeKernel): number { | ||
| return arrayNodeKernel.getInnerNode().getBoxed(EmptyKey).length; | ||
| } | ||
|
|
There was a problem hiding this comment.
I'm assuming there's no stricter typing we can use here? If not, some docs would probably be good.
| it("keeps remote editor DOM in sync after a user edit", () => { | ||
| const text = TextAsTree.Tree.fromString(""); | ||
| const root = toPropTreeNode(text); | ||
| const rendered = render( | ||
| <> | ||
| <ViewComponent root={root} /> | ||
| <ViewComponent root={root} /> | ||
| </>, | ||
| { reactStrictMode }, | ||
| ); | ||
| const sourceContainer = | ||
| rendered.container.querySelector<HTMLElement>(".ql-container"); | ||
| const editors = rendered.container.querySelectorAll<HTMLElement>(".ql-editor"); | ||
| const sourceEditor = editors[0]; | ||
| const remoteEditor = editors[1]; | ||
| assert.ok( | ||
| sourceContainer !== null && | ||
| sourceEditor !== undefined && | ||
| remoteEditor !== undefined, | ||
| ); | ||
| const source = Quill.find(sourceContainer) as Quill; | ||
|
|
||
| source.setText("Hello", "user"); | ||
|
|
||
| assert.equal(sourceEditor.innerHTML, "<p>Hello</p>"); | ||
| assert.equal(remoteEditor.innerHTML, sourceEditor.innerHTML); | ||
|
|
||
| source.setText("Hello\nWorld", "user"); | ||
|
|
||
| assert.equal(sourceEditor.innerHTML, "<p>Hello</p><p>World</p>"); | ||
| assert.equal(remoteEditor.innerHTML, sourceEditor.innerHTML); | ||
| }); |
There was a problem hiding this comment.
Nit: some docs in here would be useful
| it("keeps remote editor DOM in sync after a user edit", () => { | ||
| const { tree } = createFormattedTreeView(); | ||
| const root = toPropTreeNode(tree); | ||
| const rendered = render( | ||
| <> | ||
| <FormattedMainView root={root} /> | ||
| <FormattedMainView root={root} /> | ||
| </>, | ||
| { reactStrictMode }, | ||
| ); | ||
| const sourceContainer = | ||
| rendered.container.querySelector<HTMLElement>(".ql-container"); | ||
| const editors = rendered.container.querySelectorAll<HTMLElement>(".ql-editor"); | ||
| const sourceEditor = editors[0]; | ||
| const remoteEditor = editors[1]; | ||
| assert.ok( | ||
| sourceContainer !== null && | ||
| sourceEditor !== undefined && | ||
| remoteEditor !== undefined, | ||
| ); | ||
| const source = Quill.find(sourceContainer) as Quill; | ||
|
|
||
| source.setText("Hello", "user"); | ||
|
|
||
| assert.equal(sourceEditor.innerHTML, "<p>Hello</p>"); | ||
| assert.equal(remoteEditor.innerHTML, sourceEditor.innerHTML); | ||
|
|
||
| source.formatLine(0, source.getLength(), "list", "bullet", "user"); | ||
|
|
||
| assert.match(sourceEditor.innerHTML, /^<ol>/); | ||
| assert.equal(remoteEditor.innerHTML, sourceEditor.innerHTML); | ||
| }); |
There was a problem hiding this comment.
Nit: some docs in here would be useful
## Description While authoring #27809 I had to make some assumptions about deltas, which were undocumented. This fills in the missing documentation.
Description
Previously our array node deltas were not required to include the final retain. This is now alwayse included.
Addationally handling of the extra new line required to make quill a happe is now more robust, fixing a buig where remote copllaborators should end up with extra new lines.
Reviewer Guidance
The review process is outlined on this wiki page.