@lexical/yjs 0.1.0 → 0.1.4

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/index.js +50 -45
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -1,49 +1,54 @@
1
- 'use strict';var r=require("yjs"),y=require("lexical"),aa=require("lexical/ParagraphNode");
2
- class z{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 y.$isTextNode(a)?a:null}getNode(){const a=y.$getNodeByKey(this._key);return y.$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){const d=
3
- this._parent._xmlText;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;B(a,this._map,d,b);if(null!==d&&(a=d.__text,a!==c)){d=b.__key;b=a;var e=y.$getSelection();a=c.length;null!==e&&e.isCollapsed()&&(e=e.anchor,e.key===d&&(a=e.offset));const f=b.length;d=c.length;let g=e=0;for(;e<f&&e<d&&b[e]===c[e]&&e<a;)e++;for(;g+e<f&&g+e<d&&b[f-g-1]===c[d-g-1];)g++;for(;g+e<f&&g+e<d&&b[e]===c[e];)e++;b=e;a=f-e-g;d=c.slice(e,
1
+ 'use strict';var t=require("yjs"),w=require("lexical"),aa=require("lexical/ParagraphNode");
2
+ class z{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 w.$isTextNode(a)?a:null}getNode(){const a=w.$getNodeByKey(this._key);return w.$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){const d=
3
+ this._parent._xmlText;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;B(a,this._map,d,b);if(null!==d&&(a=d.__text,a!==c)){d=b.__key;b=a;var e=w.$getSelection();a=c.length;null!==e&&e.isCollapsed()&&(e=e.anchor,e.key===d&&(a=e.offset));const f=b.length;d=c.length;let g=e=0;for(;e<f&&e<d&&b[e]===c[e]&&e<a;)e++;for(;g+e<f&&g+e<d&&b[f-g-1]===c[d-g-1];)g++;for(;g+e<f&&g+e<d&&b[e]===c[e];)e++;b=e;a=f-e-g;d=c.slice(e,
4
4
  d-g);this.spliceText(b,a,d);this._text=c}}syncPropertiesAndTextFromYjs(a,b){const c=this.getNode();if(null===c)throw Error("Should never happen");C(a,this._map,c,b);a=this._text;c.__text!==a&&(c.getWritable().__text=a)}destroy(a){a.collabNodeMap.delete(this._key)}}function D(a,b,c,d){b=new z(a,b,c,d);return a._collabNode=b}
5
- class F{constructor(a,b){this._key="";this._map=a;this._parent=b;this._type="linebreak"}getNode(){const a=y.$getNodeByKey(this._key);return y.$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)}}function G(a,b){b=new F(a,b);return a._collabNode=b}
6
- class H{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 y.$isDecoratorNode(a)?a:null}getNode(){const a=y.$getNodeByKey(this._key);return y.$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){const d=this.getPrevNode(c);c=this._xmlElem;const e=
7
- null===d?null:d.__ref,f=b.__ref;B(a,c,d,b);if(e!==f)if(null===f)c.removeAttribute("__ref"),null!==c.firstChild&&c.delete(0,1);else{const {id:g,_type:h}=f;c.setAttribute("__ref",{id:g,type:h});a=a.docMap;b=new r.Doc;c.insert(0,[b]);a.set(g,b)}}syncPropertiesFromYjs(a,b){const c=this.getNode();if(null===c)throw Error("Should never happen");var d=this._xmlElem,e=d.getAttribute("__ref"),f=c.__ref;C(a,d,c,b);if(void 0===e)null!==f&&(d=c.getWritable(),a=a.docMap,{id:f}=f,a.delete(f),d.__ref=null);else if("string"!==
8
- typeof e&&(null===f||f.id!==e.id||f._type!==e.type)){f=c.getWritable();const {id:g,type:h}=e;"editorstate"===h&&(e=y.createEditorStateRef(g,null),d=d.firstChild,null!==d&&a.docMap.set(g,d),f.__ref=e)}}destroy(a){a.collabNodeMap.delete(this._key)}}function I(a,b,c){b=new H(a,b,c);return a._collabNode=b}const K=new Set("__key __children __parent __cachedText __text __ref".split(" "));function L(a){a=y.$getNodeByKey(a);if(null===a)throw Error("Should never happen");return a}
9
- function M(a,b,c){const d=b.__type;if(y.$isElementNode(b)){var e=new r.XmlText;c=N(e,c,d);c.syncPropertiesFromLexical(a,b,null);c.syncChildrenFromLexical(a,b,null,null,null)}else if(y.$isTextNode(b))e=new r.Map,c=D(e,b.__text,c,d),c.syncPropertiesAndTextFromLexical(a,b,null);else if(y.$isLineBreakNode(b))a=new r.Map,a.set("__type","linebreak"),c=G(a,c);else if(y.$isDecoratorNode(b))e=new r.XmlElement,c=I(e,c,d),c.syncPropertiesFromLexical(a,b,null);else throw Error("Should never happen");c._key=b.__key;
5
+ class F{constructor(a,b){this._key="";this._map=a;this._parent=b;this._type="linebreak"}getNode(){const a=w.$getNodeByKey(this._key);return w.$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)}}function G(a,b){b=new F(a,b);return a._collabNode=b}
6
+ function H(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function I(a,b,c,d){const e=c.observe(f=>{J(a,()=>L(a,b,c,c._map,d,f))});b._unobservers.add(e)}
7
+ function L(a,b,c,d,e,f){const g=d.get(f);d=e.get(f);if(g!==d)if(w.isDecoratorMap(g))void 0===d&&(d=new t.Map,d._lexicalValue=g,d._collabNode=b,d.set("type","map"),e.set(f,d),I(a,b,c,e)),M(a,b,g,d);else if(w.isDecoratorEditor(g)){let h;void 0===d&&(d=new t.Map,d._lexicalValue=g,d._collabNode=b,h=new t.Doc,d.set("doc",h),d.set("type","editor"),e.set(f,d));h=h||d.get("doc");b=d.get("id");c=g.id;b!==c&&(a=a.docMap,a.delete(b),d.set("id",c),a.set(c,h))}else e.set(f,g)}
8
+ function M(a,b,c,d){const e=c._map,f=Array.from(e.keys());for(let g=0;g<f.length;g++)L(a,b,c,e,d,f[g])}
9
+ function N(a,b,c,d,e){const f=d._map;e=null===e?Array.from(c.keys()):Array.from(e);for(let p=0;p<e.length;p++){var g=a,h=b,n=c,k=d,l=f,q=e[p],r=l.get(q);const m=n.get(q);r!==m&&(m instanceof t.Map?(r=m.get("type"),k=m._lexicalValue,"editor"===r?void 0===k&&(g=g.docMap,n=m.get("id"),r=m.get("doc"),k=w.createDecoratorEditor(n),m._lexicalValue=k,m._collabNode=h,g.set(n,r),l.set(q,k)):"map"===r?(void 0===k&&(k=w.createDecoratorMap(g.editor),I(g,h,k,n),m._lexicalValue=k,m._collabNode=h,l.set(q,k)),N(g,
10
+ h,m,k,null)):H(48)):k.set(q,m))}}
11
+ class O{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 w.$isDecoratorNode(a)?a:null}getNode(){const a=w.$getNodeByKey(this._key);return w.$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){const d=this.getPrevNode(c);
12
+ c=this._xmlElem;const e=null===d?null:d.__state,f=b.__state;B(a,c,d,b);e!==f&&(b=new t.Map,c.insert(0,[b]),b._lexicalValue=f,b._collabNode=this,M(a,this,f,b),I(a,this,f,b))}syncPropertiesFromYjs(a,b){const c=this.getNode();if(null===c)throw Error("Should never happen");const d=this._xmlElem,e=d.firstChild,f=c.__state;e._lexicalValue=f;e._collabNode=this;C(a,d,c,b);N(a,this,e,f,null);I(a,this,f,e)}destroy(a){a.collabNodeMap.delete(this._key);this._unobservers.forEach(b=>b());this._unobservers.clear()}}
13
+ function P(a,b,c){b=new O(a,b,c);return a._collabNode=b}const R=new Set("__key __children __parent __cachedText __text __state".split(" "));function S(a){a=w.$getNodeByKey(a);if(null===a)throw Error("Should never happen");return a}
14
+ function T(a,b,c){const d=b.__type;if(w.$isElementNode(b)){var e=new t.XmlText;c=U(e,c,d);c.syncPropertiesFromLexical(a,b,null);c.syncChildrenFromLexical(a,b,null,null,null)}else if(w.$isTextNode(b))e=new t.Map,c=D(e,b.__text,c,d),c.syncPropertiesAndTextFromLexical(a,b,null);else if(w.$isLineBreakNode(b))a=new t.Map,a.set("__type","linebreak"),c=G(a,c);else if(w.$isDecoratorNode(b))e=new t.XmlElement,c=P(e,c,d),c.syncPropertiesFromLexical(a,b,null);else throw Error("Should never happen");c._key=b.__key;
10
15
  return c}
11
- function P(a,b,c){const d=b._collabNode;if(void 0===d){var e=a.editor._registeredNodes;const f=b instanceof r.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?P(a,e):c||null;if(!(a instanceof Q))throw Error("Should never happen");if(b instanceof r.XmlText)return N(b,a,f);if(b instanceof r.Map){if(null===a)throw Error("Should never happen");return"linebreak"===f?G(b,a):
12
- D(b,"",a,f)}if(b instanceof r.XmlElement)return I(b,a,f)}return d}function C(a,b,c,d){a=null===d?b instanceof r.Map?Array.from(b.keys()):Object.keys(b.getAttributes()):Array.from(d);let e;for(d=0;d<a.length;d++){const f=a[d];if(K.has(f))continue;const g=c[f],h=b instanceof r.Map?b.get(f):b.getAttribute(f);g!==h&&(void 0===e&&(e=c.getWritable()),e[f]=h)}}
13
- function B(a,b,c,d){var e=d.__type,f=a.nodeProperties;a=f.get(e);void 0===a&&(a=Object.keys(d).filter(g=>!K.has(g)),f.set(e,a));for(e=0;e<a.length;e++){f=a[e];const g=d[f];(null===c?void 0:c[f])!==g&&(b instanceof r.Map?b.set(f,g):b.setAttribute(f,g))}}
14
- function R(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,m=a.getSize();d+=m;if((c?d>=b:d>b)&&a instanceof z)return b=b-h-1,0>b&&(b=0),{node:a,nodeIndex:e,offset:b,length:m-b};if(d>b)return{node:a,nodeIndex:e,offset:h,length:0};if(e===g-1)return{node:null,nodeIndex:e+1,offset:h+1,length:0}}return{node:null,nodeIndex:0,offset:0,length:0}}
15
- function S(a){const b=a.anchor;a=a.focus;let c=!1;try{const d=b.getNode(),e=a.getNode();if(!d.isAttached()||!e.isAttached()||y.$isTextNode(d)&&b.offset>d.getTextContentSize()||y.$isTextNode(e)&&a.offset>e.getTextContentSize())c=!0}catch(d){c=!0}return c}
16
- 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 y.$isElementNode(a)?a:null}getNode(){const a=y.$getNodeByKey(this._key);return y.$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(){const a=this._parent;if(null===a)throw Error("Should never happen");
17
- return a.getChildOffset(this)}syncPropertiesFromYjs(a,b){const c=this.getNode();if(null===c)throw this.getNode(),Error("Should never happen");C(a,this._xmlText,c,b)}applyChildrenYjsDelta(a,b){const c=this._children;let d=0;for(let k=0;k<b.length;k++){var e=b[k],f=e.insert,g=e.delete;if(null!=e.retain)d+=e.retain;else if("number"===typeof g)for(f=g;0<f;){const {node:l,nodeIndex:q,offset:t,length:p}=R(this,d,!1);if(l instanceof Q||l instanceof F||l instanceof H)c.splice(q,1),--f;else if(l instanceof
18
- z){e=Math.min(f,p);g=0!==q?c[q-1]:null;var h=l.getSize();if(0===t&&1===e&&0<q&&g instanceof z&&p===h)g._text+=l._text,c.splice(q,1);else if(0===t&&e===h)c.splice(q,1);else{g=l._text;h=t;var m=e;g=g.slice(0,h)+""+g.slice(h+m);l._text=g}f-=e}else break}else if(null!=f)if("string"===typeof f){const {node:l,offset:q}=R(this,d,!0);l instanceof z?(e=l._text,g=q,h=f,e=e.slice(0,g)+h+e.slice(g+0),l._text=e):this._xmlText.delete(q,f.length);d+=f.length}else e=f,{nodeIndex:f}=R(this,d,!1),e=P(a,e,this),c.splice(f,
19
- 0,e),d+=1;else throw Error("Unexpected delta format");}}syncChildrenFromYjs(a){var b=this.getNode();if(null===b)throw this.getNode(),Error("Should never happen");var c=b.__key;const d=b.__children;var e=[];const f=d.length,g=this._children,h=g.length,m=a.collabNodeMap,k=new Set;let l,q;h!==f&&(q=T(b,q,e));let t=0;for(let x=0;x<h;x++){var p=d[t];const w=g[x];var n=w.getNode(),u=w._key;if(null!==n&&p===u){n=y.$isTextNode(n);k.add(p);if(n)if(w._key=p,w instanceof Q)n=w._xmlText,w.syncPropertiesFromYjs(a,
20
- null),w.applyChildrenYjsDelta(a,n.toDelta()),w.syncChildrenFromYjs(a);else if(w instanceof z)w.syncPropertiesAndTextFromYjs(a,null);else if(w instanceof H)w.syncPropertiesFromYjs(a,null);else if(!(w instanceof F))throw Error("Should never happen");e[x]=p;t++}else{if(void 0===l)for(l=new Set,u=0;u<h;u++){var v=g[u]._key;""!==v&&l.add(v)}if(null===n||void 0===p||l.has(p)){q=T(b,q,e);p=a;n=w;u=c;v=n.getType();v=p.editor._registeredNodes.get(v);if(void 0===v)throw Error("createLexicalNode failed");v=
21
- new v.klass;v.__parent=u;n._key=v.__key;n instanceof Q?(u=n._xmlText,n.syncPropertiesFromYjs(p,null),n.applyChildrenYjsDelta(p,u.toDelta()),n.syncChildrenFromYjs(p)):n instanceof z?n.syncPropertiesAndTextFromYjs(p,null):n instanceof H&&n.syncPropertiesFromYjs(p,null);p.collabNodeMap.set(v.__key,n);p=v.__key;m.set(p,w);e[x]=p}else x--,t++}}for(b=0;b<f;b++)e=d[b],k.has(e)||(c=L(e).getWritable(),e=a.collabNodeMap.get(e),void 0!==e&&e.destroy(a),c.__parent=null)}syncPropertiesFromLexical(a,b,c){B(a,this._xmlText,
22
- this.getPrevNode(c),b)}_syncChildFromLexical(a,b,c,d,e,f){b=this._children[b];c=L(c);b instanceof Q&&y.$isElementNode(c)?(b.syncPropertiesFromLexical(a,c,d),b.syncChildrenFromLexical(a,c,d,e,f)):b instanceof z&&y.$isTextNode(c)?b.syncPropertiesAndTextFromLexical(a,c,d):b instanceof H&&y.$isDecoratorNode(c)&&b.syncPropertiesFromLexical(a,c,d)}syncChildrenFromLexical(a,b,c,d,e){var f=this.getPrevNode(c);const g=null===f?[]:f.__children;f=b.__children;const h=g.length-1,m=f.length-1,k=a.collabNodeMap;
23
- let l,q,t=0;for(b=0;t<=h&&b<=m;){var p=g[t];const u=f[b];if(p===u)this._syncChildFromLexical(a,b,u,c,d,e),t++,b++;else{void 0===l&&(l=new Set(g));void 0===q&&(q=new Set(f));var n=q.has(p);p=l.has(u);n?(n=L(u),n=M(a,n,this),k.set(u,n),p?(this.splice(a,b,1,n),t++):this.splice(a,b,0,n),b++):(this.splice(a,b,1),t++)}}c=t>h;d=b>m;if(c&&!d)for(;b<=m;++b)c=f[b],d=L(c),d=M(a,d,this),this.append(d),k.set(c,d);else if(d&&!c)for(f=this._children.length-1;f>=b;f--)this.splice(a,f,1)}append(a){const b=this._xmlText;
24
- var c=this._children;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 z){const d=a._map;null===d.parent&&b.insertEmbed(c,d);b.insert(c+1,a._text)}else a instanceof F?b.insertEmbed(c,a._map):a instanceof H&&b.insertEmbed(c,a._xmlElem);this._children.push(a)}splice(a,b,c,d){const e=this._children;var f=e[b];if(void 0===f)if(void 0!==d)this.append(d);else throw Error("Should never happen");else{var g=f.getOffset();if(-1===g)throw Error("Should never happen");
25
- var h=this._xmlText;0!==c&&h.delete(g,f.getSize());d instanceof Q?h.insertEmbed(g,d._xmlText):d instanceof z?(f=d._map,null===f.parent&&h.insertEmbed(g,f),h.insert(g+1,d._text)):d instanceof F?h.insertEmbed(g,d._map):d instanceof H&&h.insertEmbed(g,d._xmlElem);if(0!==c)for(g=e.slice(b,b+c),h=0;h<g.length;h++)g[h].destroy(a);void 0!==d?e.splice(b,c,d):e.splice(b,c)}}getChildOffset(a){let b=0;const c=this._children;for(let d=0;d<c.length;d++){const e=c[d];if(e===a)return b;b+=e.getSize()}return-1}destroy(a){const b=
26
- a.collabNodeMap,c=this._children;for(let d=0;d<c.length;d++)c[d].destroy(a);b.delete(this._key)}}function T(a,b,c){return void 0===b?(a=a.getWritable(),a.__children=c,a):b}function N(a,b,c){b=new Q(a,b,c);return a._collabNode=b}function U(a,b){b=b.collabNodeMap.get(a.key);if(void 0===b)return null;a=a.offset;let c=b.getSharedType();if(b instanceof z){c=b._parent._xmlText;b=b.getOffset();if(-1===b)return null;a=b+1+a}return r.createRelativePositionFromTypeIndex(c,a)}
27
- function V(a,b){if(null==a){if(null!=b)return!0}else if(null==b||!r.compareRelativePositions(a,b))return!0;return!1}function W(a,b){a=a.cursorsContainer;if(null!==a){b=b.selections;const c=b.length;for(let d=0;d<c;d++)a.removeChild(b[d])}}function X(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function ba(a){const b=a.parentNode;if(null==b)throw Error("Should never happen");return[b,Array.from(b.childNodes).indexOf(a)]}
28
- function ca(a,b){var c=b.awareness.getLocalState();if(null!==c&&(b=c.anchorPos,c=c.focusPos,null!==b&&null!==c&&(b=r.createAbsolutePositionFromRelativePosition(b,a.doc),a=r.createAbsolutePositionFromRelativePosition(c,a.doc),null!==b&&null!==a))){const [e,f]=Y(b.type,b.index),[g,h]=Y(a.type,a.index);if(null!==e&&null!==g){c=e.getKey();a=g.getKey();b=y.$getSelection();if(null===b)throw Error("TODO: syncLocalCursorPosition");var d=b.anchor;const m=b.focus;if(d.key!==c||d.offset!==f)d=y.$getNodeByKey(c),
29
- b.anchor.set(c,f,y.$isElementNode(d)?"element":"text");if(m.key!==a||m.offset!==h)c=y.$getNodeByKey(a),b.focus.set(a,h,y.$isElementNode(c)?"element":"text")}}}function Y(a,b){a=a._collabNode;if(void 0===a)return[null,0];if(a instanceof Q){const {node:c,offset:d}=R(a,b,!0);return null===c?[a,0]:[c,d]}return[null,0]}
30
- function ia(a,b){var c=Array.from(b.awareness.getStates()),d=a.doc.clientID;b=a.cursors;var e=a.editor._editorState._nodeMap;const f=new Set;for(var g=0;g<c.length;g++){const [J,na]=c[g];if(J!==d){f.add(J);const {anchorPos:da,focusPos:ea,name:oa,color:pa,focusing:qa}=na;var h=null,m=b.get(J);void 0===m&&(m={color:pa,name:oa,selection:null},b.set(J,m));if(null!==da&&null!==ea&&qa){var k=r.createAbsolutePositionFromRelativePosition(da,a.doc),l=r.createAbsolutePositionFromRelativePosition(ea,a.doc);
31
- if(null!==k&&null!==l){const [E,O]=Y(k.type,k.index),[fa,ha]=Y(l.type,l.index);if(null!==E&&null!==fa){l=E.getKey();var q=fa.getKey();h=m.selection;if(null===h){k=m;h=l;l=O;var t=ha,p=k.color,n=document.createElement("span");n.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=k.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`;
32
- n.appendChild(u);h={caret:n,name:u,color:p,range:document.createRange(),selections:[],anchor:{key:h,offset:l},focus:{key:q,offset:t}}}else k=h.anchor,t=h.focus,k.key=l,k.offset=O,t.key=q,t.offset=ha}}}a:{k=a;l=m;n=h;var v=e;p=k.editor;q=p.getRootElement();m=k.cursorsContainer;if(null===m||null===q)break a;h=l.selection;if(null===n){null!==h&&(l.selection=null,W(k,h));break a}else l.selection=n;t=n.range;h=n.caret;l=n.color;k=n.selections;var x=n.anchor,w=n.focus;n=x.key;u=w.key;var A=v.get(n);const E=
33
- v.get(u);v=p.getElementByKey(n);p=p.getElementByKey(u);x=x.offset;w=w.offset;y.$isTextNode(A)&&(v=X(v));y.$isTextNode(E)&&(p=X(p));if(void 0!==A&&void 0!==E&&null!==v&&null!==p){"BR"===v.nodeName&&([v,x]=ba(v));"BR"===p.nodeName&&([p,w]=ba(p));A=v.firstChild;v===p&&null!=A&&"BR"===A.nodeName&&0===x&&0===w&&(w=1);try{t.setStart(v,x),t.setEnd(p,w)}catch(O){break a}!t.collapsed||x===w&&n===u||(t.setStart(p,w),t.setEnd(v,x));p=q.getBoundingClientRect();q=getComputedStyle(q);q=parseFloat(q.paddingLeft)+
34
- parseFloat(q.paddingRight);n=Array.from(t.getClientRects());t=n.length;u=k.length;for(A=0;A<t;A++)v=n[A],v.width+q===p.width?(n.splice(A--,1),t--):(x=k[A],void 0===x&&(x=document.createElement("span"),k[A]=x,m.appendChild(x)),x.style.cssText=`position:absolute;top:${v.top}px;left:${v.left}px;height:${v.height}px;width:${v.width}px;background-color:rgba(${l}, 0.3);pointer-events:none;z-index:10;`,A===t-1&&h.parentNode!==x&&x.appendChild(h));for(h=u-1;h>=t;h--)m.removeChild(k[h]),k.pop()}}}}c=Array.from(b.keys());
35
- for(d=0;d<c.length;d++)e=c[d],f.has(e)||(g=b.get(e),void 0!==g&&(g=g.selection,null!==g&&W(a,g),b.delete(e)))}function ja(a,b,c,d){b=b.awareness;var e=b.getLocalState();if(null!==e){var {anchorPos:f,focusPos:g,name:h,color:m,focusing:k}=e,l=e=null;if(null!==d&&(null===f||d.is(c))||null!==c)null!==d&&(e=U(d.anchor,a),l=U(d.focus,a)),(V(f,e)||V(g,l))&&b.setLocalState({name:h,color:m,anchorPos:e,focusPos:l,focusing:k})}}
36
- class ka{constructor(a,b,c=1){this._offsetMap=a;this._firstNode=b;this._blockOffsetSize=c}createSelectionFromOffsets(a,b,c){var d=this._firstNode;if(null===d)return null;var e=Z(d,a,this._blockOffsetSize);let f=Z(d,b,this._blockOffsetSize);void 0!==c&&(a=la(a,e,c,this,this._blockOffsetSize),e=Z(d,a,this._blockOffsetSize),b=la(b,f,c,this,this._blockOffsetSize),f=Z(d,b,this._blockOffsetSize));if(null===e||null===f)return null;c=e.key;d=f.key;const g=y.$getNodeByKey(c),h=y.$getNodeByKey(d);if(null===
37
- g||null===h)return null;let m=0,k=0,l="element",q="element";"text"===e.type?(m=a-e.start,l="text",e=g.getNextSibling(),a!==b&&m===g.getTextContentSize()&&y.$isTextNode(e)&&(m=0,c=e.__key)):"inline"===e.type&&(c=g.getParentOrThrow().getKey(),m=b>e.start?e.end:e.start);"text"===f.type?(k=b-f.start,q="text"):"inline"===f.type&&(d=h.getParentOrThrow().getKey(),k=b>f.start?f.end:f.start);a=y.$createSelection();if(null===a)return null;a.anchor.set(c,m,l);a.focus.set(d,k,q);return a}getOffsetsFromSelection(a){var b=
16
+ function V(a,b,c){const d=b._collabNode;if(void 0===d){var e=a.editor._registeredNodes;const f=b instanceof t.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?V(a,e):c||null;if(!(a instanceof W))throw Error("Should never happen");if(b instanceof t.XmlText)return U(b,a,f);if(b instanceof t.Map){if(null===a)throw Error("Should never happen");return"linebreak"===f?G(b,a):
17
+ D(b,"",a,f)}if(b instanceof t.XmlElement)return P(b,a,f)}return d}function C(a,b,c,d){a=null===d?b instanceof t.Map?Array.from(b.keys()):Object.keys(b.getAttributes()):Array.from(d);let e;for(d=0;d<a.length;d++){const f=a[d];if(R.has(f))continue;const g=c[f],h=b instanceof t.Map?b.get(f):b.getAttribute(f);g!==h&&(void 0===e&&(e=c.getWritable()),e[f]=h)}}
18
+ function B(a,b,c,d){var e=d.__type,f=a.nodeProperties;a=f.get(e);void 0===a&&(a=Object.keys(d).filter(g=>!R.has(g)),f.set(e,a));for(e=0;e<a.length;e++){f=a[e];const g=d[f];(null===c?void 0:c[f])!==g&&(b instanceof t.Map?b.set(f,g):b.setAttribute(f,g))}}
19
+ function X(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,n=a.getSize();d+=n;if((c?d>=b:d>b)&&a instanceof z)return b=b-h-1,0>b&&(b=0),{node:a,nodeIndex:e,offset:b,length:n-b};if(d>b)return{node:a,nodeIndex:e,offset:h,length:0};if(e===g-1)return{node:null,nodeIndex:e+1,offset:h+1,length:0}}return{node:null,nodeIndex:0,offset:0,length:0}}
20
+ function ba(a){const b=a.anchor;a=a.focus;let c=!1;try{const d=b.getNode(),e=a.getNode();if(!d.isAttached()||!e.isAttached()||w.$isTextNode(d)&&b.offset>d.getTextContentSize()||w.$isTextNode(e)&&a.offset>e.getTextContentSize())c=!0}catch(d){c=!0}return c}function J(a,b){a.doc.transact(b,a)}
21
+ class W{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 w.$isElementNode(a)?a:null}getNode(){const a=w.$getNodeByKey(this._key);return w.$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(){const a=this._parent;if(null===a)throw Error("Should never happen");
22
+ return a.getChildOffset(this)}syncPropertiesFromYjs(a,b){const c=this.getNode();if(null===c)throw this.getNode(),Error("Should never happen");C(a,this._xmlText,c,b)}applyChildrenYjsDelta(a,b){const c=this._children;let d=0;for(let k=0;k<b.length;k++){var e=b[k],f=e.insert,g=e.delete;if(null!=e.retain)d+=e.retain;else if("number"===typeof g)for(f=g;0<f;){const {node:l,nodeIndex:q,offset:r,length:p}=X(this,d,!1);if(l instanceof W||l instanceof F||l instanceof O)c.splice(q,1),--f;else if(l instanceof
23
+ z){e=Math.min(f,p);g=0!==q?c[q-1]:null;var h=l.getSize();if(0===r&&1===e&&0<q&&g instanceof z&&p===h)g._text+=l._text,c.splice(q,1);else if(0===r&&e===h)c.splice(q,1);else{g=l._text;h=r;var n=e;g=g.slice(0,h)+""+g.slice(h+n);l._text=g}f-=e}else break}else if(null!=f)if("string"===typeof f){const {node:l,offset:q}=X(this,d,!0);l instanceof z?(e=l._text,g=q,h=f,e=e.slice(0,g)+h+e.slice(g+0),l._text=e):this._xmlText.delete(q,f.length);d+=f.length}else e=f,{nodeIndex:f}=X(this,d,!1),e=V(a,e,this),c.splice(f,
24
+ 0,e),d+=1;else throw Error("Unexpected delta format");}}syncChildrenFromYjs(a){var b=this.getNode();if(null===b)throw this.getNode(),Error("Should never happen");var c=b.__key;const d=b.__children;var e=[];const f=d.length,g=this._children,h=g.length,n=a.collabNodeMap,k=new Set;let l,q;h!==f&&(q=ca(b,q,e));let r=0;for(let y=0;y<h;y++){var p=d[r];const x=g[y];var m=x.getNode(),u=x._key;if(null!==m&&p===u){m=w.$isTextNode(m);k.add(p);if(m)if(x._key=p,x instanceof W)m=x._xmlText,x.syncPropertiesFromYjs(a,
25
+ null),x.applyChildrenYjsDelta(a,m.toDelta()),x.syncChildrenFromYjs(a);else if(x instanceof z)x.syncPropertiesAndTextFromYjs(a,null);else if(x instanceof O)x.syncPropertiesFromYjs(a,null);else if(!(x instanceof F))throw Error("Should never happen");e[y]=p;r++}else{if(void 0===l)for(l=new Set,u=0;u<h;u++){var v=g[u]._key;""!==v&&l.add(v)}if(null===m||void 0===p||l.has(p)){q=ca(b,q,e);p=a;m=x;u=c;v=m.getType();v=p.editor._registeredNodes.get(v);if(void 0===v)throw Error("createLexicalNode failed");v=
26
+ new v.klass;v.__parent=u;m._key=v.__key;m instanceof W?(u=m._xmlText,m.syncPropertiesFromYjs(p,null),m.applyChildrenYjsDelta(p,u.toDelta()),m.syncChildrenFromYjs(p)):m instanceof z?m.syncPropertiesAndTextFromYjs(p,null):m instanceof O&&m.syncPropertiesFromYjs(p,null);p.collabNodeMap.set(v.__key,m);p=v.__key;n.set(p,x);e[y]=p}else y--,r++}}for(b=0;b<f;b++)e=d[b],k.has(e)||(c=S(e).getWritable(),e=a.collabNodeMap.get(e),void 0!==e&&e.destroy(a),c.__parent=null)}syncPropertiesFromLexical(a,b,c){B(a,this._xmlText,
27
+ this.getPrevNode(c),b)}_syncChildFromLexical(a,b,c,d,e,f){b=this._children[b];c=S(c);b instanceof W&&w.$isElementNode(c)?(b.syncPropertiesFromLexical(a,c,d),b.syncChildrenFromLexical(a,c,d,e,f)):b instanceof z&&w.$isTextNode(c)?b.syncPropertiesAndTextFromLexical(a,c,d):b instanceof O&&w.$isDecoratorNode(c)&&b.syncPropertiesFromLexical(a,c,d)}syncChildrenFromLexical(a,b,c,d,e){var f=this.getPrevNode(c);const g=null===f?[]:f.__children;f=b.__children;const h=g.length-1,n=f.length-1,k=a.collabNodeMap;
28
+ let l,q,r=0;for(b=0;r<=h&&b<=n;){var p=g[r];const u=f[b];if(p===u)this._syncChildFromLexical(a,b,u,c,d,e),r++,b++;else{void 0===l&&(l=new Set(g));void 0===q&&(q=new Set(f));var m=q.has(p);p=l.has(u);m?(m=S(u),m=T(a,m,this),k.set(u,m),p?(this.splice(a,b,1,m),r++):this.splice(a,b,0,m),b++):(this.splice(a,b,1),r++)}}c=r>h;d=b>n;if(c&&!d)for(;b<=n;++b)c=f[b],d=S(c),d=T(a,d,this),this.append(d),k.set(c,d);else if(d&&!c)for(f=this._children.length-1;f>=b;f--)this.splice(a,f,1)}append(a){const b=this._xmlText;
29
+ var c=this._children;c=c[c.length-1];c=void 0!==c?c.getOffset()+c.getSize():0;if(a instanceof W)b.insertEmbed(c,a._xmlText);else if(a instanceof z){const d=a._map;null===d.parent&&b.insertEmbed(c,d);b.insert(c+1,a._text)}else a instanceof F?b.insertEmbed(c,a._map):a instanceof O&&b.insertEmbed(c,a._xmlElem);this._children.push(a)}splice(a,b,c,d){const e=this._children;var f=e[b];if(void 0===f)if(void 0!==d)this.append(d);else throw Error("Should never happen");else{var g=f.getOffset();if(-1===g)throw Error("Should never happen");
30
+ var h=this._xmlText;0!==c&&h.delete(g,f.getSize());d instanceof W?h.insertEmbed(g,d._xmlText):d instanceof z?(f=d._map,null===f.parent&&h.insertEmbed(g,f),h.insert(g+1,d._text)):d instanceof F?h.insertEmbed(g,d._map):d instanceof O&&h.insertEmbed(g,d._xmlElem);if(0!==c)for(g=e.slice(b,b+c),h=0;h<g.length;h++)g[h].destroy(a);void 0!==d?e.splice(b,c,d):e.splice(b,c)}}getChildOffset(a){let b=0;const c=this._children;for(let d=0;d<c.length;d++){const e=c[d];if(e===a)return b;b+=e.getSize()}return-1}destroy(a){const b=
31
+ a.collabNodeMap,c=this._children;for(let d=0;d<c.length;d++)c[d].destroy(a);b.delete(this._key)}}function ca(a,b,c){return void 0===b?(a=a.getWritable(),a.__children=c,a):b}function U(a,b,c){b=new W(a,b,c);return a._collabNode=b}function da(a,b){b=b.collabNodeMap.get(a.key);if(void 0===b)return null;a=a.offset;let c=b.getSharedType();if(b instanceof z){c=b._parent._xmlText;b=b.getOffset();if(-1===b)return null;a=b+1+a}return t.createRelativePositionFromTypeIndex(c,a)}
32
+ function ea(a,b){if(null==a){if(null!=b)return!0}else if(null==b||!t.compareRelativePositions(a,b))return!0;return!1}function fa(a,b){a=a.cursorsContainer;if(null!==a){b=b.selections;const c=b.length;for(let d=0;d<c;d++)a.removeChild(b[d])}}function ha(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function ia(a){const b=a.parentNode;if(null==b)throw Error("Should never happen");return[b,Array.from(b.childNodes).indexOf(a)]}
33
+ function ja(a,b){var c=b.awareness.getLocalState();if(null!==c&&(b=c.anchorPos,c=c.focusPos,null!==b&&null!==c&&(b=t.createAbsolutePositionFromRelativePosition(b,a.doc),a=t.createAbsolutePositionFromRelativePosition(c,a.doc),null!==b&&null!==a))){const [e,f]=Y(b.type,b.index),[g,h]=Y(a.type,a.index);if(null!==e&&null!==g){c=e.getKey();a=g.getKey();b=w.$getSelection();if(null===b)throw Error("TODO: syncLocalCursorPosition");var d=b.anchor;const n=b.focus;if(d.key!==c||d.offset!==f)d=w.$getNodeByKey(c),
34
+ b.anchor.set(c,f,w.$isElementNode(d)?"element":"text");if(n.key!==a||n.offset!==h)c=w.$getNodeByKey(a),b.focus.set(a,h,w.$isElementNode(c)?"element":"text")}}}function Y(a,b){a=a._collabNode;if(void 0===a)return[null,0];if(a instanceof W){const {node:c,offset:d}=X(a,b,!0);return null===c?[a,0]:[c,d]}return[null,0]}
35
+ function oa(a,b){var c=Array.from(b.awareness.getStates()),d=a.doc.clientID;b=a.cursors;var e=a.editor._editorState._nodeMap;const f=new Set;for(var g=0;g<c.length;g++){const [K,ta]=c[g];if(K!==d){f.add(K);const {anchorPos:ka,focusPos:la,name:ua,color:va,focusing:wa}=ta;var h=null,n=b.get(K);void 0===n&&(n={color:va,name:ua,selection:null},b.set(K,n));if(null!==ka&&null!==la&&wa){var k=t.createAbsolutePositionFromRelativePosition(ka,a.doc),l=t.createAbsolutePositionFromRelativePosition(la,a.doc);
36
+ if(null!==k&&null!==l){const [E,Q]=Y(k.type,k.index),[ma,na]=Y(l.type,l.index);if(null!==E&&null!==ma){l=E.getKey();var q=ma.getKey();h=n.selection;if(null===h){k=n;h=l;l=Q;var r=na,p=k.color,m=document.createElement("span");m.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=k.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`;
37
+ m.appendChild(u);h={caret:m,name:u,color:p,range:document.createRange(),selections:[],anchor:{key:h,offset:l},focus:{key:q,offset:r}}}else k=h.anchor,r=h.focus,k.key=l,k.offset=Q,r.key=q,r.offset=na}}}a:{k=a;l=n;m=h;var v=e;p=k.editor;q=p.getRootElement();n=k.cursorsContainer;if(null===n||null===q)break a;h=l.selection;if(null===m){null!==h&&(l.selection=null,fa(k,h));break a}else l.selection=m;r=m.range;h=m.caret;l=m.color;k=m.selections;var y=m.anchor,x=m.focus;m=y.key;u=x.key;var A=v.get(m);const E=
38
+ v.get(u);v=p.getElementByKey(m);p=p.getElementByKey(u);y=y.offset;x=x.offset;w.$isTextNode(A)&&(v=ha(v));w.$isTextNode(E)&&(p=ha(p));if(void 0!==A&&void 0!==E&&null!==v&&null!==p){"BR"===v.nodeName&&([v,y]=ia(v));"BR"===p.nodeName&&([p,x]=ia(p));A=v.firstChild;v===p&&null!=A&&"BR"===A.nodeName&&0===y&&0===x&&(x=1);try{r.setStart(v,y),r.setEnd(p,x)}catch(Q){break a}!r.collapsed||y===x&&m===u||(r.setStart(p,x),r.setEnd(v,y));p=q.getBoundingClientRect();q=getComputedStyle(q);q=parseFloat(q.paddingLeft)+
39
+ parseFloat(q.paddingRight);m=Array.from(r.getClientRects());r=m.length;u=k.length;for(A=0;A<r;A++)v=m[A],v.width+q===p.width?(m.splice(A--,1),r--):(y=k[A],void 0===y&&(y=document.createElement("span"),k[A]=y,n.appendChild(y)),y.style.cssText=`position:absolute;top:${v.top}px;left:${v.left}px;height:${v.height}px;width:${v.width}px;background-color:rgba(${l}, 0.3);pointer-events:none;z-index:10;`,A===r-1&&h.parentNode!==y&&y.appendChild(h));for(h=u-1;h>=r;h--)n.removeChild(k[h]),k.pop()}}}}c=Array.from(b.keys());
40
+ for(d=0;d<c.length;d++)e=c[d],f.has(e)||(g=b.get(e),void 0!==g&&(g=g.selection,null!==g&&fa(a,g),b.delete(e)))}function pa(a,b,c,d){b=b.awareness;var e=b.getLocalState();if(null!==e){var {anchorPos:f,focusPos:g,name:h,color:n,focusing:k}=e,l=e=null;if(null!==d&&(null===f||d.is(c))||null!==c)null!==d&&(e=da(d.anchor,a),l=da(d.focus,a)),(ea(f,e)||ea(g,l))&&b.setLocalState({name:h,color:n,anchorPos:e,focusPos:l,focusing:k})}}
41
+ class qa{constructor(a,b,c=1){this._offsetMap=a;this._firstNode=b;this._blockOffsetSize=c}createSelectionFromOffsets(a,b,c){var d=this._firstNode;if(null===d)return null;var e=Z(d,a,this._blockOffsetSize);let f=Z(d,b,this._blockOffsetSize);void 0!==c&&(a=ra(a,e,c,this,this._blockOffsetSize),e=Z(d,a,this._blockOffsetSize),b=ra(b,f,c,this,this._blockOffsetSize),f=Z(d,b,this._blockOffsetSize));if(null===e||null===f)return null;c=e.key;d=f.key;const g=w.$getNodeByKey(c),h=w.$getNodeByKey(d);if(null===
42
+ g||null===h)return null;let n=0,k=0,l="element",q="element";"text"===e.type?(n=a-e.start,l="text",e=g.getNextSibling(),a!==b&&n===g.getTextContentSize()&&w.$isTextNode(e)&&(n=0,c=e.__key)):"inline"===e.type&&(c=g.getParentOrThrow().getKey(),n=b>e.start?e.end:e.start);"text"===f.type?(k=b-f.start,q="text"):"inline"===f.type&&(d=h.getParentOrThrow().getKey(),k=b>f.start?f.end:f.start);a=w.$createSelection();if(null===a)return null;a.anchor.set(c,n,l);a.focus.set(d,k,q);return a}getOffsetsFromSelection(a){var b=
38
43
  a.anchor,c=a.focus,d=this._offsetMap;const e=b.offset;var f=c.offset;let g=a=-1;if("text"===b.type)b=d.get(b.key),void 0!==b&&(a=b.start+e);else{b=b.getNode().getDescendantByIndex(e);const h=d.get(b.getKey());void 0!==h&&(a=b.getIndexWithinParent()!==e?h.end:h.start)}"text"===c.type?(f=d.get(c.key),void 0!==f&&(g=f.start+c.offset)):(c=c.getNode().getDescendantByIndex(f),d=d.get(c.getKey()),void 0!==d&&(g=c.getIndexWithinParent()!==f?d.end:d.start));return[a,g]}}
39
- function la(a,b,c,d,e){const f=c._offsetMap;d=d._offsetMap;const g=new Set;let h=a;for(;null!==b;){var m=b.key,k=f.get(m),l=b.end-b.start;g.add(m);void 0===k?h+=l:(m=k.end-k.start,m!==l&&(h+=l-m));l=b.prev;if(null!==l)b=l;else{for(b=b.parent;null!==b;)k=b.prev,null!==k&&(l=k.key,m=f.get(l),k=k.end-k.start,g.add(l),void 0===m?h+=k:(l=m.end-m.start,l!==k&&(h+=k-l))),b=b.parent;break}}c=c._firstNode;if(null!==c){b=Z(c,a,e);for(a=!1;null!==b;){if(!g.has(b.key)){a=!0;break}b=b.parent}if(!a)for(;null!==
44
+ function ra(a,b,c,d,e){const f=c._offsetMap;d=d._offsetMap;const g=new Set;let h=a;for(;null!==b;){var n=b.key,k=f.get(n),l=b.end-b.start;g.add(n);void 0===k?h+=l:(n=k.end-k.start,n!==l&&(h+=l-n));l=b.prev;if(null!==l)b=l;else{for(b=b.parent;null!==b;)k=b.prev,null!==k&&(l=k.key,n=f.get(l),k=k.end-k.start,g.add(l),void 0===n?h+=k:(l=n.end-n.start,l!==k&&(h+=k-l))),b=b.parent;break}}c=c._firstNode;if(null!==c){b=Z(c,a,e);for(a=!1;null!==b;){if(!g.has(b.key)){a=!0;break}b=b.parent}if(!a)for(;null!==
40
45
  b;)a=b.key,g.has(a)||(e=d.get(a),a=b.end-b.start,void 0===e?h-=a:(e=e.end-e.start,a!==e&&(h+=e-a))),b=b.prev}return h}function Z(a,b,c){for(;null!==a;){if(b<a.end+("element"!==a.type||0===c?1:0)){const d=a.child;if(null!==d){a=d;continue}return a}a=a.next;if(null===a)break}return null}
41
- function ma(a,b,c,d,e,f){let g=null,h=null;const m=b.length;for(let v=0;v<m;v++){{var k=a;var l=b[v];var q=c,t=d,p=e,n=f,u=t.get(l);if(void 0===u)throw Error("Minified Lexical error #3; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const x=k.offset;if(y.$isElementNode(u)){const w=u.__children;t=(u=0===w.length)?null:ma(k,w,null,t,p,n);if(!k.prevIsBlock||u)k.prevIsBlock=!0,k.offset+=n;q={child:t,prev:null,next:null,type:"element",
42
- start:x,end:x,key:l,parent:q};null!==t&&(t.parent=q);q.end=k.offset;p.set(l,q);l=q}else k.prevIsBlock=!1,n=y.$isTextNode(u),k=k.offset+=n?u.__text.length:1,k={child:null,prev:null,next:null,type:n?"text":"inline",start:x,end:k,key:l,parent:q},p.set(l,k),l=k}null===h?g=l:(l.prev=h,h.next=l);h=l}return g}function ra(a,b=1,c){c=(c||a._pendingEditorState||a._editorState)._nodeMap;const d=c.get("root");a=new Map;c=ma({offset:0,prevIsBlock:!1},d.__children,null,c,a,b);return new ka(a,c,b)}
43
- exports.createBinding=function(a,b,c,d){b=d.get(c);if(void 0===b)throw Error("Should never happen");var e=b.get("root",r.XmlText);e=N(e,null,"root");e._key="root";return{collabNodeMap:new Map,nodeProperties:new Map,editor:a,id:c,cursors:new Map,cursorsContainer:null,doc:b,root:e,docMap:d}};exports.createUndoManager=function(a,b){return new r.UndoManager(b,{trackedOrigins:new Set([a,null])})};
44
- exports.initLocalState=function(a,b,c,d){a.awareness.setLocalState({color:c,name:b,anchorPos:null,focusPos:null,focusing:d})};exports.setLocalStateFocus=function(a,b){({awareness:a}=a);a.setLocalState({...a.getLocalState(),focusing:b})};exports.syncCursorPositions=ia;
45
- exports.syncLexicalUpdateToYjs=function(a,b,c,d,e,f,g,h){window.foo=a.doc;a.doc.transact(()=>{d.read(()=>{if(h.has("collaboration")){if(0<g.size){var m=Array.from(g),k=a.collabNodeMap,l=[];for(let n=0;n<m.length;n++){var q=m[n],t=y.$getNodeByKey(q),p=k.get(q);if(p instanceof z)if(y.$isTextNode(t))l.push([p,t.__text]);else{t=p.getOffset();if(-1===t)continue;const u=p._parent;p._normalized=!0;u._xmlText.delete(t,1);k.delete(q);q=u._children;p=q.indexOf(p);q.splice(p,1)}}for(m=0;m<l.length;m++){const [n,
46
- u]=l[m];n._text=u}}}else e.has("root")&&(l=c._nodeMap,m=y.$getRoot(),k=a.root,k.syncPropertiesFromLexical(a,m,l),k.syncChildrenFromLexical(a,m,l,e,f)),l=y.$getSelection(),ja(a,b,c._selection,l)})},a)};
47
- exports.syncYjsChangesToLexical=function(a,b,c){const d=a.editor,e=d._editorState;d.update(()=>{var f=d._pendingEditorState;for(var g=0;g<c.length;g++){var h=a,m=c[g],{target:k}=m;k=P(h,k);if(k instanceof Q&&m instanceof r.YTextEvent){const {keysChanged:l,childListChanged:q,delta:t}=m;0<l.size&&k.syncPropertiesFromYjs(h,l);q&&(k.applyChildrenYjsDelta(h,t),k.syncChildrenFromYjs(h))}else if(k instanceof z&&m instanceof r.YMapEvent)({keysChanged:m}=m),0<m.size&&k.syncPropertiesAndTextFromYjs(h,m);else if(k instanceof
48
- H&&m instanceof r.YXmlEvent)({attributesChanged:m}=m),0<m.size&&k.syncPropertiesFromYjs(h,m);else throw Error("Should never happen");}g=y.$getSelection();if(null!==g)if(S(g)){h=e._selection;if(null!==h){k=ra(d,0,e);f=ra(d,0,f);const [l,q]=k.getOffsetsFromSelection(h);f=f.createSelectionFromOffsets(l,q,k);null!==f?y.$setSelection(f):(ca(a,b),S(g)&&(f=y.$getRoot(),0===f.getChildrenSize()&&f.append(aa.$createParagraphNode()),y.$getRoot().selectEnd()))}ja(a,b,h,y.$getSelection())}else ca(a,b)},{onUpdate:()=>
49
- {ia(a,b)},skipTransforms:!0,tag:"collaboration"})};
46
+ function sa(a,b,c,d,e,f){let g=null,h=null;const n=b.length;for(let v=0;v<n;v++){{var k=a;var l=b[v];var q=c,r=d,p=e,m=f,u=r.get(l);void 0===u&&H(3);const y=k.offset;if(w.$isElementNode(u)){const x=u.__children;r=(u=0===x.length)?null:sa(k,x,null,r,p,m);if(!k.prevIsBlock||u)k.prevIsBlock=!0,k.offset+=m;q={child:r,prev:null,next:null,type:"element",start:y,end:y,key:l,parent:q};null!==r&&(r.parent=q);q.end=k.offset;p.set(l,q);l=q}else k.prevIsBlock=!1,m=w.$isTextNode(u),k=k.offset+=m?u.__text.length:
47
+ 1,k={child:null,prev:null,next:null,type:m?"text":"inline",start:y,end:k,key:l,parent:q},p.set(l,k),l=k}null===h?g=l:(l.prev=h,h.next=l);h=l}return g}function xa(a,b=1,c){c=(c||a._pendingEditorState||a._editorState)._nodeMap;const d=c.get("root");a=new Map;c=sa({offset:0,prevIsBlock:!1},d.__children,null,c,a,b);return new qa(a,c,b)}
48
+ exports.createBinding=function(a,b,c,d){b=d.get(c);if(void 0===b)throw Error("Should never happen");var e=b.get("root",t.XmlText);e=U(e,null,"root");e._key="root";return{collabNodeMap:new Map,nodeProperties:new Map,editor:a,id:c,cursors:new Map,cursorsContainer:null,doc:b,root:e,docMap:d}};exports.createUndoManager=function(a,b){return new t.UndoManager(b,{trackedOrigins:new Set([a,null])})};
49
+ exports.initLocalState=function(a,b,c,d){a.awareness.setLocalState({color:c,name:b,anchorPos:null,focusPos:null,focusing:d})};exports.setLocalStateFocus=function(a,b){({awareness:a}=a);a.setLocalState({...a.getLocalState(),focusing:b})};exports.syncCursorPositions=oa;
50
+ exports.syncLexicalUpdateToYjs=function(a,b,c,d,e,f,g,h){J(a,()=>{d.read(()=>{if(h.has("collaboration")){if(0<g.size){var n=Array.from(g),k=a.collabNodeMap,l=[];for(let m=0;m<n.length;m++){var q=n[m],r=w.$getNodeByKey(q),p=k.get(q);if(p instanceof z)if(w.$isTextNode(r))l.push([p,r.__text]);else{r=p.getOffset();if(-1===r)continue;const u=p._parent;p._normalized=!0;u._xmlText.delete(r,1);k.delete(q);q=u._children;p=q.indexOf(p);q.splice(p,1)}}for(n=0;n<l.length;n++){const [m,u]=l[n];m._text=u}}}else e.has("root")&&
51
+ (l=c._nodeMap,n=w.$getRoot(),k=a.root,k.syncPropertiesFromLexical(a,n,l),k.syncChildrenFromLexical(a,n,l,e,f)),l=w.$getSelection(),pa(a,b,c._selection,l)})})};
52
+ exports.syncYjsChangesToLexical=function(a,b,c){const d=a.editor,e=d._editorState;d.update(()=>{var f=d._pendingEditorState;for(var g=0;g<c.length;g++){{var h=a,n=c[g];const {target:l}=n;var k=V(h,l);const q=l._lexicalValue;if(void 0!==q&&l instanceof t.Map&&k instanceof O)N(h,k,l,q,n.keysChanged);else if(k instanceof W&&n instanceof t.YTextEvent){const {keysChanged:r,childListChanged:p,delta:m}=n;0<r.size&&k.syncPropertiesFromYjs(h,r);p&&(k.applyChildrenYjsDelta(h,m),k.syncChildrenFromYjs(h))}else if(k instanceof
53
+ z&&n instanceof t.YMapEvent)({keysChanged:n}=n),0<n.size&&k.syncPropertiesAndTextFromYjs(h,n);else if(k instanceof O&&n instanceof t.YXmlEvent)({attributesChanged:n}=n),0<n.size&&k.syncPropertiesFromYjs(h,n);else throw Error("Should never happen");}}g=w.$getSelection();if(null!==g)if(ba(g)){h=e._selection;if(null!==h){k=xa(d,0,e);f=xa(d,0,f);const [l,q]=k.getOffsetsFromSelection(h);f=f.createSelectionFromOffsets(l,q,k);null!==f?w.$setSelection(f):(ja(a,b),ba(g)&&(f=w.$getRoot(),0===f.getChildrenSize()&&
54
+ f.append(aa.$createParagraphNode()),w.$getRoot().selectEnd()))}pa(a,b,h,w.$getSelection())}else ja(a,b)},{onUpdate:()=>{oa(a,b)},skipTransforms:!0,tag:"collaboration"})};
package/package.json CHANGED
@@ -15,10 +15,10 @@
15
15
  "crdt"
16
16
  ],
17
17
  "license": "MIT",
18
- "version": "0.1.0",
18
+ "version": "0.1.4",
19
19
  "main": "LexicalYjs.js",
20
- "dependencies": {
21
- "lexical": "0.1.0",
20
+ "peerDependencies": {
21
+ "lexical": "0.1.4",
22
22
  "yjs": ">=13.5.22"
23
23
  },
24
24
  "repository": {