@lexical/yjs 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LexicalYjs.dev.js +10 -2
- package/LexicalYjs.prod.js +1 -1
- package/package.json +3 -3
package/LexicalYjs.dev.js
CHANGED
|
@@ -73,7 +73,6 @@ function $createCollabLineBreakNode(map, parent) {
|
|
|
73
73
|
*
|
|
74
74
|
*
|
|
75
75
|
*/
|
|
76
|
-
|
|
77
76
|
function simpleDiffWithCursor(a, b, cursor) {
|
|
78
77
|
const aLength = a.length;
|
|
79
78
|
const bLength = b.length;
|
|
@@ -104,6 +103,15 @@ function simpleDiffWithCursor(a, b, cursor) {
|
|
|
104
103
|
};
|
|
105
104
|
}
|
|
106
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the MIT license found in the
|
|
110
|
+
* LICENSE file in the root directory of this source tree.
|
|
111
|
+
*
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
|
|
107
115
|
function diffTextContentAndApplyDelta(collabNode, key, prevText, nextText) {
|
|
108
116
|
const selection = lexical.$getSelection();
|
|
109
117
|
let cursorOffset = nextText.length;
|
|
@@ -464,7 +472,7 @@ function getPositionFromElementAndOffset(node, offset, boundaryIsEdge) {
|
|
|
464
472
|
textOffset = 0;
|
|
465
473
|
}
|
|
466
474
|
|
|
467
|
-
const diffLength =
|
|
475
|
+
const diffLength = index - offset;
|
|
468
476
|
return {
|
|
469
477
|
length: diffLength,
|
|
470
478
|
node: child,
|
package/LexicalYjs.prod.js
CHANGED
|
@@ -14,7 +14,7 @@ return c}
|
|
|
14
14
|
function Q(a,b,c){const d=b._collabNode;if(void 0===d){var e=a.editor._nodes;const f=b instanceof w.Map?b.get("__type"):b.getAttribute("__type");if(null==f)throw Error("Should never happen");if(void 0===e.get(f))throw Error("Should never happen");e=b.parent;a=void 0===c&&null!==e?Q(a,e):c||null;if(!(a instanceof R))throw Error("Should never happen");if(b instanceof w.XmlText)return N(b,a,f);if(b instanceof w.Map){if(null===a)throw Error("Should never happen");return"linebreak"===f?C(b,a):I(b,"",a,
|
|
15
15
|
f)}if(b instanceof w.XmlElement)return P(b,a,f)}return d}function H(a,b,c,d){d=null===d?b instanceof w.Map?Array.from(b.keys()):Object.keys(b.getAttributes()):Array.from(d);let e;for(let g=0;g<d.length;g++){const h=d[g];if(K.has(h))continue;var f=c[h];let k=b instanceof w.Map?b.get(h):b.getAttribute(h);if(f!==k){if(k instanceof w.Doc){const m=a.docMap;f instanceof w.Doc&&m.delete(f.guid);f=q.createEditor();const l=k.guid;f._key=l;m.set(l,k);k=f}void 0===e&&(e=c.getWritable());e[h]=k}}}
|
|
16
16
|
function G(a,b,c,d){var e=d.__type,f=a.nodeProperties;let g=f.get(e);void 0===g&&(g=Object.keys(d).filter(k=>!K.has(k)),f.set(e,g));e=a.editor.constructor;for(f=0;f<g.length;f++){const k=g[f];var h=null===c?void 0:c[k];let m=d[k];if(h!==m){if(m instanceof e){const l=a.docMap;let t;h instanceof e&&(h=h._key,t=l.get(h),l.delete(h));h=t||new w.Doc;const u=h.guid;m._key=u;l.set(u,h);m=h;a.editor.update(()=>{d.markDirty()})}b instanceof w.Map?b.set(k,m):b.setAttribute(k,m)}}}
|
|
17
|
-
function S(a,b,c){let d=0,e=0;const f=a._children,g=f.length;for(;e<g;e++){a=f[e];const h=d,k=a.getSize();d+=k;if((c?d>=b:d>b)&&a instanceof D)return
|
|
17
|
+
function S(a,b,c){let d=0,e=0;const f=a._children,g=f.length;for(;e<g;e++){a=f[e];const h=d,k=a.getSize();d+=k;if((c?d>=b:d>b)&&a instanceof D)return c=b-h-1,0>c&&(c=0),{length:d-b,node:a,nodeIndex:e,offset:c};if(d>b)return{length:0,node:a,nodeIndex:e,offset:h};if(e===g-1)return{length:0,node:null,nodeIndex:e+1,offset:h+1}}return{length:0,node:null,nodeIndex:0,offset:0}}
|
|
18
18
|
function T(a){const b=a.anchor;a=a.focus;let c=!1;try{const d=b.getNode(),e=a.getNode();if(!d.isAttached()||!e.isAttached()||q.$isTextNode(d)&&b.offset>d.getTextContentSize()||q.$isTextNode(e)&&a.offset>e.getTextContentSize())c=!0}catch(d){c=!0}return c}function aa(a,b){a.doc.transact(b,a)}
|
|
19
19
|
class U{constructor(a,b,c){this._key="";this._xmlElem=a;this._parent=b;this._type=c;this._unobservers=new Set}getPrevNode(a){if(null===a)return null;a=a.get(this._key);return q.$isDecoratorNode(a)?a:null}getNode(){const a=q.$getNodeByKey(this._key);return q.$isDecoratorNode(a)?a:null}getSharedType(){return this._xmlElem}getType(){return this._type}getKey(){return this._key}getSize(){return 1}getOffset(){return this._parent.getChildOffset(this)}syncPropertiesFromLexical(a,b,c){c=this.getPrevNode(c);
|
|
20
20
|
G(a,this._xmlElem,c,b)}syncPropertiesFromYjs(a,b){const c=this.getNode();if(null===c)throw Error("Should never happen");H(a,this._xmlElem,c,b)}destroy(a){a.collabNodeMap.delete(this._key);this._unobservers.forEach(b=>b());this._unobservers.clear()}}function P(a,b,c){b=new U(a,b,c);return a._collabNode=b}
|
package/package.json
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"crdt"
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"version": "0.2.
|
|
14
|
+
"version": "0.2.5",
|
|
15
15
|
"main": "LexicalYjs.js",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/offset": "0.2.
|
|
17
|
+
"@lexical/offset": "0.2.5"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"lexical": "0.2.
|
|
20
|
+
"lexical": "0.2.5",
|
|
21
21
|
"yjs": ">=13.5.22"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|