@lexical/yjs 0.5.0 → 0.5.1-next.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
@@ -1678,8 +1678,8 @@ function syncLexicalUpdateToYjs(binding, provider, prevEditorState, currEditorSt
1678
1678
  }
1679
1679
 
1680
1680
  /** @module @lexical/yjs */
1681
- const CONNECTED_COMMAND = lexical.createCommand();
1682
- const TOGGLE_CONNECT_COMMAND = lexical.createCommand();
1681
+ const CONNECTED_COMMAND = lexical.createCommand('CONNECTED_COMMAND');
1682
+ const TOGGLE_CONNECT_COMMAND = lexical.createCommand('TOGGLE_CONNECT_COMMAND');
1683
1683
  function createUndoManager(binding, root) {
1684
1684
  return new yjs.UndoManager(root, {
1685
1685
  trackedOrigins: new Set([binding, null])
@@ -34,9 +34,9 @@ function Y(a,b){var c=Array.from(b.awareness.getStates()),d=a.clientID;b=a.curso
34
34
  n){let [ba,ca]=X(m.type,m.index),[da,ea]=X(n.type,n.index);if(null!==ba&&null!==da){m=ba.getKey();var r=da.getKey();f=k.selection;if(null===f){f=k;n=ca;var t=ea,p=f.color,l=document.createElement("span");l.style.cssText=`position:absolute;top:0;bottom:0;right:-1px;width:1px;background-color:rgb(${p});z-index:10;`;var u=document.createElement("span");u.textContent=f.name;u.style.cssText=`position:absolute;left:-2px;top:-16px;background-color:rgb(${p});color:#fff;line-height:12px;height:12px;font-size:12px;padding:2px;font-family:Arial;font-weight:bold;white-space:nowrap;`;
35
35
  l.appendChild(u);f={anchor:{key:m,offset:n},caret:l,color:p,focus:{key:r,offset:t},name:u,selections:[]}}else n=f.anchor,t=f.focus,n.key=m,n.offset=ca,t.key=r,t.offset=ea}}}m=a;n=k;l=f;p=e;t=m.editor;f=t.getRootElement();k=m.cursorsContainer;if(null!==k&&null!==f&&(f=k.offsetParent,null!==f))if(f=f.getBoundingClientRect(),r=n.selection,null===l)null!==r&&(n.selection=null,V(m,r));else{n.selection=l;n=l.caret;r=l.color;m=l.selections;u=l.anchor;l=l.focus;var w=l.key,A=p.get(u.key);p=p.get(w);if(null!=
36
36
  A&&null!=p&&(l=y.createDOMRange(t,A,u.offset,p,l.offset),null!==l)){p=m.length;l=y.createRectsFromDOMRange(t,l);t=l.length;for(u=0;u<t;u++)A=l[u],w=m[u],void 0===w&&(w=document.createElement("span"),m[u]=w,k.appendChild(w)),w.style.cssText=`position:absolute;top:${A.top-f.top}px;left:${A.left-f.left}px;height:${A.height}px;width:${A.width}px;background-color:rgba(${r}, 0.3);pointer-events:none;z-index:5;`,u===t-1&&n.parentNode!==w&&w.appendChild(n);for(f=p-1;f>=t;f--)k.removeChild(m[f]),m.pop()}}}}c=
37
- Array.from(b.keys());for(d=0;d<c.length;d++)e=c[d],g.has(e)||(h=b.get(e),void 0!==h&&(h=h.selection,null!==h&&V(a,h),b.delete(e)))}function ha(a,b,c,d){b=b.awareness;var e=b.getLocalState();if(null!==e){var {anchorPos:g,focusPos:h,name:f,color:k,focusing:m}=e,n=e=null;if(null!==d&&(null===g||d.is(c))||null!==c)q.$isRangeSelection(d)&&(e=T(d.anchor,a),n=T(d.focus,a)),(U(g,e)||U(h,n))&&b.setLocalState({anchorPos:e,color:k,focusPos:n,focusing:m,name:f})}}let ma=q.createCommand(),na=q.createCommand();
38
- exports.CONNECTED_COMMAND=ma;exports.TOGGLE_CONNECT_COMMAND=na;exports.createBinding=function(a,b,c,d,e){void 0!==d&&null!==d||B(81);b=d.get("root",v.XmlText);b=L(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])})};
39
- 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=Y;
37
+ Array.from(b.keys());for(d=0;d<c.length;d++)e=c[d],g.has(e)||(h=b.get(e),void 0!==h&&(h=h.selection,null!==h&&V(a,h),b.delete(e)))}function ha(a,b,c,d){b=b.awareness;var e=b.getLocalState();if(null!==e){var {anchorPos:g,focusPos:h,name:f,color:k,focusing:m}=e,n=e=null;if(null!==d&&(null===g||d.is(c))||null!==c)q.$isRangeSelection(d)&&(e=T(d.anchor,a),n=T(d.focus,a)),(U(g,e)||U(h,n))&&b.setLocalState({anchorPos:e,color:k,focusPos:n,focusing:m,name:f})}}
38
+ let ma=q.createCommand("CONNECTED_COMMAND"),na=q.createCommand("TOGGLE_CONNECT_COMMAND");exports.CONNECTED_COMMAND=ma;exports.TOGGLE_CONNECT_COMMAND=na;exports.createBinding=function(a,b,c,d,e){void 0!==d&&null!==d||B(81);b=d.get("root",v.XmlText);b=L(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}};
39
+ exports.createUndoManager=function(a,b){return new v.UndoManager(b,{trackedOrigins:new Set([a,null])})};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=Y;
40
40
  exports.syncLexicalUpdateToYjs=function(a,b,c,d,e,g,h,f){fa(a,()=>{d.read(()=>{if(f.has("collaboration")){if(0<h.size){var k=Array.from(h),m=a.collabNodeMap,n=[];for(let l=0;l<k.length;l++){var r=k[l],t=q.$getNodeByKey(r),p=m.get(r);if(p instanceof E)if(q.$isTextNode(t))n.push([p,t.__text]);else{t=p.getOffset();if(-1===t)continue;let u=p._parent;p._normalized=!0;u._xmlText.delete(t,1);m.delete(r);r=u._children;p=r.indexOf(p);r.splice(p,1)}}for(k=0;k<n.length;k++){let [l,u]=n[k];l instanceof E&&"string"===
41
41
  typeof u&&(l._text=u)}}}else e.has("root")&&(n=c._nodeMap,k=q.$getRoot(),m=a.root,m.syncPropertiesFromLexical(a,k,n),m.syncChildrenFromLexical(a,k,n,e,g)),n=q.$getSelection(),ha(a,b,c._selection,n)})})};
42
42
  exports.syncYjsChangesToLexical=function(a,b,c){let d=a.editor,e=d._editorState;d.update(()=>{var g=d._pendingEditorState;for(var h=0;h<c.length;h++){var f=a,k=c[h],{target:m}=k;m=N(f,m);if(m instanceof O&&k instanceof v.YTextEvent){let {keysChanged:n,childListChanged:r,delta:t}=k;0<n.size&&m.syncPropertiesFromYjs(f,n);r&&(m.applyChildrenYjsDelta(f,t),m.syncChildrenFromYjs(f))}else m instanceof E&&k instanceof v.YMapEvent?({keysChanged:k}=k,0<k.size&&m.syncPropertiesAndTextFromYjs(f,k)):m instanceof
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "crdt"
12
12
  ],
13
13
  "license": "MIT",
14
- "version": "0.5.0",
14
+ "version": "0.5.1-next.1",
15
15
  "main": "LexicalYjs.js",
16
16
  "dependencies": {
17
- "@lexical/offset": "0.5.0"
17
+ "@lexical/offset": "0.5.1-next.1"
18
18
  },
19
19
  "peerDependencies": {
20
- "lexical": "0.5.0",
20
+ "lexical": "0.5.1-next.1",
21
21
  "yjs": ">=13.5.22"
22
22
  },
23
23
  "repository": {