@lexical/selection 0.35.1-nightly.20250923.0 → 0.35.1-nightly.20250925.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.
@@ -209,7 +209,7 @@ function getCSSFromStyleObject(styles) {
209
209
 
210
210
  /**
211
211
  * Gets the computed DOM styles of the element.
212
- * @param node - The node to check the styles for.
212
+ * @param element - The node to check the styles for.
213
213
  * @returns the computed styles of the element or null if there is no DOM element or no default view for the document.
214
214
  */
215
215
  function $getComputedStyleForElement(element) {
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import { $isTextNode, $getEditor, $isRootNode, $isTokenOrSegmented, $getCharacterOffsets, $isElementNode, $getNodeByKey, $getPreviousSelection, $createTextNode, $isRangeSelection, $getSelection, $caretRangeFromSelection, $createRangeSelection, $findMatchingParent, INTERNAL_$isBlock, $setSelection, $isRootOrShadowRoot, $hasAncestor, $isLeafNode, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isChildCaret, $isDecoratorNode } from 'lexical';
9
+ import { $isTextNode, $getEditor, $isRootNode, $isElementNode, $getNodeByKey, $getPreviousSelection, $createTextNode, $isRangeSelection, $getSelection, $caretRangeFromSelection, $isTokenOrSegmented, $getCharacterOffsets, $createRangeSelection, $findMatchingParent, INTERNAL_$isBlock, $setSelection, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isChildCaret, $isDecoratorNode, $isRootOrShadowRoot, $hasAncestor, $isLeafNode } from 'lexical';
10
10
  export { $cloneWithProperties, $selectAll } from 'lexical';
11
11
 
12
12
  /**
@@ -208,7 +208,7 @@ function getCSSFromStyleObject(styles) {
208
208
 
209
209
  /**
210
210
  * Gets the computed DOM styles of the element.
211
- * @param node - The node to check the styles for.
211
+ * @param element - The node to check the styles for.
212
212
  * @returns the computed styles of the element or null if there is no DOM element or no default view for the document.
213
213
  */
214
214
  function $getComputedStyleForElement(element) {
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$isTextNode as e,$getEditor as t,$isRootNode as n,$isTokenOrSegmented as o,$getCharacterOffsets as l,$isElementNode as r,$getNodeByKey as s,$getPreviousSelection as i,$createTextNode as c,$isRangeSelection as f,$getSelection as u,$caretRangeFromSelection as g,$createRangeSelection as a,$findMatchingParent as d,INTERNAL_$isBlock as p,$setSelection as h,$isRootOrShadowRoot as y,$hasAncestor as m,$isLeafNode as S,$caretFromPoint as x,$isExtendableTextPointCaret as T,$extendCaretToRange as v,$isChildCaret as w,$isDecoratorNode as N}from"lexical";export{$cloneWithProperties,$selectAll}from"lexical";function C(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 K=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 E(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(e(n)&&(f=P(f)),e(l)&&(u=P(u)),void 0===n||void 0===l||null===f||null===u)return null;"BR"===f.nodeName&&([f,g]=E(f)),"BR"===u.nodeName&&([u,a]=E(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 I(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 B(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 F(e){let t=K.get(e);return void 0===t&&(t=B(e),K.set(e,t)),t}function b(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function R(e){const n=t().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function O(e){return R(n(e)?e:e.getParentOrThrow())}function z(e){const t=O(e);return null!==t&&"rtl"===t.direction}function A(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!o(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]=l(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 M(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return r(t)||C(177),e.offset===t.getChildrenSize()}function L(t,o,l){let u=o.getNode(),g=l;if(r(u)){const e=u.getDescendantByIndex(o.offset);null!==e&&(u=e)}for(;g>0&&null!==u;){if(r(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&&r(u)&&!u.isInline()&&(d="\n\n");const p=d.length;if(!e(u)||g>=p){const e=u.getParent();u.remove(),null==e||0!==e.getChildrenSize()||n(e)||e.remove(),g-=p+a,u=l}else{const n=u.getKey(),l=t.getEditorState().read((()=>{const t=s(n);return e(t)&&t.isSimpleText()?t.getTextContent():null})),r=p-g,a=d.slice(0,r);if(null!==l&&l!==d){const e=i();let t=u;if(u.isSimpleText())u.setTextContent(l);else{const e=c(l);u.replace(e),t=e}if(f(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=c(a);u.replace(e)}g=0}}}function $(e){const t=e.getStyle(),n=B(t);K.set(t,n)}function _(t,n){(f(t)?t.isCollapsed():e(t)||r(t))||C(280);const o=F(f(t)?t.style:e(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=b(l);f(t)||e(t)?t.setStyle(s):t.setTextStyle(s),K.set(s,l)}function D(e,t){if(f(e)&&e.isCollapsed()){_(e,t);const n=e.anchor.getNode();r(n)&&n.isEmpty()&&_(n,t)}U((e=>{_(e,t)}))}function U(t){const n=u();if(!n)return;const l=new Map;if(f(n))for(const e of g(n).getTextSlices())e&&l.set(e.caret.origin.getKey(),e.getSliceIndices());const r=n.getNodes();for(const n of r){if(!e(n)||!n.canHaveFormat())continue;const[r,i]=(s=n,l.get(s.getKey())||[0,s.getTextContentSize()]);if(i!==r)if(o(n)||0===r&&i===n.getTextContentSize())t(n);else{t(n.splitText(r,i)[0===r?0:1])}}var s;f(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&j(n)}function j(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 H(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function V(e,t,n=H){if(null===e)return;const o=e.getStartEndPoints(),l=new Map;let s=null;if(o){const[e,t]=o;s=a(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=d(e.getNode(),p),i=d(t.getNode(),p);r(n)&&l.set(n.getKey(),n),r(i)&&l.set(i.getKey(),i)}for(const t of e.getNodes())if(r(t)&&p(t))l.set(t.getKey(),t);else if(null===o){const e=d(t,p);r(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(u())&&h(s)}function W(e){return e.getNode().isAttached()}function X(e){let t=e;for(;null!==t&&!y(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(),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];y(l)?(G(e,c,c.length,t,n),c=[],i=l):null===i||null!==i&&m(l,i)?c.push(l):(G(e,c,c.length,t,n),c=[l])}G(e,c,c.length,t,n)}function G(e,t,n,o,l=null){if(0===t.length)return;const s=t[0],c=new Map,u=[];let g=r(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(),y(g))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];r(n)&&0===n.getChildrenSize()&&d.add(n.getKey())}const p=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&&S(n)&&!p.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),p.add(e.getKey()),r(e)&&e.getChildrenKeys().forEach((e=>p.add(e)))})),X(l)}}else if(d.has(n.getKey())){r(n)||C(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 m=null;if(y(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(r(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),m=t}else if(null!==l)e.insertBefore(l);else for(let t=0;t<u.length;t++){const n=u[t];e.insertBefore(n),m=n}}else if(l)g.insertAfter(l);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t),m=t}const x=i();f(x)&&W(x.anchor)&&W(x.focus)?h(x.clone()):null!==m?m.selectEnd():e.dirty=!0}function J(e){const t=Q(e);return null!==t&&"vertical-rl"===t.writingMode}function Q(e){const t=e.anchor.getNode();return r(t)?R(t):O(t)}function Y(e,t){let n=J(e)?!t:t;ee(e)&&(n=!n);const o=x(e.focus,n?"previous":"next");if(T(o))return!1;for(const e of v(o)){if(w(e))return!e.origin.isInline();if(!r(e.origin)){if(N(e.origin))return!0;break}}return!1}function Z(e,t,n,o){e.modify(t?"extend":"move",n,o)}function ee(e){const t=Q(e);return null!==t&&"rtl"===t.direction}function te(e,t,n){const o=ee(e);let l;l=J(e)||o?!n:n,Z(e,t,l,"character")}function ne(e,t,n){const o=F(e.getStyle());return null!==o&&o[t]||n}function oe(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(f(t)&&t.isCollapsed()&&""!==t.style){const e=F(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))&&e(s)){const e=ne(s,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l}const le=L;export{$ as $addNodeStyle,H as $copyBlockFormatIndent,j as $ensureForwardRangeSelection,U as $forEachSelectedTextNode,R as $getComputedStyleForElement,O as $getComputedStyleForParent,oe as $getSelectionStyleValueForProperty,M as $isAtNodeEnd,ee as $isParentElementRTL,z as $isParentRTL,Z as $moveCaretSelection,te as $moveCharacter,D as $patchStyleText,V as $setBlocksType,Y as $shouldOverrideDefaultCharacterSelection,A as $sliceSelectedTextNodeContent,L as $trimTextContentFromAnchor,q as $wrapNodes,k as createDOMRange,I as createRectsFromDOMRange,b as getCSSFromStyleObject,F as getStyleObjectFromCSS,le as trimTextContentFromAnchor};
9
+ import{$isTextNode as e,$getEditor as t,$isRootNode as n,$isElementNode as o,$getNodeByKey as l,$getPreviousSelection as r,$createTextNode as s,$isRangeSelection as i,$getSelection as c,$caretRangeFromSelection as f,$isTokenOrSegmented as u,$getCharacterOffsets as g,$createRangeSelection as a,$findMatchingParent as d,INTERNAL_$isBlock as p,$setSelection as h,$caretFromPoint as y,$isExtendableTextPointCaret as m,$extendCaretToRange as S,$isChildCaret as x,$isDecoratorNode as T,$isRootOrShadowRoot as v,$hasAncestor as w,$isLeafNode as N}from"lexical";export{$cloneWithProperties,$selectAll}from"lexical";function C(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 K=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 E(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(e(n)&&(f=P(f)),e(l)&&(u=P(u)),void 0===n||void 0===l||null===f||null===u)return null;"BR"===f.nodeName&&([f,g]=E(f)),"BR"===u.nodeName&&([u,a]=E(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 I(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 B(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 F(e){let t=K.get(e);return void 0===t&&(t=B(e),K.set(e,t)),t}function b(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function R(e){const n=t().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function O(e){return R(n(e)?e:e.getParentOrThrow())}function z(e){const t=O(e);return null!==t&&"rtl"===t.direction}function A(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!u(t)&&null!==n){const[o,l]=n,r=e.isBackward(),s=o.getNode(),i=l.getNode(),c=t.is(s),f=t.is(i);if(c||f){const[n,o]=g(e),l=s.is(i),c=t.is(r?i:s),f=t.is(r?s:i);let u,a=0;if(l)a=n>o?o:n,u=n>o?n:o;else if(c){a=r?o:n,u=void 0}else if(f){a=0,u=r?n:o}t.__text=t.__text.slice(a,u)}}return t}function M(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return o(t)||C(177),e.offset===t.getChildrenSize()}function L(t,c,f){let u=c.getNode(),g=f;if(o(u)){const e=u.getDescendantByIndex(c.offset);null!==e&&(u=e)}for(;g>0&&null!==u;){if(o(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&&o(u)&&!u.isInline()&&(d="\n\n");const p=d.length;if(!e(u)||g>=p){const e=u.getParent();u.remove(),null==e||0!==e.getChildrenSize()||n(e)||e.remove(),g-=p+a,u=f}else{const n=u.getKey(),o=t.getEditorState().read((()=>{const t=l(n);return e(t)&&t.isSimpleText()?t.getTextContent():null})),f=p-g,a=d.slice(0,f);if(null!==o&&o!==d){const e=r();let t=u;if(u.isSimpleText())u.setTextContent(o);else{const e=s(o);u.replace(e),t=e}if(i(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=s(a);u.replace(e)}g=0}}}function $(e){const t=e.getStyle(),n=B(t);K.set(t,n)}function _(t,n){(i(t)?t.isCollapsed():e(t)||o(t))||C(280);const l=F(i(t)?t.style:e(t)?t.getStyle():t.getTextStyle()),r=Object.entries(n).reduce(((e,[n,o])=>("function"==typeof o?e[n]=o(l[n],t):null===o?delete e[n]:e[n]=o,e)),{...l}),s=b(r);i(t)||e(t)?t.setStyle(s):t.setTextStyle(s),K.set(s,r)}function D(e,t){if(i(e)&&e.isCollapsed()){_(e,t);const n=e.anchor.getNode();o(n)&&n.isEmpty()&&_(n,t)}U((e=>{_(e,t)}))}function U(t){const n=c();if(!n)return;const o=new Map;if(i(n))for(const e of f(n).getTextSlices())e&&o.set(e.caret.origin.getKey(),e.getSliceIndices());const l=n.getNodes();for(const n of l){if(!e(n)||!n.canHaveFormat())continue;const[l,s]=(r=n,o.get(r.getKey())||[0,r.getTextContentSize()]);if(s!==l)if(u(n)||0===l&&s===n.getTextContentSize())t(n);else{t(n.splitText(l,s)[0===l?0:1])}}var r;i(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&j(n)}function j(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 H(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function V(e,t,n=H){if(null===e)return;const l=e.getStartEndPoints(),r=new Map;let s=null;if(l){const[e,t]=l;s=a(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=d(e.getNode(),p),i=d(t.getNode(),p);o(n)&&r.set(n.getKey(),n),o(i)&&r.set(i.getKey(),i)}for(const t of e.getNodes())if(o(t)&&p(t))r.set(t.getKey(),t);else if(null===l){const e=d(t,p);o(e)&&r.set(e.getKey(),e)}for(const[e,o]of r){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(c())&&h(s)}function W(e){return e.getNode().isAttached()}function X(e){let t=e;for(;null!==t&&!v(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(),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];v(l)?(G(e,c,c.length,t,n),c=[],i=l):null===i||null!==i&&w(l,i)?c.push(l):(G(e,c,c.length,t,n),c=[l])}G(e,c,c.length,t,n)}function G(e,t,n,l,s=null){if(0===t.length)return;const c=t[0],f=new Map,u=[];let g=o(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(),v(g))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];o(n)&&0===n.getChildrenSize()&&d.add(n.getKey())}const p=new Set;for(let e=0;e<n;e++){const n=t[e];let r=n.getParent();if(null!==r&&r.isInline()&&(r=r.getParent()),null!==r&&N(n)&&!p.has(n.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),p.add(e.getKey()),o(e)&&e.getChildrenKeys().forEach((e=>p.add(e)))})),X(r)}}else if(d.has(n.getKey())){o(n)||C(179);const e=l();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),u.push(e),n.remove(!0)}}if(null!==s)for(let e=0;e<u.length;e++){const t=u[e];s.append(t)}let y=null;if(v(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(o(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),y=t}else if(null!==s)e.insertBefore(s);else for(let t=0;t<u.length;t++){const n=u[t];e.insertBefore(n),y=n}}else if(s)g.insertAfter(s);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t),y=t}const m=r();i(m)&&W(m.anchor)&&W(m.focus)?h(m.clone()):null!==y?y.selectEnd():e.dirty=!0}function J(e){const t=Q(e);return null!==t&&"vertical-rl"===t.writingMode}function Q(e){const t=e.anchor.getNode();return o(t)?R(t):O(t)}function Y(e,t){let n=J(e)?!t:t;ee(e)&&(n=!n);const l=y(e.focus,n?"previous":"next");if(m(l))return!1;for(const e of S(l)){if(x(e))return!e.origin.isInline();if(!o(e.origin)){if(T(e.origin))return!0;break}}return!1}function Z(e,t,n,o){e.modify(t?"extend":"move",n,o)}function ee(e){const t=Q(e);return null!==t&&"rtl"===t.direction}function te(e,t,n){const o=ee(e);let l;l=J(e)||o?!n:n,Z(e,t,l,"character")}function ne(e,t,n){const o=F(e.getStyle());return null!==o&&o[t]||n}function oe(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(i(t)&&t.isCollapsed()&&""!==t.style){const e=F(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))&&e(s)){const e=ne(s,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l}const le=L;export{$ as $addNodeStyle,H as $copyBlockFormatIndent,j as $ensureForwardRangeSelection,U as $forEachSelectedTextNode,R as $getComputedStyleForElement,O as $getComputedStyleForParent,oe as $getSelectionStyleValueForProperty,M as $isAtNodeEnd,ee as $isParentElementRTL,z as $isParentRTL,Z as $moveCaretSelection,te as $moveCharacter,D as $patchStyleText,V as $setBlocksType,Y as $shouldOverrideDefaultCharacterSelection,A as $sliceSelectedTextNodeContent,L as $trimTextContentFromAnchor,q as $wrapNodes,k as createDOMRange,I as createRectsFromDOMRange,b as getCSSFromStyleObject,F as getStyleObjectFromCSS,le as trimTextContentFromAnchor};
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "selection"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.35.1-nightly.20250923.0",
12
+ "version": "0.35.1-nightly.20250925.0",
13
13
  "main": "LexicalSelection.js",
14
14
  "types": "index.d.ts",
15
15
  "repository": {
@@ -37,6 +37,6 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "lexical": "0.35.1-nightly.20250923.0"
40
+ "lexical": "0.35.1-nightly.20250925.0"
41
41
  }
42
42
  }
package/utils.d.ts CHANGED
@@ -43,7 +43,7 @@ export declare function getStyleObjectFromCSS(css: string): Record<string, strin
43
43
  export declare function getCSSFromStyleObject(styles: Record<string, string>): string;
44
44
  /**
45
45
  * Gets the computed DOM styles of the element.
46
- * @param node - The node to check the styles for.
46
+ * @param element - The node to check the styles for.
47
47
  * @returns the computed styles of the element or null if there is no DOM element or no default view for the document.
48
48
  */
49
49
  export declare function $getComputedStyleForElement(element: ElementNode): CSSStyleDeclaration | null;