Socket
Book a DemoSign in
Socket

@lexical/utils

Package Overview
Dependencies
Maintainers
6
Versions
563
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/utils - npm Package Compare versions

Comparing version
0.41.1-nightly.20260317.0
to
0.41.1-nightly.20260318.0
+35
-31
LexicalUtils.dev.js

@@ -238,2 +238,23 @@ /**

}
function defaultOnReposition(domNodes) {
for (const domNode of domNodes) {
const domNodeStyle = domNode.style;
if (domNodeStyle.background !== 'Highlight') {
domNodeStyle.background = 'Highlight';
}
if (domNodeStyle.color !== 'HighlightText') {
domNodeStyle.color = 'HighlightText';
}
if (domNodeStyle.marginTop !== px(-1.5)) {
domNodeStyle.marginTop = px(-1.5);
}
if (domNodeStyle.paddingTop !== px(4)) {
domNodeStyle.paddingTop = px(4);
}
if (domNodeStyle.paddingBottom !== px(0)) {
domNodeStyle.paddingBottom = px(0);
}
}
}
/**

@@ -247,3 +268,3 @@ * Place one or multiple newly created Nodes at the current selection. Multiple

*/
function markSelection(editor, onReposition) {
function markSelection(editor, onReposition = defaultOnReposition) {
let previousAnchorNode = null;

@@ -283,26 +304,3 @@ let previousAnchorNodeDOM = null;

removeRangeListener();
removeRangeListener = mlcPositionNodeOnRange(editor, range, domNodes => {
if (onReposition === undefined) {
for (const domNode of domNodes) {
const domNodeStyle = domNode.style;
if (domNodeStyle.background !== 'Highlight') {
domNodeStyle.background = 'Highlight';
}
if (domNodeStyle.color !== 'HighlightText') {
domNodeStyle.color = 'HighlightText';
}
if (domNodeStyle.marginTop !== px(-1.5)) {
domNodeStyle.marginTop = px(-1.5);
}
if (domNodeStyle.paddingTop !== px(4)) {
domNodeStyle.paddingTop = px(4);
}
if (domNodeStyle.paddingBottom !== px(0)) {
domNodeStyle.paddingBottom = px(0);
}
}
} else {
onReposition(domNodes);
}
});
removeRangeListener = mlcPositionNodeOnRange(editor, range, onReposition);
}

@@ -351,9 +349,15 @@ previousAnchorNode = currentStartNode;

};
document.addEventListener('selectionchange', onSelectionChange);
return () => {
if (removeSelectionMark !== null) {
removeSelectionMark();
return editor.registerRootListener(rootElement => {
if (rootElement) {
const document = rootElement.ownerDocument;
document.addEventListener('selectionchange', onSelectionChange);
onSelectionChange();
return () => {
if (removeSelectionMark !== null) {
removeSelectionMark();
}
document.removeEventListener('selectionchange', onSelectionChange);
};
}
document.removeEventListener('selectionchange', onSelectionChange);
};
});
}

@@ -360,0 +364,0 @@

@@ -237,2 +237,23 @@ /**

}
function defaultOnReposition(domNodes) {
for (const domNode of domNodes) {
const domNodeStyle = domNode.style;
if (domNodeStyle.background !== 'Highlight') {
domNodeStyle.background = 'Highlight';
}
if (domNodeStyle.color !== 'HighlightText') {
domNodeStyle.color = 'HighlightText';
}
if (domNodeStyle.marginTop !== px(-1.5)) {
domNodeStyle.marginTop = px(-1.5);
}
if (domNodeStyle.paddingTop !== px(4)) {
domNodeStyle.paddingTop = px(4);
}
if (domNodeStyle.paddingBottom !== px(0)) {
domNodeStyle.paddingBottom = px(0);
}
}
}
/**

@@ -246,3 +267,3 @@ * Place one or multiple newly created Nodes at the current selection. Multiple

*/
function markSelection(editor, onReposition) {
function markSelection(editor, onReposition = defaultOnReposition) {
let previousAnchorNode = null;

@@ -282,26 +303,3 @@ let previousAnchorNodeDOM = null;

removeRangeListener();
removeRangeListener = mlcPositionNodeOnRange(editor, range, domNodes => {
if (onReposition === undefined) {
for (const domNode of domNodes) {
const domNodeStyle = domNode.style;
if (domNodeStyle.background !== 'Highlight') {
domNodeStyle.background = 'Highlight';
}
if (domNodeStyle.color !== 'HighlightText') {
domNodeStyle.color = 'HighlightText';
}
if (domNodeStyle.marginTop !== px(-1.5)) {
domNodeStyle.marginTop = px(-1.5);
}
if (domNodeStyle.paddingTop !== px(4)) {
domNodeStyle.paddingTop = px(4);
}
if (domNodeStyle.paddingBottom !== px(0)) {
domNodeStyle.paddingBottom = px(0);
}
}
} else {
onReposition(domNodes);
}
});
removeRangeListener = mlcPositionNodeOnRange(editor, range, onReposition);
}

@@ -350,9 +348,15 @@ previousAnchorNode = currentStartNode;

};
document.addEventListener('selectionchange', onSelectionChange);
return () => {
if (removeSelectionMark !== null) {
removeSelectionMark();
return editor.registerRootListener(rootElement => {
if (rootElement) {
const document = rootElement.ownerDocument;
document.addEventListener('selectionchange', onSelectionChange);
onSelectionChange();
return () => {
if (removeSelectionMark !== null) {
removeSelectionMark();
}
document.removeEventListener('selectionchange', onSelectionChange);
};
}
document.removeEventListener('selectionchange', onSelectionChange);
};
});
}

@@ -359,0 +363,0 @@

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

"use strict";var e=require("lexical"),t=require("@lexical/selection");function n(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,o=r&&"documentMode"in document?document.documentMode:null,i=r&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=r&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),l=!(!r||!("InputEvent"in window)||o)&&"getTargetRanges"in new window.InputEvent("input"),a=r&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,u=r&&/Android/.test(navigator.userAgent),d=r&&/^(?=.*Chrome).*/i.test(navigator.userAgent),g=r&&u&&d,f=r&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!d;function p(e){return`${e}px`}const m={attributes:!0,characterData:!0,childList:!0,subtree:!0};function $(r,o,i){let s=null,l=null,a=null,c=[];const u=document.createElement("div");function d(){null===s&&n(182),null===l&&n(183);const{left:e,top:a}=l.getBoundingClientRect(),d=t.createRectsFromDOMRange(r,o);var g,f;u.isConnected||(f=u,(g=l).insertBefore(f,g.firstChild));let m=!1;for(let t=0;t<d.length;t++){const n=d[t],r=c[t]||document.createElement("div"),o=r.style;"absolute"!==o.position&&(o.position="absolute",m=!0);const i=p(n.left-e);o.left!==i&&(o.left=i,m=!0);const s=p(n.top-a);o.top!==s&&(r.style.top=s,m=!0);const l=p(n.width);o.width!==l&&(r.style.width=l,m=!0);const g=p(n.height);o.height!==g&&(r.style.height=g,m=!0),r.parentNode!==u&&(u.append(r),m=!0),c[t]=r}for(;c.length>d.length;)c.pop();m&&i(c)}function g(){l=null,s=null,null!==a&&a.disconnect(),a=null,u.remove();for(const e of c)e.remove();c=[]}u.style.position="relative";const f=r.registerRootListener(function t(){const n=r.getRootElement();if(null===n)return g();const o=n.parentElement;if(!e.isHTMLElement(o))return g();g(),s=n,l=o,a=new MutationObserver(e=>{const n=r.getRootElement(),o=n&&n.parentElement;if(n!==s||o!==l)return t();for(const t of e)if(!u.contains(t.target))return d()}),a.observe(o,m),d()});return()=>{f(),g()}}function h(t,n,r){if("text"!==t.type&&e.$isElementNode(n)){const e=n.getDOMSlot(r);return[e.element,e.getFirstChildOffset()+t.offset]}return[e.getDOMTextNode(r)||r,t.offset]}function x(t,n){let r=null,o=null,i=null,s=null,l=null,a=null,c=()=>{};function u(u){u.read(()=>{const u=e.$getSelection();if(!e.$isRangeSelection(u))return r=null,i=null,s=null,a=null,c(),void(c=()=>{});const[d,g]=function(e){const t=e.getStartEndPoints();return e.isBackward()?[t[1],t[0]]:t}(u),f=d.getNode(),m=f.getKey(),x=d.offset,C=g.getNode(),S=C.getKey(),E=g.offset,N=t.getElementByKey(m),v=t.getElementByKey(S),A=null===r||N!==o||x!==i||m!==r.getKey(),R=null===s||v!==l||E!==a||S!==s.getKey();if((A||R)&&null!==N&&null!==v){const e=function(e,t,n,r,o,i,s){const l=(e._window?e._window.document:document).createRange();return l.setStart(...h(t,n,r)),l.setEnd(...h(o,i,s)),l}(t,d,f,N,g,C,v);c(),c=$(t,e,e=>{if(void 0===n)for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),e.marginTop!==p(-1.5)&&(e.marginTop=p(-1.5)),e.paddingTop!==p(4)&&(e.paddingTop=p(4)),e.paddingBottom!==p(0)&&(e.paddingBottom=p(0))}else n(e)})}r=f,o=N,i=x,s=C,l=v,a=E})}return u(t.getEditorState()),e.mergeRegister(t.registerUpdateListener(({editorState:e})=>u(e)),()=>{c()})}const C=l,S=r,E=u,N=g,v=i,A=f,R=d,w=s,y=c,b=a;function P(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function I(e,t){return O("next",e,t)}function T(t,n){const r=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,n));return r&&r[0]}function O(t,n,r){const o=e.$getRoot(),i=n||o,s=e.$isElementNode(i)?e.$getChildCaret(i,t):e.$getSiblingCaret(i,t),l=M(i),a=r?e.$getAdjacentChildCaret(e.$getChildCaretOrSelf(e.$getSiblingCaret(r,t)))||T(r,t):T(i,t);let c=l;return e.makeStepwiseIterator({hasNext:e=>null!==e,initial:s,map:e=>({depth:c,node:e.origin}),step:t=>{if(t.isSameNodeCaret(a))return null;e.$isChildCaret(t)&&c++;const n=e.$getAdjacentSiblingOrParentSiblingCaret(t);return!n||n[0].isSameNodeCaret(a)?null:(c+=n[1],n[0])}})}function M(e){let t=-1;for(let n=e;null!==n;n=n.getParent())t++;return t}function _(e,t){return O("previous",e,t)}function L(t,r,o){let i=e.$getCaretInDirection(r,"next");for(let t=i;t;t=e.$splitAtPointCaretNext(t,o))i=t;return e.$isTextPointCaret(i)&&n(283),i.insert(t.isInline()?e.$createParagraphNode().append(t):t),e.$getCaretInDirection(e.$getSiblingCaret(t.getLatest(),"next"),r.direction)}let D=!(w||!S)&&void 0;function F(t,n,r){let o=!1;for(const i of B(t))n(i)?null!==r&&r(i):(o=!0,e.$isElementNode(i)&&F(i,n,r||(e=>i.insertAfter(e))),i.remove());return o}function B(t){return j(e.$getChildCaret(t,"previous"))}function j(t){return e.makeStepwiseIterator({hasNext:e.$isSiblingCaret,initial:t.getAdjacentCaret(),map:e=>e.origin.getLatest(),step:e=>e.getAdjacentCaret()})}exports.$findMatchingParent=e.$findMatchingParent,exports.$getAdjacentSiblingOrParentSiblingCaret=e.$getAdjacentSiblingOrParentSiblingCaret,exports.$splitNode=e.$splitNode,exports.addClassNamesToElement=e.addClassNamesToElement,exports.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,exports.mergeRegister=e.mergeRegister,exports.removeClassNamesFromElement=e.removeClassNamesFromElement,exports.$descendantsMatching=function(t,n){const r=[],o=Array.from(t).reverse();for(let t=o.pop();void 0!==t;t=o.pop())if(n(t))r.push(t);else if(e.$isElementNode(t))for(const e of B(t))o.push(e);return r},exports.$dfs=function(e,t){return Array.from(I(e,t))},exports.$dfsIterator=I,exports.$filter=function(e,t){const n=[];for(let r=0;r<e.length;r++){const o=t(e[r]);null!==o&&n.push(o)}return n},exports.$firstToLastIterator=function(t){return j(e.$getChildCaret(t,"next"))},exports.$getAdjacentCaret=function(e){return e?e.getAdjacentCaret():null},exports.$getDepth=M,exports.$getNearestBlockElementAncestorOrThrow=function(t){const r=e.$findMatchingParent(t,t=>e.$isElementNode(t)&&!t.isInline());return e.$isElementNode(r)||n(4,t.__key),r},exports.$getNearestNodeOfType=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null},exports.$getNextRightPreorderNode=function(t){const n=e.$getChildCaretOrSelf(e.$getSiblingCaret(t,"previous")),r=e.$getAdjacentSiblingOrParentSiblingCaret(n,"root");return r&&r[0].origin},exports.$getNextSiblingOrParentSibling=function(t){const n=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,"next"));return n&&[n[0].origin,n[1]]},exports.$handleIndentAndOutdent=function(t){const n=e.$getSelection();if(!e.$isRangeSelection(n))return!1;const r=new Set,o=n.getNodes();for(let n=0;n<o.length;n++){const i=o[n],s=i.getKey();if(r.has(s))continue;const l=e.$findMatchingParent(i,t=>e.$isElementNode(t)&&!t.isInline());if(null===l)continue;const a=l.getKey();l.canIndent()&&!r.has(a)&&(r.add(a),t(l))}return r.size>0},exports.$insertFirst=function(t,n){e.$getChildCaret(t,"next").insert(n)},exports.$insertNodeIntoLeaf=function(t){const n=e.$getSelection();if(!e.$isRangeSelection(n))return;const r=e.$caretRangeFromSelection(n);let o=e.$getCaretRangeInDirection(e.$removeTextFromCaretRange(r),"next").anchor;if(e.$isTextPointCaret(o)){const t=e.$splitAtPointCaretNext(o);if(!t)return;o=t}const i=o.getFlipped();i.insert(t),e.$setSelectionFromCaretRange(e.$getCaretRange(i,i))},exports.$insertNodeToNearestRoot=function(t){const n=e.$getSelection()||e.$getPreviousSelection();let r;if(e.$isRangeSelection(n))r=e.$caretFromPoint(n.focus,"next");else{if(null!=n){const t=n.getNodes(),o=t[t.length-1];o&&(r=e.$getSiblingCaret(o,"next"))}r=r||e.$getChildCaret(e.$getRoot(),"previous").getFlipped().insert(e.$createParagraphNode())}const o=L(t,r),i=e.$getAdjacentChildCaret(o),s=e.$isChildCaret(i)?e.$normalizeCaret(i):o;return e.$setSelectionFromCaretRange(e.$getCollapsedCaretRange(s)),t.getLatest()},exports.$insertNodeToNearestRootAtCaret=L,exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=B,exports.$restoreEditorState=function(t,n){const r=new Map,o=t._pendingEditorState;for(const[t,o]of n._nodeMap)r.set(t,e.$cloneWithProperties(o));o&&(o._nodeMap=r),t._dirtyType=2;const i=n._selection;e.$setSelection(null===i?null:i.clone())},exports.$reverseDfs=function(e,t){return Array.from(_(e,t))},exports.$reverseDfsIterator=_,exports.$unwrapAndFilterDescendants=function(e,t){return F(e,t,null)},exports.$unwrapNode=function(t){e.$rewindSiblingCaret(e.$getSiblingCaret(t,"next")).splice(1,t.getChildren())},exports.$wrapNodeInElement=function(e,t){const n=t();return e.replace(n),n.append(e),n},exports.CAN_USE_BEFORE_INPUT=C,exports.CAN_USE_DOM=S,exports.IS_ANDROID=E,exports.IS_ANDROID_CHROME=N,exports.IS_APPLE=v,exports.IS_APPLE_WEBKIT=A,exports.IS_CHROME=R,exports.IS_FIREFOX=w,exports.IS_IOS=y,exports.IS_SAFARI=b,exports.calculateZoomLevel=function(e,t=!1){let n=1;if(function(){if(void 0===D){const e=document.createElement("div");e.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(e);const t=e.getBoundingClientRect();e.style.setProperty("zoom","2"),D=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return D}()||t)for(;e;)n*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return n},exports.isMimeType=P,exports.makeStateWrapper=function(t){const n=n=>e.$getState(n,t),r=(n,r)=>e.$setState(n,t,r);return{$get:n,$set:r,accessors:[n,r],makeGetterMethod:()=>function(){return n(this)},makeSetterMethod:()=>function(e){return r(this,e)},stateConfig:t}},exports.markSelection=x,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise((e,r)=>{const o=[],i=()=>{const{done:s,value:l}=n.next();if(s)return e(o);const a=new FileReader;a.addEventListener("error",r),a.addEventListener("load",()=>{const e=a.result;"string"==typeof e&&o.push({file:l,result:e}),i()}),P(l,t)?a.readAsDataURL(l):i()};i()})},exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=$,exports.registerNestedElementResolver=function(e,t,n,r){const o=e=>e instanceof t;return e.registerNodeTransform(t,e=>{const t=(e=>{const t=e.getChildren();for(let e=0;e<t.length;e++){const n=t[e];if(o(n))return null}let n=e,r=e;for(;null!==n;)if(r=n,n=n.getParent(),o(n))return{child:r,parent:n};return null})(e);if(null!==t){const{child:o,parent:i}=t;if(o.is(e)){r(i,e);const t=o.getNextSiblings(),s=t.length;if(i.insertAfter(o),0!==s){const e=n(i);o.insertAfter(e);for(let n=0;n<s;n++)e.append(t[n])}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove()}}})},exports.selectionAlwaysOnDisplay=function(e,t){let n=null;const r=()=>{const r=getSelection(),o=r&&r.anchorNode,i=e.getRootElement();null!==o&&null!==i&&i.contains(o)?null!==n&&(n(),n=null):null===n&&(n=x(e,t))};return document.addEventListener("selectionchange",r),()=>{null!==n&&n(),document.removeEventListener("selectionchange",r)}};
"use strict";var e=require("lexical"),t=require("@lexical/selection");function n(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,o=r&&"documentMode"in document?document.documentMode:null,i=r&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=r&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),l=!(!r||!("InputEvent"in window)||o)&&"getTargetRanges"in new window.InputEvent("input"),a=r&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,u=r&&/Android/.test(navigator.userAgent),d=r&&/^(?=.*Chrome).*/i.test(navigator.userAgent),g=r&&u&&d,f=r&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!d;function p(e){return`${e}px`}const m={attributes:!0,characterData:!0,childList:!0,subtree:!0};function $(r,o,i){let s=null,l=null,a=null,c=[];const u=document.createElement("div");function d(){null===s&&n(182),null===l&&n(183);const{left:e,top:a}=l.getBoundingClientRect(),d=t.createRectsFromDOMRange(r,o);var g,f;u.isConnected||(f=u,(g=l).insertBefore(f,g.firstChild));let m=!1;for(let t=0;t<d.length;t++){const n=d[t],r=c[t]||document.createElement("div"),o=r.style;"absolute"!==o.position&&(o.position="absolute",m=!0);const i=p(n.left-e);o.left!==i&&(o.left=i,m=!0);const s=p(n.top-a);o.top!==s&&(r.style.top=s,m=!0);const l=p(n.width);o.width!==l&&(r.style.width=l,m=!0);const g=p(n.height);o.height!==g&&(r.style.height=g,m=!0),r.parentNode!==u&&(u.append(r),m=!0),c[t]=r}for(;c.length>d.length;)c.pop();m&&i(c)}function g(){l=null,s=null,null!==a&&a.disconnect(),a=null,u.remove();for(const e of c)e.remove();c=[]}u.style.position="relative";const f=r.registerRootListener(function t(){const n=r.getRootElement();if(null===n)return g();const o=n.parentElement;if(!e.isHTMLElement(o))return g();g(),s=n,l=o,a=new MutationObserver(e=>{const n=r.getRootElement(),o=n&&n.parentElement;if(n!==s||o!==l)return t();for(const t of e)if(!u.contains(t.target))return d()}),a.observe(o,m),d()});return()=>{f(),g()}}function h(t,n,r){if("text"!==t.type&&e.$isElementNode(n)){const e=n.getDOMSlot(r);return[e.element,e.getFirstChildOffset()+t.offset]}return[e.getDOMTextNode(r)||r,t.offset]}function x(e){for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),e.marginTop!==p(-1.5)&&(e.marginTop=p(-1.5)),e.paddingTop!==p(4)&&(e.paddingTop=p(4)),e.paddingBottom!==p(0)&&(e.paddingBottom=p(0))}}function C(t,n=x){let r=null,o=null,i=null,s=null,l=null,a=null,c=()=>{};function u(u){u.read(()=>{const u=e.$getSelection();if(!e.$isRangeSelection(u))return r=null,i=null,s=null,a=null,c(),void(c=()=>{});const[d,g]=function(e){const t=e.getStartEndPoints();return e.isBackward()?[t[1],t[0]]:t}(u),f=d.getNode(),p=f.getKey(),m=d.offset,x=g.getNode(),C=x.getKey(),S=g.offset,E=t.getElementByKey(p),N=t.getElementByKey(C),v=null===r||E!==o||m!==i||p!==r.getKey(),R=null===s||N!==l||S!==a||C!==s.getKey();if((v||R)&&null!==E&&null!==N){const e=function(e,t,n,r,o,i,s){const l=(e._window?e._window.document:document).createRange();return l.setStart(...h(t,n,r)),l.setEnd(...h(o,i,s)),l}(t,d,f,E,g,x,N);c(),c=$(t,e,n)}r=f,o=E,i=m,s=x,l=N,a=S})}return u(t.getEditorState()),e.mergeRegister(t.registerUpdateListener(({editorState:e})=>u(e)),()=>{c()})}const S=l,E=r,N=u,v=g,R=i,w=f,A=d,y=s,b=c,P=a;function I(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function T(e,t){return M("next",e,t)}function O(t,n){const r=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,n));return r&&r[0]}function M(t,n,r){const o=e.$getRoot(),i=n||o,s=e.$isElementNode(i)?e.$getChildCaret(i,t):e.$getSiblingCaret(i,t),l=L(i),a=r?e.$getAdjacentChildCaret(e.$getChildCaretOrSelf(e.$getSiblingCaret(r,t)))||O(r,t):O(i,t);let c=l;return e.makeStepwiseIterator({hasNext:e=>null!==e,initial:s,map:e=>({depth:c,node:e.origin}),step:t=>{if(t.isSameNodeCaret(a))return null;e.$isChildCaret(t)&&c++;const n=e.$getAdjacentSiblingOrParentSiblingCaret(t);return!n||n[0].isSameNodeCaret(a)?null:(c+=n[1],n[0])}})}function L(e){let t=-1;for(let n=e;null!==n;n=n.getParent())t++;return t}function _(e,t){return M("previous",e,t)}function D(t,r,o){let i=e.$getCaretInDirection(r,"next");for(let t=i;t;t=e.$splitAtPointCaretNext(t,o))i=t;return e.$isTextPointCaret(i)&&n(283),i.insert(t.isInline()?e.$createParagraphNode().append(t):t),e.$getCaretInDirection(e.$getSiblingCaret(t.getLatest(),"next"),r.direction)}let F=!(y||!E)&&void 0;function B(t,n,r){let o=!1;for(const i of j(t))n(i)?null!==r&&r(i):(o=!0,e.$isElementNode(i)&&B(i,n,r||(e=>i.insertAfter(e))),i.remove());return o}function j(t){return k(e.$getChildCaret(t,"previous"))}function k(t){return e.makeStepwiseIterator({hasNext:e.$isSiblingCaret,initial:t.getAdjacentCaret(),map:e=>e.origin.getLatest(),step:e=>e.getAdjacentCaret()})}exports.$findMatchingParent=e.$findMatchingParent,exports.$getAdjacentSiblingOrParentSiblingCaret=e.$getAdjacentSiblingOrParentSiblingCaret,exports.$splitNode=e.$splitNode,exports.addClassNamesToElement=e.addClassNamesToElement,exports.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,exports.mergeRegister=e.mergeRegister,exports.removeClassNamesFromElement=e.removeClassNamesFromElement,exports.$descendantsMatching=function(t,n){const r=[],o=Array.from(t).reverse();for(let t=o.pop();void 0!==t;t=o.pop())if(n(t))r.push(t);else if(e.$isElementNode(t))for(const e of j(t))o.push(e);return r},exports.$dfs=function(e,t){return Array.from(T(e,t))},exports.$dfsIterator=T,exports.$filter=function(e,t){const n=[];for(let r=0;r<e.length;r++){const o=t(e[r]);null!==o&&n.push(o)}return n},exports.$firstToLastIterator=function(t){return k(e.$getChildCaret(t,"next"))},exports.$getAdjacentCaret=function(e){return e?e.getAdjacentCaret():null},exports.$getDepth=L,exports.$getNearestBlockElementAncestorOrThrow=function(t){const r=e.$findMatchingParent(t,t=>e.$isElementNode(t)&&!t.isInline());return e.$isElementNode(r)||n(4,t.__key),r},exports.$getNearestNodeOfType=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null},exports.$getNextRightPreorderNode=function(t){const n=e.$getChildCaretOrSelf(e.$getSiblingCaret(t,"previous")),r=e.$getAdjacentSiblingOrParentSiblingCaret(n,"root");return r&&r[0].origin},exports.$getNextSiblingOrParentSibling=function(t){const n=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,"next"));return n&&[n[0].origin,n[1]]},exports.$handleIndentAndOutdent=function(t){const n=e.$getSelection();if(!e.$isRangeSelection(n))return!1;const r=new Set,o=n.getNodes();for(let n=0;n<o.length;n++){const i=o[n],s=i.getKey();if(r.has(s))continue;const l=e.$findMatchingParent(i,t=>e.$isElementNode(t)&&!t.isInline());if(null===l)continue;const a=l.getKey();l.canIndent()&&!r.has(a)&&(r.add(a),t(l))}return r.size>0},exports.$insertFirst=function(t,n){e.$getChildCaret(t,"next").insert(n)},exports.$insertNodeIntoLeaf=function(t){const n=e.$getSelection();if(!e.$isRangeSelection(n))return;const r=e.$caretRangeFromSelection(n);let o=e.$getCaretRangeInDirection(e.$removeTextFromCaretRange(r),"next").anchor;if(e.$isTextPointCaret(o)){const t=e.$splitAtPointCaretNext(o);if(!t)return;o=t}const i=o.getFlipped();i.insert(t),e.$setSelectionFromCaretRange(e.$getCaretRange(i,i))},exports.$insertNodeToNearestRoot=function(t){const n=e.$getSelection()||e.$getPreviousSelection();let r;if(e.$isRangeSelection(n))r=e.$caretFromPoint(n.focus,"next");else{if(null!=n){const t=n.getNodes(),o=t[t.length-1];o&&(r=e.$getSiblingCaret(o,"next"))}r=r||e.$getChildCaret(e.$getRoot(),"previous").getFlipped().insert(e.$createParagraphNode())}const o=D(t,r),i=e.$getAdjacentChildCaret(o),s=e.$isChildCaret(i)?e.$normalizeCaret(i):o;return e.$setSelectionFromCaretRange(e.$getCollapsedCaretRange(s)),t.getLatest()},exports.$insertNodeToNearestRootAtCaret=D,exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=j,exports.$restoreEditorState=function(t,n){const r=new Map,o=t._pendingEditorState;for(const[t,o]of n._nodeMap)r.set(t,e.$cloneWithProperties(o));o&&(o._nodeMap=r),t._dirtyType=2;const i=n._selection;e.$setSelection(null===i?null:i.clone())},exports.$reverseDfs=function(e,t){return Array.from(_(e,t))},exports.$reverseDfsIterator=_,exports.$unwrapAndFilterDescendants=function(e,t){return B(e,t,null)},exports.$unwrapNode=function(t){e.$rewindSiblingCaret(e.$getSiblingCaret(t,"next")).splice(1,t.getChildren())},exports.$wrapNodeInElement=function(e,t){const n=t();return e.replace(n),n.append(e),n},exports.CAN_USE_BEFORE_INPUT=S,exports.CAN_USE_DOM=E,exports.IS_ANDROID=N,exports.IS_ANDROID_CHROME=v,exports.IS_APPLE=R,exports.IS_APPLE_WEBKIT=w,exports.IS_CHROME=A,exports.IS_FIREFOX=y,exports.IS_IOS=b,exports.IS_SAFARI=P,exports.calculateZoomLevel=function(e,t=!1){let n=1;if(function(){if(void 0===F){const e=document.createElement("div");e.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(e);const t=e.getBoundingClientRect();e.style.setProperty("zoom","2"),F=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return F}()||t)for(;e;)n*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return n},exports.isMimeType=I,exports.makeStateWrapper=function(t){const n=n=>e.$getState(n,t),r=(n,r)=>e.$setState(n,t,r);return{$get:n,$set:r,accessors:[n,r],makeGetterMethod:()=>function(){return n(this)},makeSetterMethod:()=>function(e){return r(this,e)},stateConfig:t}},exports.markSelection=C,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise((e,r)=>{const o=[],i=()=>{const{done:s,value:l}=n.next();if(s)return e(o);const a=new FileReader;a.addEventListener("error",r),a.addEventListener("load",()=>{const e=a.result;"string"==typeof e&&o.push({file:l,result:e}),i()}),I(l,t)?a.readAsDataURL(l):i()};i()})},exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=$,exports.registerNestedElementResolver=function(e,t,n,r){const o=e=>e instanceof t;return e.registerNodeTransform(t,e=>{const t=(e=>{const t=e.getChildren();for(let e=0;e<t.length;e++){const n=t[e];if(o(n))return null}let n=e,r=e;for(;null!==n;)if(r=n,n=n.getParent(),o(n))return{child:r,parent:n};return null})(e);if(null!==t){const{child:o,parent:i}=t;if(o.is(e)){r(i,e);const t=o.getNextSiblings(),s=t.length;if(i.insertAfter(o),0!==s){const e=n(i);o.insertAfter(e);for(let n=0;n<s;n++)e.append(t[n])}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove()}}})},exports.selectionAlwaysOnDisplay=function(e,t){let n=null;const r=()=>{const r=getSelection(),o=r&&r.anchorNode,i=e.getRootElement();null!==o&&null!==i&&i.contains(o)?null!==n&&(n(),n=null):null===n&&(n=C(e,t))};return e.registerRootListener(e=>{if(e){const t=e.ownerDocument;return t.addEventListener("selectionchange",r),r(),()=>{null!==n&&n(),t.removeEventListener("selectionchange",r)}}})};

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

import{isHTMLElement as t,mergeRegister as e,$getSelection as n,$isRangeSelection as o,$isElementNode as r,getDOMTextNode as i,$getChildCaret as l,$findMatchingParent as s,$getChildCaretOrSelf as u,$getSiblingCaret as c,$getAdjacentSiblingOrParentSiblingCaret as a,$caretRangeFromSelection as f,$getCaretRangeInDirection as d,$removeTextFromCaretRange as g,$isTextPointCaret as p,$splitAtPointCaretNext as m,$setSelectionFromCaretRange as h,$getCaretRange as v,$getPreviousSelection as y,$caretFromPoint as w,$getRoot as x,$createParagraphNode as E,$getAdjacentChildCaret as S,$isChildCaret as C,$normalizeCaret as A,$getCollapsedCaretRange as N,$getCaretInDirection as b,$cloneWithProperties as P,$setSelection as L,$rewindSiblingCaret as M,makeStepwiseIterator as R,$isSiblingCaret as T,$getState as B,$setState as _}from"lexical";export{$findMatchingParent,$getAdjacentSiblingOrParentSiblingCaret,$splitNode,addClassNamesToElement,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode,mergeRegister,removeClassNamesFromElement}from"lexical";import{createRectsFromDOMRange as K}from"@lexical/selection";function k(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const $="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,I=$&&"documentMode"in document?document.documentMode:null,O=$&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),F=$&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),H=!(!$||!("InputEvent"in window)||I)&&"getTargetRanges"in new window.InputEvent("input"),j=$&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),D=$&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,z=$&&/Android/.test(navigator.userAgent),U=$&&/^(?=.*Chrome).*/i.test(navigator.userAgent),V=$&&z&&U,W=$&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&O&&!U;function G(t){return`${t}px`}const q={attributes:!0,characterData:!0,childList:!0,subtree:!0};function J(e,n,o){let r=null,i=null,l=null,s=[];const u=document.createElement("div");function c(){null===r&&k(182),null===i&&k(183);const{left:t,top:l}=i.getBoundingClientRect(),c=K(e,n);var a,f;u.isConnected||(f=u,(a=i).insertBefore(f,a.firstChild));let d=!1;for(let e=0;e<c.length;e++){const n=c[e],o=s[e]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",d=!0);const i=G(n.left-t);r.left!==i&&(r.left=i,d=!0);const a=G(n.top-l);r.top!==a&&(o.style.top=a,d=!0);const f=G(n.width);r.width!==f&&(o.style.width=f,d=!0);const g=G(n.height);r.height!==g&&(o.style.height=g,d=!0),o.parentNode!==u&&(u.append(o),d=!0),s[e]=o}for(;s.length>c.length;)s.pop();d&&o(s)}function a(){i=null,r=null,null!==l&&l.disconnect(),l=null,u.remove();for(const t of s)t.remove();s=[]}u.style.position="relative";const f=e.registerRootListener(function n(){const o=e.getRootElement();if(null===o)return a();const s=o.parentElement;if(!t(s))return a();a(),r=o,i=s,l=new MutationObserver(t=>{const o=e.getRootElement(),l=o&&o.parentElement;if(o!==r||l!==i)return n();for(const e of t)if(!u.contains(e.target))return c()}),l.observe(s,q),c()});return()=>{f(),a()}}function Q(t,e,n){if("text"!==t.type&&r(e)){const o=e.getDOMSlot(n);return[o.element,o.getFirstChildOffset()+t.offset]}return[i(n)||n,t.offset]}function X(t,r){let i=null,l=null,s=null,u=null,c=null,a=null,f=()=>{};function d(e){e.read(()=>{const e=n();if(!o(e))return i=null,s=null,u=null,a=null,f(),void(f=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(e),p=d.getNode(),m=p.getKey(),h=d.offset,v=g.getNode(),y=v.getKey(),w=g.offset,x=t.getElementByKey(m),E=t.getElementByKey(y),S=null===i||x!==l||h!==s||m!==i.getKey(),C=null===u||E!==c||w!==a||y!==u.getKey();if((S||C)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const s=(t._window?t._window.document:document).createRange();return s.setStart(...Q(e,n,o)),s.setEnd(...Q(r,i,l)),s}(t,d,p,x,g,v,E);f(),f=J(t,e,t=>{if(void 0===r)for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==G(-1.5)&&(t.marginTop=G(-1.5)),t.paddingTop!==G(4)&&(t.paddingTop=G(4)),t.paddingBottom!==G(0)&&(t.paddingBottom=G(0))}else r(t)})}i=p,l=x,s=h,u=v,c=E,a=w})}return d(t.getEditorState()),e(t.registerUpdateListener(({editorState:t})=>d(t)),()=>{f()})}function Y(t,e){let n=null;const o=()=>{const o=getSelection(),r=o&&o.anchorNode,i=t.getRootElement();null!==r&&null!==i&&i.contains(r)?null!==n&&(n(),n=null):null===n&&(n=X(t,e))};return document.addEventListener("selectionchange",o),()=>{null!==n&&n(),document.removeEventListener("selectionchange",o)}}const Z=H,tt=$,et=z,nt=V,ot=O,rt=W,it=U,lt=F,st=D,ut=j;function ct(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function at(t,e){const n=t[Symbol.iterator]();return new Promise((t,o)=>{const r=[],i=()=>{const{done:l,value:s}=n.next();if(l)return t(r);const u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",()=>{const t=u.result;"string"==typeof t&&r.push({file:s,result:t}),i()}),ct(s,e)?u.readAsDataURL(s):i()};i()})}function ft(t,e){return Array.from(pt(t,e))}function dt(t){return t?t.getAdjacentCaret():null}function gt(t,e){return Array.from(xt(t,e))}function pt(t,e){return ht("next",t,e)}function mt(t,e){const n=a(c(t,e));return n&&n[0]}function ht(t,e,n){const o=x(),i=e||o,s=r(i)?l(i,t):c(i,t),f=yt(i),d=n?S(u(c(n,t)))||mt(n,t):mt(i,t);let g=f;return R({hasNext:t=>null!==t,initial:s,map:t=>({depth:g,node:t.origin}),step:t=>{if(t.isSameNodeCaret(d))return null;C(t)&&g++;const e=a(t);return!e||e[0].isSameNodeCaret(d)?null:(g+=e[1],e[0])}})}function vt(t){const e=a(c(t,"next"));return e&&[e[0].origin,e[1]]}function yt(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function wt(t){const e=u(c(t,"previous")),n=a(e,"root");return n&&n[0].origin}function xt(t,e){return ht("previous",t,e)}function Et(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function St(t){const e=s(t,t=>r(t)&&!t.isInline());return r(e)||k(4,t.__key),e}function Ct(t,e,n,o){const r=t=>t instanceof e;return t.registerNodeTransform(e,t=>{const e=(t=>{const e=t.getChildren();for(let t=0;t<e.length;t++){const n=e[t];if(r(n))return null}let n=t,o=t;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return{child:o,parent:n};return null})(t);if(null!==e){const{child:r,parent:i}=e;if(r.is(t)){o(i,t);const e=r.getNextSiblings(),l=e.length;if(i.insertAfter(r),0!==l){const t=n(i);r.insertAfter(t);for(let n=0;n<l;n++)t.append(e[n])}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove()}}})}function At(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,P(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;L(null===r?null:r.clone())}function Nt(t){const e=n()||y();let r;if(o(e))r=w(e.focus,"next");else{if(null!=e){const t=e.getNodes(),n=t[t.length-1];n&&(r=c(n,"next"))}r=r||l(x(),"previous").getFlipped().insert(E())}const i=bt(t,r),s=S(i),u=C(s)?A(s):i;return h(N(u)),t.getLatest()}function bt(t,e,n){let o=b(e,"next");for(let t=o;t;t=m(t,n))o=t;return p(o)&&k(283),o.insert(t.isInline()?E().append(t):t),b(c(t.getLatest(),"next"),e.direction)}function Pt(t){const e=n();if(!o(e))return;const r=f(e);let i=d(g(r),"next").anchor;if(p(i)){const t=m(i);if(!t)return;i=t}const l=i.getFlipped();l.insert(t),h(v(l,l))}function Lt(t,e){const n=e();return t.replace(n),n.append(t),n}function Mt(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Rt(t,e){const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);null!==r&&n.push(r)}return n}function Tt(t){const e=n();if(!o(e))return!1;const i=new Set,l=e.getNodes();for(let e=0;e<l.length;e++){const n=l[e],o=n.getKey();if(i.has(o))continue;const u=s(n,t=>r(t)&&!t.isInline());if(null===u)continue;const c=u.getKey();u.canIndent()&&!i.has(c)&&(i.add(c),t(u))}return i.size>0}function Bt(t,e){l(t,"next").insert(e)}let _t=!(lt||!tt)&&void 0;function Kt(t,e=!1){let n=1;if(function(){if(void 0===_t){const t=document.createElement("div");t.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(t);const e=t.getBoundingClientRect();t.style.setProperty("zoom","2"),_t=t.getBoundingClientRect().width===e.width,document.body.removeChild(t)}return _t}()||e)for(;t;)n*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return n}function kt(t){return null!==t._parentEditor}function $t(t,e){return It(t,e,null)}function It(t,e,n){let o=!1;for(const i of Ht(t))e(i)?null!==n&&n(i):(o=!0,r(i)&&It(i,e,n||(t=>i.insertAfter(t))),i.remove());return o}function Ot(t,e){const n=[],o=Array.from(t).reverse();for(let t=o.pop();void 0!==t;t=o.pop())if(e(t))n.push(t);else if(r(t))for(const e of Ht(t))o.push(e);return n}function Ft(t){return jt(l(t,"next"))}function Ht(t){return jt(l(t,"previous"))}function jt(t){return R({hasNext:T,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function Dt(t){M(c(t,"next")).splice(1,t.getChildren())}function zt(t){const e=e=>B(e,t),n=(e,n)=>_(e,t,n);return{$get:e,$set:n,accessors:[e,n],makeGetterMethod:()=>function(){return e(this)},makeSetterMethod:()=>function(t){return n(this,t)},stateConfig:t}}export{Ot as $descendantsMatching,ft as $dfs,pt as $dfsIterator,Rt as $filter,Ft as $firstToLastIterator,dt as $getAdjacentCaret,yt as $getDepth,St as $getNearestBlockElementAncestorOrThrow,Et as $getNearestNodeOfType,wt as $getNextRightPreorderNode,vt as $getNextSiblingOrParentSibling,Tt as $handleIndentAndOutdent,Bt as $insertFirst,Pt as $insertNodeIntoLeaf,Nt as $insertNodeToNearestRoot,bt as $insertNodeToNearestRootAtCaret,kt as $isEditorIsNestedEditor,Ht as $lastToFirstIterator,At as $restoreEditorState,gt as $reverseDfs,xt as $reverseDfsIterator,$t as $unwrapAndFilterDescendants,Dt as $unwrapNode,Lt as $wrapNodeInElement,Z as CAN_USE_BEFORE_INPUT,tt as CAN_USE_DOM,et as IS_ANDROID,nt as IS_ANDROID_CHROME,ot as IS_APPLE,rt as IS_APPLE_WEBKIT,it as IS_CHROME,lt as IS_FIREFOX,st as IS_IOS,ut as IS_SAFARI,Kt as calculateZoomLevel,ct as isMimeType,zt as makeStateWrapper,X as markSelection,at as mediaFileReader,Mt as objectKlassEquals,J as positionNodeOnRange,Ct as registerNestedElementResolver,Y as selectionAlwaysOnDisplay};
import{isHTMLElement as t,mergeRegister as e,$getSelection as n,$isRangeSelection as o,$isElementNode as r,getDOMTextNode as i,$getChildCaret as l,$findMatchingParent as s,$getChildCaretOrSelf as u,$getSiblingCaret as c,$getAdjacentSiblingOrParentSiblingCaret as a,$caretRangeFromSelection as f,$getCaretRangeInDirection as d,$removeTextFromCaretRange as g,$isTextPointCaret as p,$splitAtPointCaretNext as m,$setSelectionFromCaretRange as h,$getCaretRange as v,$getPreviousSelection as y,$caretFromPoint as w,$getRoot as x,$createParagraphNode as E,$getAdjacentChildCaret as S,$isChildCaret as C,$normalizeCaret as A,$getCollapsedCaretRange as N,$getCaretInDirection as b,$cloneWithProperties as L,$setSelection as P,$rewindSiblingCaret as R,makeStepwiseIterator as M,$isSiblingCaret as T,$getState as B,$setState as _}from"lexical";export{$findMatchingParent,$getAdjacentSiblingOrParentSiblingCaret,$splitNode,addClassNamesToElement,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode,mergeRegister,removeClassNamesFromElement}from"lexical";import{createRectsFromDOMRange as K}from"@lexical/selection";function k(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const $="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,I=$&&"documentMode"in document?document.documentMode:null,O=$&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),D=$&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),F=!(!$||!("InputEvent"in window)||I)&&"getTargetRanges"in new window.InputEvent("input"),H=$&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),j=$&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,z=$&&/Android/.test(navigator.userAgent),U=$&&/^(?=.*Chrome).*/i.test(navigator.userAgent),V=$&&z&&U,W=$&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&O&&!U;function G(t){return`${t}px`}const q={attributes:!0,characterData:!0,childList:!0,subtree:!0};function J(e,n,o){let r=null,i=null,l=null,s=[];const u=document.createElement("div");function c(){null===r&&k(182),null===i&&k(183);const{left:t,top:l}=i.getBoundingClientRect(),c=K(e,n);var a,f;u.isConnected||(f=u,(a=i).insertBefore(f,a.firstChild));let d=!1;for(let e=0;e<c.length;e++){const n=c[e],o=s[e]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",d=!0);const i=G(n.left-t);r.left!==i&&(r.left=i,d=!0);const a=G(n.top-l);r.top!==a&&(o.style.top=a,d=!0);const f=G(n.width);r.width!==f&&(o.style.width=f,d=!0);const g=G(n.height);r.height!==g&&(o.style.height=g,d=!0),o.parentNode!==u&&(u.append(o),d=!0),s[e]=o}for(;s.length>c.length;)s.pop();d&&o(s)}function a(){i=null,r=null,null!==l&&l.disconnect(),l=null,u.remove();for(const t of s)t.remove();s=[]}u.style.position="relative";const f=e.registerRootListener(function n(){const o=e.getRootElement();if(null===o)return a();const s=o.parentElement;if(!t(s))return a();a(),r=o,i=s,l=new MutationObserver(t=>{const o=e.getRootElement(),l=o&&o.parentElement;if(o!==r||l!==i)return n();for(const e of t)if(!u.contains(e.target))return c()}),l.observe(s,q),c()});return()=>{f(),a()}}function Q(t,e,n){if("text"!==t.type&&r(e)){const o=e.getDOMSlot(n);return[o.element,o.getFirstChildOffset()+t.offset]}return[i(n)||n,t.offset]}function X(t){for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==G(-1.5)&&(t.marginTop=G(-1.5)),t.paddingTop!==G(4)&&(t.paddingTop=G(4)),t.paddingBottom!==G(0)&&(t.paddingBottom=G(0))}}function Y(t,r=X){let i=null,l=null,s=null,u=null,c=null,a=null,f=()=>{};function d(e){e.read(()=>{const e=n();if(!o(e))return i=null,s=null,u=null,a=null,f(),void(f=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(e),p=d.getNode(),m=p.getKey(),h=d.offset,v=g.getNode(),y=v.getKey(),w=g.offset,x=t.getElementByKey(m),E=t.getElementByKey(y),S=null===i||x!==l||h!==s||m!==i.getKey(),C=null===u||E!==c||w!==a||y!==u.getKey();if((S||C)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const s=(t._window?t._window.document:document).createRange();return s.setStart(...Q(e,n,o)),s.setEnd(...Q(r,i,l)),s}(t,d,p,x,g,v,E);f(),f=J(t,e,r)}i=p,l=x,s=h,u=v,c=E,a=w})}return d(t.getEditorState()),e(t.registerUpdateListener(({editorState:t})=>d(t)),()=>{f()})}function Z(t,e){let n=null;const o=()=>{const o=getSelection(),r=o&&o.anchorNode,i=t.getRootElement();null!==r&&null!==i&&i.contains(r)?null!==n&&(n(),n=null):null===n&&(n=Y(t,e))};return t.registerRootListener(t=>{if(t){const e=t.ownerDocument;return e.addEventListener("selectionchange",o),o(),()=>{null!==n&&n(),e.removeEventListener("selectionchange",o)}}})}const tt=F,et=$,nt=z,ot=V,rt=O,it=W,lt=U,st=D,ut=j,ct=H;function at(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function ft(t,e){const n=t[Symbol.iterator]();return new Promise((t,o)=>{const r=[],i=()=>{const{done:l,value:s}=n.next();if(l)return t(r);const u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",()=>{const t=u.result;"string"==typeof t&&r.push({file:s,result:t}),i()}),at(s,e)?u.readAsDataURL(s):i()};i()})}function dt(t,e){return Array.from(mt(t,e))}function gt(t){return t?t.getAdjacentCaret():null}function pt(t,e){return Array.from(Et(t,e))}function mt(t,e){return vt("next",t,e)}function ht(t,e){const n=a(c(t,e));return n&&n[0]}function vt(t,e,n){const o=x(),i=e||o,s=r(i)?l(i,t):c(i,t),f=wt(i),d=n?S(u(c(n,t)))||ht(n,t):ht(i,t);let g=f;return M({hasNext:t=>null!==t,initial:s,map:t=>({depth:g,node:t.origin}),step:t=>{if(t.isSameNodeCaret(d))return null;C(t)&&g++;const e=a(t);return!e||e[0].isSameNodeCaret(d)?null:(g+=e[1],e[0])}})}function yt(t){const e=a(c(t,"next"));return e&&[e[0].origin,e[1]]}function wt(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function xt(t){const e=u(c(t,"previous")),n=a(e,"root");return n&&n[0].origin}function Et(t,e){return vt("previous",t,e)}function St(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function Ct(t){const e=s(t,t=>r(t)&&!t.isInline());return r(e)||k(4,t.__key),e}function At(t,e,n,o){const r=t=>t instanceof e;return t.registerNodeTransform(e,t=>{const e=(t=>{const e=t.getChildren();for(let t=0;t<e.length;t++){const n=e[t];if(r(n))return null}let n=t,o=t;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return{child:o,parent:n};return null})(t);if(null!==e){const{child:r,parent:i}=e;if(r.is(t)){o(i,t);const e=r.getNextSiblings(),l=e.length;if(i.insertAfter(r),0!==l){const t=n(i);r.insertAfter(t);for(let n=0;n<l;n++)t.append(e[n])}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove()}}})}function Nt(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,L(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;P(null===r?null:r.clone())}function bt(t){const e=n()||y();let r;if(o(e))r=w(e.focus,"next");else{if(null!=e){const t=e.getNodes(),n=t[t.length-1];n&&(r=c(n,"next"))}r=r||l(x(),"previous").getFlipped().insert(E())}const i=Lt(t,r),s=S(i),u=C(s)?A(s):i;return h(N(u)),t.getLatest()}function Lt(t,e,n){let o=b(e,"next");for(let t=o;t;t=m(t,n))o=t;return p(o)&&k(283),o.insert(t.isInline()?E().append(t):t),b(c(t.getLatest(),"next"),e.direction)}function Pt(t){const e=n();if(!o(e))return;const r=f(e);let i=d(g(r),"next").anchor;if(p(i)){const t=m(i);if(!t)return;i=t}const l=i.getFlipped();l.insert(t),h(v(l,l))}function Rt(t,e){const n=e();return t.replace(n),n.append(t),n}function Mt(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Tt(t,e){const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);null!==r&&n.push(r)}return n}function Bt(t){const e=n();if(!o(e))return!1;const i=new Set,l=e.getNodes();for(let e=0;e<l.length;e++){const n=l[e],o=n.getKey();if(i.has(o))continue;const u=s(n,t=>r(t)&&!t.isInline());if(null===u)continue;const c=u.getKey();u.canIndent()&&!i.has(c)&&(i.add(c),t(u))}return i.size>0}function _t(t,e){l(t,"next").insert(e)}let Kt=!(st||!et)&&void 0;function kt(t,e=!1){let n=1;if(function(){if(void 0===Kt){const t=document.createElement("div");t.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(t);const e=t.getBoundingClientRect();t.style.setProperty("zoom","2"),Kt=t.getBoundingClientRect().width===e.width,document.body.removeChild(t)}return Kt}()||e)for(;t;)n*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return n}function $t(t){return null!==t._parentEditor}function It(t,e){return Ot(t,e,null)}function Ot(t,e,n){let o=!1;for(const i of Ht(t))e(i)?null!==n&&n(i):(o=!0,r(i)&&Ot(i,e,n||(t=>i.insertAfter(t))),i.remove());return o}function Dt(t,e){const n=[],o=Array.from(t).reverse();for(let t=o.pop();void 0!==t;t=o.pop())if(e(t))n.push(t);else if(r(t))for(const e of Ht(t))o.push(e);return n}function Ft(t){return jt(l(t,"next"))}function Ht(t){return jt(l(t,"previous"))}function jt(t){return M({hasNext:T,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function zt(t){R(c(t,"next")).splice(1,t.getChildren())}function Ut(t){const e=e=>B(e,t),n=(e,n)=>_(e,t,n);return{$get:e,$set:n,accessors:[e,n],makeGetterMethod:()=>function(){return e(this)},makeSetterMethod:()=>function(t){return n(this,t)},stateConfig:t}}export{Dt as $descendantsMatching,dt as $dfs,mt as $dfsIterator,Tt as $filter,Ft as $firstToLastIterator,gt as $getAdjacentCaret,wt as $getDepth,Ct as $getNearestBlockElementAncestorOrThrow,St as $getNearestNodeOfType,xt as $getNextRightPreorderNode,yt as $getNextSiblingOrParentSibling,Bt as $handleIndentAndOutdent,_t as $insertFirst,Pt as $insertNodeIntoLeaf,bt as $insertNodeToNearestRoot,Lt as $insertNodeToNearestRootAtCaret,$t as $isEditorIsNestedEditor,Ht as $lastToFirstIterator,Nt as $restoreEditorState,pt as $reverseDfs,Et as $reverseDfsIterator,It as $unwrapAndFilterDescendants,zt as $unwrapNode,Rt as $wrapNodeInElement,tt as CAN_USE_BEFORE_INPUT,et as CAN_USE_DOM,nt as IS_ANDROID,ot as IS_ANDROID_CHROME,rt as IS_APPLE,it as IS_APPLE_WEBKIT,lt as IS_CHROME,st as IS_FIREFOX,ut as IS_IOS,ct as IS_SAFARI,kt as calculateZoomLevel,at as isMimeType,Ut as makeStateWrapper,Y as markSelection,ft as mediaFileReader,Mt as objectKlassEquals,J as positionNodeOnRange,At as registerNestedElementResolver,Z as selectionAlwaysOnDisplay};

@@ -17,2 +17,2 @@ /**

*/
export default function markSelection(editor: LexicalEditor, onReposition?: (node: Array<HTMLElement>) => void): () => void;
export default function markSelection(editor: LexicalEditor, onReposition?: (node: readonly HTMLElement[]) => void): () => void;

@@ -11,8 +11,8 @@ {

"license": "MIT",
"version": "0.41.1-nightly.20260317.0",
"version": "0.41.1-nightly.20260318.0",
"main": "LexicalUtils.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/selection": "0.41.1-nightly.20260317.0",
"lexical": "0.41.1-nightly.20260317.0"
"@lexical/selection": "0.41.1-nightly.20260318.0",
"lexical": "0.41.1-nightly.20260318.0"
},

@@ -19,0 +19,0 @@ "repository": {

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

import { LexicalEditor } from 'lexical';
export default function selectionAlwaysOnDisplay(editor: LexicalEditor, onReposition?: (node: Array<HTMLElement>) => void): () => void;
export default function selectionAlwaysOnDisplay(editor: LexicalEditor, onReposition?: (node: readonly HTMLElement[]) => void): () => void;