@lexical/utils 0.26.0 → 0.26.1-nightly.20250303.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.
@@ -11,6 +11,20 @@
11
11
  var lexical = require('lexical');
12
12
  var selection = require('@lexical/selection');
13
13
 
14
+ /**
15
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ *
20
+ */
21
+
22
+ // Do not require this module directly! Use normal `invariant` calls.
23
+
24
+ function formatDevErrorMessage(message) {
25
+ throw new Error(message);
26
+ }
27
+
14
28
  /**
15
29
  * Copyright (c) Meta Platforms, Inc. and affiliates.
16
30
  *
@@ -120,14 +134,6 @@ function px(value) {
120
134
  return `${value}px`;
121
135
  }
122
136
 
123
- /**
124
- * Copyright (c) Meta Platforms, Inc. and affiliates.
125
- *
126
- * This source code is licensed under the MIT license found in the
127
- * LICENSE file in the root directory of this source tree.
128
- *
129
- */
130
-
131
137
  const mutationObserverConfig = {
132
138
  attributes: true,
133
139
  characterData: true,
@@ -159,10 +165,10 @@ function mlcPositionNodeOnRange(editor, range, onReposition) {
159
165
  wrapperNode.style.position = 'relative';
160
166
  function position() {
161
167
  if (!(rootDOMNode !== null)) {
162
- throw Error(`Unexpected null rootDOMNode`);
168
+ formatDevErrorMessage(`Unexpected null rootDOMNode`);
163
169
  }
164
170
  if (!(parentDOMNode !== null)) {
165
- throw Error(`Unexpected null parentDOMNode`);
171
+ formatDevErrorMessage(`Unexpected null parentDOMNode`);
166
172
  }
167
173
  const {
168
174
  left: parentLeft,
@@ -415,14 +421,6 @@ function selectionAlwaysOnDisplay(editor) {
415
421
  };
416
422
  }
417
423
 
418
- /**
419
- * Copyright (c) Meta Platforms, Inc. and affiliates.
420
- *
421
- * This source code is licensed under the MIT license found in the
422
- * LICENSE file in the root directory of this source tree.
423
- *
424
- */
425
-
426
424
  // Hotfix to export these with inlined types #5918
427
425
  const CAN_USE_BEFORE_INPUT = CAN_USE_BEFORE_INPUT$1;
428
426
  const CAN_USE_DOM = CAN_USE_DOM$1;
@@ -672,7 +670,7 @@ function $getNearestBlockElementAncestorOrThrow(startNode) {
672
670
  const blockNode = $findMatchingParent(startNode, node => lexical.$isElementNode(node) && !node.isInline());
673
671
  if (!lexical.$isElementNode(blockNode)) {
674
672
  {
675
- throw Error(`Expected node ${startNode.__key} to have closest block element node.`);
673
+ formatDevErrorMessage(`Expected node ${startNode.__key} to have closest block element node.`);
676
674
  }
677
675
  }
678
676
  return blockNode;
@@ -1025,7 +1023,7 @@ function $childIterator(startCaret) {
1025
1023
  if (seen !== null) {
1026
1024
  const key = origin.getKey();
1027
1025
  if (!!seen.has(key)) {
1028
- throw Error(`$childIterator: Cycle detected, node with key ${String(key)} has already been traversed`);
1026
+ formatDevErrorMessage(`$childIterator: Cycle detected, node with key ${String(key)} has already been traversed`);
1029
1027
  }
1030
1028
  seen.add(key);
1031
1029
  }
@@ -10,6 +10,20 @@ import { isHTMLElement, $getSelection, $isRangeSelection, $isElementNode, getDOM
10
10
  export { $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode } from 'lexical';
11
11
  import { createRectsFromDOMRange } from '@lexical/selection';
12
12
 
13
+ /**
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ *
19
+ */
20
+
21
+ // Do not require this module directly! Use normal `invariant` calls.
22
+
23
+ function formatDevErrorMessage(message) {
24
+ throw new Error(message);
25
+ }
26
+
13
27
  /**
14
28
  * Copyright (c) Meta Platforms, Inc. and affiliates.
15
29
  *
@@ -119,14 +133,6 @@ function px(value) {
119
133
  return `${value}px`;
120
134
  }
121
135
 
122
- /**
123
- * Copyright (c) Meta Platforms, Inc. and affiliates.
124
- *
125
- * This source code is licensed under the MIT license found in the
126
- * LICENSE file in the root directory of this source tree.
127
- *
128
- */
129
-
130
136
  const mutationObserverConfig = {
131
137
  attributes: true,
132
138
  characterData: true,
@@ -158,10 +164,10 @@ function mlcPositionNodeOnRange(editor, range, onReposition) {
158
164
  wrapperNode.style.position = 'relative';
159
165
  function position() {
160
166
  if (!(rootDOMNode !== null)) {
161
- throw Error(`Unexpected null rootDOMNode`);
167
+ formatDevErrorMessage(`Unexpected null rootDOMNode`);
162
168
  }
163
169
  if (!(parentDOMNode !== null)) {
164
- throw Error(`Unexpected null parentDOMNode`);
170
+ formatDevErrorMessage(`Unexpected null parentDOMNode`);
165
171
  }
166
172
  const {
167
173
  left: parentLeft,
@@ -414,14 +420,6 @@ function selectionAlwaysOnDisplay(editor) {
414
420
  };
415
421
  }
416
422
 
417
- /**
418
- * Copyright (c) Meta Platforms, Inc. and affiliates.
419
- *
420
- * This source code is licensed under the MIT license found in the
421
- * LICENSE file in the root directory of this source tree.
422
- *
423
- */
424
-
425
423
  // Hotfix to export these with inlined types #5918
426
424
  const CAN_USE_BEFORE_INPUT = CAN_USE_BEFORE_INPUT$1;
427
425
  const CAN_USE_DOM = CAN_USE_DOM$1;
@@ -671,7 +669,7 @@ function $getNearestBlockElementAncestorOrThrow(startNode) {
671
669
  const blockNode = $findMatchingParent(startNode, node => $isElementNode(node) && !node.isInline());
672
670
  if (!$isElementNode(blockNode)) {
673
671
  {
674
- throw Error(`Expected node ${startNode.__key} to have closest block element node.`);
672
+ formatDevErrorMessage(`Expected node ${startNode.__key} to have closest block element node.`);
675
673
  }
676
674
  }
677
675
  return blockNode;
@@ -1024,7 +1022,7 @@ function $childIterator(startCaret) {
1024
1022
  if (seen !== null) {
1025
1023
  const key = origin.getKey();
1026
1024
  if (!!seen.has(key)) {
1027
- throw Error(`$childIterator: Cycle detected, node with key ${String(key)} has already been traversed`);
1025
+ formatDevErrorMessage(`$childIterator: Cycle detected, node with key ${String(key)} has already been traversed`);
1028
1026
  }
1029
1027
  seen.add(key);
1030
1028
  }
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("lexical"),t=require("@lexical/selection");function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o=n((function(e){const t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(let e=1;e<arguments.length;e++)n.append("v",arguments[e]);throw t.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${t.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,i=r&&"documentMode"in document?document.documentMode:null,s=r&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),l=r&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),a=!(!r||!("InputEvent"in window)||i)&&"getTargetRanges"in new window.InputEvent("input"),u=r&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,d=r&&/Android/.test(navigator.userAgent),f=r&&/^(?=.*Chrome).*/i.test(navigator.userAgent),g=r&&d&&f,p=r&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!f;function m(...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 h(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function x(e){return`${e}px`}const $={attributes:!0,characterData:!0,childList:!0,subtree:!0};function S(n,r,i){let s=null,l=null,a=null,u=[];const c=document.createElement("div");function d(){null===s&&o(182),null===l&&o(183);const{left:e,top:a}=l.getBoundingClientRect(),d=t.createRectsFromDOMRange(n,r);var f,g;c.isConnected||(g=c,(f=l).insertBefore(g,f.firstChild));let p=!1;for(let t=0;t<d.length;t++){const n=d[t],o=u[t]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",p=!0);const i=x(n.left-e);r.left!==i&&(r.left=i,p=!0);const s=x(n.top-a);r.top!==s&&(o.style.top=s,p=!0);const l=x(n.width);r.width!==l&&(o.style.width=l,p=!0);const f=x(n.height);r.height!==f&&(o.style.height=f,p=!0),o.parentNode!==c&&(c.append(o),p=!0),u[t]=o}for(;u.length>d.length;)u.pop();p&&i(u)}function f(){l=null,s=null,null!==a&&a.disconnect(),a=null,c.remove();for(const e of u)e.remove();u=[]}c.style.position="relative";const g=n.registerRootListener((function t(){const o=n.getRootElement();if(null===o)return f();const r=o.parentElement;if(!e.isHTMLElement(r))return f();f(),s=o,l=r,a=new MutationObserver((e=>{const o=n.getRootElement(),r=o&&o.parentElement;if(o!==s||r!==l)return t();for(const t of e)if(!c.contains(t.target))return d()})),a.observe(r,$),d()}));return()=>{g(),f()}}function C(t,n,o){if("text"!==t.type&&e.$isElementNode(n)){const e=n.getDOMSlot(o);return[e.element,e.getFirstChildOffset()+t.offset]}return[e.getDOMTextNode(o)||o,t.offset]}function E(t,n){let o=null,r=null,i=null,s=null,l=null,a=null,u=()=>{};function c(c){c.read((()=>{const c=e.$getSelection();if(!e.$isRangeSelection(c))return o=null,i=null,s=null,a=null,u(),void(u=()=>{});const{anchor:d,focus:f}=c,g=d.getNode(),p=g.getKey(),m=d.offset,h=f.getNode(),$=h.getKey(),E=f.offset,v=t.getElementByKey(p),N=t.getElementByKey($),w=null===o||v!==r||m!==i||p!==o.getKey(),y=null===s||N!==l||E!==a||$!==s.getKey();if((w||y)&&null!==v&&null!==N){const e=function(e,t,n,o,r,i,s){const l=(e._window?e._window.document:document).createRange();return i.isBefore(n)?(l.setStart(...C(r,i,s)),l.setEnd(...C(t,n,o))):(l.setStart(...C(t,n,o)),l.setEnd(...C(r,i,s))),l}(t,d,g,v,f,h,N);u(),u=S(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!==x(-1.5)&&(e.marginTop=x(-1.5)),e.paddingTop!==x(4)&&(e.paddingTop=x(4)),e.paddingBottom!==x(0)&&(e.paddingBottom=x(0))}else n(e)}))}o=g,r=v,i=m,s=h,l=N,a=E}))}return c(t.getEditorState()),h(t.registerUpdateListener((({editorState:e})=>c(e))),(()=>{u()}))}const v=a,N=r,w=d,y=g,A=s,R=p,P=f,I=l,T=c,b=u;function O(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function _(e,t){return M("next",e,t)}function M(t,n,o){const r=e.$getRoot(),i=n||r,s=e.$isElementNode(i)?e.$getChildCaret(i,t):e.$getSiblingCaret(i,t),l=L(i),a=e.$getAdjacentChildCaret(o?e.$getChildCaretOrSelf(e.$getSiblingCaret(o,t)):s.getParentCaret("root"));let u=l;return e.makeStepwiseIterator({hasNext:e=>null!==e,initial:s,map:e=>({depth:u,node:e.origin}),step:t=>{if(t.isSameNodeCaret(a))return null;e.$isChildCaret(t)&&u++;const n=K(t);return!n||n[0].isSameNodeCaret(a)?null:(u+=n[1],n[0])}})}function L(e){let t=-1;for(let n=e;null!==n;n=n.getParent())t++;return t}function D(e,t){return M("previous",e,t)}const B=(t,n)=>{let o=t;for(;o!==e.$getRoot()&&null!=o;){if(n(o))return o;o=o.getParent()}return null};let k=!(I||!N)&&void 0;function F(t,n,o){let r=!1;for(const i of j(t))n(i)?null!==o&&o(i):(r=!0,e.$isElementNode(i)&&F(i,n,o||(e=>i.insertAfter(e))),i.remove());return r}function j(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()})}function K(t,n="root"){let o=0,r=t,i=e.$getAdjacentChildCaret(r);for(;null===i;){if(o--,i=r.getParentCaret(n),!i)return null;r=i,i=e.$getAdjacentChildCaret(r)}return i&&[i,o]}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 o=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(n(t))o.push(t);else if(e.$isElementNode(t))for(const e of j(t))r.push(e);return o},exports.$dfs=function(e,t){return Array.from(_(e,t))},exports.$dfsIterator=_,exports.$filter=function(e,t){const n=[];for(let o=0;o<e.length;o++){const r=t(e[o]);null!==r&&n.push(r)}return n},exports.$findMatchingParent=B,exports.$firstToLastIterator=function(t){return H(e.$getChildCaret(t,"next"))},exports.$getAdjacentCaret=function(e){return e?e.getAdjacentCaret():null},exports.$getAdjacentSiblingOrParentSiblingCaret=K,exports.$getDepth=L,exports.$getNearestBlockElementAncestorOrThrow=function(t){const n=B(t,(t=>e.$isElementNode(t)&&!t.isInline()));return e.$isElementNode(n)||o(4,t.__key),n},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=K(e.$getChildCaretOrSelf(e.$getSiblingCaret(t,"previous")),"root");return n&&n[0].origin},exports.$getNextSiblingOrParentSibling=function(t){const n=K(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();if(e.$isRangeSelection(n)){const{focus:o}=n,r=o.getNode(),i=o.offset;if(e.$isRootOrShadowRoot(r))e.$getChildCaretAtIndex(r,i,"next").insert(t),t.selectNext();else{let n,o;e.$isTextNode(r)?(n=r.getParentOrThrow(),o=r.getIndexWithinParent(),i>0&&(o+=1,r.splitText(i))):(n=r,o=i);const[,s]=e.$splitNode(n,o);s.insertBefore(t),s.selectStart()}}else{if(null!=n){const e=n.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(t)}else e.$getRoot().append(t);const o=e.$createParagraphNode();t.insertAfter(o),o.select()}return t.getLatest()},exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=j,exports.$restoreEditorState=function(t,n){const o=new Map,r=t._pendingEditorState;for(const[t,r]of n._nodeMap)o.set(t,e.$cloneWithProperties(r));r&&(r._nodeMap=o),t._dirtyType=2;const i=n._selection;e.$setSelection(null===i?null:i.clone())},exports.$reverseDfs=function(e,t){return Array.from(D(e,t))},exports.$reverseDfsIterator=D,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=v,exports.CAN_USE_DOM=N,exports.IS_ANDROID=w,exports.IS_ANDROID_CHROME=y,exports.IS_APPLE=A,exports.IS_APPLE_WEBKIT=R,exports.IS_CHROME=P,exports.IS_FIREFOX=I,exports.IS_IOS=T,exports.IS_SAFARI=b,exports.addClassNamesToElement=function(e,...t){const n=m(...t);n.length>0&&e.classList.add(...n)},exports.calculateZoomLevel=function(e){let t=1;if(function(){if(void 0===k){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"),k=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return k}())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),o=(n,o)=>e.$setState(n,t,o);return{$get:n,$set:o,accessors:[n,o],makeGetterMethod:()=>function(){return n(this)},makeSetterMethod:()=>function(e){return o(this,e)},stateConfig:t}},exports.markSelection=E,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise(((e,o)=>{const r=[],i=()=>{const{done:s,value:l}=n.next();if(s)return e(r);const a=new FileReader;a.addEventListener("error",o),a.addEventListener("load",(()=>{const e=a.result;"string"==typeof e&&r.push({file:l,result:e}),i()})),O(l,t)?a.readAsDataURL(l):i()};i()}))},exports.mergeRegister=h,exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=S,exports.registerNestedElementResolver=function(e,t,n,o){const r=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(r(n))return null}let n=e,o=e;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return{child:o,parent:n};return null})(e);if(null!==t){const{child:r,parent:i}=t;if(r.is(e)){o(i,e);const t=r.getNextSiblings(),s=t.length;if(i.insertAfter(r),0!==s){const e=n(i);r.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=m(...t);n.length>0&&e.classList.remove(...n)},exports.selectionAlwaysOnDisplay=function(e){let t=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=e.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==t&&(t(),t=null):null===t&&(t=E(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"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.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 o="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=o&&"documentMode"in document?document.documentMode:null,i=o&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=o&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),l=!(!o||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),a=o&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=o&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,u=o&&/Android/.test(navigator.userAgent),d=o&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=o&&u&&d,g=o&&/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 x={attributes:!0,characterData:!0,childList:!0,subtree:!0};function $(o,r,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(o,r);var f,g;u.isConnected||(g=u,(f=l).insertBefore(g,f.firstChild));let p=!1;for(let t=0;t<d.length;t++){const n=d[t],o=c[t]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",p=!0);const i=h(n.left-e);r.left!==i&&(r.left=i,p=!0);const s=h(n.top-a);r.top!==s&&(o.style.top=s,p=!0);const l=h(n.width);r.width!==l&&(o.style.width=l,p=!0);const f=h(n.height);r.height!==f&&(o.style.height=f,p=!0),o.parentNode!==u&&(u.append(o),p=!0),c[t]=o}for(;c.length>d.length;)c.pop();p&&i(c)}function f(){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 g=o.registerRootListener((function t(){const n=o.getRootElement();if(null===n)return f();const r=n.parentElement;if(!e.isHTMLElement(r))return f();f(),s=n,l=r,a=new MutationObserver((e=>{const n=o.getRootElement(),r=n&&n.parentElement;if(n!==s||r!==l)return t();for(const t of e)if(!u.contains(t.target))return d()})),a.observe(r,x),d()}));return()=>{g(),f()}}function S(t,n,o){if("text"!==t.type&&e.$isElementNode(n)){const e=n.getDOMSlot(o);return[e.element,e.getFirstChildOffset()+t.offset]}return[e.getDOMTextNode(o)||o,t.offset]}function C(t,n){let o=null,r=null,i=null,s=null,l=null,a=null,c=()=>{};function u(u){u.read((()=>{const u=e.$getSelection();if(!e.$isRangeSelection(u))return o=null,i=null,s=null,a=null,c(),void(c=()=>{});const{anchor:d,focus:f}=u,g=d.getNode(),p=g.getKey(),m=d.offset,x=f.getNode(),C=x.getKey(),E=f.offset,v=t.getElementByKey(p),N=t.getElementByKey(C),w=null===o||v!==r||m!==i||p!==o.getKey(),y=null===s||N!==l||E!==a||C!==s.getKey();if((w||y)&&null!==v&&null!==N){const e=function(e,t,n,o,r,i,s){const l=(e._window?e._window.document:document).createRange();return i.isBefore(n)?(l.setStart(...S(r,i,s)),l.setEnd(...S(t,n,o))):(l.setStart(...S(t,n,o)),l.setEnd(...S(r,i,s))),l}(t,d,g,v,f,x,N);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!==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)}))}o=g,r=v,i=m,s=x,l=N,a=E}))}return u(t.getEditorState()),m(t.registerUpdateListener((({editorState:e})=>u(e))),(()=>{c()}))}const E=l,v=o,N=u,w=f,y=i,A=g,R=d,P=s,I=c,T=a;function b(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function O(e,t){return L("next",e,t)}function L(t,n,o){const r=e.$getRoot(),i=n||r,s=e.$isElementNode(i)?e.$getChildCaret(i,t):e.$getSiblingCaret(i,t),l=M(i),a=e.$getAdjacentChildCaret(o?e.$getChildCaretOrSelf(e.$getSiblingCaret(o,t)):s.getParentCaret("root"));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=j(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 o=t;for(;o!==e.$getRoot()&&null!=o;){if(n(o))return o;o=o.getParent()}return null};let B=!(P||!v)&&void 0;function k(t,n,o){let r=!1;for(const i of F(t))n(i)?null!==o&&o(i):(r=!0,e.$isElementNode(i)&&k(i,n,o||(e=>i.insertAfter(e))),i.remove());return r}function F(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()})}function j(t,n="root"){let o=0,r=t,i=e.$getAdjacentChildCaret(r);for(;null===i;){if(o--,i=r.getParentCaret(n),!i)return null;r=i,i=e.$getAdjacentChildCaret(r)}return i&&[i,o]}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 o=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(n(t))o.push(t);else if(e.$isElementNode(t))for(const e of F(t))r.push(e);return o},exports.$dfs=function(e,t){return Array.from(O(e,t))},exports.$dfsIterator=O,exports.$filter=function(e,t){const n=[];for(let o=0;o<e.length;o++){const r=t(e[o]);null!==r&&n.push(r)}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.$getAdjacentSiblingOrParentSiblingCaret=j,exports.$getDepth=M,exports.$getNearestBlockElementAncestorOrThrow=function(t){const o=D(t,(t=>e.$isElementNode(t)&&!t.isInline()));return e.$isElementNode(o)||n(4,t.__key),o},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=j(e.$getChildCaretOrSelf(e.$getSiblingCaret(t,"previous")),"root");return n&&n[0].origin},exports.$getNextSiblingOrParentSibling=function(t){const n=j(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();if(e.$isRangeSelection(n)){const{focus:o}=n,r=o.getNode(),i=o.offset;if(e.$isRootOrShadowRoot(r))e.$getChildCaretAtIndex(r,i,"next").insert(t),t.selectNext();else{let n,o;e.$isTextNode(r)?(n=r.getParentOrThrow(),o=r.getIndexWithinParent(),i>0&&(o+=1,r.splitText(i))):(n=r,o=i);const[,s]=e.$splitNode(n,o);s.insertBefore(t),s.selectStart()}}else{if(null!=n){const e=n.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(t)}else e.$getRoot().append(t);const o=e.$createParagraphNode();t.insertAfter(o),o.select()}return t.getLatest()},exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=F,exports.$restoreEditorState=function(t,n){const o=new Map,r=t._pendingEditorState;for(const[t,r]of n._nodeMap)o.set(t,e.$cloneWithProperties(r));r&&(r._nodeMap=o),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 k(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=w,exports.IS_APPLE=y,exports.IS_APPLE_WEBKIT=A,exports.IS_CHROME=R,exports.IS_FIREFOX=P,exports.IS_IOS=I,exports.IS_SAFARI=T,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=b,exports.makeStateWrapper=function(t){const n=n=>e.$getState(n,t),o=(n,o)=>e.$setState(n,t,o);return{$get:n,$set:o,accessors:[n,o],makeGetterMethod:()=>function(){return n(this)},makeSetterMethod:()=>function(e){return o(this,e)},stateConfig:t}},exports.markSelection=C,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise(((e,o)=>{const r=[],i=()=>{const{done:s,value:l}=n.next();if(s)return e(r);const a=new FileReader;a.addEventListener("error",o),a.addEventListener("load",(()=>{const e=a.result;"string"==typeof e&&r.push({file:l,result:e}),i()})),b(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=$,exports.registerNestedElementResolver=function(e,t,n,o){const r=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(r(n))return null}let n=e,o=e;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return{child:o,parent:n};return null})(e);if(null!==t){const{child:r,parent:i}=t;if(r.is(e)){o(i,e);const t=r.getNextSiblings(),s=t.length;if(i.insertAfter(r),0!==s){const e=n(i);r.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(),o=n&&n.anchorNode,r=e.getRootElement();null!==o&&null!==r&&r.contains(o)?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 s,$getAdjacentChildCaret as u,$getChildCaretOrSelf as c,makeStepwiseIterator as f,$isChildCaret as a,$cloneWithProperties as d,$setSelection as g,$getPreviousSelection as p,$isRootOrShadowRoot as m,$getChildCaretAtIndex as h,$isTextNode as v,$splitNode as y,$createParagraphNode as w,$isSiblingCaret as x,$rewindSiblingCaret as E,$getState as S,$setState as A}from"lexical";export{$splitNode,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode}from"lexical";import{createRectsFromDOMRange as C}from"@lexical/selection";function P(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var L=P((function(t){const e=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",t);for(let t=1;t<arguments.length;t++)n.append("v",arguments[t]);throw e.search=n.toString(),Error(`Minified Lexical error #${t}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const N="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,b=N&&"documentMode"in document?document.documentMode:null,T=N&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),M=N&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),R=!(!N||!("InputEvent"in window)||b)&&"getTargetRanges"in new window.InputEvent("input"),B=N&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),_=N&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,O=N&&/Android/.test(navigator.userAgent),k=N&&/^(?=.*Chrome).*/i.test(navigator.userAgent),K=N&&O&&k,H=N&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!k;function $(...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 j(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function D(t){return`${t}px`}const I={attributes:!0,characterData:!0,childList:!0,subtree:!0};function U(e,n,o){let r=null,i=null,l=null,s=[];const u=document.createElement("div");function c(){null===r&&L(182),null===i&&L(183);const{left:t,top:l}=i.getBoundingClientRect(),c=C(e,n);var f,a;u.isConnected||(a=u,(f=i).insertBefore(a,f.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=D(n.left-t);r.left!==i&&(r.left=i,d=!0);const f=D(n.top-l);r.top!==f&&(o.style.top=f,d=!0);const a=D(n.width);r.width!==a&&(o.style.width=a,d=!0);const g=D(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 f(){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 a=e.registerRootListener((function n(){const o=e.getRootElement();if(null===o)return f();const s=o.parentElement;if(!t(s))return f();f(),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,I),c()}));return()=>{a(),f()}}function z(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 F(t,o){let r=null,i=null,l=null,s=null,u=null,c=null,f=()=>{};function a(a){a.read((()=>{const a=e();if(!n(a))return r=null,l=null,s=null,c=null,f(),void(f=()=>{});const{anchor:d,focus:g}=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===s||E!==u||w!==c||y!==s.getKey();if((S||A)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const s=(t._window?t._window.document:document).createRange();return i.isBefore(n)?(s.setStart(...z(r,i,l)),s.setEnd(...z(e,n,o))):(s.setStart(...z(e,n,o)),s.setEnd(...z(r,i,l))),s}(t,d,p,x,g,v,E);f(),f=U(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!==D(-1.5)&&(t.marginTop=D(-1.5)),t.paddingTop!==D(4)&&(t.paddingTop=D(4)),t.paddingBottom!==D(0)&&(t.paddingBottom=D(0))}else o(t)}))}r=p,i=x,l=h,s=v,u=E,c=w}))}return a(t.getEditorState()),j(t.registerUpdateListener((({editorState:t})=>a(t))),(()=>{f()}))}function W(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=F(t))};return document.addEventListener("selectionchange",n),()=>{null!==e&&e(),document.removeEventListener("selectionchange",n)}}const V=R,G=N,q=O,J=K,Q=T,X=H,Y=k,Z=M,tt=_,et=B;function nt(t,...e){const n=$(...e);n.length>0&&t.classList.add(...n)}function ot(t,...e){const n=$(...e);n.length>0&&t.classList.remove(...n)}function rt(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function it(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()})),rt(s,e)?u.readAsDataURL(s):i()};i()}))}function lt(t,e){return Array.from(ct(t,e))}function st(t){return t?t.getAdjacentCaret():null}function ut(t,e){return Array.from(pt(t,e))}function ct(t,e){return ft("next",t,e)}function ft(t,e,n){const r=i(),d=e||r,g=o(d)?l(d,t):s(d,t),p=dt(d),m=u(n?c(s(n,t)):g.getParentCaret("root"));let h=p;return f({hasNext:t=>null!==t,initial:g,map:t=>({depth:h,node:t.origin}),step:t=>{if(t.isSameNodeCaret(m))return null;a(t)&&h++;const e=kt(t);return!e||e[0].isSameNodeCaret(m)?null:(h+=e[1],e[0])}})}function at(t){const e=kt(s(t,"next"));return e&&[e[0].origin,e[1]]}function dt(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function gt(t){const e=kt(c(s(t,"previous")),"root");return e&&e[0].origin}function pt(t,e){return ft("previous",t,e)}function mt(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function ht(t){const e=vt(t,(t=>o(t)&&!t.isInline()));return o(e)||L(4,t.__key),e}const vt=(t,e)=>{let n=t;for(;n!==i()&&null!=n;){if(e(n))return n;n=n.getParent()}return null};function yt(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 wt(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,d(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;g(null===r?null:r.clone())}function xt(t){const o=e()||p();if(n(o)){const{focus:e}=o,n=e.getNode(),r=e.offset;if(m(n))h(n,r,"next").insert(t),t.selectNext();else{let e,o;v(n)?(e=n.getParentOrThrow(),o=n.getIndexWithinParent(),r>0&&(o+=1,n.splitText(r))):(e=n,o=r);const[,i]=y(e,o);i.insertBefore(t),i.selectStart()}}else{if(null!=o){const e=o.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(t)}else i().append(t);const e=w();t.insertAfter(e),e.select()}return t.getLatest()}function Et(t,e){const n=e();return t.replace(n),n.append(t),n}function St(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function At(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 Ct(t,e){l(t,"next").insert(e)}let Pt=!(Z||!G)&&void 0;function Lt(t){let e=1;if(function(){if(void 0===Pt){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"),Pt=t.getBoundingClientRect().width===e.width,document.body.removeChild(t)}return Pt}())for(;t;)e*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return e}function Nt(t){return null!==t._parentEditor}function bt(t,e){return Tt(t,e,null)}function Tt(t,e,n){let r=!1;for(const i of Bt(t))e(i)?null!==n&&n(i):(r=!0,o(i)&&Tt(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function Mt(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 Bt(t))r.push(e);return n}function Rt(t){return _t(l(t,"next"))}function Bt(t){return _t(l(t,"previous"))}function _t(t){return f({hasNext:x,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function Ot(t){E(s(t,"next")).splice(1,t.getChildren())}function kt(t,e="root"){let n=0,o=t,r=u(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=u(o)}return r&&[r,n]}function Kt(t){const e=e=>S(e,t),n=(e,n)=>A(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{Mt as $descendantsMatching,lt as $dfs,ct as $dfsIterator,At as $filter,vt as $findMatchingParent,Rt as $firstToLastIterator,st as $getAdjacentCaret,kt as $getAdjacentSiblingOrParentSiblingCaret,dt as $getDepth,ht as $getNearestBlockElementAncestorOrThrow,mt as $getNearestNodeOfType,gt as $getNextRightPreorderNode,at as $getNextSiblingOrParentSibling,Ct as $insertFirst,xt as $insertNodeToNearestRoot,Nt as $isEditorIsNestedEditor,Bt as $lastToFirstIterator,wt as $restoreEditorState,ut as $reverseDfs,pt as $reverseDfsIterator,bt as $unwrapAndFilterDescendants,Ot as $unwrapNode,Et as $wrapNodeInElement,V as CAN_USE_BEFORE_INPUT,G as CAN_USE_DOM,q as IS_ANDROID,J as IS_ANDROID_CHROME,Q as IS_APPLE,X as IS_APPLE_WEBKIT,Y as IS_CHROME,Z as IS_FIREFOX,tt as IS_IOS,et as IS_SAFARI,nt as addClassNamesToElement,Lt as calculateZoomLevel,rt as isMimeType,Kt as makeStateWrapper,F as markSelection,it as mediaFileReader,j as mergeRegister,St as objectKlassEquals,U as positionNodeOnRange,yt as registerNestedElementResolver,ot as removeClassNamesFromElement,W 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 s,$getAdjacentChildCaret as u,$getChildCaretOrSelf as c,makeStepwiseIterator as f,$isChildCaret as a,$cloneWithProperties as d,$setSelection as g,$getPreviousSelection as p,$isRootOrShadowRoot as m,$getChildCaretAtIndex as h,$isTextNode as v,$splitNode as y,$createParagraphNode as w,$isSiblingCaret as x,$rewindSiblingCaret as E,$getState as S,$setState as A}from"lexical";export{$splitNode,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode}from"lexical";import{createRectsFromDOMRange as C}from"@lexical/selection";function P(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 L="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,N=L&&"documentMode"in document?document.documentMode:null,b=L&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),T=L&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),M=!(!L||!("InputEvent"in window)||N)&&"getTargetRanges"in new window.InputEvent("input"),R=L&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),B=L&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,_=L&&/Android/.test(navigator.userAgent),O=L&&/^(?=.*Chrome).*/i.test(navigator.userAgent),k=L&&_&&O,K=L&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!O;function H(...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 $(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function D(t){return`${t}px`}const I={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&&P(182),null===i&&P(183);const{left:t,top:l}=i.getBoundingClientRect(),c=C(e,n);var f,a;u.isConnected||(a=u,(f=i).insertBefore(a,f.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=D(n.left-t);r.left!==i&&(r.left=i,d=!0);const f=D(n.top-l);r.top!==f&&(o.style.top=f,d=!0);const a=D(n.width);r.width!==a&&(o.style.width=a,d=!0);const g=D(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 f(){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 a=e.registerRootListener((function n(){const o=e.getRootElement();if(null===o)return f();const s=o.parentElement;if(!t(s))return f();f(),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,I),c()}));return()=>{a(),f()}}function U(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 z(t,o){let r=null,i=null,l=null,s=null,u=null,c=null,f=()=>{};function a(a){a.read((()=>{const a=e();if(!n(a))return r=null,l=null,s=null,c=null,f(),void(f=()=>{});const{anchor:d,focus:g}=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===s||E!==u||w!==c||y!==s.getKey();if((S||A)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const s=(t._window?t._window.document:document).createRange();return i.isBefore(n)?(s.setStart(...U(r,i,l)),s.setEnd(...U(e,n,o))):(s.setStart(...U(e,n,o)),s.setEnd(...U(r,i,l))),s}(t,d,p,x,g,v,E);f(),f=j(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!==D(-1.5)&&(t.marginTop=D(-1.5)),t.paddingTop!==D(4)&&(t.paddingTop=D(4)),t.paddingBottom!==D(0)&&(t.paddingBottom=D(0))}else o(t)}))}r=p,i=x,l=h,s=v,u=E,c=w}))}return a(t.getEditorState()),$(t.registerUpdateListener((({editorState:t})=>a(t))),(()=>{f()}))}function F(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=z(t))};return document.addEventListener("selectionchange",n),()=>{null!==e&&e(),document.removeEventListener("selectionchange",n)}}const W=M,V=L,G=_,q=k,J=b,Q=K,X=O,Y=T,Z=B,tt=R;function et(t,...e){const n=H(...e);n.length>0&&t.classList.add(...n)}function nt(t,...e){const n=H(...e);n.length>0&&t.classList.remove(...n)}function ot(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function rt(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()})),ot(s,e)?u.readAsDataURL(s):i()};i()}))}function it(t,e){return Array.from(ut(t,e))}function lt(t){return t?t.getAdjacentCaret():null}function st(t,e){return Array.from(gt(t,e))}function ut(t,e){return ct("next",t,e)}function ct(t,e,n){const r=i(),d=e||r,g=o(d)?l(d,t):s(d,t),p=at(d),m=u(n?c(s(n,t)):g.getParentCaret("root"));let h=p;return f({hasNext:t=>null!==t,initial:g,map:t=>({depth:h,node:t.origin}),step:t=>{if(t.isSameNodeCaret(m))return null;a(t)&&h++;const e=Ot(t);return!e||e[0].isSameNodeCaret(m)?null:(h+=e[1],e[0])}})}function ft(t){const e=Ot(s(t,"next"));return e&&[e[0].origin,e[1]]}function at(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function dt(t){const e=Ot(c(s(t,"previous")),"root");return e&&e[0].origin}function gt(t,e){return ct("previous",t,e)}function pt(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function mt(t){const e=ht(t,(t=>o(t)&&!t.isInline()));return o(e)||P(4,t.__key),e}const ht=(t,e)=>{let n=t;for(;n!==i()&&null!=n;){if(e(n))return n;n=n.getParent()}return null};function vt(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 yt(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,d(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;g(null===r?null:r.clone())}function wt(t){const o=e()||p();if(n(o)){const{focus:e}=o,n=e.getNode(),r=e.offset;if(m(n))h(n,r,"next").insert(t),t.selectNext();else{let e,o;v(n)?(e=n.getParentOrThrow(),o=n.getIndexWithinParent(),r>0&&(o+=1,n.splitText(r))):(e=n,o=r);const[,i]=y(e,o);i.insertBefore(t),i.selectStart()}}else{if(null!=o){const e=o.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(t)}else i().append(t);const e=w();t.insertAfter(e),e.select()}return t.getLatest()}function xt(t,e){const n=e();return t.replace(n),n.append(t),n}function Et(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function St(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 At(t,e){l(t,"next").insert(e)}let Ct=!(Y||!V)&&void 0;function Pt(t){let e=1;if(function(){if(void 0===Ct){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"),Ct=t.getBoundingClientRect().width===e.width,document.body.removeChild(t)}return Ct}())for(;t;)e*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return e}function Lt(t){return null!==t._parentEditor}function Nt(t,e){return bt(t,e,null)}function bt(t,e,n){let r=!1;for(const i of Rt(t))e(i)?null!==n&&n(i):(r=!0,o(i)&&bt(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function Tt(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 Rt(t))r.push(e);return n}function Mt(t){return Bt(l(t,"next"))}function Rt(t){return Bt(l(t,"previous"))}function Bt(t){return f({hasNext:x,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function _t(t){E(s(t,"next")).splice(1,t.getChildren())}function Ot(t,e="root"){let n=0,o=t,r=u(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=u(o)}return r&&[r,n]}function kt(t){const e=e=>S(e,t),n=(e,n)=>A(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{Tt as $descendantsMatching,it as $dfs,ut as $dfsIterator,St as $filter,ht as $findMatchingParent,Mt as $firstToLastIterator,lt as $getAdjacentCaret,Ot as $getAdjacentSiblingOrParentSiblingCaret,at as $getDepth,mt as $getNearestBlockElementAncestorOrThrow,pt as $getNearestNodeOfType,dt as $getNextRightPreorderNode,ft as $getNextSiblingOrParentSibling,At as $insertFirst,wt as $insertNodeToNearestRoot,Lt as $isEditorIsNestedEditor,Rt as $lastToFirstIterator,yt as $restoreEditorState,st as $reverseDfs,gt as $reverseDfsIterator,Nt as $unwrapAndFilterDescendants,_t as $unwrapNode,xt as $wrapNodeInElement,W as CAN_USE_BEFORE_INPUT,V as CAN_USE_DOM,G as IS_ANDROID,q as IS_ANDROID_CHROME,J as IS_APPLE,Q as IS_APPLE_WEBKIT,X as IS_CHROME,Y as IS_FIREFOX,Z as IS_IOS,tt as IS_SAFARI,et as addClassNamesToElement,Pt as calculateZoomLevel,ot as isMimeType,kt as makeStateWrapper,z as markSelection,rt as mediaFileReader,$ as mergeRegister,Et as objectKlassEquals,j as positionNodeOnRange,vt as registerNestedElementResolver,nt as removeClassNamesFromElement,F as selectionAlwaysOnDisplay};
package/package.json CHANGED
@@ -8,14 +8,14 @@
8
8
  "utils"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.26.0",
11
+ "version": "0.26.1-nightly.20250303.0",
12
12
  "main": "LexicalUtils.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/list": "0.26.0",
16
- "@lexical/selection": "0.26.0",
17
- "@lexical/table": "0.26.0",
18
- "lexical": "0.26.0"
15
+ "@lexical/list": "0.26.1-nightly.20250303.0",
16
+ "@lexical/selection": "0.26.1-nightly.20250303.0",
17
+ "@lexical/table": "0.26.1-nightly.20250303.0",
18
+ "lexical": "0.26.1-nightly.20250303.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",