@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.
- package/{src/editor/Lexical.module.css → css/_lexical.css} +8 -4
- package/css/styles.css +24 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +62 -20
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +643 -245
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +1 -1
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +29 -22
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +13 -6
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +1 -1
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +242 -141
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +1 -1
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +594 -255
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +1 -1
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +23 -16
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +102 -53
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +275 -194
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +5 -1
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +28 -18
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +2293 -878
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +1 -1
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +53 -40
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +471 -193
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +13 -1
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -32
- package/dist/cjs/node_modules/prismjs/prism.js +1 -1
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +1 -1
- package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +30 -5
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +86 -83
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +25 -17
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +62 -20
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +637 -246
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +1 -1
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +14 -7
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +1 -1
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +244 -144
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +1 -1
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +590 -257
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +1 -1
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +104 -55
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +267 -196
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +4 -2
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +2283 -881
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +1 -1
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +457 -194
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +8 -2
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
- package/dist/esm/node_modules/prismjs/prism.js +1 -1
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +1 -1
- package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +30 -5
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +88 -85
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +25 -17
- package/dist/types/editor/LexicalEditor.d.ts +25 -0
- package/dist/types/hooks/useFormatWatcher.d.ts +2 -2
- package/dist/types/nodes/StickyNode.d.ts +0 -1
- package/package.json +14 -13
- package/src/components/StickyComponent.tsx +2 -2
- package/src/editor/LexicalEditor.tsx +57 -26
- package/src/hooks/useFormatWatcher.ts +35 -31
- package/src/plugins/ToolbarPlugin.tsx +27 -17
- package/dist/cjs/editor/Lexical.module.css +0 -1
- package/dist/esm/editor/Lexical.module.css +0 -1
|
@@ -11,7 +11,7 @@ var LexicalList_prod = require('./LexicalList.prod.js');
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
const mod = process.env.NODE_ENV
|
|
14
|
+
const mod = process.env.NODE_ENV !== 'production' ? LexicalList_dev : LexicalList_prod;
|
|
15
15
|
const $isListNode = mod.$isListNode;
|
|
16
16
|
const INSERT_CHECK_LIST_COMMAND = mod.INSERT_CHECK_LIST_COMMAND;
|
|
17
17
|
const INSERT_ORDERED_LIST_COMMAND = mod.INSERT_ORDERED_LIST_COMMAND;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var lexical = require('lexical');
|
|
4
3
|
var LexicalUtils = require('../utils/LexicalUtils.js');
|
|
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,19 +12,25 @@ var LexicalUtils = require('../utils/LexicalUtils.js');
|
|
|
11
12
|
*
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
|
-
function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _=p((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.`)}));function m(e){let t=1,n=e.getParent();for(;null!=n;){if(B(n)){const e=n.getParent();if($(e)){t++,n=e.getParent();continue}_(40);}return t}return t}function v(e){let t=e.getParent();$(t)||_(40);let n=t;for(;null!==n;)n=n.getParent(),$(n)&&(t=n);return t}function y(e){let t=[];const n=e.getChildren().filter(B);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();$(i)?t=t.concat(y(i)):t.push(r);}return t}function C(e){return B(e)&&$(e.getFirstChild())}function k(e){return R().append(e)}function T(e,t){return B(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function b(s,o){s.update((()=>{const s=lexical.$getSelection();if(null!==s){const e=s.getNodes();if(lexical.$isRangeSelection(s)){const t=s.getStartEndPoints();null===t&&_(143);const[i]=t,c=i.getNode(),l=c.getParent();if(T(c,e)){const e=U(o);if(lexical.$isRootOrShadowRoot(l)){c.replace(e);const t=R();lexical.$isElementNode(c)&&(t.setFormat(c.getFormatType()),t.setIndent(c.getIndent())),e.append(t);}else if(B(c)){const t=c.getParentOrThrow();S(e,t.getChildren()),t.replace(e);}return}}const c=new Set;for(let t=0;t<e.length;t++){const s=e[t];if(!lexical.$isElementNode(s)||!s.isEmpty()||B(s)||c.has(s.getKey())){if(lexical.$isLeafNode(s)){let e=s.getParent();for(;null!=e;){const t=e.getKey();if($(e)){if(!c.has(t)){const n=U(o);S(n,e.getChildren()),e.replace(n),c.add(t);}break}{const r=e.getParent();if(lexical.$isRootOrShadowRoot(r)&&!c.has(t)){c.add(t),P(e,o);break}e=r;}}}}else P(s,o);}}}));}function S(e,t){e.splice(e.getChildrenSize(),0,t);}function P(e,t){if($(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=R();if(i.setFormat(e.getFormatType()),i.setIndent(e.getIndent()),S(i,e.getChildren()),$(n)&&t===n.getListType())return n.append(i),e.remove(),$(r)&&t===r.getListType()&&(S(n,r.getChildren()),r.remove()),n;if($(r)&&t===r.getListType())return r.getFirstChildOrThrow().insertBefore(i),e.remove(),r;{const n=U(t);return n.append(i),e.replace(n),n}}function A(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&C(n)&&C(r)&&(A(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove();}function N(n){n.update((()=>{const n=lexical.$getSelection();if(lexical.$isRangeSelection(n)){const e=new Set,t=n.getNodes(),r=n.anchor.getNode();if(T(r,t))e.add(v(r));else for(let n=0;n<t.length;n++){const r=t[n];if(lexical.$isLeafNode(r)){const t=LexicalUtils.$getNearestNodeOfType(r,M);null!=t&&e.add(v(t));}}for(const t of e){let e=t;const r=y(t);for(const t of r){const r=lexical.$createParagraphNode();S(r,t.getChildren()),e.insertAfter(r),e=r,t.__key===n.anchor.key&&n.anchor.set(r.getKey(),0,"element"),t.__key===n.focus.key&&n.focus.set(r.getKey(),0,"element"),t.remove();}t.remove();}}}));}function x(e){const t=new Set;if(C(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(C(r)&&C(i)){const n=i.getFirstChild();if($(n)){n.append(e);const i=r.getFirstChild();if($(i)){S(n,i.getChildren()),r.remove(),t.add(r.getKey());}}}else if(C(r)){const t=r.getFirstChild();if($(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e);}}else if(C(i)){const t=i.getFirstChild();$(t)&&t.append(e);}else if($(n)){const t=R(),s=U(n.getListType());t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t);}}function L(e){if(C(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if($(n?n.getParent():void 0)&&B(n)&&$(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else {const r=t.getListType(),i=R(),s=U(r);i.append(s),e.getPreviousSiblings().forEach((e=>s.append(e)));const o=R(),c=U(r);o.append(c),S(c,e.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(e);}}}function O(){const r=lexical.$getSelection();if(!lexical.$isRangeSelection(r)||!r.isCollapsed())return !1;const i=r.anchor.getNode();if(!B(i)||0!==i.getChildrenSize())return !1;const c=v(i),l=i.getParent();$(l)||_(40);const a=l.getParent();let h;if(lexical.$isRootOrShadowRoot(a))h=lexical.$createParagraphNode(),c.insertAfter(h);else {if(!B(a))return !1;h=R(),a.insertAfter(h);}h.select();const u=i.getNextSiblings();if(u.length>0){const e=U(l.getListType());if(lexical.$isParagraphNode(h))h.insertAfter(e);else {const t=R();t.append(e),h.insertAfter(t);}u.forEach((t=>{t.remove(),e.append(t);}));}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!B(t)&&!$(t))break;t=e;}t.remove();}(i),!0}function E(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}class M extends lexical.ElementNode{static getType(){return "listitem"}static clone(e){return new M(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=void 0===e?1:e,this.__checked=t;}createDOM(e){const t=document.createElement("li"),n=this.getParent();return $(n)&&"check"===n.getListType()&&w(t,this,null),t.value=this.__value,F(t,e.theme,this),t}updateDOM(e,t,n){const r=this.getParent();return $(r)&&"check"===r.getListType()&&w(t,this,e),t.value=this.__value,F(t,n.theme,this),!1}static transform(){return e=>{if(B(e)||_(144),null==e.__checked)return;const t=e.getParent();$(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);}}static importDOM(){return {li:()=>({conversion:D,priority:0})}}static importJSON(e){const t=R();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return {...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(lexical.$isElementNode(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove();}else super.append(n);}return this}replace(e,t){if(B(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!$(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else {const t=U(n.getListType());let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e);}n.insertAfter(e),e.insertAfter(t);}return t&&(lexical.$isElementNode(e)||_(139),this.getChildren().forEach((t=>{e.append(t);}))),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if($(n)||_(39),B(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=U(n.getListType());r.forEach((e=>i.append(e))),e.insertAfter(i,t);}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&C(t)&&C(n)&&(A(t.getFirstChild(),n.getFirstChild()),n.remove());}insertNewAfter(e,t=!0){const n=R(null==this.__checked&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=lexical.$createParagraphNode();this.getChildren().forEach((e=>t.append(e)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=B(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else {n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.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(t),this.remove();return !0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e;}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return $(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){this.getWritable().__checked=e;}toggleChecked(){this.setChecked(!this.__checked);}getIndent(){const e=this.getParent();if(null===e)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;B(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&_(117),(e=Math.floor(e))>=0||_(199);let t=this.getIndent();for(;t!==e;)t<e?(x(this),t++):(L(this),t--);return this}canInsertAfter(e){return B(e)}canReplaceWith(e){return B(e)}canMergeWith(e){return lexical.$isParagraphNode(e)||B(e)}extractWithChild(e,n){if(!lexical.$isRangeSelection(n))return !1;const r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return !0}createParentElementNode(){return U("bullet")}canMergeWhenEmpty(){return !0}}function F(e,t,n){const r=[],i=[],s=t.list,o=s?s.listitem:void 0;let c;if(s&&s.nested&&(c=s.nested.listitem),void 0!==o&&r.push(...E(o)),s){const e=n.getParent(),t=$(e)&&"check"===e.getListType(),o=n.getChecked();t&&!o||i.push(s.listitemUnchecked),t&&o||i.push(s.listitemChecked),t&&r.push(o?s.listitemChecked:s.listitemUnchecked);}if(void 0!==c){const e=E(c);n.getChildren().some((e=>$(e)))?r.push(...e):i.push(...e);}i.length>0&&LexicalUtils.removeClassNamesFromElement(e,...i),r.length>0&&LexicalUtils.addClassNamesToElement(e,...r);}function w(e,t,n,r){$(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"));}function D(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return I(t);const t=e.getAttribute("aria-checked");return {node:R("true"===t||"false"!==t&&void 0)}}function I(e){if(!("checkbox"===e.getAttribute("type")))return {node:null};return {node:R(e.hasAttribute("checked"))}}function R(e){return lexical.$applyNodeReplacement(new M(void 0,e))}function B(e){return e instanceof M}class K extends lexical.ElementNode{static getType(){return "list"}static clone(e){const t=e.__listType||z[e.__tag];return new K(t,e.__start,e.__key)}constructor(e,t,n){super(n);const r=z[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t;}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag="number"===e?"ol":"ul";}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,W(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||(W(t,n.theme,this),!1)}static transform(){return e=>{$(e)||_(163),function(e){const t=e.getNextSibling();$(t)&&e.getListType()===t.getListType()&&A(e,t);}(e),function(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())B(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),$(r.getFirstChild())||n++);}(e);}}static importDOM(){return {ol:()=>({conversion:J,priority:0}),ul:()=>({conversion:J,priority:0})}}static importJSON(e){const t=U(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const{element:t}=super.exportDOM(e);return t&&LexicalUtils.isHTMLElement(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return {...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return !1}canIndent(){return !1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(B(n))super.append(n);else {const e=R();if($(n))e.append(n);else if(lexical.$isElementNode(n)){const t=lexical.$createTextNode(n.getTextContent());e.append(t);}else e.append(n);super.append(e);}}return this}extractWithChild(e){return B(e)}}function W(e,t,n){const r=[],i=[],s=t.list;if(void 0!==s){const e=s[`${n.__tag}Depth`]||[],t=m(n)-1,o=t%e.length,c=e[o],l=s[n.__tag];let a;const h=s.nested,u=s.checklist;if(void 0!==h&&h.list&&(a=h.list),void 0!==l&&r.push(l),void 0!==u&&"check"===n.__listType&&r.push(u),void 0!==c){r.push(...E(c));for(let t=0;t<e.length;t++)t!==o&&i.push(n.__tag+t);}if(void 0!==a){const e=E(a);t>1?r.push(...e):i.push(...e);}}i.length>0&&LexicalUtils.removeClassNamesFromElement(e,...i),r.length>0&&LexicalUtils.addClassNamesToElement(e,...r);}function V(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(B(r)){t.push(r);const e=r.getChildren();e.length>1&&e.forEach((e=>{$(e)&&t.push(k(e));}));}else t.push(k(r));}return t}function J(e){const t=e.nodeName.toLowerCase();let n=null;if("ol"===t){n=U("number",e.start);}else "ul"===t&&(n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list"))return !0;for(const t of e.childNodes)if(LexicalUtils.isHTMLElement(t)&&t.hasAttribute("aria-checked"))return !0;return !1}(e)?U("check"):U("bullet"));return {after:V,node:n}}const z={ol:"number",ul:"bullet"};function U(e,t=1){return lexical.$applyNodeReplacement(new K(e,t))}function $(e){return e instanceof K}const j=lexical.createCommand("INSERT_UNORDERED_LIST_COMMAND"),q=lexical.createCommand("INSERT_ORDERED_LIST_COMMAND"),H=lexical.createCommand("INSERT_CHECK_LIST_COMMAND"),G=lexical.createCommand("REMOVE_LIST_COMMAND");
|
|
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 =
|
|
17
|
-
exports.$createListNode =
|
|
18
|
-
exports.$getListDepth =
|
|
19
|
-
exports.$handleListInsertParagraph =
|
|
20
|
-
exports.$
|
|
21
|
-
exports.$
|
|
22
|
-
exports
|
|
23
|
-
exports
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
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;
|
|
@@ -94,9 +94,6 @@ class QuoteNode extends lexical.ElementNode {
|
|
|
94
94
|
static clone(node) {
|
|
95
95
|
return new QuoteNode(node.__key);
|
|
96
96
|
}
|
|
97
|
-
constructor(key) {
|
|
98
|
-
super(key);
|
|
99
|
-
}
|
|
100
97
|
|
|
101
98
|
// View
|
|
102
99
|
|
|
@@ -120,12 +117,14 @@ class QuoteNode extends lexical.ElementNode {
|
|
|
120
117
|
const {
|
|
121
118
|
element
|
|
122
119
|
} = super.exportDOM(editor);
|
|
123
|
-
if (
|
|
120
|
+
if (LexicalUtils.isHTMLElement(element)) {
|
|
124
121
|
if (this.isEmpty()) {
|
|
125
122
|
element.append(document.createElement('br'));
|
|
126
123
|
}
|
|
127
124
|
const formatType = this.getFormatType();
|
|
128
|
-
|
|
125
|
+
if (formatType) {
|
|
126
|
+
element.style.textAlign = formatType;
|
|
127
|
+
}
|
|
129
128
|
const direction = this.getDirection();
|
|
130
129
|
if (direction) {
|
|
131
130
|
element.dir = direction;
|
|
@@ -136,17 +135,7 @@ class QuoteNode extends lexical.ElementNode {
|
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
137
|
static importJSON(serializedNode) {
|
|
139
|
-
|
|
140
|
-
node.setFormat(serializedNode.format);
|
|
141
|
-
node.setIndent(serializedNode.indent);
|
|
142
|
-
node.setDirection(serializedNode.direction);
|
|
143
|
-
return node;
|
|
144
|
-
}
|
|
145
|
-
exportJSON() {
|
|
146
|
-
return {
|
|
147
|
-
...super.exportJSON(),
|
|
148
|
-
type: 'quote'
|
|
149
|
-
};
|
|
138
|
+
return $createQuoteNode().updateFromJSON(serializedNode);
|
|
150
139
|
}
|
|
151
140
|
|
|
152
141
|
// Mutation
|
|
@@ -192,6 +181,11 @@ class HeadingNode extends lexical.ElementNode {
|
|
|
192
181
|
getTag() {
|
|
193
182
|
return this.__tag;
|
|
194
183
|
}
|
|
184
|
+
setTag(tag) {
|
|
185
|
+
const self = this.getWritable();
|
|
186
|
+
this.__tag = tag;
|
|
187
|
+
return self;
|
|
188
|
+
}
|
|
195
189
|
|
|
196
190
|
// View
|
|
197
191
|
|
|
@@ -206,8 +200,8 @@ class HeadingNode extends lexical.ElementNode {
|
|
|
206
200
|
}
|
|
207
201
|
return element;
|
|
208
202
|
}
|
|
209
|
-
updateDOM(prevNode, dom) {
|
|
210
|
-
return
|
|
203
|
+
updateDOM(prevNode, dom, config) {
|
|
204
|
+
return prevNode.__tag !== this.__tag;
|
|
211
205
|
}
|
|
212
206
|
static importDOM() {
|
|
213
207
|
return {
|
|
@@ -268,12 +262,14 @@ class HeadingNode extends lexical.ElementNode {
|
|
|
268
262
|
const {
|
|
269
263
|
element
|
|
270
264
|
} = super.exportDOM(editor);
|
|
271
|
-
if (
|
|
265
|
+
if (LexicalUtils.isHTMLElement(element)) {
|
|
272
266
|
if (this.isEmpty()) {
|
|
273
267
|
element.append(document.createElement('br'));
|
|
274
268
|
}
|
|
275
269
|
const formatType = this.getFormatType();
|
|
276
|
-
|
|
270
|
+
if (formatType) {
|
|
271
|
+
element.style.textAlign = formatType;
|
|
272
|
+
}
|
|
277
273
|
const direction = this.getDirection();
|
|
278
274
|
if (direction) {
|
|
279
275
|
element.dir = direction;
|
|
@@ -284,18 +280,15 @@ class HeadingNode extends lexical.ElementNode {
|
|
|
284
280
|
};
|
|
285
281
|
}
|
|
286
282
|
static importJSON(serializedNode) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return node;
|
|
283
|
+
return $createHeadingNode(serializedNode.tag).updateFromJSON(serializedNode);
|
|
284
|
+
}
|
|
285
|
+
updateFromJSON(serializedNode) {
|
|
286
|
+
return super.updateFromJSON(serializedNode).setTag(serializedNode.tag);
|
|
292
287
|
}
|
|
293
288
|
exportJSON() {
|
|
294
289
|
return {
|
|
295
290
|
...super.exportJSON(),
|
|
296
|
-
tag: this.getTag()
|
|
297
|
-
type: 'heading',
|
|
298
|
-
version: 1
|
|
291
|
+
tag: this.getTag()
|
|
299
292
|
};
|
|
300
293
|
}
|
|
301
294
|
|
|
@@ -338,6 +331,7 @@ function $convertHeadingElement(element) {
|
|
|
338
331
|
if (nodeName === 'h1' || nodeName === 'h2' || nodeName === 'h3' || nodeName === 'h4' || nodeName === 'h5' || nodeName === 'h6') {
|
|
339
332
|
node = $createHeadingNode(nodeName);
|
|
340
333
|
if (element.style !== null) {
|
|
334
|
+
lexical.setNodeIndentFromDOM(element, node);
|
|
341
335
|
node.setFormat(element.style.textAlign);
|
|
342
336
|
}
|
|
343
337
|
}
|
|
@@ -349,12 +343,13 @@ function $convertBlockquoteElement(element) {
|
|
|
349
343
|
const node = $createQuoteNode();
|
|
350
344
|
if (element.style !== null) {
|
|
351
345
|
node.setFormat(element.style.textAlign);
|
|
346
|
+
lexical.setNodeIndentFromDOM(element, node);
|
|
352
347
|
}
|
|
353
348
|
return {
|
|
354
349
|
node
|
|
355
350
|
};
|
|
356
351
|
}
|
|
357
|
-
function $createHeadingNode(headingTag) {
|
|
352
|
+
function $createHeadingNode(headingTag = 'h1') {
|
|
358
353
|
return lexical.$applyNodeReplacement(new HeadingNode(headingTag));
|
|
359
354
|
}
|
|
360
355
|
function $isHeadingNode(node) {
|
|
@@ -369,7 +364,7 @@ function onPasteForRichText(event, editor) {
|
|
|
369
364
|
LexicalClipboard.$insertDataTransferForRichText(clipboardData, selection, editor);
|
|
370
365
|
}
|
|
371
366
|
}, {
|
|
372
|
-
tag:
|
|
367
|
+
tag: lexical.PASTE_TAG
|
|
373
368
|
});
|
|
374
369
|
}
|
|
375
370
|
async function onCutForRichText(event, editor) {
|
|
@@ -435,6 +430,36 @@ function $isSelectionAtEndOfRoot(selection) {
|
|
|
435
430
|
const focus = selection.focus;
|
|
436
431
|
return focus.key === 'root' && focus.offset === lexical.$getRoot().getChildrenSize();
|
|
437
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
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Resets the capitalization of the selection to default.
|
|
453
|
+
* Called when the user presses space, tab, or enter key.
|
|
454
|
+
* @param selection The selection to reset the capitalization of.
|
|
455
|
+
*/
|
|
456
|
+
function $resetCapitalization(selection) {
|
|
457
|
+
for (const format of ['lowercase', 'uppercase', 'capitalize']) {
|
|
458
|
+
if (selection.hasFormat(format)) {
|
|
459
|
+
selection.toggleFormat(format);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
438
463
|
function registerRichText(editor) {
|
|
439
464
|
const removeListener = LexicalUtils.mergeRegister(editor.registerCommand(lexical.CLICK_COMMAND, payload => {
|
|
440
465
|
const selection = lexical.$getSelection();
|
|
@@ -443,13 +468,16 @@ function registerRichText(editor) {
|
|
|
443
468
|
return true;
|
|
444
469
|
}
|
|
445
470
|
return false;
|
|
446
|
-
},
|
|
471
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DELETE_CHARACTER_COMMAND, isBackward => {
|
|
447
472
|
const selection = lexical.$getSelection();
|
|
448
|
-
if (
|
|
449
|
-
|
|
473
|
+
if (lexical.$isRangeSelection(selection)) {
|
|
474
|
+
selection.deleteCharacter(isBackward);
|
|
475
|
+
return true;
|
|
476
|
+
} else if (lexical.$isNodeSelection(selection)) {
|
|
477
|
+
selection.deleteNodes();
|
|
478
|
+
return true;
|
|
450
479
|
}
|
|
451
|
-
|
|
452
|
-
return true;
|
|
480
|
+
return false;
|
|
453
481
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DELETE_WORD_COMMAND, isBackward => {
|
|
454
482
|
const selection = lexical.$getSelection();
|
|
455
483
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -539,12 +567,12 @@ function registerRichText(editor) {
|
|
|
539
567
|
return $handleIndentAndOutdent(block => {
|
|
540
568
|
const indent = block.getIndent();
|
|
541
569
|
if (indent > 0) {
|
|
542
|
-
block.setIndent(indent - 1);
|
|
570
|
+
block.setIndent(Math.max(0, indent - 1));
|
|
543
571
|
}
|
|
544
572
|
});
|
|
545
573
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, event => {
|
|
546
574
|
const selection = lexical.$getSelection();
|
|
547
|
-
if (lexical.$isNodeSelection(selection)
|
|
575
|
+
if (lexical.$isNodeSelection(selection)) {
|
|
548
576
|
// If selection is on a node, let's try and move selection
|
|
549
577
|
// back to being a range selection.
|
|
550
578
|
const nodes = selection.getNodes();
|
|
@@ -592,7 +620,11 @@ function registerRichText(editor) {
|
|
|
592
620
|
const nodes = selection.getNodes();
|
|
593
621
|
if (nodes.length > 0) {
|
|
594
622
|
event.preventDefault();
|
|
595
|
-
nodes[0]
|
|
623
|
+
if (LexicalSelection.$isParentRTL(nodes[0])) {
|
|
624
|
+
nodes[0].selectNext(0, 0);
|
|
625
|
+
} else {
|
|
626
|
+
nodes[0].selectPrevious();
|
|
627
|
+
}
|
|
596
628
|
return true;
|
|
597
629
|
}
|
|
598
630
|
}
|
|
@@ -608,13 +640,17 @@ function registerRichText(editor) {
|
|
|
608
640
|
return false;
|
|
609
641
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND, event => {
|
|
610
642
|
const selection = lexical.$getSelection();
|
|
611
|
-
if (lexical.$isNodeSelection(selection)
|
|
643
|
+
if (lexical.$isNodeSelection(selection)) {
|
|
612
644
|
// If selection is on a node, let's try and move selection
|
|
613
645
|
// back to being a range selection.
|
|
614
646
|
const nodes = selection.getNodes();
|
|
615
647
|
if (nodes.length > 0) {
|
|
616
648
|
event.preventDefault();
|
|
617
|
-
nodes[0]
|
|
649
|
+
if (LexicalSelection.$isParentRTL(nodes[0])) {
|
|
650
|
+
nodes[0].selectPrevious();
|
|
651
|
+
} else {
|
|
652
|
+
nodes[0].selectNext(0, 0);
|
|
653
|
+
}
|
|
618
654
|
return true;
|
|
619
655
|
}
|
|
620
656
|
}
|
|
@@ -633,27 +669,27 @@ function registerRichText(editor) {
|
|
|
633
669
|
return false;
|
|
634
670
|
}
|
|
635
671
|
const selection = lexical.$getSelection();
|
|
636
|
-
if (
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
event.preventDefault();
|
|
640
|
-
const {
|
|
641
|
-
anchor
|
|
642
|
-
} = selection;
|
|
643
|
-
const anchorNode = anchor.getNode();
|
|
644
|
-
if (selection.isCollapsed() && anchor.offset === 0 && !lexical.$isRootNode(anchorNode)) {
|
|
645
|
-
const element = LexicalUtils.$getNearestBlockElementAncestorOrThrow(anchorNode);
|
|
646
|
-
if (element.getIndent() > 0) {
|
|
672
|
+
if (lexical.$isRangeSelection(selection)) {
|
|
673
|
+
if ($isSelectionCollapsedAtFrontOfIndentedBlock(selection)) {
|
|
674
|
+
event.preventDefault();
|
|
647
675
|
return editor.dispatchCommand(lexical.OUTDENT_CONTENT_COMMAND, undefined);
|
|
648
676
|
}
|
|
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)) {
|
|
683
|
+
return false;
|
|
649
684
|
}
|
|
685
|
+
event.preventDefault();
|
|
650
686
|
return editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, true);
|
|
651
687
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_DELETE_COMMAND, event => {
|
|
652
688
|
if ($isTargetWithinDecorator(event.target)) {
|
|
653
689
|
return false;
|
|
654
690
|
}
|
|
655
691
|
const selection = lexical.$getSelection();
|
|
656
|
-
if (!lexical.$isRangeSelection(selection)) {
|
|
692
|
+
if (!(lexical.$isRangeSelection(selection) || lexical.$isNodeSelection(selection))) {
|
|
657
693
|
return false;
|
|
658
694
|
}
|
|
659
695
|
event.preventDefault();
|
|
@@ -663,6 +699,7 @@ function registerRichText(editor) {
|
|
|
663
699
|
if (!lexical.$isRangeSelection(selection)) {
|
|
664
700
|
return false;
|
|
665
701
|
}
|
|
702
|
+
$resetCapitalization(selection);
|
|
666
703
|
if (event !== null) {
|
|
667
704
|
// If we have beforeinput, then we can avoid blocking
|
|
668
705
|
// the default behavior. This ensures that the iOS can
|
|
@@ -765,7 +802,7 @@ function registerRichText(editor) {
|
|
|
765
802
|
}
|
|
766
803
|
|
|
767
804
|
// if inputs then paste within the input ignore creating a new node on paste event
|
|
768
|
-
if (lexical.isSelectionCapturedInDecoratorInput(event.target)) {
|
|
805
|
+
if (lexical.isDOMNode(event.target) && lexical.isSelectionCapturedInDecoratorInput(event.target)) {
|
|
769
806
|
return false;
|
|
770
807
|
}
|
|
771
808
|
const selection = lexical.$getSelection();
|
|
@@ -774,6 +811,18 @@ function registerRichText(editor) {
|
|
|
774
811
|
return true;
|
|
775
812
|
}
|
|
776
813
|
return false;
|
|
814
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_SPACE_COMMAND, _ => {
|
|
815
|
+
const selection = lexical.$getSelection();
|
|
816
|
+
if (lexical.$isRangeSelection(selection)) {
|
|
817
|
+
$resetCapitalization(selection);
|
|
818
|
+
}
|
|
819
|
+
return false;
|
|
820
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_TAB_COMMAND, _ => {
|
|
821
|
+
const selection = lexical.$getSelection();
|
|
822
|
+
if (lexical.$isRangeSelection(selection)) {
|
|
823
|
+
$resetCapitalization(selection);
|
|
824
|
+
}
|
|
825
|
+
return false;
|
|
777
826
|
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
778
827
|
return removeListener;
|
|
779
828
|
}
|
|
@@ -11,7 +11,7 @@ var LexicalRichText_prod = require('./LexicalRichText.prod.js');
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
const mod = process.env.NODE_ENV
|
|
14
|
+
const mod = process.env.NODE_ENV !== 'production' ? LexicalRichText_dev : LexicalRichText_prod;
|
|
15
15
|
const $createHeadingNode = mod.$createHeadingNode;
|
|
16
16
|
const $createQuoteNode = mod.$createQuoteNode;
|
|
17
17
|
const $isHeadingNode = mod.$isHeadingNode;
|
|
@@ -13,14 +13,14 @@ var lexical = require('lexical');
|
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
function st(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 ct="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,at=ct&&"documentMode"in document?document.documentMode:null,ut=!(!ct||!("InputEvent"in window)||at)&&"getTargetRanges"in new window.InputEvent("input"),lt=ct&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),dt=ct&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,mt=ct&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ft=ct&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!mt,gt=lexical.createCommand("DRAG_DROP_PASTE_FILE");class pt extends lexical.ElementNode{static getType(){return "quote"}static clone(t){return new pt(t.__key)}constructor(t){super(t);}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:xt,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(e&&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){const e=ht();return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return {...super.exportJSON(),type:"quote"}}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 ht(){return lexical.$applyNodeReplacement(new pt)}function Ct(t){return t instanceof pt}class yt extends lexical.ElementNode{static getType(){return "heading"}static clone(t){return new yt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t;}getTag(){return this.__tag}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){return !1}static importDOM(){return {h1:t=>({conversion:Dt,priority:0}),h2:t=>({conversion:Dt,priority:0}),h3:t=>({conversion:Dt,priority:0}),h4:t=>({conversion:Dt,priority:0}),h5:t=>({conversion:Dt,priority:0}),h6:t=>({conversion:Dt,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&vt(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>vt(t)?{conversion:t=>({node:wt("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(e&&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){const e=wt(t.tag);return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return {...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}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():wt(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():wt(this.getTag());return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}extractWithChild(){return !0}}function vt(t){return "span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function Dt(t){const e=t.nodeName.toLowerCase();let n=null;return "h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=wt(e),null!==t.style&&n.setFormat(t.style.textAlign)),{node:n}}function xt(t){const e=ht();return null!==t.style&&e.setFormat(t.style.textAlign),{node:e}}function wt(t){return lexical.$applyNodeReplacement(new yt(t))}function Et(t){return t instanceof yt}function Nt(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 It(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 c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),t(s));}return n.size>0}function Ot(t){const e=lexical.$getNearestNodeFromDOMNode(t);return lexical.$isDecoratorNode(e)}function Tt(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,(()=>It((t=>{const e=t.getIndent();t.setIndent(e+1);}))),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.OUTDENT_CONTENT_COMMAND,(()=>It((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)&&!Ot(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)&&!Ot(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(Ot(t.target))return !1;const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;t.preventDefault();const{anchor:n}=e,r=n.getNode();if(e.isCollapsed()&&0===n.offset&&!lexical.$isRootNode(r)){if(LexicalUtils.$getNearestBlockElementAncestorOrThrow(r).getIndent()>0)return o.dispatchCommand(lexical.OUTDENT_CONTENT_COMMAND,void 0)}return o.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND,!0)}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.KEY_DELETE_COMMAND,(t=>{if(Ot(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(null!==t){if((dt||lt||ft)&&ut)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]=Nt(t);if(e.length>0){const n=st(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(gt,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]=Nt(t),n=lexical.$getSelection();return !(e&&!lexical.$isRangeSelection(n))}),lexical.COMMAND_PRIORITY_EDITOR),o.registerCommand(lexical.DRAGOVER_COMMAND,(t=>{const[e]=Nt(t),n=lexical.$getSelection();if(e&&!lexical.$isRangeSelection(n))return !1;const r=st(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]=Nt(e);if(n.length>0&&!r)return o.dispatchCommand(gt,n),!0;if(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))}
|
|
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 =
|
|
19
|
-
exports.$createQuoteNode =
|
|
20
|
-
exports.$isHeadingNode =
|
|
21
|
-
exports.$isQuoteNode =
|
|
22
|
-
exports.DRAG_DROP_PASTE =
|
|
23
|
-
exports.HeadingNode =
|
|
24
|
-
exports.QuoteNode =
|
|
25
|
-
exports.eventFiles =
|
|
26
|
-
exports.registerRichText =
|
|
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;
|