Socket
Socket
Sign inDemoInstall

@lexical/selection

Package Overview
Dependencies
Maintainers
3
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/selection - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

4

package.json

@@ -12,6 +12,6 @@ {

"license": "MIT",
"version": "0.2.1",
"version": "0.2.2",
"main": "LexicalSelection.js",
"peerDependencies": {
"lexical": "0.2.1"
"lexical": "0.2.2"
},

@@ -18,0 +18,0 @@ "repository": {

# `@lexical/selection`
This package contains utilities and helpers for handling Lexical selection.
This package contains selection helpers for Lexical.
### Methods
#### `$cloneContents`
Clones the Lexical nodes in the selection, returning a map of Key -> LexicalNode and a list containing the keys
of all direct children of the RootNode. Useful for insertion/transfer operations, such as copy and paste.
```ts
export function $cloneContents(
selection: RangeSelection | NodeSelection | GridSelection,
): {
nodeMap: Array<[NodeKey, LexicalNode]>;
range: Array<NodeKey>;
};
```
#### `getStyleObjectFromCSS`
Given a CSS string, returns an object from the style cache.
```ts
export function getStyleObjectFromCSS(css: string): {
[key: string]: string;
} | null;
```
#### `$patchStyleText`
Applies the provided styles to the TextNodes in the provided Selection. Key names in the patch argument should be
the valid CSS properties (i.e., kebab-case).
```ts
export function $patchStyleText(
selection: RangeSelection | GridSelection,
patch: {
[key: string]: string;
},
): void;
```
#### `$getSelectionStyleValueForProperty`
Given a selection and a valid CSS property name, returns the current value of that property for TextNodes in the Selection, if set. If not set, it returns the defaultValue. If all TextNodes do not have the same value, it returns an empty string.
```ts
export function $getSelectionStyleValueForProperty(
selection: RangeSelection,
styleProperty: string,
defaultValue: string,
): string;
```
#### `$moveCaretSelection`
Moves the selection according to the arguments.
```ts
export function $moveCaretSelection(
selection: RangeSelection,
isHoldingShift: boolean,
isBackward: boolean,
granularity: 'character' | 'word' | 'lineboundary',
): void;
```
#### `$isParentElementRTL`
Returns true if the parent of the Selection anchor node is in Right-To-Left mode, false if not.
```ts
export function $isParentElementRTL(selection: RangeSelection): boolean;
```
#### `$moveCharacter`
Wraps $moveCaretSelection, using character granularity and accounting for RTL mode.
```ts
export function $moveCharacter(
selection: RangeSelection,
isHoldingShift: boolean,
isBackward: boolean,
): void;
```
#### `$selectAll`
Expands the current Selection to cover all of the content in the editor.
```ts
export function $selectAll(selection: RangeSelection): void;
```
#### `$wrapLeafNodesInElements`
Attempts to wrap all leaf nodes in the Selection in ElementNodes returned from createElement. If wrappingElement is provided, all of the wrapped leaves are appended to the wrappingElement. It attempts to append the resulting sub-tree to the nearest safe insertion target.
```ts
export function $wrapLeafNodesInElements(
selection: RangeSelection,
createElement: () => ElementNode,
wrappingElement?: ElementNode,
): void;
```
#### `$isAtNodeEnd`
Returns true if the provided point offset is in the last possible position.
```ts
export function $isAtNodeEnd(point: Point): boolean;
```
#### `$shouldOverrideDefaultCharacterSelection`
Returns true if default character selection should be overridden, false if not. Used with DecoratorNodes
```ts
export function $shouldOverrideDefaultCharacterSelection(
selection: RangeSelection,
isBackward: boolean,
): boolean;
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc