@react-fabric/lexical 1.0.0-beta.46 → 1.0.0-beta.48

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.
Files changed (62) hide show
  1. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +29 -19
  2. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
  3. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +9 -9
  4. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +142 -75
  5. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +1 -1
  6. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +25 -21
  7. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +10 -3
  8. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +1 -1
  9. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  10. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +147 -103
  11. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +1 -1
  12. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +10 -10
  13. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +254 -178
  14. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +1 -1
  15. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +19 -16
  16. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +53 -29
  17. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
  18. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
  19. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +176 -194
  20. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +1 -1
  21. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +25 -18
  22. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +1925 -793
  23. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +1 -1
  24. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +48 -40
  25. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +426 -144
  26. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +11 -1
  27. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +46 -32
  28. package/dist/cjs/node_modules/prismjs/prism.js +1 -1
  29. package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +1 -1
  30. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +29 -19
  31. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
  32. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
  33. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +139 -76
  34. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +1 -1
  35. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +4 -4
  36. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +11 -4
  37. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +1 -1
  38. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  39. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +149 -105
  40. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +1 -1
  41. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +4 -4
  42. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +253 -180
  43. package/dist/esm/node_modules/@lexical/list/LexicalList.js +1 -1
  44. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +4 -4
  45. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +54 -30
  46. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
  47. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +3 -3
  48. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +171 -196
  49. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +1 -1
  50. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +4 -4
  51. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +1920 -796
  52. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +1 -1
  53. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +4 -4
  54. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +413 -145
  55. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +7 -2
  56. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
  57. package/dist/esm/node_modules/prismjs/prism.js +1 -1
  58. package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +1 -1
  59. package/package.json +7 -8
  60. package/src/components/StickyComponent.tsx +1 -1
  61. package/src/editor/LexicalEditor.tsx +25 -21
  62. package/src/plugins/ToolbarPlugin.tsx +20 -4
@@ -11,10 +11,15 @@ var LexicalUtils_prod = require('./LexicalUtils.prod.js');
11
11
  *
12
12
  */
13
13
 
14
- const mod = process.env.NODE_ENV === 'development' ? LexicalUtils_dev : LexicalUtils_prod;
14
+ const mod = process.env.NODE_ENV !== 'production' ? LexicalUtils_dev : LexicalUtils_prod;
15
+ const $descendantsMatching = mod.$descendantsMatching;
15
16
  const $findMatchingParent = mod.$findMatchingParent;
17
+ const $getAdjacentCaret = mod.$getAdjacentCaret;
16
18
  const $getNearestBlockElementAncestorOrThrow = mod.$getNearestBlockElementAncestorOrThrow;
17
19
  const $getNearestNodeOfType = mod.$getNearestNodeOfType;
20
+ const $insertFirst = mod.$insertFirst;
21
+ const $insertNodeToNearestRoot = mod.$insertNodeToNearestRoot;
22
+ const $unwrapAndFilterDescendants = mod.$unwrapAndFilterDescendants;
18
23
  const addClassNamesToElement = mod.addClassNamesToElement;
19
24
  const isBlockDomNode = mod.isBlockDomNode;
20
25
  const isHTMLAnchorElement = mod.isHTMLAnchorElement;
@@ -23,9 +28,14 @@ const mergeRegister = mod.mergeRegister;
23
28
  const objectKlassEquals = mod.objectKlassEquals;
24
29
  const removeClassNamesFromElement = mod.removeClassNamesFromElement;
25
30
 
31
+ exports.$descendantsMatching = $descendantsMatching;
26
32
  exports.$findMatchingParent = $findMatchingParent;
33
+ exports.$getAdjacentCaret = $getAdjacentCaret;
27
34
  exports.$getNearestBlockElementAncestorOrThrow = $getNearestBlockElementAncestorOrThrow;
28
35
  exports.$getNearestNodeOfType = $getNearestNodeOfType;
36
+ exports.$insertFirst = $insertFirst;
37
+ exports.$insertNodeToNearestRoot = $insertNodeToNearestRoot;
38
+ exports.$unwrapAndFilterDescendants = $unwrapAndFilterDescendants;
29
39
  exports.addClassNamesToElement = addClassNamesToElement;
30
40
  exports.isBlockDomNode = isBlockDomNode;
31
41
  exports.isHTMLAnchorElement = isHTMLAnchorElement;
@@ -11,7 +11,7 @@ var LexicalSelection = require('../selection/LexicalSelection.js');
11
11
  *
12
12
  */
13
13
 
14
- function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p=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 h="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,m=h&&"documentMode"in document?document.documentMode:null,v=h&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),y=h&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),w=!(!h||!("InputEvent"in window)||m)&&"getTargetRanges"in new window.InputEvent("input"),E=h&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),P=h&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,S=h&&/Android/.test(navigator.userAgent),x=h&&/^(?=.*Chrome).*/i.test(navigator.userAgent),N=h&&S&&x,A=h&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!x;function L(...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 ()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0;}}function T(e){return `${e}px`}const M={attributes:!0,characterData:!0,childList:!0,subtree:!0};function C(e,t,n){let o=null,r=null,l=null,i=[];const s=document.createElement("div");function u(){null===o&&p(182),null===r&&p(183);const{left:l,top:u}=o.getBoundingClientRect(),c=r,f=LexicalSelection.createRectsFromDOMRange(e,t);s.isConnected||c.append(s);let a=!1;for(let e=0;e<f.length;e++){const t=f[e],n=i[e]||document.createElement("div"),o=n.style;"absolute"!==o.position&&(o.position="absolute",a=!0);const r=T(t.left-l);o.left!==r&&(o.left=r,a=!0);const c=T(t.top-u);o.top!==c&&(n.style.top=c,a=!0);const d=T(t.width);o.width!==d&&(n.style.width=d,a=!0);const g=T(t.height);o.height!==g&&(n.style.height=g,a=!0),n.parentNode!==s&&(s.append(n),a=!0),i[e]=n;}for(;i.length>f.length;)i.pop();a&&n(i);}function c(){r=null,o=null,null!==l&&l.disconnect(),l=null,s.remove();for(const e of i)e.remove();i=[];}const f=e.registerRootListener((function t(){const n=e.getRootElement();if(null===n)return c();const i=n.parentElement;if(!(i instanceof HTMLElement))return c();c(),o=n,r=i,l=new MutationObserver((n=>{const l=e.getRootElement(),i=l&&l.parentElement;if(l!==o||i!==r)return t();for(const e of n)if(!s.contains(e.target))return u()})),l.observe(i,M),u();}));return ()=>{f(),c();}}function B(o,r){let l=null,i=null,s=null,u=null,c=()=>{};function f(f){f.read((()=>{const f=lexical.$getSelection();if(!lexical.$isRangeSelection(f))return l=null,i=null,s=null,u=null,c(),void(c=()=>{});const{anchor:a,focus:d}=f,g=a.getNode(),h=g.getKey(),m=a.offset,v=d.getNode(),y=v.getKey(),w=d.offset,E=o.getElementByKey(h),P=o.getElementByKey(y),S=null===l||null===E||m!==i||h!==l.getKey()||g!==l&&(!(l instanceof lexical.TextNode)||g.updateDOM(l,E,o._config)),x=null===s||null===P||w!==u||y!==s.getKey()||v!==s&&(!(s instanceof lexical.TextNode)||v.updateDOM(s,P,o._config));if(S||x){const e=o.getElementByKey(a.getNode().getKey()),t=o.getElementByKey(d.getNode().getKey());if(null!==e&&null!==t&&"SPAN"===e.tagName&&"SPAN"===t.tagName){const n=document.createRange();let l,i,s,u;d.isBefore(a)?(l=t,i=d.offset,s=e,u=a.offset):(l=e,i=a.offset,s=t,u=d.offset);const f=l.firstChild;null===f&&p(181);const g=s.firstChild;null===g&&p(181),n.setStart(f,i),n.setEnd(g,u),c(),c=C(o,n,(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!==T(-1.5)&&(e.marginTop=T(-1.5)),e.paddingTop!==T(4)&&(e.paddingTop=T(4)),e.paddingBottom!==T(0)&&(e.paddingBottom=T(0));}void 0!==r&&r(e);}));}}l=g,i=m,s=v,u=w;}));}return f(o.getEditorState()),b(o.registerUpdateListener((({editorState:e})=>f(e))),c,(()=>{c();}))}const _=w,K=h,O=S,R=N,I=v,D=A,H=x,z=y,k=P,F=E;function $(e,...t){const n=L(...t);n.length>0&&e.classList.add(...n);}function U(e,...t){const n=L(...t);n.length>0&&e.classList.remove(...n);}function W(e,t){for(const n of t)if(e.type.startsWith(n))return !0;return !1}function j(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 u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",(()=>{const e=u.result;"string"==typeof e&&r.push({file:s,result:e}),l();})),W(s,t)?u.readAsDataURL(s):l();};l();}))}function V(e,t){const n=[],l=(e||lexical.$getRoot()).getLatest(),i=t||lexical.$isElementNode(l)&&l.getLastDescendant()||l;let s=l,u=function(e){let t=e,n=0;for(;null!==(t=t.getParent());)n++;return n}(s);for(;null!==s&&!s.is(i);)if(n.push({depth:u,node:s}),lexical.$isElementNode(s)&&s.getChildrenSize()>0)s=s.getFirstChild(),u++;else {let e=null;for(;null===e&&null!==s;)e=s.getNextSibling(),null===e?(s=s.getParent(),u--):s=e;}return null!==s&&s.is(i)&&n.push({depth:u,node:s}),n}function q(e){let t=e;if(lexical.$isElementNode(t)&&t.getChildrenSize()>0)t=t.getLastChild();else {let e=null;for(;null===e&&null!==t;)e=t.getPreviousSibling(),t=null===e?t.getParent():e;}return t}function G(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent();}return null}function J(e){const t=Q(e,(e=>lexical.$isElementNode(e)&&!e.isInline()));return lexical.$isElementNode(t)||p(4,e.__key),t}const Q=(e,t)=>{let n=e;for(;n!==lexical.$getRoot()&&null!=n;){if(t(n))return n;n=n.getParent();}return null};function X(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 Y(e,t){const n=new Map,o=e._pendingEditorState;for(const[e,o]of t._nodeMap)n.set(e,lexical.$cloneWithProperties(o));o&&(o._nodeMap=n),e._dirtyType=2;const r=t._selection;lexical.$setSelection(null===r?null:r.clone());}function Z(n){const r=lexical.$getSelection()||lexical.$getPreviousSelection();if(lexical.$isRangeSelection(r)){const{focus:e}=r,t=e.getNode(),o=e.offset;if(lexical.$isRootOrShadowRoot(t)){const e=t.getChildAtIndex(o);null==e?t.append(n):e.insertBefore(n),n.selectNext();}else {let e,r;lexical.$isTextNode(t)?(e=t.getParentOrThrow(),r=t.getIndexWithinParent(),o>0&&(r+=1,t.splitText(o))):(e=t,r=o);const[,l]=lexical.$splitNode(e,r);l.insertBefore(n),l.selectStart();}}else {if(null!=r){const e=r.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(n);}else {lexical.$getRoot().append(n);}const e=lexical.$createParagraphNode();n.insertAfter(e),e.select();}return n.getLatest()}function ee(e,t){const n=t();return e.replace(n),n.append(e),n}function te(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name}function ne(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 oe(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t);}function re(e){if(z)return 1;let t=1;for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t}function le(e){return null!==e._parentEditor}
14
+ function L(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 N="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,P=N&&"documentMode"in document?document.documentMode:null,b=N&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),T=N&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),M=!(!N||!("InputEvent"in window)||P)&&"getTargetRanges"in new window.InputEvent("input"),R=N&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),B=N&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,_=N&&/Android/.test(navigator.userAgent),O=N&&/^(?=.*Chrome).*/i.test(navigator.userAgent),k=N&&_&&O,K=N&&/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&&L(182),null===i&&L(183);const{left:t,top:l}=i.getBoundingClientRect(),c=LexicalSelection.createRectsFromDOMRange(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(!lexical.isHTMLElement(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&&lexical.$isElementNode(e)){const o=e.getDOMSlot(n);return [o.element,o.getFirstChildOffset()+t.offset]}return [lexical.getDOMTextNode(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=lexical.$getSelection();if(!lexical.$isRangeSelection(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=N,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=lexical.$getRoot(),d=e||r,g=lexical.$isElementNode(d)?lexical.$getChildCaret(d,t):lexical.$getSiblingCaret(d,t),p=at(d),m=n?lexical.$getAdjacentChildCaret(lexical.$getChildCaretOrSelf(lexical.$getSiblingCaret(n,t))):function(t,e){const n=Ot(lexical.$getSiblingCaret(t,e));return n&&n[0]}(d,t);let h=p;return lexical.makeStepwiseIterator({hasNext:t=>null!==t,initial:g,map:t=>({depth:h,node:t.origin}),step:t=>{if(t.isSameNodeCaret(m))return null;lexical.$isChildCaret(t)&&h++;const e=Ot(t);return !e||e[0].isSameNodeCaret(m)?null:(h+=e[1],e[0])}})}function ft(t){const e=Ot(lexical.$getSiblingCaret(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(lexical.$getChildCaretOrSelf(lexical.$getSiblingCaret(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=>lexical.$isElementNode(t)&&!t.isInline()));return lexical.$isElementNode(e)||L(4,t.__key),e}const ht=(t,e)=>{let n=t;for(;n!==lexical.$getRoot()&&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,lexical.$cloneWithProperties(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;lexical.$setSelection(null===r?null:r.clone());}function wt(t){const o=lexical.$getSelection()||lexical.$getPreviousSelection();if(lexical.$isRangeSelection(o)){const{focus:e}=o,n=e.getNode(),r=e.offset;if(lexical.$isRootOrShadowRoot(n))lexical.$getChildCaretAtIndex(n,r,"next").insert(t),t.selectNext();else {let e,o;lexical.$isTextNode(n)?(e=n.getParentOrThrow(),o=n.getIndexWithinParent(),r>0&&(o+=1,n.splitText(r))):(e=n,o=r);const[,i]=lexical.$splitNode(e,o);i.insertBefore(t),i.selectStart();}}else {if(null!=o){const e=o.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(t);}else lexical.$getRoot().append(t);const e=lexical.$createParagraphNode();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){lexical.$getChildCaret(t,"next").insert(e);}let Ct=!(Y||!V)&&void 0;function Lt(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 Nt(t){return null!==t._parentEditor}function Pt(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,lexical.$isElementNode(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(lexical.$isElementNode(t))for(const e of Rt(t))r.push(e);return n}function Mt(t){return Bt(lexical.$getChildCaret(t,"next"))}function Rt(t){return Bt(lexical.$getChildCaret(t,"previous"))}function Bt(t){return lexical.makeStepwiseIterator({hasNext:lexical.$isSiblingCaret,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function _t(t){lexical.$rewindSiblingCaret(lexical.$getSiblingCaret(t,"next")).splice(1,t.getChildren());}function Ot(t,e="root"){let n=0,o=t,r=lexical.$getAdjacentChildCaret(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=lexical.$getAdjacentChildCaret(o);}return r&&[r,n]}function kt(t){const e=e=>lexical.$getState(e,t),n=(e,n)=>lexical.$setState(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}}
15
15
 
16
16
  Object.defineProperty(exports, "$splitNode", {
17
17
  enumerable: true,
@@ -33,34 +33,48 @@ Object.defineProperty(exports, "isInlineDomNode", {
33
33
  enumerable: true,
34
34
  get: function () { return lexical.isInlineDomNode; }
35
35
  });
36
- exports.$dfs = V;
37
- exports.$filter = ne;
38
- exports.$findMatchingParent = Q;
39
- exports.$getNearestBlockElementAncestorOrThrow = J;
40
- exports.$getNearestNodeOfType = G;
41
- exports.$getNextRightPreorderNode = q;
42
- exports.$insertFirst = oe;
43
- exports.$insertNodeToNearestRoot = Z;
44
- exports.$isEditorIsNestedEditor = le;
45
- exports.$restoreEditorState = Y;
46
- exports.$wrapNodeInElement = ee;
47
- exports.CAN_USE_BEFORE_INPUT = _;
48
- exports.CAN_USE_DOM = K;
49
- exports.IS_ANDROID = O;
50
- exports.IS_ANDROID_CHROME = R;
51
- exports.IS_APPLE = I;
52
- exports.IS_APPLE_WEBKIT = D;
53
- exports.IS_CHROME = H;
54
- exports.IS_FIREFOX = z;
55
- exports.IS_IOS = k;
56
- exports.IS_SAFARI = F;
57
- exports.addClassNamesToElement = $;
58
- exports.calculateZoomLevel = re;
59
- exports.isMimeType = W;
60
- exports.markSelection = B;
61
- exports.mediaFileReader = j;
62
- exports.mergeRegister = b;
63
- exports.objectKlassEquals = te;
64
- exports.positionNodeOnRange = C;
65
- exports.registerNestedElementResolver = X;
66
- exports.removeClassNamesFromElement = U;
36
+ exports.$descendantsMatching = Tt;
37
+ exports.$dfs = it;
38
+ exports.$dfsIterator = ut;
39
+ exports.$filter = St;
40
+ exports.$findMatchingParent = ht;
41
+ exports.$firstToLastIterator = Mt;
42
+ exports.$getAdjacentCaret = lt;
43
+ exports.$getAdjacentSiblingOrParentSiblingCaret = Ot;
44
+ exports.$getDepth = at;
45
+ exports.$getNearestBlockElementAncestorOrThrow = mt;
46
+ exports.$getNearestNodeOfType = pt;
47
+ exports.$getNextRightPreorderNode = dt;
48
+ exports.$getNextSiblingOrParentSibling = ft;
49
+ exports.$insertFirst = At;
50
+ exports.$insertNodeToNearestRoot = wt;
51
+ exports.$isEditorIsNestedEditor = Nt;
52
+ exports.$lastToFirstIterator = Rt;
53
+ exports.$restoreEditorState = yt;
54
+ exports.$reverseDfs = st;
55
+ exports.$reverseDfsIterator = gt;
56
+ exports.$unwrapAndFilterDescendants = Pt;
57
+ exports.$unwrapNode = _t;
58
+ exports.$wrapNodeInElement = xt;
59
+ exports.CAN_USE_BEFORE_INPUT = W;
60
+ exports.CAN_USE_DOM = V;
61
+ exports.IS_ANDROID = G;
62
+ exports.IS_ANDROID_CHROME = q;
63
+ exports.IS_APPLE = J;
64
+ exports.IS_APPLE_WEBKIT = Q;
65
+ exports.IS_CHROME = X;
66
+ exports.IS_FIREFOX = Y;
67
+ exports.IS_IOS = Z;
68
+ exports.IS_SAFARI = tt;
69
+ exports.addClassNamesToElement = et;
70
+ exports.calculateZoomLevel = Lt;
71
+ exports.isMimeType = ot;
72
+ exports.makeStateWrapper = kt;
73
+ exports.markSelection = z;
74
+ exports.mediaFileReader = rt;
75
+ exports.mergeRegister = $;
76
+ exports.objectKlassEquals = Et;
77
+ exports.positionNodeOnRange = j;
78
+ exports.registerNestedElementResolver = vt;
79
+ exports.removeClassNamesFromElement = nt;
80
+ exports.selectionAlwaysOnDisplay = F;
@@ -231,7 +231,7 @@ var prism = require('../../_virtual/prism.js');
231
231
  if (typeof document === 'undefined') {
232
232
  return null;
233
233
  }
234
- if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
234
+ if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) {
235
235
  return /** @type {any} */ (document.currentScript);
236
236
  }
237
237
 
@@ -21,8 +21,8 @@ var react = require('react');
21
21
  var StickyNode = require('../nodes/StickyNode.js');
22
22
  var DraggableBlockPlugin = require('../plugins/DraggableBlockPlugin.js');
23
23
  var StickyPlugin = require('../plugins/StickyPlugin.js');
24
- var theme = require('./theme.js');
25
24
  var ToolbarPlugin = require('../plugins/ToolbarPlugin.js');
25
+ var theme = require('./theme.js');
26
26
  var jsxRuntime = require('react/jsx-runtime');
27
27
 
28
28
  var LexicalEditor = function LexicalEditor(_ref) {
@@ -3,7 +3,7 @@
3
3
  import { $generateHtmlFromNodes, $generateNodesFromDOM } from '../html/LexicalHtml.js';
4
4
  import { $addNodeStyle, $sliceSelectedTextNodeContent } from '../selection/LexicalSelection.js';
5
5
  import { objectKlassEquals } from '../utils/LexicalUtils.js';
6
- import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getRoot, $parseSerializedNode, $isTextNode, COPY_COMMAND, COMMAND_PRIORITY_CRITICAL, isSelectionWithinEditor, $getEditor, $isElementNode, $cloneWithProperties } from 'lexical';
6
+ import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getRoot, $parseSerializedNode, $isTextNode, getDOMSelection, COPY_COMMAND, COMMAND_PRIORITY_CRITICAL, isSelectionWithinEditor, $getEditor, $isElementNode, $cloneWithProperties } from 'lexical';
7
7
 
8
8
  /**
9
9
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -22,17 +22,12 @@ import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIP
22
22
  *
23
23
  */
24
24
 
25
- const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
25
+ // Do not require this module directly! Use normal `invariant` calls.
26
26
 
27
- /**
28
- * Copyright (c) Meta Platforms, Inc. and affiliates.
29
- *
30
- * This source code is licensed under the MIT license found in the
31
- * LICENSE file in the root directory of this source tree.
32
- *
33
- */
27
+ function formatDevErrorMessage(message) {
28
+ throw new Error(message);
29
+ }
34
30
 
35
- const getDOMSelection = targetWindow => CAN_USE_DOM ? (targetWindow || window).getSelection() : null;
36
31
  /**
37
32
  * Returns the *currently selected* Lexical content as an HTML string, relying on the
38
33
  * logic defined in the exportDOM methods on the LexicalNode classes. Note that
@@ -46,7 +41,7 @@ const getDOMSelection = targetWindow => CAN_USE_DOM ? (targetWindow || window).g
46
41
  function $getHtmlContent(editor, selection = $getSelection()) {
47
42
  if (selection == null) {
48
43
  {
49
- throw Error(`Expected valid LexicalSelection`);
44
+ formatDevErrorMessage(`Expected valid LexicalSelection`);
50
45
  }
51
46
  }
52
47
 
@@ -70,7 +65,7 @@ function $getHtmlContent(editor, selection = $getSelection()) {
70
65
  function $getLexicalContent(editor, selection = $getSelection()) {
71
66
  if (selection == null) {
72
67
  {
73
- throw Error(`Expected valid LexicalSelection`);
68
+ formatDevErrorMessage(`Expected valid LexicalSelection`);
74
69
  }
75
70
  }
76
71
 
@@ -119,10 +114,15 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) {
119
114
  }
120
115
  }
121
116
  const htmlString = dataTransfer.getData('text/html');
122
- if (htmlString) {
117
+ const plainString = dataTransfer.getData('text/plain');
118
+
119
+ // Skip HTML handling if it matches the plain text representation.
120
+ // This avoids unnecessary processing for plain text strings created by
121
+ // iOS Safari autocorrect, which incorrectly includes a `text/html` type.
122
+ if (htmlString && plainString !== htmlString) {
123
123
  try {
124
124
  const parser = new DOMParser();
125
- const dom = parser.parseFromString(htmlString, 'text/html');
125
+ const dom = parser.parseFromString(trustHTML(htmlString), 'text/html');
126
126
  const nodes = $generateNodesFromDOM(editor, dom);
127
127
  return $insertGeneratedNodes(editor, nodes, selection);
128
128
  } catch (_unused2) {
@@ -133,7 +133,7 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) {
133
133
  // Multi-line plain text in rich text mode pasted as separate paragraphs
134
134
  // instead of single paragraph with linebreaks.
135
135
  // Webkit-specific: Supports read 'text/uri-list' in clipboard.
136
- const text = dataTransfer.getData('text/plain') || dataTransfer.getData('text/uri-list');
136
+ const text = plainString || dataTransfer.getData('text/uri-list');
137
137
  if (text != null) {
138
138
  if ($isRangeSelection(selection)) {
139
139
  const parts = text.split(/(\r?\n|\t)/);
@@ -158,6 +158,15 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) {
158
158
  }
159
159
  }
160
160
  }
161
+ function trustHTML(html) {
162
+ if (window.trustedTypes && window.trustedTypes.createPolicy) {
163
+ const policy = window.trustedTypes.createPolicy('lexical', {
164
+ createHTML: input => input
165
+ });
166
+ return policy.createHTML(html);
167
+ }
168
+ return html;
169
+ }
161
170
 
162
171
  /**
163
172
  * Inserts Lexical nodes into the editor using different strategies depending on
@@ -183,14 +192,14 @@ function exportNodeToJSON(node) {
183
192
  const nodeClass = node.constructor;
184
193
  if (serializedNode.type !== nodeClass.getType()) {
185
194
  {
186
- throw Error(`LexicalNode: Node ${nodeClass.name} does not implement .exportJSON().`);
195
+ formatDevErrorMessage(`LexicalNode: Node ${nodeClass.name} does not implement .exportJSON().`);
187
196
  }
188
197
  }
189
198
  if ($isElementNode(node)) {
190
199
  const serializedChildren = serializedNode.children;
191
200
  if (!Array.isArray(serializedChildren)) {
192
201
  {
193
- throw Error(`LexicalNode: Node ${nodeClass.name} is an element but .exportJSON() does not have a children array.`);
202
+ formatDevErrorMessage(`LexicalNode: Node ${nodeClass.name} is an element but .exportJSON() does not have a children array.`);
194
203
  }
195
204
  }
196
205
  }
@@ -313,8 +322,9 @@ async function copyToClipboard(editor, event, data) {
313
322
  });
314
323
  }
315
324
  const rootElement = editor.getRootElement();
316
- const windowDocument = editor._window == null ? window.document : editor._window.document;
317
- const domSelection = getDOMSelection(editor._window);
325
+ const editorWindow = editor._window || window;
326
+ const windowDocument = window.document;
327
+ const domSelection = getDOMSelection(editorWindow);
318
328
  if (rootElement === null || domSelection === null) {
319
329
  return false;
320
330
  }
@@ -11,7 +11,7 @@ import * as LexicalClipboard_prod from './LexicalClipboard.prod.js';
11
11
  *
12
12
  */
13
13
 
14
- const mod = process.env.NODE_ENV === 'development' ? LexicalClipboard_dev : LexicalClipboard_prod;
14
+ const mod = process.env.NODE_ENV !== 'production' ? LexicalClipboard_dev : LexicalClipboard_prod;
15
15
  const $getClipboardDataFromSelection = mod.$getClipboardDataFromSelection;
16
16
  const $insertDataTransferForRichText = mod.$insertDataTransferForRichText;
17
17
  const copyToClipboard = mod.copyToClipboard;
@@ -3,7 +3,7 @@
3
3
  import { $generateHtmlFromNodes, $generateNodesFromDOM } from '../html/LexicalHtml.js';
4
4
  import { $addNodeStyle, $sliceSelectedTextNodeContent } from '../selection/LexicalSelection.js';
5
5
  import { objectKlassEquals } from '../utils/LexicalUtils.js';
6
- import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getRoot, $parseSerializedNode, $isTextNode, COPY_COMMAND, COMMAND_PRIORITY_CRITICAL, isSelectionWithinEditor, $getEditor, $isElementNode, $cloneWithProperties } from 'lexical';
6
+ import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getRoot, $parseSerializedNode, $isTextNode, getDOMSelection, COPY_COMMAND, COMMAND_PRIORITY_CRITICAL, isSelectionWithinEditor, $getEditor, $isElementNode, $cloneWithProperties } from 'lexical';
7
7
 
8
8
  /**
9
9
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -13,6 +13,6 @@ import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIP
13
13
  *
14
14
  */
15
15
 
16
- function w(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var y=w((function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const v="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,C=t=>v?(t||window).getSelection():null;function D(e,n=$getSelection()){return null==n&&y(166),$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":$generateHtmlFromNodes(e,n)}function N(t,e=$getSelection()){return null==e&&y(166),$isRangeSelection(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(R(t,e))}function _(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n);}function T(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return S(o,E(t.nodes),n)}}catch(t){}const s=t.getData("text/html");if(s)try{const t=(new DOMParser).parseFromString(s,"text/html");return S(o,$generateNodesFromDOM(o,t),n)}catch(t){}const a=t.getData("text/plain")||t.getData("text/uri-list");if(null!=a)if($isRangeSelection(n)){const t=a.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=$getSelection();if($isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([$createTabNode()]):n.insertText(o);}}}else n.insertRawText(a);}function S(t,e,n){t.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||n.insertNodes(e);}function A(t,e,n,r=[]){let l=null===e||n.isSelected(e);const i=$isElementNode(n)&&n.excludeFromCopy("html");let c=n;if(null!==e){let t=$cloneWithProperties(n);t=$isTextNode(t)&&null!==e?$sliceSelectedTextNodeContent(e,t):t,c=t;}const s=$isElementNode(c)?c.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&y(58,n.name),$isElementNode(t)){const t=e.children;Array.isArray(t)||y(59,n.name);}return e}(c);if($isTextNode(c)){const t=c.__text;t.length>0?a.text=t:l=!1;}for(let o=0;o<s.length;o++){const r=s[o],i=A(t,e,r,a.children);!l&&$isElementNode(n)&&i&&n.extractWithChild(r,e,"clone")&&(l=!0);}if(l&&!i)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return l}function R(t,e){const n=[],o=$getRoot().getChildren();for(let r=0;r<o.length;r++){A(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function E(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],l=$parseSerializedNode(r);$isTextNode(l)&&$addNodeStyle(l),e.push(l);}return e}let O=null;async function P(t,e,n){if(null!==O)return !1;if(null!==e)return new Promise(((o,r)=>{t.update((()=>{o(b(t,e,n));}));}));const o=t.getRootElement(),l=null==t._window?window.document:t._window.document,i=C(t._window);if(null===o||null===i)return !1;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const s=new Range;return s.setStart(c,0),s.setEnd(c,1),i.removeAllRanges(),i.addRange(s),new Promise(((e,o)=>{const i=t.registerCommand(COPY_COMMAND,(o=>(objectKlassEquals(o,ClipboardEvent)&&(i(),null!==O&&(window.clearTimeout(O),O=null),e(b(t,o,n))),!0)),COMMAND_PRIORITY_CRITICAL);O=window.setTimeout((()=>{i(),O=null,e(!1);}),50),l.execCommand("copy"),c.remove();}))}function b(t,e,n){if(void 0===n){const e=C(t._window);if(!e)return !1;const o=e.anchorNode,r=e.focusNode;if(null!==o&&null!==r&&!isSelectionWithinEditor(t,o,r))return !1;const l=$getSelection();if(null===l)return !1;n=M(l);}e.preventDefault();const o=e.clipboardData;return null!==o&&(F(o,n),!0)}const J=[["text/html",D],["application/x-lexical-editor",N]];function M(t=$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=$getEditor();for(const[o,r]of J){const l=r(n,t);null!==l&&(e[o]=l);}}return e}function F(t,e){for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}}
16
+ function y(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.`)}function T(e,n=$getSelection()){return null==n&&y(166),$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":$generateHtmlFromNodes(e,n)}function v(t,e=$getSelection()){return null==e&&y(166),$isRangeSelection(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(R(t,e))}function C(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n);}function D(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return N(o,A(t.nodes),n)}}catch(t){}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return N(o,$generateNodesFromDOM(o,t),n)}catch(t){}const u=a||t.getData("text/uri-list");if(null!=u)if($isRangeSelection(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=$getSelection();if($isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([$createTabNode()]):n.insertText(o);}}}else n.insertRawText(u);}function N(t,e,n){t.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||n.insertNodes(e);}function S(t,e,n,r=[]){let i=null===e||n.isSelected(e);const l=$isElementNode(n)&&n.excludeFromCopy("html");let s=n;if(null!==e){let t=$cloneWithProperties(n);t=$isTextNode(t)&&null!==e?$sliceSelectedTextNodeContent(e,t):t,s=t;}const c=$isElementNode(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&y(58,n.name),$isElementNode(t)){const t=e.children;Array.isArray(t)||y(59,n.name);}return e}(s);if($isTextNode(s)){const t=s.__text;t.length>0?a.text=t:i=!1;}for(let o=0;o<c.length;o++){const r=c[o],l=S(t,e,r,a.children);!i&&$isElementNode(n)&&l&&n.extractWithChild(r,e,"clone")&&(i=!0);}if(i&&!l)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return i}function R(t,e){const n=[],o=$getRoot().getChildren();for(let r=0;r<o.length;r++){S(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function A(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],i=$parseSerializedNode(r);$isTextNode(i)&&$addNodeStyle(i),e.push(i);}return e}let P=null;async function _(t,e,n){if(null!==P)return !1;if(null!==e)return new Promise(((o,r)=>{t.update((()=>{o(E(t,e,n));}));}));const o=t.getRootElement(),i=t._window||window,l=window.document,s=getDOMSelection(i);if(null===o||null===s)return !1;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise(((e,o)=>{const i=t.registerCommand(COPY_COMMAND,(o=>(objectKlassEquals(o,ClipboardEvent)&&(i(),null!==P&&(window.clearTimeout(P),P=null),e(E(t,o,n))),!0)),COMMAND_PRIORITY_CRITICAL);P=window.setTimeout((()=>{i(),P=null,e(!1);}),50),l.execCommand("copy"),c.remove();}))}function E(t,e,n){if(void 0===n){const e=getDOMSelection(t._window);if(!e)return !1;const o=e.anchorNode,r=e.focusNode;if(null!==o&&null!==r&&!isSelectionWithinEditor(t,o,r))return !1;const i=$getSelection();if(null===i)return !1;n=M(i);}e.preventDefault();const o=e.clipboardData;return null!==o&&(O(o,n),!0)}const L=[["text/html",T],["application/x-lexical-editor",v]];function M(t=$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=$getEditor();for(const[o,r]of L){const i=r(n,t);null!==i&&(e[o]=i);}}return e}function O(t,e){for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}}
17
17
 
18
- export { R as $generateJSONFromSelectedNodes, E as $generateNodesFromSerializedNodes, M as $getClipboardDataFromSelection, D as $getHtmlContent, N as $getLexicalContent, _ as $insertDataTransferForPlainText, T as $insertDataTransferForRichText, S as $insertGeneratedNodes, P as copyToClipboard, F as setLexicalClipboardDataTransfer };
18
+ export { R as $generateJSONFromSelectedNodes, A as $generateNodesFromSerializedNodes, M as $getClipboardDataFromSelection, T as $getHtmlContent, v as $getLexicalContent, C as $insertDataTransferForPlainText, D as $insertDataTransferForRichText, N as $insertGeneratedNodes, _ as copyToClipboard, O as setLexicalClipboardDataTransfer };