@lexical/yjs 0.23.2-nightly.20250114.0 → 0.23.2-nightly.20250115.0

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.
Files changed (2) hide show
  1. package/LexicalYjs.prod.js +1 -45
  2. package/package.json +4 -4
@@ -6,48 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var p=require("lexical"),v=require("yjs"),x=require("@lexical/offset"),z=require("@lexical/selection"),A;function C(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
10
- A=C&&C.__esModule&&Object.prototype.hasOwnProperty.call(C,"default")?C["default"]:C;class E{constructor(a,b){this._key="";this._map=a;this._parent=b;this._type="linebreak"}getNode(){let a=p.$getNodeByKey(this._key);return p.$isLineBreakNode(a)?a:null}getKey(){return this._key}getSharedType(){return this._map}getType(){return this._type}getSize(){return 1}getOffset(){return this._parent.getChildOffset(this)}destroy(a){a.collabNodeMap.delete(this._key)}}
11
- function F(a,b){b=new E(a,b);return a._collabNode=b}
12
- class G{constructor(a,b,c,d){this._key="";this._map=a;this._parent=c;this._text=b;this._type=d;this._normalized=!1}getPrevNode(a){if(null===a)return null;a=a.get(this._key);return p.$isTextNode(a)?a:null}getNode(){let a=p.$getNodeByKey(this._key);return p.$isTextNode(a)?a:null}getSharedType(){return this._map}getType(){return this._type}getKey(){return this._key}getSize(){return this._text.length+(this._normalized?0:1)}getOffset(){return this._parent.getChildOffset(this)}spliceText(a,b,c){let d=this._parent._xmlText;
13
- a=this.getOffset()+1+a;0!==b&&d.delete(a,b);""!==c&&d.insert(a,c)}syncPropertiesAndTextFromLexical(a,b,c){var d=this.getPrevNode(c);c=b.__text;H(a,this._map,d,b);if(null!==d&&(a=d.__text,a!==c)){d=b.__key;b=a;var e=p.$getSelection();a=c.length;p.$isRangeSelection(e)&&e.isCollapsed()&&(e=e.anchor,e.key===d&&(a=e.offset));d=b.length;let f=c.length,h=e=0;for(;e<d&&e<f&&b[e]===c[e]&&e<a;)e++;for(;h+e<d&&h+e<f&&b[d-h-1]===c[f-h-1];)h++;for(;h+e<d&&h+e<f&&b[e]===c[e];)e++;b=e;a=c.slice(e,f-h);d=d-e-h;this.spliceText(b,
14
- d,a);this._text=c}}syncPropertiesAndTextFromYjs(a,b){let c=this.getNode();null===c&&A(84);I(a,this._map,c,b);a=this._text;c.__text!==a&&(c.getWritable().__text=a)}destroy(a){a.collabNodeMap.delete(this._key)}}function J(a,b,c,d){b=new G(a,b,c,d);return a._collabNode=b}let aa=new Set(["__key","__parent","__next","__prev"]),ba=new Set(["__first","__last","__size"]),ca=new Set(["__cachedText"]),da=new Set(["__text"]);
15
- function K(a,b,c){if(aa.has(a))return!0;if(p.$isTextNode(b)){if(da.has(a))return!0}else if(p.$isElementNode(b)&&(ba.has(a)||p.$isRootNode(b)&&ca.has(a)))return!0;b=c.excludedProperties.get(b.constructor);return null!=b&&b.has(a)}function L(a){a=p.$getNodeByKey(a);null===a&&A(85);return a}
16
- function M(a,b,c){let d=b.__type;if(p.$isElementNode(b)){var e=new v.XmlText;e=N(e,c,d);e.syncPropertiesFromLexical(a,b,null);e.syncChildrenFromLexical(a,b,null,null,null)}else p.$isTextNode(b)?(e=new v.Map,e=J(e,b.__text,c,d),e.syncPropertiesAndTextFromLexical(a,b,null)):p.$isLineBreakNode(b)?(a=new v.Map,a.set("__type","linebreak"),e=F(a,c)):p.$isDecoratorNode(b)?(e=new v.XmlElement,e=O(e,c,d),e.syncPropertiesFromLexical(a,b,null)):A(86);e._key=b.__key;return e}
17
- function P(a,b,c){let d=b._collabNode;if(void 0===d){var e=a.editor._nodes;let f=b instanceof v.Map?b.get("__type"):b.getAttribute("__type");null==f&&A(87);void 0===e.get(f)&&A(88,f);e=b.parent;a=void 0===c&&null!==e?P(a,e):c||null;a instanceof Q||A(89);if(b instanceof v.XmlText)return N(b,a,f);if(b instanceof v.Map)return"linebreak"===f?F(b,a):J(b,"",a,f);if(b instanceof v.XmlElement)return O(b,a,f)}return d}
18
- function I(a,b,c,d){d=null===d?b instanceof v.Map?Array.from(b.keys()):Object.keys(b.getAttributes()):Array.from(d);let e;for(let h=0;h<d.length;h++){let g=d[h];if(K(g,c,a))continue;var f=c[g];let k=b instanceof v.Map?b.get(g):b.getAttribute(g);if(f!==k){if(k instanceof v.Doc){let l=a.docMap;f instanceof v.Doc&&l.delete(f.guid);f=p.createEditor();let t=k.guid;f._key=t;l.set(t,k);k=f}void 0===e&&(e=c.getWritable());e[g]=k}}}
19
- function H(a,b,c,d){var e=d.__type,f=a.nodeProperties;let h=f.get(e);void 0===h&&(h=Object.keys(d).filter(k=>!K(k,d,a)),f.set(e,h));e=a.editor.constructor;for(f=0;f<h.length;f++){let k=h[f];var g=null===c?void 0:c[k];let l=d[k];if(g!==l){if(l instanceof e){let t=a.docMap,n;g instanceof e&&(g=g._key,n=t.get(g),t.delete(g));g=n||new v.Doc;let m=g.guid;l._key=m;t.set(m,g);l=g;a.editor.update(()=>{d.markDirty()})}b instanceof v.Map?b.set(k,l):b.setAttribute(k,l)}}}
20
- function R(a,b,c,d){return a.slice(0,b)+d+a.slice(b+c)}function S(a,b,c){let d=0,e=0,f=a._children,h=f.length;for(;e<h;e++){a=f[e];let g=d,k=a.getSize();d+=k;if((c?d>=b:d>b)&&a instanceof G)return c=b-g-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:g};if(e===h-1)return{length:0,node:null,nodeIndex:e+1,offset:g+1}}return{length:0,node:null,nodeIndex:0,offset:0}}
21
- function T(a){let b=a.anchor;a=a.focus;let c=!1;try{let d=b.getNode(),e=a.getNode();if(!d.isAttached()||!e.isAttached()||p.$isTextNode(d)&&b.offset>d.getTextContentSize()||p.$isTextNode(e)&&a.offset>e.getTextContentSize())c=!0}catch(d){c=!0}return c}function ea(a,b){a.doc.transact(b,a)}
22
- function U(a){var b=a.getParent();if(null!==b){let e=a.getWritable();b=b.getWritable();var c=a.getPreviousSibling();a=a.getNextSibling();if(null===c)if(null!==a){var d=a.getWritable();b.__first=a.__key;d.__prev=null}else b.__first=null;else{d=c.getWritable();if(null!==a){let f=a.getWritable();f.__prev=d.__key;d.__next=f.__key}else d.__next=null;e.__prev=null}null===a?null!==c?(a=c.getWritable(),b.__last=c.__key,a.__next=null):b.__last=null:(a=a.getWritable(),null!==c?(c=c.getWritable(),c.__next=a.__key,
23
- a.__prev=c.__key):a.__prev=null,e.__next=null);b.__size--;e.__parent=null}}function V(a,b){if(a=b._nodeMap.get(a)){var c=a.__prev,d=null;c&&(d=p.$getNodeByKey(c));null===d&&null!==a.__parent&&(d=p.$getNodeByKey(a.__parent));null===d?p.$getRoot().selectStart():null!==d&&d.isAttached()?d.selectEnd():V(d.__key,b)}else p.$getRoot().selectStart()}
24
- class W{constructor(a,b,c){this._key="";this._xmlElem=a;this._parent=b;this._type=c}getPrevNode(a){if(null===a)return null;a=a.get(this._key);return p.$isDecoratorNode(a)?a:null}getNode(){let a=p.$getNodeByKey(this._key);return p.$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);H(a,this._xmlElem,c,b)}syncPropertiesFromYjs(a,
25
- b){let c=this.getNode();null===c&&A(83);I(a,this._xmlElem,c,b)}destroy(a){a.collabNodeMap.delete(this._key)}}function O(a,b,c){b=new W(a,b,c);return a._collabNode=b}
26
- class Q{constructor(a,b,c){this._key="";this._children=[];this._xmlText=a;this._type=c;this._parent=b}getPrevNode(a){if(null===a)return null;a=a.get(this._key);return p.$isElementNode(a)?a:null}getNode(){let a=p.$getNodeByKey(this._key);return p.$isElementNode(a)?a:null}getSharedType(){return this._xmlText}getType(){return this._type}getKey(){return this._key}isEmpty(){return 0===this._children.length}getSize(){return 1}getOffset(){let a=this._parent;null===a&&A(90);return a.getChildOffset(this)}syncPropertiesFromYjs(a,
27
- b){let c=this.getNode();null===c&&A(91);I(a,this._xmlText,c,b)}applyChildrenYjsDelta(a,b){let c=this._children,d=0;for(let k=0;k<b.length;k++){var e=b[k],f=e.insert,h=e.delete;if(null!=e.retain)d+=e.retain;else if("number"===typeof h)for(e=h;0<e;){let {node:l,nodeIndex:t,offset:n,length:m}=S(this,d,!1);if(l instanceof Q||l instanceof E||l instanceof W)c.splice(t,1),--e;else if(l instanceof G){f=Math.min(e,m);h=0!==t?c[t-1]:null;var g=l.getSize();0===n&&m===g?(c.splice(t,1),g=R(l._text,n,f-1,""),0<
28
- g.length&&(h instanceof G?h._text+=g:this._xmlText.delete(n,g.length))):l._text=R(l._text,n,f,"");e-=f}else break}else if(null!=f)if("string"===typeof f){let {node:l,offset:t}=S(this,d,!0);l instanceof G?l._text=R(l._text,t,0,f):this._xmlText.delete(t,f.length);d+=f.length}else({nodeIndex:e}=S(this,d,!1)),f=P(a,f,this),c.splice(e,0,f),d+=1;else throw Error("Unexpected delta format");}}syncChildrenFromYjs(a){var b=this.getNode();null===b&&A(92);var c=b.__key;let d=x.$createChildrenArray(b,null),e=
29
- d.length;var f=this._children;let h=f.length,g=a.collabNodeMap,k=new Set,l;let t=0;var n=null;h!==e&&b.getWritable();for(let y=0;y<h;y++){var m=d[t],r=f[y];var u=r.getNode();var q=r._key;if(null!==u&&m===q)n=p.$isTextNode(u),k.add(m),n&&(r._key=m,r instanceof Q?(n=r._xmlText,r.syncPropertiesFromYjs(a,null),r.applyChildrenYjsDelta(a,n.toDelta()),r.syncChildrenFromYjs(a)):r instanceof G?r.syncPropertiesAndTextFromYjs(a,null):r instanceof W?r.syncPropertiesFromYjs(a,null):r instanceof E||A(93)),n=u,
30
- t++;else{if(void 0===l)for(l=new Set,q=0;q<h;q++){var w=f[q]._key;""!==w&&l.add(w)}if(null!==u&&void 0!==m&&!l.has(m)){r=L(m);U(r);y--;t++;continue}u=b.getWritable();m=a;q=r;w=c;var B=q.getType();let D=m.editor._nodes.get(B);void 0===D&&A(88,B);B=new D.klass;B.__parent=w;q._key=B.__key;q instanceof Q?(w=q._xmlText,q.syncPropertiesFromYjs(m,null),q.applyChildrenYjsDelta(m,w.toDelta()),q.syncChildrenFromYjs(m)):q instanceof G?q.syncPropertiesAndTextFromYjs(m,null):q instanceof W&&q.syncPropertiesFromYjs(m,
31
- null);m.collabNodeMap.set(B.__key,q);m=B;q=m.__key;g.set(q,r);null===n?(n=u.getFirstChild(),u.__first=q,null!==n&&(n=n.getWritable(),n.__prev=q,m.__next=n.__key)):(r=n.getWritable(),w=n.getNextSibling(),r.__next=q,m.__prev=n.__key,null!==w&&(n=w.getWritable(),n.__prev=q,m.__next=n.__key));y===h-1&&(u.__last=q);u.__size++;n=m}}for(b=0;b<e;b++)f=d[b],k.has(f)||(c=L(f),f=a.collabNodeMap.get(f),void 0!==f&&f.destroy(a),U(c))}syncPropertiesFromLexical(a,b,c){H(a,this._xmlText,this.getPrevNode(c),b)}_syncChildFromLexical(a,
32
- b,c,d,e,f){b=this._children[b];c=L(c);b instanceof Q&&p.$isElementNode(c)?(b.syncPropertiesFromLexical(a,c,d),b.syncChildrenFromLexical(a,c,d,e,f)):b instanceof G&&p.$isTextNode(c)?b.syncPropertiesAndTextFromLexical(a,c,d):b instanceof W&&p.$isDecoratorNode(c)&&b.syncPropertiesFromLexical(a,c,d)}syncChildrenFromLexical(a,b,c,d,e){var f=this.getPrevNode(c);let h=null===f?[]:x.$createChildrenArray(f,c);f=x.$createChildrenArray(b,null);let g=h.length-1,k=f.length-1,l=a.collabNodeMap,t,n,m=0;for(b=0;m<=
33
- g&&b<=k;){var r=h[m];let q=f[b];if(r===q)this._syncChildFromLexical(a,b,q,c,d,e),m++,b++;else{void 0===t&&(t=new Set(h));void 0===n&&(n=new Set(f));var u=n.has(r);r=t.has(q);u?(u=L(q),u=M(a,u,this),l.set(q,u),r?(this.splice(a,b,1,u),m++):this.splice(a,b,0,u),b++):(this.splice(a,b,1),m++)}}c=m>g;d=b>k;if(c&&!d)for(;b<=k;++b)c=f[b],d=L(c),d=M(a,d,this),this.append(d),l.set(c,d);else if(d&&!c)for(f=this._children.length-1;f>=b;f--)this.splice(a,f,1)}append(a){let b=this._xmlText;var c=this._children;
34
- c=c[c.length-1];c=void 0!==c?c.getOffset()+c.getSize():0;if(a instanceof Q)b.insertEmbed(c,a._xmlText);else if(a instanceof G){let d=a._map;null===d.parent&&b.insertEmbed(c,d);b.insert(c+1,a._text)}else a instanceof E?b.insertEmbed(c,a._map):a instanceof W&&b.insertEmbed(c,a._xmlElem);this._children.push(a)}splice(a,b,c,d){let e=this._children;var f=e[b];if(void 0===f)void 0===d&&A(94),this.append(d);else{var h=f.getOffset();-1===h&&A(95);var g=this._xmlText;0!==c&&g.delete(h,f.getSize());d instanceof
35
- Q?g.insertEmbed(h,d._xmlText):d instanceof G?(f=d._map,null===f.parent&&g.insertEmbed(h,f),g.insert(h+1,d._text)):d instanceof E?g.insertEmbed(h,d._map):d instanceof W&&g.insertEmbed(h,d._xmlElem);if(0!==c)for(h=e.slice(b,b+c),g=0;g<h.length;g++)h[g].destroy(a);void 0!==d?e.splice(b,c,d):e.splice(b,c)}}getChildOffset(a){let b=0,c=this._children;for(let d=0;d<c.length;d++){let e=c[d];if(e===a)return b;b+=e.getSize()}return-1}destroy(a){let b=a.collabNodeMap,c=this._children;for(let d=0;d<c.length;d++)c[d].destroy(a);
36
- b.delete(this._key)}}function N(a,b,c){b=new Q(a,b,c);return a._collabNode=b}
37
- function X(a,b){var c=b.collabNodeMap.get(a.key);if(void 0===c)return null;b=a.offset;let d=c.getSharedType();if(c instanceof G){d=c._parent._xmlText;a=c.getOffset();if(-1===a)return null;b=a+1+b}else if(c instanceof Q&&"element"===a.type){var e=a.getNode();p.$isElementNode(e)||A(184);c=a=0;for(e=e.getFirstChild();null!==e&&c++<b;)p.$isTextNode(e)?a+=e.getTextContentSize()+1:a++,e=e.getNextSibling();b=a}return v.createRelativePositionFromTypeIndex(d,b)}
38
- function Y(a,b){if(null==a){if(null!=b)return!0}else if(null==b||!v.compareRelativePositions(a,b))return!0;return!1}function la(a,b){a=a.cursorsContainer;if(null!==a){b=b.selections;let c=b.length;for(let d=0;d<c;d++)a.removeChild(b[d])}}
39
- function Z(a,b){let {anchorPos:c,focusPos:d}=b;b=null;let e=0,f=null,h=0;if(null!==c&&null!==d){let g=v.createAbsolutePositionFromRelativePosition(c,a.doc);a=v.createAbsolutePositionFromRelativePosition(d,a.doc);null!==g&&null!==a&&([b,e]=ma(g.type,g.index),[f,h]=ma(a.type,a.index))}return{anchorCollabNode:b,anchorOffset:e,focusCollabNode:f,focusOffset:h}}
40
- function na(a,b){b=b.awareness.getLocalState();if(null!==b){var {anchorCollabNode:c,anchorOffset:d,focusCollabNode:e,focusOffset:f}=Z(a,b);if(null!==c&&null!==e){a=c.getKey();b=e.getKey();let h=p.$getSelection();p.$isRangeSelection(h)&&(oa(h.anchor,a,d),oa(h.focus,b,f))}}}
41
- function oa(a,b,c){if(a.key!==b||a.offset!==c){let d=p.$getNodeByKey(b);if(null!==d&&!p.$isElementNode(d)&&!p.$isTextNode(d)){let e=d.getParentOrThrow();b=e.getKey();c=d.getIndexWithinParent();d=e}a.set(b,c,p.$isElementNode(d)?"element":"text")}}function ma(a,b){a=a._collabNode;if(void 0===a)return[null,0];if(a instanceof Q){let {node:c,offset:d}=S(a,b,!0);return null===c?[a,0]:[c,d]}return[null,0]}
42
- function pa(a,b){var c=Array.from(b.awareness.getStates()),d=a.clientID;b=a.cursors;var e=a.editor._editorState._nodeMap;let f=new Set;for(var h=0;h<c.length;h++){let [D,fa]=c[h];if(D!==d){f.add(D);let {name:ra,color:sa,focusing:ta}=fa;var g=null,k=b.get(D);void 0===k&&(k={color:sa,name:ra,selection:null},b.set(D,k));if(ta){let {anchorCollabNode:ha,anchorOffset:ia,focusCollabNode:ja,focusOffset:ka}=Z(a,fa);if(null!==ha&&null!==ja){var l=ha.getKey(),t=ja.getKey();g=k.selection;if(null===g){g=k;var n=
43
- ia,m=ka,r=g.color,u=document.createElement("span");u.style.cssText=`position:absolute;top:0;bottom:0;right:-1px;width:1px;background-color:${r};z-index:10;`;var q=document.createElement("span");q.textContent=g.name;q.style.cssText=`position:absolute;left:-2px;top:-16px;background-color:${r};color:#fff;line-height:12px;font-size:12px;padding:2px;font-family:Arial;font-weight:bold;white-space:nowrap;`;u.appendChild(q);g={anchor:{key:l,offset:n},caret:u,color:r,focus:{key:t,offset:m},name:q,selections:[]}}else n=
44
- g.anchor,m=g.focus,n.key=l,n.offset=ia,m.key=t,m.offset=ka}}a:if(l=a,n=k,u=g,r=e,m=l.editor,g=m.getRootElement(),k=l.cursorsContainer,null!==k&&null!==g&&(g=k.offsetParent,null!==g))if(g=g.getBoundingClientRect(),t=n.selection,null===u)null!==t&&(n.selection=null,la(l,t));else{n.selection=u;n=u.caret;t=u.color;l=u.selections;q=u.anchor;u=u.focus;var w=q.key,B=u.key,y=r.get(w);r=r.get(B);if(null!=y&&null!=r){if(y===r&&p.$isLineBreakNode(y))r=[m.getElementByKey(w).getBoundingClientRect()];else{r=z.createDOMRange(m,
45
- y,q.offset,r,u.offset);if(null===r)break a;r=z.createRectsFromDOMRange(m,r)}u=l.length;m=r.length;for(q=0;q<m;q++)y=r[q],w=l[q],void 0===w&&(w=document.createElement("span"),l[q]=w,B=document.createElement("span"),w.appendChild(B),k.appendChild(w)),y=`position:absolute;top:${y.top-g.top}px;left:${y.left-g.left}px;height:${y.height}px;width:${y.width}px;pointer-events:none;z-index:5;`,w.style.cssText=y,w.firstChild.style.cssText=`${y}left:0;top:0;background-color:${t};opacity:0.3;`,q===m-1&&n.parentNode!==
46
- w&&w.appendChild(n);for(g=u-1;g>=m;g--)k.removeChild(l[g]),l.pop()}}}}c=Array.from(b.keys());for(d=0;d<c.length;d++)e=c[d],f.has(e)||(h=b.get(e),void 0!==h&&(h=h.selection,null!==h&&la(a,h),b.delete(e)))}
47
- function qa(a,b,c,d){b=b.awareness;let e=b.getLocalState();if(null!==e){var {anchorPos:f,focusPos:h,name:g,color:k,focusing:l,awarenessData:t}=e,n=null,m=null;if(null!==d&&(null===f||d.is(c))||null!==c)p.$isRangeSelection(d)&&(n=X(d.anchor,a),m=X(d.focus,a)),(Y(f,n)||Y(h,m))&&b.setLocalState({...e,anchorPos:n,awarenessData:t,color:k,focusPos:m,focusing:l,name:g})}}let ua=p.createCommand("CONNECTED_COMMAND"),va=p.createCommand("TOGGLE_CONNECT_COMMAND");exports.CONNECTED_COMMAND=ua;
48
- exports.TOGGLE_CONNECT_COMMAND=va;exports.createBinding=function(a,b,c,d,e,f){void 0!==d&&null!==d||A(81);b=d.get("root",v.XmlText);b=N(b,null,"root");b._key="root";return{clientID:d.clientID,collabNodeMap:new Map,cursors:new Map,cursorsContainer:null,doc:d,docMap:e,editor:a,excludedProperties:f||new Map,id:c,nodeProperties:new Map,root:b}};exports.createUndoManager=function(a,b){return new v.UndoManager(b,{trackedOrigins:new Set([a,null])})};exports.getAnchorAndFocusCollabNodesForUserState=Z;
49
- exports.initLocalState=function(a,b,c,d,e){a.awareness.setLocalState({anchorPos:null,awarenessData:e,color:c,focusPos:null,focusing:d,name:b})};exports.setLocalStateFocus=function(a,b,c,d,e){({awareness:a}=a);let f=a.getLocalState();null===f&&(f={anchorPos:null,awarenessData:e,color:c,focusPos:null,focusing:d,name:b});f.focusing=d;a.setLocalState(f)};exports.syncCursorPositions=pa;
50
- exports.syncLexicalUpdateToYjs=function(a,b,c,d,e,f,h,g){ea(a,()=>{d.read(()=>{if(g.has("collaboration")||g.has("historic")){if(0<h.size){var k=Array.from(h),l=a.collabNodeMap,t=[];for(let u=0;u<k.length;u++){var n=k[u],m=p.$getNodeByKey(n),r=l.get(n);if(r instanceof G)if(p.$isTextNode(m))t.push([r,m.__text]);else{m=r.getOffset();if(-1===m)continue;let q=r._parent;r._normalized=!0;q._xmlText.delete(m,1);l.delete(n);n=q._children;r=n.indexOf(r);n.splice(r,1)}}for(k=0;k<t.length;k++){let [u,q]=t[k];
51
- u instanceof G&&"string"===typeof q&&(u._text=q)}}}else e.has("root")&&(t=c._nodeMap,k=p.$getRoot(),l=a.root,l.syncPropertiesFromLexical(a,k,t),l.syncChildrenFromLexical(a,k,t,e,f)),t=p.$getSelection(),qa(a,b,c._selection,t)})})};
52
- exports.syncYjsChangesToLexical=function(a,b,c,d){let e=a.editor,f=e._editorState;c.forEach(h=>h.delta);e.update(()=>{for(var h=0;h<c.length;h++){var g=a,k=c[h],{target:l}=k;l=P(g,l);if(l instanceof Q&&k instanceof v.YTextEvent){let {keysChanged:t,childListChanged:n,delta:m}=k;0<t.size&&l.syncPropertiesFromYjs(g,t);n&&(l.applyChildrenYjsDelta(g,m),l.syncChildrenFromYjs(g))}else l instanceof G&&k instanceof v.YMapEvent?({keysChanged:k}=k,0<k.size&&l.syncPropertiesAndTextFromYjs(g,k)):l instanceof W&&
53
- k instanceof v.YXmlEvent?({attributesChanged:k}=k,0<k.size&&l.syncPropertiesFromYjs(g,k)):A(82)}g=p.$getSelection();p.$isRangeSelection(g)&&(T(g)?(h=f._selection,p.$isRangeSelection(h)&&(na(a,b),T(g)&&V(g.anchor.key,f)),qa(a,b,h,p.$getSelection())):na(a,b))},{onUpdate:()=>{pa(a,b);e.update(()=>{0===p.$getRoot().getChildrenSize()&&p.$getRoot().append(p.$createParagraphNode())})},skipTransforms:!0,tag:d?"historic":"collaboration"})}
9
+ "use strict";var e=require("lexical"),t=require("yjs"),n=require("@lexical/offset"),o=require("@lexical/selection");function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l=s((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class i{constructor(e,t){this._key="",this._map=e,this._parent=t,this._type="linebreak"}getNode(){const t=e.$getNodeByKey(this._key);return e.$isLineBreakNode(t)?t:null}getKey(){return this._key}getSharedType(){return this._map}getType(){return this._type}getSize(){return 1}getOffset(){return this._parent.getChildOffset(this)}destroy(e){e.collabNodeMap.delete(this._key)}}function r(e,t){const n=new i(e,t);return e._collabNode=n,n}class c{constructor(e,t,n,o){this._key="",this._map=e,this._parent=n,this._text=t,this._type=o,this._normalized=!1}getPrevNode(t){if(null===t)return null;const n=t.get(this._key);return e.$isTextNode(n)?n:null}getNode(){const t=e.$getNodeByKey(this._key);return e.$isTextNode(t)?t:null}getSharedType(){return this._map}getType(){return this._type}getKey(){return this._key}getSize(){return this._text.length+(this._normalized?0:1)}getOffset(){return this._parent.getChildOffset(this)}spliceText(e,t,n){const o=this._parent._xmlText,s=this.getOffset()+1+e;0!==t&&o.delete(s,t),""!==n&&o.insert(s,n)}syncPropertiesAndTextFromLexical(t,n,o){const s=this.getPrevNode(o),l=n.__text;if(N(t,this._map,s,n),null!==s){const t=s.__text;if(t!==l){!function(t,n,o,s){const l=e.$getSelection();let i=s.length;if(e.$isRangeSelection(l)&&l.isCollapsed()){const e=l.anchor;e.key===n&&(i=e.offset)}const r=function(e,t,n){const o=e.length,s=t.length;let l=0,i=0;for(;l<o&&l<s&&e[l]===t[l]&&l<n;)l++;for(;i+l<o&&i+l<s&&e[o-i-1]===t[s-i-1];)i++;for(;i+l<o&&i+l<s&&e[l]===t[l];)l++;return{index:l,insert:t.slice(l,s-i),remove:o-l-i}}(o,s,i);t.spliceText(r.index,r.remove,r.insert)}(this,n.__key,t,l),this._text=l}}}syncPropertiesAndTextFromYjs(e,t){const n=this.getNode();null===n&&l(84),m(e,this._map,n,t);const o=this._text;if(n.__text!==o){n.getWritable().__text=o}}destroy(e){e.collabNodeMap.delete(this._key)}}function a(e,t,n,o){const s=new c(e,t,n,o);return e._collabNode=s,s}const f=new Set(["__key","__parent","__next","__prev"]),u=new Set(["__first","__last","__size"]),d=new Set(["__cachedText"]),_=new Set(["__text"]);function h(t,n,o){if(f.has(t))return!0;if(e.$isTextNode(n)){if(_.has(t))return!0}else if(e.$isElementNode(n)&&(u.has(t)||e.$isRootNode(n)&&d.has(t)))return!0;const s=n.constructor,l=o.excludedProperties.get(s);return null!=l&&l.has(t)}function p(t){const n=e.$getNodeByKey(t);return null===n&&l(85),n}function g(n,o,s){const i=o.__type;let c;if(e.$isElementNode(o)){c=w(new t.XmlText,s,i),c.syncPropertiesFromLexical(n,o,null),c.syncChildrenFromLexical(n,o,null,null,null)}else if(e.$isTextNode(o)){c=a(new t.Map,o.__text,s,i),c.syncPropertiesAndTextFromLexical(n,o,null)}else if(e.$isLineBreakNode(o)){const e=new t.Map;e.set("__type","linebreak"),c=r(e,s)}else if(e.$isDecoratorNode(o)){c=S(new t.XmlElement,s,i),c.syncPropertiesFromLexical(n,o,null)}else l(86);return c._key=o.__key,c}function y(e,n,o){const s=n._collabNode;if(void 0===s){const s=e.editor._nodes,i=function(e){const n=e instanceof t.Map?e.get("__type"):e.getAttribute("__type");return null==n&&l(87),n}(n);void 0===s.get(i)&&l(88,i);const c=n.parent,f=void 0===o&&null!==c?y(e,c):o||null;if(f instanceof P||l(89),n instanceof t.XmlText)return w(n,f,i);if(n instanceof t.Map)return"linebreak"===i?r(n,f):a(n,"",f,i);if(n instanceof t.XmlElement)return S(n,f,i)}return s}function x(e,t,n){const o=t.getType(),s=e.editor._nodes.get(o);void 0===s&&l(88,o);const i=new s.klass;if(i.__parent=n,t._key=i.__key,t instanceof P){const n=t._xmlText;t.syncPropertiesFromYjs(e,null),t.applyChildrenYjsDelta(e,n.toDelta()),t.syncChildrenFromYjs(e)}else t instanceof c?t.syncPropertiesAndTextFromYjs(e,null):t instanceof v&&t.syncPropertiesFromYjs(e,null);return e.collabNodeMap.set(i.__key,t),i}function m(n,o,s,l){const i=null===l?o instanceof t.Map?Array.from(o.keys()):Object.keys(o.getAttributes()):Array.from(l);let r;for(let l=0;l<i.length;l++){const c=i[l];if(h(c,s,n))continue;const a=s[c];let f=o instanceof t.Map?o.get(c):o.getAttribute(c);if(a!==f){if(f instanceof t.Doc){const o=n.docMap;a instanceof t.Doc&&o.delete(a.guid);const s=e.createEditor(),l=f.guid;s._key=l,o.set(l,f),f=s}void 0===r&&(r=s.getWritable()),r[c]=f}}}function N(e,n,o,s){const l=s.__type,i=e.nodeProperties;let r=i.get(l);void 0===r&&(r=Object.keys(s).filter((t=>!h(t,s,e))),i.set(l,r));const c=e.editor.constructor;for(let l=0;l<r.length;l++){const i=r[l],a=null===o?void 0:o[i];let f=s[i];if(a!==f){if(f instanceof c){const n=e.docMap;let o;if(a instanceof c){const e=a._key;o=n.get(e),n.delete(e)}const l=o||new t.Doc,i=l.guid;f._key=i,n.set(i,l),f=l,e.editor.update((()=>{s.markDirty()}))}n instanceof t.Map?n.set(i,f):n.setAttribute(i,f)}}}function b(e,t,n,o){return e.slice(0,t)+o+e.slice(t+n)}function k(e,t,n){let o=0,s=0;const l=e._children,i=l.length;for(;s<i;s++){const e=l[s],r=o;o+=e.getSize();if((n?o>=t:o>t)&&e instanceof c){let n=t-r-1;n<0&&(n=0);return{length:o-t,node:e,nodeIndex:s,offset:n}}if(o>t)return{length:0,node:e,nodeIndex:s,offset:r};if(s===i-1)return{length:0,node:null,nodeIndex:s+1,offset:r+1}}return{length:0,node:null,nodeIndex:0,offset:0}}function C(t){const n=t.anchor,o=t.focus;let s=!1;try{const t=n.getNode(),l=o.getNode();(!t.isAttached()||!l.isAttached()||e.$isTextNode(t)&&n.offset>t.getTextContentSize()||e.$isTextNode(l)&&o.offset>l.getTextContentSize())&&(s=!0)}catch(e){s=!0}return s}function T(e){const t=e.getParent();if(null!==t){const n=e.getWritable(),o=t.getWritable(),s=e.getPreviousSibling(),l=e.getNextSibling();if(null===s)if(null!==l){const e=l.getWritable();o.__first=l.__key,e.__prev=null}else o.__first=null;else{const e=s.getWritable();if(null!==l){const t=l.getWritable();t.__prev=e.__key,e.__next=t.__key}else e.__next=null;n.__prev=null}if(null===l)if(null!==s){const e=s.getWritable();o.__last=s.__key,e.__next=null}else o.__last=null;else{const e=l.getWritable();if(null!==s){const t=s.getWritable();t.__next=e.__key,e.__prev=t.__key}else e.__prev=null;n.__next=null}o.__size--,n.__parent=null}}function $(t,n){const o=n._nodeMap.get(t);if(!o)return void e.$getRoot().selectStart();const s=o.__prev;let l=null;s&&(l=e.$getNodeByKey(s)),null===l&&null!==o.__parent&&(l=e.$getNodeByKey(o.__parent)),null!==l?null!==l&&l.isAttached()?l.selectEnd():$(l.__key,n):e.$getRoot().selectStart()}class v{constructor(e,t,n){this._key="",this._xmlElem=e,this._parent=t,this._type=n}getPrevNode(t){if(null===t)return null;const n=t.get(this._key);return e.$isDecoratorNode(n)?n:null}getNode(){const t=e.$getNodeByKey(this._key);return e.$isDecoratorNode(t)?t:null}getSharedType(){return this._xmlElem}getType(){return this._type}getKey(){return this._key}getSize(){return 1}getOffset(){return this._parent.getChildOffset(this)}syncPropertiesFromLexical(e,t,n){const o=this.getPrevNode(n);N(e,this._xmlElem,o,t)}syncPropertiesFromYjs(e,t){const n=this.getNode();null===n&&l(83);m(e,this._xmlElem,n,t)}destroy(e){e.collabNodeMap.delete(this._key)}}function S(e,t,n){const o=new v(e,t,n);return e._collabNode=o,o}class P{constructor(e,t,n){this._key="",this._children=[],this._xmlText=e,this._type=n,this._parent=t}getPrevNode(t){if(null===t)return null;const n=t.get(this._key);return e.$isElementNode(n)?n:null}getNode(){const t=e.$getNodeByKey(this._key);return e.$isElementNode(t)?t:null}getSharedType(){return this._xmlText}getType(){return this._type}getKey(){return this._key}isEmpty(){return 0===this._children.length}getSize(){return 1}getOffset(){const e=this._parent;return null===e&&l(90),e.getChildOffset(this)}syncPropertiesFromYjs(e,t){const n=this.getNode();null===n&&l(91),m(e,this._xmlText,n,t)}applyChildrenYjsDelta(e,t){const n=this._children;let o=0;for(let s=0;s<t.length;s++){const l=t[s],r=l.insert,a=l.delete;if(null!=l.retain)o+=l.retain;else if("number"==typeof a){let e=a;for(;e>0;){const{node:t,nodeIndex:s,offset:l,length:r}=k(this,o,!1);if(t instanceof P||t instanceof i||t instanceof v)n.splice(s,1),e-=1;else{if(!(t instanceof c))break;{const o=Math.min(e,r),i=0!==s?n[s-1]:null,a=t.getSize();if(0===l&&r===a){n.splice(s,1);const e=b(t._text,l,o-1,"");e.length>0&&(i instanceof c?i._text+=e:this._xmlText.delete(l,e.length))}else t._text=b(t._text,l,o,"");e-=o}}}}else{if(null==r)throw new Error("Unexpected delta format");if("string"==typeof r){const{node:e,offset:t}=k(this,o,!0);e instanceof c?e._text=b(e._text,t,0,r):this._xmlText.delete(t,r.length),o+=r.length}else{const t=r,{nodeIndex:s}=k(this,o,!1),l=y(e,t,this);n.splice(s,0,l),o+=1}}}}syncChildrenFromYjs(t){const o=this.getNode();null===o&&l(92);const s=o.__key,r=n.$createChildrenArray(o,null),a=r.length,f=this._children,u=f.length,d=t.collabNodeMap,_=new Set;let h,g,y=0,m=null;u!==a&&(g=o.getWritable());for(let n=0;n<u;n++){const a=r[y],N=f[n],b=N.getNode(),k=N._key;if(null!==b&&a===k){const n=e.$isTextNode(b);if(_.add(a),n)if(N._key=a,N instanceof P){const e=N._xmlText;N.syncPropertiesFromYjs(t,null),N.applyChildrenYjsDelta(t,e.toDelta()),N.syncChildrenFromYjs(t)}else N instanceof c?N.syncPropertiesAndTextFromYjs(t,null):N instanceof v?N.syncPropertiesFromYjs(t,null):N instanceof i||l(93);m=b,y++}else{if(void 0===h){h=new Set;for(let e=0;e<u;e++){const t=f[e]._key;""!==t&&h.add(t)}}if(null!==b&&void 0!==a&&!h.has(a)){T(p(a)),n--,y++;continue}g=o.getWritable();const e=x(t,N,s),l=e.__key;if(d.set(l,N),null===m){const t=g.getFirstChild();if(g.__first=l,null!==t){const n=t.getWritable();n.__prev=l,e.__next=n.__key}}else{const t=m.getWritable(),n=m.getNextSibling();if(t.__next=l,e.__prev=m.__key,null!==n){const t=n.getWritable();t.__prev=l,e.__next=t.__key}}n===u-1&&(g.__last=l),g.__size++,m=e}}for(let e=0;e<a;e++){const n=r[e];if(!_.has(n)){const e=p(n),o=t.collabNodeMap.get(n);void 0!==o&&o.destroy(t),T(e)}}}syncPropertiesFromLexical(e,t,n){N(e,this._xmlText,this.getPrevNode(n),t)}_syncChildFromLexical(t,n,o,s,l,i){const r=this._children[n],a=p(o);r instanceof P&&e.$isElementNode(a)?(r.syncPropertiesFromLexical(t,a,s),r.syncChildrenFromLexical(t,a,s,l,i)):r instanceof c&&e.$isTextNode(a)?r.syncPropertiesAndTextFromLexical(t,a,s):r instanceof v&&e.$isDecoratorNode(a)&&r.syncPropertiesFromLexical(t,a,s)}syncChildrenFromLexical(e,t,o,s,l){const i=this.getPrevNode(o),r=null===i?[]:n.$createChildrenArray(i,o),c=n.$createChildrenArray(t,null),a=r.length-1,f=c.length-1,u=e.collabNodeMap;let d,_,h=0,y=0;for(;h<=a&&y<=f;){const t=r[h],n=c[y];if(t===n)this._syncChildFromLexical(e,y,n,o,s,l),h++,y++;else{void 0===d&&(d=new Set(r)),void 0===_&&(_=new Set(c));const o=_.has(t),s=d.has(n);if(o){const t=g(e,p(n),this);u.set(n,t),s?(this.splice(e,y,1,t),h++,y++):(this.splice(e,y,0,t),y++)}else this.splice(e,y,1),h++}}const x=h>a,m=y>f;if(x&&!m)for(;y<=f;++y){const t=c[y],n=g(e,p(t),this);this.append(n),u.set(t,n)}else if(m&&!x)for(let t=this._children.length-1;t>=y;t--)this.splice(e,t,1)}append(e){const t=this._xmlText,n=this._children,o=n[n.length-1],s=void 0!==o?o.getOffset()+o.getSize():0;if(e instanceof P)t.insertEmbed(s,e._xmlText);else if(e instanceof c){const n=e._map;null===n.parent&&t.insertEmbed(s,n),t.insert(s+1,e._text)}else e instanceof i?t.insertEmbed(s,e._map):e instanceof v&&t.insertEmbed(s,e._xmlElem);this._children.push(e)}splice(e,t,n,o){const s=this._children,r=s[t];if(void 0===r)return void 0===o&&l(94),void this.append(o);const a=r.getOffset();-1===a&&l(95);const f=this._xmlText;if(0!==n&&f.delete(a,r.getSize()),o instanceof P)f.insertEmbed(a,o._xmlText);else if(o instanceof c){const e=o._map;null===e.parent&&f.insertEmbed(a,e),f.insert(a+1,o._text)}else o instanceof i?f.insertEmbed(a,o._map):o instanceof v&&f.insertEmbed(a,o._xmlElem);if(0!==n){const o=s.slice(t,t+n);for(let t=0;t<o.length;t++)o[t].destroy(e)}void 0!==o?s.splice(t,n,o):s.splice(t,n)}getChildOffset(e){let t=0;const n=this._children;for(let o=0;o<n.length;o++){const s=n[o];if(s===e)return t;t+=s.getSize()}return-1}destroy(e){const t=e.collabNodeMap,n=this._children;for(let t=0;t<n.length;t++)n[t].destroy(e);t.delete(this._key)}}function w(e,t,n){const o=new P(e,t,n);return e._collabNode=o,o}function E(n,o){const s=o.collabNodeMap.get(n.key);if(void 0===s)return null;let i=n.offset,r=s.getSharedType();if(s instanceof c){r=s._parent._xmlText;const e=s.getOffset();if(-1===e)return null;i=e+1+i}else if(s instanceof P&&"element"===n.type){const t=n.getNode();e.$isElementNode(t)||l(184);let o=0,s=0,r=t.getFirstChild();for(;null!==r&&s++<i;)e.$isTextNode(r)?o+=r.getTextContentSize()+1:o++,r=r.getNextSibling();i=o}return t.createRelativePositionFromTypeIndex(r,i)}function M(e,n){return t.createAbsolutePositionFromRelativePosition(e,n.doc)}function F(e,n){if(null==e){if(null!=n)return!0}else if(null==n||!t.compareRelativePositions(e,n))return!0;return!1}function O(e,t){return{color:t,name:e,selection:null}}function L(e,t){const n=e.cursorsContainer;if(null!==n){const e=t.selections,o=e.length;for(let t=0;t<o;t++)n.removeChild(e[t])}}function A(e,t){const n=t.selection;null!==n&&L(e,n)}function D(e,t,n,o,s){const l=e.color,i=document.createElement("span");i.style.cssText=`position:absolute;top:0;bottom:0;right:-1px;width:1px;background-color:${l};z-index:10;`;const r=document.createElement("span");return r.textContent=e.name,r.style.cssText=`position:absolute;left:-2px;top:-16px;background-color:${l};color:#fff;line-height:12px;font-size:12px;padding:2px;font-family:Arial;font-weight:bold;white-space:nowrap;`,i.appendChild(r),{anchor:{key:t,offset:n},caret:i,color:l,focus:{key:o,offset:s},name:r,selections:[]}}function j(t,n,s,l){const i=t.editor,r=i.getRootElement(),c=t.cursorsContainer;if(null===c||null===r)return;const a=c.offsetParent;if(null===a)return;const f=a.getBoundingClientRect(),u=n.selection;if(null===s)return null===u?void 0:(n.selection=null,void L(t,u));n.selection=s;const d=s.caret,_=s.color,h=s.selections,p=s.anchor,g=s.focus,y=p.key,x=g.key,m=l.get(y),N=l.get(x);if(null==m||null==N)return;let b;if(m===N&&e.$isLineBreakNode(m)){b=[i.getElementByKey(y).getBoundingClientRect()]}else{const e=o.createDOMRange(i,m,p.offset,N,g.offset);if(null===e)return;b=o.createRectsFromDOMRange(i,e)}const k=h.length,C=b.length;for(let e=0;e<C;e++){const t=b[e];let n=h[e];if(void 0===n){n=document.createElement("span"),h[e]=n;const t=document.createElement("span");n.appendChild(t),c.appendChild(n)}const o=`position:absolute;top:${t.top-f.top}px;left:${t.left-f.left}px;height:${t.height}px;width:${t.width}px;pointer-events:none;z-index:5;`;n.style.cssText=o,n.firstChild.style.cssText=`${o}left:0;top:0;background-color:${_};opacity:0.3;`,e===C-1&&d.parentNode!==n&&n.appendChild(d)}for(let e=k-1;e>=C;e--){const t=h[e];c.removeChild(t),h.pop()}}function z(e,t){const{anchorPos:n,focusPos:o}=t;let s=null,l=0,i=null,r=0;if(null!==n&&null!==o){const t=M(n,e),c=M(o,e);null!==t&&null!==c&&([s,l]=K(t.type,t.index),[i,r]=K(c.type,c.index))}return{anchorCollabNode:s,anchorOffset:l,focusCollabNode:i,focusOffset:r}}function Y(t,n){const o=n.awareness.getLocalState();if(null===o)return;const{anchorCollabNode:s,anchorOffset:l,focusCollabNode:i,focusOffset:r}=z(t,o);if(null!==s&&null!==i){const t=s.getKey(),n=i.getKey(),o=e.$getSelection();if(!e.$isRangeSelection(o))return;R(o.anchor,t,l),R(o.focus,n,r)}}function R(t,n,o){if(t.key!==n||t.offset!==o){let s=e.$getNodeByKey(n);if(null!==s&&!e.$isElementNode(s)&&!e.$isTextNode(s)){const e=s.getParentOrThrow();n=e.getKey(),o=s.getIndexWithinParent(),s=e}t.set(n,o,e.$isElementNode(s)?"element":"text")}}function K(e,t){const n=e._collabNode;if(void 0===n)return[null,0];if(n instanceof P){const{node:e,offset:o}=k(n,t,!0);return null===e?[n,0]:[e,o]}return[null,0]}function B(e,t){const n=Array.from(t.awareness.getStates()),o=e.clientID,s=e.cursors,l=e.editor._editorState._nodeMap,i=new Set;for(let t=0;t<n.length;t++){const r=n[t],[c,a]=r;if(c!==o){i.add(c);const{name:t,color:n,focusing:o}=a;let r=null,f=s.get(c);if(void 0===f&&(f=O(t,n),s.set(c,f)),o){const{anchorCollabNode:t,anchorOffset:n,focusCollabNode:o,focusOffset:s}=z(e,a);if(null!==t&&null!==o){const e=t.getKey(),l=o.getKey();if(r=f.selection,null===r)r=D(f,e,n,l,s);else{const t=r.anchor,o=r.focus;t.key=e,t.offset=n,o.key=l,o.offset=s}}}j(e,f,r,l)}}const r=Array.from(s.keys());for(let t=0;t<r.length;t++){const n=r[t];if(!i.has(n)){const t=s.get(n);void 0!==t&&(A(e,t),s.delete(n))}}}function W(t,n,o,s){const l=n.awareness,i=l.getLocalState();if(null===i)return;const{anchorPos:r,focusPos:c,name:a,color:f,focusing:u,awarenessData:d}=i;let _=null,h=null;(null!==s&&(null===r||s.is(o))||null!==o)&&(e.$isRangeSelection(s)&&(_=E(s.anchor,t),h=E(s.focus,t)),(F(r,_)||F(c,h))&&l.setLocalState({...i,anchorPos:_,awarenessData:d,color:f,focusPos:h,focusing:u,name:a}))}function I(e,n){const{target:o}=n,s=y(e,o);if(s instanceof P&&n instanceof t.YTextEvent){const{keysChanged:t,childListChanged:o,delta:l}=n;t.size>0&&s.syncPropertiesFromYjs(e,t),o&&(s.applyChildrenYjsDelta(e,l),s.syncChildrenFromYjs(e))}else if(s instanceof c&&n instanceof t.YMapEvent){const{keysChanged:t}=n;t.size>0&&s.syncPropertiesAndTextFromYjs(e,t)}else if(s instanceof v&&n instanceof t.YXmlEvent){const{attributesChanged:t}=n;t.size>0&&s.syncPropertiesFromYjs(e,t)}else l(82)}const U=e.createCommand("CONNECTED_COMMAND"),X=e.createCommand("TOGGLE_CONNECT_COMMAND");exports.CONNECTED_COMMAND=U,exports.TOGGLE_CONNECT_COMMAND=X,exports.createBinding=function(e,n,o,s,i,r){null==s&&l(81);const c=w(s.get("root",t.XmlText),null,"root");return c._key="root",{clientID:s.clientID,collabNodeMap:new Map,cursors:new Map,cursorsContainer:null,doc:s,docMap:i,editor:e,excludedProperties:r||new Map,id:o,nodeProperties:new Map,root:c}},exports.createUndoManager=function(e,n){return new t.UndoManager(n,{trackedOrigins:new Set([e,null])})},exports.getAnchorAndFocusCollabNodesForUserState=z,exports.initLocalState=function(e,t,n,o,s){e.awareness.setLocalState({anchorPos:null,awarenessData:s,color:n,focusPos:null,focusing:o,name:t})},exports.setLocalStateFocus=function(e,t,n,o,s){const{awareness:l}=e;let i=l.getLocalState();null===i&&(i={anchorPos:null,awarenessData:s,color:n,focusPos:null,focusing:o,name:t}),i.focusing=o,l.setLocalState(i)},exports.syncCursorPositions=B,exports.syncLexicalUpdateToYjs=function(t,n,o,s,l,i,r,a){!function(e,t){e.doc.transact(t,e)}(t,(()=>{s.read((()=>{if(a.has("collaboration")||a.has("historic"))return void(r.size>0&&function(t,n){const o=Array.from(n),s=t.collabNodeMap,l=[];for(let t=0;t<o.length;t++){const n=o[t],i=e.$getNodeByKey(n),r=s.get(n);if(r instanceof c)if(e.$isTextNode(i))l.push([r,i.__text]);else{const e=r.getOffset();if(-1===e)continue;const t=r._parent;r._normalized=!0,t._xmlText.delete(e,1),s.delete(n);const o=t._children,l=o.indexOf(r);o.splice(l,1)}}for(let e=0;e<l.length;e++){const[t,n]=l[e];t instanceof c&&"string"==typeof n&&(t._text=n)}}(t,r));if(l.has("root")){const n=o._nodeMap,s=e.$getRoot(),r=t.root;r.syncPropertiesFromLexical(t,s,n),r.syncChildrenFromLexical(t,s,n,l,i)}const s=e.$getSelection(),f=o._selection;W(t,n,f,s)}))}))},exports.syncYjsChangesToLexical=function(t,n,o,s){const l=t.editor,i=l._editorState;o.forEach((e=>e.delta)),l.update((()=>{for(let e=0;e<o.length;e++){const n=o[e];I(t,n)}const s=e.$getSelection();if(e.$isRangeSelection(s))if(C(s)){const o=i._selection;if(e.$isRangeSelection(o)&&(Y(t,n),C(s))){$(s.anchor.key,i)}W(t,n,o,e.$getSelection())}else Y(t,n)}),{onUpdate:()=>{B(t,n),l.update((()=>{0===e.$getRoot().getChildrenSize()&&e.$getRoot().append(e.$createParagraphNode())}))},skipTransforms:!0,tag:s?"historic":"collaboration"})};
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "crdt"
12
12
  ],
13
13
  "license": "MIT",
14
- "version": "0.23.2-nightly.20250114.0",
14
+ "version": "0.23.2-nightly.20250115.0",
15
15
  "main": "LexicalYjs.js",
16
16
  "types": "index.d.ts",
17
17
  "dependencies": {
18
- "@lexical/offset": "0.23.2-nightly.20250114.0",
19
- "@lexical/selection": "0.23.2-nightly.20250114.0",
20
- "lexical": "0.23.2-nightly.20250114.0"
18
+ "@lexical/offset": "0.23.2-nightly.20250115.0",
19
+ "@lexical/selection": "0.23.2-nightly.20250115.0",
20
+ "lexical": "0.23.2-nightly.20250115.0"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "yjs": ">=13.5.22"