@react-fabric/lexical 1.0.0-beta.57 → 1.0.0-beta.59
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/css/_lexical.css +4 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +33 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +525 -194
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +26 -23
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +3 -3
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +95 -38
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +387 -124
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +22 -18
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +54 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +107 -8
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +4 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +23 -20
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +420 -137
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +50 -45
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +61 -65
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +2 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -46
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +34 -2
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +524 -196
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +4 -4
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +96 -40
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +387 -127
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +56 -31
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +106 -10
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +3 -1
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +417 -139
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +62 -67
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +2 -1
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
- package/package.json +12 -12
- package/src/hooks/useFormatWatcher.ts +3 -1
- package/src/plugins/ToolbarPlugin.tsx +5 -10
|
@@ -10,7 +10,7 @@ var lexical = require('lexical');
|
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
function N(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const w=new Map;function C(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild;}return null}function P(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return [t,Array.from(t.childNodes).indexOf(e)]}function k(t,n,o,l,r){const s=n.getKey(),i=l.getKey(),c=document.createRange();let f=t.getElementByKey(s),u=t.getElementByKey(i),g=o,a=r;if(lexical.$isTextNode(n)&&(f=C(f)),lexical.$isTextNode(l)&&(u=C(u)),void 0===n||void 0===l||null===f||null===u)return null;"BR"===f.nodeName&&([f,g]=P(f)),"BR"===u.nodeName&&([u,a]=P(u));const d=f.firstChild;f===u&&null!=d&&"BR"===d.nodeName&&0===g&&0===a&&(a=1);try{c.setStart(f,g),c.setEnd(u,a);}catch(e){return null}return !c.collapsed||g===a&&s===i||(c.setStart(u,a),c.setEnd(f,g)),c}function E(e,t){const n=e.getRootElement();if(null===n)return [];const o=n.getBoundingClientRect(),l=getComputedStyle(n),r=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight),s=Array.from(t.getClientRects());let i,c=s.length;s.sort(((e,t)=>{const n=e.top-t.top;return Math.abs(n)<=3?e.left-t.left:n}));for(let e=0;e<c;e++){const t=s[e],n=i&&i.top<=t.top&&i.top+i.height>t.top&&i.left+i.width>t.left,l=t.width+r===o.width;n||l?(s.splice(e--,1),c--):i=t;}return s}function K(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim());}return t}function I(e){let t=w.get(e);return void 0===t&&(t=K(e),w.set(e,t)),t}function F(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function B(e,n){const o=e.getStartEndPoints();if(n.isSelected(e)&&!n.isSegmented()&&!n.isToken()&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),c=r.getNode(),f=n.is(i),u=n.is(c);if(f||u){const[o,l]=lexical.$getCharacterOffsets(e),r=i.is(c),f=n.is(s?c:i),u=n.is(s?i:c);let g,a=0;if(r)a=o>l?l:o,g=o>l?o:l;else if(f){a=s?l:o,g=void 0;}else if(u){a=0,g=s?o:l;}return n.__text=n.__text.slice(a,g),n}}return n}function b(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return lexical.$isElementNode(t)||N(177),e.offset===t.getChildrenSize()}function O(t,c,f){let u=c.getNode(),g=f;if(lexical.$isElementNode(u)){const e=u.getDescendantByIndex(c.offset);null!==e&&(u=e);}for(;g>0&&null!==u;){if(lexical.$isElementNode(u)){const e=u.getLastDescendant();null!==e&&(u=e);}let f=u.getPreviousSibling(),a=0;if(null===f){let e=u.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){f=null;break}t=e.getPreviousSibling();}null!==e&&(a=e.isInline()?0:2,f=t);}let d=u.getTextContent();""===d&&lexical.$isElementNode(u)&&!u.isInline()&&(d="\n\n");const p=d.length;if(!lexical.$isTextNode(u)||g>=p){const e=u.getParent();u.remove(),null==e||0!==e.getChildrenSize()||lexical.$isRootNode(e)||e.remove(),g-=p+a,u=f;}else {const n=u.getKey(),o=t.getEditorState().read((()=>{const t=lexical.$getNodeByKey(n);return lexical.$isTextNode(t)&&t.isSimpleText()?t.getTextContent():null})),f=p-g,a=d.slice(0,f);if(null!==o&&o!==d){const e=lexical.$getPreviousSelection();let t=u;if(u.isSimpleText())u.setTextContent(o);else {const e=lexical.$createTextNode(o);u.replace(e),t=e;}if(lexical.$isRangeSelection(e)&&e.isCollapsed()){const n=e.anchor.offset;t.select(n,n);}}else if(u.isSimpleText()){const e=c.key===n;let t=c.offset;t<g&&(t=p);const o=e?t-g:0,l=e?t:f;if(e&&0===o){const[e]=u.splitText(o,l);e.remove();}else {const[,e]=u.splitText(o,l);e.remove();}}else {const e=lexical.$createTextNode(a);u.replace(e);}g=0;}}}function R(e){const t=e.getStyle(),n=K(t);w.set(t,n);}function z(t,o){(lexical.$isRangeSelection(t)?t.isCollapsed():lexical.$isTextNode(t)||lexical.$isElementNode(t))||N(280);const l=I(lexical.$isRangeSelection(t)?t.style:lexical.$isTextNode(t)?t.getStyle():t.getTextStyle()),r=Object.entries(o).reduce(((e,[n,o])=>("function"==typeof o?e[n]=o(l[n],t):null===o?delete e[n]:e[n]=o,e)),{...l}),s=F(r);lexical.$isRangeSelection(t)||lexical.$isTextNode(t)?t.setStyle(s):t.setTextStyle(s),w.set(s,r);}function A(e,t){if(lexical.$isRangeSelection(e)&&e.isCollapsed()){z(e,t);const o=e.anchor.getNode();lexical.$isElementNode(o)&&o.isEmpty()&&z(o,t);}L((e=>{z(e,t);}));}function L(t){const n=lexical.$getSelection();if(!n)return;const o=new Map;if(lexical.$isRangeSelection(n))for(const e of lexical.$caretRangeFromSelection(n).getTextSlices())e&&o.set(e.caret.origin.getKey(),e.getSliceIndices());const l=n.getNodes();for(const n of l){if(!lexical.$isTextNode(n)||!n.canHaveFormat())continue;const[l,s]=(r=n,o.get(r.getKey())||[0,r.getTextContentSize()]);if(s!==l)if(lexical.$isTokenOrSegmented(n)||0===l&&s===n.getTextContentSize())t(n);else {t(n.splitText(l,s)[0===l?0:1]);}}var r;lexical.$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&M(n);}function M(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:l,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,l,r);}}function $(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o);}function _(e,t,o=$){if(null===e)return;const l=e.getStartEndPoints(),r=new Map;let s=null;if(l){const[e,t]=l;s=lexical.$createRangeSelection(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const o=V(e.getNode(),lexical.INTERNAL_$isBlock),i=V(t.getNode(),lexical.INTERNAL_$isBlock);lexical.$isElementNode(o)&&r.set(o.getKey(),o),lexical.$isElementNode(i)&&r.set(i.getKey(),i);}for(const t of e.getNodes())lexical.$isElementNode(t)&&lexical.INTERNAL_$isBlock(t)&&r.set(t.getKey(),t);for(const[e,n]of r){const l=t();o(n,l),n.replace(l,!0),s&&(e===s.anchor.key&&s.anchor.set(l.getKey(),s.anchor.offset,s.anchor.type),e===s.focus.key&&s.focus.set(l.getKey(),s.focus.offset,s.focus.type));}s&&e.is(lexical.$getSelection())&&lexical.$setSelection(s);}function D(e){return e.getNode().isAttached()}function U(e){let t=e;for(;null!==t&&!lexical.$isRootOrShadowRoot(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n;}}function j(e,t,n=null){const o=e.getStartEndPoints(),l=o?o[0]:null,r=e.getNodes(),s=r.length;if(null!==l&&(0===s||1===s&&"element"===l.type&&0===l.getNode().getChildrenSize())){const e="text"===l.type?l.getNode().getParentOrThrow():l.getNode(),o=e.getChildren();let r=t();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),o.forEach((e=>r.append(e))),n&&(r=n.append(r)),void e.replace(r)}let i=null,c=[];for(let o=0;o<s;o++){const l=r[o];lexical.$isRootOrShadowRoot(l)?(H(e,c,c.length,t,n),c=[],i=l):null===i||null!==i&&lexical.$hasAncestor(l,i)?c.push(l):(H(e,c,c.length,t,n),c=[l]);}H(e,c,c.length,t,n);}function H(e,t,o,l,s=null){if(0===t.length)return;const c=t[0],f=new Map,u=[];let g=lexical.$isElementNode(c)?c:c.getParentOrThrow();g.isInline()&&(g=g.getParentOrThrow());let a=!1;for(;null!==g;){const e=g.getPreviousSibling();if(null!==e){g=e,a=!0;break}if(g=g.getParentOrThrow(),lexical.$isRootOrShadowRoot(g))break}const h=new Set;for(let e=0;e<o;e++){const o=t[e];lexical.$isElementNode(o)&&0===o.getChildrenSize()&&h.add(o.getKey());}const m=new Set;for(let e=0;e<o;e++){const o=t[e];let r=o.getParent();if(null!==r&&r.isInline()&&(r=r.getParent()),null!==r&&lexical.$isLeafNode(o)&&!m.has(o.getKey())){const e=r.getKey();if(void 0===f.get(e)){const t=l();t.setFormat(r.getFormatType()),t.setIndent(r.getIndent()),u.push(t),f.set(e,t),r.getChildren().forEach((e=>{t.append(e),m.add(e.getKey()),lexical.$isElementNode(e)&&e.getChildrenKeys().forEach((e=>m.add(e)));})),U(r);}}else if(h.has(o.getKey())){lexical.$isElementNode(o)||N(179);const e=l();e.setFormat(o.getFormatType()),e.setIndent(o.getIndent()),u.push(e),o.remove(!0);}}if(null!==s)for(let e=0;e<u.length;e++){const t=u[e];s.append(t);}let S=null;if(lexical.$isRootOrShadowRoot(g))if(a)if(null!==s)g.insertAfter(s);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t);}else {const e=g.getFirstChild();if(lexical.$isElementNode(e)&&(g=e),null===e)if(s)g.append(s);else for(let e=0;e<u.length;e++){const t=u[e];g.append(t),S=t;}else if(null!==s)e.insertBefore(s);else for(let t=0;t<u.length;t++){const n=u[t];e.insertBefore(n),S=n;}}else if(s)g.insertAfter(s);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t),S=t;}const x=lexical.$getPreviousSelection();lexical.$isRangeSelection(x)&&D(x.anchor)&&D(x.focus)?lexical.$setSelection(x.clone()):null!==S?S.selectEnd():e.dirty=!0;}function W(e,t){const o=lexical.$caretFromPoint(e.focus,t?"previous":"next");if(lexical.$isExtendableTextPointCaret(o))return !1;for(const e of lexical.$extendCaretToRange(o)){if(lexical.$isChildCaret(e))return !e.origin.isInline();if(!lexical.$isElementNode(e.origin)){if(lexical.$isDecoratorNode(e.origin))return !0;break}}return !1}function X(e,t,n,o){e.modify(t?"extend":"move",n,o);}function q(e){const t=e.anchor.getNode();return "rtl"===(lexical.$isRootNode(t)?t:t.getParentOrThrow()).getDirection()}function G(e,t,n){const o=q(e);X(e,t,n?!o:o,"character");}function J(e,t,n){const o=I(e.getStyle());return null!==o&&o[t]||n}function Q(t,n,o=""){let l=null;const r=t.getNodes(),s=t.anchor,c=t.focus,f=t.isBackward(),u=f?c.offset:s.offset,g=f?c.getNode():s.getNode();if(lexical.$isRangeSelection(t)&&t.isCollapsed()&&""!==t.style){const e=I(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t<r.length;t++){const s=r[t];if((0===t||0!==u||!s.is(g))&&lexical.$isTextNode(s)){const e=J(s,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l}function V(e,t){let n=e;for(;null!==n&&null!==n.getParent()&&!t(n);)n=n.getParentOrThrow();return t(n)?n:null}const Y=O;
|
|
13
|
+
function N(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const C=new Map;function P(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild;}return null}function K(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return [t,Array.from(t.childNodes).indexOf(e)]}function E(t,n,o,l,r){const s=n.getKey(),i=l.getKey(),c=document.createRange();let f=t.getElementByKey(s),u=t.getElementByKey(i),g=o,a=r;if(lexical.$isTextNode(n)&&(f=P(f)),lexical.$isTextNode(l)&&(u=P(u)),void 0===n||void 0===l||null===f||null===u)return null;"BR"===f.nodeName&&([f,g]=K(f)),"BR"===u.nodeName&&([u,a]=K(u));const d=f.firstChild;f===u&&null!=d&&"BR"===d.nodeName&&0===g&&0===a&&(a=1);try{c.setStart(f,g),c.setEnd(u,a);}catch(e){return null}return !c.collapsed||g===a&&s===i||(c.setStart(u,a),c.setEnd(f,g)),c}function k(e,t){const n=e.getRootElement();if(null===n)return [];const o=n.getBoundingClientRect(),l=getComputedStyle(n),r=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight),s=Array.from(t.getClientRects());let i,c=s.length;s.sort(((e,t)=>{const n=e.top-t.top;return Math.abs(n)<=3?e.left-t.left:n}));for(let e=0;e<c;e++){const t=s[e],n=i&&i.top<=t.top&&i.top+i.height>t.top&&i.left+i.width>t.left,l=t.width+r===o.width;n||l?(s.splice(e--,1),c--):i=t;}return s}function I(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim());}return t}function B(e){let t=C.get(e);return void 0===t&&(t=I(e),C.set(e,t)),t}function F(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function b(e){const n=lexical.$getEditor().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function O(e){return b(lexical.$isRootNode(e)?e:e.getParentOrThrow())}function R(e){const t=O(e);return null!==t&&"rtl"===t.direction}function z(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!lexical.$isTokenOrSegmented(t)&&null!==n){const[o,r]=n,s=e.isBackward(),i=o.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[n,o]=lexical.$getCharacterOffsets(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let g,a=0;if(r)a=n>o?o:n,g=n>o?n:o;else if(f){a=s?o:n,g=void 0;}else if(u){a=0,g=s?n:o;}t.__text=t.__text.slice(a,g);}}return t}function A(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return lexical.$isElementNode(t)||N(177),e.offset===t.getChildrenSize()}function M(t,o,l){let u=o.getNode(),g=l;if(lexical.$isElementNode(u)){const e=u.getDescendantByIndex(o.offset);null!==e&&(u=e);}for(;g>0&&null!==u;){if(lexical.$isElementNode(u)){const e=u.getLastDescendant();null!==e&&(u=e);}let l=u.getPreviousSibling(),a=0;if(null===l){let e=u.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){l=null;break}t=e.getPreviousSibling();}null!==e&&(a=e.isInline()?0:2,l=t);}let d=u.getTextContent();""===d&&lexical.$isElementNode(u)&&!u.isInline()&&(d="\n\n");const p=d.length;if(!lexical.$isTextNode(u)||g>=p){const e=u.getParent();u.remove(),null==e||0!==e.getChildrenSize()||lexical.$isRootNode(e)||e.remove(),g-=p+a,u=l;}else {const n=u.getKey(),l=t.getEditorState().read((()=>{const t=lexical.$getNodeByKey(n);return lexical.$isTextNode(t)&&t.isSimpleText()?t.getTextContent():null})),r=p-g,a=d.slice(0,r);if(null!==l&&l!==d){const e=lexical.$getPreviousSelection();let t=u;if(u.isSimpleText())u.setTextContent(l);else {const e=lexical.$createTextNode(l);u.replace(e),t=e;}if(lexical.$isRangeSelection(e)&&e.isCollapsed()){const n=e.anchor.offset;t.select(n,n);}}else if(u.isSimpleText()){const e=o.key===n;let t=o.offset;t<g&&(t=p);const l=e?t-g:0,s=e?t:r;if(e&&0===l){const[e]=u.splitText(l,s);e.remove();}else {const[,e]=u.splitText(l,s);e.remove();}}else {const e=lexical.$createTextNode(a);u.replace(e);}g=0;}}}function L(e){const t=e.getStyle(),n=I(t);C.set(t,n);}function $(t,n){(lexical.$isRangeSelection(t)?t.isCollapsed():lexical.$isTextNode(t)||lexical.$isElementNode(t))||N(280);const o=B(lexical.$isRangeSelection(t)?t.style:lexical.$isTextNode(t)?t.getStyle():t.getTextStyle()),l=Object.entries(n).reduce(((e,[n,l])=>("function"==typeof l?e[n]=l(o[n],t):null===l?delete e[n]:e[n]=l,e)),{...o}),s=F(l);lexical.$isRangeSelection(t)||lexical.$isTextNode(t)?t.setStyle(s):t.setTextStyle(s),C.set(s,l);}function _(e,t){if(lexical.$isRangeSelection(e)&&e.isCollapsed()){$(e,t);const n=e.anchor.getNode();lexical.$isElementNode(n)&&n.isEmpty()&&$(n,t);}D((e=>{$(e,t);}));}function D(t){const n=lexical.$getSelection();if(!n)return;const l=new Map;if(lexical.$isRangeSelection(n))for(const e of lexical.$caretRangeFromSelection(n).getTextSlices())e&&l.set(e.caret.origin.getKey(),e.getSliceIndices());const r=n.getNodes();for(const n of r){if(!lexical.$isTextNode(n)||!n.canHaveFormat())continue;const[r,i]=(s=n,l.get(s.getKey())||[0,s.getTextContentSize()]);if(i!==r)if(lexical.$isTokenOrSegmented(n)||0===r&&i===n.getTextContentSize())t(n);else {t(n.splitText(r,i)[0===r?0:1]);}}var s;lexical.$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&U(n);}function U(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:l,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,l,r);}}function j(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o);}function H(e,t,n=j){if(null===e)return;const o=e.getStartEndPoints(),l=new Map;let s=null;if(o){const[e,t]=o;s=lexical.$createRangeSelection(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=oe(e.getNode(),lexical.INTERNAL_$isBlock),i=oe(t.getNode(),lexical.INTERNAL_$isBlock);lexical.$isElementNode(n)&&l.set(n.getKey(),n),lexical.$isElementNode(i)&&l.set(i.getKey(),i);}for(const t of e.getNodes())if(lexical.$isElementNode(t)&&lexical.INTERNAL_$isBlock(t))l.set(t.getKey(),t);else if(null===o){const e=oe(t,lexical.INTERNAL_$isBlock);lexical.$isElementNode(e)&&l.set(e.getKey(),e);}for(const[e,o]of l){const l=t();n(o,l),o.replace(l,!0),s&&(e===s.anchor.key&&s.anchor.set(l.getKey(),s.anchor.offset,s.anchor.type),e===s.focus.key&&s.focus.set(l.getKey(),s.focus.offset,s.focus.type));}s&&e.is(lexical.$getSelection())&&lexical.$setSelection(s);}function V(e){return e.getNode().isAttached()}function W(e){let t=e;for(;null!==t&&!lexical.$isRootOrShadowRoot(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n;}}function X(e,t,n=null){const o=e.getStartEndPoints(),l=o?o[0]:null,r=e.getNodes(),s=r.length;if(null!==l&&(0===s||1===s&&"element"===l.type&&0===l.getNode().getChildrenSize())){const e="text"===l.type?l.getNode().getParentOrThrow():l.getNode(),o=e.getChildren();let r=t();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),o.forEach((e=>r.append(e))),n&&(r=n.append(r)),void e.replace(r)}let i=null,c=[];for(let o=0;o<s;o++){const l=r[o];lexical.$isRootOrShadowRoot(l)?(q(e,c,c.length,t,n),c=[],i=l):null===i||null!==i&&lexical.$hasAncestor(l,i)?c.push(l):(q(e,c,c.length,t,n),c=[l]);}q(e,c,c.length,t,n);}function q(e,t,n,o,l=null){if(0===t.length)return;const s=t[0],c=new Map,u=[];let g=lexical.$isElementNode(s)?s:s.getParentOrThrow();g.isInline()&&(g=g.getParentOrThrow());let a=!1;for(;null!==g;){const e=g.getPreviousSibling();if(null!==e){g=e,a=!0;break}if(g=g.getParentOrThrow(),lexical.$isRootOrShadowRoot(g))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];lexical.$isElementNode(n)&&0===n.getChildrenSize()&&d.add(n.getKey());}const y=new Set;for(let e=0;e<n;e++){const n=t[e];let l=n.getParent();if(null!==l&&l.isInline()&&(l=l.getParent()),null!==l&&lexical.$isLeafNode(n)&&!y.has(n.getKey())){const e=l.getKey();if(void 0===c.get(e)){const t=o();t.setFormat(l.getFormatType()),t.setIndent(l.getIndent()),u.push(t),c.set(e,t),l.getChildren().forEach((e=>{t.append(e),y.add(e.getKey()),lexical.$isElementNode(e)&&e.getChildrenKeys().forEach((e=>y.add(e)));})),W(l);}}else if(d.has(n.getKey())){lexical.$isElementNode(n)||N(179);const e=o();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),u.push(e),n.remove(!0);}}if(null!==l)for(let e=0;e<u.length;e++){const t=u[e];l.append(t);}let S=null;if(lexical.$isRootOrShadowRoot(g))if(a)if(null!==l)g.insertAfter(l);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t);}else {const e=g.getFirstChild();if(lexical.$isElementNode(e)&&(g=e),null===e)if(l)g.append(l);else for(let e=0;e<u.length;e++){const t=u[e];g.append(t),S=t;}else if(null!==l)e.insertBefore(l);else for(let t=0;t<u.length;t++){const n=u[t];e.insertBefore(n),S=n;}}else if(l)g.insertAfter(l);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t),S=t;}const x=lexical.$getPreviousSelection();lexical.$isRangeSelection(x)&&V(x.anchor)&&V(x.focus)?lexical.$setSelection(x.clone()):null!==S?S.selectEnd():e.dirty=!0;}function G(e){const t=J(e);return null!==t&&"vertical-rl"===t.writingMode}function J(e){const t=e.anchor.getNode();return lexical.$isElementNode(t)?b(t):O(t)}function Q(e,t){let n=G(e)?!t:t;Z(e)&&(n=!n);const o=lexical.$caretFromPoint(e.focus,n?"previous":"next");if(lexical.$isExtendableTextPointCaret(o))return !1;for(const e of lexical.$extendCaretToRange(o)){if(lexical.$isChildCaret(e))return !e.origin.isInline();if(!lexical.$isElementNode(e.origin)){if(lexical.$isDecoratorNode(e.origin))return !0;break}}return !1}function Y(e,t,n,o){e.modify(t?"extend":"move",n,o);}function Z(e){const t=J(e);return null!==t&&"rtl"===t.direction}function ee(e,t,n){const o=Z(e);let l;l=G(e)||o?!n:n,Y(e,t,l,"character");}function te(e,t,n){const o=B(e.getStyle());return null!==o&&o[t]||n}function ne(t,n,o=""){let l=null;const r=t.getNodes(),s=t.anchor,i=t.focus,c=t.isBackward(),u=c?i.offset:s.offset,g=c?i.getNode():s.getNode();if(lexical.$isRangeSelection(t)&&t.isCollapsed()&&""!==t.style){const e=B(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t<r.length;t++){const s=r[t];if((0===t||0!==u||!s.is(g))&&lexical.$isTextNode(s)){const e=te(s,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l}function oe(e,t){let n=e;for(;null!==n&&null!==n.getParent()&&!t(n);)n=n.getParentOrThrow();return t(n)?n:null}const le=M;
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, "$cloneWithProperties", {
|
|
16
16
|
enumerable: true,
|
|
@@ -20,23 +20,26 @@ Object.defineProperty(exports, "$selectAll", {
|
|
|
20
20
|
enumerable: true,
|
|
21
21
|
get: function () { return lexical.$selectAll; }
|
|
22
22
|
});
|
|
23
|
-
exports.$addNodeStyle =
|
|
24
|
-
exports.$copyBlockFormatIndent =
|
|
25
|
-
exports.$ensureForwardRangeSelection =
|
|
26
|
-
exports.$forEachSelectedTextNode =
|
|
27
|
-
exports.$
|
|
28
|
-
exports.$
|
|
29
|
-
exports.$
|
|
30
|
-
exports.$
|
|
31
|
-
exports.$
|
|
32
|
-
exports.$
|
|
33
|
-
exports.$
|
|
34
|
-
exports.$
|
|
35
|
-
exports.$
|
|
36
|
-
exports.$
|
|
37
|
-
exports.$
|
|
38
|
-
exports
|
|
39
|
-
exports
|
|
23
|
+
exports.$addNodeStyle = L;
|
|
24
|
+
exports.$copyBlockFormatIndent = j;
|
|
25
|
+
exports.$ensureForwardRangeSelection = U;
|
|
26
|
+
exports.$forEachSelectedTextNode = D;
|
|
27
|
+
exports.$getComputedStyleForElement = b;
|
|
28
|
+
exports.$getComputedStyleForParent = O;
|
|
29
|
+
exports.$getSelectionStyleValueForProperty = ne;
|
|
30
|
+
exports.$isAtNodeEnd = A;
|
|
31
|
+
exports.$isParentElementRTL = Z;
|
|
32
|
+
exports.$isParentRTL = R;
|
|
33
|
+
exports.$moveCaretSelection = Y;
|
|
34
|
+
exports.$moveCharacter = ee;
|
|
35
|
+
exports.$patchStyleText = _;
|
|
36
|
+
exports.$setBlocksType = H;
|
|
37
|
+
exports.$shouldOverrideDefaultCharacterSelection = Q;
|
|
38
|
+
exports.$sliceSelectedTextNodeContent = z;
|
|
39
|
+
exports.$trimTextContentFromAnchor = M;
|
|
40
|
+
exports.$wrapNodes = X;
|
|
41
|
+
exports.createDOMRange = E;
|
|
42
|
+
exports.createRectsFromDOMRange = k;
|
|
40
43
|
exports.getCSSFromStyleObject = F;
|
|
41
|
-
exports.getStyleObjectFromCSS =
|
|
42
|
-
exports.trimTextContentFromAnchor =
|
|
44
|
+
exports.getStyleObjectFromCSS = B;
|
|
45
|
+
exports.trimTextContentFromAnchor = le;
|