@lexical/yjs 0.12.0 → 0.12.1

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
@@ -1726,7 +1726,7 @@ function syncYjsChangesToLexical(binding, provider, events, isFromUndoManger) {
1726
1726
  const prevOffsetView = offset.$createOffsetView(editor, 0, currentEditorState);
1727
1727
  const nextOffsetView = offset.$createOffsetView(editor, 0, pendingEditorState);
1728
1728
  const [start, end] = prevOffsetView.getOffsetsFromSelection(prevSelection);
1729
- const nextSelection = nextOffsetView.createSelectionFromOffsets(start, end, prevOffsetView);
1729
+ const nextSelection = start >= 0 && end >= 0 ? nextOffsetView.createSelectionFromOffsets(start, end, prevOffsetView) : null;
1730
1730
 
1731
1731
  if (nextSelection !== null) {
1732
1732
  lexical.$setSelection(nextSelection);
@@ -46,5 +46,5 @@ exports.initLocalState=function(a,b,c,d,e){a.awareness.setLocalState({anchorPos:
46
46
  exports.syncLexicalUpdateToYjs=function(a,b,c,d,e,f,h,g){la(a,()=>{d.read(()=>{if(g.has("collaboration")||g.has("historic")){if(0<h.size){var m=Array.from(h),p=a.collabNodeMap,n=[];for(let u=0;u<m.length;u++){var k=m[u],l=r.$getNodeByKey(k),q=p.get(k);if(q instanceof F)if(r.$isTextNode(l))n.push([q,l.__text]);else{l=q.getOffset();if(-1===l)continue;let t=q._parent;q._normalized=!0;t._xmlText.delete(l,1);p.delete(k);k=t._children;q=k.indexOf(q);k.splice(q,1)}}for(m=0;m<n.length;m++){let [u,t]=n[m];
47
47
  u instanceof F&&"string"===typeof t&&(u._text=t)}}}else e.has("root")&&(n=c._nodeMap,m=r.$getRoot(),p=a.root,p.syncPropertiesFromLexical(a,m,n),p.syncChildrenFromLexical(a,m,n,e,f)),n=r.$getSelection(),oa(a,b,c._selection,n)})})};
48
48
  exports.syncYjsChangesToLexical=function(a,b,c,d){let e=a.editor,f=e._editorState;c.forEach(h=>h.delta);e.update(()=>{var h=e._pendingEditorState;for(var g=0;g<c.length;g++){var m=a,p=c[g],{target:n}=p;n=O(m,n);if(n instanceof P&&p instanceof v.YTextEvent){let {keysChanged:k,childListChanged:l,delta:q}=p;0<k.size&&n.syncPropertiesFromYjs(m,k);l&&(n.applyChildrenYjsDelta(m,q),n.syncChildrenFromYjs(m))}else n instanceof F&&p instanceof v.YMapEvent?({keysChanged:p}=p,0<p.size&&n.syncPropertiesAndTextFromYjs(m,
49
- p)):n instanceof U&&p instanceof v.YXmlEvent?({attributesChanged:p}=p,0<p.size&&n.syncPropertiesFromYjs(m,p)):A(82)}g=r.$getSelection();if(r.$isRangeSelection(g))if(R(g)){m=f._selection;if(r.$isRangeSelection(m)){n=z.$createOffsetView(e,0,f);h=z.$createOffsetView(e,0,h);let [k,l]=n.getOffsetsFromSelection(m);h=h.createSelectionFromOffsets(k,l,n);null!==h?r.$setSelection(h):(Y(a,b),R(g)&&(h=r.$getRoot(),0===h.getChildrenSize()&&h.append(r.$createParagraphNode()),r.$getRoot().selectEnd()))}oa(a,b,m,
50
- r.$getSelection())}else Y(a,b)},{onUpdate:()=>{na(a,b)},skipTransforms:!0,tag:d?"historic":"collaboration"})}
49
+ p)):n instanceof U&&p instanceof v.YXmlEvent?({attributesChanged:p}=p,0<p.size&&n.syncPropertiesFromYjs(m,p)):A(82)}g=r.$getSelection();if(r.$isRangeSelection(g))if(R(g)){m=f._selection;if(r.$isRangeSelection(m)){n=z.$createOffsetView(e,0,f);h=z.$createOffsetView(e,0,h);let [k,l]=n.getOffsetsFromSelection(m);h=0<=k&&0<=l?h.createSelectionFromOffsets(k,l,n):null;null!==h?r.$setSelection(h):(Y(a,b),R(g)&&(h=r.$getRoot(),0===h.getChildrenSize()&&h.append(r.$createParagraphNode()),r.$getRoot().selectEnd()))}oa(a,
50
+ b,m,r.$getSelection())}else Y(a,b)},{onUpdate:()=>{na(a,b)},skipTransforms:!0,tag:d?"historic":"collaboration"})}
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "crdt"
12
12
  ],
13
13
  "license": "MIT",
14
- "version": "0.12.0",
14
+ "version": "0.12.1",
15
15
  "main": "LexicalYjs.js",
16
16
  "dependencies": {
17
- "@lexical/offset": "0.12.0"
17
+ "@lexical/offset": "0.12.1"
18
18
  },
19
19
  "peerDependencies": {
20
- "lexical": "0.12.0",
20
+ "lexical": "0.12.1",
21
21
  "yjs": ">=13.5.22"
22
22
  },
23
23
  "repository": {