@react-fabric/lexical 1.0.0-beta.57 → 1.0.0-beta.58

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 (48) hide show
  1. package/css/_lexical.css +4 -0
  2. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +33 -1
  3. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
  4. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +525 -194
  5. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +26 -23
  6. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +3 -3
  7. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  8. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +95 -38
  9. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
  10. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +387 -124
  11. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +22 -18
  12. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +54 -29
  13. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
  14. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +107 -8
  15. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +4 -0
  16. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +23 -20
  17. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +420 -137
  18. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +50 -45
  19. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +61 -65
  20. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +2 -0
  21. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -46
  22. package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
  23. package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
  24. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +34 -2
  25. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
  26. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +524 -196
  27. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +3 -3
  28. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +4 -4
  29. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  30. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +96 -40
  31. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +3 -3
  32. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +387 -127
  33. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
  34. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +56 -31
  35. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
  36. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +106 -10
  37. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +3 -1
  38. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +3 -3
  39. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +417 -139
  40. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +3 -3
  41. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +62 -67
  42. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +2 -1
  43. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
  44. package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
  45. package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
  46. package/package.json +12 -12
  47. package/src/hooks/useFormatWatcher.ts +3 -1
  48. package/src/plugins/ToolbarPlugin.tsx +5 -10
@@ -2,6 +2,7 @@
2
2
 
3
3
  var LexicalUtils = require('../utils/LexicalUtils.js');
4
4
  var lexical = require('lexical');
5
+ var LexicalSelection = require('../selection/LexicalSelection.js');
5
6
 
6
7
  /**
7
8
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -11,22 +12,25 @@ var lexical = require('lexical');
11
12
  *
12
13
  */
13
14
 
14
- function v(t,...e){const r=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",t);for(const t of e)n.append("v",t);throw r.search=n.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function k(t){let e=1,r=t.getParent();for(;null!=r;){if($(r)){const t=r.getParent();if(Y(t)){e++,r=t.getParent();continue}v(40);}return e}return e}function b(t){let e=t.getParent();Y(e)||v(40);let r=e;for(;null!==r;)r=r.getParent(),Y(r)&&(e=r);return e}function N(t){let e=[];const r=t.getChildren().filter($);for(let t=0;t<r.length;t++){const n=r[t],s=n.getFirstChild();Y(s)?e=e.concat(N(s)):e.push(n);}return e}function F(t){return $(t)&&Y(t.getFirstChild())}function O(t){return z().append(t)}function P(t,e){return $(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function A(t){const e=lexical.$getSelection();if(null!==e){let r=e.getNodes();if(lexical.$isRangeSelection(e)){const n=e.getStartEndPoints();null===n&&v(143);const[s]=n,i=s.getNode(),o=i.getParent();if(lexical.$isRootOrShadowRoot(i)){const t=i.getFirstChild();if(t)r=t.selectStart().getNodes();else {const t=lexical.$createParagraphNode();i.append(t),r=t.select().getNodes();}}else if(P(i,r)){const e=X(t);if(lexical.$isRootOrShadowRoot(o)){i.replace(e);const t=z();lexical.$isElementNode(i)&&(t.setFormat(i.getFormatType()),t.setIndent(i.getIndent())),e.append(t);}else if($(i)){const t=i.getParentOrThrow();L(e,t.getChildren()),t.replace(e);}return}}const n=new Set;for(let e=0;e<r.length;e++){const s=r[e];if(!lexical.$isElementNode(s)||!s.isEmpty()||$(s)||n.has(s.getKey())){if(lexical.$isLeafNode(s)){let e=s.getParent();for(;null!=e;){const r=e.getKey();if(Y(e)){if(!n.has(r)){const s=X(t);L(s,e.getChildren()),e.replace(s),n.add(r);}break}{const s=e.getParent();if(lexical.$isRootOrShadowRoot(s)&&!n.has(r)){n.add(r),E(e,t);break}e=s;}}}}else E(s,t);}}}function L(t,e){t.splice(t.getChildrenSize(),0,e);}function E(t,e){if(Y(t))return t;const r=t.getPreviousSibling(),n=t.getNextSibling(),s=z();let i;if(L(s,t.getChildren()),Y(r)&&e===r.getListType())r.append(s),Y(n)&&e===n.getListType()&&(L(r,n.getChildren()),n.remove()),i=r;else if(Y(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else {const r=X(e);r.append(s),t.replace(r),i=r;}return s.setFormat(t.getFormatType()),s.setIndent(t.getIndent()),t.remove(),i}function M(t,e){const r=t.getLastChild(),n=e.getFirstChild();r&&n&&F(r)&&F(n)&&(M(r.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&t.append(...s),e.remove();}function w(){const e=lexical.$getSelection();if(lexical.$isRangeSelection(e)){const r=new Set,n=e.getNodes(),s=e.anchor.getNode();if(P(s,n))r.add(b(s));else for(let e=0;e<n.length;e++){const s=n[e];if(lexical.$isLeafNode(s)){const e=LexicalUtils.$getNearestNodeOfType(s,W);null!=e&&r.add(b(e));}}for(const t of r){let r=t;const n=N(t);for(const t of n){const n=lexical.$createParagraphNode().setTextStyle(e.style).setTextFormat(e.format);L(n,t.getChildren()),r.insertAfter(n),r=n,t.__key===e.anchor.key&&lexical.$setPointFromCaret(e.anchor,lexical.$normalizeCaret(lexical.$getChildCaret(n,"next"))),t.__key===e.focus.key&&lexical.$setPointFromCaret(e.focus,lexical.$normalizeCaret(lexical.$getChildCaret(n,"next"))),t.remove();}t.remove();}}}function I(t){const e=new Set;if(F(t)||e.has(t.getKey()))return;const r=t.getParent(),n=t.getNextSibling(),s=t.getPreviousSibling();if(F(n)&&F(s)){const r=s.getFirstChild();if(Y(r)){r.append(t);const s=n.getFirstChild();if(Y(s)){L(r,s.getChildren()),n.remove(),e.add(n.getKey());}}}else if(F(n)){const e=n.getFirstChild();if(Y(e)){const r=e.getFirstChild();null!==r&&r.insertBefore(t);}}else if(F(s)){const e=s.getFirstChild();Y(e)&&e.append(t);}else if(Y(r)){const e=z().setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle()),i=X(r.getListType()).setTextFormat(r.getTextFormat()).setTextStyle(r.getTextStyle());e.append(i),i.append(t),s?s.insertAfter(e):n?n.insertBefore(e):r.append(e);}}function D(t){if(F(t))return;const e=t.getParent(),r=e?e.getParent():void 0;if(Y(r?r.getParent():void 0)&&$(r)&&Y(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(t.is(n))r.insertBefore(t),e.isEmpty()&&r.remove();else if(t.is(s))r.insertAfter(t),e.isEmpty()&&r.remove();else {const n=e.getListType(),s=z(),i=X(n);s.append(i),t.getPreviousSiblings().forEach((t=>i.append(t)));const o=z(),l=X(n);o.append(l),L(l,t.getNextSiblings()),r.insertBefore(s),r.insertAfter(o),r.replace(t);}}}function J(){const t=lexical.$getSelection();if(!lexical.$isRangeSelection(t)||!t.isCollapsed())return !1;const e=t.anchor.getNode();if(!$(e)||0!==e.getChildrenSize())return !1;const r=b(e),n=e.getParent();Y(n)||v(40);const s=n.getParent();let a;if(lexical.$isRootOrShadowRoot(s))a=lexical.$createParagraphNode(),r.insertAfter(a);else {if(!$(s))return !1;a=z(),s.insertAfter(a);}a.setTextStyle(t.style).setTextFormat(t.format).select();const h=e.getNextSiblings();if(h.length>0){const t=X(n.getListType());if($(a)){const e=z();e.append(t),a.insertAfter(e);}else a.insertAfter(t);t.append(...h);}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!$(t)&&!Y(t))break;e=t;}e.remove();}(e),!0}function R(...t){const e=[];for(const r of t)if(r&&"string"==typeof r)for(const[t]of r.matchAll(/\S+/g))e.push(t);return e}class W extends lexical.ElementNode{static getType(){return "listitem"}static clone(t){return new W(t.__value,t.__checked,t.__key)}constructor(t,e,r){super(r),this.__value=void 0===t?1:t,this.__checked=e;}createDOM(t){const e=document.createElement("li"),r=this.getParent();Y(r)&&"check"===r.getListType()&&K(e,this,null),e.value=this.__value,B(e,t.theme,this);const n=this.__style||this.__textStyle;return n&&(e.style.cssText=n),e}updateDOM(t,e,r){const n=this.getParent();Y(n)&&"check"===n.getListType()&&K(e,this,t),e.value=this.__value,B(e,r.theme,this);const s=t.__style||t.__textStyle,i=this.__style||this.__textStyle;return s!==i&&(e.style.cssText=i,""===i&&e.removeAttribute("style")),!1}static transform(){return t=>{if($(t)||v(144),null==t.__checked)return;const e=t.getParent();Y(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0);}}static importDOM(){return {li:()=>({conversion:V,priority:0})}}static importJSON(t){return z().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setValue(t.value).setChecked(t.checked)}exportDOM(t){const e=this.createDOM(t._config);e.style.textAlign=this.getFormatType();const r=this.getDirection();return r&&(e.dir=r),{element:e}}exportJSON(){return {...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...t){for(let e=0;e<t.length;e++){const r=t[e];if(lexical.$isElementNode(r)&&this.canMergeWith(r)){const t=r.getChildren();this.append(...t),r.remove();}else super.append(r);}return this}replace(t,e){if($(t))return super.replace(t);this.setIndent(0);const r=this.getParentOrThrow();if(!Y(r))return t;if(r.__first===this.getKey())r.insertBefore(t);else if(r.__last===this.getKey())r.insertAfter(t);else {const e=X(r.getListType());let n=this.getNextSibling();for(;n;){const t=n;n=n.getNextSibling(),e.append(t);}r.insertAfter(t),t.insertAfter(e);}return e&&(lexical.$isElementNode(t)||v(139),this.getChildren().forEach((e=>{t.append(e);}))),this.remove(),0===r.getChildrenSize()&&r.remove(),t}insertAfter(t,e=!0){const r=this.getParentOrThrow();if(Y(r)||v(39),$(t))return super.insertAfter(t,e);const n=this.getNextSiblings();if(r.insertAfter(t,e),0!==n.length){const s=X(r.getListType());n.forEach((t=>s.append(t))),t.insertAfter(s,e);}return t}remove(t){const e=this.getPreviousSibling(),r=this.getNextSibling();super.remove(t),e&&r&&F(e)&&F(r)&&(M(e.getFirstChild(),r.getFirstChild()),r.remove());}insertNewAfter(t,e=!0){const r=z().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(r,e),r}collapseAtStart(t){const e=lexical.$createParagraphNode();this.getChildren().forEach((t=>e.append(t)));const r=this.getParentOrThrow(),n=r.getParentOrThrow(),s=$(n);if(1===r.getChildrenSize())if(s)r.remove(),n.select();else {r.insertBefore(e),r.remove();const n=t.anchor,s=t.focus,i=e.getKey();"element"===n.type&&n.getNode().is(this)&&n.set(i,n.offset,"element"),"element"===s.type&&s.getNode().is(this)&&s.set(i,s.offset,"element");}else r.insertBefore(e),this.remove();return !0}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const r=this.getParent();return Y(r)&&(e=r.getListType()),"check"===e?Boolean(t.__checked):void 0}setChecked(t){const e=this.getWritable();return e.__checked=t,e}toggleChecked(){const t=this.getWritable();return t.setChecked(!t.__checked)}getIndent(){const t=this.getParent();if(null===t||!this.isAttached())return this.getLatest().__indent;let e=t.getParentOrThrow(),r=0;for(;$(e);)e=e.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(t){"number"!=typeof t&&v(117),(t=Math.floor(t))>=0||v(199);let e=this.getIndent();for(;e!==t;)e<t?(I(this),e++):(D(this),e--);return this}canInsertAfter(t){return $(t)}canReplaceWith(t){return $(t)}canMergeWith(t){return $(t)||lexical.$isParagraphNode(t)}extractWithChild(t,e){if(!lexical.$isRangeSelection(e))return !1;const r=e.anchor.getNode(),n=e.focus.getNode();return this.isParentOf(r)&&this.isParentOf(n)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return !0}createParentElementNode(){return X("bullet")}canMergeWhenEmpty(){return !0}}function B(t,n,s){const i=[],o=[],l=n.list,c=l?l.listitem:void 0;let a;if(l&&l.nested&&(a=l.nested.listitem),void 0!==c&&i.push(...R(c)),l){const t=s.getParent(),e=Y(t)&&"check"===t.getListType(),r=s.getChecked();e&&!r||o.push(l.listitemUnchecked),e&&r||o.push(l.listitemChecked),e&&i.push(r?l.listitemChecked:l.listitemUnchecked);}if(void 0!==a){const t=R(a);s.getChildren().some((t=>Y(t)))?i.push(...t):o.push(...t);}o.length>0&&LexicalUtils.removeClassNamesFromElement(t,...o),i.length>0&&LexicalUtils.addClassNamesToElement(t,...i);}function K(t,e,r,n){Y(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),r&&e.__checked===r.__checked||t.setAttribute("aria-checked",e.getChecked()?"true":"false"));}function V(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return U(e);const e=t.getAttribute("aria-checked");return {node:z("true"===e||"false"!==e&&void 0)}}function U(t){if(!("checkbox"===t.getAttribute("type")))return {node:null};return {node:z(t.hasAttribute("checked"))}}function z(t){return lexical.$applyNodeReplacement(new W(void 0,t))}function $(t){return t instanceof W}class q extends lexical.ElementNode{static getType(){return "list"}static clone(t){const e=t.__listType||Q[t.__tag];return new q(e,t.__start,t.__key)}constructor(t="number",e=1,r){super(r);const n=Q[t]||t;this.__listType=n,this.__tag="number"===n?"ol":"ul",this.__start=e;}getTag(){return this.__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.__listType}getStart(){return this.__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const r=this.__tag,n=document.createElement(r);return 1!==this.__start&&n.setAttribute("start",String(this.__start)),n.__lexicalListType=this.__listType,H(n,t.theme,this),n}updateDOM(t,e,r){return t.__tag!==this.__tag||(H(e,r.theme,this),!1)}static transform(){return t=>{Y(t)||v(163),function(t){const e=t.getNextSibling();Y(e)&&t.getListType()===e.getListType()&&M(t,e);}(t),function(t){const e="check"!==t.getListType();let r=t.getStart();for(const n of t.getChildren())$(n)&&(n.getValue()!==r&&n.setValue(r),e&&null!=n.getLatest().__checked&&n.setChecked(void 0),Y(n.getFirstChild())||r++);}(t);}}static importDOM(){return {ol:()=>({conversion:G,priority:0}),ul:()=>({conversion:G,priority:0})}}static importJSON(t){return X().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return LexicalUtils.isHTMLElement(e)&&(1!==this.__start&&e.setAttribute("start",String(this.__start)),"check"===this.__listType&&e.setAttribute("__lexicalListType","check")),{element:e}}exportJSON(){return {...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return !1}canIndent(){return !1}append(...t){for(let e=0;e<t.length;e++){const r=t[e];if($(r))super.append(r);else {const t=z();if(Y(r))t.append(r);else if(lexical.$isElementNode(r))if(r.isInline())t.append(r);else {const e=lexical.$createTextNode(r.getTextContent());t.append(e);}else t.append(r);super.append(t);}}return this}extractWithChild(t){return $(t)}}function H(t,n,s){const i=[],o=[],l=n.list;if(void 0!==l){const t=l[`${s.__tag}Depth`]||[],e=k(s)-1,r=e%t.length,n=t[r],c=l[s.__tag];let a;const h=l.nested,g=l.checklist;if(void 0!==h&&h.list&&(a=h.list),void 0!==c&&i.push(c),void 0!==g&&"check"===s.__listType&&i.push(g),void 0!==n){i.push(...R(n));for(let e=0;e<t.length;e++)e!==r&&o.push(s.__tag+e);}if(void 0!==a){const t=R(a);e>1?i.push(...t):o.push(...t);}}o.length>0&&LexicalUtils.removeClassNamesFromElement(t,...o),i.length>0&&LexicalUtils.addClassNamesToElement(t,...i);}function j(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if($(n)){e.push(n);const t=n.getChildren();t.length>1&&t.forEach((t=>{Y(t)&&e.push(O(t));}));}else e.push(O(n));}return e}function G(t){const e=t.nodeName.toLowerCase();let r=null;if("ol"===e){r=X("number",t.start);}else "ul"===e&&(r=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return !0;for(const e of t.childNodes)if(LexicalUtils.isHTMLElement(e)&&e.hasAttribute("aria-checked"))return !0;return !1}(t)?X("check"):X("bullet"));return {after:j,node:r}}const Q={ol:"number",ul:"bullet"};function X(t="number",e=1){return lexical.$applyNodeReplacement(new q(t,e))}function Y(t){return t instanceof q}const Z=lexical.createCommand("INSERT_UNORDERED_LIST_COMMAND"),tt=lexical.createCommand("INSERT_ORDERED_LIST_COMMAND"),et=lexical.createCommand("INSERT_CHECK_LIST_COMMAND"),rt=lexical.createCommand("REMOVE_LIST_COMMAND");function nt(t){return LexicalUtils.mergeRegister(t.registerCommand(tt,(()=>(A("number"),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(Z,(()=>(A("bullet"),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(rt,(()=>(w(),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND,(()=>J()),lexical.COMMAND_PRIORITY_LOW),t.registerNodeTransform(W,(t=>{const e=t.getFirstChild();if(e){if(lexical.$isTextNode(e)){const r=e.getStyle(),n=e.getFormat();t.getTextStyle()!==r&&t.setTextStyle(r),t.getTextFormat()!==n&&t.setTextFormat(n);}}else {const e=lexical.$getSelection();lexical.$isRangeSelection(e)&&(e.style!==t.getTextStyle()||e.format!==t.getTextFormat())&&e.isCollapsed()&&t.is(e.anchor.getNode())&&t.setTextStyle(e.style).setTextFormat(e.format);}})),t.registerNodeTransform(lexical.TextNode,(t=>{const e=t.getParent();if($(e)&&t.is(e.getFirstChild())){const r=t.getStyle(),n=t.getFormat();r===e.getTextStyle()&&n===e.getTextFormat()||e.setTextStyle(r).setTextFormat(n);}})))}function st(t,e){t.update((()=>A(e)));}function it(t){t.update((()=>w()));}
15
+ function I(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.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 M(t){let e=1,n=t.getParent();for(;null!=n;){if(nt(n)){const t=n.getParent();if(at(t)){e++,n=t.getParent();continue}I(40);}return e}return e}function R(t){let e=t.getParent();at(e)||I(40);let n=e;for(;null!==n;)n=n.getParent(),at(n)&&(e=n);return e}function B(t){let e=[];const n=t.getChildren().filter(nt);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();at(i)?e=e.concat(B(i)):e.push(r);}return e}function K(t){return nt(t)&&at(t.getFirstChild())}function W(t){return et().append(t)}function J(t,e){return nt(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function $(t){const e=lexical.$getSelection();if(null!==e){let n=e.getNodes();if(lexical.$isRangeSelection(e)){const r=e.getStartEndPoints();null===r&&I(143);const[i]=r,s=i.getNode(),o=s.getParent();if(lexical.$isRootOrShadowRoot(s)){const t=s.getFirstChild();if(t)n=t.selectStart().getNodes();else {const t=lexical.$createParagraphNode();s.append(t),n=t.select().getNodes();}}else if(J(s,n)){const e=ct(t);if(lexical.$isRootOrShadowRoot(o)){s.replace(e);const t=et();lexical.$isElementNode(s)&&(t.setFormat(s.getFormatType()),t.setIndent(s.getIndent())),e.append(t);}else if(nt(s)){const t=s.getParentOrThrow();U(e,t.getChildren()),t.replace(e);}return}}const r=new Set;for(let e=0;e<n.length;e++){const i=n[e];if(lexical.$isElementNode(i)&&i.isEmpty()&&!nt(i)&&!r.has(i.getKey())){V(i,t);continue}let s=lexical.$isLeafNode(i)?i.getParent():nt(i)&&i.isEmpty()?i:null;for(;null!=s;){const e=s.getKey();if(at(s)){if(!r.has(e)){const n=ct(t);U(n,s.getChildren()),s.replace(n),r.add(e);}break}{const n=s.getParent();if(lexical.$isRootOrShadowRoot(n)&&!r.has(e)){r.add(e),V(s,t);break}s=n;}}}}}function U(t,e){t.splice(t.getChildrenSize(),0,e);}function V(t,e){if(at(t))return t;const n=t.getPreviousSibling(),r=t.getNextSibling(),i=et();let s;if(U(i,t.getChildren()),at(n)&&e===n.getListType())n.append(i),at(r)&&e===r.getListType()&&(U(n,r.getChildren()),r.remove()),s=n;else if(at(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else {const n=ct(e);n.append(i),t.replace(n),s=n;}return i.setFormat(t.getFormatType()),i.setIndent(t.getIndent()),t.remove(),s}function z(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&K(n)&&K(r)&&(z(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove();}function q(){const e=lexical.$getSelection();if(lexical.$isRangeSelection(e)){const n=new Set,r=e.getNodes(),i=e.anchor.getNode();if(J(i,r))n.add(R(i));else for(let e=0;e<r.length;e++){const i=r[e];if(lexical.$isLeafNode(i)){const e=LexicalUtils.$getNearestNodeOfType(i,Y);null!=e&&n.add(R(e));}}for(const t of n){let n=t;const r=B(t);for(const t of r){const r=lexical.$createParagraphNode().setTextStyle(e.style).setTextFormat(e.format);U(r,t.getChildren()),n.insertAfter(r),n=r,t.__key===e.anchor.key&&lexical.$setPointFromCaret(e.anchor,lexical.$normalizeCaret(lexical.$getChildCaret(r,"next"))),t.__key===e.focus.key&&lexical.$setPointFromCaret(e.focus,lexical.$normalizeCaret(lexical.$getChildCaret(r,"next"))),t.remove();}t.remove();}}}function H(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())nt(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),at(r.getFirstChild())||n++);}function X(t){const e=new Set;if(K(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if(K(r)&&K(i)){const n=i.getFirstChild();if(at(n)){n.append(t);const i=r.getFirstChild();if(at(i)){U(n,i.getChildren()),r.remove(),e.add(r.getKey());}}}else if(K(r)){const e=r.getFirstChild();if(at(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t);}}else if(K(i)){const e=i.getFirstChild();at(e)&&e.append(t);}else if(at(n)){const e=et().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()),s=ct(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());e.append(s),s.append(t),i?i.insertAfter(e):r?r.insertBefore(e):n.append(e);}}function j(t){if(K(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(at(n?n.getParent():void 0)&&nt(n)&&at(e)){const r=e?e.getFirstChild():void 0,i=e?e.getLastChild():void 0;if(t.is(r))n.insertBefore(t),e.isEmpty()&&n.remove();else if(t.is(i))n.insertAfter(t),e.isEmpty()&&n.remove();else {const r=e.getListType(),i=et(),s=ct(r);i.append(s),t.getPreviousSiblings().forEach((t=>s.append(t)));const o=et(),l=ct(r);o.append(l),U(l,t.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(t);}}}function G(){const t=lexical.$getSelection();if(!lexical.$isRangeSelection(t)||!t.isCollapsed())return !1;const e=t.anchor.getNode();if(!nt(e)||0!==e.getChildrenSize())return !1;const n=R(e),r=e.getParent();at(r)||I(40);const i=r.getParent();let s;if(lexical.$isRootOrShadowRoot(i))s=lexical.$createParagraphNode(),n.insertAfter(s);else {if(!nt(i))return !1;s=et(),i.insertAfter(s);}s.setTextStyle(t.style).setTextFormat(t.format).select();const o=e.getNextSiblings();if(o.length>0){const t=ct(r.getListType());if(nt(s)){const e=et();e.append(t),s.insertAfter(e);}else s.insertAfter(t);t.append(...o);}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!nt(t)&&!at(t))break;e=t;}e.remove();}(e),!0}function Q(...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}class Y extends lexical.ElementNode{$config(){return this.config("listitem",{$transform:t=>{if(null==t.__checked)return;const e=t.getParent();at(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0);},extends:lexical.ElementNode,importDOM:lexical.buildImportMap({li:()=>({conversion:Z,priority:0})})})}constructor(t=1,e=void 0,n){super(n),this.__value=void 0===t?1:t,this.__checked=e;}afterCloneFrom(t){super.afterCloneFrom(t),this.__value=t.__value,this.__checked=t.__checked;}createDOM(t){const e=document.createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,r,i){const s=this.getParent();at(s)&&"check"===s.getListType()&&function(t,e,n,r){at(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),n&&e.__checked===n.__checked||t.setAttribute("aria-checked",e.getChecked()?"true":"false"));}(r,this,t),r.value=this.__value,function(t,r,i){const s=[],o=[],l=r.list,c=l?l.listitem:void 0;let a;l&&l.nested&&(a=l.nested.listitem);void 0!==c&&s.push(...Q(c));if(l){const t=i.getParent(),e=at(t)&&"check"===t.getListType(),n=i.getChecked();e&&!n||o.push(l.listitemUnchecked),e&&n||o.push(l.listitemChecked),e&&s.push(n?l.listitemChecked:l.listitemUnchecked);}if(void 0!==a){const t=Q(a);i.getChildren().some((t=>at(t)))?s.push(...t):o.push(...t);}o.length>0&&LexicalUtils.removeClassNamesFromElement(t,...o);s.length>0&&LexicalUtils.addClassNamesToElement(t,...s);}(r,i.theme,this);const o=t?t.__style:"",l=this.__style;o!==l&&(""===l?r.removeAttribute("style"):r.style.cssText=l),function(t,e,n){const r=LexicalSelection.getStyleObjectFromCSS(e.__textStyle);for(const e in r)t.style.setProperty(`--listitem-marker-${e}`,r[e]);if(n)for(const e in LexicalSelection.getStyleObjectFromCSS(n.__textStyle))e in r||t.style.removeProperty(`--listitem-marker-${e}`);}(r,this,t);}updateDOM(t,e,n){const r=e;return this.updateListItemDOM(t,r,n),!1}updateFromJSON(t){return super.updateFromJSON(t).setValue(t.value).setChecked(t.checked)}exportDOM(t){const e=this.createDOM(t._config),n=this.getFormatType();n&&(e.style.textAlign=n);const r=this.getDirection();return r&&(e.dir=r),{element:e}}exportJSON(){return {...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...t){for(let e=0;e<t.length;e++){const n=t[e];if(lexical.$isElementNode(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove();}else super.append(n);}return this}replace(t,e){if(nt(t))return super.replace(t);this.setIndent(0);const n=this.getParentOrThrow();if(!at(n))return t;if(n.__first===this.getKey())n.insertBefore(t);else if(n.__last===this.getKey())n.insertAfter(t);else {const e=ct(n.getListType());let r=this.getNextSibling();for(;r;){const t=r;r=r.getNextSibling(),e.append(t);}n.insertAfter(t),t.insertAfter(e);}return e&&(lexical.$isElementNode(t)||I(139),this.getChildren().forEach((e=>{t.append(e);}))),this.remove(),0===n.getChildrenSize()&&n.remove(),t}insertAfter(t,e=!0){const n=this.getParentOrThrow();if(at(n)||I(39),nt(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=ct(n.getListType());r.forEach((t=>i.append(t))),t.insertAfter(i,e);}return t}remove(t){const e=this.getPreviousSibling(),n=this.getNextSibling();super.remove(t),e&&n&&K(e)&&K(n)&&(z(e.getFirstChild(),n.getFirstChild()),n.remove());}insertNewAfter(t,e=!0){const n=et().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(n,e),n}collapseAtStart(t){const e=lexical.$createParagraphNode();this.getChildren().forEach((t=>e.append(t)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=nt(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else {n.insertBefore(e),n.remove();const r=t.anchor,i=t.focus,s=e.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element");}else n.insertBefore(e),this.remove();return !0}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const n=this.getParent();return at(n)&&(e=n.getListType()),"check"===e?Boolean(t.__checked):void 0}setChecked(t){const e=this.getWritable();return e.__checked=t,e}toggleChecked(){const t=this.getWritable();return t.setChecked(!t.__checked)}getIndent(){const t=this.getParent();if(null===t||!this.isAttached())return this.getLatest().__indent;let e=t.getParentOrThrow(),n=0;for(;nt(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&I(117),(t=Math.floor(t))>=0||I(199);let e=this.getIndent();for(;e!==t;)e<t?(X(this),e++):(j(this),e--);return this}canInsertAfter(t){return nt(t)}canReplaceWith(t){return nt(t)}canMergeWith(t){return nt(t)||lexical.$isParagraphNode(t)}extractWithChild(t,e){if(!lexical.$isRangeSelection(e))return !1;const n=e.anchor.getNode(),r=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return !0}createParentElementNode(){return ct("bullet")}canMergeWhenEmpty(){return !0}}function Z(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return tt(e);const e=t.getAttribute("aria-checked");return {node:et("true"===e||"false"!==e&&void 0)}}function tt(t){if(!("checkbox"===t.getAttribute("type")))return {node:null};return {node:et(t.hasAttribute("checked"))}}function et(t){return lexical.$applyNodeReplacement(new Y(void 0,t))}function nt(t){return t instanceof Y}class rt extends lexical.ElementNode{$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();at(e)&&t.getListType()===e.getListType()&&z(t,e);}(t),H(t);},extends:lexical.ElementNode,importDOM:lexical.buildImportMap({ol:()=>({conversion:ot,priority:0}),ul:()=>({conversion:ot,priority:0})})})}constructor(t="number",e=1,n){super(n);const r=lt[t]||t;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=e;}afterCloneFrom(t){super.afterCloneFrom(t),this.__listType=t.__listType,this.__tag=t.__tag,this.__start=t.__start;}getTag(){return this.getLatest().__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,it(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||(it(e,n.theme,this),!1)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return LexicalUtils.isHTMLElement(e)&&(1!==this.__start&&e.setAttribute("start",String(this.__start)),"check"===this.__listType&&e.setAttribute("__lexicalListType","check")),{element:e}}exportJSON(){return {...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return !1}canIndent(){return !1}splice(t,e,n){let r=n;for(let t=0;t<n.length;t++){const e=n[t];nt(e)||(r===n&&(r=[...n]),r[t]=et().append(!lexical.$isElementNode(e)||at(e)||e.isInline()?e:lexical.$createTextNode(e.getTextContent())));}return super.splice(t,e,r)}extractWithChild(t){return nt(t)}}function it(t,r,i){const s=[],o=[],l=r.list;if(void 0!==l){const t=l[`${i.__tag}Depth`]||[],e=M(i)-1,n=e%t.length,r=t[n],c=l[i.__tag];let a;const g=l.nested,u=l.checklist;if(void 0!==g&&g.list&&(a=g.list),void 0!==c&&s.push(c),void 0!==u&&"check"===i.__listType&&s.push(u),void 0!==r){s.push(...Q(r));for(let e=0;e<t.length;e++)e!==n&&o.push(i.__tag+e);}if(void 0!==a){const t=Q(a);e>1?s.push(...t):o.push(...t);}}o.length>0&&LexicalUtils.removeClassNamesFromElement(t,...o),s.length>0&&LexicalUtils.addClassNamesToElement(t,...s);}function st(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(nt(r)){e.push(r);const t=r.getChildren();t.length>1&&t.forEach((t=>{at(t)&&e.push(W(t));}));}else e.push(W(r));}return e}function ot(t){const e=t.nodeName.toLowerCase();let n=null;if("ol"===e){n=ct("number",t.start);}else "ul"===e&&(n=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list"))return !0;for(const e of t.childNodes)if(LexicalUtils.isHTMLElement(e)&&e.hasAttribute("aria-checked"))return !0;return !1}(t)?ct("check"):ct("bullet"));return {after:st,node:n}}const lt={ol:"number",ul:"bullet"};function ct(t="number",e=1){return lexical.$applyNodeReplacement(new rt(t,e))}function at(t){return t instanceof rt}const gt=lexical.createCommand("INSERT_CHECK_LIST_COMMAND");function ut(t){return LexicalUtils.mergeRegister(t.registerCommand(gt,(()=>($("check"),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND,(e=>mt(e,t,!1)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_UP_COMMAND,(e=>mt(e,t,!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ESCAPE_COMMAND,(()=>{if(null!=pt()){const e=t.getRootElement();return null!=e&&e.focus(),!0}return !1}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_SPACE_COMMAND,(e=>{const n=pt();return !(null==n||!t.isEditable())&&(t.update((()=>{const t=lexical.$getNearestNodeFromDOMNode(n);nt(t)&&(e.preventDefault(),t.toggleChecked());})),!0)}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND,(e=>t.getEditorState().read((()=>{const n=lexical.$getSelection();if(lexical.$isRangeSelection(n)&&n.isCollapsed()){const{anchor:r}=n,i="element"===r.type;if(i||0===r.offset){const n=r.getNode(),o=LexicalUtils.$findMatchingParent(n,(t=>lexical.$isElementNode(t)&&!t.isInline()));if(nt(o)){const r=o.getParent();if(at(r)&&"check"===r.getListType()&&(i||o.getFirstDescendant()===n)){const n=t.getElementByKey(o.__key);if(null!=n&&document.activeElement!==n)return n.focus(),e.preventDefault(),!0}}}}return !1}))),lexical.COMMAND_PRIORITY_LOW),t.registerRootListener(((t,e)=>{null!==t&&(t.addEventListener("click",ft),t.addEventListener("pointerdown",dt)),null!==e&&(e.removeEventListener("click",ft),e.removeEventListener("pointerdown",dt));})))}function ht(t,e){const n=t.target;if(!LexicalUtils.isHTMLElement(n))return;const i=n.firstChild;if(LexicalUtils.isHTMLElement(i)&&("UL"===i.tagName||"OL"===i.tagName))return;const s=n.parentNode;if(!s||"check"!==s.__lexicalListType)return;const l=n.getBoundingClientRect(),c=LexicalUtils.calculateZoomLevel(n),a=t.clientX/c,g=window.getComputedStyle?window.getComputedStyle(n,"::before"):{width:"0px"},u=parseFloat(g.width),h="touch"===t.pointerType?32:0;("rtl"===n.dir?a<l.right+h&&a>l.right-u-h:a>l.left-h&&a<l.left+u+h)&&e();}function ft(t){ht(t,(()=>{if(LexicalUtils.isHTMLElement(t.target)){const e=t.target,n=lexical.getNearestEditorFromDOMNode(e);null!=n&&n.isEditable()&&n.update((()=>{const t=lexical.$getNearestNodeFromDOMNode(e);nt(t)&&(e.focus(),t.toggleChecked());}));}}));}function dt(t){ht(t,(()=>{t.preventDefault();}));}function pt(){const t=document.activeElement;return LexicalUtils.isHTMLElement(t)&&"LI"===t.tagName&&null!=t.parentNode&&"check"===t.parentNode.__lexicalListType?t:null}function mt(t,e,n){const r=pt();return null!=r&&e.update((()=>{const i=lexical.$getNearestNodeFromDOMNode(r);if(!nt(i))return;const s=function(t,e){let n=e?t.getPreviousSibling():t.getNextSibling(),r=t;for(;null==n&&nt(r);)r=r.getParentOrThrow().getParent(),null!=r&&(n=e?r.getPreviousSibling():r.getNextSibling());for(;nt(n);){const t=e?n.getLastChild():n.getFirstChild();if(!at(t))return n;n=e?t.getLastChild():t.getFirstChild();}return null}(i,n);if(null!=s){s.selectStart();const n=e.getElementByKey(s.__key);null!=n&&(t.preventDefault(),setTimeout((()=>{n.focus();}),0));}})),!1}const _t=lexical.createCommand("UPDATE_LIST_START_COMMAND"),yt=lexical.createCommand("INSERT_UNORDERED_LIST_COMMAND"),Ct=lexical.createCommand("INSERT_ORDERED_LIST_COMMAND"),Tt=lexical.createCommand("REMOVE_LIST_COMMAND");function St(t){return LexicalUtils.mergeRegister(t.registerCommand(Ct,(()=>($("number"),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(_t,(t=>{const{listNodeKey:e,newStart:n}=t,r=lexical.$getNodeByKey(e);return !!at(r)&&("number"===r.getListType()&&(r.setStart(n),H(r)),!0)}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(yt,(()=>($("bullet"),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(Tt,(()=>(q(),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND,(()=>G()),lexical.COMMAND_PRIORITY_LOW),t.registerNodeTransform(Y,(t=>{const e=t.getFirstChild();if(e){if(lexical.$isTextNode(e)){const n=e.getStyle(),r=e.getFormat();t.getTextStyle()!==n&&t.setTextStyle(n),t.getTextFormat()!==r&&t.setTextFormat(r);}}else {const e=lexical.$getSelection();lexical.$isRangeSelection(e)&&(e.style!==t.getTextStyle()||e.format!==t.getTextFormat())&&e.isCollapsed()&&t.is(e.anchor.getNode())&&t.setTextStyle(e.style).setTextFormat(e.format);}})),t.registerNodeTransform(lexical.TextNode,(t=>{const e=t.getParent();if(nt(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r);}})))}function vt(t){const e=t=>{const e=t.getParent();if(at(t.getFirstChild())||!at(e))return;const n=LexicalUtils.$findMatchingParent(t,(t=>nt(t)&&at(t.getParent())&&nt(t.getPreviousSibling())));if(null===n&&t.getIndent()>0)t.setIndent(0);else if(nt(n)){const r=n.getPreviousSibling();if(nt(r)){const n=function(t){let e=t,n=e.getFirstChild();for(;at(n);){const t=n.getLastChild();if(!nt(t))break;e=t,n=e.getFirstChild();}return e}(r),i=n.getParent();if(at(i)){const n=M(i);n+1<M(e)&&t.setIndent(n);}}}};return t.registerNodeTransform(rt,(t=>{const n=[t];for(;n.length>0;){const t=n.shift();if(at(t))for(const r of t.getChildren())if(nt(r)){e(r);const t=r.getFirstChild();at(t)&&n.push(t);}}}))}function xt(t,e){t.update((()=>$(e)));}function kt(t){t.update((()=>q()));}
15
16
 
16
- exports.$createListItemNode = z;
17
- exports.$createListNode = X;
18
- exports.$getListDepth = k;
19
- exports.$handleListInsertParagraph = J;
20
- exports.$insertList = A;
21
- exports.$isListItemNode = $;
22
- exports.$isListNode = Y;
23
- exports.$removeList = w;
24
- exports.INSERT_CHECK_LIST_COMMAND = et;
25
- exports.INSERT_ORDERED_LIST_COMMAND = tt;
26
- exports.INSERT_UNORDERED_LIST_COMMAND = Z;
27
- exports.ListItemNode = W;
28
- exports.ListNode = q;
29
- exports.REMOVE_LIST_COMMAND = rt;
30
- exports.insertList = st;
31
- exports.registerList = nt;
32
- exports.removeList = it;
17
+ exports.$createListItemNode = et;
18
+ exports.$createListNode = ct;
19
+ exports.$getListDepth = M;
20
+ exports.$handleListInsertParagraph = G;
21
+ exports.$insertList = $;
22
+ exports.$isListItemNode = nt;
23
+ exports.$isListNode = at;
24
+ exports.$removeList = q;
25
+ exports.INSERT_CHECK_LIST_COMMAND = gt;
26
+ exports.INSERT_ORDERED_LIST_COMMAND = Ct;
27
+ exports.INSERT_UNORDERED_LIST_COMMAND = yt;
28
+ exports.ListItemNode = Y;
29
+ exports.ListNode = rt;
30
+ exports.REMOVE_LIST_COMMAND = Tt;
31
+ exports.UPDATE_LIST_START_COMMAND = _t;
32
+ exports.insertList = xt;
33
+ exports.registerCheckList = ut;
34
+ exports.registerList = St;
35
+ exports.registerListStrictIndentTransform = vt;
36
+ exports.removeList = kt;
@@ -122,7 +122,9 @@ class QuoteNode extends lexical.ElementNode {
122
122
  element.append(document.createElement('br'));
123
123
  }
124
124
  const formatType = this.getFormatType();
125
- element.style.textAlign = formatType;
125
+ if (formatType) {
126
+ element.style.textAlign = formatType;
127
+ }
126
128
  const direction = this.getDirection();
127
129
  if (direction) {
128
130
  element.dir = direction;
@@ -265,7 +267,9 @@ class HeadingNode extends lexical.ElementNode {
265
267
  element.append(document.createElement('br'));
266
268
  }
267
269
  const formatType = this.getFormatType();
268
- element.style.textAlign = formatType;
270
+ if (formatType) {
271
+ element.style.textAlign = formatType;
272
+ }
269
273
  const direction = this.getDirection();
270
274
  if (direction) {
271
275
  element.dir = direction;
@@ -360,7 +364,7 @@ function onPasteForRichText(event, editor) {
360
364
  LexicalClipboard.$insertDataTransferForRichText(clipboardData, selection, editor);
361
365
  }
362
366
  }, {
363
- tag: 'paste'
367
+ tag: lexical.PASTE_TAG
364
368
  });
365
369
  }
366
370
  async function onCutForRichText(event, editor) {
@@ -426,6 +430,23 @@ function $isSelectionAtEndOfRoot(selection) {
426
430
  const focus = selection.focus;
427
431
  return focus.key === 'root' && focus.offset === lexical.$getRoot().getChildrenSize();
428
432
  }
433
+ function $isSelectionCollapsedAtFrontOfIndentedBlock(selection) {
434
+ if (!selection.isCollapsed()) {
435
+ return false;
436
+ }
437
+ const {
438
+ anchor
439
+ } = selection;
440
+ if (anchor.offset !== 0) {
441
+ return false;
442
+ }
443
+ const anchorNode = anchor.getNode();
444
+ if (lexical.$isRootNode(anchorNode)) {
445
+ return false;
446
+ }
447
+ const element = LexicalUtils.$getNearestBlockElementAncestorOrThrow(anchorNode);
448
+ return element.getIndent() > 0 && (element.is(anchorNode) || anchorNode.is(element.getFirstDescendant()));
449
+ }
429
450
 
430
451
  /**
431
452
  * Resets the capitalization of the selection to default.
@@ -447,13 +468,16 @@ function registerRichText(editor) {
447
468
  return true;
448
469
  }
449
470
  return false;
450
- }, 0), editor.registerCommand(lexical.DELETE_CHARACTER_COMMAND, isBackward => {
471
+ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DELETE_CHARACTER_COMMAND, isBackward => {
451
472
  const selection = lexical.$getSelection();
452
- if (!lexical.$isRangeSelection(selection)) {
453
- return false;
473
+ if (lexical.$isRangeSelection(selection)) {
474
+ selection.deleteCharacter(isBackward);
475
+ return true;
476
+ } else if (lexical.$isNodeSelection(selection)) {
477
+ selection.deleteNodes();
478
+ return true;
454
479
  }
455
- selection.deleteCharacter(isBackward);
456
- return true;
480
+ return false;
457
481
  }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DELETE_WORD_COMMAND, isBackward => {
458
482
  const selection = lexical.$getSelection();
459
483
  if (!lexical.$isRangeSelection(selection)) {
@@ -543,12 +567,12 @@ function registerRichText(editor) {
543
567
  return $handleIndentAndOutdent(block => {
544
568
  const indent = block.getIndent();
545
569
  if (indent > 0) {
546
- block.setIndent(indent - 1);
570
+ block.setIndent(Math.max(0, indent - 1));
547
571
  }
548
572
  });
549
573
  }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, event => {
550
574
  const selection = lexical.$getSelection();
551
- if (lexical.$isNodeSelection(selection) && !$isTargetWithinDecorator(event.target)) {
575
+ if (lexical.$isNodeSelection(selection)) {
552
576
  // If selection is on a node, let's try and move selection
553
577
  // back to being a range selection.
554
578
  const nodes = selection.getNodes();
@@ -596,7 +620,11 @@ function registerRichText(editor) {
596
620
  const nodes = selection.getNodes();
597
621
  if (nodes.length > 0) {
598
622
  event.preventDefault();
599
- nodes[0].selectPrevious();
623
+ if (LexicalSelection.$isParentRTL(nodes[0])) {
624
+ nodes[0].selectNext(0, 0);
625
+ } else {
626
+ nodes[0].selectPrevious();
627
+ }
600
628
  return true;
601
629
  }
602
630
  }
@@ -612,13 +640,17 @@ function registerRichText(editor) {
612
640
  return false;
613
641
  }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND, event => {
614
642
  const selection = lexical.$getSelection();
615
- if (lexical.$isNodeSelection(selection) && !$isTargetWithinDecorator(event.target)) {
643
+ if (lexical.$isNodeSelection(selection)) {
616
644
  // If selection is on a node, let's try and move selection
617
645
  // back to being a range selection.
618
646
  const nodes = selection.getNodes();
619
647
  if (nodes.length > 0) {
620
648
  event.preventDefault();
621
- nodes[0].selectNext(0, 0);
649
+ if (LexicalSelection.$isParentRTL(nodes[0])) {
650
+ nodes[0].selectPrevious();
651
+ } else {
652
+ nodes[0].selectNext(0, 0);
653
+ }
622
654
  return true;
623
655
  }
624
656
  }
@@ -637,24 +669,17 @@ function registerRichText(editor) {
637
669
  return false;
638
670
  }
639
671
  const selection = lexical.$getSelection();
640
- if (!lexical.$isRangeSelection(selection)) {
641
- return false;
642
- }
643
- const {
644
- anchor
645
- } = selection;
646
- const anchorNode = anchor.getNode();
647
- if (selection.isCollapsed() && anchor.offset === 0 && !lexical.$isRootNode(anchorNode)) {
648
- const element = LexicalUtils.$getNearestBlockElementAncestorOrThrow(anchorNode);
649
- if (element.getIndent() > 0) {
672
+ if (lexical.$isRangeSelection(selection)) {
673
+ if ($isSelectionCollapsedAtFrontOfIndentedBlock(selection)) {
650
674
  event.preventDefault();
651
675
  return editor.dispatchCommand(lexical.OUTDENT_CONTENT_COMMAND, undefined);
652
676
  }
653
- }
654
-
655
- // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices.
656
- // more details - https://github.com/facebook/lexical/issues/5841
657
- if (IS_IOS && navigator.language === 'ko-KR') {
677
+ // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices.
678
+ // more details - https://github.com/facebook/lexical/issues/5841
679
+ if (IS_IOS && navigator.language === 'ko-KR') {
680
+ return false;
681
+ }
682
+ } else if (!lexical.$isNodeSelection(selection)) {
658
683
  return false;
659
684
  }
660
685
  event.preventDefault();
@@ -664,7 +689,7 @@ function registerRichText(editor) {
664
689
  return false;
665
690
  }
666
691
  const selection = lexical.$getSelection();
667
- if (!lexical.$isRangeSelection(selection)) {
692
+ if (!(lexical.$isRangeSelection(selection) || lexical.$isNodeSelection(selection))) {
668
693
  return false;
669
694
  }
670
695
  event.preventDefault();
@@ -13,14 +13,14 @@ var lexical = require('lexical');
13
13
  *
14
14
  */
15
15
 
16
- function lt(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const dt="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,mt=dt&&"documentMode"in document?document.documentMode:null,ft=!(!dt||!("InputEvent"in window)||mt)&&"getTargetRanges"in new window.InputEvent("input"),gt=dt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),pt=dt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ht=dt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ct=dt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!ht,vt=lexical.createCommand("DRAG_DROP_PASTE_FILE");class yt extends lexical.ElementNode{static getType(){return "quote"}static clone(t){return new yt(t.__key)}createDOM(t){const e=document.createElement("blockquote");return LexicalUtils.addClassNamesToElement(e,t.theme.quote),e}updateDOM(t,e){return !1}static importDOM(){return {blockquote:t=>({conversion:Ot,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(LexicalUtils.isHTMLElement(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return Dt().updateFromJSON(t)}insertNewAfter(t,e){const n=lexical.$createParagraphNode(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=lexical.$createParagraphNode();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}canMergeWhenEmpty(){return !0}}function Dt(){return lexical.$applyNodeReplacement(new yt)}function xt(t){return t instanceof yt}class wt extends lexical.ElementNode{static getType(){return "heading"}static clone(t){return new wt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t;}getTag(){return this.__tag}setTag(t){const e=this.getWritable();return this.__tag=t,e}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];LexicalUtils.addClassNamesToElement(n,t);}return n}updateDOM(t,e,n){return t.__tag!==this.__tag}static importDOM(){return {h1:t=>({conversion:Et,priority:0}),h2:t=>({conversion:Et,priority:0}),h3:t=>({conversion:Et,priority:0}),h4:t=>({conversion:Et,priority:0}),h5:t=>({conversion:Et,priority:0}),h6:t=>({conversion:Et,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Nt(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Nt(t)?{conversion:t=>({node:Tt("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(LexicalUtils.isHTMLElement(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return Tt(t.tag).updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTag(t.tag)}exportJSON(){return {...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=!0){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?lexical.$createParagraphNode():Tt(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=lexical.$createParagraphNode();t.select(),this.replace(t,!0);}return o}collapseAtStart(){const t=this.isEmpty()?lexical.$createParagraphNode():Tt(this.getTag());return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}extractWithChild(){return !0}}function Nt(t){return "span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function Et(t){const e=t.nodeName.toLowerCase();let n=null;return "h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=Tt(e),null!==t.style&&(lexical.setNodeIndentFromDOM(t,n),n.setFormat(t.style.textAlign))),{node:n}}function Ot(t){const e=Dt();return null!==t.style&&(e.setFormat(t.style.textAlign),lexical.setNodeIndentFromDOM(t,e)),{node:e}}function Tt(t="h1"){return lexical.$applyNodeReplacement(new wt(t))}function _t(t){return t instanceof wt}function At(t){let e=null;if(LexicalUtils.objectKlassEquals(t,DragEvent)?e=t.dataTransfer:LexicalUtils.objectKlassEquals(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return [!1,[],!1];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return [r,Array.from(e.files),o]}function St(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;const n=new Set,r=e.getNodes();for(let e=0;e<r.length;e++){const o=r[e],i=o.getKey();if(n.has(i))continue;const s=LexicalUtils.$findMatchingParent(o,(t=>lexical.$isElementNode(t)&&!t.isInline()));if(null===s)continue;const a=s.getKey();s.canIndent()&&!n.has(a)&&(n.add(a),t(s));}return n.size>0}function Ft(t){const e=lexical.$getNearestNodeFromDOMNode(t);return lexical.$isDecoratorNode(e)}function It(t){for(const e of ["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e);}function Pt(o){return LexicalUtils.mergeRegister(o.registerCommand(lexical.CLICK_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isNodeSelection(e)&&(e.clear(),!0)}),0),o.registerCommand(lexical.DELETE_CHARACTER_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.deleteCharacter(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.DELETE_WORD_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.deleteWord(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.DELETE_LINE_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.deleteLine(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.CONTROLLED_TEXT_INSERTION_COMMAND,(e=>{const n=lexical.$getSelection();if("string"==typeof e)null!==n&&n.insertText(e);else {if(null===n)return !1;const r=e.dataTransfer;if(null!=r)LexicalClipboard.$insertDataTransferForRichText(r,n,o);else if(lexical.$isRangeSelection(n)){const t=e.data;return t&&n.insertText(t),!0}}return !0}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.REMOVE_TEXT_COMMAND,(()=>{const t=lexical.$getSelection();return !!lexical.$isRangeSelection(t)&&(t.removeText(),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.FORMAT_TEXT_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.formatText(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.FORMAT_ELEMENT_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)&&!lexical.$isNodeSelection(e))return !1;const n=e.getNodes();for(const e of n){const n=LexicalUtils.$findMatchingParent(e,(t=>lexical.$isElementNode(t)&&!t.isInline()));null!==n&&n.setFormat(t);}return !0}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.INSERT_LINE_BREAK_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.insertLineBreak(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND,(()=>{const t=lexical.$getSelection();return !!lexical.$isRangeSelection(t)&&(t.insertParagraph(),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.INSERT_TAB_COMMAND,(()=>(lexical.$insertNodes([lexical.$createTabNode()]),!0)),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.INDENT_CONTENT_COMMAND,(()=>St((t=>{const e=t.getIndent();t.setIndent(e+1);}))),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.OUTDENT_CONTENT_COMMAND,(()=>St((t=>{const e=t.getIndent();e>0&&t.setIndent(e-1);}))),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_ARROW_UP_COMMAND,(t=>{const e=lexical.$getSelection();if(lexical.$isNodeSelection(e)&&!Ft(t.target)){const t=e.getNodes();if(t.length>0)return t[0].selectPrevious(),!0}else if(lexical.$isRangeSelection(e)){const n=lexical.$getAdjacentNode(e.focus,!0);if(!t.shiftKey&&lexical.$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),!0}return !1}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND,(t=>{const e=lexical.$getSelection();if(lexical.$isNodeSelection(e)){const t=e.getNodes();if(t.length>0)return t[0].selectNext(0,0),!0}else if(lexical.$isRangeSelection(e)){if(function(t){const e=t.focus;return "root"===e.key&&e.offset===lexical.$getRoot().getChildrenSize()}(e))return t.preventDefault(),!0;const n=lexical.$getAdjacentNode(e.focus,!1);if(!t.shiftKey&&lexical.$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),!0}return !1}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND,(t=>{const e=lexical.$getSelection();if(lexical.$isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),!0}if(!lexical.$isRangeSelection(e))return !1;if(LexicalSelection.$shouldOverrideDefaultCharacterSelection(e,!0)){const n=t.shiftKey;return t.preventDefault(),LexicalSelection.$moveCharacter(e,n,!0),!0}return !1}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND,(t=>{const e=lexical.$getSelection();if(lexical.$isNodeSelection(e)&&!Ft(t.target)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),!0}if(!lexical.$isRangeSelection(e))return !1;const o=t.shiftKey;return !!LexicalSelection.$shouldOverrideDefaultCharacterSelection(e,!1)&&(t.preventDefault(),LexicalSelection.$moveCharacter(e,o,!1),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_BACKSPACE_COMMAND,(t=>{if(Ft(t.target))return !1;const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;const{anchor:n}=e,r=n.getNode();if(e.isCollapsed()&&0===n.offset&&!lexical.$isRootNode(r)){if(LexicalUtils.$getNearestBlockElementAncestorOrThrow(r).getIndent()>0)return t.preventDefault(),o.dispatchCommand(lexical.OUTDENT_CONTENT_COMMAND,void 0)}return (!pt||"ko-KR"!==navigator.language)&&(t.preventDefault(),o.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND,!0))}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_DELETE_COMMAND,(t=>{if(Ft(t.target))return !1;const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(t.preventDefault(),o.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND,!1))}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_ENTER_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;if(It(e),null!==t){if((pt||gt||Ct)&&ft)return !1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand(lexical.INSERT_LINE_BREAK_COMMAND,!1)}return o.dispatchCommand(lexical.INSERT_PARAGRAPH_COMMAND,void 0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_ESCAPE_COMMAND,(()=>{const t=lexical.$getSelection();return !!lexical.$isRangeSelection(t)&&(o.blur(),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.DROP_COMMAND,(t=>{const[,e]=At(t);if(e.length>0){const n=lt(t.clientX,t.clientY);if(null!==n){const{offset:t,node:r}=n,i=lexical.$getNearestNodeFromDOMNode(r);if(null!==i){const e=lexical.$createRangeSelection();if(lexical.$isTextNode(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else {const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element");}const n=lexical.$normalizeSelection__EXPERIMENTAL(e);lexical.$setSelection(n);}o.dispatchCommand(vt,e);}return t.preventDefault(),!0}const n=lexical.$getSelection();return !!lexical.$isRangeSelection(n)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.DRAGSTART_COMMAND,(t=>{const[e]=At(t),n=lexical.$getSelection();return !(e&&!lexical.$isRangeSelection(n))}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.DRAGOVER_COMMAND,(t=>{const[e]=At(t),n=lexical.$getSelection();if(e&&!lexical.$isRangeSelection(n))return !1;const r=lt(t.clientX,t.clientY);if(null!==r){const e=lexical.$getNearestNodeFromDOMNode(r.node);lexical.$isDecoratorNode(e)&&t.preventDefault();}return !0}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.SELECT_ALL_COMMAND,(()=>(lexical.$selectAll(),!0)),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.COPY_COMMAND,(t=>(LexicalClipboard.copyToClipboard(o,LexicalUtils.objectKlassEquals(t,ClipboardEvent)?t:null),!0)),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.CUT_COMMAND,(t=>(async function(t,n){await LexicalClipboard.copyToClipboard(n,LexicalUtils.objectKlassEquals(t,ClipboardEvent)?t:null),n.update((()=>{const t=lexical.$getSelection();lexical.$isRangeSelection(t)?t.removeText():lexical.$isNodeSelection(t)&&t.getNodes().forEach((t=>t.remove()));}));}(t,o),!0)),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.PASTE_COMMAND,(e=>{const[,n,r]=At(e);if(n.length>0&&!r)return o.dispatchCommand(vt,n),!0;if(lexical.isDOMNode(e.target)&&lexical.isSelectionCapturedInDecoratorInput(e.target))return !1;return null!==lexical.$getSelection()&&(function(e,n){e.preventDefault(),n.update((()=>{const r=lexical.$getSelection(),o=LexicalUtils.objectKlassEquals(e,InputEvent)||LexicalUtils.objectKlassEquals(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&LexicalClipboard.$insertDataTransferForRichText(o,r,n);}),{tag:"paste"});}(e,o),!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_SPACE_COMMAND,(t=>{const e=lexical.$getSelection();return lexical.$isRangeSelection(e)&&It(e),!1}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_TAB_COMMAND,(t=>{const e=lexical.$getSelection();return lexical.$isRangeSelection(e)&&It(e),!1}),lexical.COMMAND_PRIORITY_EDITOR))}
16
+ function mt(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const ft="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,gt=ft&&"documentMode"in document?document.documentMode:null,pt=!(!ft||!("InputEvent"in window)||gt)&&"getTargetRanges"in new window.InputEvent("input"),ht=ft&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Ct=ft&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,vt=ft&&/^(?=.*Chrome).*/i.test(navigator.userAgent),yt=ft&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!vt,Dt=lexical.createCommand("DRAG_DROP_PASTE_FILE");class xt extends lexical.ElementNode{static getType(){return "quote"}static clone(t){return new xt(t.__key)}createDOM(t){const e=document.createElement("blockquote");return LexicalUtils.addClassNamesToElement(e,t.theme.quote),e}updateDOM(t,e){return !1}static importDOM(){return {blockquote:t=>({conversion:_t,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(LexicalUtils.isHTMLElement(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return Nt().updateFromJSON(t)}insertNewAfter(t,e){const n=lexical.$createParagraphNode(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=lexical.$createParagraphNode();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}canMergeWhenEmpty(){return !0}}function Nt(){return lexical.$applyNodeReplacement(new xt)}function wt(t){return t instanceof xt}class Et extends lexical.ElementNode{static getType(){return "heading"}static clone(t){return new Et(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t;}getTag(){return this.__tag}setTag(t){const e=this.getWritable();return this.__tag=t,e}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];LexicalUtils.addClassNamesToElement(n,t);}return n}updateDOM(t,e,n){return t.__tag!==this.__tag}static importDOM(){return {h1:t=>({conversion:Tt,priority:0}),h2:t=>({conversion:Tt,priority:0}),h3:t=>({conversion:Tt,priority:0}),h4:t=>({conversion:Tt,priority:0}),h5:t=>({conversion:Tt,priority:0}),h6:t=>({conversion:Tt,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Ot(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Ot(t)?{conversion:t=>({node:At("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(LexicalUtils.isHTMLElement(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return At(t.tag).updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTag(t.tag)}exportJSON(){return {...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=!0){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?lexical.$createParagraphNode():At(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=lexical.$createParagraphNode();t.select(),this.replace(t,!0);}return o}collapseAtStart(){const t=this.isEmpty()?lexical.$createParagraphNode():At(this.getTag());return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}extractWithChild(){return !0}}function Ot(t){return "span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function Tt(t){const e=t.nodeName.toLowerCase();let n=null;return "h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=At(e),null!==t.style&&(lexical.setNodeIndentFromDOM(t,n),n.setFormat(t.style.textAlign))),{node:n}}function _t(t){const e=Nt();return null!==t.style&&(e.setFormat(t.style.textAlign),lexical.setNodeIndentFromDOM(t,e)),{node:e}}function At(t="h1"){return lexical.$applyNodeReplacement(new Et(t))}function Ft(t){return t instanceof Et}function Pt(t){let e=null;if(LexicalUtils.objectKlassEquals(t,DragEvent)?e=t.dataTransfer:LexicalUtils.objectKlassEquals(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return [!1,[],!1];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return [r,Array.from(e.files),o]}function St(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;const n=new Set,r=e.getNodes();for(let e=0;e<r.length;e++){const o=r[e],i=o.getKey();if(n.has(i))continue;const s=LexicalUtils.$findMatchingParent(o,(t=>lexical.$isElementNode(t)&&!t.isInline()));if(null===s)continue;const a=s.getKey();s.canIndent()&&!n.has(a)&&(n.add(a),t(s));}return n.size>0}function It(t){const e=lexical.$getNearestNodeFromDOMNode(t);return lexical.$isDecoratorNode(e)}function Mt(t){for(const e of ["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e);}function bt(i){return LexicalUtils.mergeRegister(i.registerCommand(lexical.CLICK_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isNodeSelection(e)&&(e.clear(),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.DELETE_CHARACTER_COMMAND,(t=>{const e=lexical.$getSelection();return lexical.$isRangeSelection(e)?(e.deleteCharacter(t),!0):!!lexical.$isNodeSelection(e)&&(e.deleteNodes(),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.DELETE_WORD_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.deleteWord(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.DELETE_LINE_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.deleteLine(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.CONTROLLED_TEXT_INSERTION_COMMAND,(e=>{const n=lexical.$getSelection();if("string"==typeof e)null!==n&&n.insertText(e);else {if(null===n)return !1;const r=e.dataTransfer;if(null!=r)LexicalClipboard.$insertDataTransferForRichText(r,n,i);else if(lexical.$isRangeSelection(n)){const t=e.data;return t&&n.insertText(t),!0}}return !0}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.REMOVE_TEXT_COMMAND,(()=>{const t=lexical.$getSelection();return !!lexical.$isRangeSelection(t)&&(t.removeText(),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.FORMAT_TEXT_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.formatText(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.FORMAT_ELEMENT_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)&&!lexical.$isNodeSelection(e))return !1;const n=e.getNodes();for(const e of n){const n=LexicalUtils.$findMatchingParent(e,(t=>lexical.$isElementNode(t)&&!t.isInline()));null!==n&&n.setFormat(t);}return !0}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.INSERT_LINE_BREAK_COMMAND,(t=>{const e=lexical.$getSelection();return !!lexical.$isRangeSelection(e)&&(e.insertLineBreak(t),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND,(()=>{const t=lexical.$getSelection();return !!lexical.$isRangeSelection(t)&&(t.insertParagraph(),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.INSERT_TAB_COMMAND,(()=>(lexical.$insertNodes([lexical.$createTabNode()]),!0)),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.INDENT_CONTENT_COMMAND,(()=>St((t=>{const e=t.getIndent();t.setIndent(e+1);}))),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.OUTDENT_CONTENT_COMMAND,(()=>St((t=>{const e=t.getIndent();e>0&&t.setIndent(Math.max(0,e-1));}))),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_ARROW_UP_COMMAND,(t=>{const e=lexical.$getSelection();if(lexical.$isNodeSelection(e)){const t=e.getNodes();if(t.length>0)return t[0].selectPrevious(),!0}else if(lexical.$isRangeSelection(e)){const n=lexical.$getAdjacentNode(e.focus,!0);if(!t.shiftKey&&lexical.$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),!0}return !1}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND,(t=>{const e=lexical.$getSelection();if(lexical.$isNodeSelection(e)){const t=e.getNodes();if(t.length>0)return t[0].selectNext(0,0),!0}else if(lexical.$isRangeSelection(e)){if(function(t){const e=t.focus;return "root"===e.key&&e.offset===lexical.$getRoot().getChildrenSize()}(e))return t.preventDefault(),!0;const n=lexical.$getAdjacentNode(e.focus,!1);if(!t.shiftKey&&lexical.$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),!0}return !1}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND,(t=>{const e=lexical.$getSelection();if(lexical.$isNodeSelection(e)){const r=e.getNodes();if(r.length>0)return t.preventDefault(),LexicalSelection.$isParentRTL(r[0])?r[0].selectNext(0,0):r[0].selectPrevious(),!0}if(!lexical.$isRangeSelection(e))return !1;if(LexicalSelection.$shouldOverrideDefaultCharacterSelection(e,!0)){const n=t.shiftKey;return t.preventDefault(),LexicalSelection.$moveCharacter(e,n,!0),!0}return !1}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND,(t=>{const e=lexical.$getSelection();if(lexical.$isNodeSelection(e)){const r=e.getNodes();if(r.length>0)return t.preventDefault(),LexicalSelection.$isParentRTL(r[0])?r[0].selectPrevious():r[0].selectNext(0,0),!0}if(!lexical.$isRangeSelection(e))return !1;const i=t.shiftKey;return !!LexicalSelection.$shouldOverrideDefaultCharacterSelection(e,!1)&&(t.preventDefault(),LexicalSelection.$moveCharacter(e,i,!1),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_BACKSPACE_COMMAND,(t=>{if(It(t.target))return !1;const e=lexical.$getSelection();if(lexical.$isRangeSelection(e)){if(function(t){if(!t.isCollapsed())return !1;const{anchor:e}=t;if(0!==e.offset)return !1;const n=e.getNode();if(lexical.$isRootNode(n))return !1;const r=LexicalUtils.$getNearestBlockElementAncestorOrThrow(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(e))return t.preventDefault(),i.dispatchCommand(lexical.OUTDENT_CONTENT_COMMAND,void 0);if(Ct&&"ko-KR"===navigator.language)return !1}else if(!lexical.$isNodeSelection(e))return !1;return t.preventDefault(),i.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND,!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_DELETE_COMMAND,(t=>{if(It(t.target))return !1;const e=lexical.$getSelection();return !(!lexical.$isRangeSelection(e)&&!lexical.$isNodeSelection(e))&&(t.preventDefault(),i.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND,!1))}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_ENTER_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;if(Mt(e),null!==t){if((Ct||ht||yt)&&pt)return !1;if(t.preventDefault(),t.shiftKey)return i.dispatchCommand(lexical.INSERT_LINE_BREAK_COMMAND,!1)}return i.dispatchCommand(lexical.INSERT_PARAGRAPH_COMMAND,void 0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_ESCAPE_COMMAND,(()=>{const t=lexical.$getSelection();return !!lexical.$isRangeSelection(t)&&(i.blur(),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.DROP_COMMAND,(t=>{const[,e]=Pt(t);if(e.length>0){const n=mt(t.clientX,t.clientY);if(null!==n){const{offset:t,node:r}=n,o=lexical.$getNearestNodeFromDOMNode(r);if(null!==o){const e=lexical.$createRangeSelection();if(lexical.$isTextNode(o))e.anchor.set(o.getKey(),t,"text"),e.focus.set(o.getKey(),t,"text");else {const t=o.getParentOrThrow().getKey(),n=o.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element");}const n=lexical.$normalizeSelection__EXPERIMENTAL(e);lexical.$setSelection(n);}i.dispatchCommand(Dt,e);}return t.preventDefault(),!0}const n=lexical.$getSelection();return !!lexical.$isRangeSelection(n)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.DRAGSTART_COMMAND,(t=>{const[e]=Pt(t),n=lexical.$getSelection();return !(e&&!lexical.$isRangeSelection(n))}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.DRAGOVER_COMMAND,(t=>{const[e]=Pt(t),n=lexical.$getSelection();if(e&&!lexical.$isRangeSelection(n))return !1;const r=mt(t.clientX,t.clientY);if(null!==r){const e=lexical.$getNearestNodeFromDOMNode(r.node);lexical.$isDecoratorNode(e)&&t.preventDefault();}return !0}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.SELECT_ALL_COMMAND,(()=>(lexical.$selectAll(),!0)),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.COPY_COMMAND,(t=>(LexicalClipboard.copyToClipboard(i,LexicalUtils.objectKlassEquals(t,ClipboardEvent)?t:null),!0)),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.CUT_COMMAND,(t=>(async function(t,n){await LexicalClipboard.copyToClipboard(n,LexicalUtils.objectKlassEquals(t,ClipboardEvent)?t:null),n.update((()=>{const t=lexical.$getSelection();lexical.$isRangeSelection(t)?t.removeText():lexical.$isNodeSelection(t)&&t.getNodes().forEach((t=>t.remove()));}));}(t,i),!0)),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.PASTE_COMMAND,(e=>{const[,n,r]=Pt(e);if(n.length>0&&!r)return i.dispatchCommand(Dt,n),!0;if(lexical.isDOMNode(e.target)&&lexical.isSelectionCapturedInDecoratorInput(e.target))return !1;return null!==lexical.$getSelection()&&(function(e,n){e.preventDefault(),n.update((()=>{const r=lexical.$getSelection(),o=LexicalUtils.objectKlassEquals(e,InputEvent)||LexicalUtils.objectKlassEquals(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&LexicalClipboard.$insertDataTransferForRichText(o,r,n);}),{tag:lexical.PASTE_TAG});}(e,i),!0)}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_SPACE_COMMAND,(t=>{const e=lexical.$getSelection();return lexical.$isRangeSelection(e)&&Mt(e),!1}),lexical.COMMAND_PRIORITY_EDITOR),i.registerCommand(lexical.KEY_TAB_COMMAND,(t=>{const e=lexical.$getSelection();return lexical.$isRangeSelection(e)&&Mt(e),!1}),lexical.COMMAND_PRIORITY_EDITOR))}
17
17
 
18
- exports.$createHeadingNode = Tt;
19
- exports.$createQuoteNode = Dt;
20
- exports.$isHeadingNode = _t;
21
- exports.$isQuoteNode = xt;
22
- exports.DRAG_DROP_PASTE = vt;
23
- exports.HeadingNode = wt;
24
- exports.QuoteNode = yt;
25
- exports.eventFiles = At;
26
- exports.registerRichText = Pt;
18
+ exports.$createHeadingNode = At;
19
+ exports.$createQuoteNode = Nt;
20
+ exports.$isHeadingNode = Ft;
21
+ exports.$isQuoteNode = wt;
22
+ exports.DRAG_DROP_PASTE = Dt;
23
+ exports.HeadingNode = Et;
24
+ exports.QuoteNode = xt;
25
+ exports.eventFiles = Pt;
26
+ exports.registerRichText = bt;
@@ -208,6 +208,44 @@ function getCSSFromStyleObject(styles) {
208
208
  return css;
209
209
  }
210
210
 
211
+ /**
212
+ * Gets the computed DOM styles of the element.
213
+ * @param node - The node to check the styles for.
214
+ * @returns the computed styles of the element or null if there is no DOM element or no default view for the document.
215
+ */
216
+ function $getComputedStyleForElement(element) {
217
+ const editor = lexical.$getEditor();
218
+ const domElement = editor.getElementByKey(element.getKey());
219
+ if (domElement === null) {
220
+ return null;
221
+ }
222
+ const view = domElement.ownerDocument.defaultView;
223
+ if (view === null) {
224
+ return null;
225
+ }
226
+ return view.getComputedStyle(domElement);
227
+ }
228
+
229
+ /**
230
+ * Gets the computed DOM styles of the parent of the node.
231
+ * @param node - The node to check its parent's styles for.
232
+ * @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
233
+ */
234
+ function $getComputedStyleForParent(node) {
235
+ const parent = lexical.$isRootNode(node) ? node : node.getParentOrThrow();
236
+ return $getComputedStyleForElement(parent);
237
+ }
238
+
239
+ /**
240
+ * Determines whether a node's parent is RTL.
241
+ * @param node - The node to check whether it is RTL.
242
+ * @returns whether the node is RTL.
243
+ */
244
+ function $isParentRTL(node) {
245
+ const styles = $getComputedStyleForParent(node);
246
+ return styles !== null && styles.direction === 'rtl';
247
+ }
248
+
211
249
  /**
212
250
  * Generally used to append text content to HTML and JSON. Grabs the text content and "slices"
213
251
  * it to be generated into the new TextNode.
@@ -217,7 +255,7 @@ function getCSSFromStyleObject(styles) {
217
255
  */
218
256
  function $sliceSelectedTextNodeContent(selection, textNode) {
219
257
  const anchorAndFocus = selection.getStartEndPoints();
220
- if (textNode.isSelected(selection) && !textNode.isSegmented() && !textNode.isToken() && anchorAndFocus !== null) {
258
+ if (textNode.isSelected(selection) && !lexical.$isTokenOrSegmented(textNode) && anchorAndFocus !== null) {
221
259
  const [anchor, focus] = anchorAndFocus;
222
260
  const isBackward = selection.isBackward();
223
261
  const anchorNode = anchor.getNode();
@@ -243,8 +281,11 @@ function $sliceSelectedTextNodeContent(selection, textNode) {
243
281
  startOffset = 0;
244
282
  endOffset = offset;
245
283
  }
284
+
285
+ // NOTE: This mutates __text directly because the primary use case is to
286
+ // modify a $cloneWithProperties node that should never be added
287
+ // to the EditorState so we must not call getWritable via setTextContent
246
288
  textNode.__text = textNode.__text.slice(startOffset, endOffset);
247
- return textNode;
248
289
  }
249
290
  }
250
291
  return textNode;
@@ -553,6 +594,11 @@ function $setBlocksType(selection, $createElement, $afterCreateElement = $copyBl
553
594
  for (const node of selection.getNodes()) {
554
595
  if (lexical.$isElementNode(node) && lexical.INTERNAL_$isBlock(node)) {
555
596
  blockMap.set(node.getKey(), node);
597
+ } else if (anchorAndFocus === null) {
598
+ const ancestorBlock = $getAncestor(node, lexical.INTERNAL_$isBlock);
599
+ if (lexical.$isElementNode(ancestorBlock)) {
600
+ blockMap.set(ancestorBlock.getKey(), ancestorBlock);
601
+ }
556
602
  }
557
603
  }
558
604
  for (const [key, prevNode] of blockMap) {
@@ -588,7 +634,7 @@ function $removeParentEmptyElements(startingNode) {
588
634
  }
589
635
 
590
636
  /**
591
- * @deprecated
637
+ * @deprecated In favor of $setBlockTypes
592
638
  * Wraps all nodes in the selection into another node of the type returned by createElement.
593
639
  * @param selection - The selection of nodes to be wrapped.
594
640
  * @param createElement - A function that creates the wrapping ElementNode. eg. $createParagraphNode.
@@ -790,6 +836,29 @@ function $wrapNodesImpl(selection, nodes, nodesLength, createElement, wrappingEl
790
836
  }
791
837
  }
792
838
 
839
+ /**
840
+ * Tests if the selection's parent element has vertical writing mode.
841
+ * @param selection - The selection whose parent to test.
842
+ * @returns true if the selection's parent has vertical writing mode (writing-mode: vertical-rl), false otherwise.
843
+ */
844
+ function $isEditorVerticalOrientation(selection) {
845
+ const computedStyle = $getComputedStyle(selection);
846
+ return computedStyle !== null && computedStyle.writingMode === 'vertical-rl';
847
+ }
848
+
849
+ /**
850
+ * Gets the computed DOM styles of the parent of the selection's anchor node.
851
+ * @param selection - The selection to check the styles for.
852
+ * @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
853
+ */
854
+ function $getComputedStyle(selection) {
855
+ const anchorNode = selection.anchor.getNode();
856
+ if (lexical.$isElementNode(anchorNode)) {
857
+ return $getComputedStyleForElement(anchorNode);
858
+ }
859
+ return $getComputedStyleForParent(anchorNode);
860
+ }
861
+
793
862
  /**
794
863
  * Determines if the default character selection should be overridden. Used with DecoratorNodes
795
864
  * @param selection - The selection whose default character selection may need to be overridden.
@@ -797,7 +866,16 @@ function $wrapNodesImpl(selection, nodes, nodesLength, createElement, wrappingEl
797
866
  * @returns true if it should be overridden, false if not.
798
867
  */
799
868
  function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
800
- const focusCaret = lexical.$caretFromPoint(selection.focus, isBackward ? 'previous' : 'next');
869
+ const isVertical = $isEditorVerticalOrientation(selection);
870
+
871
+ // In vertical writing mode, we adjust the direction for correct caret movement
872
+ let adjustedIsBackward = isVertical ? !isBackward : isBackward;
873
+
874
+ // In right-to-left writing mode, we invert the direction for correct caret movement
875
+ if ($isParentElementRTL(selection)) {
876
+ adjustedIsBackward = !adjustedIsBackward;
877
+ }
878
+ const focusCaret = lexical.$caretFromPoint(selection.focus, adjustedIsBackward ? 'previous' : 'next');
801
879
  if (lexical.$isExtendableTextPointCaret(focusCaret)) {
802
880
  return false;
803
881
  }
@@ -831,9 +909,8 @@ function $moveCaretSelection(selection, isHoldingShift, isBackward, granularity)
831
909
  * @returns true if the selections' parent element has a direction of 'rtl' (right to left), false otherwise.
832
910
  */
833
911
  function $isParentElementRTL(selection) {
834
- const anchorNode = selection.anchor.getNode();
835
- const parent = lexical.$isRootNode(anchorNode) ? anchorNode : anchorNode.getParentOrThrow();
836
- return parent.getDirection() === 'rtl';
912
+ const computedStyle = $getComputedStyle(selection);
913
+ return computedStyle !== null && computedStyle.direction === 'rtl';
837
914
  }
838
915
 
839
916
  /**
@@ -844,7 +921,26 @@ function $isParentElementRTL(selection) {
844
921
  */
845
922
  function $moveCharacter(selection, isHoldingShift, isBackward) {
846
923
  const isRTL = $isParentElementRTL(selection);
847
- $moveCaretSelection(selection, isHoldingShift, isBackward ? !isRTL : isRTL, 'character');
924
+ const isVertical = $isEditorVerticalOrientation(selection);
925
+
926
+ // In vertical-rl writing mode, arrow key directions need to be flipped
927
+ // to match the visual flow of text (top to bottom, right to left)
928
+ let adjustedIsBackward;
929
+ if (isVertical) {
930
+ // In vertical-rl mode, we need to completely invert the direction
931
+ // Left arrow (backward) should move down (forward)
932
+ // Right arrow (forward) should move up (backward)
933
+ adjustedIsBackward = !isBackward;
934
+ } else if (isRTL) {
935
+ // In horizontal RTL mode, use the standard RTL behavior
936
+ adjustedIsBackward = !isBackward;
937
+ } else {
938
+ // Standard LTR horizontal text
939
+ adjustedIsBackward = isBackward;
940
+ }
941
+
942
+ // Apply the direction adjustment to move the caret
943
+ $moveCaretSelection(selection, isHoldingShift, adjustedIsBackward, 'character');
848
944
  }
849
945
 
850
946
  /**
@@ -940,9 +1036,12 @@ exports.$addNodeStyle = $addNodeStyle;
940
1036
  exports.$copyBlockFormatIndent = $copyBlockFormatIndent;
941
1037
  exports.$ensureForwardRangeSelection = $ensureForwardRangeSelection;
942
1038
  exports.$forEachSelectedTextNode = $forEachSelectedTextNode;
1039
+ exports.$getComputedStyleForElement = $getComputedStyleForElement;
1040
+ exports.$getComputedStyleForParent = $getComputedStyleForParent;
943
1041
  exports.$getSelectionStyleValueForProperty = $getSelectionStyleValueForProperty;
944
1042
  exports.$isAtNodeEnd = $isAtNodeEnd;
945
1043
  exports.$isParentElementRTL = $isParentElementRTL;
1044
+ exports.$isParentRTL = $isParentRTL;
946
1045
  exports.$moveCaretSelection = $moveCaretSelection;
947
1046
  exports.$moveCharacter = $moveCharacter;
948
1047
  exports.$patchStyleText = $patchStyleText;
@@ -16,20 +16,24 @@ const $addNodeStyle = mod.$addNodeStyle;
16
16
  const $getSelectionStyleValueForProperty = mod.$getSelectionStyleValueForProperty;
17
17
  const $isAtNodeEnd = mod.$isAtNodeEnd;
18
18
  const $isParentElementRTL = mod.$isParentElementRTL;
19
+ const $isParentRTL = mod.$isParentRTL;
19
20
  const $moveCharacter = mod.$moveCharacter;
20
21
  const $patchStyleText = mod.$patchStyleText;
21
22
  const $setBlocksType = mod.$setBlocksType;
22
23
  const $shouldOverrideDefaultCharacterSelection = mod.$shouldOverrideDefaultCharacterSelection;
23
24
  const $sliceSelectedTextNodeContent = mod.$sliceSelectedTextNodeContent;
24
25
  const createRectsFromDOMRange = mod.createRectsFromDOMRange;
26
+ const getStyleObjectFromCSS = mod.getStyleObjectFromCSS;
25
27
 
26
28
  exports.$addNodeStyle = $addNodeStyle;
27
29
  exports.$getSelectionStyleValueForProperty = $getSelectionStyleValueForProperty;
28
30
  exports.$isAtNodeEnd = $isAtNodeEnd;
29
31
  exports.$isParentElementRTL = $isParentElementRTL;
32
+ exports.$isParentRTL = $isParentRTL;
30
33
  exports.$moveCharacter = $moveCharacter;
31
34
  exports.$patchStyleText = $patchStyleText;
32
35
  exports.$setBlocksType = $setBlocksType;
33
36
  exports.$shouldOverrideDefaultCharacterSelection = $shouldOverrideDefaultCharacterSelection;
34
37
  exports.$sliceSelectedTextNodeContent = $sliceSelectedTextNodeContent;
35
38
  exports.createRectsFromDOMRange = createRectsFromDOMRange;
39
+ exports.getStyleObjectFromCSS = getStyleObjectFromCSS;