@lexical/utils 0.35.1-nightly.20250915.0 → 0.35.1-nightly.20250917.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -666,7 +666,7 @@ function $getNearestNodeOfType(node, klass) {
666
666
  * @returns The ancestor node found
667
667
  */
668
668
  function $getNearestBlockElementAncestorOrThrow(startNode) {
669
- const blockNode = $findMatchingParent(startNode, node => lexical.$isElementNode(node) && !node.isInline());
669
+ const blockNode = lexical.$findMatchingParent(startNode, node => lexical.$isElementNode(node) && !node.isInline());
670
670
  if (!lexical.$isElementNode(blockNode)) {
671
671
  {
672
672
  formatDevErrorMessage(`Expected node ${startNode.__key} to have closest block element node.`);
@@ -674,25 +674,6 @@ function $getNearestBlockElementAncestorOrThrow(startNode) {
674
674
  }
675
675
  return blockNode;
676
676
  }
677
- /**
678
- * Starts with a node and moves up the tree (toward the root node) to find a matching node based on
679
- * the search parameters of the findFn. (Consider JavaScripts' .find() function where a testing function must be
680
- * passed as an argument. eg. if( (node) => node.__type === 'div') ) return true; otherwise return false
681
- * @param startingNode - The node where the search starts.
682
- * @param findFn - A testing function that returns true if the current node satisfies the testing parameters.
683
- * @returns A parent node that matches the findFn parameters, or null if one wasn't found.
684
- */
685
- const $findMatchingParent = (startingNode, findFn) => {
686
- let curr = startingNode;
687
- while (curr !== lexical.$getRoot() && curr != null) {
688
- if (findFn(curr)) {
689
- return curr;
690
- }
691
- curr = curr.getParent();
692
- }
693
- return null;
694
- };
695
-
696
677
  /**
697
678
  * Attempts to resolve nested element nodes of the same type into a single node of that type.
698
679
  * It is generally used for marks/commenting
@@ -1073,6 +1054,7 @@ function makeStateWrapper(stateConfig) {
1073
1054
  };
1074
1055
  }
1075
1056
 
1057
+ exports.$findMatchingParent = lexical.$findMatchingParent;
1076
1058
  exports.$getAdjacentSiblingOrParentSiblingCaret = lexical.$getAdjacentSiblingOrParentSiblingCaret;
1077
1059
  exports.$splitNode = lexical.$splitNode;
1078
1060
  exports.isBlockDomNode = lexical.isBlockDomNode;
@@ -1083,7 +1065,6 @@ exports.$descendantsMatching = $descendantsMatching;
1083
1065
  exports.$dfs = $dfs;
1084
1066
  exports.$dfsIterator = $dfsIterator;
1085
1067
  exports.$filter = $filter;
1086
- exports.$findMatchingParent = $findMatchingParent;
1087
1068
  exports.$firstToLastIterator = $firstToLastIterator;
1088
1069
  exports.$getAdjacentCaret = $getAdjacentCaret;
1089
1070
  exports.$getDepth = $getDepth;
@@ -6,8 +6,8 @@
6
6
  *
7
7
  */
8
8
 
9
- import { isHTMLElement, $getSelection, $isRangeSelection, $isElementNode, getDOMTextNode, $getRoot, $getChildCaret, $getSiblingCaret, $getAdjacentChildCaret, $getChildCaretOrSelf, makeStepwiseIterator, $isChildCaret, $getAdjacentSiblingOrParentSiblingCaret, $cloneWithProperties, $setSelection, $getPreviousSelection, $caretFromPoint, $createParagraphNode, $normalizeCaret, $setSelectionFromCaretRange, $getCollapsedCaretRange, $getCaretInDirection, $splitAtPointCaretNext, $isTextPointCaret, $isSiblingCaret, $rewindSiblingCaret, $getState, $setState } from 'lexical';
10
- export { $getAdjacentSiblingOrParentSiblingCaret, $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode } from 'lexical';
9
+ import { isHTMLElement, $getSelection, $isRangeSelection, $isElementNode, getDOMTextNode, $getRoot, $getChildCaret, $getSiblingCaret, $getAdjacentChildCaret, $getChildCaretOrSelf, makeStepwiseIterator, $isChildCaret, $getAdjacentSiblingOrParentSiblingCaret, $findMatchingParent, $cloneWithProperties, $setSelection, $getPreviousSelection, $caretFromPoint, $createParagraphNode, $normalizeCaret, $setSelectionFromCaretRange, $getCollapsedCaretRange, $getCaretInDirection, $splitAtPointCaretNext, $isTextPointCaret, $isSiblingCaret, $rewindSiblingCaret, $getState, $setState } from 'lexical';
10
+ export { $findMatchingParent, $getAdjacentSiblingOrParentSiblingCaret, $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode } from 'lexical';
11
11
  import { createRectsFromDOMRange } from '@lexical/selection';
12
12
 
13
13
  /**
@@ -673,25 +673,6 @@ function $getNearestBlockElementAncestorOrThrow(startNode) {
673
673
  }
674
674
  return blockNode;
675
675
  }
676
- /**
677
- * Starts with a node and moves up the tree (toward the root node) to find a matching node based on
678
- * the search parameters of the findFn. (Consider JavaScripts' .find() function where a testing function must be
679
- * passed as an argument. eg. if( (node) => node.__type === 'div') ) return true; otherwise return false
680
- * @param startingNode - The node where the search starts.
681
- * @param findFn - A testing function that returns true if the current node satisfies the testing parameters.
682
- * @returns A parent node that matches the findFn parameters, or null if one wasn't found.
683
- */
684
- const $findMatchingParent = (startingNode, findFn) => {
685
- let curr = startingNode;
686
- while (curr !== $getRoot() && curr != null) {
687
- if (findFn(curr)) {
688
- return curr;
689
- }
690
- curr = curr.getParent();
691
- }
692
- return null;
693
- };
694
-
695
676
  /**
696
677
  * Attempts to resolve nested element nodes of the same type into a single node of that type.
697
678
  * It is generally used for marks/commenting
@@ -1072,4 +1053,4 @@ function makeStateWrapper(stateConfig) {
1072
1053
  };
1073
1054
  }
1074
1055
 
1075
- export { $descendantsMatching, $dfs, $dfsIterator, $filter, $findMatchingParent, $firstToLastIterator, $getAdjacentCaret, $getDepth, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, $getNextRightPreorderNode, $getNextSiblingOrParentSibling, $insertFirst, $insertNodeToNearestRoot, $insertNodeToNearestRootAtCaret, $isEditorIsNestedEditor, $lastToFirstIterator, $restoreEditorState, $reverseDfs, $reverseDfsIterator, $unwrapAndFilterDescendants, $unwrapNode, $wrapNodeInElement, CAN_USE_BEFORE_INPUT, CAN_USE_DOM, IS_ANDROID, IS_ANDROID_CHROME, IS_APPLE, IS_APPLE_WEBKIT, IS_CHROME, IS_FIREFOX, IS_IOS, IS_SAFARI, addClassNamesToElement, calculateZoomLevel, isMimeType, makeStateWrapper, markSelection, mediaFileReader, mergeRegister, objectKlassEquals, mlcPositionNodeOnRange as positionNodeOnRange, registerNestedElementResolver, removeClassNamesFromElement, selectionAlwaysOnDisplay };
1056
+ export { $descendantsMatching, $dfs, $dfsIterator, $filter, $firstToLastIterator, $getAdjacentCaret, $getDepth, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, $getNextRightPreorderNode, $getNextSiblingOrParentSibling, $insertFirst, $insertNodeToNearestRoot, $insertNodeToNearestRootAtCaret, $isEditorIsNestedEditor, $lastToFirstIterator, $restoreEditorState, $reverseDfs, $reverseDfsIterator, $unwrapAndFilterDescendants, $unwrapNode, $wrapNodeInElement, CAN_USE_BEFORE_INPUT, CAN_USE_DOM, IS_ANDROID, IS_ANDROID_CHROME, IS_APPLE, IS_APPLE_WEBKIT, IS_CHROME, IS_FIREFOX, IS_IOS, IS_SAFARI, addClassNamesToElement, calculateZoomLevel, isMimeType, makeStateWrapper, markSelection, mediaFileReader, mergeRegister, objectKlassEquals, mlcPositionNodeOnRange as positionNodeOnRange, registerNestedElementResolver, removeClassNamesFromElement, selectionAlwaysOnDisplay };
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "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)&&!d;function p(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function m(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function h(e){return`${e}px`}const $={attributes:!0,characterData:!0,childList:!0,subtree:!0};function x(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 p=!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",p=!0);const i=h(n.left-e);o.left!==i&&(o.left=i,p=!0);const s=h(n.top-a);o.top!==s&&(r.style.top=s,p=!0);const l=h(n.width);o.width!==l&&(r.style.width=l,p=!0);const g=h(n.height);o.height!==g&&(r.style.height=g,p=!0),r.parentNode!==u&&(u.append(r),p=!0),c[t]=r}for(;c.length>d.length;)c.pop();p&&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,$),d()}));return()=>{f(),g()}}function S(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 C(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(),p=f.getKey(),m=d.offset,$=g.getNode(),C=$.getKey(),E=g.offset,v=t.getElementByKey(p),N=t.getElementByKey(C),A=null===r||v!==o||m!==i||p!==r.getKey(),w=null===s||N!==l||E!==a||C!==s.getKey();if((A||w)&&null!==v&&null!==N){const e=function(e,t,n,r,o,i,s){const l=(e._window?e._window.document:document).createRange();return l.setStart(...S(t,n,r)),l.setEnd(...S(o,i,s)),l}(t,d,f,v,g,$,N);c(),c=x(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!==h(-1.5)&&(e.marginTop=h(-1.5)),e.paddingTop!==h(4)&&(e.paddingTop=h(4)),e.paddingBottom!==h(0)&&(e.paddingBottom=h(0))}else n(e)}))}r=f,o=v,i=m,s=$,l=N,a=E}))}return u(t.getEditorState()),m(t.registerUpdateListener((({editorState:e})=>u(e))),(()=>{c()}))}const E=l,v=r,N=u,A=g,w=i,b=f,y=d,P=s,R=c,I=a;function O(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function T(e,t){return L("next",e,t)}function L(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))):function(t,n){const r=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,n));return r&&r[0]}(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 L("previous",e,t)}const D=(t,n)=>{let r=t;for(;r!==e.$getRoot()&&null!=r;){if(n(r))return r;r=r.getParent()}return null};function F(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 B=!(P||!v)&&void 0;function j(t,n,r){let o=!1;for(const i of k(t))n(i)?null!==r&&r(i):(o=!0,e.$isElementNode(i)&&j(i,n,r||(e=>i.insertAfter(e))),i.remove());return o}function k(t){return H(e.$getChildCaret(t,"previous"))}function H(t){return e.makeStepwiseIterator({hasNext:e.$isSiblingCaret,initial:t.getAdjacentCaret(),map:e=>e.origin.getLatest(),step:e=>e.getAdjacentCaret()})}exports.$getAdjacentSiblingOrParentSiblingCaret=e.$getAdjacentSiblingOrParentSiblingCaret,exports.$splitNode=e.$splitNode,exports.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,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 k(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.$findMatchingParent=D,exports.$firstToLastIterator=function(t){return H(e.$getChildCaret(t,"next"))},exports.$getAdjacentCaret=function(e){return e?e.getAdjacentCaret():null},exports.$getDepth=M,exports.$getNearestBlockElementAncestorOrThrow=function(t){const r=D(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.$insertFirst=function(t,n){e.$getChildCaret(t,"next").insert(n)},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=F(t,r),i=e.$getAdjacentChildCaret(o),s=e.$isChildCaret(i)?e.$normalizeCaret(i):o;return e.$setSelectionFromCaretRange(e.$getCollapsedCaretRange(s)),t.getLatest()},exports.$insertNodeToNearestRootAtCaret=F,exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=k,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 j(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=E,exports.CAN_USE_DOM=v,exports.IS_ANDROID=N,exports.IS_ANDROID_CHROME=A,exports.IS_APPLE=w,exports.IS_APPLE_WEBKIT=b,exports.IS_CHROME=y,exports.IS_FIREFOX=P,exports.IS_IOS=R,exports.IS_SAFARI=I,exports.addClassNamesToElement=function(e,...t){const n=p(...t);n.length>0&&e.classList.add(...n)},exports.calculateZoomLevel=function(e){let t=1;if(function(){if(void 0===B){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"),B=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return B}())for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t},exports.isMimeType=O,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()})),O(l,t)?a.readAsDataURL(l):i()};i()}))},exports.mergeRegister=m,exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=x,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.removeClassNamesFromElement=function(e,...t){const n=p(...t);n.length>0&&e.classList.remove(...n)},exports.selectionAlwaysOnDisplay=function(e){let t=null;const n=()=>{const n=getSelection(),r=n&&n.anchorNode,o=e.getRootElement();null!==r&&null!==o&&o.contains(r)?null!==t&&(t(),t=null):null===t&&(t=C(e))};return document.addEventListener("selectionchange",n),()=>{null!==t&&t(),document.removeEventListener("selectionchange",n)}};
9
+ "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)&&!d;function p(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function m(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function h(e){return`${e}px`}const $={attributes:!0,characterData:!0,childList:!0,subtree:!0};function x(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 p=!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",p=!0);const i=h(n.left-e);o.left!==i&&(o.left=i,p=!0);const s=h(n.top-a);o.top!==s&&(r.style.top=s,p=!0);const l=h(n.width);o.width!==l&&(r.style.width=l,p=!0);const g=h(n.height);o.height!==g&&(r.style.height=g,p=!0),r.parentNode!==u&&(u.append(r),p=!0),c[t]=r}for(;c.length>d.length;)c.pop();p&&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,$),d()}));return()=>{f(),g()}}function S(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 C(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(),p=f.getKey(),m=d.offset,$=g.getNode(),C=$.getKey(),E=g.offset,v=t.getElementByKey(p),N=t.getElementByKey(C),A=null===r||v!==o||m!==i||p!==r.getKey(),w=null===s||N!==l||E!==a||C!==s.getKey();if((A||w)&&null!==v&&null!==N){const e=function(e,t,n,r,o,i,s){const l=(e._window?e._window.document:document).createRange();return l.setStart(...S(t,n,r)),l.setEnd(...S(o,i,s)),l}(t,d,f,v,g,$,N);c(),c=x(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!==h(-1.5)&&(e.marginTop=h(-1.5)),e.paddingTop!==h(4)&&(e.paddingTop=h(4)),e.paddingBottom!==h(0)&&(e.paddingBottom=h(0))}else n(e)}))}r=f,o=v,i=m,s=$,l=N,a=E}))}return u(t.getEditorState()),m(t.registerUpdateListener((({editorState:e})=>u(e))),(()=>{c()}))}const E=l,v=r,N=u,A=g,w=i,b=f,y=d,P=s,R=c,I=a;function O(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function M(e,t){return T("next",e,t)}function T(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))):function(t,n){const r=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,n));return r&&r[0]}(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 T("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=!(P||!v)&&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.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,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(M(e,t))},exports.$dfsIterator=M,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.$insertFirst=function(t,n){e.$getChildCaret(t,"next").insert(n)},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=E,exports.CAN_USE_DOM=v,exports.IS_ANDROID=N,exports.IS_ANDROID_CHROME=A,exports.IS_APPLE=w,exports.IS_APPLE_WEBKIT=b,exports.IS_CHROME=y,exports.IS_FIREFOX=P,exports.IS_IOS=R,exports.IS_SAFARI=I,exports.addClassNamesToElement=function(e,...t){const n=p(...t);n.length>0&&e.classList.add(...n)},exports.calculateZoomLevel=function(e){let t=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}())for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t},exports.isMimeType=O,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()})),O(l,t)?a.readAsDataURL(l):i()};i()}))},exports.mergeRegister=m,exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=x,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.removeClassNamesFromElement=function(e,...t){const n=p(...t);n.length>0&&e.classList.remove(...n)},exports.selectionAlwaysOnDisplay=function(e){let t=null;const n=()=>{const n=getSelection(),r=n&&n.anchorNode,o=e.getRootElement();null!==r&&null!==o&&o.contains(r)?null!==t&&(t(),t=null):null===t&&(t=C(e))};return document.addEventListener("selectionchange",n),()=>{null!==t&&t(),document.removeEventListener("selectionchange",n)}};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{isHTMLElement as t,$getSelection as e,$isRangeSelection as n,$isElementNode as o,getDOMTextNode as r,$getRoot as i,$getChildCaret as l,$getSiblingCaret as u,$getAdjacentChildCaret as s,$getChildCaretOrSelf as c,makeStepwiseIterator as f,$isChildCaret as a,$getAdjacentSiblingOrParentSiblingCaret as d,$cloneWithProperties as g,$setSelection as p,$getPreviousSelection as m,$caretFromPoint as h,$createParagraphNode as v,$normalizeCaret as y,$setSelectionFromCaretRange as w,$getCollapsedCaretRange as x,$getCaretInDirection as E,$splitAtPointCaretNext as S,$isTextPointCaret as A,$isSiblingCaret as C,$rewindSiblingCaret as b,$getState as L,$setState as P}from"lexical";export{$getAdjacentSiblingOrParentSiblingCaret,$splitNode,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode}from"lexical";import{createRectsFromDOMRange as N}from"@lexical/selection";function M(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 R="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,T=R&&"documentMode"in document?document.documentMode:null,B=R&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),_=R&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),k=!(!R||!("InputEvent"in window)||T)&&"getTargetRanges"in new window.InputEvent("input"),K=R&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),O=R&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,$=R&&/Android/.test(navigator.userAgent),H=R&&/^(?=.*Chrome).*/i.test(navigator.userAgent),j=R&&$&&H,D=R&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!H;function I(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function F(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function U(t){return`${t}px`}const z={attributes:!0,characterData:!0,childList:!0,subtree:!0};function V(e,n,o){let r=null,i=null,l=null,u=[];const s=document.createElement("div");function c(){null===r&&M(182),null===i&&M(183);const{left:t,top:l}=i.getBoundingClientRect(),c=N(e,n);var f,a;s.isConnected||(a=s,(f=i).insertBefore(a,f.firstChild));let d=!1;for(let e=0;e<c.length;e++){const n=c[e],o=u[e]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",d=!0);const i=U(n.left-t);r.left!==i&&(r.left=i,d=!0);const f=U(n.top-l);r.top!==f&&(o.style.top=f,d=!0);const a=U(n.width);r.width!==a&&(o.style.width=a,d=!0);const g=U(n.height);r.height!==g&&(o.style.height=g,d=!0),o.parentNode!==s&&(s.append(o),d=!0),u[e]=o}for(;u.length>c.length;)u.pop();d&&o(u)}function f(){i=null,r=null,null!==l&&l.disconnect(),l=null,s.remove();for(const t of u)t.remove();u=[]}s.style.position="relative";const a=e.registerRootListener((function n(){const o=e.getRootElement();if(null===o)return f();const u=o.parentElement;if(!t(u))return f();f(),r=o,i=u,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(!s.contains(e.target))return c()})),l.observe(u,z),c()}));return()=>{a(),f()}}function W(t,e,n){if("text"!==t.type&&o(e)){const o=e.getDOMSlot(n);return[o.element,o.getFirstChildOffset()+t.offset]}return[r(n)||n,t.offset]}function G(t,o){let r=null,i=null,l=null,u=null,s=null,c=null,f=()=>{};function a(a){a.read((()=>{const a=e();if(!n(a))return r=null,l=null,u=null,c=null,f(),void(f=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(a),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===r||x!==i||h!==l||m!==r.getKey(),A=null===u||E!==s||w!==c||y!==u.getKey();if((S||A)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const u=(t._window?t._window.document:document).createRange();return u.setStart(...W(e,n,o)),u.setEnd(...W(r,i,l)),u}(t,d,p,x,g,v,E);f(),f=V(t,e,(t=>{if(void 0===o)for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==U(-1.5)&&(t.marginTop=U(-1.5)),t.paddingTop!==U(4)&&(t.paddingTop=U(4)),t.paddingBottom!==U(0)&&(t.paddingBottom=U(0))}else o(t)}))}r=p,i=x,l=h,u=v,s=E,c=w}))}return a(t.getEditorState()),F(t.registerUpdateListener((({editorState:t})=>a(t))),(()=>{f()}))}function q(t){let e=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=t.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==e&&(e(),e=null):null===e&&(e=G(t))};return document.addEventListener("selectionchange",n),()=>{null!==e&&e(),document.removeEventListener("selectionchange",n)}}const J=k,Q=R,X=$,Y=j,Z=B,tt=D,et=H,nt=_,ot=O,rt=K;function it(t,...e){const n=I(...e);n.length>0&&t.classList.add(...n)}function lt(t,...e){const n=I(...e);n.length>0&&t.classList.remove(...n)}function ut(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function st(t,e){const n=t[Symbol.iterator]();return new Promise(((t,o)=>{const r=[],i=()=>{const{done:l,value:u}=n.next();if(l)return t(r);const s=new FileReader;s.addEventListener("error",o),s.addEventListener("load",(()=>{const t=s.result;"string"==typeof t&&r.push({file:u,result:t}),i()})),ut(u,e)?s.readAsDataURL(u):i()};i()}))}function ct(t,e){return Array.from(dt(t,e))}function ft(t){return t?t.getAdjacentCaret():null}function at(t,e){return Array.from(vt(t,e))}function dt(t,e){return gt("next",t,e)}function gt(t,e,n){const r=i(),g=e||r,p=o(g)?l(g,t):u(g,t),m=mt(g),h=n?s(c(u(n,t))):function(t,e){const n=d(u(t,e));return n&&n[0]}(g,t);let v=m;return f({hasNext:t=>null!==t,initial:p,map:t=>({depth:v,node:t.origin}),step:t=>{if(t.isSameNodeCaret(h))return null;a(t)&&v++;const e=d(t);return!e||e[0].isSameNodeCaret(h)?null:(v+=e[1],e[0])}})}function pt(t){const e=d(u(t,"next"));return e&&[e[0].origin,e[1]]}function mt(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function ht(t){const e=c(u(t,"previous")),n=d(e,"root");return n&&n[0].origin}function vt(t,e){return gt("previous",t,e)}function yt(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function wt(t){const e=xt(t,(t=>o(t)&&!t.isInline()));return o(e)||M(4,t.__key),e}const xt=(t,e)=>{let n=t;for(;n!==i()&&null!=n;){if(e(n))return n;n=n.getParent()}return null};function Et(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 St(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,g(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;p(null===r?null:r.clone())}function At(t){const o=e()||m();let r;if(n(o))r=h(o.focus,"next");else{if(null!=o){const t=o.getNodes(),e=t[t.length-1];e&&(r=u(e,"next"))}r=r||l(i(),"previous").getFlipped().insert(v())}const c=Ct(t,r),f=s(c),d=a(f)?y(f):c;return w(x(d)),t.getLatest()}function Ct(t,e,n){let o=E(e,"next");for(let t=o;t;t=S(t,n))o=t;return A(o)&&M(283),o.insert(t.isInline()?v().append(t):t),E(u(t.getLatest(),"next"),e.direction)}function bt(t,e){const n=e();return t.replace(n),n.append(t),n}function Lt(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Pt(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 Nt(t,e){l(t,"next").insert(e)}let Mt=!(nt||!Q)&&void 0;function Rt(t){let e=1;if(function(){if(void 0===Mt){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"),Mt=t.getBoundingClientRect().width===e.width,document.body.removeChild(t)}return Mt}())for(;t;)e*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return e}function Tt(t){return null!==t._parentEditor}function Bt(t,e){return _t(t,e,null)}function _t(t,e,n){let r=!1;for(const i of Ot(t))e(i)?null!==n&&n(i):(r=!0,o(i)&&_t(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function kt(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if(o(t))for(const e of Ot(t))r.push(e);return n}function Kt(t){return $t(l(t,"next"))}function Ot(t){return $t(l(t,"previous"))}function $t(t){return f({hasNext:C,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function Ht(t){b(u(t,"next")).splice(1,t.getChildren())}function jt(t){const e=e=>L(e,t),n=(e,n)=>P(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{kt as $descendantsMatching,ct as $dfs,dt as $dfsIterator,Pt as $filter,xt as $findMatchingParent,Kt as $firstToLastIterator,ft as $getAdjacentCaret,mt as $getDepth,wt as $getNearestBlockElementAncestorOrThrow,yt as $getNearestNodeOfType,ht as $getNextRightPreorderNode,pt as $getNextSiblingOrParentSibling,Nt as $insertFirst,At as $insertNodeToNearestRoot,Ct as $insertNodeToNearestRootAtCaret,Tt as $isEditorIsNestedEditor,Ot as $lastToFirstIterator,St as $restoreEditorState,at as $reverseDfs,vt as $reverseDfsIterator,Bt as $unwrapAndFilterDescendants,Ht as $unwrapNode,bt as $wrapNodeInElement,J as CAN_USE_BEFORE_INPUT,Q as CAN_USE_DOM,X as IS_ANDROID,Y as IS_ANDROID_CHROME,Z as IS_APPLE,tt as IS_APPLE_WEBKIT,et as IS_CHROME,nt as IS_FIREFOX,ot as IS_IOS,rt as IS_SAFARI,it as addClassNamesToElement,Rt as calculateZoomLevel,ut as isMimeType,jt as makeStateWrapper,G as markSelection,st as mediaFileReader,F as mergeRegister,Lt as objectKlassEquals,V as positionNodeOnRange,Et as registerNestedElementResolver,lt as removeClassNamesFromElement,q as selectionAlwaysOnDisplay};
9
+ import{isHTMLElement as t,$getSelection as e,$isRangeSelection as n,$isElementNode as o,getDOMTextNode as r,$getRoot as i,$getChildCaret as l,$getSiblingCaret as u,$getAdjacentChildCaret as s,$getChildCaretOrSelf as c,makeStepwiseIterator as a,$isChildCaret as f,$getAdjacentSiblingOrParentSiblingCaret as d,$findMatchingParent as g,$cloneWithProperties as p,$setSelection as m,$getPreviousSelection as h,$caretFromPoint as v,$createParagraphNode as y,$normalizeCaret as w,$setSelectionFromCaretRange as x,$getCollapsedCaretRange as E,$getCaretInDirection as S,$splitAtPointCaretNext as A,$isTextPointCaret as C,$isSiblingCaret as b,$rewindSiblingCaret as L,$getState as P,$setState as N}from"lexical";export{$findMatchingParent,$getAdjacentSiblingOrParentSiblingCaret,$splitNode,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode}from"lexical";import{createRectsFromDOMRange as M}from"@lexical/selection";function R(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 T="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,B=T&&"documentMode"in document?document.documentMode:null,_=T&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),k=T&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),$=!(!T||!("InputEvent"in window)||B)&&"getTargetRanges"in new window.InputEvent("input"),K=T&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),O=T&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,H=T&&/Android/.test(navigator.userAgent),j=T&&/^(?=.*Chrome).*/i.test(navigator.userAgent),D=T&&H&&j,I=T&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!j;function F(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function U(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function z(t){return`${t}px`}const V={attributes:!0,characterData:!0,childList:!0,subtree:!0};function W(e,n,o){let r=null,i=null,l=null,u=[];const s=document.createElement("div");function c(){null===r&&R(182),null===i&&R(183);const{left:t,top:l}=i.getBoundingClientRect(),c=M(e,n);var a,f;s.isConnected||(f=s,(a=i).insertBefore(f,a.firstChild));let d=!1;for(let e=0;e<c.length;e++){const n=c[e],o=u[e]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",d=!0);const i=z(n.left-t);r.left!==i&&(r.left=i,d=!0);const a=z(n.top-l);r.top!==a&&(o.style.top=a,d=!0);const f=z(n.width);r.width!==f&&(o.style.width=f,d=!0);const g=z(n.height);r.height!==g&&(o.style.height=g,d=!0),o.parentNode!==s&&(s.append(o),d=!0),u[e]=o}for(;u.length>c.length;)u.pop();d&&o(u)}function a(){i=null,r=null,null!==l&&l.disconnect(),l=null,s.remove();for(const t of u)t.remove();u=[]}s.style.position="relative";const f=e.registerRootListener((function n(){const o=e.getRootElement();if(null===o)return a();const u=o.parentElement;if(!t(u))return a();a(),r=o,i=u,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(!s.contains(e.target))return c()})),l.observe(u,V),c()}));return()=>{f(),a()}}function G(t,e,n){if("text"!==t.type&&o(e)){const o=e.getDOMSlot(n);return[o.element,o.getFirstChildOffset()+t.offset]}return[r(n)||n,t.offset]}function q(t,o){let r=null,i=null,l=null,u=null,s=null,c=null,a=()=>{};function f(f){f.read((()=>{const f=e();if(!n(f))return r=null,l=null,u=null,c=null,a(),void(a=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(f),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===r||x!==i||h!==l||m!==r.getKey(),A=null===u||E!==s||w!==c||y!==u.getKey();if((S||A)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const u=(t._window?t._window.document:document).createRange();return u.setStart(...G(e,n,o)),u.setEnd(...G(r,i,l)),u}(t,d,p,x,g,v,E);a(),a=W(t,e,(t=>{if(void 0===o)for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==z(-1.5)&&(t.marginTop=z(-1.5)),t.paddingTop!==z(4)&&(t.paddingTop=z(4)),t.paddingBottom!==z(0)&&(t.paddingBottom=z(0))}else o(t)}))}r=p,i=x,l=h,u=v,s=E,c=w}))}return f(t.getEditorState()),U(t.registerUpdateListener((({editorState:t})=>f(t))),(()=>{a()}))}function J(t){let e=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=t.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==e&&(e(),e=null):null===e&&(e=q(t))};return document.addEventListener("selectionchange",n),()=>{null!==e&&e(),document.removeEventListener("selectionchange",n)}}const Q=$,X=T,Y=H,Z=D,tt=_,et=I,nt=j,ot=k,rt=O,it=K;function lt(t,...e){const n=F(...e);n.length>0&&t.classList.add(...n)}function ut(t,...e){const n=F(...e);n.length>0&&t.classList.remove(...n)}function st(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function ct(t,e){const n=t[Symbol.iterator]();return new Promise(((t,o)=>{const r=[],i=()=>{const{done:l,value:u}=n.next();if(l)return t(r);const s=new FileReader;s.addEventListener("error",o),s.addEventListener("load",(()=>{const t=s.result;"string"==typeof t&&r.push({file:u,result:t}),i()})),st(u,e)?s.readAsDataURL(u):i()};i()}))}function at(t,e){return Array.from(gt(t,e))}function ft(t){return t?t.getAdjacentCaret():null}function dt(t,e){return Array.from(yt(t,e))}function gt(t,e){return pt("next",t,e)}function pt(t,e,n){const r=i(),g=e||r,p=o(g)?l(g,t):u(g,t),m=ht(g),h=n?s(c(u(n,t))):function(t,e){const n=d(u(t,e));return n&&n[0]}(g,t);let v=m;return a({hasNext:t=>null!==t,initial:p,map:t=>({depth:v,node:t.origin}),step:t=>{if(t.isSameNodeCaret(h))return null;f(t)&&v++;const e=d(t);return!e||e[0].isSameNodeCaret(h)?null:(v+=e[1],e[0])}})}function mt(t){const e=d(u(t,"next"));return e&&[e[0].origin,e[1]]}function ht(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function vt(t){const e=c(u(t,"previous")),n=d(e,"root");return n&&n[0].origin}function yt(t,e){return pt("previous",t,e)}function wt(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function xt(t){const e=g(t,(t=>o(t)&&!t.isInline()));return o(e)||R(4,t.__key),e}function Et(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 St(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;m(null===r?null:r.clone())}function At(t){const o=e()||h();let r;if(n(o))r=v(o.focus,"next");else{if(null!=o){const t=o.getNodes(),e=t[t.length-1];e&&(r=u(e,"next"))}r=r||l(i(),"previous").getFlipped().insert(y())}const c=Ct(t,r),a=s(c),d=f(a)?w(a):c;return x(E(d)),t.getLatest()}function Ct(t,e,n){let o=S(e,"next");for(let t=o;t;t=A(t,n))o=t;return C(o)&&R(283),o.insert(t.isInline()?y().append(t):t),S(u(t.getLatest(),"next"),e.direction)}function bt(t,e){const n=e();return t.replace(n),n.append(t),n}function Lt(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Pt(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 Nt(t,e){l(t,"next").insert(e)}let Mt=!(ot||!X)&&void 0;function Rt(t){let e=1;if(function(){if(void 0===Mt){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"),Mt=t.getBoundingClientRect().width===e.width,document.body.removeChild(t)}return Mt}())for(;t;)e*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return e}function Tt(t){return null!==t._parentEditor}function Bt(t,e){return _t(t,e,null)}function _t(t,e,n){let r=!1;for(const i of Kt(t))e(i)?null!==n&&n(i):(r=!0,o(i)&&_t(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function kt(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if(o(t))for(const e of Kt(t))r.push(e);return n}function $t(t){return Ot(l(t,"next"))}function Kt(t){return Ot(l(t,"previous"))}function Ot(t){return a({hasNext:b,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function Ht(t){L(u(t,"next")).splice(1,t.getChildren())}function jt(t){const e=e=>P(e,t),n=(e,n)=>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{kt as $descendantsMatching,at as $dfs,gt as $dfsIterator,Pt as $filter,$t as $firstToLastIterator,ft as $getAdjacentCaret,ht as $getDepth,xt as $getNearestBlockElementAncestorOrThrow,wt as $getNearestNodeOfType,vt as $getNextRightPreorderNode,mt as $getNextSiblingOrParentSibling,Nt as $insertFirst,At as $insertNodeToNearestRoot,Ct as $insertNodeToNearestRootAtCaret,Tt as $isEditorIsNestedEditor,Kt as $lastToFirstIterator,St as $restoreEditorState,dt as $reverseDfs,yt as $reverseDfsIterator,Bt as $unwrapAndFilterDescendants,Ht as $unwrapNode,bt as $wrapNodeInElement,Q as CAN_USE_BEFORE_INPUT,X as CAN_USE_DOM,Y as IS_ANDROID,Z as IS_ANDROID_CHROME,tt as IS_APPLE,et as IS_APPLE_WEBKIT,nt as IS_CHROME,ot as IS_FIREFOX,rt as IS_IOS,it as IS_SAFARI,lt as addClassNamesToElement,Rt as calculateZoomLevel,st as isMimeType,jt as makeStateWrapper,q as markSelection,ct as mediaFileReader,U as mergeRegister,Lt as objectKlassEquals,W as positionNodeOnRange,Et as registerNestedElementResolver,ut as removeClassNamesFromElement,J as selectionAlwaysOnDisplay};
package/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { default as markSelection } from './markSelection';
10
10
  export { default as mergeRegister } from './mergeRegister';
11
11
  export { default as positionNodeOnRange } from './positionNodeOnRange';
12
12
  export { default as selectionAlwaysOnDisplay } from './selectionAlwaysOnDisplay';
13
- export { $getAdjacentSiblingOrParentSiblingCaret, $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, } from 'lexical';
13
+ export { $findMatchingParent, $getAdjacentSiblingOrParentSiblingCaret, $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, } from 'lexical';
14
14
  export declare const CAN_USE_BEFORE_INPUT: boolean;
15
15
  export declare const CAN_USE_DOM: boolean;
16
16
  export declare const IS_ANDROID: boolean;
@@ -141,18 +141,6 @@ export declare function $getNearestNodeOfType<T extends ElementNode>(node: Lexic
141
141
  export declare function $getNearestBlockElementAncestorOrThrow(startNode: LexicalNode): ElementNode;
142
142
  export type DOMNodeToLexicalConversion = (element: Node) => LexicalNode;
143
143
  export type DOMNodeToLexicalConversionMap = Record<string, DOMNodeToLexicalConversion>;
144
- /**
145
- * Starts with a node and moves up the tree (toward the root node) to find a matching node based on
146
- * the search parameters of the findFn. (Consider JavaScripts' .find() function where a testing function must be
147
- * passed as an argument. eg. if( (node) => node.__type === 'div') ) return true; otherwise return false
148
- * @param startingNode - The node where the search starts.
149
- * @param findFn - A testing function that returns true if the current node satisfies the testing parameters.
150
- * @returns A parent node that matches the findFn parameters, or null if one wasn't found.
151
- */
152
- export declare const $findMatchingParent: {
153
- <T extends LexicalNode>(startingNode: LexicalNode, findFn: (node: LexicalNode) => node is T): T | null;
154
- (startingNode: LexicalNode, findFn: (node: LexicalNode) => boolean): LexicalNode | null;
155
- };
156
144
  /**
157
145
  * Attempts to resolve nested element nodes of the same type into a single node of that type.
158
146
  * It is generally used for marks/commenting
package/package.json CHANGED
@@ -8,14 +8,14 @@
8
8
  "utils"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.35.1-nightly.20250915.0",
11
+ "version": "0.35.1-nightly.20250917.0",
12
12
  "main": "LexicalUtils.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/list": "0.35.1-nightly.20250915.0",
16
- "@lexical/selection": "0.35.1-nightly.20250915.0",
17
- "@lexical/table": "0.35.1-nightly.20250915.0",
18
- "lexical": "0.35.1-nightly.20250915.0"
15
+ "@lexical/list": "0.35.1-nightly.20250917.0",
16
+ "@lexical/selection": "0.35.1-nightly.20250917.0",
17
+ "@lexical/table": "0.35.1-nightly.20250917.0",
18
+ "lexical": "0.35.1-nightly.20250917.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",