@react-fabric/lexical 1.0.0-beta.6 → 1.0.0-beta.60

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 (76) hide show
  1. package/{src/editor/Lexical.module.css → css/_lexical.css} +8 -4
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +62 -20
  4. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
  5. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
  6. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +643 -245
  7. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +1 -1
  8. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +29 -22
  9. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +13 -6
  10. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +1 -1
  11. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  12. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +242 -141
  13. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +1 -1
  14. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
  15. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +594 -255
  16. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +1 -1
  17. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +23 -16
  18. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +102 -53
  19. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
  20. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
  21. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +275 -194
  22. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +5 -1
  23. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +28 -18
  24. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +2293 -878
  25. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +1 -1
  26. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +53 -40
  27. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +471 -193
  28. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +13 -1
  29. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -32
  30. package/dist/cjs/node_modules/prismjs/prism.js +1 -1
  31. package/dist/cjs/packages/lexical/src/components/StickyComponent.js +1 -1
  32. package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +30 -5
  33. package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +86 -83
  34. package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +25 -17
  35. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +62 -20
  36. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
  37. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
  38. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +637 -246
  39. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +1 -1
  40. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +4 -4
  41. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +14 -7
  42. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +1 -1
  43. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  44. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +244 -144
  45. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +1 -1
  46. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +4 -4
  47. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +590 -257
  48. package/dist/esm/node_modules/@lexical/list/LexicalList.js +1 -1
  49. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
  50. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +104 -55
  51. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
  52. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
  53. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +267 -196
  54. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +4 -2
  55. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +4 -4
  56. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +2283 -881
  57. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +1 -1
  58. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +4 -4
  59. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +457 -194
  60. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +8 -2
  61. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
  62. package/dist/esm/node_modules/prismjs/prism.js +1 -1
  63. package/dist/esm/packages/lexical/src/components/StickyComponent.js +1 -1
  64. package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +30 -5
  65. package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +88 -85
  66. package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +25 -17
  67. package/dist/types/editor/LexicalEditor.d.ts +25 -0
  68. package/dist/types/hooks/useFormatWatcher.d.ts +2 -2
  69. package/dist/types/nodes/StickyNode.d.ts +0 -1
  70. package/package.json +14 -13
  71. package/src/components/StickyComponent.tsx +2 -2
  72. package/src/editor/LexicalEditor.tsx +57 -26
  73. package/src/hooks/useFormatWatcher.ts +35 -31
  74. package/src/plugins/ToolbarPlugin.tsx +27 -17
  75. package/dist/cjs/editor/Lexical.module.css +0 -1
  76. package/dist/esm/editor/Lexical.module.css +0 -1
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
- import { $isTextNode, $getCharacterOffsets, $isElementNode, $isRootNode, $getNodeByKey, $getPreviousSelection, $createTextNode, $isRangeSelection, $isTokenOrSegmented, $getRoot, $isRootOrShadowRoot, $hasAncestor, $isLeafNode, $setSelection, $getAdjacentNode, $isDecoratorNode, $isLineBreakNode } from 'lexical';
4
- export { $cloneWithProperties } from 'lexical';
3
+ import { $isTextNode, $getEditor, $isRootNode, $isTokenOrSegmented, $getCharacterOffsets, $isElementNode, $getNodeByKey, $getPreviousSelection, $createTextNode, $isRangeSelection, $getSelection, $caretRangeFromSelection, $createRangeSelection, INTERNAL_$isBlock, $setSelection, $isRootOrShadowRoot, $hasAncestor, $isLeafNode, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isChildCaret, $isDecoratorNode } from 'lexical';
4
+ export { $cloneWithProperties, $selectAll } from 'lexical';
5
5
 
6
6
  /**
7
7
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -11,6 +11,6 @@ export { $cloneWithProperties } from 'lexical';
11
11
  *
12
12
  */
13
13
 
14
- function m(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T=m((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 x=new Map;function S(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild;}return null}function v(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return [t,Array.from(t.childNodes).indexOf(e)]}function C(t,n,l,o,r){const s=n.getKey(),i=o.getKey(),c=document.createRange();let f=t.getElementByKey(s),u=t.getElementByKey(i),g=l,a=r;if($isTextNode(n)&&(f=S(f)),$isTextNode(o)&&(u=S(u)),void 0===n||void 0===o||null===f||null===u)return null;"BR"===f.nodeName&&([f,g]=v(f)),"BR"===u.nodeName&&([u,a]=v(u));const d=f.firstChild;f===u&&null!=d&&"BR"===d.nodeName&&0===g&&0===a&&(a=1);try{c.setStart(f,g),c.setEnd(u,a);}catch(e){return null}return !c.collapsed||g===a&&s===i||(c.setStart(u,a),c.setEnd(f,g)),c}function P(e,t){const n=e.getRootElement();if(null===n)return [];const l=n.getBoundingClientRect(),o=getComputedStyle(n),r=parseFloat(o.paddingLeft)+parseFloat(o.paddingRight),s=Array.from(t.getClientRects());let i,c=s.length;s.sort(((e,t)=>{const n=e.top-t.top;return Math.abs(n)<=3?e.left-t.left:n}));for(let e=0;e<c;e++){const t=s[e],n=i&&i.top<=t.top&&i.top+i.height>t.top&&i.left+i.width>t.left,o=t.width+r===l.width;n||o?(s.splice(e--,1),c--):i=t;}return s}function w(e){const t={},n=e.split(";");for(const e of n)if(""!==e){const[n,l]=e.split(/:([^]+)/);n&&l&&(t[n.trim()]=l.trim());}return t}function N(e){let t=x.get(e);return void 0===t&&(t=w(e),x.set(e,t)),t}function E(e,n){const l=e.getStartEndPoints();if(n.isSelected(e)&&!n.isSegmented()&&!n.isToken()&&null!==l){const[o,r]=l,s=e.isBackward(),i=o.getNode(),c=r.getNode(),f=n.is(i),u=n.is(c);if(f||u){const[l,o]=$getCharacterOffsets(e),r=i.is(c),f=n.is(s?c:i),u=n.is(s?i:c);let g,a=0;if(r)a=l>o?o:l,g=l>o?l:o;else if(f){a=s?o:l,g=void 0;}else if(u){a=0,g=s?l:o;}return n.__text=n.__text.slice(a,g),n}}return n}function F(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return $isElementNode(t)||T(177),e.offset===t.getChildrenSize()}function K(t,c,f){let u=c.getNode(),g=f;if($isElementNode(u)){const e=u.getDescendantByIndex(c.offset);null!==e&&(u=e);}for(;g>0&&null!==u;){if($isElementNode(u)){const e=u.getLastDescendant();null!==e&&(u=e);}let f=u.getPreviousSibling(),a=0;if(null===f){let e=u.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){f=null;break}t=e.getPreviousSibling();}null!==e&&(a=e.isInline()?0:2,f=t);}let d=u.getTextContent();""===d&&$isElementNode(u)&&!u.isInline()&&(d="\n\n");const p=d.length;if(!$isTextNode(u)||g>=p){const e=u.getParent();u.remove(),null==e||0!==e.getChildrenSize()||$isRootNode(e)||e.remove(),g-=p+a,u=f;}else {const n=u.getKey(),l=t.getEditorState().read((()=>{const t=$getNodeByKey(n);return $isTextNode(t)&&t.isSimpleText()?t.getTextContent():null})),f=p-g,a=d.slice(0,f);if(null!==l&&l!==d){const e=$getPreviousSelection();let t=u;if(u.isSimpleText())u.setTextContent(l);else {const e=$createTextNode(l);u.replace(e),t=e;}if($isRangeSelection(e)&&e.isCollapsed()){const n=e.anchor.offset;t.select(n,n);}}else if(u.isSimpleText()){const e=c.key===n;let t=c.offset;t<g&&(t=p);const l=e?t-g:0,o=e?t:f;if(e&&0===l){const[e]=u.splitText(l,o);e.remove();}else {const[,e]=u.splitText(l,o);e.remove();}}else {const e=$createTextNode(a);u.replace(e);}g=0;}}}function I(e){const t=e.getStyle(),n=w(t);x.set(t,n);}function O(e,t){const n=N("getStyle"in e?e.getStyle():e.style),l=Object.entries(t).reduce(((t,[l,o])=>("function"==typeof o?t[l]=o(n[l],e):null===o?delete t[l]:t[l]=o,t)),{...n}||{}),o=function(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}(l);e.setStyle(o),x.set(o,l);}function B(t,n){const l=t.getNodes(),o=l.length,r=t.getStartEndPoints();if(null===r)return;const[s,f]=r,u=o-1;let g=l[0],a=l[u];if(t.isCollapsed()&&$isRangeSelection(t))return void O(t,n);const d=g.getTextContent().length,p=f.offset;let h=s.offset;const y=s.isBefore(f);let m=y?h:p,T=y?p:h;const x=y?s.type:f.type,S=y?f.type:s.type,v=y?f.key:s.key;if($isTextNode(g)&&m===d){const t=g.getNextSibling();$isTextNode(t)&&(h=0,m=0,g=t);}if(1===l.length){if($isTextNode(g)&&g.canHaveFormat()){if(m="element"===x?0:h>p?p:h,T="element"===S?d:h>p?h:p,m===T)return;if($isTokenOrSegmented(g)||0===m&&T===d)O(g,n),g.select(m,T);else {const e=g.splitText(m,T),t=0===m?e[0]:e[1];O(t,n),t.select(0,T-m);}}}else {if($isTextNode(g)&&m<g.getTextContentSize()&&g.canHaveFormat()&&(0===m||$isTokenOrSegmented(g)||(g=g.splitText(m)[1],m=0,y?s.set(g.getKey(),m,"text"):f.set(g.getKey(),m,"text")),O(g,n)),$isTextNode(a)&&a.canHaveFormat()){const e=a.getTextContent().length;a.__key!==v&&0!==T&&(T=e),T===e||$isTokenOrSegmented(a)||([a]=a.splitText(T)),0===T&&"element"!==S||O(a,n);}for(let t=1;t<u;t++){const o=l[t],r=o.getKey();$isTextNode(o)&&o.canHaveFormat()&&r!==g.getKey()&&r!==a.getKey()&&!o.isToken()&&O(o,n);}}}function k(e,t){if(null===e)return;const l=e.getStartEndPoints(),o=l?l[0]:null;if(null!==o&&"root"===o.key){const e=t(),n=$getRoot(),l=n.getFirstChild();return void(l?l.replace(e,!0):n.append(e))}const r=e.getNodes(),s=null!==o&&function(e,t){let n=e;for(;null!==n&&null!==n.getParent()&&!t(n);)n=n.getParentOrThrow();return t(n)?n:null}(o.getNode(),U);s&&-1===r.indexOf(s)&&r.push(s);for(let e=0;e<r.length;e++){const l=r[e];if(!U(l))continue;$isElementNode(l)||T(178);const o=t();o.setFormat(l.getFormatType()),o.setIndent(l.getIndent()),l.replace(o,!0);}}function b(e){return e.getNode().isAttached()}function R(e){let t=e;for(;null!==t&&!$isRootOrShadowRoot(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n;}}function _(e,t,n=null){const l=e.getStartEndPoints(),o=l?l[0]:null,r=e.getNodes(),s=r.length;if(null!==o&&(0===s||1===s&&"element"===o.type&&0===o.getNode().getChildrenSize())){const e="text"===o.type?o.getNode().getParentOrThrow():o.getNode(),l=e.getChildren();let r=t();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),l.forEach((e=>r.append(e))),n&&(r=n.append(r)),void e.replace(r)}let i=null,c=[];for(let l=0;l<s;l++){const o=r[l];$isRootOrShadowRoot(o)?(z(e,c,c.length,t,n),c=[],i=o):null===i||null!==i&&$hasAncestor(o,i)?c.push(o):(z(e,c,c.length,t,n),c=[o]);}z(e,c,c.length,t,n);}function z(e,t,l,o,s=null){if(0===t.length)return;const c=t[0],f=new Map,g=[];let p=$isElementNode(c)?c:c.getParentOrThrow();p.isInline()&&(p=p.getParentOrThrow());let h=!1;for(;null!==p;){const e=p.getPreviousSibling();if(null!==e){p=e,h=!0;break}if(p=p.getParentOrThrow(),$isRootOrShadowRoot(p))break}const y=new Set;for(let e=0;e<l;e++){const l=t[e];$isElementNode(l)&&0===l.getChildrenSize()&&y.add(l.getKey());}const m=new Set;for(let e=0;e<l;e++){const l=t[e];let r=l.getParent();if(null!==r&&r.isInline()&&(r=r.getParent()),null!==r&&$isLeafNode(l)&&!m.has(l.getKey())){const e=r.getKey();if(void 0===f.get(e)){const t=o();t.setFormat(r.getFormatType()),t.setIndent(r.getIndent()),g.push(t),f.set(e,t),r.getChildren().forEach((e=>{t.append(e),m.add(e.getKey()),$isElementNode(e)&&e.getChildrenKeys().forEach((e=>m.add(e)));})),R(r);}}else if(y.has(l.getKey())){$isElementNode(l)||T(179);const e=o();e.setFormat(l.getFormatType()),e.setIndent(l.getIndent()),g.push(e),l.remove(!0);}}if(null!==s)for(let e=0;e<g.length;e++){const t=g[e];s.append(t);}let x=null;if($isRootOrShadowRoot(p))if(h)if(null!==s)p.insertAfter(s);else for(let e=g.length-1;e>=0;e--){const t=g[e];p.insertAfter(t);}else {const e=p.getFirstChild();if($isElementNode(e)&&(p=e),null===e)if(s)p.append(s);else for(let e=0;e<g.length;e++){const t=g[e];p.append(t),x=t;}else if(null!==s)e.insertBefore(s);else for(let t=0;t<g.length;t++){const n=g[t];e.insertBefore(n),x=n;}}else if(s)p.insertAfter(s);else for(let e=g.length-1;e>=0;e--){const t=g[e];p.insertAfter(t),x=t;}const S=$getPreviousSelection();$isRangeSelection(S)&&b(S.anchor)&&b(S.focus)?$setSelection(S.clone()):null!==x?x.selectEnd():e.dirty=!0;}function A(e,t){const l=$getAdjacentNode(e.focus,t);return $isDecoratorNode(l)&&!l.isIsolated()||$isElementNode(l)&&!l.isInline()&&!l.canBeEmpty()}function L(e,t,n,l){e.modify(t?"extend":"move",n,l);}function D(e){const t=e.anchor.getNode();return "rtl"===($isRootNode(t)?t:t.getParentOrThrow()).getDirection()}function M(e,t,n){const l=D(e);L(e,t,n?!l:l,"character");}function $(t){const l=t.anchor,o=t.focus,r=l.getNode().getTopLevelElementOrThrow().getParentOrThrow();let s=r.getFirstDescendant(),i=r.getLastDescendant(),c="element",f="element",u=0;$isTextNode(s)?c="text":$isElementNode(s)||null===s||(s=s.getParentOrThrow()),$isTextNode(i)?(f="text",u=i.getTextContentSize()):$isElementNode(i)||null===i||(i=i.getParentOrThrow()),s&&i&&(l.set(s.getKey(),0,c),o.set(i.getKey(),u,f));}function H(e,t,n){const l=N(e.getStyle());return null!==l&&l[t]||n}function j(t,n,l=""){let o=null;const r=t.getNodes(),s=t.anchor,c=t.focus,f=t.isBackward(),u=f?c.offset:s.offset,g=f?c.getNode():s.getNode();if($isRangeSelection(t)&&t.isCollapsed()&&""!==t.style){const e=N(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t<r.length;t++){const s=r[t];if((0===t||0!==u||!s.is(g))&&$isTextNode(s)){const e=H(s,n,l);if(null===o)o=e;else if(o!==e){o="";break}}}return null===o?l:o}function U(t){if($isDecoratorNode(t))return !1;if(!$isElementNode(t)||$isRootOrShadowRoot(t))return !1;const l=t.getFirstChild(),o=null===l||$isLineBreakNode(l)||$isTextNode(l)||l.isInline();return !t.isInline()&&!1!==t.canBeEmpty()&&o}const W=K;
14
+ 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 C=new Map;function P(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild;}return null}function K(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return [t,Array.from(t.childNodes).indexOf(e)]}function E(t,n,o,l,r){const s=n.getKey(),i=l.getKey(),c=document.createRange();let f=t.getElementByKey(s),u=t.getElementByKey(i),g=o,a=r;if($isTextNode(n)&&(f=P(f)),$isTextNode(l)&&(u=P(u)),void 0===n||void 0===l||null===f||null===u)return null;"BR"===f.nodeName&&([f,g]=K(f)),"BR"===u.nodeName&&([u,a]=K(u));const d=f.firstChild;f===u&&null!=d&&"BR"===d.nodeName&&0===g&&0===a&&(a=1);try{c.setStart(f,g),c.setEnd(u,a);}catch(e){return null}return !c.collapsed||g===a&&s===i||(c.setStart(u,a),c.setEnd(f,g)),c}function k(e,t){const n=e.getRootElement();if(null===n)return [];const o=n.getBoundingClientRect(),l=getComputedStyle(n),r=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight),s=Array.from(t.getClientRects());let i,c=s.length;s.sort(((e,t)=>{const n=e.top-t.top;return Math.abs(n)<=3?e.left-t.left:n}));for(let e=0;e<c;e++){const t=s[e],n=i&&i.top<=t.top&&i.top+i.height>t.top&&i.left+i.width>t.left,l=t.width+r===o.width;n||l?(s.splice(e--,1),c--):i=t;}return s}function I(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim());}return t}function B(e){let t=C.get(e);return void 0===t&&(t=I(e),C.set(e,t)),t}function F(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function b(e){const n=$getEditor().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function O(e){return b($isRootNode(e)?e:e.getParentOrThrow())}function R(e){const t=O(e);return null!==t&&"rtl"===t.direction}function z(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!$isTokenOrSegmented(t)&&null!==n){const[o,r]=n,s=e.isBackward(),i=o.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[n,o]=$getCharacterOffsets(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let g,a=0;if(r)a=n>o?o:n,g=n>o?n:o;else if(f){a=s?o:n,g=void 0;}else if(u){a=0,g=s?n:o;}t.__text=t.__text.slice(a,g);}}return t}function A(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return $isElementNode(t)||N(177),e.offset===t.getChildrenSize()}function M(t,o,l){let u=o.getNode(),g=l;if($isElementNode(u)){const e=u.getDescendantByIndex(o.offset);null!==e&&(u=e);}for(;g>0&&null!==u;){if($isElementNode(u)){const e=u.getLastDescendant();null!==e&&(u=e);}let l=u.getPreviousSibling(),a=0;if(null===l){let e=u.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){l=null;break}t=e.getPreviousSibling();}null!==e&&(a=e.isInline()?0:2,l=t);}let d=u.getTextContent();""===d&&$isElementNode(u)&&!u.isInline()&&(d="\n\n");const p=d.length;if(!$isTextNode(u)||g>=p){const e=u.getParent();u.remove(),null==e||0!==e.getChildrenSize()||$isRootNode(e)||e.remove(),g-=p+a,u=l;}else {const n=u.getKey(),l=t.getEditorState().read((()=>{const t=$getNodeByKey(n);return $isTextNode(t)&&t.isSimpleText()?t.getTextContent():null})),r=p-g,a=d.slice(0,r);if(null!==l&&l!==d){const e=$getPreviousSelection();let t=u;if(u.isSimpleText())u.setTextContent(l);else {const e=$createTextNode(l);u.replace(e),t=e;}if($isRangeSelection(e)&&e.isCollapsed()){const n=e.anchor.offset;t.select(n,n);}}else if(u.isSimpleText()){const e=o.key===n;let t=o.offset;t<g&&(t=p);const l=e?t-g:0,s=e?t:r;if(e&&0===l){const[e]=u.splitText(l,s);e.remove();}else {const[,e]=u.splitText(l,s);e.remove();}}else {const e=$createTextNode(a);u.replace(e);}g=0;}}}function L(e){const t=e.getStyle(),n=I(t);C.set(t,n);}function $(t,n){($isRangeSelection(t)?t.isCollapsed():$isTextNode(t)||$isElementNode(t))||N(280);const o=B($isRangeSelection(t)?t.style:$isTextNode(t)?t.getStyle():t.getTextStyle()),l=Object.entries(n).reduce(((e,[n,l])=>("function"==typeof l?e[n]=l(o[n],t):null===l?delete e[n]:e[n]=l,e)),{...o}),s=F(l);$isRangeSelection(t)||$isTextNode(t)?t.setStyle(s):t.setTextStyle(s),C.set(s,l);}function _(e,t){if($isRangeSelection(e)&&e.isCollapsed()){$(e,t);const n=e.anchor.getNode();$isElementNode(n)&&n.isEmpty()&&$(n,t);}D((e=>{$(e,t);}));}function D(t){const n=$getSelection();if(!n)return;const l=new Map;if($isRangeSelection(n))for(const e of $caretRangeFromSelection(n).getTextSlices())e&&l.set(e.caret.origin.getKey(),e.getSliceIndices());const r=n.getNodes();for(const n of r){if(!$isTextNode(n)||!n.canHaveFormat())continue;const[r,i]=(s=n,l.get(s.getKey())||[0,s.getTextContentSize()]);if(i!==r)if($isTokenOrSegmented(n)||0===r&&i===n.getTextContentSize())t(n);else {t(n.splitText(r,i)[0===r?0:1]);}}var s;$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&U(n);}function U(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:l,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,l,r);}}function j(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o);}function H(e,t,n=j){if(null===e)return;const o=e.getStartEndPoints(),l=new Map;let s=null;if(o){const[e,t]=o;s=$createRangeSelection(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=oe(e.getNode(),INTERNAL_$isBlock),i=oe(t.getNode(),INTERNAL_$isBlock);$isElementNode(n)&&l.set(n.getKey(),n),$isElementNode(i)&&l.set(i.getKey(),i);}for(const t of e.getNodes())if($isElementNode(t)&&INTERNAL_$isBlock(t))l.set(t.getKey(),t);else if(null===o){const e=oe(t,INTERNAL_$isBlock);$isElementNode(e)&&l.set(e.getKey(),e);}for(const[e,o]of l){const l=t();n(o,l),o.replace(l,!0),s&&(e===s.anchor.key&&s.anchor.set(l.getKey(),s.anchor.offset,s.anchor.type),e===s.focus.key&&s.focus.set(l.getKey(),s.focus.offset,s.focus.type));}s&&e.is($getSelection())&&$setSelection(s);}function V(e){return e.getNode().isAttached()}function W(e){let t=e;for(;null!==t&&!$isRootOrShadowRoot(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n;}}function X(e,t,n=null){const o=e.getStartEndPoints(),l=o?o[0]:null,r=e.getNodes(),s=r.length;if(null!==l&&(0===s||1===s&&"element"===l.type&&0===l.getNode().getChildrenSize())){const e="text"===l.type?l.getNode().getParentOrThrow():l.getNode(),o=e.getChildren();let r=t();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),o.forEach((e=>r.append(e))),n&&(r=n.append(r)),void e.replace(r)}let i=null,c=[];for(let o=0;o<s;o++){const l=r[o];$isRootOrShadowRoot(l)?(q(e,c,c.length,t,n),c=[],i=l):null===i||null!==i&&$hasAncestor(l,i)?c.push(l):(q(e,c,c.length,t,n),c=[l]);}q(e,c,c.length,t,n);}function q(e,t,n,o,l=null){if(0===t.length)return;const s=t[0],c=new Map,u=[];let g=$isElementNode(s)?s:s.getParentOrThrow();g.isInline()&&(g=g.getParentOrThrow());let a=!1;for(;null!==g;){const e=g.getPreviousSibling();if(null!==e){g=e,a=!0;break}if(g=g.getParentOrThrow(),$isRootOrShadowRoot(g))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];$isElementNode(n)&&0===n.getChildrenSize()&&d.add(n.getKey());}const y=new Set;for(let e=0;e<n;e++){const n=t[e];let l=n.getParent();if(null!==l&&l.isInline()&&(l=l.getParent()),null!==l&&$isLeafNode(n)&&!y.has(n.getKey())){const e=l.getKey();if(void 0===c.get(e)){const t=o();t.setFormat(l.getFormatType()),t.setIndent(l.getIndent()),u.push(t),c.set(e,t),l.getChildren().forEach((e=>{t.append(e),y.add(e.getKey()),$isElementNode(e)&&e.getChildrenKeys().forEach((e=>y.add(e)));})),W(l);}}else if(d.has(n.getKey())){$isElementNode(n)||N(179);const e=o();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),u.push(e),n.remove(!0);}}if(null!==l)for(let e=0;e<u.length;e++){const t=u[e];l.append(t);}let S=null;if($isRootOrShadowRoot(g))if(a)if(null!==l)g.insertAfter(l);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t);}else {const e=g.getFirstChild();if($isElementNode(e)&&(g=e),null===e)if(l)g.append(l);else for(let e=0;e<u.length;e++){const t=u[e];g.append(t),S=t;}else if(null!==l)e.insertBefore(l);else for(let t=0;t<u.length;t++){const n=u[t];e.insertBefore(n),S=n;}}else if(l)g.insertAfter(l);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t),S=t;}const x=$getPreviousSelection();$isRangeSelection(x)&&V(x.anchor)&&V(x.focus)?$setSelection(x.clone()):null!==S?S.selectEnd():e.dirty=!0;}function G(e){const t=J(e);return null!==t&&"vertical-rl"===t.writingMode}function J(e){const t=e.anchor.getNode();return $isElementNode(t)?b(t):O(t)}function Q(e,t){let n=G(e)?!t:t;Z(e)&&(n=!n);const o=$caretFromPoint(e.focus,n?"previous":"next");if($isExtendableTextPointCaret(o))return !1;for(const e of $extendCaretToRange(o)){if($isChildCaret(e))return !e.origin.isInline();if(!$isElementNode(e.origin)){if($isDecoratorNode(e.origin))return !0;break}}return !1}function Y(e,t,n,o){e.modify(t?"extend":"move",n,o);}function Z(e){const t=J(e);return null!==t&&"rtl"===t.direction}function ee(e,t,n){const o=Z(e);let l;l=G(e)||o?!n:n,Y(e,t,l,"character");}function te(e,t,n){const o=B(e.getStyle());return null!==o&&o[t]||n}function ne(t,n,o=""){let l=null;const r=t.getNodes(),s=t.anchor,i=t.focus,c=t.isBackward(),u=c?i.offset:s.offset,g=c?i.getNode():s.getNode();if($isRangeSelection(t)&&t.isCollapsed()&&""!==t.style){const e=B(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t<r.length;t++){const s=r[t];if((0===t||0!==u||!s.is(g))&&$isTextNode(s)){const e=te(s,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l}function oe(e,t){let n=e;for(;null!==n&&null!==n.getParent()&&!t(n);)n=n.getParentOrThrow();return t(n)?n:null}const le=M;
15
15
 
16
- export { I as $addNodeStyle, j as $getSelectionStyleValueForProperty, F as $isAtNodeEnd, D as $isParentElementRTL, L as $moveCaretSelection, M as $moveCharacter, B as $patchStyleText, $ as $selectAll, k as $setBlocksType, A as $shouldOverrideDefaultCharacterSelection, E as $sliceSelectedTextNodeContent, K as $trimTextContentFromAnchor, _ as $wrapNodes, C as createDOMRange, P as createRectsFromDOMRange, N as getStyleObjectFromCSS, W as trimTextContentFromAnchor };
16
+ export { L as $addNodeStyle, j as $copyBlockFormatIndent, U as $ensureForwardRangeSelection, D as $forEachSelectedTextNode, b as $getComputedStyleForElement, O as $getComputedStyleForParent, ne as $getSelectionStyleValueForProperty, A as $isAtNodeEnd, Z as $isParentElementRTL, R as $isParentRTL, Y as $moveCaretSelection, ee as $moveCharacter, _ as $patchStyleText, H as $setBlocksType, Q as $shouldOverrideDefaultCharacterSelection, z as $sliceSelectedTextNodeContent, M as $trimTextContentFromAnchor, X as $wrapNodes, E as createDOMRange, k as createRectsFromDOMRange, F as getCSSFromStyleObject, B as getStyleObjectFromCSS, le as trimTextContentFromAnchor };