@lexical/selection 0.34.1-nightly.20250828.0 → 0.34.1-nightly.20250901.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.
- package/LexicalSelection.dev.js +50 -10
- package/LexicalSelection.dev.mjs +49 -12
- package/LexicalSelection.mjs +3 -0
- package/LexicalSelection.node.mjs +3 -0
- package/LexicalSelection.prod.js +1 -1
- package/LexicalSelection.prod.mjs +1 -1
- package/index.d.ts +1 -1
- package/package.json +2 -2
- package/utils.d.ts +19 -1
package/LexicalSelection.dev.js
CHANGED
|
@@ -207,6 +207,44 @@ function getCSSFromStyleObject(styles) {
|
|
|
207
207
|
return css;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Gets the computed DOM styles of the element.
|
|
212
|
+
* @param node - The node to check the styles for.
|
|
213
|
+
* @returns the computed styles of the element or null if there is no DOM element or no default view for the document.
|
|
214
|
+
*/
|
|
215
|
+
function $getComputedStyleForElement(element) {
|
|
216
|
+
const editor = lexical.$getEditor();
|
|
217
|
+
const domElement = editor.getElementByKey(element.getKey());
|
|
218
|
+
if (domElement === null) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const view = domElement.ownerDocument.defaultView;
|
|
222
|
+
if (view === null) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
return view.getComputedStyle(domElement);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Gets the computed DOM styles of the parent of the node.
|
|
230
|
+
* @param node - The node to check its parent's styles for.
|
|
231
|
+
* @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
|
|
232
|
+
*/
|
|
233
|
+
function $getComputedStyleForParent(node) {
|
|
234
|
+
const parent = lexical.$isRootNode(node) ? node : node.getParentOrThrow();
|
|
235
|
+
return $getComputedStyleForElement(parent);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Determines whether a node's parent is RTL.
|
|
240
|
+
* @param node - The node to check whether it is RTL.
|
|
241
|
+
* @returns whether the node is RTL.
|
|
242
|
+
*/
|
|
243
|
+
function $isParentRTL(node) {
|
|
244
|
+
const styles = $getComputedStyleForParent(node);
|
|
245
|
+
return styles !== null && styles.direction === 'rtl';
|
|
246
|
+
}
|
|
247
|
+
|
|
210
248
|
/**
|
|
211
249
|
* Generally used to append text content to HTML and JSON. Grabs the text content and "slices"
|
|
212
250
|
* it to be generated into the new TextNode.
|
|
@@ -806,19 +844,18 @@ function $isEditorVerticalOrientation(selection) {
|
|
|
806
844
|
const computedStyle = $getComputedStyle(selection);
|
|
807
845
|
return computedStyle !== null && computedStyle.writingMode === 'vertical-rl';
|
|
808
846
|
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Gets the computed DOM styles of the parent of the selection's anchor node.
|
|
850
|
+
* @param selection - The selection to check the styles for.
|
|
851
|
+
* @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
|
|
852
|
+
*/
|
|
809
853
|
function $getComputedStyle(selection) {
|
|
810
854
|
const anchorNode = selection.anchor.getNode();
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const domElement = editor.getElementByKey(parent.getKey());
|
|
814
|
-
if (domElement === null) {
|
|
815
|
-
return null;
|
|
816
|
-
}
|
|
817
|
-
const view = domElement.ownerDocument.defaultView;
|
|
818
|
-
if (view === null) {
|
|
819
|
-
return null;
|
|
855
|
+
if (lexical.$isElementNode(anchorNode)) {
|
|
856
|
+
return $getComputedStyleForElement(anchorNode);
|
|
820
857
|
}
|
|
821
|
-
return
|
|
858
|
+
return $getComputedStyleForParent(anchorNode);
|
|
822
859
|
}
|
|
823
860
|
|
|
824
861
|
/**
|
|
@@ -992,9 +1029,12 @@ exports.$addNodeStyle = $addNodeStyle;
|
|
|
992
1029
|
exports.$copyBlockFormatIndent = $copyBlockFormatIndent;
|
|
993
1030
|
exports.$ensureForwardRangeSelection = $ensureForwardRangeSelection;
|
|
994
1031
|
exports.$forEachSelectedTextNode = $forEachSelectedTextNode;
|
|
1032
|
+
exports.$getComputedStyleForElement = $getComputedStyleForElement;
|
|
1033
|
+
exports.$getComputedStyleForParent = $getComputedStyleForParent;
|
|
995
1034
|
exports.$getSelectionStyleValueForProperty = $getSelectionStyleValueForProperty;
|
|
996
1035
|
exports.$isAtNodeEnd = $isAtNodeEnd;
|
|
997
1036
|
exports.$isParentElementRTL = $isParentElementRTL;
|
|
1037
|
+
exports.$isParentRTL = $isParentRTL;
|
|
998
1038
|
exports.$moveCaretSelection = $moveCaretSelection;
|
|
999
1039
|
exports.$moveCharacter = $moveCharacter;
|
|
1000
1040
|
exports.$patchStyleText = $patchStyleText;
|
package/LexicalSelection.dev.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { $isTextNode, $isTokenOrSegmented, $getCharacterOffsets, $isElementNode, $
|
|
9
|
+
import { $isTextNode, $getEditor, $isRootNode, $isTokenOrSegmented, $getCharacterOffsets, $isElementNode, $getNodeByKey, $getPreviousSelection, $createTextNode, $isRangeSelection, $getSelection, $caretRangeFromSelection, $createRangeSelection, INTERNAL_$isBlock, $setSelection, $isRootOrShadowRoot, $hasAncestor, $isLeafNode, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isChildCaret, $isDecoratorNode } from 'lexical';
|
|
10
10
|
export { $cloneWithProperties, $selectAll } from 'lexical';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -206,6 +206,44 @@ function getCSSFromStyleObject(styles) {
|
|
|
206
206
|
return css;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Gets the computed DOM styles of the element.
|
|
211
|
+
* @param node - The node to check the styles for.
|
|
212
|
+
* @returns the computed styles of the element or null if there is no DOM element or no default view for the document.
|
|
213
|
+
*/
|
|
214
|
+
function $getComputedStyleForElement(element) {
|
|
215
|
+
const editor = $getEditor();
|
|
216
|
+
const domElement = editor.getElementByKey(element.getKey());
|
|
217
|
+
if (domElement === null) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
const view = domElement.ownerDocument.defaultView;
|
|
221
|
+
if (view === null) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
return view.getComputedStyle(domElement);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Gets the computed DOM styles of the parent of the node.
|
|
229
|
+
* @param node - The node to check its parent's styles for.
|
|
230
|
+
* @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
|
|
231
|
+
*/
|
|
232
|
+
function $getComputedStyleForParent(node) {
|
|
233
|
+
const parent = $isRootNode(node) ? node : node.getParentOrThrow();
|
|
234
|
+
return $getComputedStyleForElement(parent);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Determines whether a node's parent is RTL.
|
|
239
|
+
* @param node - The node to check whether it is RTL.
|
|
240
|
+
* @returns whether the node is RTL.
|
|
241
|
+
*/
|
|
242
|
+
function $isParentRTL(node) {
|
|
243
|
+
const styles = $getComputedStyleForParent(node);
|
|
244
|
+
return styles !== null && styles.direction === 'rtl';
|
|
245
|
+
}
|
|
246
|
+
|
|
209
247
|
/**
|
|
210
248
|
* Generally used to append text content to HTML and JSON. Grabs the text content and "slices"
|
|
211
249
|
* it to be generated into the new TextNode.
|
|
@@ -805,19 +843,18 @@ function $isEditorVerticalOrientation(selection) {
|
|
|
805
843
|
const computedStyle = $getComputedStyle(selection);
|
|
806
844
|
return computedStyle !== null && computedStyle.writingMode === 'vertical-rl';
|
|
807
845
|
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Gets the computed DOM styles of the parent of the selection's anchor node.
|
|
849
|
+
* @param selection - The selection to check the styles for.
|
|
850
|
+
* @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
|
|
851
|
+
*/
|
|
808
852
|
function $getComputedStyle(selection) {
|
|
809
853
|
const anchorNode = selection.anchor.getNode();
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
const domElement = editor.getElementByKey(parent.getKey());
|
|
813
|
-
if (domElement === null) {
|
|
814
|
-
return null;
|
|
815
|
-
}
|
|
816
|
-
const view = domElement.ownerDocument.defaultView;
|
|
817
|
-
if (view === null) {
|
|
818
|
-
return null;
|
|
854
|
+
if ($isElementNode(anchorNode)) {
|
|
855
|
+
return $getComputedStyleForElement(anchorNode);
|
|
819
856
|
}
|
|
820
|
-
return
|
|
857
|
+
return $getComputedStyleForParent(anchorNode);
|
|
821
858
|
}
|
|
822
859
|
|
|
823
860
|
/**
|
|
@@ -985,4 +1022,4 @@ function $getAncestor(node, predicate) {
|
|
|
985
1022
|
/** @deprecated renamed to {@link $trimTextContentFromAnchor} by @lexical/eslint-plugin rules-of-lexical */
|
|
986
1023
|
const trimTextContentFromAnchor = $trimTextContentFromAnchor;
|
|
987
1024
|
|
|
988
|
-
export { $addNodeStyle, $copyBlockFormatIndent, $ensureForwardRangeSelection, $forEachSelectedTextNode, $getSelectionStyleValueForProperty, $isAtNodeEnd, $isParentElementRTL, $moveCaretSelection, $moveCharacter, $patchStyleText, $setBlocksType, $shouldOverrideDefaultCharacterSelection, $sliceSelectedTextNodeContent, $trimTextContentFromAnchor, $wrapNodes, createDOMRange, createRectsFromDOMRange, getCSSFromStyleObject, getStyleObjectFromCSS, trimTextContentFromAnchor };
|
|
1025
|
+
export { $addNodeStyle, $copyBlockFormatIndent, $ensureForwardRangeSelection, $forEachSelectedTextNode, $getComputedStyleForElement, $getComputedStyleForParent, $getSelectionStyleValueForProperty, $isAtNodeEnd, $isParentElementRTL, $isParentRTL, $moveCaretSelection, $moveCharacter, $patchStyleText, $setBlocksType, $shouldOverrideDefaultCharacterSelection, $sliceSelectedTextNodeContent, $trimTextContentFromAnchor, $wrapNodes, createDOMRange, createRectsFromDOMRange, getCSSFromStyleObject, getStyleObjectFromCSS, trimTextContentFromAnchor };
|
package/LexicalSelection.mjs
CHANGED
|
@@ -14,9 +14,12 @@ export const $cloneWithProperties = mod.$cloneWithProperties;
|
|
|
14
14
|
export const $copyBlockFormatIndent = mod.$copyBlockFormatIndent;
|
|
15
15
|
export const $ensureForwardRangeSelection = mod.$ensureForwardRangeSelection;
|
|
16
16
|
export const $forEachSelectedTextNode = mod.$forEachSelectedTextNode;
|
|
17
|
+
export const $getComputedStyleForElement = mod.$getComputedStyleForElement;
|
|
18
|
+
export const $getComputedStyleForParent = mod.$getComputedStyleForParent;
|
|
17
19
|
export const $getSelectionStyleValueForProperty = mod.$getSelectionStyleValueForProperty;
|
|
18
20
|
export const $isAtNodeEnd = mod.$isAtNodeEnd;
|
|
19
21
|
export const $isParentElementRTL = mod.$isParentElementRTL;
|
|
22
|
+
export const $isParentRTL = mod.$isParentRTL;
|
|
20
23
|
export const $moveCaretSelection = mod.$moveCaretSelection;
|
|
21
24
|
export const $moveCharacter = mod.$moveCharacter;
|
|
22
25
|
export const $patchStyleText = mod.$patchStyleText;
|
|
@@ -12,9 +12,12 @@ export const $cloneWithProperties = mod.$cloneWithProperties;
|
|
|
12
12
|
export const $copyBlockFormatIndent = mod.$copyBlockFormatIndent;
|
|
13
13
|
export const $ensureForwardRangeSelection = mod.$ensureForwardRangeSelection;
|
|
14
14
|
export const $forEachSelectedTextNode = mod.$forEachSelectedTextNode;
|
|
15
|
+
export const $getComputedStyleForElement = mod.$getComputedStyleForElement;
|
|
16
|
+
export const $getComputedStyleForParent = mod.$getComputedStyleForParent;
|
|
15
17
|
export const $getSelectionStyleValueForProperty = mod.$getSelectionStyleValueForProperty;
|
|
16
18
|
export const $isAtNodeEnd = mod.$isAtNodeEnd;
|
|
17
19
|
export const $isParentElementRTL = mod.$isParentElementRTL;
|
|
20
|
+
export const $isParentRTL = mod.$isParentRTL;
|
|
18
21
|
export const $moveCaretSelection = mod.$moveCaretSelection;
|
|
19
22
|
export const $moveCharacter = mod.$moveCharacter;
|
|
20
23
|
export const $patchStyleText = mod.$patchStyleText;
|
package/LexicalSelection.prod.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
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.`)}const n=new Map;function o(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild}return null}function s(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){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 l(e){let t=n.get(e);return void 0===t&&(t=r(e),n.set(e,t)),t}function i(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function c(t,n,o){let s=n.getNode(),r=o;if(e.$isElementNode(s)){const e=s.getDescendantByIndex(n.offset);null!==e&&(s=e)}for(;r>0&&null!==s;){if(e.$isElementNode(s)){const e=s.getLastDescendant();null!==e&&(s=e)}let o=s.getPreviousSibling(),l=0;if(null===o){let e=s.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){o=null;break}t=e.getPreviousSibling()}null!==e&&(l=e.isInline()?0:2,o=t)}let i=s.getTextContent();""===i&&e.$isElementNode(s)&&!s.isInline()&&(i="\n\n");const c=i.length;if(!e.$isTextNode(s)||r>=c){const t=s.getParent();s.remove(),null==t||0!==t.getChildrenSize()||e.$isRootNode(t)||t.remove(),r-=c+l,s=o}else{const o=s.getKey(),l=t.getEditorState().read((()=>{const t=e.$getNodeByKey(o);return e.$isTextNode(t)&&t.isSimpleText()?t.getTextContent():null})),f=c-r,a=i.slice(0,f);if(null!==l&&l!==i){const t=e.$getPreviousSelection();let n=s;if(s.isSimpleText())s.setTextContent(l);else{const t=e.$createTextNode(l);s.replace(t),n=t}if(e.$isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor.offset;n.select(e,e)}}else if(s.isSimpleText()){const e=n.key===o;let t=n.offset;t<r&&(t=c);const l=e?t-r:0,i=e?t:f;if(e&&0===l){const[e]=s.splitText(l,i);e.remove()}else{const[,e]=s.splitText(l,i);e.remove()}}else{const t=e.$createTextNode(a);s.replace(t)}r=0}}}function f(o,s){(e.$isRangeSelection(o)?o.isCollapsed():e.$isTextNode(o)||e.$isElementNode(o))||t(280);const r=l(e.$isRangeSelection(o)?o.style:e.$isTextNode(o)?o.getStyle():o.getTextStyle()),c=Object.entries(s).reduce(((e,[t,n])=>("function"==typeof n?e[t]=n(r[t],o):null===n?delete e[t]:e[t]=n,e)),{...r}),f=i(c);e.$isRangeSelection(o)||e.$isTextNode(o)?o.setStyle(f):o.setTextStyle(f),n.set(f,c)}function a(t){const n=e.$getSelection();if(!n)return;const o=new Map;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[s,l]=(r=n,o.get(r.getKey())||[0,r.getTextContentSize()]);if(l!==s)if(e.$isTokenOrSegmented(n)||0===s&&l===n.getTextContentSize())t(n);else{t(n.splitText(s,l)[0===s?0:1])}}var r;e.$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&d(n)}function d(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:s,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,s,r)}}function u(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function g(e){return e.getNode().isAttached()}function p(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,s,r,l=null){if(0===o.length)return;const i=o[0],c=new Map,f=[];let a=e.$isElementNode(i)?i:i.getParentOrThrow();a.isInline()&&(a=a.getParentOrThrow());let d=!1;for(;null!==a;){const t=a.getPreviousSibling();if(null!==t){a=t,d=!0;break}if(a=a.getParentOrThrow(),e.$isRootOrShadowRoot(a))break}const u=new Set;for(let t=0;t<s;t++){const n=o[t];e.$isElementNode(n)&&0===n.getChildrenSize()&&u.add(n.getKey())}const h=new Set;for(let n=0;n<s;n++){const s=o[n];let l=s.getParent();if(null!==l&&l.isInline()&&(l=l.getParent()),null!==l&&e.$isLeafNode(s)&&!h.has(s.getKey())){const t=l.getKey();if(void 0===c.get(t)){const n=r();n.setFormat(l.getFormatType()),n.setIndent(l.getIndent()),f.push(n),c.set(t,n),l.getChildren().forEach((t=>{n.append(t),h.add(t.getKey()),e.$isElementNode(t)&&t.getChildrenKeys().forEach((e=>h.add(e)))})),p(l)}}else if(u.has(s.getKey())){e.$isElementNode(s)||t(179);const n=r();n.setFormat(s.getFormatType()),n.setIndent(s.getIndent()),f.push(n),s.remove(!0)}}if(null!==l)for(let e=0;e<f.length;e++){const t=f[e];l.append(t)}let $=null;if(e.$isRootOrShadowRoot(a))if(d)if(null!==l)a.insertAfter(l);else for(let e=f.length-1;e>=0;e--){const t=f[e];a.insertAfter(t)}else{const t=a.getFirstChild();if(e.$isElementNode(t)&&(a=t),null===t)if(l)a.append(l);else for(let e=0;e<f.length;e++){const t=f[e];a.append(t),$=t}else if(null!==l)t.insertBefore(l);else for(let e=0;e<f.length;e++){const n=f[e];t.insertBefore(n),$=n}}else if(l)a.insertAfter(l);else for(let e=f.length-1;e>=0;e--){const t=f[e];a.insertAfter(t),$=t}const y=e.$getPreviousSelection();e.$isRangeSelection(y)&&g(y.anchor)&&g(y.focus)?e.$setSelection(y.clone()):null!==$?$.selectEnd():n.dirty=!0}function $(e){const t=y(e);return null!==t&&"vertical-rl"===t.writingMode}function y(t){const n=t.anchor.getNode(),o=e.$isRootNode(n)?n:n.getParentOrThrow(),s=e.$getEditor().getElementByKey(o.getKey());if(null===s)return null;const r=s.ownerDocument.defaultView;return null===r?null:r.getComputedStyle(s)}function S(e,t,n,o){e.modify(t?"extend":"move",n,o)}function m(e){const t=y(e);return null!==t&&"rtl"===t.direction}function N(e,t,n){const o=l(e.getStyle());return null!==o&&o[t]||n}function x(e,t){let n=e;for(;null!==n&&null!==n.getParent()&&!t(n);)n=n.getParentOrThrow();return t(n)?n:null}const T=c;exports.$cloneWithProperties=e.$cloneWithProperties,exports.$selectAll=e.$selectAll,exports.$addNodeStyle=function(e){const t=e.getStyle(),o=r(t);n.set(t,o)},exports.$copyBlockFormatIndent=u,exports.$ensureForwardRangeSelection=d,exports.$forEachSelectedTextNode=a,exports.$getSelectionStyleValueForProperty=function(t,n,o=""){let s=null;const r=t.getNodes(),i=t.anchor,c=t.focus,f=t.isBackward(),a=f?c.offset:i.offset,d=f?c.getNode():i.getNode();if(e.$isRangeSelection(t)&&t.isCollapsed()&&""!==t.style){const e=l(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t<r.length;t++){const l=r[t];if((0===t||0!==a||!l.is(d))&&e.$isTextNode(l)){const e=N(l,n,o);if(null===s)s=e;else if(s!==e){s="";break}}}return null===s?o:s},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=m,exports.$moveCaretSelection=S,exports.$moveCharacter=function(e,t,n){const o=m(e);let s;s=$(e)||o?!n:n,S(e,t,s,"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)}a((e=>{f(e,n)}))},exports.$setBlocksType=function(t,n,o=u){if(null===t)return;const s=t.getStartEndPoints(),r=new Map;let l=null;if(s){const[t,n]=s;l=e.$createRangeSelection(),l.anchor.set(t.key,t.offset,t.type),l.focus.set(n.key,n.offset,n.type);const o=x(t.getNode(),e.INTERNAL_$isBlock),i=x(n.getNode(),e.INTERNAL_$isBlock);e.$isElementNode(o)&&r.set(o.getKey(),o),e.$isElementNode(i)&&r.set(i.getKey(),i)}for(const n of t.getNodes())if(e.$isElementNode(n)&&e.INTERNAL_$isBlock(n))r.set(n.getKey(),n);else if(null===s){const t=x(n,e.INTERNAL_$isBlock);e.$isElementNode(t)&&r.set(t.getKey(),t)}for(const[e,t]of r){const s=n();o(t,s),t.replace(s,!0),l&&(e===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,l.anchor.type),e===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,l.focus.type))}l&&t.is(e.$getSelection())&&e.$setSelection(l)},exports.$shouldOverrideDefaultCharacterSelection=function(t,n){let o=$(t)?!n:n;m(t)&&(o=!o);const s=e.$caretFromPoint(t.focus,o?"previous":"next");if(e.$isExtendableTextPointCaret(s))return!1;for(const t of e.$extendCaretToRange(s)){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){const o=t.getStartEndPoints();if(n.isSelected(t)&&!e.$isTokenOrSegmented(n)&&null!==o){const[s,r]=o,l=t.isBackward(),i=s.getNode(),c=r.getNode(),f=n.is(i),a=n.is(c);if(f||a){const[o,s]=e.$getCharacterOffsets(t),r=i.is(c),f=n.is(l?c:i),a=n.is(l?i:c);let d,u=0;if(r)u=o>s?s:o,d=o>s?o:s;else if(f){u=l?s:o,d=void 0}else if(a){u=0,d=l?o:s}n.__text=n.__text.slice(u,d)}}return n},exports.$trimTextContentFromAnchor=c,exports.$wrapNodes=function(t,n,o=null){const s=t.getStartEndPoints(),r=s?s[0]:null,l=t.getNodes(),i=l.length;if(null!==r&&(0===i||1===i&&"element"===r.type&&0===r.getNode().getChildrenSize())){const e="text"===r.type?r.getNode().getParentOrThrow():r.getNode(),t=e.getChildren();let s=n();return s.setFormat(e.getFormatType()),s.setIndent(e.getIndent()),t.forEach((e=>s.append(e))),o&&(s=o.append(s)),void e.replace(s)}let c=null,f=[];for(let s=0;s<i;s++){const r=l[s];e.$isRootOrShadowRoot(r)?(h(t,f,f.length,n,o),f=[],c=r):null===c||null!==c&&e.$hasAncestor(r,c)?f.push(r):(h(t,f,f.length,n,o),f=[r])}h(t,f,f.length,n,o)},exports.createDOMRange=function(t,n,r,l,i){const c=n.getKey(),f=l.getKey(),a=document.createRange();let d=t.getElementByKey(c),u=t.getElementByKey(f),g=r,p=i;if(e.$isTextNode(n)&&(d=o(d)),e.$isTextNode(l)&&(u=o(u)),void 0===n||void 0===l||null===d||null===u)return null;"BR"===d.nodeName&&([d,g]=s(d)),"BR"===u.nodeName&&([u,p]=s(u));const h=d.firstChild;d===u&&null!=h&&"BR"===h.nodeName&&0===g&&0===p&&(p=1);try{a.setStart(d,g),a.setEnd(u,p)}catch(e){return null}return!a.collapsed||g===p&&c===f||(a.setStart(u,p),a.setEnd(d,g)),a},exports.createRectsFromDOMRange=function(e,t){const n=e.getRootElement();if(null===n)return[];const o=n.getBoundingClientRect(),s=getComputedStyle(n),r=parseFloat(s.paddingLeft)+parseFloat(s.paddingRight),l=Array.from(t.getClientRects());let i,c=l.length;l.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=l[e],n=i&&i.top<=t.top&&i.top+i.height>t.top&&i.left+i.width>t.left,s=t.width+r===o.width;n||s?(l.splice(e--,1),c--):i=t}return l},exports.getCSSFromStyleObject=i,exports.getStyleObjectFromCSS=l,exports.trimTextContentFromAnchor=T;
|
|
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.`)}const n=new Map;function o(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild}return null}function r(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return[t,Array.from(t.childNodes).indexOf(e)]}function s(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 l(e){let t=n.get(e);return void 0===t&&(t=s(e),n.set(e,t)),t}function i(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function c(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 f(t){return c(e.$isRootNode(t)?t:t.getParentOrThrow())}function d(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(),l=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&&(l=e.isInline()?0:2,o=t)}let i=r.getTextContent();""===i&&e.$isElementNode(r)&&!r.isInline()&&(i="\n\n");const c=i.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+l,r=o}else{const o=r.getKey(),l=t.getEditorState().read((()=>{const t=e.$getNodeByKey(o);return e.$isTextNode(t)&&t.isSimpleText()?t.getTextContent():null})),f=c-s,d=i.slice(0,f);if(null!==l&&l!==i){const t=e.$getPreviousSelection();let n=r;if(r.isSimpleText())r.setTextContent(l);else{const t=e.$createTextNode(l);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 l=e?t-s:0,i=e?t:f;if(e&&0===l){const[e]=r.splitText(l,i);e.remove()}else{const[,e]=r.splitText(l,i);e.remove()}}else{const t=e.$createTextNode(d);r.replace(t)}s=0}}}function a(o,r){(e.$isRangeSelection(o)?o.isCollapsed():e.$isTextNode(o)||e.$isElementNode(o))||t(280);const s=l(e.$isRangeSelection(o)?o.style:e.$isTextNode(o)?o.getStyle():o.getTextStyle()),c=Object.entries(r).reduce(((e,[t,n])=>("function"==typeof n?e[t]=n(s[t],o):null===n?delete e[t]:e[t]=n,e)),{...s}),f=i(c);e.$isRangeSelection(o)||e.$isTextNode(o)?o.setStyle(f):o.setTextStyle(f),n.set(f,c)}function u(t){const n=e.$getSelection();if(!n)return;const o=new Map;if(e.$isRangeSelection(n))for(const t of e.$caretRangeFromSelection(n).getTextSlices())t&&o.set(t.caret.origin.getKey(),t.getSliceIndices());const r=n.getNodes();for(const n of r){if(!e.$isTextNode(n)||!n.canHaveFormat())continue;const[r,l]=(s=n,o.get(s.getKey())||[0,s.getTextContentSize()]);if(l!==r)if(e.$isTokenOrSegmented(n)||0===r&&l===n.getTextContentSize())t(n);else{t(n.splitText(r,l)[0===r?0:1])}}var s;e.$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&g(n)}function g(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 p(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function $(e){return e.getNode().isAttached()}function h(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 y(n,o,r,s,l=null){if(0===o.length)return;const i=o[0],c=new Map,f=[];let d=e.$isElementNode(i)?i:i.getParentOrThrow();d.isInline()&&(d=d.getParentOrThrow());let a=!1;for(;null!==d;){const t=d.getPreviousSibling();if(null!==t){d=t,a=!0;break}if(d=d.getParentOrThrow(),e.$isRootOrShadowRoot(d))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 g=new Set;for(let n=0;n<r;n++){const r=o[n];let l=r.getParent();if(null!==l&&l.isInline()&&(l=l.getParent()),null!==l&&e.$isLeafNode(r)&&!g.has(r.getKey())){const t=l.getKey();if(void 0===c.get(t)){const n=s();n.setFormat(l.getFormatType()),n.setIndent(l.getIndent()),f.push(n),c.set(t,n),l.getChildren().forEach((t=>{n.append(t),g.add(t.getKey()),e.$isElementNode(t)&&t.getChildrenKeys().forEach((e=>g.add(e)))})),h(l)}}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!==l)for(let e=0;e<f.length;e++){const t=f[e];l.append(t)}let p=null;if(e.$isRootOrShadowRoot(d))if(a)if(null!==l)d.insertAfter(l);else for(let e=f.length-1;e>=0;e--){const t=f[e];d.insertAfter(t)}else{const t=d.getFirstChild();if(e.$isElementNode(t)&&(d=t),null===t)if(l)d.append(l);else for(let e=0;e<f.length;e++){const t=f[e];d.append(t),p=t}else if(null!==l)t.insertBefore(l);else for(let e=0;e<f.length;e++){const n=f[e];t.insertBefore(n),p=n}}else if(l)d.insertAfter(l);else for(let e=f.length-1;e>=0;e--){const t=f[e];d.insertAfter(t),p=t}const y=e.$getPreviousSelection();e.$isRangeSelection(y)&&$(y.anchor)&&$(y.focus)?e.$setSelection(y.clone()):null!==p?p.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)?c(n):f(n)}function x(e,t,n,o){e.modify(t?"extend":"move",n,o)}function N(e){const t=m(e);return null!==t&&"rtl"===t.direction}function T(e,t,n){const o=l(e.getStyle());return null!==o&&o[t]||n}function E(e,t){let n=e;for(;null!==n&&null!==n.getParent()&&!t(n);)n=n.getParentOrThrow();return t(n)?n:null}const R=d;exports.$cloneWithProperties=e.$cloneWithProperties,exports.$selectAll=e.$selectAll,exports.$addNodeStyle=function(e){const t=e.getStyle(),o=s(t);n.set(t,o)},exports.$copyBlockFormatIndent=p,exports.$ensureForwardRangeSelection=g,exports.$forEachSelectedTextNode=u,exports.$getComputedStyleForElement=c,exports.$getComputedStyleForParent=f,exports.$getSelectionStyleValueForProperty=function(t,n,o=""){let r=null;const s=t.getNodes(),i=t.anchor,c=t.focus,f=t.isBackward(),d=f?c.offset:i.offset,a=f?c.getNode():i.getNode();if(e.$isRangeSelection(t)&&t.isCollapsed()&&""!==t.style){const e=l(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t<s.length;t++){const l=s[t];if((0===t||0!==d||!l.is(a))&&e.$isTextNode(l)){const e=T(l,n,o);if(null===r)r=e;else if(r!==e){r="";break}}}return null===r?o:r},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=N,exports.$isParentRTL=function(e){const t=f(e);return null!==t&&"rtl"===t.direction},exports.$moveCaretSelection=x,exports.$moveCharacter=function(e,t,n){const o=N(e);let r;r=S(e)||o?!n:n,x(e,t,r,"character")},exports.$patchStyleText=function(t,n){if(e.$isRangeSelection(t)&&t.isCollapsed()){a(t,n);const o=t.anchor.getNode();e.$isElementNode(o)&&o.isEmpty()&&a(o,n)}u((e=>{a(e,n)}))},exports.$setBlocksType=function(t,n,o=p){if(null===t)return;const r=t.getStartEndPoints(),s=new Map;let l=null;if(r){const[t,n]=r;l=e.$createRangeSelection(),l.anchor.set(t.key,t.offset,t.type),l.focus.set(n.key,n.offset,n.type);const o=E(t.getNode(),e.INTERNAL_$isBlock),i=E(n.getNode(),e.INTERNAL_$isBlock);e.$isElementNode(o)&&s.set(o.getKey(),o),e.$isElementNode(i)&&s.set(i.getKey(),i)}for(const n of t.getNodes())if(e.$isElementNode(n)&&e.INTERNAL_$isBlock(n))s.set(n.getKey(),n);else if(null===r){const t=E(n,e.INTERNAL_$isBlock);e.$isElementNode(t)&&s.set(t.getKey(),t)}for(const[e,t]of s){const r=n();o(t,r),t.replace(r,!0),l&&(e===l.anchor.key&&l.anchor.set(r.getKey(),l.anchor.offset,l.anchor.type),e===l.focus.key&&l.focus.set(r.getKey(),l.focus.offset,l.focus.type))}l&&t.is(e.$getSelection())&&e.$setSelection(l)},exports.$shouldOverrideDefaultCharacterSelection=function(t,n){let o=S(t)?!n:n;N(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){const o=t.getStartEndPoints();if(n.isSelected(t)&&!e.$isTokenOrSegmented(n)&&null!==o){const[r,s]=o,l=t.isBackward(),i=r.getNode(),c=s.getNode(),f=n.is(i),d=n.is(c);if(f||d){const[o,r]=e.$getCharacterOffsets(t),s=i.is(c),f=n.is(l?c:i),d=n.is(l?i:c);let a,u=0;if(s)u=o>r?r:o,a=o>r?o:r;else if(f){u=l?r:o,a=void 0}else if(d){u=0,a=l?o:r}n.__text=n.__text.slice(u,a)}}return n},exports.$trimTextContentFromAnchor=d,exports.$wrapNodes=function(t,n,o=null){const r=t.getStartEndPoints(),s=r?r[0]:null,l=t.getNodes(),i=l.length;if(null!==s&&(0===i||1===i&&"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<i;r++){const s=l[r];e.$isRootOrShadowRoot(s)?(y(t,f,f.length,n,o),f=[],c=s):null===c||null!==c&&e.$hasAncestor(s,c)?f.push(s):(y(t,f,f.length,n,o),f=[s])}y(t,f,f.length,n,o)},exports.createDOMRange=function(t,n,s,l,i){const c=n.getKey(),f=l.getKey(),d=document.createRange();let a=t.getElementByKey(c),u=t.getElementByKey(f),g=s,p=i;if(e.$isTextNode(n)&&(a=o(a)),e.$isTextNode(l)&&(u=o(u)),void 0===n||void 0===l||null===a||null===u)return null;"BR"===a.nodeName&&([a,g]=r(a)),"BR"===u.nodeName&&([u,p]=r(u));const $=a.firstChild;a===u&&null!=$&&"BR"===$.nodeName&&0===g&&0===p&&(p=1);try{d.setStart(a,g),d.setEnd(u,p)}catch(e){return null}return!d.collapsed||g===p&&c===f||(d.setStart(u,p),d.setEnd(a,g)),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),l=Array.from(t.getClientRects());let i,c=l.length;l.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=l[e],n=i&&i.top<=t.top&&i.top+i.height>t.top&&i.left+i.width>t.left,r=t.width+s===o.width;n||r?(l.splice(e--,1),c--):i=t}return l},exports.getCSSFromStyleObject=i,exports.getStyleObjectFromCSS=l,exports.trimTextContentFromAnchor=R;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{$isTextNode as e,$isTokenOrSegmented as t,$getCharacterOffsets as n,$isElementNode as o,$isRootNode as l,$getNodeByKey as r,$getPreviousSelection as s,$createTextNode as i,$isRangeSelection as c,$getSelection as f,$caretRangeFromSelection as u,$createRangeSelection as g,INTERNAL_$isBlock as a,$setSelection as d,$isRootOrShadowRoot as p,$hasAncestor as h,$isLeafNode as y,$caretFromPoint as m,$isExtendableTextPointCaret as S,$extendCaretToRange as x,$isChildCaret as T,$isDecoratorNode as w,$getEditor as v}from"lexical";export{$cloneWithProperties,$selectAll}from"lexical";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(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]=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,o){const l=e.getStartEndPoints();if(o.isSelected(e)&&!t(o)&&null!==l){const[t,r]=l,s=e.isBackward(),i=t.getNode(),c=r.getNode(),f=o.is(i),u=o.is(c);if(f||u){const[t,l]=n(e),r=i.is(c),f=o.is(s?c:i),u=o.is(s?i:c);let g,a=0;if(r)a=t>l?l:t,g=t>l?t:l;else if(f){a=s?l:t,g=void 0}else if(u){a=0,g=s?t:l}o.__text=o.__text.slice(a,g)}}return o}function O(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return o(t)||N(177),e.offset===t.getChildrenSize()}function R(t,n,f){let u=n.getNode(),g=f;if(o(u)){const e=u.getDescendantByIndex(n.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()||l(e)||e.remove(),g-=p+a,u=f}else{const o=u.getKey(),l=t.getEditorState().read((()=>{const t=r(o);return e(t)&&t.isSimpleText()?t.getTextContent():null})),f=p-g,a=d.slice(0,f);if(null!==l&&l!==d){const e=s();let t=u;if(u.isSimpleText())u.setTextContent(l);else{const e=i(l);u.replace(e),t=e}if(c(e)&&e.isCollapsed()){const n=e.anchor.offset;t.select(n,n)}}else if(u.isSimpleText()){const e=n.key===o;let t=n.offset;t<g&&(t=p);const l=e?t-g:0,r=e?t:f;if(e&&0===l){const[e]=u.splitText(l,r);e.remove()}else{const[,e]=u.splitText(l,r);e.remove()}}else{const e=i(a);u.replace(e)}g=0}}}function z(e){const t=e.getStyle(),n=I(t);C.set(t,n)}function A(t,n){(c(t)?t.isCollapsed():e(t)||o(t))||N(280);const l=B(c(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=F(r);c(t)||e(t)?t.setStyle(s):t.setTextStyle(s),C.set(s,r)}function M(e,t){if(c(e)&&e.isCollapsed()){A(e,t);const n=e.anchor.getNode();o(n)&&n.isEmpty()&&A(n,t)}L((e=>{A(e,t)}))}function L(n){const o=f();if(!o)return;const l=new Map;if(c(o))for(const e of u(o).getTextSlices())e&&l.set(e.caret.origin.getKey(),e.getSliceIndices());const r=o.getNodes();for(const o of r){if(!e(o)||!o.canHaveFormat())continue;const[r,i]=(s=o,l.get(s.getKey())||[0,s.getTextContentSize()]);if(i!==r)if(t(o)||0===r&&i===o.getTextContentSize())n(o);else{n(o.splitText(r,i)[0===r?0:1])}}var s;c(o)&&"text"===o.anchor.type&&"text"===o.focus.type&&o.anchor.key===o.focus.key&&$(o)}function $(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 D(e,t,n=_){if(null===e)return;const l=e.getStartEndPoints(),r=new Map;let s=null;if(l){const[e,t]=l;s=g(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=ee(e.getNode(),a),i=ee(t.getNode(),a);o(n)&&r.set(n.getKey(),n),o(i)&&r.set(i.getKey(),i)}for(const t of e.getNodes())if(o(t)&&a(t))r.set(t.getKey(),t);else if(null===l){const e=ee(t,a);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(f())&&d(s)}function U(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 H(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];p(l)?(V(e,c,c.length,t,n),c=[],i=l):null===i||null!==i&&h(l,i)?c.push(l):(V(e,c,c.length,t,n),c=[l])}V(e,c,c.length,t,n)}function V(e,t,n,l,r=null){if(0===t.length)return;const i=t[0],f=new Map,u=[];let g=o(i)?i:i.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(),p(g))break}const h=new Set;for(let e=0;e<n;e++){const n=t[e];o(n)&&0===n.getChildrenSize()&&h.add(n.getKey())}const m=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&&y(n)&&!m.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),m.add(e.getKey()),o(e)&&e.getChildrenKeys().forEach((e=>m.add(e)))})),j(r)}}else if(h.has(n.getKey())){o(n)||N(179);const e=l();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),u.push(e),n.remove(!0)}}if(null!==r)for(let e=0;e<u.length;e++){const t=u[e];r.append(t)}let S=null;if(p(g))if(a)if(null!==r)g.insertAfter(r);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(r)g.append(r);else for(let e=0;e<u.length;e++){const t=u[e];g.append(t),S=t}else if(null!==r)e.insertBefore(r);else for(let t=0;t<u.length;t++){const n=u[t];e.insertBefore(n),S=n}}else if(r)g.insertAfter(r);else for(let e=u.length-1;e>=0;e--){const t=u[e];g.insertAfter(t),S=t}const x=s();c(x)&&U(x.anchor)&&U(x.focus)?d(x.clone()):null!==S?S.selectEnd():e.dirty=!0}function W(e){const t=X(e);return null!==t&&"vertical-rl"===t.writingMode}function X(e){const t=e.anchor.getNode(),n=l(t)?t:t.getParentOrThrow(),o=v().getElementByKey(n.getKey());if(null===o)return null;const r=o.ownerDocument.defaultView;return null===r?null:r.getComputedStyle(o)}function q(e,t){let n=W(e)?!t:t;J(e)&&(n=!n);const l=m(e.focus,n?"previous":"next");if(S(l))return!1;for(const e of x(l)){if(T(e))return!e.origin.isInline();if(!o(e.origin)){if(w(e.origin))return!0;break}}return!1}function G(e,t,n,o){e.modify(t?"extend":"move",n,o)}function J(e){const t=X(e);return null!==t&&"rtl"===t.direction}function Q(e,t,n){const o=J(e);let l;l=W(e)||o?!n:n,G(e,t,l,"character")}function Y(e,t,n){const o=B(e.getStyle());return null!==o&&o[t]||n}function Z(t,n,o=""){let l=null;const r=t.getNodes(),s=t.anchor,i=t.focus,f=t.isBackward(),u=f?i.offset:s.offset,g=f?i.getNode():s.getNode();if(c(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))&&e(s)){const e=Y(s,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l}function ee(e,t){let n=e;for(;null!==n&&null!==n.getParent()&&!t(n);)n=n.getParentOrThrow();return t(n)?n:null}const te=R;export{z as $addNodeStyle,_ as $copyBlockFormatIndent,$ as $ensureForwardRangeSelection,L as $forEachSelectedTextNode,Z as $getSelectionStyleValueForProperty,O as $isAtNodeEnd,J as $isParentElementRTL,G as $moveCaretSelection,Q as $moveCharacter,M as $patchStyleText,D as $setBlocksType,q as $shouldOverrideDefaultCharacterSelection,b as $sliceSelectedTextNodeContent,R as $trimTextContentFromAnchor,H as $wrapNodes,E as createDOMRange,k as createRectsFromDOMRange,F as getCSSFromStyleObject,B as getStyleObjectFromCSS,te as trimTextContentFromAnchor};
|
|
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,INTERNAL_$isBlock as d,$setSelection as p,$isRootOrShadowRoot as h,$hasAncestor as y,$isLeafNode as m,$caretFromPoint as S,$isExtendableTextPointCaret as x,$extendCaretToRange as T,$isChildCaret as w,$isDecoratorNode as v}from"lexical";export{$cloneWithProperties,$selectAll}from"lexical";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(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]=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=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 b(n(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)&&!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 A(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return r(t)||N(177),e.offset===t.getChildrenSize()}function M(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 L(e){const t=e.getStyle(),n=I(t);C.set(t,n)}function $(t,n){(f(t)?t.isCollapsed():e(t)||r(t))||N(280);const o=B(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=F(l);f(t)||e(t)?t.setStyle(s):t.setTextStyle(s),C.set(s,l)}function _(e,t){if(f(e)&&e.isCollapsed()){$(e,t);const n=e.anchor.getNode();r(n)&&n.isEmpty()&&$(n,t)}D((e=>{$(e,t)}))}function D(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&&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=a(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=oe(e.getNode(),d),i=oe(t.getNode(),d);r(n)&&l.set(n.getKey(),n),r(i)&&l.set(i.getKey(),i)}for(const t of e.getNodes())if(r(t)&&d(t))l.set(t.getKey(),t);else if(null===o){const e=oe(t,d);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())&&p(s)}function V(e){return e.getNode().isAttached()}function W(e){let t=e;for(;null!==t&&!h(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];h(l)?(q(e,c,c.length,t,n),c=[],i=l):null===i||null!==i&&y(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=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(),h(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 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&&m(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()),r(e)&&e.getChildrenKeys().forEach((e=>y.add(e)))})),W(l)}}else if(d.has(n.getKey())){r(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(h(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),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=i();f(x)&&V(x.anchor)&&V(x.focus)?p(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 r(t)?b(t):O(t)}function Q(e,t){let n=G(e)?!t:t;Z(e)&&(n=!n);const o=S(e.focus,n?"previous":"next");if(x(o))return!1;for(const e of T(o)){if(w(e))return!e.origin.isInline();if(!r(e.origin)){if(v(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(f(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))&&e(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;export{L as $addNodeStyle,j as $copyBlockFormatIndent,U as $ensureForwardRangeSelection,D as $forEachSelectedTextNode,b as $getComputedStyleForElement,O as $getComputedStyleForParent,ne as $getSelectionStyleValueForProperty,A as $isAtNodeEnd,Z as $isParentElementRTL,R as $isParentRTL,Y as $moveCaretSelection,ee as $moveCharacter,_ as $patchStyleText,H as $setBlocksType,Q as $shouldOverrideDefaultCharacterSelection,z as $sliceSelectedTextNodeContent,M as $trimTextContentFromAnchor,X as $wrapNodes,E as createDOMRange,k as createRectsFromDOMRange,F as getCSSFromStyleObject,B as getStyleObjectFromCSS,le as trimTextContentFromAnchor};
|
package/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { $trimTextContentFromAnchor } from './lexical-node';
|
|
9
9
|
export { $addNodeStyle, $ensureForwardRangeSelection, $forEachSelectedTextNode, $isAtNodeEnd, $patchStyleText, $sliceSelectedTextNodeContent, $trimTextContentFromAnchor, } from './lexical-node';
|
|
10
10
|
export { $copyBlockFormatIndent, $getSelectionStyleValueForProperty, $isParentElementRTL, $moveCaretSelection, $moveCharacter, $setBlocksType, $shouldOverrideDefaultCharacterSelection, $wrapNodes, } from './range-selection';
|
|
11
|
-
export { createDOMRange, createRectsFromDOMRange, getCSSFromStyleObject, getStyleObjectFromCSS, } from './utils';
|
|
11
|
+
export { $getComputedStyleForElement, $getComputedStyleForParent, $isParentRTL, createDOMRange, createRectsFromDOMRange, getCSSFromStyleObject, getStyleObjectFromCSS, } from './utils';
|
|
12
12
|
/** @deprecated renamed to {@link $trimTextContentFromAnchor} by @lexical/eslint-plugin rules-of-lexical */
|
|
13
13
|
export declare const trimTextContentFromAnchor: typeof $trimTextContentFromAnchor;
|
|
14
14
|
export {
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"selection"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "0.34.1-nightly.
|
|
12
|
+
"version": "0.34.1-nightly.20250901.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.34.1-nightly.
|
|
40
|
+
"lexical": "0.34.1-nightly.20250901.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { LexicalEditor, LexicalNode } from 'lexical';
|
|
8
|
+
import type { ElementNode, LexicalEditor, LexicalNode } from 'lexical';
|
|
9
9
|
/**
|
|
10
10
|
* Creates a selection range for the DOM.
|
|
11
11
|
* @param editor - The lexical editor.
|
|
@@ -41,3 +41,21 @@ export declare function getStyleObjectFromCSS(css: string): Record<string, strin
|
|
|
41
41
|
* @returns A string containing the CSS styles and their values.
|
|
42
42
|
*/
|
|
43
43
|
export declare function getCSSFromStyleObject(styles: Record<string, string>): string;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the computed DOM styles of the element.
|
|
46
|
+
* @param node - The node to check the styles for.
|
|
47
|
+
* @returns the computed styles of the element or null if there is no DOM element or no default view for the document.
|
|
48
|
+
*/
|
|
49
|
+
export declare function $getComputedStyleForElement(element: ElementNode): CSSStyleDeclaration | null;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the computed DOM styles of the parent of the node.
|
|
52
|
+
* @param node - The node to check its parent's styles for.
|
|
53
|
+
* @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
|
|
54
|
+
*/
|
|
55
|
+
export declare function $getComputedStyleForParent(node: LexicalNode): CSSStyleDeclaration | null;
|
|
56
|
+
/**
|
|
57
|
+
* Determines whether a node's parent is RTL.
|
|
58
|
+
* @param node - The node to check whether it is RTL.
|
|
59
|
+
* @returns whether the node is RTL.
|
|
60
|
+
*/
|
|
61
|
+
export declare function $isParentRTL(node: LexicalNode): boolean;
|