@lexical/yjs 0.3.5 → 0.3.8

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 CHANGED
@@ -1629,7 +1629,10 @@ function handleNormalizationMergeConflicts(binding, normalizedNodes) {
1629
1629
 
1630
1630
  for (let i = 0; i < mergedNodes.length; i++) {
1631
1631
  const [collabNode, text] = mergedNodes[i];
1632
- collabNode._text = text;
1632
+
1633
+ if (collabNode instanceof CollabTextNode && typeof text === 'string') {
1634
+ collabNode._text = text;
1635
+ }
1633
1636
  }
1634
1637
  }
1635
1638
 
@@ -39,8 +39,8 @@ null!==m)){t=l.length;m=y.createRectsFromDOMRange(q,m);q=m.length;for(p=0;p<q;p+
39
39
  void 0!==h&&(h=h.selection,null!==h&&U(a,h),b.delete(e)))}function fa(a,b,c,d){b=b.awareness;var e=b.getLocalState();if(null!==e){var {anchorPos:f,focusPos:h,name:g,color:k,focusing:l}=e,n=e=null;if(null!==d&&(null===f||d.is(c))||null!==c)r.$isRangeSelection(d)&&(e=S(d.anchor,a),n=S(d.focus,a)),(T(f,e)||T(h,n))&&b.setLocalState({anchorPos:e,color:k,focusPos:n,focusing:l,name:g})}}let ka=r.createCommand(),la=r.createCommand();exports.CONNECTED_COMMAND=ka;exports.TOGGLE_CONNECT_COMMAND=la;
40
40
  exports.createBinding=function(a,b,c,d,e){if(void 0===d||null===d)throw Error("Should never happen");b=d.get("root",v.XmlText);b=K(b,null,"root");b._key="root";return{clientID:d.clientID,collabNodeMap:new Map,cursors:new Map,cursorsContainer:null,doc:d,docMap:e,editor:a,id:c,nodeProperties:new Map,root:b}};exports.createUndoManager=function(a,b){return new v.UndoManager(b,{trackedOrigins:new Set([a,null])})};
41
41
  exports.initLocalState=function(a,b,c,d){a.awareness.setLocalState({anchorPos:null,color:c,focusPos:null,focusing:d,name:b})};exports.setLocalStateFocus=function(a,b,c,d){({awareness:a}=a);let e=a.getLocalState();null===e&&(e={anchorPos:null,color:c,focusPos:null,focusing:d,name:b});e.focusing=d;a.setLocalState(e)};exports.syncCursorPositions=X;
42
- exports.syncLexicalUpdateToYjs=function(a,b,c,d,e,f,h,g){ea(a,()=>{d.read(()=>{if(g.has("collaboration")){if(0<h.size){var k=Array.from(h),l=a.collabNodeMap,n=[];for(let p=0;p<k.length;p++){var q=k[p],t=r.$getNodeByKey(q),m=l.get(q);if(m instanceof D)if(r.$isTextNode(t))n.push([m,t.__text]);else{t=m.getOffset();if(-1===t)continue;let u=m._parent;m._normalized=!0;u._xmlText.delete(t,1);l.delete(q);q=u._children;m=q.indexOf(m);q.splice(m,1)}}for(k=0;k<n.length;k++){let [p,u]=n[k];p._text=u}}}else e.has("root")&&
43
- (n=c._nodeMap,k=r.$getRoot(),l=a.root,l.syncPropertiesFromLexical(a,k,n),l.syncChildrenFromLexical(a,k,n,e,f)),n=r.$getSelection(),fa(a,b,c._selection,n)})})};
42
+ exports.syncLexicalUpdateToYjs=function(a,b,c,d,e,f,h,g){ea(a,()=>{d.read(()=>{if(g.has("collaboration")){if(0<h.size){var k=Array.from(h),l=a.collabNodeMap,n=[];for(let p=0;p<k.length;p++){var q=k[p],t=r.$getNodeByKey(q),m=l.get(q);if(m instanceof D)if(r.$isTextNode(t))n.push([m,t.__text]);else{t=m.getOffset();if(-1===t)continue;let u=m._parent;m._normalized=!0;u._xmlText.delete(t,1);l.delete(q);q=u._children;m=q.indexOf(m);q.splice(m,1)}}for(k=0;k<n.length;k++){let [p,u]=n[k];p instanceof D&&"string"===
43
+ typeof u&&(p._text=u)}}}else e.has("root")&&(n=c._nodeMap,k=r.$getRoot(),l=a.root,l.syncPropertiesFromLexical(a,k,n),l.syncChildrenFromLexical(a,k,n,e,f)),n=r.$getSelection(),fa(a,b,c._selection,n)})})};
44
44
  exports.syncYjsChangesToLexical=function(a,b,c){let d=a.editor,e=d._editorState;d.update(()=>{var f=d._pendingEditorState;for(var h=0;h<c.length;h++){var g=a,k=c[h],{target:l}=k;l=M(g,l);if(l instanceof N&&k instanceof v.YTextEvent){let {keysChanged:n,childListChanged:q,delta:t}=k;0<n.size&&l.syncPropertiesFromYjs(g,n);q&&(l.applyChildrenYjsDelta(g,t),l.syncChildrenFromYjs(g))}else if(l instanceof D&&k instanceof v.YMapEvent)({keysChanged:k}=k),0<k.size&&l.syncPropertiesAndTextFromYjs(g,k);else if(l instanceof
45
45
  Q&&k instanceof v.YXmlEvent)({attributesChanged:k}=k),0<k.size&&l.syncPropertiesFromYjs(g,k);else throw Error("Should never happen");}h=r.$getSelection();if(r.$isRangeSelection(h))if(P(h)){g=e._selection;if(r.$isRangeSelection(g)){l=A.$createOffsetView(d,0,e);f=A.$createOffsetView(d,0,f);let [n,q]=l.getOffsetsFromSelection(g);f=f.createSelectionFromOffsets(n,q,l);null!==f?r.$setSelection(f):(V(a,b),P(h)&&(f=r.$getRoot(),0===f.getChildrenSize()&&f.append(r.$createParagraphNode()),r.$getRoot().selectEnd()))}fa(a,
46
46
  b,g,r.$getSelection())}else V(a,b)},{onUpdate:()=>{X(a,b)},skipTransforms:!0,tag:"collaboration"})}
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "crdt"
12
12
  ],
13
13
  "license": "MIT",
14
- "version": "0.3.5",
14
+ "version": "0.3.8",
15
15
  "main": "LexicalYjs.js",
16
16
  "dependencies": {
17
- "@lexical/offset": "0.3.5"
17
+ "@lexical/offset": "0.3.8"
18
18
  },
19
19
  "peerDependencies": {
20
- "lexical": "0.3.5",
20
+ "lexical": "0.3.8",
21
21
  "yjs": ">=13.5.22"
22
22
  },
23
23
  "repository": {