@@ -519,7 +519,7 @@ index 0000000000000000000000000000000000000000..8939eeae75b5f0fab4cf12fe43bdb03f
519519+ declare type SyncPluginStateUpdate = import('lib0/schema').Unwrap<typeof import('@y/prosemirror').$syncPluginStateUpdate>
520520+ declare type ProsemirrorDelta = import('lib0/schema').Unwrap<typeof import('@y/prosemirror').$prosemirrorDelta>
521521diff --git a/package.json b/package.json
522- index 8eaef6bf2b216933047f528e3c3b0aa469df45e7..99ea779e7487cdc459ca93c65a8e84febb679091 100644
522+ index 8eaef6bf2b216933047f528e3c3b0aa469df45e7..258a3b18cc50c11181b70a716953fdb1708bf840 100644
523523--- a/package.json
524524+++ b/package.json
525525@@ -2,10 +2,7 @@
@@ -565,7 +565,7 @@ index 8eaef6bf2b216933047f528e3c3b0aa469df45e7..99ea779e7487cdc459ca93c65a8e84fe
565565 "peerDependencies": {
566566- "@y/protocols": "^1.0.6-3",
567567+ "@y/protocols": "^1.0.6-rc.1",
568- + "@y/y": "^14.0.0-rc.16 ",
568+ + "@y/y": "^14.0.0-rc.17 ",
569569 "prosemirror-model": "^1.7.1",
570570 "prosemirror-state": "^1.2.3",
571571- "prosemirror-view": "^1.9.10",
@@ -2292,7 +2292,7 @@ index 0000000000000000000000000000000000000000..e9444af4c344c486bb7ba7255bcd26f4
22922292+ }
22932293diff --git a/src/sync-utils.js b/src/sync-utils.js
22942294new file mode 100644
2295- index 0000000000000000000000000000000000000000..bb1ef1b4b4cfdb808410929cb8f848301a1b8307
2295+ index 0000000000000000000000000000000000000000..582bf01bb5ccd524f4c56d2edcf3a49f1f144433
22962296--- /dev/null
22972297+++ b/src/sync-utils.js
22982298@@ -0,0 +1,573 @@
@@ -2303,7 +2303,7 @@ index 0000000000000000000000000000000000000000..bb1ef1b4b4cfdb808410929cb8f84830
23032303+ import * as math from 'lib0/math'
23042304+ import * as object from 'lib0/object'
23052305+ import * as s from 'lib0/schema'
2306- + import { Node } from 'prosemirror-model'
2306+ + import { Node, Slice, Fragment } from 'prosemirror-model'
23072307+ import {
23082308+ AddMarkStep,
23092309+ AddNodeMarkStep,
@@ -2608,10 +2608,10 @@ index 0000000000000000000000000000000000000000..bb1ef1b4b4cfdb808410929cb8f84830
26082608+ currPos.i = childStart + child.nodeSize + netChange
26092609+ } else if (delta.$insertOp.check(op)) {
26102610+ const newPChildren = op.insert.map(ins => deltaToPNode(ins, schema, op.format))
2611- + tr.insert( currPos.i, newPChildren)
2611+ + tr.step(new ReplaceStep( currPos.i, currPos.i, new Slice(Fragment.from( newPChildren), 0, 0)) )
26122612+ currPos.i += newPChildren.reduce((s, c) => c.nodeSize + s, 0)
26132613+ } else if (delta.$textOp.check(op)) {
2614- + tr.insert( currPos.i, schema.text(op.insert, formattingAttributesToMarks(op.format, schema)))
2614+ + tr.step(new ReplaceStep( currPos.i, currPos.i, new Slice(Fragment.from( schema.text(op.insert, formattingAttributesToMarks(op.format, schema))), 0, 0 )))
26152615+ currPos.i += op.length
26162616+ } else if (delta.$deleteOp.check(op)) {
26172617+ for (let remainingDelLen = op.delete; remainingDelLen > 0;) {
@@ -2621,7 +2621,7 @@ index 0000000000000000000000000000000000000000..bb1ef1b4b4cfdb808410929cb8f84830
26212621+ }
26222622+ if (pc.isText) {
26232623+ const delLen = math.min(pc.nodeSize - nOffset, remainingDelLen)
2624- + tr.delete( currPos.i, currPos.i + delLen)
2624+ + tr.step(new ReplaceStep( currPos.i, currPos.i + delLen, Slice.empty) )
26252625+ nOffset += delLen
26262626+ if (nOffset === pc.nodeSize) {
26272627+ // TODO this can't actually "jump out" of the current node
@@ -2631,7 +2631,7 @@ index 0000000000000000000000000000000000000000..bb1ef1b4b4cfdb808410929cb8f84830
26312631+ }
26322632+ remainingDelLen -= delLen
26332633+ } else {
2634- + tr.delete( currPos.i, currPos.i + pc.nodeSize)
2634+ + tr.step(new ReplaceStep( currPos.i, currPos.i + pc.nodeSize, Slice.empty) )
26352635+ currParentIndex++
26362636+ remainingDelLen--
26372637+ }
0 commit comments