@lexical/selection 0.5.0 → 0.5.1-next.1
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 +567 -502
- package/LexicalSelection.prod.js +24 -24
- package/constants.d.ts +8 -0
- package/grid-selection.d.ts +10 -0
- package/index.d.ts +6 -32
- package/lexical-node.d.ts +19 -0
- package/node-selection.d.ts +10 -0
- package/package.json +2 -2
- package/range-selection.d.ts +28 -0
- package/utils.d.ts +13 -0
package/LexicalSelection.prod.js
CHANGED
|
@@ -4,28 +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 l=require("lexical");let
|
|
8
|
-
function
|
|
9
|
-
h.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.$getSelectionStyleValueForProperty=function(a,b,c=""){let g=null,d=a.getNodes();var
|
|
19
|
-
exports.$isParentElementRTL=
|
|
20
|
-
exports.$patchStyleText=function(a,b){var c=a.getNodes();let g=c.length-1,d=c[0],
|
|
21
|
-
d.splitText(h)[1]),
|
|
22
|
-
exports.$selectAll=function(a){let b=a.anchor;a=a.focus;var c=b.getNode().getTopLevelElementOrThrow().getParentOrThrow();let g=c.getFirstDescendant();c=c.getLastDescendant();let d="element",
|
|
7
|
+
'use strict';var l=require("lexical");let t=new Map;function u(a){return{nodeMap:a.getNodes().map(b=>{const c=b.getKey();b=v(b);return[c,b]}),range:[a.gridKey]}}function w(a){for(;null!=a;){if(a.nodeType===Node.TEXT_NODE)return a;a=a.firstChild}return null}function y(a){let b=a.parentNode;if(null==b)throw Error("Should never happen");return[b,Array.from(b.childNodes).indexOf(a)]}
|
|
8
|
+
function z(a){let b={};a=a.split(";");for(let c of a)if(""!==c){let [g,d]=c.split(/:([^]+)/);b[g.trim()]=d.trim()}return b}function A(a){let b=t.get(a);void 0===b&&(b=z(a),t.set(a,b));return b}function B(a){for(;null!==a&&!l.$isRootOrShadowRoot(a);){let b=a.getLatest(),c=a.getParent();0===b.__children.length&&a.remove(!0);a=c}}
|
|
9
|
+
function D(a,b,c,g,d=null){if(0!==b.length){var e=b[0],h=new Map,f=[];e=l.$isElementNode(e)?e:e.getParentOrThrow();e.isInline()&&(e=e.getParentOrThrow());for(var k=!1;null!==e;){var m=e.getPreviousSibling();if(null!==m){e=m;k=!0;break}e=e.getParentOrThrow();if(l.$isRootOrShadowRoot(e))break}m=new Set;for(var p=0;p<c;p++){var n=b[p];l.$isElementNode(n)&&0===n.getChildrenSize()&&m.add(n.getKey())}var x=new Set;for(p=0;p<c;p++){n=b[p];var q=n.getParent();null!==q&&q.isInline()&&(q=q.getParent());if(null!==
|
|
10
|
+
q&&l.$isLeafNode(n)&&!x.has(n.getKey())){if(n=q.getKey(),void 0===h.get(n)){let r=g();r.setFormat(q.getFormatType());r.setIndent(q.getIndent());f.push(r);h.set(n,r);q.getChildren().forEach(C=>{r.append(C);x.add(C.getKey())});B(q)}}else m.has(n.getKey())&&(q=g(),q.setFormat(n.getFormatType()),q.setIndent(n.getIndent()),f.push(q),n.remove(!0))}if(null!==d)for(b=0;b<f.length;b++)d.append(f[b]);if(l.$isRootOrShadowRoot(e))if(k)if(null!==d)e.insertAfter(d);else for(d=f.length-1;0<=d;d--)e.insertAfter(f[d]);
|
|
11
|
+
else if(b=e.getFirstChild(),l.$isElementNode(b)&&(e=b),null===b)if(d)e.append(d);else for(d=0;d<f.length;d++)e.append(f[d]);else if(null!==d)b.insertBefore(d);else for(e=0;e<f.length;e++)b.insertBefore(f[e]);else if(d)e.insertAfter(d);else for(d=f.length-1;0<=d;d--)e.insertAfter(f[d]);f=l.$getPreviousSelection();l.$isRangeSelection(f)&&f.anchor.getNode().isAttached()&&f.focus.getNode().isAttached()?l.$setSelection(f.clone()):a.dirty=!0}}function E(a,b,c,g){a.modify(b?"extend":"move",c,g)}
|
|
12
|
+
function F(a){a=a.anchor.getNode();return"rtl"===(l.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}
|
|
13
|
+
function G(a,b,c,g,d,e){for(var h=b;null!==a;){for(b=a.getParent();null!==b&&b.excludeFromCopy("clone");)b=b.getParent();if(null===b)break;if(!l.$isElementNode(a)||!a.excludeFromCopy("clone")){let f=a.getKey(),k=e.get(f),m=void 0===k;m&&(k=v(a),e.set(f,k));!l.$isTextNode(k)||k.isSegmented()||k.isToken()?l.$isElementNode(k)&&(k.__children=k.__children.slice(g?h:0,g?void 0:(h||0)+1)):k.__text=k.__text.slice(g?h:0,g?c:h);if(l.$isRootNode(b)){m&&d.push(f);break}}h=e.get(b.getKey());h=l.$isElementNode(h)?
|
|
14
|
+
h.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=b}}function v(a){a=a.getLatest();let b=a.constructor.clone(a);b.__parent=a.__parent;if(l.$isElementNode(a)&&l.$isElementNode(b))return b.__children=Array.from(a.__children),b.__format=a.__format,b.__indent=a.__indent,b.__dir=a.__dir,b;l.$isTextNode(a)&&l.$isTextNode(b)&&(b.__format=a.__format,b.__style=a.__style,b.__mode=a.__mode,b.__detail=a.__detail);return b}
|
|
15
|
+
function H(a,b){var c=A(a.getStyle());b=c?{...c,...b}:b;c="";for(g in b)g&&(c+=`${g}: ${b[g]};`);var g=c;a.setStyle(g);t.set(g,b)}exports.$addNodeStyle=function(a){a=a.getStyle();let b=z(a);t.set(a,b)};
|
|
16
|
+
exports.$cloneContents=function(a){var b={nodeMap:[],range:[]};if(l.$isRangeSelection(a)){{var c=a.anchor,g=a.focus;let [m,p]=a.getCharacterOffsets();b=a.getNodes();if(0===b.length)b={nodeMap:[],range:[]};else{a=b.length;var d=b[0],e=d.getParent();if(null!==e&&(!e.canBeEmpty()||l.$isRootNode(e))){var h=e.__children;if(h.length===a){var f=!0;for(var k=0;k<h.length;k++)if(h[k]!==b[k].__key){f=!1;break}f&&(a++,b.push(e))}}e=b[a-1];c=c.isBefore(g);g=new Map;h=[];f=l.$isTextNode(d)&&1===a;G(d,c?m:p,f?
|
|
17
|
+
c?p:m:void 0,!0,h,g);for(d=0;d<a;d++){k=b[d];let n=k.getKey();if(!(g.has(n)||l.$isElementNode(k)&&k.excludeFromCopy("clone"))){let x=v(k);l.$isRootNode(k.getParent())&&h.push(k.getKey());"root"!==n&&g.set(n,x)}}G(e,f?void 0:c?p:m,void 0,!1,h,g);b={nodeMap:Array.from(g.entries()),range:h}}}}else if(l.DEPRECATED_$isGridSelection(a))b=u(a);else if(l.$isNodeSelection(a))throw Error("Minified Lexical error #1; visit https://lexical.dev/docs/error?code=1 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");
|
|
18
|
+
return b};exports.$cloneWithProperties=v;exports.$getSelectionStyleValueForProperty=function(a,b,c=""){let g=null,d=a.getNodes();var e=a.anchor,h=a.focus,f=a.isBackward();a=f?h.offset:e.offset;e=f?h.getNode():e.getNode();for(h=0;h<d.length;h++){var k=d[h];if((0===h||0!==a||!k.is(e))&&l.$isTextNode(k)){f=b;var m=c;k=k.getStyle();k=A(k);f=null!==k?k[f]||m:m;if(null===g)g=f;else if(g!==f){g="";break}}}return null===g?c:g};
|
|
19
|
+
exports.$isAtNodeEnd=function(a){return"text"===a.type?a.offset===a.getNode().getTextContentSize():a.offset===a.getNode().getChildrenSize()};exports.$isParentElementRTL=F;exports.$moveCaretSelection=E;exports.$moveCharacter=function(a,b,c){let g=F(a);E(a,b,c?!g:g,"character")};
|
|
20
|
+
exports.$patchStyleText=function(a,b){var c=a.getNodes();let g=c.length-1,d=c[0],e=c[g];if(!a.isCollapsed()){var h=a.anchor,f=a.focus;a=d.getTextContent().length;var k=f.offset,m=h.offset;h=(f=h.isBefore(f))?m:k;f=f?k:m;if(h===d.getTextContentSize()){let p=d.getNextSibling();l.$isTextNode(p)&&(h=m=0,d=p)}if(d.is(e))l.$isTextNode(d)&&(h=m>k?k:m,f=m>k?m:k,h!==f&&(0===h&&f===a?(H(d,b),d.select(h,f)):(c=d.splitText(h,f),c=0===h?c[0]:c[1],H(c,b),c.select(0,f-h))));else for(l.$isTextNode(d)&&h<d.getTextContentSize()&&
|
|
21
|
+
(0!==h&&(d=d.splitText(h)[1]),H(d,b)),l.$isTextNode(e)&&(a=e.getTextContent().length,f!==a&&([e]=e.splitText(f)),0!==f&&H(e,b)),a=1;a<g;a++)k=c[a],m=k.getKey(),l.$isTextNode(k)&&m!==d.getKey()&&m!==e.getKey()&&!k.isToken()&&H(k,b)}};
|
|
22
|
+
exports.$selectAll=function(a){let b=a.anchor;a=a.focus;var c=b.getNode().getTopLevelElementOrThrow().getParentOrThrow();let g=c.getFirstDescendant();c=c.getLastDescendant();let d="element",e="element",h=0;l.$isTextNode(g)?d="text":l.$isElementNode(g)||null===g||(g=g.getParentOrThrow());l.$isTextNode(c)?(e="text",h=c.getTextContentSize()):l.$isElementNode(c)||null===c||(c=c.getParentOrThrow());g&&c&&(b.set(g.getKey(),0,d),a.set(c.getKey(),h,e))};
|
|
23
23
|
exports.$shouldOverrideDefaultCharacterSelection=function(a,b){a=l.$getDecoratorNode(a.focus,b);return l.$isDecoratorNode(a)&&!a.isIsolated()};
|
|
24
|
-
exports.$sliceSelectedTextNodeContent=function(a,b){if(b.isSelected()&&!b.isSegmented()&&!b.isToken()&&(l.$isRangeSelection(a)||l.DEPRECATED_$isGridSelection(a))){var c=a.anchor.getNode(),g=a.focus.getNode(),d=b.is(c),
|
|
25
|
-
exports.$wrapNodes=function(a,b,c=null){var g=a.getNodes();let d=g.length;var
|
|
26
|
-
|
|
27
|
-
exports.createDOMRange=function(a,b,c,g,d){let
|
|
28
|
-
c));return
|
|
29
|
-
exports.trimTextContentFromAnchor=function(a,b,c){let g=b.getNode();if(l.$isElementNode(g)){var d=g.getDescendantByIndex(b.offset);null!==d&&(g=d)}for(;0<c&&null!==g;){var
|
|
30
|
-
d=k.length;
|
|
31
|
-
(
|
|
24
|
+
exports.$sliceSelectedTextNodeContent=function(a,b){if(b.isSelected()&&!b.isSegmented()&&!b.isToken()&&(l.$isRangeSelection(a)||l.DEPRECATED_$isGridSelection(a))){var c=a.anchor.getNode(),g=a.focus.getNode(),d=b.is(c),e=b.is(g);if(d||e){d=a.isBackward();let [h,f]=a.getCharacterOffsets();a=c.is(g);e=b.is(d?g:c);g=b.is(d?c:g);c=0;let k=void 0;a?(c=h>f?f:h,k=h>f?h:f):e?(c=d?f:h,k=void 0):g&&(d=d?h:f,c=0,k=d);b.__text=b.__text.slice(c,k)}}return b};
|
|
25
|
+
exports.$wrapNodes=function(a,b,c=null){var g=a.getNodes();let d=g.length;var e=a.anchor;if(0===d||1===d&&"element"===e.type&&0===e.getNode().getChildrenSize()){a="text"===e.type?e.getNode().getParentOrThrow():e.getNode();g=a.getChildren();let f=b();f.setFormat(a.getFormatType());f.setIndent(a.getIndent());g.forEach(k=>f.append(k));c&&(f=c.append(f));a.replace(f)}else{e=null;var h=[];for(let f=0;f<d;f++){let k=g[f];l.$isRootOrShadowRoot(k)?(D(a,h,h.length,b,c),h=[],e=k):null===e||null!==e&&l.$hasAncestor(k,
|
|
26
|
+
e)?h.push(k):(D(a,h,h.length,b,c),h=[k])}D(a,h,h.length,b,c)}};exports.$wrapNodesImpl=D;
|
|
27
|
+
exports.createDOMRange=function(a,b,c,g,d){let e=b.getKey(),h=g.getKey(),f=document.createRange(),k=a.getElementByKey(e);a=a.getElementByKey(h);l.$isTextNode(b)&&(k=w(k));l.$isTextNode(g)&&(a=w(a));if(void 0===b||void 0===g||null===k||null===a)return null;"BR"===k.nodeName&&([k,c]=y(k));"BR"===a.nodeName&&([a,d]=y(a));b=k.firstChild;k===a&&null!=b&&"BR"===b.nodeName&&0===c&&0===d&&(d=1);try{f.setStart(k,c),f.setEnd(a,d)}catch(m){return null}!f.collapsed||c===d&&e===h||(f.setStart(a,d),f.setEnd(k,
|
|
28
|
+
c));return f};exports.createRectsFromDOMRange=function(a,b){var c=a.getRootElement();if(null===c)return[];a=c.getBoundingClientRect();c=getComputedStyle(c);c=parseFloat(c.paddingLeft)+parseFloat(c.paddingRight);b=Array.from(b.getClientRects());let g=b.length,d;for(let e=0;e<g;e++){let h=b[e],f=h.width+c===a.width;d&&d.top===h.top&&d.left===h.left&&d.width===h.width&&d.height===h.height||f?(b.splice(e--,1),g--):d=h}return b};exports.getStyleObjectFromCSS=A;
|
|
29
|
+
exports.trimTextContentFromAnchor=function(a,b,c){let g=b.getNode();if(l.$isElementNode(g)){var d=g.getDescendantByIndex(b.offset);null!==d&&(g=d)}for(;0<c&&null!==g;){var e=g.getPreviousSibling(),h=0;if(null===e){d=g.getParentOrThrow();for(var f=d.getPreviousSibling();null===f;){d=d.getParent();if(null===d){e=null;break}f=d.getPreviousSibling()}null!==d&&(h=d.isInline()?0:2,e=l.$isElementNode(f)?f.getLastDescendant():f)}let k=g.getTextContent();""===k&&l.$isElementNode(g)&&!g.isInline()&&(k="\n\n");
|
|
30
|
+
d=k.length;f=d-c;let m=k.slice(0,f);if(!l.$isTextNode(g)||c>=d)f=g.getParent(),g.remove(),null!=f&&0===f.getChildrenSize()&&f.remove(),c-=d+h,g=e;else{let p=g.getKey();e=a.getEditorState().read(()=>{const n=l.$getNodeByKey(p);return l.$isTextNode(n)&&n.isSimpleText()?n.getTextContent():null});null!==e&&e!==k?(c=l.$getPreviousSelection(),d=g,g.isSimpleText()?g.setTextContent(e):(d=l.$createTextNode(e),g.replace(d)),l.$isRangeSelection(c)&&c.isCollapsed()&&(c=c.anchor.offset,d.select(c,c))):g.isSimpleText()?
|
|
31
|
+
(e=b.key===p,h=b.offset,h<c&&(h=d),c=e?h-c:0,d=e?h:f,e&&0===c?([c]=g.splitText(c,d),c.remove()):([,c]=g.splitText(c,d),c.remove())):(c=l.$createTextNode(m),g.replace(c));c=0}}}
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare const CSS_TO_STYLES: Map<string, Record<string, string>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { ICloneSelectionContent } from './lexical-node';
|
|
9
|
+
import type { GridSelection } from 'lexical';
|
|
10
|
+
export declare function $cloneGridSelectionContent(selection: GridSelection): ICloneSelectionContent;
|
package/index.d.ts
CHANGED
|
@@ -6,35 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
export declare function getStyleObjectFromCSS(css: string): Record<string, string>;
|
|
16
|
-
export declare function $addNodeStyle(node: TextNode): void;
|
|
17
|
-
export declare function $patchStyleText(selection: RangeSelection | GridSelection, patch: Record<string, string>): void;
|
|
18
|
-
export declare function $getSelectionStyleValueForProperty(selection: RangeSelection, styleProperty: string, defaultValue?: string): string;
|
|
19
|
-
export declare function $moveCaretSelection(selection: RangeSelection, isHoldingShift: boolean, isBackward: boolean, granularity: 'character' | 'word' | 'lineboundary'): void;
|
|
20
|
-
export declare function $isParentElementRTL(selection: RangeSelection): boolean;
|
|
21
|
-
export declare function $moveCharacter(selection: RangeSelection, isHoldingShift: boolean, isBackward: boolean): void;
|
|
22
|
-
export declare function $selectAll(selection: RangeSelection): void;
|
|
23
|
-
/**
|
|
24
|
-
* Attempts to wrap all nodes in the Selection in ElementNodes returned from createElement.
|
|
25
|
-
* If wrappingElement is provided, all of the wrapped leaves are appended to the wrappingElement.
|
|
26
|
-
* It attempts to append the resulting sub-tree to the nearest safe insertion target.
|
|
27
|
-
*
|
|
28
|
-
* @param selection
|
|
29
|
-
* @param createElement
|
|
30
|
-
* @param wrappingElement
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export declare function $wrapNodes(selection: RangeSelection, createElement: () => ElementNode, wrappingElement?: null | ElementNode): void;
|
|
34
|
-
export declare function $wrapNodesImpl(selection: RangeSelection, nodes: LexicalNode[], nodesLength: number, createElement: () => ElementNode, wrappingElement?: null | ElementNode): void;
|
|
35
|
-
export declare function $isAtNodeEnd(point: Point): boolean;
|
|
36
|
-
export declare function $shouldOverrideDefaultCharacterSelection(selection: RangeSelection, isBackward: boolean): boolean;
|
|
37
|
-
export declare function createDOMRange(editor: LexicalEditor, anchorNode: LexicalNode, _anchorOffset: number, focusNode: LexicalNode, _focusOffset: number): Range | null;
|
|
38
|
-
export declare function createRectsFromDOMRange(editor: LexicalEditor, range: Range): Array<ClientRect>;
|
|
39
|
-
export declare function trimTextContentFromAnchor(editor: LexicalEditor, anchor: Point, delCount: number): void;
|
|
40
|
-
export declare function $sliceSelectedTextNodeContent(selection: RangeSelection | GridSelection | NodeSelection, textNode: TextNode): LexicalNode;
|
|
9
|
+
import { $addNodeStyle, $cloneContents, $cloneWithProperties, $isAtNodeEnd, $patchStyleText, $sliceSelectedTextNodeContent, trimTextContentFromAnchor } from './lexical-node';
|
|
10
|
+
import { $getSelectionStyleValueForProperty, $isParentElementRTL, $moveCaretSelection, $moveCharacter, $selectAll, $shouldOverrideDefaultCharacterSelection, $wrapNodes, $wrapNodesImpl } from './range-selection';
|
|
11
|
+
import { createDOMRange, createRectsFromDOMRange, getStyleObjectFromCSS } from './utils';
|
|
12
|
+
export { $addNodeStyle, $cloneContents, $cloneWithProperties, $isAtNodeEnd, $patchStyleText, $sliceSelectedTextNodeContent, trimTextContentFromAnchor, };
|
|
13
|
+
export { $getSelectionStyleValueForProperty, $isParentElementRTL, $moveCaretSelection, $moveCharacter, $selectAll, $shouldOverrideDefaultCharacterSelection, $wrapNodes, $wrapNodesImpl, };
|
|
14
|
+
export { createDOMRange, createRectsFromDOMRange, getStyleObjectFromCSS };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { GridSelection, LexicalEditor, LexicalNode, NodeKey, NodeSelection, Point, RangeSelection, TextNode } from 'lexical';
|
|
9
|
+
export declare function $cloneWithProperties<T extends LexicalNode>(node: T): T;
|
|
10
|
+
export declare function $sliceSelectedTextNodeContent(selection: RangeSelection | GridSelection | NodeSelection, textNode: TextNode): LexicalNode;
|
|
11
|
+
export declare function $isAtNodeEnd(point: Point): boolean;
|
|
12
|
+
export declare function trimTextContentFromAnchor(editor: LexicalEditor, anchor: Point, delCount: number): void;
|
|
13
|
+
export interface ICloneSelectionContent {
|
|
14
|
+
nodeMap: Array<[NodeKey, LexicalNode]>;
|
|
15
|
+
range: Array<NodeKey>;
|
|
16
|
+
}
|
|
17
|
+
export declare function $cloneContents(selection: RangeSelection | NodeSelection | GridSelection): ICloneSelectionContent;
|
|
18
|
+
export declare function $addNodeStyle(node: TextNode): void;
|
|
19
|
+
export declare function $patchStyleText(selection: RangeSelection | GridSelection, patch: Record<string, string>): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { ICloneSelectionContent } from './lexical-node';
|
|
9
|
+
import type { NodeSelection } from 'lexical';
|
|
10
|
+
export declare function $cloneNodeSelectionContent(selection: NodeSelection): ICloneSelectionContent;
|
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { ICloneSelectionContent } from './lexical-node';
|
|
9
|
+
import type { ElementNode, LexicalNode, RangeSelection } from 'lexical';
|
|
10
|
+
/**
|
|
11
|
+
* Attempts to wrap all nodes in the Selection in ElementNodes returned from createElement.
|
|
12
|
+
* If wrappingElement is provided, all of the wrapped leaves are appended to the wrappingElement.
|
|
13
|
+
* It attempts to append the resulting sub-tree to the nearest safe insertion target.
|
|
14
|
+
*
|
|
15
|
+
* @param selection
|
|
16
|
+
* @param createElement
|
|
17
|
+
* @param wrappingElement
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function $wrapNodes(selection: RangeSelection, createElement: () => ElementNode, wrappingElement?: null | ElementNode): void;
|
|
21
|
+
export declare function $wrapNodesImpl(selection: RangeSelection, nodes: LexicalNode[], nodesLength: number, createElement: () => ElementNode, wrappingElement?: null | ElementNode): void;
|
|
22
|
+
export declare function $shouldOverrideDefaultCharacterSelection(selection: RangeSelection, isBackward: boolean): boolean;
|
|
23
|
+
export declare function $moveCaretSelection(selection: RangeSelection, isHoldingShift: boolean, isBackward: boolean, granularity: 'character' | 'word' | 'lineboundary'): void;
|
|
24
|
+
export declare function $isParentElementRTL(selection: RangeSelection): boolean;
|
|
25
|
+
export declare function $moveCharacter(selection: RangeSelection, isHoldingShift: boolean, isBackward: boolean): void;
|
|
26
|
+
export declare function $selectAll(selection: RangeSelection): void;
|
|
27
|
+
export declare function $cloneRangeSelectionContent(selection: RangeSelection): ICloneSelectionContent;
|
|
28
|
+
export declare function $getSelectionStyleValueForProperty(selection: RangeSelection, styleProperty: string, defaultValue?: string): string;
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { LexicalEditor, LexicalNode } from 'lexical';
|
|
9
|
+
export declare function createDOMRange(editor: LexicalEditor, anchorNode: LexicalNode, _anchorOffset: number, focusNode: LexicalNode, _focusOffset: number): Range | null;
|
|
10
|
+
export declare function createRectsFromDOMRange(editor: LexicalEditor, range: Range): Array<ClientRect>;
|
|
11
|
+
export declare function getStyleObjectFromRawCSS(css: string): Record<string, string>;
|
|
12
|
+
export declare function getStyleObjectFromCSS(css: string): Record<string, string>;
|
|
13
|
+
export declare function getCSSFromStyleObject(styles: Record<string, string>): string;
|