@webiny/lexical-editor 5.36.1 → 5.36.2-beta.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.
Files changed (69) hide show
  1. package/commands/webiny-list.d.ts +1 -1
  2. package/commands/webiny-list.js.map +1 -1
  3. package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +2 -0
  4. package/components/LexicalEditorConfig/LexicalEditorConfig.js +3 -1
  5. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  6. package/components/Toolbar/Toolbar.css +12 -0
  7. package/components/Toolbar/Toolbar.js +83 -49
  8. package/components/Toolbar/Toolbar.js.map +1 -1
  9. package/components/ToolbarActions/BulletListAction.js +7 -2
  10. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  11. package/components/ToolbarActions/FontSizeAction.js +1 -1
  12. package/components/ToolbarActions/FontSizeAction.js.map +1 -1
  13. package/components/ToolbarActions/NumberedListAction.js +7 -2
  14. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  15. package/components/ToolbarActions/QuoteAction.js +3 -2
  16. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  17. package/components/ToolbarActions/TextAlignmentAction.d.ts +11 -0
  18. package/components/ToolbarActions/TextAlignmentAction.js +70 -0
  19. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
  20. package/components/ToolbarPresets/HeadingToolbarPreset.js +4 -0
  21. package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -1
  22. package/components/ToolbarPresets/ParagraphToolbarPreset.js +4 -0
  23. package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +1 -1
  24. package/context/RichTextEditorContext.d.ts +5 -0
  25. package/context/RichTextEditorContext.js +17 -5
  26. package/context/RichTextEditorContext.js.map +1 -1
  27. package/context/TextAlignmentActionContextProps.d.ts +9 -0
  28. package/context/TextAlignmentActionContextProps.js +10 -0
  29. package/context/TextAlignmentActionContextProps.js.map +1 -0
  30. package/hooks/useList.d.ts +2 -0
  31. package/hooks/{useWebinyList.js → useList.js} +3 -3
  32. package/hooks/useList.js.map +1 -0
  33. package/hooks/useTextAlignmentAction.d.ts +1 -0
  34. package/hooks/useTextAlignmentAction.js +15 -0
  35. package/hooks/useTextAlignmentAction.js.map +1 -0
  36. package/images/icons/indent.svg +3 -0
  37. package/images/icons/justify.svg +3 -0
  38. package/images/icons/outdent.svg +3 -0
  39. package/index.d.ts +2 -0
  40. package/index.js +14 -0
  41. package/index.js.map +1 -1
  42. package/nodes/{list-node/WebinyListItemNode.d.ts → ListItemNode.d.ts} +7 -7
  43. package/nodes/{list-node/WebinyListItemNode.js → ListItemNode.js} +49 -50
  44. package/nodes/ListItemNode.js.map +1 -0
  45. package/nodes/{list-node → ListNode}/formatList.d.ts +6 -6
  46. package/nodes/{list-node → ListNode}/formatList.js +38 -38
  47. package/nodes/ListNode/formatList.js.map +1 -0
  48. package/nodes/{list-node/WebinyListNode.d.ts → ListNode.d.ts} +11 -7
  49. package/nodes/{list-node/WebinyListNode.js → ListNode.js} +70 -29
  50. package/nodes/ListNode.js.map +1 -0
  51. package/nodes/webinyNodes.js +3 -3
  52. package/nodes/webinyNodes.js.map +1 -1
  53. package/package.json +5 -5
  54. package/plugins/WebinyListPLugin/WebinyListPlugin.js +5 -5
  55. package/plugins/WebinyListPLugin/WebinyListPlugin.js.map +1 -1
  56. package/types.d.ts +2 -0
  57. package/types.js.map +1 -1
  58. package/utils/getLexicalTextSelectionState.js +9 -3
  59. package/utils/getLexicalTextSelectionState.js.map +1 -1
  60. package/utils/nodes/listNode.d.ts +11 -0
  61. package/utils/nodes/{list-node.js → listNode.js} +13 -13
  62. package/utils/nodes/listNode.js.map +1 -0
  63. package/hooks/useWebinyList.d.ts +0 -2
  64. package/hooks/useWebinyList.js.map +0 -1
  65. package/nodes/list-node/WebinyListItemNode.js.map +0 -1
  66. package/nodes/list-node/WebinyListNode.js.map +0 -1
  67. package/nodes/list-node/formatList.js.map +0 -1
  68. package/utils/nodes/list-node.d.ts +0 -11
  69. package/utils/nodes/list-node.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DEFAULT_LIST_START_NUMBER","$isSelectingEmptyListItem","anchorNode","nodes","$isListItemNode","length","is","getChildrenSize","$getListItemValue","listItem","list","getParent","value","$isListNode","console","log","getStart","siblings","getPreviousSiblings","i","sibling","getFirstChild","insertList","editor","listType","styleId","update","selection","$getSelection","$isRangeSelection","DEPRECATED_$isGridSelection","getNodes","anchor","getNode","anchorNodeParent","$createListNode","$isRootOrShadowRoot","replace","$createListItemNode","$isElementNode","setFormat","getFormatType","setIndent","getIndent","append","parent","getParentOrThrow","getChildren","handled","Set","node","isEmpty","has","getKey","createListOrMerge","$isLeafNode","parentKey","newListNode","updateChildrenListItemValue","add","nextParent","nodesToAppend","splice","previousSibling","getPreviousSibling","nextSibling","getNextSibling","getListType","remove","getFirstChildOrThrow","insertBefore","removeList","listNodes","$getTopListNode","WebinyListItemNode","$getNearestNodeOfType","ListNode","listNode","insertionPoint","listItems","$getAllListItems","paragraph","$createParagraphNode","insertAfter","__key","key","set","focus","children","childrenOrExisting","undefined","child","prevValue","getValue","nextValue","setValue","$handleIndent","WebinyListItemNodes","removed","forEach","isNestedListNode","innerList","nextInnerList","firstChild","newListItem","newList","getStyleId","$handleOutdent","parentList","grandparentListItem","greatGrandparentList","lastChild","getLastChild","themeStyleId","previousSiblingsListItem","previousSiblingsList","nextSiblingsListItem","nextSiblingsList","getNextSiblings","maybeIndentOrOutdent","direction","selectedNodes","webinyListItemNodes","push","nearestWebinyListItemNode","findNearestWebinyListItemNode","getUniqueWebinyListItemNodes","indentList","outdentList","$handleListInsertParagraph","isCollapsed","getTextContent","topListNode","grandparent","replacementNode","select","nextSiblings","$isParagraphNode","$removeHighestEmptyListParent"],"sources":["formatList.ts"],"sourcesContent":["import {\n $getSelection,\n $isElementNode,\n $isLeafNode,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n DEPRECATED_$isGridSelection,\n ElementNode,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n ParagraphNode as BaseParagraphNode\n} from \"lexical\";\nimport { $createListNode, $isListNode, ListNode } from \"../ListNode\";\nimport {\n $getAllListItems,\n $getTopListNode,\n $removeHighestEmptyListParent,\n findNearestWebinyListItemNode,\n getUniqueWebinyListItemNodes,\n isNestedListNode\n} from \"~/utils/nodes/listNode\";\nimport { $getNearestNodeOfType } from \"@lexical/utils\";\nimport { $createListItemNode, $isListItemNode, ListItemNode } from \"~/nodes/ListItemNode\";\nimport { ListType } from \"@lexical/list\";\nimport { $createParagraphNode } from \"~/nodes/ParagraphNode\";\n\nconst DEFAULT_LIST_START_NUMBER = 1;\n\nfunction $isSelectingEmptyListItem(\n anchorNode: ListItemNode | LexicalNode,\n nodes: Array<LexicalNode>\n): boolean {\n return (\n $isListItemNode(anchorNode) &&\n (nodes.length === 0 ||\n (nodes.length === 1 && anchorNode.is(nodes[0]) && anchorNode.getChildrenSize() === 0))\n );\n}\n\nfunction $getListItemValue(listItem: ListItemNode): number {\n const list = listItem.getParent();\n\n let value = 1;\n\n if (list !== null) {\n if (!$isListNode(list)) {\n console.log(\n \"$getListItemValue: webiny list node is not parent of webiny list item node\"\n );\n return DEFAULT_LIST_START_NUMBER;\n } else {\n value = list.getStart();\n }\n }\n\n const siblings = listItem.getPreviousSiblings();\n for (let i = 0; i < siblings.length; i++) {\n const sibling = siblings[i];\n\n if ($isListItemNode(sibling) && !$isListNode(sibling.getFirstChild())) {\n value++;\n }\n }\n return value;\n}\n\nexport function insertList(editor: LexicalEditor, listType: ListType, styleId?: string): void {\n editor.update(() => {\n const selection = $getSelection();\n\n if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {\n const nodes = selection.getNodes();\n const anchor = selection.anchor;\n const anchorNode = anchor.getNode();\n const anchorNodeParent = anchorNode.getParent();\n\n if ($isSelectingEmptyListItem(anchorNode, nodes)) {\n const list = $createListNode(listType, styleId);\n\n if ($isRootOrShadowRoot(anchorNodeParent)) {\n anchorNode.replace(list);\n const listItem = $createListItemNode();\n if ($isElementNode(anchorNode)) {\n listItem.setFormat(anchorNode.getFormatType());\n listItem.setIndent(anchorNode.getIndent());\n }\n list.append(listItem);\n } else if ($isListItemNode(anchorNode)) {\n const parent = anchorNode.getParentOrThrow();\n append(list, parent.getChildren());\n parent.replace(list);\n }\n\n return;\n } else {\n const handled = new Set();\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n\n if ($isElementNode(node) && node.isEmpty() && !handled.has(node.getKey())) {\n createListOrMerge(node, listType, styleId);\n continue;\n }\n\n if ($isLeafNode(node)) {\n let parent = node.getParent();\n while (parent != null) {\n const parentKey = parent.getKey();\n\n if ($isListNode(parent)) {\n if (!handled.has(parentKey)) {\n const newListNode = $createListNode(listType, styleId);\n append(newListNode, parent.getChildren());\n parent.replace(newListNode);\n updateChildrenListItemValue(newListNode);\n handled.add(parentKey);\n }\n\n break;\n } else {\n const nextParent = parent.getParent();\n\n if ($isRootOrShadowRoot(nextParent) && !handled.has(parentKey)) {\n handled.add(parentKey);\n createListOrMerge(parent, listType, styleId);\n break;\n }\n\n parent = nextParent;\n }\n }\n }\n }\n }\n }\n });\n}\n\nfunction append(node: ElementNode, nodesToAppend: Array<LexicalNode>) {\n node.splice(node.getChildrenSize(), 0, nodesToAppend);\n}\n\nfunction createListOrMerge(node: ElementNode, listType: ListType, styleId?: string): ListNode {\n if ($isListNode(node)) {\n return node;\n }\n\n const previousSibling = node.getPreviousSibling();\n const nextSibling = node.getNextSibling();\n const listItem = $createListItemNode();\n listItem.setFormat(node.getFormatType());\n listItem.setIndent(node.getIndent());\n append(listItem, node.getChildren());\n\n if ($isListNode(previousSibling) && listType === previousSibling.getListType()) {\n previousSibling.append(listItem);\n node.remove();\n // if the same type of list is on both sides, merge them.\n\n if ($isListNode(nextSibling) && listType === nextSibling.getListType()) {\n append(previousSibling, nextSibling.getChildren());\n nextSibling.remove();\n }\n return previousSibling;\n } else if ($isListNode(nextSibling) && listType === nextSibling.getListType()) {\n nextSibling.getFirstChildOrThrow().insertBefore(listItem);\n node.remove();\n return nextSibling;\n } else {\n const list = $createListNode(listType, styleId);\n list.append(listItem);\n node.replace(list);\n updateChildrenListItemValue(list);\n return list;\n }\n}\n\nexport function removeList(editor: LexicalEditor): void {\n editor.update(() => {\n const selection = $getSelection();\n\n if ($isRangeSelection(selection)) {\n const listNodes = new Set<ListNode>();\n const nodes = selection.getNodes();\n const anchorNode = selection.anchor.getNode();\n\n if ($isSelectingEmptyListItem(anchorNode, nodes)) {\n listNodes.add($getTopListNode(anchorNode));\n } else {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n\n if ($isLeafNode(node)) {\n const WebinyListItemNode = $getNearestNodeOfType(node, ListNode);\n\n if (WebinyListItemNode != null) {\n listNodes.add($getTopListNode(WebinyListItemNode));\n }\n }\n }\n }\n\n for (const listNode of listNodes) {\n let insertionPoint: ListNode | BaseParagraphNode = listNode;\n\n const listItems = $getAllListItems(listNode);\n\n for (const WebinyListItemNode of listItems) {\n const paragraph = $createParagraphNode();\n\n append(paragraph, WebinyListItemNode.getChildren());\n\n insertionPoint.insertAfter(paragraph);\n insertionPoint = paragraph;\n\n // When the anchor and focus fall on the textNode\n // we don't have to change the selection because the textNode will be appended to\n // the newly generated paragraph.\n // When selection is in empty nested list item, selection is actually on the WebinyListItemNode.\n // When the corresponding WebinyListItemNode is deleted and replaced by the newly generated paragraph\n // we should manually set the selection's focus and anchor to the newly generated paragraph.\n if (WebinyListItemNode.__key === selection.anchor.key) {\n selection.anchor.set(paragraph.getKey(), 0, \"element\");\n }\n if (WebinyListItemNode.__key === selection.focus.key) {\n selection.focus.set(paragraph.getKey(), 0, \"element\");\n }\n\n WebinyListItemNode.remove();\n }\n listNode.remove();\n }\n }\n });\n}\n\nexport function updateChildrenListItemValue(list: ListNode, children?: Array<LexicalNode>): void {\n const childrenOrExisting = children || list.getChildren();\n if (childrenOrExisting !== undefined) {\n for (let i = 0; i < childrenOrExisting.length; i++) {\n const child = childrenOrExisting[i];\n if ($isListItemNode(child)) {\n const prevValue = child.getValue();\n const nextValue = $getListItemValue(child);\n\n if (prevValue !== nextValue) {\n child.setValue(nextValue);\n }\n }\n }\n }\n}\n\nexport function $handleIndent(WebinyListItemNodes: Array<ListItemNode>): void {\n // go through each node and decide where to move it.\n const removed = new Set<NodeKey>();\n\n WebinyListItemNodes.forEach((WebinyListItemNode: ListItemNode) => {\n if (isNestedListNode(WebinyListItemNode) || removed.has(WebinyListItemNode.getKey())) {\n return;\n }\n\n const parent = WebinyListItemNode.getParent();\n\n // We can cast both of the below `isNestedListNode` only returns a boolean type instead of a user-defined type guards\n const nextSibling = WebinyListItemNode.getNextSibling<ListItemNode>() as ListItemNode;\n const previousSibling =\n WebinyListItemNode.getPreviousSibling<ListItemNode>() as ListItemNode;\n // if there are nested lists on either side, merge them all together.\n\n if (isNestedListNode(nextSibling) && isNestedListNode(previousSibling)) {\n const innerList = previousSibling.getFirstChild();\n\n if ($isListNode(innerList)) {\n innerList.append(WebinyListItemNode);\n const nextInnerList = nextSibling.getFirstChild();\n\n if ($isListNode(nextInnerList)) {\n const children = nextInnerList.getChildren();\n append(innerList, children);\n nextSibling.remove();\n removed.add(nextSibling.getKey());\n }\n updateChildrenListItemValue(innerList);\n }\n } else if (isNestedListNode(nextSibling)) {\n // if the WebinyListItemNode is next to a nested ListNode, merge them\n const innerList = nextSibling.getFirstChild();\n\n if ($isListNode(innerList)) {\n const firstChild = innerList.getFirstChild();\n\n if (firstChild !== null) {\n firstChild.insertBefore(WebinyListItemNode);\n }\n updateChildrenListItemValue(innerList);\n }\n } else if (isNestedListNode(previousSibling)) {\n const innerList = previousSibling.getFirstChild();\n\n if ($isListNode(innerList)) {\n innerList.append(WebinyListItemNode);\n updateChildrenListItemValue(innerList);\n }\n } else {\n // otherwise, we need to create a new nested ListNode\n\n if ($isListNode(parent)) {\n const newListItem = $createListItemNode();\n const newList = $createListNode(parent.getListType(), parent.getStyleId());\n newListItem.append(newList);\n newList.append(WebinyListItemNode);\n\n if (previousSibling) {\n previousSibling.insertAfter(newListItem);\n } else if (nextSibling) {\n nextSibling.insertBefore(newListItem);\n } else {\n parent.append(newListItem);\n }\n }\n }\n\n if ($isListNode(parent)) {\n updateChildrenListItemValue(parent);\n }\n });\n}\n\nexport function $handleOutdent(WebinyListItemNodes: Array<ListItemNode>): void {\n // go through each node and decide where to move it.\n\n WebinyListItemNodes.forEach(WebinyListItemNode => {\n if (isNestedListNode(WebinyListItemNode)) {\n return;\n }\n const parentList = WebinyListItemNode.getParent();\n const grandparentListItem = parentList ? parentList.getParent() : undefined;\n const greatGrandparentList = grandparentListItem\n ? grandparentListItem.getParent()\n : undefined;\n // If it doesn't have these ancestors, it's not indented.\n\n if (\n $isListNode(greatGrandparentList) &&\n $isListItemNode(grandparentListItem) &&\n $isListNode(parentList)\n ) {\n // if it's the first child in it's parent list, insert it into the\n // great grandparent list before the grandparent\n const firstChild = parentList ? parentList.getFirstChild() : undefined;\n const lastChild = parentList ? parentList.getLastChild() : undefined;\n\n if (WebinyListItemNode.is(firstChild)) {\n grandparentListItem.insertBefore(WebinyListItemNode);\n\n if (parentList.isEmpty()) {\n grandparentListItem.remove();\n }\n // if it's the last child in it's parent list, insert it into the\n // great grandparent list after the grandparent.\n } else if (WebinyListItemNode.is(lastChild)) {\n grandparentListItem.insertAfter(WebinyListItemNode);\n\n if (parentList.isEmpty()) {\n grandparentListItem.remove();\n }\n } else {\n // otherwise, we need to split the siblings into two new nested lists\n const listType = parentList.getListType();\n const themeStyleId = parentList.getStyleId();\n const previousSiblingsListItem = $createListItemNode();\n const previousSiblingsList = $createListNode(listType, themeStyleId);\n previousSiblingsListItem.append(previousSiblingsList);\n WebinyListItemNode.getPreviousSiblings().forEach(sibling =>\n previousSiblingsList.append(sibling)\n );\n const nextSiblingsListItem = $createListItemNode();\n const nextSiblingsList = $createListNode(listType, themeStyleId);\n nextSiblingsListItem.append(nextSiblingsList);\n append(nextSiblingsList, WebinyListItemNode.getNextSiblings());\n // put the sibling nested lists on either side of the grandparent list item in the great grandparent.\n grandparentListItem.insertBefore(previousSiblingsListItem);\n grandparentListItem.insertAfter(nextSiblingsListItem);\n // replace the grandparent list item (now between the siblings) with the outdented list item.\n grandparentListItem.replace(WebinyListItemNode);\n }\n updateChildrenListItemValue(parentList);\n updateChildrenListItemValue(greatGrandparentList);\n }\n });\n}\n\nfunction maybeIndentOrOutdent(direction: \"indent\" | \"outdent\"): void {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection)) {\n return;\n }\n const selectedNodes = selection.getNodes();\n let webinyListItemNodes: Array<ListItemNode> = [];\n\n if (selectedNodes.length === 0) {\n selectedNodes.push(selection.anchor.getNode());\n }\n\n if (selectedNodes.length === 1) {\n // Only 1 node selected. Selection may not contain the ListNodeItem so we traverse the tree to\n // find whether this is part of a WebinyListItemNode\n const nearestWebinyListItemNode = findNearestWebinyListItemNode(selectedNodes[0]);\n\n if (nearestWebinyListItemNode !== null) {\n webinyListItemNodes = [nearestWebinyListItemNode];\n }\n } else {\n webinyListItemNodes = getUniqueWebinyListItemNodes(selectedNodes);\n }\n\n if (webinyListItemNodes.length > 0) {\n if (direction === \"indent\") {\n $handleIndent(webinyListItemNodes);\n } else {\n $handleOutdent(webinyListItemNodes);\n }\n }\n}\n\nexport function indentList(): void {\n maybeIndentOrOutdent(\"indent\");\n}\n\nexport function outdentList(): void {\n maybeIndentOrOutdent(\"outdent\");\n}\n\nexport function $handleListInsertParagraph(): boolean {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection) || !selection.isCollapsed()) {\n return false;\n }\n\n // Only run this code on empty list items\n const anchor = selection.anchor.getNode();\n\n if (!$isListItemNode(anchor) || anchor.getTextContent() !== \"\") {\n return false;\n }\n const topListNode = $getTopListNode(anchor);\n const parent = anchor.getParent();\n\n if (!$isListNode(parent)) {\n console.log(\"A WebinyListItemNode must have a WebinyListNode for a parent.\");\n return false;\n }\n\n const grandparent = parent?.getParent() || null;\n\n let replacementNode;\n\n if ($isRootOrShadowRoot(grandparent)) {\n replacementNode = $createParagraphNode();\n topListNode.insertAfter(replacementNode);\n } else if ($isListItemNode(grandparent)) {\n replacementNode = $createListItemNode();\n grandparent.insertAfter(replacementNode);\n } else {\n return false;\n }\n replacementNode.select();\n\n const nextSiblings = anchor.getNextSiblings();\n\n if (nextSiblings.length > 0) {\n const newList = $createListNode(parent?.getListType(), parent?.getStyleId());\n\n if ($isParagraphNode(replacementNode)) {\n replacementNode.insertAfter(newList);\n } else {\n const newListItem = $createListItemNode();\n newListItem.append(newList);\n replacementNode.insertAfter(newListItem);\n }\n nextSiblings.forEach(sibling => {\n sibling.remove();\n newList.append(sibling);\n });\n }\n\n // Don't leave hanging nested empty lists\n $removeHighestEmptyListParent(anchor);\n\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAcA;AACA;AAQA;AACA;AAEA;AAEA,IAAMA,yBAAyB,GAAG,CAAC;AAEnC,SAASC,yBAAyB,CAC9BC,UAAsC,EACtCC,KAAyB,EAClB;EACP,OACI,IAAAC,6BAAe,EAACF,UAAU,CAAC,KAC1BC,KAAK,CAACE,MAAM,KAAK,CAAC,IACdF,KAAK,CAACE,MAAM,KAAK,CAAC,IAAIH,UAAU,CAACI,EAAE,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC,IAAID,UAAU,CAACK,eAAe,EAAE,KAAK,CAAE,CAAC;AAElG;AAEA,SAASC,iBAAiB,CAACC,QAAsB,EAAU;EACvD,IAAMC,IAAI,GAAGD,QAAQ,CAACE,SAAS,EAAE;EAEjC,IAAIC,KAAK,GAAG,CAAC;EAEb,IAAIF,IAAI,KAAK,IAAI,EAAE;IACf,IAAI,CAAC,IAAAG,qBAAW,EAACH,IAAI,CAAC,EAAE;MACpBI,OAAO,CAACC,GAAG,CACP,4EAA4E,CAC/E;MACD,OAAOf,yBAAyB;IACpC,CAAC,MAAM;MACHY,KAAK,GAAGF,IAAI,CAACM,QAAQ,EAA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,WAAW,CAACjD,WAAW,CAACmD,eAAe,CAAC;EAC5C,CAAC,MAAM,IAAI,IAAAlI,6BAAe,EAACiI,WAAW,CAAC,EAAE;IACrCC,eAAe,GAAG,IAAAhG,iCAAmB,GAAE;IACvC+F,WAAW,CAAClD,WAAW,CAACmD,eAAe,CAAC;EAC5C,CAAC,MAAM;IACH,OAAO,KAAK;EAChB;EACAA,eAAe,CAACC,MAAM,EAAE;EAExB,IAAMC,YAAY,GAAGxG,MAAM,CAACsF,eAAe,EAAE;EAE7C,IAAIkB,YAAY,CAACnI,MAAM,GAAG,CAAC,EAAE;IACzB,IAAMoG,OAAO,GAAG,IAAAtE,yBAAe,EAACU,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEsB,WAAW,EAAE,EAAEtB,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAE6D,UAAU,EAAE,CAAC;IAE5E,IAAI,IAAA+B,yBAAgB,EAACH,eAAe,CAAC,EAAE;MACnCA,eAAe,CAACnD,WAAW,CAACsB,OAAO,CAAC;IACxC,CAAC,MAAM;MACH,IAAMD,WAAW,GAAG,IAAAlE,iCAAmB,GAAE;MACzCkE,WAAW,CAAC5D,MAAM,CAAC6D,OAAO,CAAC;MAC3B6B,eAAe,CAACnD,WAAW,CAACqB,WAAW,CAAC;IAC5C;IACAgC,YAAY,CAACrC,OAAO,CAAC,UAAA/E,OAAO,EAAI;MAC5BA,OAAO,CAACgD,MAAM,EAAE;MAChBqC,OAAO,CAAC7D,MAAM,CAACxB,OAAO,CAAC;IAC3B,CAAC,CAAC;EACN;;EAEA;EACA,IAAAsH,uCAA6B,EAAC1G,MAAM,CAAC;EAErC,OAAO,IAAI;AACf"}
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  /// <reference types="web" />
3
3
  import { DOMConversion, DOMConversionMap, EditorConfig, ElementNode, LexicalNode, NodeKey, SerializedElementNode, Spread } from "lexical";
4
+ import { WebinyTheme } from "../themes/webinyLexicalTheme";
4
5
  import { ListNodeTagType } from "@lexical/list/LexicalListNode";
5
6
  import { ListType } from "@lexical/list";
6
7
  export declare type SerializedWebinyListNode = Spread<{
@@ -11,7 +12,7 @@ export declare type SerializedWebinyListNode = Spread<{
11
12
  type: "webiny-list";
12
13
  version: 1;
13
14
  }, SerializedElementNode>;
14
- export declare class WebinyListNode extends ElementNode {
15
+ export declare class ListNode extends ElementNode {
15
16
  /** @internal */
16
17
  __tag: ListNodeTagType;
17
18
  /** @internal */
@@ -19,20 +20,23 @@ export declare class WebinyListNode extends ElementNode {
19
20
  /** @internal */
20
21
  __listType: ListType;
21
22
  __themeStyleId: string;
22
- constructor(listType: ListType, themeStyleId: string, start: number, key?: NodeKey);
23
+ constructor(listType: ListType, themeStyleId?: string, start?: number, key?: NodeKey);
23
24
  static getType(): string;
25
+ isStyleExistInTheme(theme: WebinyTheme): boolean;
24
26
  createDOM(config: EditorConfig): HTMLElement;
25
- static clone(node: WebinyListNode): WebinyListNode;
27
+ static clone(node: ListNode): ListNode;
26
28
  getTag(): ListNodeTagType;
27
29
  getListType(): ListType;
28
30
  getStart(): number;
29
31
  getStyleId(): string;
30
- static importJSON(serializedNode: SerializedWebinyListNode): WebinyListNode;
32
+ static importJSON(serializedNode: SerializedWebinyListNode): ListNode;
31
33
  exportJSON(): SerializedWebinyListNode;
32
34
  static importDomConversionMap(): DOMConversion<HTMLElement> | null;
33
35
  static importDOM(): DOMConversionMap | null;
34
- updateDOM(prevNode: WebinyListNode, dom: HTMLElement, config: EditorConfig): boolean;
36
+ setDefaultThemeListStyleByTag(tag: string, theme: WebinyTheme): void;
37
+ hasThemeStyle(): boolean;
38
+ updateDOM(prevNode: ListNode, dom: HTMLElement, config: EditorConfig): boolean;
35
39
  extractWithChild(child: LexicalNode): boolean;
36
40
  }
37
- export declare function $createWebinyListNode(listType: ListType, themeStyleId: string, start?: number): WebinyListNode;
38
- export declare function $isWebinyListNode(node: LexicalNode | null | undefined): node is WebinyListNode;
41
+ export declare function $createListNode(listType: ListType, themeStyleId?: string, start?: number): ListNode;
42
+ export declare function $isListNode(node: LexicalNode | null | undefined): node is ListNode;
@@ -4,9 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.$createWebinyListNode = $createWebinyListNode;
8
- exports.$isWebinyListNode = $isWebinyListNode;
9
- exports.WebinyListNode = void 0;
7
+ exports.$createListNode = $createListNode;
8
+ exports.$isListNode = $isListNode;
9
+ exports.ListNode = void 0;
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -19,42 +19,54 @@ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
19
19
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
20
20
  var _lexical = require("lexical");
21
21
  var _utils = require("@lexical/utils");
22
- var _listNode = require("../../utils/nodes/list-node");
23
- var _WebinyListItemNode = require("./WebinyListItemNode");
22
+ var _listNode = require("../utils/nodes/listNode");
23
+ var _ListItemNode = require("./ListItemNode");
24
+ var _findTypographyStyleByHtmlTag = require("../utils/findTypographyStyleByHtmlTag");
24
25
  var TypographyStyleAttrName = "data-theme-list-style-id";
25
- var WebinyListNode = /*#__PURE__*/function (_ElementNode) {
26
- (0, _inherits2.default)(WebinyListNode, _ElementNode);
27
- var _super = (0, _createSuper2.default)(WebinyListNode);
26
+ var ListNode = /*#__PURE__*/function (_ElementNode) {
27
+ (0, _inherits2.default)(ListNode, _ElementNode);
28
+ var _super = (0, _createSuper2.default)(ListNode);
28
29
  /** @internal */
29
30
 
30
31
  /** @internal */
31
32
 
32
33
  /** @internal */
33
34
 
34
- function WebinyListNode(listType, themeStyleId, start, key) {
35
+ function ListNode(listType, themeStyleId, start, key) {
35
36
  var _this;
36
- (0, _classCallCheck2.default)(this, WebinyListNode);
37
+ (0, _classCallCheck2.default)(this, ListNode);
37
38
  _this = _super.call(this, key);
38
39
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__tag", void 0);
39
40
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__start", void 0);
40
41
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__listType", void 0);
41
42
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__themeStyleId", void 0);
42
- _this.__themeStyleId = themeStyleId;
43
+ _this.__themeStyleId = themeStyleId || "";
43
44
  var _listType = TAG_TO_WEBINY_LIST_TYPE[listType] || listType;
44
45
  _this.__listType = _listType;
45
46
  _this.__tag = _listType === "number" ? "ol" : "ul";
46
- _this.__start = start;
47
+ _this.__start = start || 1;
47
48
  return _this;
48
49
  }
49
- (0, _createClass2.default)(WebinyListNode, [{
50
+ (0, _createClass2.default)(ListNode, [{
51
+ key: "isStyleExistInTheme",
52
+ value: function isStyleExistInTheme(theme) {
53
+ return theme !== null && theme !== void 0 && theme.emotionMap ? !!(theme !== null && theme !== void 0 && theme.emotionMap[this.__themeStyleId]) : false;
54
+ }
55
+ }, {
50
56
  key: "createDOM",
51
57
  value: function createDOM(config) {
52
58
  var tag = this.__tag;
53
59
  var dom = document.createElement(tag);
60
+ var wTheme = config.theme;
54
61
  if (this.__start !== 1) {
55
62
  dom.setAttribute("start", String(this.__start));
56
63
  }
57
64
 
65
+ // If styleId is not set or user removed from theme, set default style
66
+ if (!this.hasThemeStyle() || !this.isStyleExistInTheme(wTheme)) {
67
+ this.setDefaultThemeListStyleByTag(this.__tag, wTheme);
68
+ }
69
+
58
70
  // @ts-expect-error Internal field.
59
71
  dom.__lexicalListType = this.__listType;
60
72
  var theme = config.theme;
@@ -88,7 +100,7 @@ var WebinyListNode = /*#__PURE__*/function (_ElementNode) {
88
100
  // @ts-ignore
89
101
  function exportJSON() {
90
102
  var _this$__themeStyleId;
91
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(WebinyListNode.prototype), "exportJSON", this).call(this)), {}, {
103
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(ListNode.prototype), "exportJSON", this).call(this)), {}, {
92
104
  themeStyleId: (_this$__themeStyleId = this.__themeStyleId) !== null && _this$__themeStyleId !== void 0 ? _this$__themeStyleId : "",
93
105
  listType: this.getListType(),
94
106
  start: this.getStart(),
@@ -97,13 +109,42 @@ var WebinyListNode = /*#__PURE__*/function (_ElementNode) {
97
109
  version: 1
98
110
  });
99
111
  }
112
+ }, {
113
+ key: "setDefaultThemeListStyleByTag",
114
+ value:
115
+ /*
116
+ * Set default styleId from first style that is found in the theme that contains current ul or ol tag
117
+ */
118
+ function setDefaultThemeListStyleByTag(tag, theme) {
119
+ if (!tag) {
120
+ return;
121
+ }
122
+ var themeEmotionMap = theme === null || theme === void 0 ? void 0 : theme.emotionMap;
123
+ if (!themeEmotionMap) {
124
+ return;
125
+ }
126
+ var style = (0, _findTypographyStyleByHtmlTag.findTypographyStyleByHtmlTag)(tag, themeEmotionMap);
127
+ if (style) {
128
+ this.__themeStyleId = style.id;
129
+ }
130
+ }
131
+ }, {
132
+ key: "hasThemeStyle",
133
+ value: function hasThemeStyle() {
134
+ return !!this.__themeStyleId;
135
+ }
100
136
  }, {
101
137
  key: "updateDOM",
102
138
  value: function updateDOM(prevNode, dom, config) {
139
+ var wTheme = config.theme;
103
140
  if (prevNode.__tag !== this.__tag) {
104
141
  return true;
105
142
  }
106
- // update styles for different tag styles
143
+
144
+ // if styleId is not set or user removed from theme, set default style.
145
+ if (!this.hasThemeStyle() || !this.isStyleExistInTheme(wTheme)) {
146
+ this.setDefaultThemeListStyleByTag(this.__tag, wTheme);
147
+ }
107
148
  setListThemeClassNames(dom, config.theme, this, this.__themeStyleId);
108
149
  dom.setAttribute(TypographyStyleAttrName, this.__themeStyleId);
109
150
  return false;
@@ -111,7 +152,7 @@ var WebinyListNode = /*#__PURE__*/function (_ElementNode) {
111
152
  }, {
112
153
  key: "extractWithChild",
113
154
  value: function extractWithChild(child) {
114
- return (0, _WebinyListItemNode.$isWebinyListItemNode)(child);
155
+ return (0, _ListItemNode.$isListItemNode)(child);
115
156
  }
116
157
  }], [{
117
158
  key: "getType",
@@ -121,12 +162,12 @@ var WebinyListNode = /*#__PURE__*/function (_ElementNode) {
121
162
  }, {
122
163
  key: "clone",
123
164
  value: function clone(node) {
124
- return new WebinyListNode(node.getListType(), node.getStyleId(), node.getStart(), node.__key);
165
+ return new ListNode(node.getListType(), node.getStyleId(), node.getStart(), node.__key);
125
166
  }
126
167
  }, {
127
168
  key: "importJSON",
128
169
  value: function importJSON(serializedNode) {
129
- var node = $createWebinyListNode(serializedNode.listType, serializedNode.themeStyleId, serializedNode.start);
170
+ var node = $createListNode(serializedNode.listType, serializedNode.themeStyleId, serializedNode.start);
130
171
  node.setFormat(serializedNode.format);
131
172
  node.setIndent(serializedNode.indent);
132
173
  node.setDirection(serializedNode.direction);
@@ -154,9 +195,9 @@ var WebinyListNode = /*#__PURE__*/function (_ElementNode) {
154
195
  };
155
196
  }
156
197
  }]);
157
- return WebinyListNode;
198
+ return ListNode;
158
199
  }(_lexical.ElementNode);
159
- exports.WebinyListNode = WebinyListNode;
200
+ exports.ListNode = ListNode;
160
201
  function setListThemeClassNames(dom, editorTheme, node, themeStyleId) {
161
202
  var editorThemeClasses = editorTheme;
162
203
  var classesToAdd = [];
@@ -175,7 +216,7 @@ function setListThemeClassNames(dom, editorTheme, node, themeStyleId) {
175
216
  if (nestedListTheme !== undefined && nestedListTheme.list) {
176
217
  nestedListClassName = nestedListTheme.list;
177
218
  }
178
- if (listClassName !== undefined) {
219
+ if (listClassName) {
179
220
  classesToAdd.push(listClassName);
180
221
  }
181
222
  if (listLevelClassName !== undefined) {
@@ -213,10 +254,10 @@ function normalizeChildren(nodes) {
213
254
  var normalizedListItems = [];
214
255
  for (var i = 0; i < nodes.length; i++) {
215
256
  var node = nodes[i];
216
- if ((0, _WebinyListItemNode.$isWebinyListItemNode)(node)) {
257
+ if ((0, _ListItemNode.$isListItemNode)(node)) {
217
258
  normalizedListItems.push(node);
218
259
  node.getChildren().forEach(function (child) {
219
- if ($isWebinyListNode(child)) {
260
+ if ($isListNode(child)) {
220
261
  normalizedListItems.push((0, _listNode.wrapInListItem)(child));
221
262
  }
222
263
  });
@@ -230,9 +271,9 @@ function convertWebinyListNode(domNode) {
230
271
  var nodeName = domNode.nodeName.toLowerCase();
231
272
  var node = null;
232
273
  if (nodeName === "ol") {
233
- node = $createWebinyListNode("number", "");
274
+ node = $createListNode("number");
234
275
  } else if (nodeName === "ul") {
235
- node = $createWebinyListNode("bullet", "");
276
+ node = $createListNode("bullet");
236
277
  }
237
278
  return {
238
279
  // @ts-ignore
@@ -244,10 +285,10 @@ var TAG_TO_WEBINY_LIST_TYPE = {
244
285
  ol: "number",
245
286
  ul: "bullet"
246
287
  };
247
- function $createWebinyListNode(listType, themeStyleId) {
288
+ function $createListNode(listType, themeStyleId) {
248
289
  var start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
249
- return new WebinyListNode(listType, themeStyleId, start);
290
+ return new ListNode(listType, themeStyleId, start);
250
291
  }
251
- function $isWebinyListNode(node) {
252
- return node instanceof WebinyListNode;
292
+ function $isListNode(node) {
293
+ return node instanceof ListNode;
253
294
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TypographyStyleAttrName","ListNode","listType","themeStyleId","start","key","__themeStyleId","_listType","TAG_TO_WEBINY_LIST_TYPE","__listType","__tag","__start","theme","emotionMap","config","tag","dom","document","createElement","wTheme","setAttribute","String","hasThemeStyle","isStyleExistInTheme","setDefaultThemeListStyleByTag","__lexicalListType","setListThemeClassNames","getListType","getStart","getTag","type","version","themeEmotionMap","style","findTypographyStyleByHtmlTag","id","prevNode","child","$isListItemNode","node","getStyleId","__key","serializedNode","$createListNode","setFormat","format","setIndent","indent","setDirection","direction","conversion","convertWebinyListNode","priority","ol","importDomConversionMap","ul","ElementNode","editorTheme","editorThemeClasses","classesToAdd","classesToRemove","listTheme","list","undefined","listLevelsClassNames","listDepth","$getListDepth","normalizedListDepth","length","listLevelClassName","listClassName","className","nestedListClassName","nestedListTheme","nested","push","listItemClasses","split","i","nestedListItemClasses","removeClassNamesFromElement","addClassNamesToElement","normalizeChildren","nodes","normalizedListItems","getChildren","forEach","$isListNode","wrapInListItem","domNode","nodeName","toLowerCase","after"],"sources":["ListNode.ts"],"sourcesContent":["import {\n DOMConversion,\n DOMConversionMap,\n DOMConversionOutput,\n EditorConfig,\n ElementNode,\n LexicalNode,\n NodeKey,\n SerializedElementNode,\n Spread\n} from \"lexical\";\nimport { WebinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { addClassNamesToElement, removeClassNamesFromElement } from \"@lexical/utils\";\nimport { ListNodeTagType } from \"@lexical/list/LexicalListNode\";\nimport { $getListDepth, wrapInListItem } from \"~/utils/nodes/listNode\";\nimport { ListType } from \"@lexical/list\";\nimport { $isListItemNode, ListItemNode } from \"~/nodes/ListItemNode\";\nimport { findTypographyStyleByHtmlTag } from \"~/utils/findTypographyStyleByHtmlTag\";\n\nconst TypographyStyleAttrName = \"data-theme-list-style-id\";\n\nexport type SerializedWebinyListNode = Spread<\n {\n themeStyleId: string;\n listType: ListType;\n start: number;\n tag: ListNodeTagType;\n type: \"webiny-list\";\n version: 1;\n },\n SerializedElementNode\n>;\n\nexport class ListNode extends ElementNode {\n /** @internal */\n __tag: ListNodeTagType;\n /** @internal */\n __start: number;\n /** @internal */\n __listType: ListType;\n\n __themeStyleId: string;\n\n constructor(listType: ListType, themeStyleId?: string, start?: number, key?: NodeKey) {\n super(key);\n this.__themeStyleId = themeStyleId || \"\";\n const _listType = TAG_TO_WEBINY_LIST_TYPE[listType] || listType;\n this.__listType = _listType;\n this.__tag = _listType === \"number\" ? \"ol\" : \"ul\";\n this.__start = start || 1;\n }\n\n static override getType() {\n return \"webiny-list\";\n }\n\n isStyleExistInTheme(theme: WebinyTheme): boolean {\n return theme?.emotionMap ? !!theme?.emotionMap[this.__themeStyleId] : false;\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const tag = this.__tag;\n const dom = document.createElement(tag);\n const wTheme = config.theme as WebinyTheme;\n\n if (this.__start !== 1) {\n dom.setAttribute(\"start\", String(this.__start));\n }\n\n // If styleId is not set or user removed from theme, set default style\n if (!this.hasThemeStyle() || !this.isStyleExistInTheme(wTheme)) {\n this.setDefaultThemeListStyleByTag(this.__tag, wTheme);\n }\n\n // @ts-expect-error Internal field.\n dom.__lexicalListType = this.__listType;\n const theme = config.theme as WebinyEditorTheme;\n setListThemeClassNames(dom, theme, this, this.__themeStyleId);\n dom.setAttribute(TypographyStyleAttrName, this.__themeStyleId);\n return dom;\n }\n\n static override clone(node: ListNode): ListNode {\n return new ListNode(node.getListType(), node.getStyleId(), node.getStart(), node.__key);\n }\n\n getTag(): ListNodeTagType {\n return this.__tag;\n }\n\n getListType(): ListType {\n return this.__listType;\n }\n\n getStart(): number {\n return this.__start;\n }\n\n getStyleId(): string {\n return this.__themeStyleId;\n }\n\n static override importJSON(serializedNode: SerializedWebinyListNode): ListNode {\n const node = $createListNode(\n serializedNode.listType,\n serializedNode.themeStyleId,\n serializedNode.start\n );\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n return node;\n }\n\n // @ts-ignore\n override exportJSON(): SerializedWebinyListNode {\n return {\n ...super.exportJSON(),\n themeStyleId: this.__themeStyleId ?? \"\",\n listType: this.getListType(),\n start: this.getStart(),\n tag: this.getTag(),\n type: \"webiny-list\",\n version: 1\n };\n }\n\n static importDomConversionMap(): DOMConversion<HTMLElement> | null {\n return {\n conversion: convertWebinyListNode,\n priority: 0\n };\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n ol: () => {\n return this.importDomConversionMap();\n },\n ul: () => {\n return this.importDomConversionMap();\n }\n };\n }\n\n /*\n * Set default styleId from first style that is found in the theme that contains current ul or ol tag\n */\n setDefaultThemeListStyleByTag(tag: string, theme: WebinyTheme) {\n if (!tag) {\n return;\n }\n\n const themeEmotionMap = theme?.emotionMap;\n if (!themeEmotionMap) {\n return;\n }\n\n const style = findTypographyStyleByHtmlTag(tag, themeEmotionMap);\n\n if (style) {\n this.__themeStyleId = style.id;\n }\n }\n\n hasThemeStyle(): boolean {\n return !!this.__themeStyleId;\n }\n\n override updateDOM(prevNode: ListNode, dom: HTMLElement, config: EditorConfig): boolean {\n const wTheme = config.theme as WebinyTheme;\n\n if (prevNode.__tag !== this.__tag) {\n return true;\n }\n\n // if styleId is not set or user removed from theme, set default style.\n if (!this.hasThemeStyle() || !this.isStyleExistInTheme(wTheme)) {\n this.setDefaultThemeListStyleByTag(this.__tag, wTheme);\n }\n\n setListThemeClassNames(dom, config.theme, this, this.__themeStyleId);\n dom.setAttribute(TypographyStyleAttrName, this.__themeStyleId);\n return false;\n }\n\n override extractWithChild(child: LexicalNode): boolean {\n return $isListItemNode(child);\n }\n}\n\nfunction setListThemeClassNames(\n dom: HTMLElement,\n editorTheme: WebinyEditorTheme,\n node: ListNode,\n themeStyleId: string\n): void {\n const editorThemeClasses = editorTheme;\n const classesToAdd = [];\n const classesToRemove = [];\n const listTheme = editorThemeClasses.list;\n const emotionMap = editorTheme?.emotionMap || {};\n if (listTheme !== undefined) {\n const listLevelsClassNames = listTheme[`${node.__tag}Depth`] || [];\n const listDepth = $getListDepth(node) - 1;\n const normalizedListDepth = listDepth % listLevelsClassNames.length;\n const listLevelClassName = listLevelsClassNames[normalizedListDepth];\n const listClassName = `${listTheme[node.__tag]} ${\n emotionMap[themeStyleId]?.className ?? \"\"\n }`;\n let nestedListClassName;\n const nestedListTheme = listTheme.nested;\n\n if (nestedListTheme !== undefined && nestedListTheme.list) {\n nestedListClassName = nestedListTheme.list;\n }\n\n if (listClassName) {\n classesToAdd.push(listClassName);\n }\n\n if (listLevelClassName !== undefined) {\n const listItemClasses = listLevelClassName.split(\" \");\n classesToAdd.push(...listItemClasses);\n for (let i = 0; i < listLevelsClassNames.length; i++) {\n if (i !== normalizedListDepth) {\n classesToRemove.push(node.__tag + i);\n }\n }\n }\n\n if (nestedListClassName !== undefined) {\n const nestedListItemClasses = nestedListClassName.split(\" \");\n\n if (listDepth > 1) {\n classesToAdd.push(...nestedListItemClasses);\n } else {\n classesToRemove.push(...nestedListItemClasses);\n }\n }\n }\n\n if (classesToRemove.length > 0) {\n removeClassNamesFromElement(dom, ...classesToRemove);\n }\n\n if (classesToAdd.length > 0) {\n addClassNamesToElement(dom, ...classesToAdd);\n }\n}\n\n/*\n * This function normalizes the children of a ListNode after the conversion from HTML,\n * ensuring that they are all ListItemNodes and contain either a single nested ListNode\n * or some other inline content.\n */\nfunction normalizeChildren(nodes: Array<ListNode>): Array<ListItemNode> {\n const normalizedListItems: Array<ListItemNode> = [];\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if ($isListItemNode(node)) {\n normalizedListItems.push(node);\n node.getChildren().forEach(child => {\n if ($isListNode(child)) {\n normalizedListItems.push(wrapInListItem(child));\n }\n });\n } else {\n normalizedListItems.push(wrapInListItem(node));\n }\n }\n return normalizedListItems;\n}\n\nfunction convertWebinyListNode(domNode: Node): DOMConversionOutput {\n const nodeName = domNode.nodeName.toLowerCase();\n let node = null;\n\n if (nodeName === \"ol\") {\n node = $createListNode(\"number\");\n } else if (nodeName === \"ul\") {\n node = $createListNode(\"bullet\");\n }\n\n return {\n // @ts-ignore\n after: normalizeChildren,\n node\n };\n}\n\nconst TAG_TO_WEBINY_LIST_TYPE: Record<string, ListType> = {\n ol: \"number\",\n ul: \"bullet\"\n};\n\nexport function $createListNode(listType: ListType, themeStyleId?: string, start = 1): ListNode {\n return new ListNode(listType, themeStyleId, start);\n}\n\nexport function $isListNode(node: LexicalNode | null | undefined): node is ListNode {\n return node instanceof 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B;IACxB3C,IAAI,EAAJA;EACJ,CAAC;AACL;AAEA,IAAM/B,uBAAiD,GAAG;EACtD6C,EAAE,EAAE,QAAQ;EACZE,EAAE,EAAE;AACR,CAAC;AAEM,SAASZ,eAAe,CAACzC,QAAkB,EAAEC,YAAqB,EAAuB;EAAA,IAArBC,KAAK,uEAAG,CAAC;EAChF,OAAO,IAAIH,QAAQ,CAACC,QAAQ,EAAEC,YAAY,EAAEC,KAAK,CAAC;AACtD;AAEO,SAASmF,WAAW,CAAChD,IAAoC,EAAoB;EAChF,OAAOA,IAAI,YAAYtC,QAAQ;AACnC"}
@@ -11,8 +11,8 @@ var _mark = require("@lexical/mark");
11
11
  var _overflow = require("@lexical/overflow");
12
12
  var _FontColorNode = require("./FontColorNode");
13
13
  var _TypographyElementNode = require("./TypographyElementNode");
14
- var _WebinyListNode = require("./list-node/WebinyListNode");
15
- var _WebinyListItemNode = require("./list-node/WebinyListItemNode");
14
+ var _ListNode = require("./ListNode");
15
+ var _ListItemNode = require("./ListItemNode");
16
16
  var _lexical = require("lexical");
17
17
  var _HeadingNode = require("./HeadingNode");
18
18
  var _ParagraphNode = require("./ParagraphNode");
@@ -21,7 +21,7 @@ var _QuoteNode = require("./QuoteNode");
21
21
  /*
22
22
  * This is a list of all the nodes that Webiny's Lexical implementation supports OOTB.
23
23
  * */
24
- var WebinyNodes = [_WebinyListNode.WebinyListNode, _WebinyListItemNode.WebinyListItemNode, _code.CodeNode, _hashtag.HashtagNode, _code.CodeHighlightNode, _link.AutoLinkNode, _link.LinkNode, _overflow.OverflowNode, _mark.MarkNode, _FontColorNode.FontColorNode, _TypographyElementNode.TypographyElementNode,
24
+ var WebinyNodes = [_ListNode.ListNode, _ListItemNode.ListItemNode, _code.CodeNode, _hashtag.HashtagNode, _code.CodeHighlightNode, _link.AutoLinkNode, _link.LinkNode, _overflow.OverflowNode, _mark.MarkNode, _FontColorNode.FontColorNode, _TypographyElementNode.TypographyElementNode,
25
25
  /*
26
26
  * In order to provide additional Webiny-related functionality, we override Lexical's ParagraphNode and HeadingNode nodes.
27
27
  * More info on overriding can be found here: https://lexical.dev/docs/concepts/node-replacement.
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyNodes","WebinyListNode","WebinyListItemNode","CodeNode","HashtagNode","CodeHighlightNode","AutoLinkNode","LinkNode","OverflowNode","MarkNode","FontColorNode","TypographyElementNode","ParagraphNode","replace","BaseParagraphNode","with","HeadingNode","BaseHeadingNode","node","getTag","QuoteNode","BaseQuoteNode"],"sources":["webinyNodes.ts"],"sourcesContent":["import type { Klass, LexicalNode } from \"lexical\";\n\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { AutoLinkNode, LinkNode } from \"@lexical/link\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { OverflowNode } from \"@lexical/overflow\";\nimport { FontColorNode } from \"~/nodes/FontColorNode\";\nimport { TypographyElementNode } from \"~/nodes/TypographyElementNode\";\nimport { WebinyListNode } from \"~/nodes/list-node/WebinyListNode\";\nimport { WebinyListItemNode } from \"~/nodes/list-node/WebinyListItemNode\";\nimport { ParagraphNode as BaseParagraphNode } from \"lexical\";\nimport { HeadingNode } from \"~/nodes/HeadingNode\";\nimport { ParagraphNode } from \"~/nodes/ParagraphNode\";\nimport { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport { QuoteNode } from \"~/nodes/QuoteNode\";\n\n/*\n * This is a list of all the nodes that Webiny's Lexical implementation supports OOTB.\n * */\nexport const WebinyNodes: ReadonlyArray<\n | Klass<LexicalNode>\n | {\n replace: Klass<LexicalNode>;\n with: <T extends { new (...args: any): any }>(node: InstanceType<T>) => LexicalNode;\n }\n> = [\n WebinyListNode,\n WebinyListItemNode,\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n LinkNode,\n OverflowNode,\n MarkNode,\n FontColorNode,\n TypographyElementNode,\n /*\n * In order to provide additional Webiny-related functionality, we override Lexical's ParagraphNode and HeadingNode nodes.\n * More info on overriding can be found here: https://lexical.dev/docs/concepts/node-replacement.\n * */\n ParagraphNode,\n {\n replace: BaseParagraphNode,\n with: () => {\n return new ParagraphNode();\n }\n },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n }\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n }\n }\n];\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACO,IAAMA,WAMZ,GAAG,CACAC,8BAAc,EACdC,sCAAkB,EAClBC,cAAQ,EACRC,oBAAW,EACXC,uBAAiB,EACjBC,kBAAY,EACZC,cAAQ,EACRC,sBAAY,EACZC,cAAQ,EACRC,4BAAa,EACbC,4CAAqB;AACrB;AACJ;AACA;AACA;AACIC,4BAAa,EACb;EACIC,OAAO,EAAEC,sBAAiB;EAC1BC,IAAI,EAAE,iBAAM;IACR,OAAO,IAAIH,4BAAa,EAAE;EAC9B;AACJ,CAAC,EACDI,wBAAW,EACX;EACIH,OAAO,EAAEI,qBAAe;EACxBF,IAAI,EAAE,eAACG,IAAqB,EAAK;IAC7B,OAAO,IAAIF,wBAAW,CAACE,IAAI,CAACC,MAAM,EAAE,CAAC;EACzC;AACJ,CAAC,EACDC,oBAAS,EACT;EACIP,OAAO,EAAEQ,mBAAa;EACtBN,IAAI,EAAE,iBAAM;IACR,OAAO,IAAIK,oBAAS,EAAE;EAC1B;AACJ,CAAC,CACJ;AAAC"}
1
+ {"version":3,"names":["WebinyNodes","ListNode","ListItemNode","CodeNode","HashtagNode","CodeHighlightNode","AutoLinkNode","LinkNode","OverflowNode","MarkNode","FontColorNode","TypographyElementNode","ParagraphNode","replace","BaseParagraphNode","with","HeadingNode","BaseHeadingNode","node","getTag","QuoteNode","BaseQuoteNode"],"sources":["webinyNodes.ts"],"sourcesContent":["import type { Klass, LexicalNode } from \"lexical\";\n\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { AutoLinkNode, LinkNode } from \"@lexical/link\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { OverflowNode } from \"@lexical/overflow\";\nimport { FontColorNode } from \"~/nodes/FontColorNode\";\nimport { TypographyElementNode } from \"~/nodes/TypographyElementNode\";\nimport { ListNode } from \"~/nodes/ListNode\";\nimport { ListItemNode } from \"~/nodes/ListItemNode\";\nimport { ParagraphNode as BaseParagraphNode } from \"lexical\";\nimport { HeadingNode } from \"~/nodes/HeadingNode\";\nimport { ParagraphNode } from \"~/nodes/ParagraphNode\";\nimport { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport { QuoteNode } from \"~/nodes/QuoteNode\";\n\n/*\n * This is a list of all the nodes that Webiny's Lexical implementation supports OOTB.\n * */\nexport const WebinyNodes: ReadonlyArray<\n | Klass<LexicalNode>\n | {\n replace: Klass<LexicalNode>;\n with: <T extends { new (...args: any): any }>(node: InstanceType<T>) => LexicalNode;\n }\n> = [\n ListNode,\n ListItemNode,\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n LinkNode,\n OverflowNode,\n MarkNode,\n FontColorNode,\n TypographyElementNode,\n /*\n * In order to provide additional Webiny-related functionality, we override Lexical's ParagraphNode and HeadingNode nodes.\n * More info on overriding can be found here: https://lexical.dev/docs/concepts/node-replacement.\n * */\n ParagraphNode,\n {\n replace: BaseParagraphNode,\n with: () => {\n return new ParagraphNode();\n }\n },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n }\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n }\n }\n];\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACO,IAAMA,WAMZ,GAAG,CACAC,kBAAQ,EACRC,0BAAY,EACZC,cAAQ,EACRC,oBAAW,EACXC,uBAAiB,EACjBC,kBAAY,EACZC,cAAQ,EACRC,sBAAY,EACZC,cAAQ,EACRC,4BAAa,EACbC,4CAAqB;AACrB;AACJ;AACA;AACA;AACIC,4BAAa,EACb;EACIC,OAAO,EAAEC,sBAAiB;EAC1BC,IAAI,EAAE,iBAAM;IACR,OAAO,IAAIH,4BAAa,EAAE;EAC9B;AACJ,CAAC,EACDI,wBAAW,EACX;EACIH,OAAO,EAAEI,qBAAe;EACxBF,IAAI,EAAE,eAACG,IAAqB,EAAK;IAC7B,OAAO,IAAIF,wBAAW,CAACE,IAAI,CAACC,MAAM,EAAE,CAAC;EACzC;AACJ,CAAC,EACDC,oBAAS,EACT;EACIP,OAAO,EAAEQ,mBAAa;EACtBN,IAAI,EAAE,iBAAM;IACR,OAAO,IAAIK,oBAAS,EAAE;EAC1B;AACJ,CAAC,CACJ;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/lexical-editor",
3
- "version": "5.36.1",
3
+ "version": "5.36.2-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/webiny/webiny-js.git"
@@ -19,15 +19,15 @@
19
19
  "@lexical/rich-text": "0.10.0",
20
20
  "@lexical/selection": "0.10.0",
21
21
  "@lexical/utils": "0.10.0",
22
- "@webiny/react-composition": "5.36.1",
22
+ "@webiny/react-composition": "5.36.2-beta.1",
23
23
  "lexical": "0.10.0",
24
24
  "react": "17.0.2",
25
25
  "react-dom": "17.0.2",
26
26
  "react-style-object-to-css": "1.1.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@webiny/cli": "5.36.1",
30
- "@webiny/project-utils": "5.36.1"
29
+ "@webiny/cli": "5.36.2-beta.1",
30
+ "@webiny/project-utils": "5.36.2-beta.1"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public",
@@ -37,5 +37,5 @@
37
37
  "build": "yarn webiny run build",
38
38
  "watch": "yarn webiny run watch"
39
39
  },
40
- "gitHead": "09c2454cad3aeba99988bd7bee678c6de4325caf"
40
+ "gitHead": "49a0945306457226d4e625af10923d832c9c1065"
41
41
  }
@@ -8,18 +8,18 @@ exports.WebinyListPlugin = WebinyListPlugin;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
10
10
  var _react = require("react");
11
- var _WebinyListNode = require("../../nodes/list-node/WebinyListNode");
12
- var _WebinyListItemNode = require("../../nodes/list-node/WebinyListItemNode");
13
- var _useWebinyList = require("../../hooks/useWebinyList");
11
+ var _ListNode = require("../../nodes/ListNode");
12
+ var _ListItemNode = require("../../nodes/ListItemNode");
13
+ var _useList = require("../../hooks/useList");
14
14
  function WebinyListPlugin() {
15
15
  var _useLexicalComposerCo = (0, _LexicalComposerContext.useLexicalComposerContext)(),
16
16
  _useLexicalComposerCo2 = (0, _slicedToArray2.default)(_useLexicalComposerCo, 1),
17
17
  editor = _useLexicalComposerCo2[0];
18
18
  (0, _react.useEffect)(function () {
19
- if (!editor.hasNodes([_WebinyListNode.WebinyListNode, _WebinyListItemNode.WebinyListItemNode])) {
19
+ if (!editor.hasNodes([_ListNode.ListNode, _ListItemNode.ListItemNode])) {
20
20
  throw new Error("WebinyListPlugin: WebinyListNode and/or WebinyListItemNode not registered on editor");
21
21
  }
22
22
  }, [editor]);
23
- (0, _useWebinyList.useWebinyList)(editor);
23
+ (0, _useList.useList)(editor);
24
24
  return null;
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyListPlugin","useLexicalComposerContext","editor","useEffect","hasNodes","WebinyListNode","WebinyListItemNode","Error","useWebinyList"],"sources":["WebinyListPlugin.ts"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { useEffect } from \"react\";\nimport { WebinyListNode } from \"~/nodes/list-node/WebinyListNode\";\nimport { WebinyListItemNode } from \"~/nodes/list-node/WebinyListItemNode\";\nimport { useWebinyList } from \"~/hooks/useWebinyList\";\n\nexport function WebinyListPlugin(): null {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n if (!editor.hasNodes([WebinyListNode, WebinyListItemNode])) {\n throw new Error(\n \"WebinyListPlugin: WebinyListNode and/or WebinyListItemNode not registered on editor\"\n );\n }\n }, [editor]);\n\n useWebinyList(editor);\n\n return null;\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEO,SAASA,gBAAgB,GAAS;EACrC,4BAAiB,IAAAC,iDAAyB,GAAE;IAAA;IAArCC,MAAM;EAEb,IAAAC,gBAAS,EAAC,YAAM;IACZ,IAAI,CAACD,MAAM,CAACE,QAAQ,CAAC,CAACC,8BAAc,EAAEC,sCAAkB,CAAC,CAAC,EAAE;MACxD,MAAM,IAAIC,KAAK,CACX,qFAAqF,CACxF;IACL;EACJ,CAAC,EAAE,CAACL,MAAM,CAAC,CAAC;EAEZ,IAAAM,4BAAa,EAACN,MAAM,CAAC;EAErB,OAAO,IAAI;AACf"}
1
+ {"version":3,"names":["WebinyListPlugin","useLexicalComposerContext","editor","useEffect","hasNodes","ListNode","ListItemNode","Error","useList"],"sources":["WebinyListPlugin.ts"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { useEffect } from \"react\";\nimport { ListNode } from \"~/nodes/ListNode\";\nimport { ListItemNode } from \"~/nodes/ListItemNode\";\nimport { useList } from \"~/hooks/useList\";\n\nexport function WebinyListPlugin(): null {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n if (!editor.hasNodes([ListNode, ListItemNode])) {\n throw new Error(\n \"WebinyListPlugin: WebinyListNode and/or WebinyListItemNode not registered on editor\"\n );\n }\n }, [editor]);\n\n useList(editor);\n\n return null;\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEO,SAASA,gBAAgB,GAAS;EACrC,4BAAiB,IAAAC,iDAAyB,GAAE;IAAA;IAArCC,MAAM;EAEb,IAAAC,gBAAS,EAAC,YAAM;IACZ,IAAI,CAACD,MAAM,CAACE,QAAQ,CAAC,CAACC,kBAAQ,EAAEC,0BAAY,CAAC,CAAC,EAAE;MAC5C,MAAM,IAAIC,KAAK,CACX,qFAAqF,CACxF;IACL;EACJ,CAAC,EAAE,CAACL,MAAM,CAAC,CAAC;EAEZ,IAAAM,gBAAO,EAACN,MAAM,CAAC;EAEf,OAAO,IAAI;AACf"}
package/types.d.ts CHANGED
@@ -19,6 +19,7 @@ export declare type ToolbarState = {
19
19
  underline: boolean;
20
20
  italic: boolean;
21
21
  code: boolean;
22
+ isRTL: boolean;
22
23
  link: NodeState;
23
24
  typography: NodeState;
24
25
  fontColor: NodeState;
@@ -36,6 +37,7 @@ export declare type TextBlockSelection = {
36
37
  node: ElementNode | TextNode;
37
38
  anchorNode: ElementNode | TextNode;
38
39
  isElementDom: boolean;
40
+ selectedText: string;
39
41
  state: ToolbarState | undefined;
40
42
  };
41
43
  export declare type ListHtmlTag = "ol" | "ul";
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { ElementNode, LexicalNode, NodeSelection, RangeSelection, TextNode } from \"lexical\";\nimport { ListType } from \"@lexical/list\";\nimport { CSSObject } from \"@emotion/react\";\nexport type ToolbarType = \"heading\" | \"paragraph\" | string;\nexport type LexicalValue = string;\nexport { FontColorPicker } from \"~/components/ToolbarActions/FontColorAction\";\n\nexport type LexicalTextType =\n | ListType\n | \"paragraph\"\n | \"heading\"\n | \"quoteblock\"\n | \"bullet\"\n | \"number\"\n | \"link\"\n | undefined;\n\nexport type TextFormatting = {\n bold: boolean;\n underline: boolean;\n italic: boolean;\n // highlight: boolean #TODO implement with highlight action\n code: boolean;\n};\n\nexport type NodeState = {\n isSelected: boolean;\n};\n\nexport type ToolbarState = {\n // text format\n bold: boolean;\n underline: boolean;\n italic: boolean;\n code: boolean;\n // nodes selection state\n link: NodeState;\n typography: NodeState;\n fontColor: NodeState;\n list: NodeState;\n quote: NodeState;\n textType: LexicalTextType;\n paragraph: NodeState;\n heading: NodeState;\n};\n\n/*\n * Represent set of data from the current selection of the text and nodes selected by the user.\n * You can access this object through the @see useRichTextEditor context.\n */\nexport type TextBlockSelection = {\n elementKey?: string;\n selection: RangeSelection | NodeSelection | null;\n element: LexicalNode;\n parent: ElementNode | null;\n node: ElementNode | TextNode;\n anchorNode: ElementNode | TextNode;\n isElementDom: boolean;\n state: ToolbarState | undefined;\n};\n\n// Supported HTML tags by webiny lexical implementation\nexport type ListHtmlTag = \"ol\" | \"ul\";\nexport type HeadingHtmlTag = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\nexport type ParagraphHtmlTag = \"p\";\nexport type QuoteBlockHtmlTag = \"quoteblock\";\n\n// Typography\nexport type TypographyHTMLTag = HeadingHtmlTag | ParagraphHtmlTag | ListHtmlTag | QuoteBlockHtmlTag;\n\nexport type TypographyValue = {\n // CSSObject type\n css: CSSObject;\n id: string;\n tag: TypographyHTMLTag;\n // Display name\n name: string;\n};\n\n/* Nodes */\n\n/*\n * Contains IDs of the styles and Emotion generated classes.\n */\nexport type ThemeEmotionMap = {\n [styleId: string]: {\n id: string;\n tag: TypographyHTMLTag;\n name: string;\n styles: Record<string, any>;\n // emotion generated class\n className: string;\n };\n};\n"],"mappings":";;;;;;;;;;;AAKA"}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { ElementNode, LexicalNode, NodeSelection, RangeSelection, TextNode } from \"lexical\";\nimport { ListType } from \"@lexical/list\";\nimport { CSSObject } from \"@emotion/react\";\nexport type ToolbarType = \"heading\" | \"paragraph\" | string;\nexport type LexicalValue = string;\nexport { FontColorPicker } from \"~/components/ToolbarActions/FontColorAction\";\n\nexport type LexicalTextType =\n | ListType\n | \"paragraph\"\n | \"heading\"\n | \"quoteblock\"\n | \"bullet\"\n | \"number\"\n | \"link\"\n | undefined;\n\nexport type TextFormatting = {\n bold: boolean;\n underline: boolean;\n italic: boolean;\n // highlight: boolean #TODO implement with highlight action\n code: boolean;\n};\n\nexport type NodeState = {\n isSelected: boolean;\n};\n\nexport type ToolbarState = {\n // text format\n bold: boolean;\n underline: boolean;\n italic: boolean;\n code: boolean;\n // is direction of the text right-to-left\n isRTL: boolean;\n // nodes selection state\n link: NodeState;\n typography: NodeState;\n fontColor: NodeState;\n list: NodeState;\n quote: NodeState;\n textType: LexicalTextType;\n paragraph: NodeState;\n heading: NodeState;\n};\n\n/*\n * Represent set of data from the current selection of the text and nodes selected by the user.\n * You can access this object through the @see useRichTextEditor context.\n */\nexport type TextBlockSelection = {\n elementKey?: string;\n selection: RangeSelection | NodeSelection | null;\n element: LexicalNode;\n parent: ElementNode | null;\n node: ElementNode | TextNode;\n anchorNode: ElementNode | TextNode;\n isElementDom: boolean;\n selectedText: string;\n state: ToolbarState | undefined;\n};\n\n// Supported HTML tags by webiny lexical implementation\nexport type ListHtmlTag = \"ol\" | \"ul\";\nexport type HeadingHtmlTag = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\nexport type ParagraphHtmlTag = \"p\";\nexport type QuoteBlockHtmlTag = \"quoteblock\";\n\n// Typography\nexport type TypographyHTMLTag = HeadingHtmlTag | ParagraphHtmlTag | ListHtmlTag | QuoteBlockHtmlTag;\n\nexport type TypographyValue = {\n // CSSObject type\n css: CSSObject;\n id: string;\n tag: TypographyHTMLTag;\n // Display name\n name: string;\n};\n\n/* Nodes */\n\n/*\n * Contains IDs of the styles and Emotion generated classes.\n */\nexport type ThemeEmotionMap = {\n [styleId: string]: {\n id: string;\n tag: TypographyHTMLTag;\n name: string;\n styles: Record<string, any>;\n // emotion generated class\n className: string;\n };\n};\n"],"mappings":";;;;;;;;;;;AAKA"}
@@ -10,13 +10,14 @@ var _lexical = require("lexical");
10
10
  var _utils = require("@lexical/utils");
11
11
  var _getSelectedNode = require("./getSelectedNode");
12
12
  var _link = require("@lexical/link");
13
- var _WebinyListNode = require("../nodes/list-node/WebinyListNode");
13
+ var _ListNode = require("../nodes/ListNode");
14
14
  var _richText = require("@lexical/rich-text");
15
15
  var _TypographyElementNode = require("../nodes/TypographyElementNode");
16
16
  var _FontColorNode = require("../nodes/FontColorNode");
17
17
  var _ParagraphNode = require("../nodes/ParagraphNode");
18
18
  var _HeadingNode = require("../nodes/HeadingNode");
19
19
  var _QuoteNode = require("../nodes/QuoteNode");
20
+ var _selection = require("@lexical/selection");
20
21
  var getSelectionTextFormat = function getSelectionTextFormat(selection) {
21
22
  return !(0, _lexical.$isRangeSelection)(selection) ? {
22
23
  italic: false,
@@ -37,6 +38,7 @@ var getDefaultToolbarState = function getDefaultToolbarState() {
37
38
  italic: false,
38
39
  underline: false,
39
40
  code: false,
41
+ isRTL: false,
40
42
  link: {
41
43
  isSelected: false
42
44
  },
@@ -70,18 +72,20 @@ var getToolbarState = function getToolbarState(selection, node, parent, element,
70
72
  underline: textFormat.underline,
71
73
  code: textFormat.code
72
74
  });
75
+ state.isRTL = (0, _selection.$isParentElementRTL)(selection);
73
76
 
74
77
  // link
75
78
  state.link.isSelected = (0, _link.$isLinkNode)(parent) || (0, _link.$isLinkNode)(node);
76
79
  if (state.link.isSelected) {
77
80
  state.textType = "link";
78
81
  }
82
+
79
83
  // font color
80
84
  if ((0, _FontColorNode.$isFontColorNode)(node)) {
81
85
  state.fontColor.isSelected = true;
82
86
  }
83
- if ((0, _WebinyListNode.$isWebinyListNode)(element)) {
84
- var parentList = (0, _utils.$getNearestNodeOfType)(anchorNode, _WebinyListNode.WebinyListNode);
87
+ if ((0, _ListNode.$isListNode)(element)) {
88
+ var parentList = (0, _utils.$getNearestNodeOfType)(anchorNode, _ListNode.ListNode);
85
89
  var type = parentList ? parentList.getListType() : element.getListType();
86
90
  state.textType = type;
87
91
  }
@@ -140,6 +144,7 @@ var getLexicalTextSelectionState = function getLexicalTextSelectionState(activeE
140
144
  var node = (0, _getSelectedNode.getSelectedNode)(selection);
141
145
  var parent = node.getParent();
142
146
  var isElementDom = elementDOM !== null;
147
+ var selectedText = selection.getTextContent();
143
148
  return {
144
149
  // node/element data from selection
145
150
  elementKey: elementKey,
@@ -149,6 +154,7 @@ var getLexicalTextSelectionState = function getLexicalTextSelectionState(activeE
149
154
  anchorNode: anchorNode,
150
155
  selection: selection,
151
156
  isElementDom: isElementDom,
157
+ selectedText: selectedText,
152
158
  state: getToolbarState(selection, node, parent, element, anchorNode)
153
159
  };
154
160
  }