@lexical/utils 0.14.3 → 0.14.5

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.
@@ -27,11 +27,11 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
27
27
  *
28
28
  */
29
29
  const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
30
- CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
30
+ const IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
31
31
  const IS_FIREFOX = CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
32
- CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
33
- CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
34
- CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
32
+ const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
33
+ const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
34
+ const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
35
35
  const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
36
36
 
37
37
  // Keep these in case we need to use them in the future.
@@ -39,8 +39,8 @@ const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
39
39
  const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
40
40
  // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
41
41
 
42
- CAN_USE_DOM && IS_ANDROID && IS_CHROME;
43
- CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
42
+ const IS_ANDROID_CHROME = CAN_USE_DOM && IS_ANDROID && IS_CHROME;
43
+ const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
44
44
 
45
45
  /**
46
46
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -354,7 +354,13 @@ function markSelection(editor, onReposition) {
354
354
  });
355
355
  }
356
356
 
357
- /** @module @lexical/utils */
357
+ /**
358
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
359
+ *
360
+ * This source code is licensed under the MIT license found in the
361
+ * LICENSE file in the root directory of this source tree.
362
+ *
363
+ */
358
364
  /**
359
365
  * Takes an HTML element and adds the classNames passed within an array,
360
366
  * ignoring any non-string types. A space can be used to add multiple classes
@@ -790,6 +796,16 @@ exports.$insertFirst = $insertFirst;
790
796
  exports.$insertNodeToNearestRoot = $insertNodeToNearestRoot;
791
797
  exports.$restoreEditorState = $restoreEditorState;
792
798
  exports.$wrapNodeInElement = $wrapNodeInElement;
799
+ exports.CAN_USE_BEFORE_INPUT = CAN_USE_BEFORE_INPUT;
800
+ exports.CAN_USE_DOM = CAN_USE_DOM;
801
+ exports.IS_ANDROID = IS_ANDROID;
802
+ exports.IS_ANDROID_CHROME = IS_ANDROID_CHROME;
803
+ exports.IS_APPLE = IS_APPLE;
804
+ exports.IS_APPLE_WEBKIT = IS_APPLE_WEBKIT;
805
+ exports.IS_CHROME = IS_CHROME;
806
+ exports.IS_FIREFOX = IS_FIREFOX;
807
+ exports.IS_IOS = IS_IOS;
808
+ exports.IS_SAFARI = IS_SAFARI;
793
809
  exports.addClassNamesToElement = addClassNamesToElement;
794
810
  exports.calculateZoomLevel = calculateZoomLevel;
795
811
  exports.isMimeType = isMimeType;
@@ -26,11 +26,11 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
26
26
  *
27
27
  */
28
28
  const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
29
- CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
29
+ const IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
30
30
  const IS_FIREFOX = CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
31
- CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
32
- CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
33
- CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
31
+ const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
32
+ const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
33
+ const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
34
34
  const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
35
35
 
36
36
  // Keep these in case we need to use them in the future.
@@ -38,8 +38,8 @@ const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
38
38
  const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
39
39
  // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
40
40
 
41
- CAN_USE_DOM && IS_ANDROID && IS_CHROME;
42
- CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
41
+ const IS_ANDROID_CHROME = CAN_USE_DOM && IS_ANDROID && IS_CHROME;
42
+ const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
43
43
 
44
44
  /**
45
45
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -353,7 +353,13 @@ function markSelection(editor, onReposition) {
353
353
  });
354
354
  }
355
355
 
356
- /** @module @lexical/utils */
356
+ /**
357
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
358
+ *
359
+ * This source code is licensed under the MIT license found in the
360
+ * LICENSE file in the root directory of this source tree.
361
+ *
362
+ */
357
363
  /**
358
364
  * Takes an HTML element and adds the classNames passed within an array,
359
365
  * ignoring any non-string types. A space can be used to add multiple classes
@@ -777,4 +783,4 @@ function calculateZoomLevel(element) {
777
783
  return zoom;
778
784
  }
779
785
 
780
- export { $dfs, $filter, $findMatchingParent, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, $insertFirst, $insertNodeToNearestRoot, $restoreEditorState, $wrapNodeInElement, addClassNamesToElement, calculateZoomLevel, isMimeType, markSelection, mediaFileReader, mergeRegister, objectKlassEquals, positionNodeOnRange, registerNestedElementResolver, removeClassNamesFromElement };
786
+ export { $dfs, $filter, $findMatchingParent, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, $insertFirst, $insertNodeToNearestRoot, $restoreEditorState, $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, markSelection, mediaFileReader, mergeRegister, objectKlassEquals, positionNodeOnRange, registerNestedElementResolver, removeClassNamesFromElement };
package/LexicalUtils.mjs CHANGED
@@ -17,6 +17,16 @@ export const $insertNodeToNearestRoot = mod.$insertNodeToNearestRoot;
17
17
  export const $restoreEditorState = mod.$restoreEditorState;
18
18
  export const $splitNode = mod.$splitNode;
19
19
  export const $wrapNodeInElement = mod.$wrapNodeInElement;
20
+ export const CAN_USE_BEFORE_INPUT = mod.CAN_USE_BEFORE_INPUT;
21
+ export const CAN_USE_DOM = mod.CAN_USE_DOM;
22
+ export const IS_ANDROID = mod.IS_ANDROID;
23
+ export const IS_ANDROID_CHROME = mod.IS_ANDROID_CHROME;
24
+ export const IS_APPLE = mod.IS_APPLE;
25
+ export const IS_APPLE_WEBKIT = mod.IS_APPLE_WEBKIT;
26
+ export const IS_CHROME = mod.IS_CHROME;
27
+ export const IS_FIREFOX = mod.IS_FIREFOX;
28
+ export const IS_IOS = mod.IS_IOS;
29
+ export const IS_SAFARI = mod.IS_SAFARI;
20
30
  export const addClassNamesToElement = mod.addClassNamesToElement;
21
31
  export const calculateZoomLevel = mod.calculateZoomLevel;
22
32
  export const isHTMLAnchorElement = mod.isHTMLAnchorElement;
@@ -15,6 +15,16 @@ export const $insertNodeToNearestRoot = mod.$insertNodeToNearestRoot;
15
15
  export const $restoreEditorState = mod.$restoreEditorState;
16
16
  export const $splitNode = mod.$splitNode;
17
17
  export const $wrapNodeInElement = mod.$wrapNodeInElement;
18
+ export const CAN_USE_BEFORE_INPUT = mod.CAN_USE_BEFORE_INPUT;
19
+ export const CAN_USE_DOM = mod.CAN_USE_DOM;
20
+ export const IS_ANDROID = mod.IS_ANDROID;
21
+ export const IS_ANDROID_CHROME = mod.IS_ANDROID_CHROME;
22
+ export const IS_APPLE = mod.IS_APPLE;
23
+ export const IS_APPLE_WEBKIT = mod.IS_APPLE_WEBKIT;
24
+ export const IS_CHROME = mod.IS_CHROME;
25
+ export const IS_FIREFOX = mod.IS_FIREFOX;
26
+ export const IS_IOS = mod.IS_IOS;
27
+ export const IS_SAFARI = mod.IS_SAFARI;
18
28
  export const addClassNamesToElement = mod.addClassNamesToElement;
19
29
  export const calculateZoomLevel = mod.calculateZoomLevel;
20
30
  export const isHTMLAnchorElement = mod.isHTMLAnchorElement;
@@ -4,21 +4,22 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var h=require("@lexical/selection"),y=require("lexical");function C(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
8
- let D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,E=D&&"documentMode"in document?document.documentMode:null;D&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);let F=D&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);D&&"InputEvent"in window&&!E?"getTargetRanges"in new window.InputEvent("input"):!1;D&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent);D&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;
9
- let G=D&&/Android/.test(navigator.userAgent),H=D&&/^(?=.*Chrome).*/i.test(navigator.userAgent);D&&G&&H;D&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!H;function I(...a){let b=[];for(let c of a)if(c&&"string"===typeof c)for(let [e]of c.matchAll(/\S+/g))b.push(e);return b}function J(...a){return()=>{a.forEach(b=>b())}}let K={attributes:!0,characterData:!0,childList:!0,subtree:!0};
10
- function L(a,b,c){function e(){if(null===g)throw Error("Unexpected null rootDOMNode");if(null===n)throw Error("Unexpected null parentDOMNode");let {left:p,top:A}=g.getBoundingClientRect();var q=n;let r=h.createRectsFromDOMRange(a,b);t.isConnected||q.append(t);q=!1;for(let x=0;x<r.length;x++){var w=r[x];let u=k[x]||document.createElement("div"),z=u.style;"absolute"!==z.position&&(z.position="absolute",q=!0);var l=`${w.left-p}px`;z.left!==l&&(z.left=l,q=!0);l=`${w.top-A}px`;z.top!==l&&(u.style.top=
11
- l,q=!0);l=`${w.width}px`;z.width!==l&&(u.style.width=l,q=!0);w=`${w.height}px`;z.height!==w&&(u.style.height=w,q=!0);u.parentNode!==t&&(t.append(u),q=!0);k[x]=u}for(;k.length>r.length;)k.pop();q&&c(k)}function d(){g=n=null;null!==m&&m.disconnect();m=null;t.remove();for(let p of k)p.remove();k=[]}function f(){let p=a.getRootElement();if(null===p)return d();let A=p.parentElement;if(!(A instanceof HTMLElement))return d();d();g=p;n=A;m=new MutationObserver(q=>{let r=a.getRootElement(),w=r&&r.parentElement;
12
- if(r!==g||w!==n)return f();for(let l of q)if(!t.contains(l.target))return e()});m.observe(A,K);e()}let g=null,n=null,m=null,k=[],t=document.createElement("div"),B=a.registerRootListener(f);return()=>{B();d()}}function M(a,b){for(let c of b)if(a.type.startsWith(c))return!0;return!1}let N=(a,b)=>{for(;a!==y.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null};exports.$splitNode=y.$splitNode;exports.isHTMLAnchorElement=y.isHTMLAnchorElement;exports.isHTMLElement=y.isHTMLElement;
13
- exports.$dfs=function(a,b){let c=[];a=(a||y.$getRoot()).getLatest();b=b||(y.$isElementNode(a)?a.getLastDescendant():a);for(var e=a,d=0;null!==(e=e.getParent());)d++;for(e=d;null!==a&&!a.is(b);)if(c.push({depth:e,node:a}),y.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),e++;else for(d=null;null===d&&null!==a;)d=a.getNextSibling(),null===d?(a=a.getParent(),e--):a=d;null!==a&&a.is(b)&&c.push({depth:e,node:a});return c};
14
- exports.$filter=function(a,b){let c=[];for(let e=0;e<a.length;e++){let d=b(a[e]);null!==d&&c.push(d)}return c};exports.$findMatchingParent=N;exports.$getNearestBlockElementAncestorOrThrow=function(a){let b=N(a,c=>y.$isElementNode(c)&&!c.isInline());y.$isElementNode(b)||C(4,a.__key);return b};exports.$getNearestNodeOfType=function(a,b){for(;null!=a;){if(a instanceof b)return a;a=a.getParent()}return null};exports.$insertFirst=function(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)};
15
- exports.$insertNodeToNearestRoot=function(a){var b=y.$getSelection()||y.$getPreviousSelection();if(y.$isRangeSelection(b)){var {focus:c}=b;b=c.getNode();c=c.offset;if(y.$isRootOrShadowRoot(b))c=b.getChildAtIndex(c),null==c?b.append(a):c.insertBefore(a),a.selectNext();else{let e,d;y.$isTextNode(b)?(e=b.getParentOrThrow(),d=b.getIndexWithinParent(),0<c&&(d+=1,b.splitText(c))):(e=b,d=c);[,b]=y.$splitNode(e,d);b.insertBefore(a);b.selectStart()}}else null!=b?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
16
- y.$getRoot().append(a),b=y.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$restoreEditorState=function(a,b){let c=new Map,e=a._pendingEditorState;for(let [d,f]of b._nodeMap){let g=h.$cloneWithProperties(f);if(y.$isTextNode(g)){if(!y.$isTextNode(f))throw Error("Expected node be a TextNode");g.__text=f.__text}c.set(d,g)}e&&(e._nodeMap=c);a._dirtyType=2;a=b._selection;y.$setSelection(null===a?null:a.clone())};
17
- exports.$wrapNodeInElement=function(a,b){b=b();a.replace(b);b.append(a);return b};exports.addClassNamesToElement=function(a,...b){b=I(...b);0<b.length&&a.classList.add(...b)};exports.calculateZoomLevel=function(a){if(F)return 1;let b=1;for(;a;)b*=Number(window.getComputedStyle(a).getPropertyValue("zoom")),a=a.parentElement;return b};exports.isMimeType=M;
18
- exports.markSelection=function(a,b){function c(m){m.read(()=>{var k=y.$getSelection();if(y.$isRangeSelection(k)){var {anchor:t,focus:B}=k;k=t.getNode();var p=k.getKey(),A=t.offset,q=B.getNode(),r=q.getKey(),w=B.offset,l=a.getElementByKey(p),x=a.getElementByKey(r);p=null===e||null===l||A!==d||p!==e.getKey()||k!==e&&(!(e instanceof y.TextNode)||k.updateDOM(e,l,a._config));r=null===f||null===x||w!==g||r!==f.getKey()||q!==f&&(!(f instanceof y.TextNode)||q.updateDOM(f,x,a._config));if(p||r){l=a.getElementByKey(t.getNode().getKey());
19
- var u=a.getElementByKey(B.getNode().getKey());if(null!==l&&null!==u&&"SPAN"===l.tagName&&"SPAN"===u.tagName){r=document.createRange();B.isBefore(t)?(p=u,x=B.offset,u=l,l=t.offset):(p=l,x=t.offset,l=B.offset);p=p.firstChild;if(null===p)throw Error("Expected text node to be first child of span");u=u.firstChild;if(null===u)throw Error("Expected text node to be first child of span");r.setStart(p,x);r.setEnd(u,l);n();n=L(a,r,z=>{for(let O of z){let v=O.style;"Highlight"!==v.background&&(v.background="Highlight");
20
- "HighlightText"!==v.color&&(v.color="HighlightText");"-1"!==v.zIndex&&(v.zIndex="-1");"none"!==v.pointerEvents&&(v.pointerEvents="none");"-1.5px"!==v.marginTop&&(v.marginTop="-1.5px");"4px"!==v.paddingTop&&(v.paddingTop="4px");"0px"!==v.paddingBottom&&(v.paddingBottom="0px")}void 0!==b&&b(z)})}}e=k;d=A;f=q;g=w}else g=f=d=e=null,n(),n=()=>{}})}let e=null,d=null,f=null,g=null,n=()=>{};c(a.getEditorState());return J(a.registerUpdateListener(({editorState:m})=>c(m)),n,()=>{n()})};
21
- exports.mediaFileReader=function(a,b){let c=a[Symbol.iterator]();return new Promise((e,d)=>{let f=[],g=()=>{const {done:n,value:m}=c.next();if(n)return e(f);const k=new FileReader;k.addEventListener("error",d);k.addEventListener("load",()=>{const t=k.result;"string"===typeof t&&f.push({file:m,result:t});g()});M(m,b)?k.readAsDataURL(m):g()};g()})};exports.mergeRegister=J;exports.objectKlassEquals=function(a,b){return null!==a?Object.getPrototypeOf(a).constructor.name===b.name:!1};
22
- exports.positionNodeOnRange=L;
7
+ 'use strict';var h=require("@lexical/selection"),x=require("lexical");function C(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
8
+ let D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,E=D&&"documentMode"in document?document.documentMode:null,F=D&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),G=D&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),H=D&&"InputEvent"in window&&!E?"getTargetRanges"in new window.InputEvent("input"):!1,I=D&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),J=D&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,
9
+ K=D&&/Android/.test(navigator.userAgent),L=D&&/^(?=.*Chrome).*/i.test(navigator.userAgent),M=D&&K&&L,N=D&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!L;function O(...a){let b=[];for(let c of a)if(c&&"string"===typeof c)for(let [e]of c.matchAll(/\S+/g))b.push(e);return b}function P(...a){return()=>{a.forEach(b=>b())}}let Q={attributes:!0,characterData:!0,childList:!0,subtree:!0};
10
+ function R(a,b,c){function e(){if(null===g)throw Error("Unexpected null rootDOMNode");if(null===n)throw Error("Unexpected null parentDOMNode");let {left:p,top:A}=g.getBoundingClientRect();var q=n;let r=h.createRectsFromDOMRange(a,b);t.isConnected||q.append(t);q=!1;for(let y=0;y<r.length;y++){var w=r[y];let u=k[y]||document.createElement("div"),z=u.style;"absolute"!==z.position&&(z.position="absolute",q=!0);var l=`${w.left-p}px`;z.left!==l&&(z.left=l,q=!0);l=`${w.top-A}px`;z.top!==l&&(u.style.top=
11
+ l,q=!0);l=`${w.width}px`;z.width!==l&&(u.style.width=l,q=!0);w=`${w.height}px`;z.height!==w&&(u.style.height=w,q=!0);u.parentNode!==t&&(t.append(u),q=!0);k[y]=u}for(;k.length>r.length;)k.pop();q&&c(k)}function d(){g=n=null;null!==m&&m.disconnect();m=null;t.remove();for(let p of k)p.remove();k=[]}function f(){let p=a.getRootElement();if(null===p)return d();let A=p.parentElement;if(!(A instanceof HTMLElement))return d();d();g=p;n=A;m=new MutationObserver(q=>{let r=a.getRootElement(),w=r&&r.parentElement;
12
+ if(r!==g||w!==n)return f();for(let l of q)if(!t.contains(l.target))return e()});m.observe(A,Q);e()}let g=null,n=null,m=null,k=[],t=document.createElement("div"),B=a.registerRootListener(f);return()=>{B();d()}}function S(a,b){for(let c of b)if(a.type.startsWith(c))return!0;return!1}let T=(a,b)=>{for(;a!==x.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null};exports.$splitNode=x.$splitNode;exports.isHTMLAnchorElement=x.isHTMLAnchorElement;exports.isHTMLElement=x.isHTMLElement;
13
+ exports.$dfs=function(a,b){let c=[];a=(a||x.$getRoot()).getLatest();b=b||(x.$isElementNode(a)?a.getLastDescendant():a);for(var e=a,d=0;null!==(e=e.getParent());)d++;for(e=d;null!==a&&!a.is(b);)if(c.push({depth:e,node:a}),x.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild(),e++;else for(d=null;null===d&&null!==a;)d=a.getNextSibling(),null===d?(a=a.getParent(),e--):a=d;null!==a&&a.is(b)&&c.push({depth:e,node:a});return c};
14
+ exports.$filter=function(a,b){let c=[];for(let e=0;e<a.length;e++){let d=b(a[e]);null!==d&&c.push(d)}return c};exports.$findMatchingParent=T;exports.$getNearestBlockElementAncestorOrThrow=function(a){let b=T(a,c=>x.$isElementNode(c)&&!c.isInline());x.$isElementNode(b)||C(4,a.__key);return b};exports.$getNearestNodeOfType=function(a,b){for(;null!=a;){if(a instanceof b)return a;a=a.getParent()}return null};exports.$insertFirst=function(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)};
15
+ exports.$insertNodeToNearestRoot=function(a){var b=x.$getSelection()||x.$getPreviousSelection();if(x.$isRangeSelection(b)){var {focus:c}=b;b=c.getNode();c=c.offset;if(x.$isRootOrShadowRoot(b))c=b.getChildAtIndex(c),null==c?b.append(a):c.insertBefore(a),a.selectNext();else{let e,d;x.$isTextNode(b)?(e=b.getParentOrThrow(),d=b.getIndexWithinParent(),0<c&&(d+=1,b.splitText(c))):(e=b,d=c);[,b]=x.$splitNode(e,d);b.insertBefore(a);b.selectStart()}}else null!=b?(b=b.getNodes(),b[b.length-1].getTopLevelElementOrThrow().insertAfter(a)):
16
+ x.$getRoot().append(a),b=x.$createParagraphNode(),a.insertAfter(b),b.select();return a.getLatest()};exports.$restoreEditorState=function(a,b){let c=new Map,e=a._pendingEditorState;for(let [d,f]of b._nodeMap){let g=h.$cloneWithProperties(f);if(x.$isTextNode(g)){if(!x.$isTextNode(f))throw Error("Expected node be a TextNode");g.__text=f.__text}c.set(d,g)}e&&(e._nodeMap=c);a._dirtyType=2;a=b._selection;x.$setSelection(null===a?null:a.clone())};
17
+ exports.$wrapNodeInElement=function(a,b){b=b();a.replace(b);b.append(a);return b};exports.CAN_USE_BEFORE_INPUT=H;exports.CAN_USE_DOM=D;exports.IS_ANDROID=K;exports.IS_ANDROID_CHROME=M;exports.IS_APPLE=F;exports.IS_APPLE_WEBKIT=N;exports.IS_CHROME=L;exports.IS_FIREFOX=G;exports.IS_IOS=J;exports.IS_SAFARI=I;exports.addClassNamesToElement=function(a,...b){b=O(...b);0<b.length&&a.classList.add(...b)};
18
+ exports.calculateZoomLevel=function(a){if(G)return 1;let b=1;for(;a;)b*=Number(window.getComputedStyle(a).getPropertyValue("zoom")),a=a.parentElement;return b};exports.isMimeType=S;
19
+ exports.markSelection=function(a,b){function c(m){m.read(()=>{var k=x.$getSelection();if(x.$isRangeSelection(k)){var {anchor:t,focus:B}=k;k=t.getNode();var p=k.getKey(),A=t.offset,q=B.getNode(),r=q.getKey(),w=B.offset,l=a.getElementByKey(p),y=a.getElementByKey(r);p=null===e||null===l||A!==d||p!==e.getKey()||k!==e&&(!(e instanceof x.TextNode)||k.updateDOM(e,l,a._config));r=null===f||null===y||w!==g||r!==f.getKey()||q!==f&&(!(f instanceof x.TextNode)||q.updateDOM(f,y,a._config));if(p||r){l=a.getElementByKey(t.getNode().getKey());
20
+ var u=a.getElementByKey(B.getNode().getKey());if(null!==l&&null!==u&&"SPAN"===l.tagName&&"SPAN"===u.tagName){r=document.createRange();B.isBefore(t)?(p=u,y=B.offset,u=l,l=t.offset):(p=l,y=t.offset,l=B.offset);p=p.firstChild;if(null===p)throw Error("Expected text node to be first child of span");u=u.firstChild;if(null===u)throw Error("Expected text node to be first child of span");r.setStart(p,y);r.setEnd(u,l);n();n=R(a,r,z=>{for(let U of z){let v=U.style;"Highlight"!==v.background&&(v.background="Highlight");
21
+ "HighlightText"!==v.color&&(v.color="HighlightText");"-1"!==v.zIndex&&(v.zIndex="-1");"none"!==v.pointerEvents&&(v.pointerEvents="none");"-1.5px"!==v.marginTop&&(v.marginTop="-1.5px");"4px"!==v.paddingTop&&(v.paddingTop="4px");"0px"!==v.paddingBottom&&(v.paddingBottom="0px")}void 0!==b&&b(z)})}}e=k;d=A;f=q;g=w}else g=f=d=e=null,n(),n=()=>{}})}let e=null,d=null,f=null,g=null,n=()=>{};c(a.getEditorState());return P(a.registerUpdateListener(({editorState:m})=>c(m)),n,()=>{n()})};
22
+ exports.mediaFileReader=function(a,b){let c=a[Symbol.iterator]();return new Promise((e,d)=>{let f=[],g=()=>{const {done:n,value:m}=c.next();if(n)return e(f);const k=new FileReader;k.addEventListener("error",d);k.addEventListener("load",()=>{const t=k.result;"string"===typeof t&&f.push({file:m,result:t});g()});S(m,b)?k.readAsDataURL(m):g()};g()})};exports.mergeRegister=P;exports.objectKlassEquals=function(a,b){return null!==a?Object.getPrototypeOf(a).constructor.name===b.name:!1};
23
+ exports.positionNodeOnRange=R;
23
24
  exports.registerNestedElementResolver=function(a,b,c,e){return a.registerNodeTransform(b,d=>{a:{var f=d.getChildren();for(var g=0;g<f.length;g++)if(f[g]instanceof b){f=null;break a}for(f=d;null!==f;)if(g=f,f=f.getParent(),f instanceof b){f={child:g,parent:f};break a}f=null}if(null!==f){const {child:n,parent:m}=f;if(n.is(d)){e(m,d);d=n.getNextSiblings();f=d.length;m.insertAfter(n);if(0!==f){g=c(m);n.insertAfter(g);for(let k=0;k<f;k++)g.append(d[k])}m.canBeEmpty()||0!==m.getChildrenSize()||m.remove()}}})};
24
- exports.removeClassNamesFromElement=function(a,...b){b=I(...b);0<b.length&&a.classList.remove(...b)}
25
+ exports.removeClassNamesFromElement=function(a,...b){b=O(...b);0<b.length&&a.classList.remove(...b)}
@@ -4,4 +4,4 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import{createRectsFromDOMRange as e,$cloneWithProperties as t}from"@lexical/selection";import{$getSelection as n,$isRangeSelection as o,TextNode as r,$getRoot as l,$isElementNode as i,$isTextNode as s,$setSelection as c,$getPreviousSelection as u,$isRootOrShadowRoot as f,$splitNode as d,$createParagraphNode as a}from"lexical";export{$splitNode,isHTMLAnchorElement,isHTMLElement}from"lexical";var g=function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)};const p="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,h=p&&"documentMode"in document?document.documentMode:null;p&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);const m=p&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);p&&"InputEvent"in window&&!h&&new window.InputEvent("input"),p&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),p&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&window.MSStream;p&&/Android/.test(navigator.userAgent),p&&/^(?=.*Chrome).*/i.test(navigator.userAgent);function E(...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 v(...e){return()=>{e.forEach((e=>e()))}}function w(e){return`${e}px`}p&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent);const y={attributes:!0,characterData:!0,childList:!0,subtree:!0};function x(t,n,o){let r=null,l=null,i=null,s=[];const c=document.createElement("div");function u(){if(null===r)throw Error("Unexpected null rootDOMNode");if(null===l)throw Error("Unexpected null parentDOMNode");const{left:i,top:u}=r.getBoundingClientRect(),f=l,d=e(t,n);c.isConnected||f.append(c);let a=!1;for(let e=0;e<d.length;e++){const t=d[e],n=s[e]||document.createElement("div"),o=n.style;"absolute"!==o.position&&(o.position="absolute",a=!0);const r=w(t.left-i);o.left!==r&&(o.left=r,a=!0);const l=w(t.top-u);o.top!==l&&(n.style.top=l,a=!0);const f=w(t.width);o.width!==f&&(n.style.width=f,a=!0);const g=w(t.height);o.height!==g&&(n.style.height=g,a=!0),n.parentNode!==c&&(c.append(n),a=!0),s[e]=n}for(;s.length>d.length;)s.pop();a&&o(s)}function f(){l=null,r=null,null!==i&&i.disconnect(),i=null,c.remove();for(const e of s)e.remove();s=[]}const d=t.registerRootListener((function e(){const n=t.getRootElement();if(null===n)return f();const o=n.parentElement;if(!(o instanceof HTMLElement))return f();f(),r=n,l=o,i=new MutationObserver((n=>{const o=t.getRootElement(),i=o&&o.parentElement;if(o!==r||i!==l)return e();for(const e of n)if(!c.contains(e.target))return u()})),i.observe(o,y),u()}));return()=>{d(),f()}}function N(e,t){let l=null,i=null,s=null,c=null,u=()=>{};function f(f){f.read((()=>{const f=n();if(!o(f))return l=null,i=null,s=null,c=null,u(),void(u=()=>{});const{anchor:d,focus:a}=f,g=d.getNode(),p=g.getKey(),h=d.offset,m=a.getNode(),E=m.getKey(),v=a.offset,y=e.getElementByKey(p),N=e.getElementByKey(E),P=null===l||null===y||h!==i||p!==l.getKey()||g!==l&&(!(l instanceof r)||g.updateDOM(l,y,e._config)),S=null===s||null===N||v!==c||E!==s.getKey()||m!==s&&(!(s instanceof r)||m.updateDOM(s,N,e._config));if(P||S){const n=e.getElementByKey(d.getNode().getKey()),o=e.getElementByKey(a.getNode().getKey());if(null!==n&&null!==o&&"SPAN"===n.tagName&&"SPAN"===o.tagName){const r=document.createRange();let l,i,s,c;a.isBefore(d)?(l=o,i=a.offset,s=n,c=d.offset):(l=n,i=d.offset,s=o,c=a.offset);const f=l.firstChild;if(null===f)throw Error("Expected text node to be first child of span");const g=s.firstChild;if(null===g)throw Error("Expected text node to be first child of span");r.setStart(f,i),r.setEnd(g,c),u(),u=x(e,r,(e=>{for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),"-1"!==e.zIndex&&(e.zIndex="-1"),"none"!==e.pointerEvents&&(e.pointerEvents="none"),e.marginTop!==w(-1.5)&&(e.marginTop=w(-1.5)),e.paddingTop!==w(4)&&(e.paddingTop=w(4)),e.paddingBottom!==w(0)&&(e.paddingBottom=w(0))}void 0!==t&&t(e)}))}}l=g,i=h,s=m,c=v}))}return f(e.getEditorState()),v(e.registerUpdateListener((({editorState:e})=>f(e))),u,(()=>{u()}))}function P(e,...t){const n=E(...t);n.length>0&&e.classList.add(...n)}function S(e,...t){const n=E(...t);n.length>0&&e.classList.remove(...n)}function A(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function b(e,t){const n=e[Symbol.iterator]();return new Promise(((e,o)=>{const r=[],l=()=>{const{done:i,value:s}=n.next();if(i)return e(r);const c=new FileReader;c.addEventListener("error",o),c.addEventListener("load",(()=>{const e=c.result;"string"==typeof e&&r.push({file:s,result:e}),l()})),A(s,t)?c.readAsDataURL(s):l()};l()}))}function L(e,t){const n=[],o=(e||l()).getLatest(),r=t||(i(o)?o.getLastDescendant():o);let s=o,c=function(e){let t=e,n=0;for(;null!==(t=t.getParent());)n++;return n}(s);for(;null!==s&&!s.is(r);)if(n.push({depth:c,node:s}),i(s)&&s.getChildrenSize()>0)s=s.getFirstChild(),c++;else{let e=null;for(;null===e&&null!==s;)e=s.getNextSibling(),null===e?(s=s.getParent(),c--):s=e}return null!==s&&s.is(r)&&n.push({depth:c,node:s}),n}function M(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function T(e){const t=_(e,(e=>i(e)&&!e.isInline()));return i(t)||g(4,e.__key),t}const _=(e,t)=>{let n=e;for(;n!==l()&&null!=n;){if(t(n))return n;n=n.getParent()}return null};function B(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:l}=t;if(r.is(e)){o(l,e);const t=r.getNextSiblings(),i=t.length;if(l.insertAfter(r),0!==i){const e=n(l);r.insertAfter(e);for(let n=0;n<i;n++)e.append(t[n])}l.canBeEmpty()||0!==l.getChildrenSize()||l.remove()}}}))}function C(e,n){const o=new Map,r=e._pendingEditorState;for(const[e,r]of n._nodeMap){const n=t(r);if(s(n)){if(!s(r))throw Error("Expected node be a TextNode");n.__text=r.__text}o.set(e,n)}r&&(r._nodeMap=o),e._dirtyType=2;const l=n._selection;c(null===l?null:l.clone())}function K(e){const t=n()||u();if(o(t)){const{focus:n}=t,o=n.getNode(),r=n.offset;if(f(o)){const t=o.getChildAtIndex(r);null==t?o.append(e):t.insertBefore(e),e.selectNext()}else{let t,n;s(o)?(t=o.getParentOrThrow(),n=o.getIndexWithinParent(),r>0&&(n+=1,o.splitText(r))):(t=o,n=r);const[,l]=d(t,n);l.insertBefore(e),l.selectStart()}}else{if(null!=t){const n=t.getNodes();n[n.length-1].getTopLevelElementOrThrow().insertAfter(e)}else{l().append(e)}const n=a();e.insertAfter(n),n.select()}return e.getLatest()}function O(e,t){const n=t();return e.replace(n),n.append(e),n}function R(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name}function D(e,t){const n=[];for(let o=0;o<e.length;o++){const r=t(e[o]);null!==r&&n.push(r)}return n}function H(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function I(e){if(m)return 1;let t=1;for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t}export{L as $dfs,D as $filter,_ as $findMatchingParent,T as $getNearestBlockElementAncestorOrThrow,M as $getNearestNodeOfType,H as $insertFirst,K as $insertNodeToNearestRoot,C as $restoreEditorState,O as $wrapNodeInElement,P as addClassNamesToElement,I as calculateZoomLevel,A as isMimeType,N as markSelection,b as mediaFileReader,v as mergeRegister,R as objectKlassEquals,x as positionNodeOnRange,B as registerNestedElementResolver,S as removeClassNamesFromElement};
7
+ import{createRectsFromDOMRange as e,$cloneWithProperties as t}from"@lexical/selection";import{$getSelection as n,$isRangeSelection as o,TextNode as r,$getRoot as l,$isElementNode as i,$isTextNode as s,$setSelection as c,$getPreviousSelection as u,$isRootOrShadowRoot as f,$splitNode as a,$createParagraphNode as d}from"lexical";export{$splitNode,isHTMLAnchorElement,isHTMLElement}from"lexical";var g=function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)};const p="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,h=p&&"documentMode"in document?document.documentMode:null,m=p&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),E=p&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),v=!(!p||!("InputEvent"in window)||h)&&"getTargetRanges"in new window.InputEvent("input"),w=p&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),y=p&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,x=p&&/Android/.test(navigator.userAgent),N=p&&/^(?=.*Chrome).*/i.test(navigator.userAgent),P=p&&x&&N,S=p&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!N;function A(...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 b(...e){return()=>{e.forEach((e=>e()))}}function L(e){return`${e}px`}const T={attributes:!0,characterData:!0,childList:!0,subtree:!0};function M(t,n,o){let r=null,l=null,i=null,s=[];const c=document.createElement("div");function u(){if(null===r)throw Error("Unexpected null rootDOMNode");if(null===l)throw Error("Unexpected null parentDOMNode");const{left:i,top:u}=r.getBoundingClientRect(),f=l,a=e(t,n);c.isConnected||f.append(c);let d=!1;for(let e=0;e<a.length;e++){const t=a[e],n=s[e]||document.createElement("div"),o=n.style;"absolute"!==o.position&&(o.position="absolute",d=!0);const r=L(t.left-i);o.left!==r&&(o.left=r,d=!0);const l=L(t.top-u);o.top!==l&&(n.style.top=l,d=!0);const f=L(t.width);o.width!==f&&(n.style.width=f,d=!0);const g=L(t.height);o.height!==g&&(n.style.height=g,d=!0),n.parentNode!==c&&(c.append(n),d=!0),s[e]=n}for(;s.length>a.length;)s.pop();d&&o(s)}function f(){l=null,r=null,null!==i&&i.disconnect(),i=null,c.remove();for(const e of s)e.remove();s=[]}const a=t.registerRootListener((function e(){const n=t.getRootElement();if(null===n)return f();const o=n.parentElement;if(!(o instanceof HTMLElement))return f();f(),r=n,l=o,i=new MutationObserver((n=>{const o=t.getRootElement(),i=o&&o.parentElement;if(o!==r||i!==l)return e();for(const e of n)if(!c.contains(e.target))return u()})),i.observe(o,T),u()}));return()=>{a(),f()}}function _(e,t){let l=null,i=null,s=null,c=null,u=()=>{};function f(f){f.read((()=>{const f=n();if(!o(f))return l=null,i=null,s=null,c=null,u(),void(u=()=>{});const{anchor:a,focus:d}=f,g=a.getNode(),p=g.getKey(),h=a.offset,m=d.getNode(),E=m.getKey(),v=d.offset,w=e.getElementByKey(p),y=e.getElementByKey(E),x=null===l||null===w||h!==i||p!==l.getKey()||g!==l&&(!(l instanceof r)||g.updateDOM(l,w,e._config)),N=null===s||null===y||v!==c||E!==s.getKey()||m!==s&&(!(s instanceof r)||m.updateDOM(s,y,e._config));if(x||N){const n=e.getElementByKey(a.getNode().getKey()),o=e.getElementByKey(d.getNode().getKey());if(null!==n&&null!==o&&"SPAN"===n.tagName&&"SPAN"===o.tagName){const r=document.createRange();let l,i,s,c;d.isBefore(a)?(l=o,i=d.offset,s=n,c=a.offset):(l=n,i=a.offset,s=o,c=d.offset);const f=l.firstChild;if(null===f)throw Error("Expected text node to be first child of span");const g=s.firstChild;if(null===g)throw Error("Expected text node to be first child of span");r.setStart(f,i),r.setEnd(g,c),u(),u=M(e,r,(e=>{for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),"-1"!==e.zIndex&&(e.zIndex="-1"),"none"!==e.pointerEvents&&(e.pointerEvents="none"),e.marginTop!==L(-1.5)&&(e.marginTop=L(-1.5)),e.paddingTop!==L(4)&&(e.paddingTop=L(4)),e.paddingBottom!==L(0)&&(e.paddingBottom=L(0))}void 0!==t&&t(e)}))}}l=g,i=h,s=m,c=v}))}return f(e.getEditorState()),b(e.registerUpdateListener((({editorState:e})=>f(e))),u,(()=>{u()}))}function B(e,...t){const n=A(...t);n.length>0&&e.classList.add(...n)}function C(e,...t){const n=A(...t);n.length>0&&e.classList.remove(...n)}function K(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function O(e,t){const n=e[Symbol.iterator]();return new Promise(((e,o)=>{const r=[],l=()=>{const{done:i,value:s}=n.next();if(i)return e(r);const c=new FileReader;c.addEventListener("error",o),c.addEventListener("load",(()=>{const e=c.result;"string"==typeof e&&r.push({file:s,result:e}),l()})),K(s,t)?c.readAsDataURL(s):l()};l()}))}function R(e,t){const n=[],o=(e||l()).getLatest(),r=t||(i(o)?o.getLastDescendant():o);let s=o,c=function(e){let t=e,n=0;for(;null!==(t=t.getParent());)n++;return n}(s);for(;null!==s&&!s.is(r);)if(n.push({depth:c,node:s}),i(s)&&s.getChildrenSize()>0)s=s.getFirstChild(),c++;else{let e=null;for(;null===e&&null!==s;)e=s.getNextSibling(),null===e?(s=s.getParent(),c--):s=e}return null!==s&&s.is(r)&&n.push({depth:c,node:s}),n}function D(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function H(e){const t=I(e,(e=>i(e)&&!e.isInline()));return i(t)||g(4,e.__key),t}const I=(e,t)=>{let n=e;for(;n!==l()&&null!=n;){if(t(n))return n;n=n.getParent()}return null};function z(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:l}=t;if(r.is(e)){o(l,e);const t=r.getNextSiblings(),i=t.length;if(l.insertAfter(r),0!==i){const e=n(l);r.insertAfter(e);for(let n=0;n<i;n++)e.append(t[n])}l.canBeEmpty()||0!==l.getChildrenSize()||l.remove()}}}))}function U(e,n){const o=new Map,r=e._pendingEditorState;for(const[e,r]of n._nodeMap){const n=t(r);if(s(n)){if(!s(r))throw Error("Expected node be a TextNode");n.__text=r.__text}o.set(e,n)}r&&(r._nodeMap=o),e._dirtyType=2;const l=n._selection;c(null===l?null:l.clone())}function k(e){const t=n()||u();if(o(t)){const{focus:n}=t,o=n.getNode(),r=n.offset;if(f(o)){const t=o.getChildAtIndex(r);null==t?o.append(e):t.insertBefore(e),e.selectNext()}else{let t,n;s(o)?(t=o.getParentOrThrow(),n=o.getIndexWithinParent(),r>0&&(n+=1,o.splitText(r))):(t=o,n=r);const[,l]=a(t,n);l.insertBefore(e),l.selectStart()}}else{if(null!=t){const n=t.getNodes();n[n.length-1].getTopLevelElementOrThrow().insertAfter(e)}else{l().append(e)}const n=d();e.insertAfter(n),n.select()}return e.getLatest()}function F(e,t){const n=t();return e.replace(n),n.append(e),n}function $(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name}function W(e,t){const n=[];for(let o=0;o<e.length;o++){const r=t(e[o]);null!==r&&n.push(r)}return n}function V(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function j(e){if(E)return 1;let t=1;for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t}export{R as $dfs,W as $filter,I as $findMatchingParent,H as $getNearestBlockElementAncestorOrThrow,D as $getNearestNodeOfType,V as $insertFirst,k as $insertNodeToNearestRoot,U as $restoreEditorState,F as $wrapNodeInElement,v as CAN_USE_BEFORE_INPUT,p as CAN_USE_DOM,x as IS_ANDROID,P as IS_ANDROID_CHROME,m as IS_APPLE,S as IS_APPLE_WEBKIT,N as IS_CHROME,E as IS_FIREFOX,y as IS_IOS,w as IS_SAFARI,B as addClassNamesToElement,j as calculateZoomLevel,K as isMimeType,_ as markSelection,O as mediaFileReader,b as mergeRegister,$ as objectKlassEquals,M as positionNodeOnRange,z as registerNestedElementResolver,C as removeClassNamesFromElement};
package/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /** @module @lexical/utils */
2
1
  /**
3
2
  * Copyright (c) Meta Platforms, Inc. and affiliates.
4
3
  *
@@ -11,6 +10,8 @@ export { default as markSelection } from './markSelection';
11
10
  export { default as mergeRegister } from './mergeRegister';
12
11
  export { default as positionNodeOnRange } from './positionNodeOnRange';
13
12
  export { $splitNode, isHTMLAnchorElement, isHTMLElement } from 'lexical';
13
+ export { CAN_USE_DOM } from 'shared/canUseDOM';
14
+ export { CAN_USE_BEFORE_INPUT, IS_ANDROID, IS_ANDROID_CHROME, IS_APPLE, IS_APPLE_WEBKIT, IS_CHROME, IS_FIREFOX, IS_IOS, IS_SAFARI, } from 'shared/environment';
14
15
  export type DFSNode = Readonly<{
15
16
  depth: number;
16
17
  node: LexicalNode;
package/package.json CHANGED
@@ -8,14 +8,14 @@
8
8
  "utils"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.14.3",
11
+ "version": "0.14.5",
12
12
  "main": "LexicalUtils.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/list": "0.14.3",
16
- "@lexical/selection": "0.14.3",
17
- "@lexical/table": "0.14.3",
18
- "lexical": "0.14.3"
15
+ "@lexical/list": "0.14.5",
16
+ "@lexical/selection": "0.14.5",
17
+ "@lexical/table": "0.14.5",
18
+ "lexical": "0.14.5"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -28,11 +28,15 @@
28
28
  ".": {
29
29
  "import": {
30
30
  "types": "./index.d.ts",
31
+ "development": "./LexicalUtils.dev.mjs",
32
+ "production": "./LexicalUtils.prod.mjs",
31
33
  "node": "./LexicalUtils.node.mjs",
32
34
  "default": "./LexicalUtils.mjs"
33
35
  },
34
36
  "require": {
35
37
  "types": "./index.d.ts",
38
+ "development": "./LexicalUtils.dev.js",
39
+ "production": "./LexicalUtils.prod.js",
36
40
  "default": "./LexicalUtils.js"
37
41
  }
38
42
  }