@lexical/selection 0.12.4 → 0.12.6
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 +17 -5
- package/LexicalSelection.js.flow +3 -3
- package/LexicalSelection.prod.js +24 -23
- package/README.md +1 -1
- package/lexical-node.d.ts +3 -3
- package/package.json +2 -2
- package/range-selection.d.ts +4 -4
package/LexicalSelection.dev.js
CHANGED
|
@@ -146,7 +146,9 @@ function getStyleObjectFromRawCSS(css) {
|
|
|
146
146
|
for (const style of styles) {
|
|
147
147
|
if (style !== '') {
|
|
148
148
|
const [key, value] = style.split(/:([^]+)/); // split on first colon
|
|
149
|
-
|
|
149
|
+
if (key && value) {
|
|
150
|
+
styleObject[key.trim()] = value.trim();
|
|
151
|
+
}
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
return styleObject;
|
|
@@ -238,7 +240,7 @@ function $cloneWithProperties(node) {
|
|
|
238
240
|
* @returns The updated TextNode.
|
|
239
241
|
*/
|
|
240
242
|
function $sliceSelectedTextNodeContent(selection, textNode) {
|
|
241
|
-
if (textNode.isSelected() && !textNode.isSegmented() && !textNode.isToken() &&
|
|
243
|
+
if (textNode.isSelected(selection) && !textNode.isSegmented() && !textNode.isToken() && lexical.$INTERNAL_isPointSelection(selection)) {
|
|
242
244
|
const anchorNode = selection.anchor.getNode();
|
|
243
245
|
const focusNode = selection.focus.getNode();
|
|
244
246
|
const isAnchor = textNode.is(anchorNode);
|
|
@@ -279,7 +281,11 @@ function $isAtNodeEnd(point) {
|
|
|
279
281
|
if (point.type === 'text') {
|
|
280
282
|
return point.offset === point.getNode().getTextContentSize();
|
|
281
283
|
}
|
|
282
|
-
|
|
284
|
+
const node = point.getNode();
|
|
285
|
+
if (!lexical.$isElementNode(node)) {
|
|
286
|
+
throw Error(`isAtNodeEnd: node must be a TextNode or ElementNode`);
|
|
287
|
+
}
|
|
288
|
+
return point.offset === node.getChildrenSize();
|
|
283
289
|
}
|
|
284
290
|
|
|
285
291
|
/**
|
|
@@ -430,7 +436,7 @@ function $patchStyle(target, patch) {
|
|
|
430
436
|
function $patchStyleText(selection, patch) {
|
|
431
437
|
const selectedNodes = selection.getNodes();
|
|
432
438
|
const selectedNodesLength = selectedNodes.length;
|
|
433
|
-
if (lexical
|
|
439
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
434
440
|
const cellSelection = lexical.$createRangeSelection();
|
|
435
441
|
const cellSelectionAnchor = cellSelection.anchor;
|
|
436
442
|
const cellSelectionFocus = cellSelection.focus;
|
|
@@ -448,7 +454,7 @@ function $patchStyleText(selection, patch) {
|
|
|
448
454
|
const lastIndex = selectedNodesLength - 1;
|
|
449
455
|
let firstNode = selectedNodes[0];
|
|
450
456
|
let lastNode = selectedNodes[lastIndex];
|
|
451
|
-
if (selection.isCollapsed()) {
|
|
457
|
+
if (selection.isCollapsed() && lexical.$isRangeSelection(selection)) {
|
|
452
458
|
$patchStyle(selection, patch);
|
|
453
459
|
return;
|
|
454
460
|
}
|
|
@@ -578,6 +584,9 @@ function $setBlocksType(selection, createElement) {
|
|
|
578
584
|
if (!INTERNAL_$isBlock(node)) {
|
|
579
585
|
continue;
|
|
580
586
|
}
|
|
587
|
+
if (!lexical.$isElementNode(node)) {
|
|
588
|
+
throw Error(`Expected block node to be an ElementNode`);
|
|
589
|
+
}
|
|
581
590
|
const targetElement = createElement();
|
|
582
591
|
targetElement.setFormat(node.getFormatType());
|
|
583
592
|
targetElement.setIndent(node.getIndent());
|
|
@@ -723,6 +732,9 @@ function $wrapNodesImpl(selection, nodes, nodesLength, createElement, wrappingEl
|
|
|
723
732
|
$removeParentEmptyElements(parent);
|
|
724
733
|
}
|
|
725
734
|
} else if (emptyElements.has(node.getKey())) {
|
|
735
|
+
if (!lexical.$isElementNode(node)) {
|
|
736
|
+
throw Error(`Expected node in emptyElements to be an ElementNode`);
|
|
737
|
+
}
|
|
726
738
|
const targetElement = createElement();
|
|
727
739
|
targetElement.setFormat(node.getFormatType());
|
|
728
740
|
targetElement.setIndent(node.getIndent());
|
package/LexicalSelection.js.flow
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type {
|
|
10
10
|
ElementNode,
|
|
11
|
-
GridSelection,
|
|
12
11
|
LexicalEditor,
|
|
13
12
|
LexicalNode,
|
|
14
13
|
NodeKey,
|
|
15
14
|
NodeSelection,
|
|
16
15
|
Point,
|
|
16
|
+
INTERNAL_PointSelection,
|
|
17
17
|
RangeSelection,
|
|
18
18
|
} from 'lexical';
|
|
19
19
|
declare export function $cloneWithProperties<T: LexicalNode>(node: T): T;
|
|
@@ -21,7 +21,7 @@ declare export function getStyleObjectFromCSS(css: string): {
|
|
|
21
21
|
[string]: string,
|
|
22
22
|
};
|
|
23
23
|
declare export function $patchStyleText(
|
|
24
|
-
selection:
|
|
24
|
+
selection: INTERNAL_PointSelection,
|
|
25
25
|
patch: {
|
|
26
26
|
[string]: string | null,
|
|
27
27
|
},
|
|
@@ -45,7 +45,7 @@ declare export function $moveCharacter(
|
|
|
45
45
|
): void;
|
|
46
46
|
declare export function $selectAll(selection: RangeSelection): void;
|
|
47
47
|
declare export function $wrapNodes(
|
|
48
|
-
selection:
|
|
48
|
+
selection: INTERNAL_PointSelection,
|
|
49
49
|
createElement: () => ElementNode,
|
|
50
50
|
wrappingElement?: ElementNode,
|
|
51
51
|
): void;
|
package/LexicalSelection.prod.js
CHANGED
|
@@ -4,27 +4,28 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';var k=require("lexical");let u=new Map;function v(a){for(;null!=a;){if(a.nodeType===Node.TEXT_NODE)return a;a=a.firstChild}return null}function w(a){let b=a.parentNode;if(null==b)throw Error("Should never happen");return[b,Array.from(b.childNodes).indexOf(a)]}function y(a){let b={};a=a.split(";");for(let d of a)if(""!==d){let [
|
|
8
|
-
function A(a){let b="";for(let d in a)d&&(b+=`${d}: ${a[d]};`);return b}function B(a,b){var d=z("getStyle"in a?a.getStyle():a.style);b=Object.entries(b).reduce((
|
|
9
|
-
function C(a,b){var d=a.getNodes(),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function E(a,b,d,
|
|
13
|
-
|
|
14
|
-
c)g.insertAfter(c);else for(c=
|
|
15
|
-
null!==b?b.selectEnd():a.dirty=!0}}function F(a,b,d,
|
|
16
|
-
|
|
17
|
-
exports.$
|
|
18
|
-
exports.$
|
|
19
|
-
exports.$
|
|
20
|
-
exports.$
|
|
21
|
-
exports.$
|
|
22
|
-
exports.$
|
|
23
|
-
exports.$
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
'use strict';var k=require("lexical");let u=new Map;function v(a){for(;null!=a;){if(a.nodeType===Node.TEXT_NODE)return a;a=a.firstChild}return null}function w(a){let b=a.parentNode;if(null==b)throw Error("Should never happen");return[b,Array.from(b.childNodes).indexOf(a)]}function y(a){let b={};a=a.split(";");for(let d of a)if(""!==d){let [e,c]=d.split(/:([^]+)/);e&&c&&(b[e.trim()]=c.trim())}return b}function z(a){let b=u.get(a);void 0===b&&(b=y(a),u.set(a,b));return b}
|
|
8
|
+
function A(a){let b="";for(let d in a)d&&(b+=`${d}: ${a[d]};`);return b}function B(a,b){var d=z("getStyle"in a?a.getStyle():a.style);b=Object.entries(b).reduce((e,[c,f])=>{null===f?delete e[c]:e[c]=f;return e},{...d});d=A(b);a.setStyle(d);u.set(d,b)}
|
|
9
|
+
function C(a,b){var d=a.getNodes(),e=d.length;if(k.$isRangeSelection(a)){--e;var c=d[0],f=d[e];if(a.isCollapsed()&&k.$isRangeSelection(a))B(a,b);else{var h=a.anchor,g=a.focus,l=c.getTextContent().length,n=g.offset,q=h.offset,p=h.isBefore(g),m=p?q:n;a=p?n:q;var r=p?h.type:g.type,t=p?g.type:h.type;g=p?g.key:h.key;k.$isTextNode(c)&&m===l&&(p=c.getNextSibling(),k.$isTextNode(p)&&(m=q=0,c=p));if(1===d.length)k.$isTextNode(c)&&(m="element"===r?0:q>n?n:q,a="element"===t?l:q>n?q:n,m!==a&&(0===m&&a===l?(B(c,
|
|
10
|
+
b),c.select(m,a)):(d=c.splitText(m,a),d=0===m?d[0]:d[1],B(d,b),d.select(0,a-m))));else for(k.$isTextNode(c)&&m<c.getTextContentSize()&&(0!==m&&(c=c.splitText(m)[1],m=0,h.set(c.getKey(),m,"text")),B(c,b)),k.$isTextNode(f)&&(m=f.getTextContent().length,f.__key!==g&&0!==a&&(a=m),a!==m&&([f]=f.splitText(a)),0!==a&&B(f,b)),a=1;a<e;a++)m=d[a],h=m.getKey(),k.$isTextNode(m)&&h!==c.getKey()&&h!==f.getKey()&&!m.isToken()&&B(m,b)}}else{c=k.$createRangeSelection();f=c.anchor;m=c.focus;for(h=0;h<e;h++)l=d[h],
|
|
11
|
+
k.DEPRECATED_$isGridCellNode(l)&&(f.set(l.getKey(),0,"element"),m.set(l.getKey(),l.getChildrenSize(),"element"),C(k.$normalizeSelection__EXPERIMENTAL(c),b));k.$setSelection(a)}}function D(a){for(;null!==a&&!k.$isRootOrShadowRoot(a);){let b=a.getLatest(),d=a.getParent();0===b.getChildrenSize()&&a.remove(!0);a=d}}
|
|
12
|
+
function E(a,b,d,e,c=null){if(0!==b.length){var f=b[0],h=new Map,g=[];f=k.$isElementNode(f)?f:f.getParentOrThrow();f.isInline()&&(f=f.getParentOrThrow());for(var l=!1;null!==f;){var n=f.getPreviousSibling();if(null!==n){f=n;l=!0;break}f=f.getParentOrThrow();if(k.$isRootOrShadowRoot(f))break}n=new Set;for(var q=0;q<d;q++){var p=b[q];k.$isElementNode(p)&&0===p.getChildrenSize()&&n.add(p.getKey())}var m=new Set;for(q=0;q<d;q++){p=b[q];var r=p.getParent();null!==r&&r.isInline()&&(r=r.getParent());if(null!==
|
|
13
|
+
r&&k.$isLeafNode(p)&&!m.has(p.getKey())){if(p=r.getKey(),void 0===h.get(p)){let t=e();t.setFormat(r.getFormatType());t.setIndent(r.getIndent());g.push(t);h.set(p,t);r.getChildren().forEach(x=>{t.append(x);m.add(x.getKey());k.$isElementNode(x)&&x.getChildrenKeys().forEach(I=>m.add(I))});D(r)}}else if(n.has(p.getKey())){if(!k.$isElementNode(p))throw Error("Expected node in emptyElements to be an ElementNode");r=e();r.setFormat(p.getFormatType());r.setIndent(p.getIndent());g.push(r);p.remove(!0)}}if(null!==
|
|
14
|
+
c)for(b=0;b<g.length;b++)c.append(g[b]);b=null;if(k.$isRootOrShadowRoot(f))if(l)if(null!==c)f.insertAfter(c);else for(c=g.length-1;0<=c;c--)f.insertAfter(g[c]);else if(l=f.getFirstChild(),k.$isElementNode(l)&&(f=l),null===l)if(c)f.append(c);else for(c=0;c<g.length;c++)l=g[c],f.append(l),b=l;else if(null!==c)l.insertBefore(c);else for(f=0;f<g.length;f++)c=g[f],l.insertBefore(c),b=c;else if(c)f.insertAfter(c);else for(c=g.length-1;0<=c;c--)l=g[c],f.insertAfter(l),b=l;g=k.$getPreviousSelection();k.$isRangeSelection(g)&&
|
|
15
|
+
g.anchor.getNode().isAttached()&&g.focus.getNode().isAttached()?k.$setSelection(g.clone()):null!==b?b.selectEnd():a.dirty=!0}}function F(a,b,d,e){a.modify(b?"extend":"move",d,e)}function G(a){a=a.anchor.getNode();return"rtl"===(k.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}
|
|
16
|
+
function H(a){if(k.$isDecoratorNode(a)&&!a.isInline())return!0;if(!k.$isElementNode(a)||k.$isRootOrShadowRoot(a))return!1;var b=a.getFirstChild();b=null===b||k.$isLineBreakNode(b)||k.$isTextNode(b)||b.isInline();return!a.isInline()&&!1!==a.canBeEmpty()&&b}exports.$addNodeStyle=function(a){a=a.getStyle();let b=y(a);u.set(a,b)};
|
|
17
|
+
exports.$cloneWithProperties=function(a){let b=a.constructor.clone(a);b.__parent=a.__parent;b.__next=a.__next;b.__prev=a.__prev;if(k.$isElementNode(a)&&k.$isElementNode(b))return b.__first=a.__first,b.__last=a.__last,b.__size=a.__size,b.__format=a.__format,b.__indent=a.__indent,b.__dir=a.__dir,b;k.$isTextNode(a)&&k.$isTextNode(b)&&(b.__format=a.__format,b.__style=a.__style,b.__mode=a.__mode,b.__detail=a.__detail);return b};
|
|
18
|
+
exports.$getSelectionStyleValueForProperty=function(a,b,d=""){let e=null,c=a.getNodes();var f=a.anchor,h=a.focus,g=a.isBackward();let l=g?h.offset:f.offset;f=g?h.getNode():f.getNode();if(a.isCollapsed()&&""!==a.style&&(a=z(a.style),null!==a&&b in a))return a[b];for(a=0;a<c.length;a++){var n=c[a];if((0===a||0!==l||!n.is(f))&&k.$isTextNode(n))if(h=b,g=d,n=n.getStyle(),n=z(n),h=null!==n?n[h]||g:g,null===e)e=h;else if(e!==h){e="";break}}return null===e?d:e};
|
|
19
|
+
exports.$isAtNodeEnd=function(a){if("text"===a.type)return a.offset===a.getNode().getTextContentSize();let b=a.getNode();if(!k.$isElementNode(b))throw Error("isAtNodeEnd: node must be a TextNode or ElementNode");return a.offset===b.getChildrenSize()};exports.$isParentElementRTL=G;exports.$moveCaretSelection=F;exports.$moveCharacter=function(a,b,d){let e=G(a);F(a,b,d?!e:e,"character")};exports.$patchStyleText=C;
|
|
20
|
+
exports.$selectAll=function(a){let b=a.anchor;a=a.focus;var d=b.getNode().getTopLevelElementOrThrow().getParentOrThrow();let e=d.getFirstDescendant();d=d.getLastDescendant();let c="element",f="element",h=0;k.$isTextNode(e)?c="text":k.$isElementNode(e)||null===e||(e=e.getParentOrThrow());k.$isTextNode(d)?(f="text",h=d.getTextContentSize()):k.$isElementNode(d)||null===d||(d=d.getParentOrThrow());e&&d&&(b.set(e.getKey(),0,c),a.set(d.getKey(),h,f))};
|
|
21
|
+
exports.$setBlocksType=function(a,b){if("root"===a.anchor.key){b=b();var d=k.$getRoot();(a=d.getFirstChild())?a.replace(b,!0):d.append(b)}else{d=a.getNodes();for(a=a.anchor.getNode();null!==a&&null!==a.getParent()&&!H(a);)a=a.getParentOrThrow();(a=H(a)?a:null)&&-1===d.indexOf(a)&&d.push(a);for(a=0;a<d.length;a++){let e=d[a];if(!H(e))continue;if(!k.$isElementNode(e))throw Error("Expected block node to be an ElementNode");let c=b();c.setFormat(e.getFormatType());c.setIndent(e.getIndent());e.replace(c,
|
|
22
|
+
!0)}}};exports.$shouldOverrideDefaultCharacterSelection=function(a,b){a=k.$getAdjacentNode(a.focus,b);return k.$isDecoratorNode(a)&&!a.isIsolated()||k.$isElementNode(a)&&!a.isInline()&&!a.canBeEmpty()};
|
|
23
|
+
exports.$sliceSelectedTextNodeContent=function(a,b){if(b.isSelected(a)&&!b.isSegmented()&&!b.isToken()&&k.$INTERNAL_isPointSelection(a)){var d=a.anchor.getNode(),e=a.focus.getNode(),c=b.is(d),f=b.is(e);if(c||f){c=a.isBackward();let [h,g]=a.getCharacterOffsets();a=d.is(e);f=b.is(c?e:d);e=b.is(c?d:e);d=0;let l=void 0;a?(d=h>g?g:h,l=h>g?h:g):f?(d=c?g:h,l=void 0):e&&(c=c?h:g,d=0,l=c);b.__text=b.__text.slice(d,l)}}return b};
|
|
24
|
+
exports.$wrapNodes=function(a,b,d=null){var e=a.getNodes();let c=e.length;var f=a.anchor;if(0===c||1===c&&"element"===f.type&&0===f.getNode().getChildrenSize()){a="text"===f.type?f.getNode().getParentOrThrow():f.getNode();e=a.getChildren();let g=b();g.setFormat(a.getFormatType());g.setIndent(a.getIndent());e.forEach(l=>g.append(l));d&&(g=d.append(g));a.replace(g)}else{f=null;var h=[];for(let g=0;g<c;g++){let l=e[g];k.$isRootOrShadowRoot(l)?(E(a,h,h.length,b,d),h=[],f=l):null===f||null!==f&&k.$hasAncestor(l,
|
|
25
|
+
f)?h.push(l):(E(a,h,h.length,b,d),h=[l])}E(a,h,h.length,b,d)}};
|
|
26
|
+
exports.createDOMRange=function(a,b,d,e,c){let f=b.getKey(),h=e.getKey(),g=document.createRange(),l=a.getElementByKey(f);a=a.getElementByKey(h);k.$isTextNode(b)&&(l=v(l));k.$isTextNode(e)&&(a=v(a));if(void 0===b||void 0===e||null===l||null===a)return null;"BR"===l.nodeName&&([l,d]=w(l));"BR"===a.nodeName&&([a,c]=w(a));b=l.firstChild;l===a&&null!=b&&"BR"===b.nodeName&&0===d&&0===c&&(c=1);try{g.setStart(l,d),g.setEnd(a,c)}catch(n){return null}!g.collapsed||d===c&&f===h||(g.setStart(a,c),g.setEnd(l,
|
|
27
|
+
d));return g};exports.createRectsFromDOMRange=function(a,b){var d=a.getRootElement();if(null===d)return[];a=d.getBoundingClientRect();d=getComputedStyle(d);d=parseFloat(d.paddingLeft)+parseFloat(d.paddingRight);b=Array.from(b.getClientRects());let e=b.length;b.sort((f,h)=>{let g=f.top-h.top;return 3>=Math.abs(g)?f.left-h.left:g});let c;for(let f=0;f<e;f++){let h=b[f],g=h.width+d===a.width;c&&c.top<=h.top&&c.top+c.height>h.top&&c.left+c.width>h.left||g?(b.splice(f--,1),e--):c=h}return b};
|
|
27
28
|
exports.getStyleObjectFromCSS=z;
|
|
28
|
-
exports.trimTextContentFromAnchor=function(a,b,d){let
|
|
29
|
-
(
|
|
30
|
-
c.select(d,d))):
|
|
29
|
+
exports.trimTextContentFromAnchor=function(a,b,d){let e=b.getNode();if(k.$isElementNode(e)){var c=e.getDescendantByIndex(b.offset);null!==c&&(e=c)}for(;0<d&&null!==e;){k.$isElementNode(e)&&(c=e.getLastDescendant(),null!==c&&(e=c));var f=e.getPreviousSibling(),h=0;if(null===f){c=e.getParentOrThrow();for(var g=c.getPreviousSibling();null===g;){c=c.getParent();if(null===c){f=null;break}g=c.getPreviousSibling()}null!==c&&(h=c.isInline()?0:2,f=g)}g=e.getTextContent();""===g&&k.$isElementNode(e)&&!e.isInline()&&
|
|
30
|
+
(g="\n\n");c=g.length;if(!k.$isTextNode(e)||d>=c)g=e.getParent(),e.remove(),null==g||0!==g.getChildrenSize()||k.$isRootNode(g)||g.remove(),d-=c+h,e=f;else{let l=e.getKey();h=a.getEditorState().read(()=>{const q=k.$getNodeByKey(l);return k.$isTextNode(q)&&q.isSimpleText()?q.getTextContent():null});f=c-d;let n=g.slice(0,f);null!==h&&h!==g?(d=k.$getPreviousSelection(),c=e,e.isSimpleText()?e.setTextContent(h):(c=k.$createTextNode(h),e.replace(c)),k.$isRangeSelection(d)&&d.isCollapsed()&&(d=d.anchor.offset,
|
|
31
|
+
c.select(d,d))):e.isSimpleText()?(h=b.key===l,g=b.offset,g<d&&(g=c),d=h?g-d:0,c=h?g:f,h&&0===d?([d]=e.splitText(d,c),d.remove()):([,d]=e.splitText(d,c),d.remove())):(d=k.$createTextNode(n),e.replace(d));d=0}}}
|
package/README.md
CHANGED
package/lexical-node.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 {
|
|
8
|
+
import { BaseSelection, INTERNAL_PointSelection, LexicalEditor, LexicalNode, Point, TextNode } from 'lexical';
|
|
9
9
|
/**
|
|
10
10
|
* Returns a copy of a node, but generates a new key for the copy.
|
|
11
11
|
* @param node - The node to be cloned.
|
|
@@ -19,7 +19,7 @@ export declare function $cloneWithProperties<T extends LexicalNode>(node: T): T;
|
|
|
19
19
|
* @param textNode - The TextNode to be edited.
|
|
20
20
|
* @returns The updated TextNode.
|
|
21
21
|
*/
|
|
22
|
-
export declare function $sliceSelectedTextNodeContent(selection:
|
|
22
|
+
export declare function $sliceSelectedTextNodeContent(selection: BaseSelection, textNode: TextNode): LexicalNode;
|
|
23
23
|
/**
|
|
24
24
|
* Determines if the current selection is at the end of the node.
|
|
25
25
|
* @param point - The point of the selection to test.
|
|
@@ -47,4 +47,4 @@ export declare function $addNodeStyle(node: TextNode): void;
|
|
|
47
47
|
* @param selection - The selected node(s) to update.
|
|
48
48
|
* @param patch - The patch to apply, which can include multiple styles. { CSSProperty: value }
|
|
49
49
|
*/
|
|
50
|
-
export declare function $patchStyleText(selection:
|
|
50
|
+
export declare function $patchStyleText(selection: INTERNAL_PointSelection, patch: Record<string, string | null>): void;
|
package/package.json
CHANGED
package/range-selection.d.ts
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { DecoratorNode, ElementNode,
|
|
8
|
+
import type { DecoratorNode, ElementNode, INTERNAL_PointSelection, LexicalNode, RangeSelection } from 'lexical';
|
|
9
9
|
/**
|
|
10
10
|
* Converts all nodes in the selection that are of one block type to another.
|
|
11
11
|
* @param selection - The selected blocks to be converted.
|
|
12
12
|
* @param createElement - The function that creates the node. eg. $createParagraphNode.
|
|
13
13
|
*/
|
|
14
|
-
export declare function $setBlocksType(selection:
|
|
14
|
+
export declare function $setBlocksType(selection: INTERNAL_PointSelection, createElement: () => ElementNode): void;
|
|
15
15
|
/**
|
|
16
16
|
* @deprecated
|
|
17
17
|
* Wraps all nodes in the selection into another node of the type returned by createElement.
|
|
@@ -19,7 +19,7 @@ export declare function $setBlocksType(selection: RangeSelection | GridSelection
|
|
|
19
19
|
* @param createElement - A function that creates the wrapping ElementNode. eg. $createParagraphNode.
|
|
20
20
|
* @param wrappingElement - An element to append the wrapped selection and its children to.
|
|
21
21
|
*/
|
|
22
|
-
export declare function $wrapNodes(selection:
|
|
22
|
+
export declare function $wrapNodes(selection: INTERNAL_PointSelection, createElement: () => ElementNode, wrappingElement?: null | ElementNode): void;
|
|
23
23
|
/**
|
|
24
24
|
* Wraps each node into a new ElementNode.
|
|
25
25
|
* @param selection - The selection of nodes to wrap.
|
|
@@ -29,7 +29,7 @@ export declare function $wrapNodes(selection: RangeSelection | GridSelection, cr
|
|
|
29
29
|
* @param wrappingElement - An element to wrap all the nodes into.
|
|
30
30
|
* @returns
|
|
31
31
|
*/
|
|
32
|
-
export declare function $wrapNodesImpl(selection:
|
|
32
|
+
export declare function $wrapNodesImpl(selection: INTERNAL_PointSelection, nodes: LexicalNode[], nodesLength: number, createElement: () => ElementNode, wrappingElement?: null | ElementNode): void;
|
|
33
33
|
/**
|
|
34
34
|
* Determines if the default character selection should be overridden. Used with DecoratorNodes
|
|
35
35
|
* @param selection - The selection whose default character selection may need to be overridden.
|