New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/yjs

Package Overview
Dependencies
Maintainers
5
Versions
275
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/yjs - npm Package Compare versions

Comparing version 0.23.2-nightly.20250124.0 to 0.23.2-nightly.20250127.0

23

LexicalYjs.dev.js

@@ -676,2 +676,3 @@ /**

let currIndex = 0;
let pendingSplitText = null;
for (let i = 0; i < deltas.length; i++) {

@@ -745,6 +746,24 @@ const delta = deltas[i];

const {
nodeIndex
node,
nodeIndex,
length
} = getPositionFromElementAndOffset(this, currIndex, false);
const collabNode = $getOrInitCollabNodeFromSharedType(binding, sharedType, this);
children.splice(nodeIndex, 0, collabNode);
if (node instanceof CollabTextNode && length > 0 && length < node._text.length) {
// Trying to insert in the middle of a text node; split the text.
const text = node._text;
const splitIdx = text.length - length;
node._text = spliceString(text, splitIdx, length, '');
children.splice(nodeIndex + 1, 0, collabNode);
// The insert that triggers the text split might not be a text node. Need to keep a
// reference to the remaining text so that it can be added when we do create one.
pendingSplitText = spliceString(text, 0, splitIdx, '');
} else {
children.splice(nodeIndex, 0, collabNode);
}
if (pendingSplitText !== null && collabNode instanceof CollabTextNode) {
// Found a text node to insert the pending text into.
collabNode._text = pendingSplitText + collabNode._text;
pendingSplitText = null;
}
currIndex += 1;

@@ -751,0 +770,0 @@ }

2

LexicalYjs.prod.js

@@ -9,2 +9,2 @@ /**

"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,l=B){const i=t.editor,r=i._editorState;o.forEach((e=>e.delta)),i.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=r._selection;if(e.$isRangeSelection(o)&&(Y(t,n),C(s))){$(s.anchor.key,r)}W(t,n,o,e.$getSelection())}else Y(t,n)}),{onUpdate:()=>{l(t,n),i.update((()=>{0===e.$getRoot().getChildrenSize()&&e.$getRoot().append(e.$createParagraphNode())}))},skipTransforms:!0,tag:s?"historic":"collaboration"})};
"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,s=null;for(let l=0;l<t.length;l++){const r=t[l],a=r.insert,f=r.delete;if(null!=r.retain)o+=r.retain;else if("number"==typeof f){let e=f;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==a)throw new Error("Unexpected delta format");if("string"==typeof a){const{node:e,offset:t}=k(this,o,!0);e instanceof c?e._text=b(e._text,t,0,a):this._xmlText.delete(t,a.length),o+=a.length}else{const t=a,{node:l,nodeIndex:i,length:r}=k(this,o,!1),f=y(e,t,this);if(l instanceof c&&r>0&&r<l._text.length){const e=l._text,t=e.length-r;l._text=b(e,t,r,""),n.splice(i+1,0,f),s=b(e,0,t,"")}else n.splice(i,0,f);null!==s&&f instanceof c&&(f._text=s+f._text,s=null),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,l=B){const i=t.editor,r=i._editorState;o.forEach((e=>e.delta)),i.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=r._selection;if(e.$isRangeSelection(o)&&(Y(t,n),C(s))){$(s.anchor.key,r)}W(t,n,o,e.$getSelection())}else Y(t,n)}),{onUpdate:()=>{l(t,n),i.update((()=>{0===e.$getRoot().getChildrenSize()&&e.$getRoot().append(e.$createParagraphNode())}))},skipTransforms:!0,tag:s?"historic":"collaboration"})};

@@ -14,9 +14,9 @@ {

"license": "MIT",
"version": "0.23.2-nightly.20250124.0",
"version": "0.23.2-nightly.20250127.0",
"main": "LexicalYjs.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/offset": "0.23.2-nightly.20250124.0",
"@lexical/selection": "0.23.2-nightly.20250124.0",
"lexical": "0.23.2-nightly.20250124.0"
"@lexical/offset": "0.23.2-nightly.20250127.0",
"@lexical/selection": "0.23.2-nightly.20250127.0",
"lexical": "0.23.2-nightly.20250127.0"
},

@@ -23,0 +23,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc