@ekz/lexical-list 0.40.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/index.d.ts ADDED
@@ -0,0 +1,68 @@
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 { SerializedListItemNode } from './LexicalListItemNode';
9
+ import type { ListNodeTagType, ListType, SerializedListNode } from './LexicalListNode';
10
+ import type { LexicalCommand, LexicalEditor, NodeKey } from '@ekz/lexical';
11
+ import { INSERT_CHECK_LIST_COMMAND, registerCheckList } from './checkList';
12
+ import { $handleListInsertParagraph, $insertList, $removeList } from './formatList';
13
+ import { $createListItemNode, $isListItemNode, ListItemNode } from './LexicalListItemNode';
14
+ import { $createListNode, $isListNode, ListNode } from './LexicalListNode';
15
+ import { $getListDepth } from './utils';
16
+ export { $createListItemNode, $createListNode, $getListDepth, $handleListInsertParagraph, $insertList, $isListItemNode, $isListNode, $removeList, INSERT_CHECK_LIST_COMMAND, ListItemNode, ListNode, ListNodeTagType, ListType, registerCheckList, SerializedListItemNode, SerializedListNode, };
17
+ export declare const UPDATE_LIST_START_COMMAND: LexicalCommand<{
18
+ listNodeKey: NodeKey;
19
+ newStart: number;
20
+ }>;
21
+ export declare const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<void>;
22
+ export declare const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<void>;
23
+ export declare const REMOVE_LIST_COMMAND: LexicalCommand<void>;
24
+ export declare function registerList(editor: LexicalEditor): () => void;
25
+ export declare function registerListStrictIndentTransform(editor: LexicalEditor): () => void;
26
+ /**
27
+ * @deprecated use {@link $insertList} from an update or command listener.
28
+ *
29
+ * Inserts a new ListNode. If the selection's anchor node is an empty ListItemNode and is a child of
30
+ * the root/shadow root, it will replace the ListItemNode with a ListNode and the old ListItemNode.
31
+ * Otherwise it will replace its parent with a new ListNode and re-insert the ListItemNode and any previous children.
32
+ * If the selection's anchor node is not an empty ListItemNode, it will add a new ListNode or merge an existing ListNode,
33
+ * unless the the node is a leaf node, in which case it will attempt to find a ListNode up the branch and replace it with
34
+ * a new ListNode, or create a new ListNode at the nearest root/shadow root.
35
+ * @param editor - The lexical editor.
36
+ * @param listType - The type of list, "number" | "bullet" | "check".
37
+ */
38
+ export declare function insertList(editor: LexicalEditor, listType: ListType): void;
39
+ /**
40
+ * @deprecated use {@link $removeList} from an update or command listener.
41
+ *
42
+ * Searches for the nearest ancestral ListNode and removes it. If selection is an empty ListItemNode
43
+ * it will remove the whole list, including the ListItemNode. For each ListItemNode in the ListNode,
44
+ * removeList will also generate new ParagraphNodes in the removed ListNode's place. Any child node
45
+ * inside a ListItemNode will be appended to the new ParagraphNodes.
46
+ * @param editor - The lexical editor.
47
+ */
48
+ export declare function removeList(editor: LexicalEditor): void;
49
+ export interface ListConfig {
50
+ /**
51
+ * When `true`, enforces strict indentation rules for list items, ensuring consistent structure.
52
+ * When `false` (default), indentation is more flexible.
53
+ */
54
+ hasStrictIndent: boolean;
55
+ }
56
+ /**
57
+ * Configures {@link ListNode}, {@link ListItemNode} and registers
58
+ * the strict indent transform if `hasStrictIndent` is true (default false).
59
+ */
60
+ export declare const ListExtension: import("@ekz/lexical").LexicalExtension<ListConfig, "@ekz/lexical-list/List", import("@ekz/lexical-extension").NamedSignalsOutput<ListConfig>, unknown>;
61
+ /**
62
+ * Registers checklist functionality for {@link ListNode} and
63
+ * {@link ListItemNode} with a
64
+ * {@link INSERT_CHECK_LIST_COMMAND} listener and
65
+ * the expected keyboard and mouse interactions for
66
+ * checkboxes.
67
+ */
68
+ export declare const CheckListExtension: import("@ekz/lexical").LexicalExtension<import("@ekz/lexical").ExtensionConfigBase, "@ekz/lexical-list/CheckList", unknown, unknown>;
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@ekz/lexical-list",
3
+ "description": "This package provides the list feature for Lexical.",
4
+ "keywords": [
5
+ "lexical",
6
+ "editor",
7
+ "rich-text",
8
+ "list"
9
+ ],
10
+ "license": "MIT",
11
+ "version": "0.40.0",
12
+ "main": "LexicalList.js",
13
+ "types": "index.d.ts",
14
+ "dependencies": {
15
+ "@ekz/lexical-extension": "0.40.0",
16
+ "@ekz/lexical-selection": "0.40.0",
17
+ "@ekz/lexical-utils": "0.40.0",
18
+ "@ekz/lexical": "0.40.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/facebook/lexical.git",
23
+ "directory": "packages/lexical-list"
24
+ },
25
+ "module": "LexicalList.mjs",
26
+ "sideEffects": false,
27
+ "exports": {
28
+ ".": {
29
+ "import": {
30
+ "types": "./index.d.ts",
31
+ "development": "./LexicalList.dev.mjs",
32
+ "production": "./LexicalList.prod.mjs",
33
+ "node": "./LexicalList.node.mjs",
34
+ "default": "./LexicalList.mjs"
35
+ },
36
+ "require": {
37
+ "types": "./index.d.ts",
38
+ "development": "./LexicalList.dev.js",
39
+ "production": "./LexicalList.prod.js",
40
+ "default": "./LexicalList.js"
41
+ }
42
+ }
43
+ }
44
+ }
package/utils.d.ts ADDED
@@ -0,0 +1,65 @@
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 { LexicalNode, Spread } from '@ekz/lexical';
9
+ import { ListItemNode, ListNode } from './';
10
+ /**
11
+ * Checks the depth of listNode from the root node.
12
+ * @param listNode - The ListNode to be checked.
13
+ * @returns The depth of the ListNode.
14
+ */
15
+ export declare function $getListDepth(listNode: ListNode): number;
16
+ /**
17
+ * Finds the nearest ancestral ListNode and returns it, throws an invariant if listItem is not a ListItemNode.
18
+ * @param listItem - The node to be checked.
19
+ * @returns The ListNode found.
20
+ */
21
+ export declare function $getTopListNode(listItem: LexicalNode): ListNode;
22
+ /**
23
+ * Checks if listItem has no child ListNodes and has no ListItemNode ancestors with siblings.
24
+ * @param listItem - the ListItemNode to be checked.
25
+ * @returns true if listItem has no child ListNode and no ListItemNode ancestors with siblings, false otherwise.
26
+ */
27
+ export declare function $isLastItemInList(listItem: ListItemNode): boolean;
28
+ /**
29
+ * A recursive Depth-First Search (Postorder Traversal) that finds all of a node's children
30
+ * that are of type ListItemNode and returns them in an array.
31
+ * @param node - The ListNode to start the search.
32
+ * @returns An array containing all nodes of type ListItemNode found.
33
+ */
34
+ export declare function $getAllListItems(node: ListNode): Array<ListItemNode>;
35
+ declare const NestedListNodeBrand: unique symbol;
36
+ /**
37
+ * Checks to see if the passed node is a ListItemNode and has a ListNode as a child.
38
+ * @param node - The node to be checked.
39
+ * @returns true if the node is a ListItemNode and has a ListNode child, false otherwise.
40
+ */
41
+ export declare function isNestedListNode(node: LexicalNode | null | undefined): node is Spread<{
42
+ getFirstChild(): ListNode;
43
+ [NestedListNodeBrand]: never;
44
+ }, ListItemNode>;
45
+ /**
46
+ * Traverses up the tree and returns the first ListItemNode found.
47
+ * @param node - Node to start the search.
48
+ * @returns The first ListItemNode found, or null if none exist.
49
+ */
50
+ export declare function $findNearestListItemNode(node: LexicalNode): ListItemNode | null;
51
+ /**
52
+ * Takes a deeply nested ListNode or ListItemNode and traverses up the branch to delete the first
53
+ * ancestral ListNode (which could be the root ListNode) or ListItemNode with siblings, essentially
54
+ * bringing the deeply nested node up the branch once. Would remove sublist if it has siblings.
55
+ * Should not break ListItem -> List -> ListItem chain as empty List/ItemNodes should be removed on .remove().
56
+ * @param sublist - The nested ListNode or ListItemNode to be brought up the branch.
57
+ */
58
+ export declare function $removeHighestEmptyListParent(sublist: ListItemNode | ListNode): void;
59
+ /**
60
+ * Wraps a node into a ListItemNode.
61
+ * @param node - The node to be wrapped into a ListItemNode
62
+ * @returns The ListItemNode which the passed node is wrapped in.
63
+ */
64
+ export declare function $wrapInListItem(node: LexicalNode): ListItemNode;
65
+ export {};