@webiny/lexical-nodes 6.4.4-beta.4 → 6.4.4-beta.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/package.json +13 -13
- package/utils/listNode.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/lexical-nodes",
|
|
3
|
-
"version": "6.4.4-beta.
|
|
3
|
+
"version": "6.4.4-beta.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
7
7
|
"./*": "./*"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@lexical/code": "0.
|
|
11
|
-
"@lexical/hashtag": "0.
|
|
12
|
-
"@lexical/list": "0.
|
|
13
|
-
"@lexical/mark": "0.
|
|
14
|
-
"@lexical/overflow": "0.
|
|
15
|
-
"@lexical/react": "0.
|
|
16
|
-
"@lexical/rich-text": "0.
|
|
17
|
-
"@lexical/selection": "0.
|
|
18
|
-
"@lexical/utils": "0.
|
|
10
|
+
"@lexical/code": "0.46.0",
|
|
11
|
+
"@lexical/hashtag": "0.46.0",
|
|
12
|
+
"@lexical/list": "0.46.0",
|
|
13
|
+
"@lexical/mark": "0.46.0",
|
|
14
|
+
"@lexical/overflow": "0.46.0",
|
|
15
|
+
"@lexical/react": "0.46.0",
|
|
16
|
+
"@lexical/rich-text": "0.46.0",
|
|
17
|
+
"@lexical/selection": "0.46.0",
|
|
18
|
+
"@lexical/utils": "0.46.0",
|
|
19
19
|
"@types/prismjs": "1.26.6",
|
|
20
|
-
"@webiny/lexical-theme": "6.4.4-beta.
|
|
21
|
-
"lexical": "0.
|
|
20
|
+
"@webiny/lexical-theme": "6.4.4-beta.6",
|
|
21
|
+
"lexical": "0.46.0",
|
|
22
22
|
"react": "18.3.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@webiny/build-tools": "6.4.4-beta.
|
|
25
|
+
"@webiny/build-tools": "6.4.4-beta.6"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
package/utils/listNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/listNode.js","sources":["../../src/utils/listNode.ts"],"sourcesContent":["import type { LexicalNode, Spread } from \"lexical\";\n\nimport type { ListNode } from \"~/ListNode.js\";\nimport { $isListNode } from \"~/ListNode.js\";\nimport type { ListItemNode } from \"~/ListItemNode.js\";\nimport { $createListItemNode, $isListItemNode } from \"~/ListItemNode.js\";\n\nexport function $getListDepth(listNode: ListNode): number {\n let depth = 1;\n let parent = listNode.getParent();\n\n while (parent !== null) {\n if ($isListItemNode(parent)) {\n const parentList = parent.getParent();\n\n if ($isListNode(parentList)) {\n depth++;\n parent = parentList?.getParent() || null;\n continue;\n }\n console.log(\"A WebinyListItemNode must have a WebinyListNode for a parent.\");\n }\n\n return depth;\n }\n\n return depth;\n}\n\nexport function $getTopListNode(listItem: LexicalNode): ListNode {\n let list = listItem.getParent<ListNode>();\n\n if (!$isListNode(list)) {\n console.log(\"A WebinyListItemNode must have a ListNode for a parent.\");\n return listItem as ListNode;\n }\n\n let parent:
|
|
1
|
+
{"version":3,"file":"utils/listNode.js","sources":["../../src/utils/listNode.ts"],"sourcesContent":["import type { ElementNode, LexicalNode, Spread } from \"lexical\";\n\nimport type { ListNode } from \"~/ListNode.js\";\nimport { $isListNode } from \"~/ListNode.js\";\nimport type { ListItemNode } from \"~/ListItemNode.js\";\nimport { $createListItemNode, $isListItemNode } from \"~/ListItemNode.js\";\n\nexport function $getListDepth(listNode: ListNode): number {\n let depth = 1;\n let parent = listNode.getParent();\n\n while (parent !== null) {\n if ($isListItemNode(parent)) {\n const parentList = parent.getParent();\n\n if ($isListNode(parentList)) {\n depth++;\n parent = parentList?.getParent() || null;\n continue;\n }\n console.log(\"A WebinyListItemNode must have a WebinyListNode for a parent.\");\n }\n\n return depth;\n }\n\n return depth;\n}\n\nexport function $getTopListNode(listItem: LexicalNode): ListNode {\n let list = listItem.getParent<ListNode>();\n\n if (!$isListNode(list)) {\n console.log(\"A WebinyListItemNode must have a ListNode for a parent.\");\n return listItem as ListNode;\n }\n\n let parent: ElementNode | null = list;\n\n while (parent !== null) {\n parent = parent.getParent();\n\n if ($isListNode(parent)) {\n list = parent;\n }\n }\n\n return list;\n}\n\nexport function $getAllListItems(node: ListNode): Array<ListItemNode> {\n let listItemNodes: Array<ListItemNode> = [];\n const listChildren: Array<ListItemNode> = node.getChildren().filter($isListItemNode);\n\n for (let i = 0; i < listChildren.length; i++) {\n const listItemNode = listChildren[i];\n const firstChild = listItemNode?.getFirstChild();\n\n if ($isListNode(firstChild)) {\n listItemNodes = listItemNodes.concat($getAllListItems(firstChild));\n } else {\n listItemNodes.push(listItemNode);\n }\n }\n\n return listItemNodes;\n}\n\nconst NestedListNodeBrand: unique symbol = Symbol.for(\"@lexical/NestedListNodeBrand\");\n\n/**\n * Checks to see if the passed node is a ListItemNode and has a ListNode as a child.\n * @param node - The node to be checked.\n * @returns true if the node is a ListItemNode and has a ListNode child, false otherwise.\n */\nexport function isNestedListNode(\n node: LexicalNode | null | undefined\n): node is Spread<{ getFirstChild(): ListNode; [NestedListNodeBrand]: never }, ListItemNode> {\n return $isListItemNode(node) && $isListNode(node.getFirstChild());\n}\n\n// TODO: rewrite with $findMatchingParent or *nodeOfType\nexport function findNearestListItemNode(node: LexicalNode): ListItemNode | null {\n let currentNode: LexicalNode | null = node;\n\n while (currentNode !== null) {\n if ($isListItemNode(currentNode)) {\n return currentNode;\n }\n currentNode = currentNode.getParent();\n }\n\n return null;\n}\n\nexport function getUniqueListItemNodes(nodeList: Array<LexicalNode>): Array<ListItemNode> {\n const keys = new Set<ListItemNode>();\n\n for (let i = 0; i < nodeList.length; i++) {\n const node = nodeList[i];\n\n if ($isListItemNode(node)) {\n keys.add(node);\n }\n }\n\n return Array.from(keys);\n}\n\nexport function $removeHighestEmptyListParent(sublist: ListItemNode | ListNode) {\n // Nodes may be repeatedly indented, to create deeply nested lists that each\n // contain just one bullet.\n // Our goal is to remove these (empty) deeply nested lists. The easiest\n // way to do that is crawl back up the tree until we find a node that has siblings\n // (e.g. is actually part of the list contents) and delete that, or delete\n // the root of the list (if no list nodes have siblings.)\n let emptyListPtr = sublist;\n\n while (emptyListPtr.getNextSibling() == null && emptyListPtr.getPreviousSibling() == null) {\n const parent = emptyListPtr.getParent<ListItemNode | ListNode>();\n\n if (parent == null || !($isListItemNode(emptyListPtr) || $isListNode(emptyListPtr))) {\n break;\n }\n\n emptyListPtr = parent;\n }\n\n emptyListPtr.remove();\n}\n\nexport function wrapInListItem(node: LexicalNode): ListItemNode {\n const listItemWrapper = $createListItemNode();\n return listItemWrapper.append(node);\n}\n"],"names":["$getListDepth","listNode","depth","parent","$isListItemNode","parentList","$isListNode","console","$getTopListNode","listItem","list","$getAllListItems","node","listItemNodes","listChildren","i","listItemNode","firstChild","Symbol","isNestedListNode","findNearestListItemNode","currentNode","getUniqueListItemNodes","nodeList","keys","Set","Array","$removeHighestEmptyListParent","sublist","emptyListPtr","wrapInListItem","listItemWrapper","$createListItemNode"],"mappings":";;AAOO,SAASA,cAAcC,QAAkB;IAC5C,IAAIC,QAAQ;IACZ,IAAIC,SAASF,SAAS,SAAS;IAE/B,MAAOE,AAAW,SAAXA,OAAiB;QACpB,IAAIC,gBAAgBD,SAAS;YACzB,MAAME,aAAaF,OAAO,SAAS;YAEnC,IAAIG,YAAYD,aAAa;gBACzBH;gBACAC,SAASE,YAAY,eAAe;gBACpC;YACJ;YACAE,QAAQ,GAAG,CAAC;QAChB;QAEA;IACJ;IAEA,OAAOL;AACX;AAEO,SAASM,gBAAgBC,QAAqB;IACjD,IAAIC,OAAOD,SAAS,SAAS;IAE7B,IAAI,CAACH,YAAYI,OAAO;QACpBH,QAAQ,GAAG,CAAC;QACZ,OAAOE;IACX;IAEA,IAAIN,SAA6BO;IAEj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