@lexical/selection 0.46.1-nightly.20260709.0 → 0.47.0
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.
|
@@ -941,6 +941,16 @@ function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
|
|
|
941
941
|
if (lexical.$isExtendableTextPointCaret(focusCaret)) {
|
|
942
942
|
return false;
|
|
943
943
|
}
|
|
944
|
+
// At an unmergeable TextNode boundary adjacent to another plain TextNode,
|
|
945
|
+
// override so Lexical's modify() can pre-normalize across inline-grid/flex
|
|
946
|
+
// spans (#7301). Restricted to unmergeable nodes to avoid disrupting
|
|
947
|
+
// format-affinity at normal bold/italic boundaries.
|
|
948
|
+
if (lexical.$isTextPointCaret(focusCaret) && !lexical.$isTabNode(focusCaret.origin) && focusCaret.origin.isUnmergeable()) {
|
|
949
|
+
const sibling = focusCaret.getNodeAtCaret();
|
|
950
|
+
if (lexical.$isTextNode(sibling) && !lexical.$isTabNode(sibling)) {
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
944
954
|
for (const nextCaret of lexical.$extendCaretToRange(focusCaret)) {
|
|
945
955
|
if (lexical.$isChildCaret(nextCaret)) {
|
|
946
956
|
return !nextCaret.origin.isInline();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { getRootOwnerDocument, $isTextNode, $getEditor, $isRootNode, $getSelection, $isRangeSelection, $caretRangeFromSelection, $isTokenOrSegmented, $isElementNode, $getCharacterOffsets, $cloneWithPropertiesEphemeral, $getNodeByKey, $getPreviousSelection, $createTextNode, getStyleObjectFromCSS as getStyleObjectFromCSS$1, $caretFromPoint, $isExtendableTextPointCaret, $findMatchingParent, INTERNAL_$isBlock, flipDirection, $extendCaretToRange, $isChildCaret, $isDecoratorNode, $isRootOrShadowRoot, $hasAncestor, $isLeafNode, $setSelection } from 'lexical';
|
|
9
|
+
import { getRootOwnerDocument, $isTextNode, $getEditor, $isRootNode, $getSelection, $isRangeSelection, $caretRangeFromSelection, $isTokenOrSegmented, $isElementNode, $getCharacterOffsets, $cloneWithPropertiesEphemeral, $getNodeByKey, $getPreviousSelection, $createTextNode, getStyleObjectFromCSS as getStyleObjectFromCSS$1, $caretFromPoint, $isExtendableTextPointCaret, $findMatchingParent, INTERNAL_$isBlock, flipDirection, $isTextPointCaret, $isTabNode, $extendCaretToRange, $isChildCaret, $isDecoratorNode, $isRootOrShadowRoot, $hasAncestor, $isLeafNode, $setSelection } from 'lexical';
|
|
10
10
|
export { $cloneWithProperties, $selectAll } from 'lexical';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -940,6 +940,16 @@ function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
|
|
|
940
940
|
if ($isExtendableTextPointCaret(focusCaret)) {
|
|
941
941
|
return false;
|
|
942
942
|
}
|
|
943
|
+
// At an unmergeable TextNode boundary adjacent to another plain TextNode,
|
|
944
|
+
// override so Lexical's modify() can pre-normalize across inline-grid/flex
|
|
945
|
+
// spans (#7301). Restricted to unmergeable nodes to avoid disrupting
|
|
946
|
+
// format-affinity at normal bold/italic boundaries.
|
|
947
|
+
if ($isTextPointCaret(focusCaret) && !$isTabNode(focusCaret.origin) && focusCaret.origin.isUnmergeable()) {
|
|
948
|
+
const sibling = focusCaret.getNodeAtCaret();
|
|
949
|
+
if ($isTextNode(sibling) && !$isTabNode(sibling)) {
|
|
950
|
+
return true;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
943
953
|
for (const nextCaret of $extendCaretToRange(focusCaret)) {
|
|
944
954
|
if ($isChildCaret(nextCaret)) {
|
|
945
955
|
return !nextCaret.origin.isInline();
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
"use strict";var e=require("lexical");function t(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.`)}
|
|
10
|
-
/*@__INLINE__*/function n(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild}return null}function o(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return[t,Array.from(t.childNodes).indexOf(e)]}function r(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function s(t){const n=e.$getEditor().getElementByKey(t.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function i(t){return s(e.$isRootNode(t)?t:t.getParentOrThrow())}function l(t,n,o){let r=n.getNode(),s=o;if(e.$isElementNode(r)){const e=r.getDescendantByIndex(n.offset);null!==e&&(r=e)}for(;s>0&&null!==r;){if(e.$isElementNode(r)){const e=r.getLastDescendant();null!==e&&(r=e)}let o=r.getPreviousSibling(),i=0;if(null===o){let e=r.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){o=null;break}t=e.getPreviousSibling()}null!==e&&(i=e.isInline()?0:2,o=t)}let l=r.getTextContent();""===l&&e.$isElementNode(r)&&!r.isInline()&&(l="\n\n");const c=l.length;if(!e.$isTextNode(r)||s>=c){const t=r.getParent();r.remove(),null==t||0!==t.getChildrenSize()||e.$isRootNode(t)||t.remove(),s-=c+i,r=o}else{const o=r.getKey(),i=t.read("latest",()=>{const t=e.$getNodeByKey(o);return e.$isTextNode(t)&&t.isSimpleText()?t.getTextContent():null}),f=c-s,d=l.slice(0,f);if(null!==i&&i!==l){const t=e.$getPreviousSelection();let n=r;if(r.isSimpleText())r.setTextContent(i);else{const t=e.$createTextNode(i);r.replace(t),n=t}if(e.$isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor.offset;n.select(e,e)}}else if(r.isSimpleText()){const e=n.key===o;let t=n.offset;t<s&&(t=c);const i=e?t-s:0,l=e?t:f;if(e&&0===i){const[e]=r.splitText(i,l);e.remove()}else{const[,e]=r.splitText(i,l);e.remove()}}else{const t=e.$createTextNode(d);r.replace(t)}s=0}}}const c=()=>{};function f(n,o){(e.$isRangeSelection(n)?n.isCollapsed():e.$isTextNode(n)||e.$isElementNode(n))||t(280);const s=e.getStyleObjectFromCSS(e.$isRangeSelection(n)?n.style:e.$isTextNode(n)?n.getStyle():n.getTextStyle()),i=r(Object.entries(o).reduce((e,[t,o])=>("function"==typeof o?e[t]=o(s[t],n):null===o?delete e[t]:e[t]=o,e),{...s}));e.$isRangeSelection(n)||e.$isTextNode(n)?n.setStyle(i):n.setTextStyle(i)}function d(t){const n=e.$getSelection();if(!n)return;const o=new Map,r=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(e.$isRangeSelection(n))for(const t of e.$caretRangeFromSelection(n).getTextSlices())t&&o.set(t.caret.origin.getKey(),t.getSliceIndices());const s=n.getNodes();for(const n of s){if(!e.$isTextNode(n)||!n.canHaveFormat())continue;const[o,s]=r(n);if(s!==o)if(e.$isTokenOrSegmented(n)||0===o&&s===n.getTextContentSize())t(n);else{t(n.splitText(o,s)[0===o?0:1])}}e.$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&a(n)}function a(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:r,type:s}=t;t.set(n.key,n.offset,n.type),n.set(o,r,s)}}function g(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function u(t,n,o){let r=e.$caretFromPoint(t,o);if(e.$isExtendableTextPointCaret(r))return!1;for(;r;r=r.getParentCaret()){const e=r.getParentAtCaret();if(!e||r.getNodeAtCaret())return!1;if(n.is(e))return!0}return!1}function p(e){return e.getNode().isAttached()}function $(t){let n=t;for(;null!==n&&!e.$isRootOrShadowRoot(n);){const e=n.getLatest(),t=n.getParent();0===e.getChildrenSize()&&n.remove(!0),n=t}}function h(n,o,r,s,i=null){if(0===o.length)return;const l=o[0],c=new Map,f=[],d=e.$isElementNode(l)?l:l.getParentOrThrow();let a=d.isInline()?d.getParentOrThrow():d,g=!1;for(;null!==a;){const t=a.getPreviousSibling();if(null!==t){a=t,g=!0;break}if(a=a.getParentOrThrow(),e.$isRootOrShadowRoot(a))break}const u=new Set;for(let t=0;t<r;t++){const n=o[t];e.$isElementNode(n)&&0===n.getChildrenSize()&&u.add(n.getKey())}const h=new Set;for(let n=0;n<r;n++){const r=o[n];let i=r.getParent();if(null!==i&&i.isInline()&&(i=i.getParent()),null!==i&&e.$isLeafNode(r)&&!h.has(r.getKey())){const t=i.getKey();if(void 0===c.get(t)){const n=s();n.setFormat(i.getFormatType()),n.setIndent(i.getIndent()),f.push(n),c.set(t,n);const o=i.getChildren();n.splice(n.getChildrenSize(),0,o);for(const t of o)if(h.add(t.getKey()),e.$isElementNode(t))for(const e of t.getChildrenKeys())h.add(e);$(i)}}else if(u.has(r.getKey())){e.$isElementNode(r)||t(179);const n=s();n.setFormat(r.getFormatType()),n.setIndent(r.getIndent()),f.push(n),r.remove(!0)}}if(null!==i)for(let e=0;e<f.length;e++){const t=f[e];i.append(t)}let S=null;if(e.$isRootOrShadowRoot(a))if(g)if(null!==i)a.insertAfter(i);else for(let e=f.length-1;e>=0;e--){const t=f[e];a.insertAfter(t)}else{const t=a,n=t.getFirstChild();if(e.$isElementNode(n)&&(a=n),null===n)if(i)t.append(i);else for(let e=0;e<f.length;e++){const n=f[e];t.append(n),S=n}else if(null!==i)n.insertBefore(i);else for(let e=0;e<f.length;e++){const t=f[e];n.insertBefore(t),S=t}}else if(i)a.insertAfter(i);else for(let e=f.length-1;e>=0;e--){const t=f[e];a.insertAfter(t),S=t}const m=e.$getPreviousSelection();e.$isRangeSelection(m)&&p(m.anchor)&&p(m.focus)?e.$setSelection(m.clone()):null!==S?S.selectEnd():n.dirty=!0}function S(e){const t=m(e);return null!==t&&"vertical-rl"===t.writingMode}function m(t){const n=t.anchor.getNode();return e.$isElementNode(n)?s(n):i(n)}function N(e,t,n,o){e.modify(t?"extend":"move",n,o)}function x(e){const t=m(e);return null!==t&&"rtl"===t.direction}function y(t,n,o){const r=t.getStyle(),s=e.getStyleObjectFromCSS(r);return null!==s&&s[n]||o}const T=e.getStyleObjectFromCSS,E=l;exports.$cloneWithProperties=e.$cloneWithProperties,exports.$selectAll=e.$selectAll,exports.$addNodeStyle=c,exports.$copyBlockFormatIndent=g,exports.$ensureForwardRangeSelection=a,exports.$forEachSelectedTextNode=d,exports.$getComputedStyleForElement=s,exports.$getComputedStyleForParent=i,exports.$getSelectionStyleValueForProperty=function(t,n,o=""){let r=null;const s=t.getNodes();let i,l;if(e.$isRangeSelection(t)){if(t.isCollapsed()&&""!==t.style){const o=e.getStyleObjectFromCSS(t.style);if(null!==o&&n in o)return o[n]}const{anchor:o,focus:r}=t,s=t.isBackward(),c=s?r.getNode():o.getNode(),f=s?o.getNode():r.getNode(),d=s?r.offset:o.offset,a=s?o.offset:r.offset;e.$isTextNode(c)&&d===c.getTextContentSize()&&(i=c),0===a&&(l=f)}for(let t=0;t<s.length;t++){const c=s[t];if(e.$isTextNode(c)&&!c.is(0===t?i:l)){const e=y(c,n,o);if(null===r)r=e;else if(r!==e){r="";break}}}return null===r?o:r},exports.$isAtEdgeOfElement=u,exports.$isAtNodeEnd=function(n){if("text"===n.type)return n.offset===n.getNode().getTextContentSize();const o=n.getNode();return e.$isElementNode(o)||t(177),n.offset===o.getChildrenSize()},exports.$isParentElementRTL=x,exports.$isParentRTL=function(e){const t=i(e);return null!==t&&"rtl"===t.direction},exports.$moveCaretSelection=N,exports.$moveCharacter=function(e,t,n){const o=x(e);let r;r=S(e)||o?!n:n,N(e,t,r,"character")},exports.$patchStyleText=function(t,n){if(e.$isRangeSelection(t)&&t.isCollapsed()){f(t,n);const o=t.anchor.getNode();e.$isElementNode(o)&&o.isEmpty()&&f(o,n)}d(e=>{f(e,n)});const o=t.getNodes();if(o.length>0){const t=new Set;for(const r of o){if(!e.$isElementNode(r)||!r.canBeEmpty()||0!==r.getChildrenSize())continue;const o=r.getKey();t.has(o)||(t.add(o),f(r,n))}}},exports.$setBlocksType=function(t,n,o=g){if(!t)return;const r=t.getStartEndPoints();let s=!1,i=null;const l=new Map;if(r){const[n,o]=r,c=e.$findMatchingParent(n.getNode(),e.INTERNAL_$isBlock);i=e.$findMatchingParent(o.getNode(),e.INTERNAL_$isBlock);const f=t.isBackward()?"previous":"next";s=e.$isElementNode(i)&&!i.is(c)&&function(t,n,o){const r=t.getNode();return(!e.$isElementNode(r)||!r.isEmpty())&&u(t,n,o)}(o,i,e.flipDirection(f)),e.$isElementNode(c)&&l.set(c.getKey(),c),e.$isElementNode(i)&&!s&&l.set(i.getKey(),i)}for(const n of t.getNodes())if(e.$isElementNode(n)&&e.INTERNAL_$isBlock(n)){if(s&&n.is(i))continue;l.set(n.getKey(),n)}else if(!r){const t=e.$findMatchingParent(n,e.INTERNAL_$isBlock);e.$isElementNode(t)&&l.set(t.getKey(),t)}for(const e of l.values()){const t=n();o(e,t),e.replace(t,!0)}},exports.$shouldOverrideDefaultCharacterSelection=function(t,n){let o=S(t)?!n:n;x(t)&&(o=!o);const r=e.$caretFromPoint(t.focus,o?"previous":"next");if(e.$isExtendableTextPointCaret(r))return!1;for(const t of e.$extendCaretToRange(r)){if(e.$isChildCaret(t))return!t.origin.isInline();if(!e.$isElementNode(t.origin)){if(e.$isDecoratorNode(t.origin))return!0;break}}return!1},exports.$sliceSelectedTextNodeContent=function(t,n,o="self"){const r=t.getStartEndPoints();if(n.isSelected(t)&&!e.$isTokenOrSegmented(n)&&null!==r){const[s,i]=r,l=t.isBackward(),c=s.getNode(),f=i.getNode(),d=n.is(c),a=n.is(f);if(d||a){const[r,s]=e.$getCharacterOffsets(t),i=c.is(f),d=n.is(l?f:c),a=n.is(l?c:f);let g,u=0;if(i)u=r>s?s:r,g=r>s?r:s;else if(d){u=l?s:r,g=void 0}else if(a){u=0,g=l?r:s}const p=n.__text.slice(u,g);p!==n.__text&&("clone"===o&&(n=e.$cloneWithPropertiesEphemeral(n)),n.__text=p)}}return n},exports.$trimTextContentFromAnchor=l,exports.$wrapNodes=function(t,n,o=null){const r=t.getStartEndPoints(),s=r?r[0]:null,i=t.getNodes(),l=i.length;if(null!==s&&(0===l||1===l&&"element"===s.type&&0===s.getNode().getChildrenSize())){const e="text"===s.type?s.getNode().getParentOrThrow():s.getNode(),t=e.getChildren();let r=n();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),t.forEach(e=>r.append(e)),o&&(r=o.append(r)),void e.replace(r)}let c=null,f=[];for(let r=0;r<l;r++){const s=i[r];e.$isRootOrShadowRoot(s)?(h(t,f,f.length,n,o),f=[],c=s):null===c||null!==c&&e.$hasAncestor(s,c)?f.push(s):(h(t,f,f.length,n,o),f=[s])}h(t,f,f.length,n,o)},exports.createDOMRange=function(t,r,s,i,l){const c=r.getKey(),f=i.getKey(),d=e.getRootOwnerDocument(t.getRootElement()).createRange();let a=t.getElementByKey(c),g=t.getElementByKey(f),u=s,p=l;if(e.$isTextNode(r)&&(a=n(a)),e.$isTextNode(i)&&(g=n(g)),void 0===r||void 0===i||null===a||null===g)return null;"BR"===a.nodeName&&([a,u]=o(a)),"BR"===g.nodeName&&([g,p]=o(g));const $=a.firstChild;a===g&&null!=$&&"BR"===$.nodeName&&0===u&&0===p&&(p=1);try{d.setStart(a,u),d.setEnd(g,p)}catch(e){return null}return!d.collapsed||u===p&&c===f||(d.setStart(g,p),d.setEnd(a,u)),d},exports.createRectsFromDOMRange=function(e,t){const n=e.getRootElement();if(null===n)return[];const o=n.getBoundingClientRect(),r=getComputedStyle(n),s=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight),i=Array.from(t.getClientRects());let l,c=i.length;i.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=i[e],n=l&&l.top<=t.top&&l.top+l.height>t.top&&l.left+l.width>t.left,r=t.width+s===o.width;n||r?(i.splice(e--,1),c--):l=t}return i},exports.getCSSFromStyleObject=r,exports.getStyleObjectFromCSS=T,exports.trimTextContentFromAnchor=E;
|
|
10
|
+
/*@__INLINE__*/function n(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild}return null}function o(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return[t,Array.from(t.childNodes).indexOf(e)]}function r(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function i(t){const n=e.$getEditor().getElementByKey(t.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function s(t){return i(e.$isRootNode(t)?t:t.getParentOrThrow())}function l(t,n,o){let r=n.getNode(),i=o;if(e.$isElementNode(r)){const e=r.getDescendantByIndex(n.offset);null!==e&&(r=e)}for(;i>0&&null!==r;){if(e.$isElementNode(r)){const e=r.getLastDescendant();null!==e&&(r=e)}let o=r.getPreviousSibling(),s=0;if(null===o){let e=r.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){o=null;break}t=e.getPreviousSibling()}null!==e&&(s=e.isInline()?0:2,o=t)}let l=r.getTextContent();""===l&&e.$isElementNode(r)&&!r.isInline()&&(l="\n\n");const c=l.length;if(!e.$isTextNode(r)||i>=c){const t=r.getParent();r.remove(),null==t||0!==t.getChildrenSize()||e.$isRootNode(t)||t.remove(),i-=c+s,r=o}else{const o=r.getKey(),s=t.read("latest",()=>{const t=e.$getNodeByKey(o);return e.$isTextNode(t)&&t.isSimpleText()?t.getTextContent():null}),f=c-i,d=l.slice(0,f);if(null!==s&&s!==l){const t=e.$getPreviousSelection();let n=r;if(r.isSimpleText())r.setTextContent(s);else{const t=e.$createTextNode(s);r.replace(t),n=t}if(e.$isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor.offset;n.select(e,e)}}else if(r.isSimpleText()){const e=n.key===o;let t=n.offset;t<i&&(t=c);const s=e?t-i:0,l=e?t:f;if(e&&0===s){const[e]=r.splitText(s,l);e.remove()}else{const[,e]=r.splitText(s,l);e.remove()}}else{const t=e.$createTextNode(d);r.replace(t)}i=0}}}const c=()=>{};function f(n,o){(e.$isRangeSelection(n)?n.isCollapsed():e.$isTextNode(n)||e.$isElementNode(n))||t(280);const i=e.getStyleObjectFromCSS(e.$isRangeSelection(n)?n.style:e.$isTextNode(n)?n.getStyle():n.getTextStyle()),s=r(Object.entries(o).reduce((e,[t,o])=>("function"==typeof o?e[t]=o(i[t],n):null===o?delete e[t]:e[t]=o,e),{...i}));e.$isRangeSelection(n)||e.$isTextNode(n)?n.setStyle(s):n.setTextStyle(s)}function d(t){const n=e.$getSelection();if(!n)return;const o=new Map,r=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(e.$isRangeSelection(n))for(const t of e.$caretRangeFromSelection(n).getTextSlices())t&&o.set(t.caret.origin.getKey(),t.getSliceIndices());const i=n.getNodes();for(const n of i){if(!e.$isTextNode(n)||!n.canHaveFormat())continue;const[o,i]=r(n);if(i!==o)if(e.$isTokenOrSegmented(n)||0===o&&i===n.getTextContentSize())t(n);else{t(n.splitText(o,i)[0===o?0:1])}}e.$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&a(n)}function a(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:r,type:i}=t;t.set(n.key,n.offset,n.type),n.set(o,r,i)}}function g(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function u(t,n,o){let r=e.$caretFromPoint(t,o);if(e.$isExtendableTextPointCaret(r))return!1;for(;r;r=r.getParentCaret()){const e=r.getParentAtCaret();if(!e||r.getNodeAtCaret())return!1;if(n.is(e))return!0}return!1}function p(e){return e.getNode().isAttached()}function $(t){let n=t;for(;null!==n&&!e.$isRootOrShadowRoot(n);){const e=n.getLatest(),t=n.getParent();0===e.getChildrenSize()&&n.remove(!0),n=t}}function h(n,o,r,i,s=null){if(0===o.length)return;const l=o[0],c=new Map,f=[],d=e.$isElementNode(l)?l:l.getParentOrThrow();let a=d.isInline()?d.getParentOrThrow():d,g=!1;for(;null!==a;){const t=a.getPreviousSibling();if(null!==t){a=t,g=!0;break}if(a=a.getParentOrThrow(),e.$isRootOrShadowRoot(a))break}const u=new Set;for(let t=0;t<r;t++){const n=o[t];e.$isElementNode(n)&&0===n.getChildrenSize()&&u.add(n.getKey())}const h=new Set;for(let n=0;n<r;n++){const r=o[n];let s=r.getParent();if(null!==s&&s.isInline()&&(s=s.getParent()),null!==s&&e.$isLeafNode(r)&&!h.has(r.getKey())){const t=s.getKey();if(void 0===c.get(t)){const n=i();n.setFormat(s.getFormatType()),n.setIndent(s.getIndent()),f.push(n),c.set(t,n);const o=s.getChildren();n.splice(n.getChildrenSize(),0,o);for(const t of o)if(h.add(t.getKey()),e.$isElementNode(t))for(const e of t.getChildrenKeys())h.add(e);$(s)}}else if(u.has(r.getKey())){e.$isElementNode(r)||t(179);const n=i();n.setFormat(r.getFormatType()),n.setIndent(r.getIndent()),f.push(n),r.remove(!0)}}if(null!==s)for(let e=0;e<f.length;e++){const t=f[e];s.append(t)}let m=null;if(e.$isRootOrShadowRoot(a))if(g)if(null!==s)a.insertAfter(s);else for(let e=f.length-1;e>=0;e--){const t=f[e];a.insertAfter(t)}else{const t=a,n=t.getFirstChild();if(e.$isElementNode(n)&&(a=n),null===n)if(s)t.append(s);else for(let e=0;e<f.length;e++){const n=f[e];t.append(n),m=n}else if(null!==s)n.insertBefore(s);else for(let e=0;e<f.length;e++){const t=f[e];n.insertBefore(t),m=t}}else if(s)a.insertAfter(s);else for(let e=f.length-1;e>=0;e--){const t=f[e];a.insertAfter(t),m=t}const S=e.$getPreviousSelection();e.$isRangeSelection(S)&&p(S.anchor)&&p(S.focus)?e.$setSelection(S.clone()):null!==m?m.selectEnd():n.dirty=!0}function m(e){const t=S(e);return null!==t&&"vertical-rl"===t.writingMode}function S(t){const n=t.anchor.getNode();return e.$isElementNode(n)?i(n):s(n)}function N(e,t,n,o){e.modify(t?"extend":"move",n,o)}function x(e){const t=S(e);return null!==t&&"rtl"===t.direction}function y(t,n,o){const r=t.getStyle(),i=e.getStyleObjectFromCSS(r);return null!==i&&i[n]||o}const T=e.getStyleObjectFromCSS,C=l;exports.$cloneWithProperties=e.$cloneWithProperties,exports.$selectAll=e.$selectAll,exports.$addNodeStyle=c,exports.$copyBlockFormatIndent=g,exports.$ensureForwardRangeSelection=a,exports.$forEachSelectedTextNode=d,exports.$getComputedStyleForElement=i,exports.$getComputedStyleForParent=s,exports.$getSelectionStyleValueForProperty=function(t,n,o=""){let r=null;const i=t.getNodes();let s,l;if(e.$isRangeSelection(t)){if(t.isCollapsed()&&""!==t.style){const o=e.getStyleObjectFromCSS(t.style);if(null!==o&&n in o)return o[n]}const{anchor:o,focus:r}=t,i=t.isBackward(),c=i?r.getNode():o.getNode(),f=i?o.getNode():r.getNode(),d=i?r.offset:o.offset,a=i?o.offset:r.offset;e.$isTextNode(c)&&d===c.getTextContentSize()&&(s=c),0===a&&(l=f)}for(let t=0;t<i.length;t++){const c=i[t];if(e.$isTextNode(c)&&!c.is(0===t?s:l)){const e=y(c,n,o);if(null===r)r=e;else if(r!==e){r="";break}}}return null===r?o:r},exports.$isAtEdgeOfElement=u,exports.$isAtNodeEnd=function(n){if("text"===n.type)return n.offset===n.getNode().getTextContentSize();const o=n.getNode();return e.$isElementNode(o)||t(177),n.offset===o.getChildrenSize()},exports.$isParentElementRTL=x,exports.$isParentRTL=function(e){const t=s(e);return null!==t&&"rtl"===t.direction},exports.$moveCaretSelection=N,exports.$moveCharacter=function(e,t,n){const o=x(e);let r;r=m(e)||o?!n:n,N(e,t,r,"character")},exports.$patchStyleText=function(t,n){if(e.$isRangeSelection(t)&&t.isCollapsed()){f(t,n);const o=t.anchor.getNode();e.$isElementNode(o)&&o.isEmpty()&&f(o,n)}d(e=>{f(e,n)});const o=t.getNodes();if(o.length>0){const t=new Set;for(const r of o){if(!e.$isElementNode(r)||!r.canBeEmpty()||0!==r.getChildrenSize())continue;const o=r.getKey();t.has(o)||(t.add(o),f(r,n))}}},exports.$setBlocksType=function(t,n,o=g){if(!t)return;const r=t.getStartEndPoints();let i=!1,s=null;const l=new Map;if(r){const[n,o]=r,c=e.$findMatchingParent(n.getNode(),e.INTERNAL_$isBlock);s=e.$findMatchingParent(o.getNode(),e.INTERNAL_$isBlock);const f=t.isBackward()?"previous":"next";i=e.$isElementNode(s)&&!s.is(c)&&function(t,n,o){const r=t.getNode();return(!e.$isElementNode(r)||!r.isEmpty())&&u(t,n,o)}(o,s,e.flipDirection(f)),e.$isElementNode(c)&&l.set(c.getKey(),c),e.$isElementNode(s)&&!i&&l.set(s.getKey(),s)}for(const n of t.getNodes())if(e.$isElementNode(n)&&e.INTERNAL_$isBlock(n)){if(i&&n.is(s))continue;l.set(n.getKey(),n)}else if(!r){const t=e.$findMatchingParent(n,e.INTERNAL_$isBlock);e.$isElementNode(t)&&l.set(t.getKey(),t)}for(const e of l.values()){const t=n();o(e,t),e.replace(t,!0)}},exports.$shouldOverrideDefaultCharacterSelection=function(t,n){let o=m(t)?!n:n;x(t)&&(o=!o);const r=e.$caretFromPoint(t.focus,o?"previous":"next");if(e.$isExtendableTextPointCaret(r))return!1;if(e.$isTextPointCaret(r)&&!e.$isTabNode(r.origin)&&r.origin.isUnmergeable()){const t=r.getNodeAtCaret();if(e.$isTextNode(t)&&!e.$isTabNode(t))return!0}for(const t of e.$extendCaretToRange(r)){if(e.$isChildCaret(t))return!t.origin.isInline();if(!e.$isElementNode(t.origin)){if(e.$isDecoratorNode(t.origin))return!0;break}}return!1},exports.$sliceSelectedTextNodeContent=function(t,n,o="self"){const r=t.getStartEndPoints();if(n.isSelected(t)&&!e.$isTokenOrSegmented(n)&&null!==r){const[i,s]=r,l=t.isBackward(),c=i.getNode(),f=s.getNode(),d=n.is(c),a=n.is(f);if(d||a){const[r,i]=e.$getCharacterOffsets(t),s=c.is(f),d=n.is(l?f:c),a=n.is(l?c:f);let g,u=0;if(s)u=r>i?i:r,g=r>i?r:i;else if(d){u=l?i:r,g=void 0}else if(a){u=0,g=l?r:i}const p=n.__text.slice(u,g);p!==n.__text&&("clone"===o&&(n=e.$cloneWithPropertiesEphemeral(n)),n.__text=p)}}return n},exports.$trimTextContentFromAnchor=l,exports.$wrapNodes=function(t,n,o=null){const r=t.getStartEndPoints(),i=r?r[0]:null,s=t.getNodes(),l=s.length;if(null!==i&&(0===l||1===l&&"element"===i.type&&0===i.getNode().getChildrenSize())){const e="text"===i.type?i.getNode().getParentOrThrow():i.getNode(),t=e.getChildren();let r=n();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),t.forEach(e=>r.append(e)),o&&(r=o.append(r)),void e.replace(r)}let c=null,f=[];for(let r=0;r<l;r++){const i=s[r];e.$isRootOrShadowRoot(i)?(h(t,f,f.length,n,o),f=[],c=i):null===c||null!==c&&e.$hasAncestor(i,c)?f.push(i):(h(t,f,f.length,n,o),f=[i])}h(t,f,f.length,n,o)},exports.createDOMRange=function(t,r,i,s,l){const c=r.getKey(),f=s.getKey(),d=e.getRootOwnerDocument(t.getRootElement()).createRange();let a=t.getElementByKey(c),g=t.getElementByKey(f),u=i,p=l;if(e.$isTextNode(r)&&(a=n(a)),e.$isTextNode(s)&&(g=n(g)),void 0===r||void 0===s||null===a||null===g)return null;"BR"===a.nodeName&&([a,u]=o(a)),"BR"===g.nodeName&&([g,p]=o(g));const $=a.firstChild;a===g&&null!=$&&"BR"===$.nodeName&&0===u&&0===p&&(p=1);try{d.setStart(a,u),d.setEnd(g,p)}catch(e){return null}return!d.collapsed||u===p&&c===f||(d.setStart(g,p),d.setEnd(a,u)),d},exports.createRectsFromDOMRange=function(e,t){const n=e.getRootElement();if(null===n)return[];const o=n.getBoundingClientRect(),r=getComputedStyle(n),i=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight),s=Array.from(t.getClientRects());let l,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=l&&l.top<=t.top&&l.top+l.height>t.top&&l.left+l.width>t.left,r=t.width+i===o.width;n||r?(s.splice(e--,1),c--):l=t}return s},exports.getCSSFromStyleObject=r,exports.getStyleObjectFromCSS=T,exports.trimTextContentFromAnchor=C;
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{getRootOwnerDocument as e,$isTextNode as t,$getEditor as n,$isRootNode as o,$getSelection as l,$isRangeSelection as r,$caretRangeFromSelection as i,$isTokenOrSegmented as s,$isElementNode as c,$getCharacterOffsets as f,$cloneWithPropertiesEphemeral as u,$getNodeByKey as g,$getPreviousSelection as a,$createTextNode as d,getStyleObjectFromCSS as p,$caretFromPoint as h,$isExtendableTextPointCaret as y,$findMatchingParent as m,INTERNAL_$isBlock as S,flipDirection as x,$
|
|
10
|
-
/*@__INLINE__*/function
|
|
9
|
+
import{getRootOwnerDocument as e,$isTextNode as t,$getEditor as n,$isRootNode as o,$getSelection as l,$isRangeSelection as r,$caretRangeFromSelection as i,$isTokenOrSegmented as s,$isElementNode as c,$getCharacterOffsets as f,$cloneWithPropertiesEphemeral as u,$getNodeByKey as g,$getPreviousSelection as a,$createTextNode as d,getStyleObjectFromCSS as p,$caretFromPoint as h,$isExtendableTextPointCaret as y,$findMatchingParent as m,INTERNAL_$isBlock as S,flipDirection as x,$isTextPointCaret as C,$isTabNode as N,$extendCaretToRange as T,$isChildCaret as w,$isDecoratorNode as v,$isRootOrShadowRoot as P,$hasAncestor as K,$isLeafNode as E,$setSelection as I}from"lexical";export{$cloneWithProperties,$selectAll}from"lexical";function B(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.`)}
|
|
10
|
+
/*@__INLINE__*/function k(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild}return null}function F(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return[t,Array.from(t.childNodes).indexOf(e)]}function b(n,o,l,r,i){const s=o.getKey(),c=r.getKey(),f=e(n.getRootElement()).createRange();let u=n.getElementByKey(s),g=n.getElementByKey(c),a=l,d=i;if(t(o)&&(u=k(u)),t(r)&&(g=k(g)),void 0===o||void 0===r||null===u||null===g)return null;"BR"===u.nodeName&&([u,a]=F(u)),"BR"===g.nodeName&&([g,d]=F(g));const p=u.firstChild;u===g&&null!=p&&"BR"===p.nodeName&&0===a&&0===d&&(d=1);try{f.setStart(u,a),f.setEnd(g,d)}catch(e){return null}return!f.collapsed||a===d&&s===c||(f.setStart(g,d),f.setEnd(u,a)),f}function z(e,t){const n=e.getRootElement();if(null===n)return[];const o=n.getBoundingClientRect(),l=getComputedStyle(n),r=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight),i=Array.from(t.getClientRects());let s,c=i.length;i.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=i[e],n=s&&s.top<=t.top&&s.top+s.height>t.top&&s.left+s.width>t.left,l=t.width+r===o.width;n||l?(i.splice(e--,1),c--):s=t}return i}function A(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function R(e){const t=n().getElementByKey(e.getKey());if(null===t)return null;const o=t.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(t)}function O(e){return R(o(e)?e:e.getParentOrThrow())}function _(e){const t=O(e);return null!==t&&"rtl"===t.direction}function L(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!s(t)&&null!==o){const[l,r]=o,i=e.isBackward(),s=l.getNode(),c=r.getNode(),g=t.is(s),a=t.is(c);if(g||a){const[o,l]=f(e),r=s.is(c),g=t.is(i?c:s),a=t.is(i?s:c);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(g){p=i?l:o,d=void 0}else if(a){p=0,d=i?o:l}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=u(t)),t.__text=h)}}return t}function M(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return c(t)||B(177),e.offset===t.getChildrenSize()}function $(e,n,l){let i=n.getNode(),s=l;if(c(i)){const e=i.getDescendantByIndex(n.offset);null!==e&&(i=e)}for(;s>0&&null!==i;){if(c(i)){const e=i.getLastDescendant();null!==e&&(i=e)}let l=i.getPreviousSibling(),f=0;if(null===l){let e=i.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){l=null;break}t=e.getPreviousSibling()}null!==e&&(f=e.isInline()?0:2,l=t)}let u=i.getTextContent();""===u&&c(i)&&!i.isInline()&&(u="\n\n");const p=u.length;if(!t(i)||s>=p){const e=i.getParent();i.remove(),null==e||0!==e.getChildrenSize()||o(e)||e.remove(),s-=p+f,i=l}else{const o=i.getKey(),l=e.read("latest",()=>{const e=g(o);return t(e)&&e.isSimpleText()?e.getTextContent():null}),c=p-s,f=u.slice(0,c);if(null!==l&&l!==u){const e=a();let t=i;if(i.isSimpleText())i.setTextContent(l);else{const e=d(l);i.replace(e),t=e}if(r(e)&&e.isCollapsed()){const n=e.anchor.offset;t.select(n,n)}}else if(i.isSimpleText()){const e=n.key===o;let t=n.offset;t<s&&(t=p);const l=e?t-s:0,r=e?t:c;if(e&&0===l){const[e]=i.splitText(l,r);e.remove()}else{const[,e]=i.splitText(l,r);e.remove()}}else{const e=d(f);i.replace(e)}s=0}}}const D=()=>{};function U(e,n){(r(e)?e.isCollapsed():t(e)||c(e))||B(280);const o=p(r(e)?e.style:t(e)?e.getStyle():e.getTextStyle()),l=A(Object.entries(n).reduce((t,[n,l])=>("function"==typeof l?t[n]=l(o[n],e):null===l?delete t[n]:t[n]=l,t),{...o}));r(e)||t(e)?e.setStyle(l):e.setTextStyle(l)}function j(e,t){if(r(e)&&e.isCollapsed()){U(e,t);const n=e.anchor.getNode();c(n)&&n.isEmpty()&&U(n,t)}H(e=>{U(e,t)});const n=e.getNodes();if(n.length>0){const e=new Set;for(const o of n){if(!c(o)||!o.canBeEmpty()||0!==o.getChildrenSize())continue;const n=o.getKey();e.has(n)||(e.add(n),U(o,t))}}}function H(e){const n=l();if(!n)return;const o=new Map,c=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(r(n))for(const e of i(n).getTextSlices())e&&o.set(e.caret.origin.getKey(),e.getSliceIndices());const f=n.getNodes();for(const n of f){if(!t(n)||!n.canHaveFormat())continue;const[o,l]=c(n);if(l!==o)if(s(n)||0===o&&l===n.getTextContentSize())e(n);else{e(n.splitText(o,l)[0===o?0:1])}}r(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&V(n)}function V(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 W(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function X(e,t,n){let o=h(e,n);if(y(o))return!1;for(;o;o=o.getParentCaret()){const e=o.getParentAtCaret();if(!e||o.getNodeAtCaret())return!1;if(t.is(e))return!0}return!1}function q(e,t,n=W){if(!e)return;const o=e.getStartEndPoints();let l=!1,r=null;const i=new Map;if(o){const[t,n]=o,s=m(t.getNode(),S);r=m(n.getNode(),S);const f=e.isBackward()?"previous":"next";l=c(r)&&!r.is(s)&&function(e,t,n){const o=e.getNode();return(!c(o)||!o.isEmpty())&&X(e,t,n)}(n,r,x(f)),c(s)&&i.set(s.getKey(),s),c(r)&&!l&&i.set(r.getKey(),r)}for(const t of e.getNodes())if(c(t)&&S(t)){if(l&&t.is(r))continue;i.set(t.getKey(),t)}else if(!o){const e=m(t,S);c(e)&&i.set(e.getKey(),e)}for(const e of i.values()){const o=t();n(e,o),e.replace(o,!0)}}function G(e){return e.getNode().isAttached()}function J(e){let t=e;for(;null!==t&&!P(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function Q(e,t,n=null){const o=e.getStartEndPoints(),l=o?o[0]:null,r=e.getNodes(),i=r.length;if(null!==l&&(0===i||1===i&&"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 s=null,c=[];for(let o=0;o<i;o++){const l=r[o];P(l)?(Y(e,c,c.length,t,n),c=[],s=l):null===s||null!==s&&K(l,s)?c.push(l):(Y(e,c,c.length,t,n),c=[l])}Y(e,c,c.length,t,n)}function Y(e,t,n,o,l=null){if(0===t.length)return;const i=t[0],s=new Map,f=[],u=c(i)?i:i.getParentOrThrow();let g=u.isInline()?u.getParentOrThrow():u,d=!1;for(;null!==g;){const e=g.getPreviousSibling();if(null!==e){g=e,d=!0;break}if(g=g.getParentOrThrow(),P(g))break}const p=new Set;for(let e=0;e<n;e++){const n=t[e];c(n)&&0===n.getChildrenSize()&&p.add(n.getKey())}const h=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&&E(n)&&!h.has(n.getKey())){const e=l.getKey();if(void 0===s.get(e)){const t=o();t.setFormat(l.getFormatType()),t.setIndent(l.getIndent()),f.push(t),s.set(e,t);const n=l.getChildren();t.splice(t.getChildrenSize(),0,n);for(const e of n)if(h.add(e.getKey()),c(e))for(const t of e.getChildrenKeys())h.add(t);J(l)}}else if(p.has(n.getKey())){c(n)||B(179);const e=o();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),f.push(e),n.remove(!0)}}if(null!==l)for(let e=0;e<f.length;e++){const t=f[e];l.append(t)}let y=null;if(P(g))if(d)if(null!==l)g.insertAfter(l);else for(let e=f.length-1;e>=0;e--){const t=f[e];g.insertAfter(t)}else{const e=g,t=e.getFirstChild();if(c(t)&&(g=t),null===t)if(l)e.append(l);else for(let t=0;t<f.length;t++){const n=f[t];e.append(n),y=n}else if(null!==l)t.insertBefore(l);else for(let e=0;e<f.length;e++){const n=f[e];t.insertBefore(n),y=n}}else if(l)g.insertAfter(l);else for(let e=f.length-1;e>=0;e--){const t=f[e];g.insertAfter(t),y=t}const m=a();r(m)&&G(m.anchor)&&G(m.focus)?I(m.clone()):null!==y?y.selectEnd():e.dirty=!0}function Z(e){const t=ee(e);return null!==t&&"vertical-rl"===t.writingMode}function ee(e){const t=e.anchor.getNode();return c(t)?R(t):O(t)}function te(e,n){let o=Z(e)?!n:n;oe(e)&&(o=!o);const l=h(e.focus,o?"previous":"next");if(y(l))return!1;if(C(l)&&!N(l.origin)&&l.origin.isUnmergeable()){const e=l.getNodeAtCaret();if(t(e)&&!N(e))return!0}for(const e of T(l)){if(w(e))return!e.origin.isInline();if(!c(e.origin)){if(v(e.origin))return!0;break}}return!1}function ne(e,t,n,o){e.modify(t?"extend":"move",n,o)}function oe(e){const t=ee(e);return null!==t&&"rtl"===t.direction}function le(e,t,n){const o=oe(e);let l;l=Z(e)||o?!n:n,ne(e,t,l,"character")}function re(e,t,n){const o=e.getStyle(),l=p(o);return null!==l&&l[t]||n}function ie(e,n,o=""){let l=null;const i=e.getNodes();let s,c;if(r(e)){if(e.isCollapsed()&&""!==e.style){const t=p(e.style);if(null!==t&&n in t)return t[n]}const{anchor:o,focus:l}=e,r=e.isBackward(),i=r?l.getNode():o.getNode(),f=r?o.getNode():l.getNode(),u=r?l.offset:o.offset,g=r?o.offset:l.offset;t(i)&&u===i.getTextContentSize()&&(s=i),0===g&&(c=f)}for(let e=0;e<i.length;e++){const r=i[e];if(t(r)&&!r.is(0===e?s:c)){const e=re(r,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l}const se=p,ce=$;export{D as $addNodeStyle,W as $copyBlockFormatIndent,V as $ensureForwardRangeSelection,H as $forEachSelectedTextNode,R as $getComputedStyleForElement,O as $getComputedStyleForParent,ie as $getSelectionStyleValueForProperty,X as $isAtEdgeOfElement,M as $isAtNodeEnd,oe as $isParentElementRTL,_ as $isParentRTL,ne as $moveCaretSelection,le as $moveCharacter,j as $patchStyleText,q as $setBlocksType,te as $shouldOverrideDefaultCharacterSelection,L as $sliceSelectedTextNodeContent,$ as $trimTextContentFromAnchor,Q as $wrapNodes,b as createDOMRange,z as createRectsFromDOMRange,A as getCSSFromStyleObject,se as getStyleObjectFromCSS,ce as trimTextContentFromAnchor};
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"selection"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.47.0",
|
|
13
13
|
"main": "./dist/LexicalSelection.js",
|
|
14
14
|
"types": "./dist/typescript-too-old.d.ts",
|
|
15
15
|
"repository": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@lexical/internal": "0.
|
|
44
|
-
"lexical": "0.
|
|
43
|
+
"@lexical/internal": "0.47.0",
|
|
44
|
+
"lexical": "0.47.0"
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
47
|
"dist",
|
package/src/range-selection.ts
CHANGED
|
@@ -20,7 +20,9 @@ import {
|
|
|
20
20
|
$isLeafNode,
|
|
21
21
|
$isRangeSelection,
|
|
22
22
|
$isRootOrShadowRoot,
|
|
23
|
+
$isTabNode,
|
|
23
24
|
$isTextNode,
|
|
25
|
+
$isTextPointCaret,
|
|
24
26
|
$setSelection,
|
|
25
27
|
type BaseSelection,
|
|
26
28
|
type CaretDirection,
|
|
@@ -547,6 +549,20 @@ export function $shouldOverrideDefaultCharacterSelection(
|
|
|
547
549
|
if ($isExtendableTextPointCaret(focusCaret)) {
|
|
548
550
|
return false;
|
|
549
551
|
}
|
|
552
|
+
// At an unmergeable TextNode boundary adjacent to another plain TextNode,
|
|
553
|
+
// override so Lexical's modify() can pre-normalize across inline-grid/flex
|
|
554
|
+
// spans (#7301). Restricted to unmergeable nodes to avoid disrupting
|
|
555
|
+
// format-affinity at normal bold/italic boundaries.
|
|
556
|
+
if (
|
|
557
|
+
$isTextPointCaret(focusCaret) &&
|
|
558
|
+
!$isTabNode(focusCaret.origin) &&
|
|
559
|
+
focusCaret.origin.isUnmergeable()
|
|
560
|
+
) {
|
|
561
|
+
const sibling = focusCaret.getNodeAtCaret();
|
|
562
|
+
if ($isTextNode(sibling) && !$isTabNode(sibling)) {
|
|
563
|
+
return true;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
550
566
|
for (const nextCaret of $extendCaretToRange(focusCaret)) {
|
|
551
567
|
if ($isChildCaret(nextCaret)) {
|
|
552
568
|
return !nextCaret.origin.isInline();
|