@payloadcms/richtext-lexical 3.0.0-beta.35 → 3.0.0-beta.36

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 (235) hide show
  1. package/dist/cell/index.d.ts +2 -0
  2. package/dist/cell/index.d.ts.map +1 -1
  3. package/dist/cell/index.js +24 -15
  4. package/dist/cell/index.js.map +1 -1
  5. package/dist/field/Field.d.ts.map +1 -1
  6. package/dist/field/Field.js +66 -47
  7. package/dist/field/Field.js.map +1 -1
  8. package/dist/field/features/blocks/component/BlockContent.js +62 -45
  9. package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
  10. package/dist/field/features/blocks/component/index.js +38 -28
  11. package/dist/field/features/blocks/component/index.js.map +1 -1
  12. package/dist/field/features/blocks/drawer/index.js +2 -1
  13. package/dist/field/features/blocks/drawer/index.js.map +1 -1
  14. package/dist/field/features/blocks/nodes/BlocksNode.d.ts +1 -1
  15. package/dist/field/features/blocks/nodes/BlocksNode.d.ts.map +1 -1
  16. package/dist/field/features/blocks/nodes/BlocksNode.js +2 -1
  17. package/dist/field/features/blocks/nodes/BlocksNode.js.map +1 -1
  18. package/dist/field/features/blocks/plugin/index.js +2 -1
  19. package/dist/field/features/blocks/plugin/index.js.map +1 -1
  20. package/dist/field/features/debug/testRecorder/plugin/index.js +65 -39
  21. package/dist/field/features/debug/testRecorder/plugin/index.js.map +1 -1
  22. package/dist/field/features/debug/treeView/plugin/index.js +2 -1
  23. package/dist/field/features/debug/treeView/plugin/index.js.map +1 -1
  24. package/dist/field/features/horizontalRule/nodes/HorizontalRuleNode.js +2 -1
  25. package/dist/field/features/horizontalRule/nodes/HorizontalRuleNode.js.map +1 -1
  26. package/dist/field/features/link/drawer/index.js +30 -22
  27. package/dist/field/features/link/drawer/index.js.map +1 -1
  28. package/dist/field/features/link/plugins/clickableLink/index.js +2 -1
  29. package/dist/field/features/link/plugins/clickableLink/index.js.map +1 -1
  30. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  31. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +88 -70
  32. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  33. package/dist/field/features/link/plugins/floatingLinkEditor/index.js +2 -1
  34. package/dist/field/features/link/plugins/floatingLinkEditor/index.js.map +1 -1
  35. package/dist/field/features/lists/checklist/plugin/index.js +2 -1
  36. package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
  37. package/dist/field/features/lists/plugin/index.js +2 -1
  38. package/dist/field/features/lists/plugin/index.js.map +1 -1
  39. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +9 -1
  40. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
  41. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
  42. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  43. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +2 -1
  44. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  45. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +9 -1
  46. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
  47. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
  48. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  49. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +2 -1
  50. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  51. package/dist/field/features/relationship/drawer/index.js +10 -2
  52. package/dist/field/features/relationship/drawer/index.js.map +1 -1
  53. package/dist/field/features/relationship/nodes/RelationshipNode.d.ts +1 -1
  54. package/dist/field/features/relationship/nodes/RelationshipNode.d.ts.map +1 -1
  55. package/dist/field/features/relationship/nodes/RelationshipNode.js +2 -1
  56. package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
  57. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +64 -44
  58. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  59. package/dist/field/features/relationship/plugins/index.js +2 -1
  60. package/dist/field/features/relationship/plugins/index.js.map +1 -1
  61. package/dist/field/features/toolbars/fixed/Toolbar/index.js +60 -55
  62. package/dist/field/features/toolbars/fixed/Toolbar/index.js.map +1 -1
  63. package/dist/field/features/toolbars/fixed/Toolbar/index.scss +16 -2
  64. package/dist/field/features/toolbars/inline/Toolbar/index.js +57 -49
  65. package/dist/field/features/toolbars/inline/Toolbar/index.js.map +1 -1
  66. package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts +1 -1
  67. package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  68. package/dist/field/features/toolbars/shared/ToolbarButton/index.js +5 -3
  69. package/dist/field/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  70. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  71. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js +54 -35
  72. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  73. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts +1 -1
  74. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  75. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js +25 -22
  76. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  77. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +30 -22
  78. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
  79. package/dist/field/features/upload/component/index.js +104 -71
  80. package/dist/field/features/upload/component/index.js.map +1 -1
  81. package/dist/field/features/upload/drawer/index.js +8 -4
  82. package/dist/field/features/upload/drawer/index.js.map +1 -1
  83. package/dist/field/features/upload/nodes/UploadNode.d.ts +1 -1
  84. package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
  85. package/dist/field/features/upload/nodes/UploadNode.js +2 -1
  86. package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
  87. package/dist/field/features/upload/plugin/index.js +2 -1
  88. package/dist/field/features/upload/plugin/index.js.map +1 -1
  89. package/dist/field/index.d.ts +2 -0
  90. package/dist/field/index.d.ts.map +1 -1
  91. package/dist/field/index.js +29 -21
  92. package/dist/field/index.js.map +1 -1
  93. package/dist/field/index.scss +0 -19
  94. package/dist/field/lexical/EditorFocusProvider.d.ts +1 -2
  95. package/dist/field/lexical/EditorFocusProvider.d.ts.map +1 -1
  96. package/dist/field/lexical/EditorFocusProvider.js +5 -3
  97. package/dist/field/lexical/EditorFocusProvider.js.map +1 -1
  98. package/dist/field/lexical/EditorPlugin.js +3 -2
  99. package/dist/field/lexical/EditorPlugin.js.map +1 -1
  100. package/dist/field/lexical/LexicalEditor.js +113 -81
  101. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  102. package/dist/field/lexical/LexicalEditor.scss +10 -1
  103. package/dist/field/lexical/LexicalProvider.js +16 -10
  104. package/dist/field/lexical/LexicalProvider.js.map +1 -1
  105. package/dist/field/lexical/config/client/EditorConfigProvider.js +5 -3
  106. package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
  107. package/dist/field/lexical/config/client/sanitize.d.ts +2 -1
  108. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  109. package/dist/field/lexical/config/client/sanitize.js +2 -1
  110. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  111. package/dist/field/lexical/config/types.d.ts +2 -0
  112. package/dist/field/lexical/config/types.d.ts.map +1 -1
  113. package/dist/field/lexical/config/types.js.map +1 -1
  114. package/dist/field/lexical/plugins/MarkdownShortcut/index.js +2 -1
  115. package/dist/field/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  116. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +1 -1
  117. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  118. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  119. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +1 -1
  120. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  121. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +2 -1
  122. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  123. package/dist/field/lexical/plugins/SlashMenu/index.js +51 -40
  124. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  125. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts +2 -2
  126. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
  127. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js +38 -119
  128. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  129. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.scss +2 -2
  130. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.d.ts +1 -1
  131. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.d.ts.map +1 -1
  132. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.js.map +1 -1
  133. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts +2 -2
  134. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  135. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +102 -58
  136. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  137. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.scss +12 -3
  138. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts +8 -1
  139. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
  140. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +73 -25
  141. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
  142. package/dist/field/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.d.ts +5 -0
  143. package/dist/field/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.d.ts.map +1 -0
  144. package/dist/field/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.js +21 -0
  145. package/dist/field/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.js.map +1 -0
  146. package/dist/field/lexical/plugins/handles/{DraggableBlockPlugin → utils}/getNodeCloseToPoint.d.ts +4 -0
  147. package/dist/field/lexical/plugins/handles/utils/getNodeCloseToPoint.d.ts.map +1 -0
  148. package/dist/field/lexical/plugins/handles/{DraggableBlockPlugin → utils}/getNodeCloseToPoint.js +2 -14
  149. package/dist/field/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -0
  150. package/dist/field/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  151. package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js +4 -2
  152. package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  153. package/dist/field/lexical/theme/EditorTheme.scss +5 -0
  154. package/dist/field/lexical/ui/ContentEditable.d.ts +1 -1
  155. package/dist/field/lexical/ui/ContentEditable.d.ts.map +1 -1
  156. package/dist/field/lexical/ui/ContentEditable.js +2 -1
  157. package/dist/field/lexical/ui/ContentEditable.js.map +1 -1
  158. package/dist/field/lexical/ui/ContentEditable.scss +50 -2
  159. package/dist/field/lexical/ui/icons/AI/index.js +26 -17
  160. package/dist/field/lexical/ui/icons/AI/index.js.map +1 -1
  161. package/dist/field/lexical/ui/icons/Add/index.js +14 -9
  162. package/dist/field/lexical/ui/icons/Add/index.js.map +1 -1
  163. package/dist/field/lexical/ui/icons/Add/light.svg +4 -0
  164. package/dist/field/lexical/ui/icons/AlignCenter/index.js +21 -15
  165. package/dist/field/lexical/ui/icons/AlignCenter/index.js.map +1 -1
  166. package/dist/field/lexical/ui/icons/AlignJustify/index.js +21 -15
  167. package/dist/field/lexical/ui/icons/AlignJustify/index.js.map +1 -1
  168. package/dist/field/lexical/ui/icons/AlignLeft/index.js +21 -15
  169. package/dist/field/lexical/ui/icons/AlignLeft/index.js.map +1 -1
  170. package/dist/field/lexical/ui/icons/AlignRight/index.js +21 -15
  171. package/dist/field/lexical/ui/icons/AlignRight/index.js.map +1 -1
  172. package/dist/field/lexical/ui/icons/Block/index.js +30 -24
  173. package/dist/field/lexical/ui/icons/Block/index.js.map +1 -1
  174. package/dist/field/lexical/ui/icons/Blockquote/index.js +8 -6
  175. package/dist/field/lexical/ui/icons/Blockquote/index.js.map +1 -1
  176. package/dist/field/lexical/ui/icons/Bold/index.js +8 -6
  177. package/dist/field/lexical/ui/icons/Bold/index.js.map +1 -1
  178. package/dist/field/lexical/ui/icons/Checklist/index.js +19 -14
  179. package/dist/field/lexical/ui/icons/Checklist/index.js.map +1 -1
  180. package/dist/field/lexical/ui/icons/Code/index.js +14 -9
  181. package/dist/field/lexical/ui/icons/Code/index.js.map +1 -1
  182. package/dist/field/lexical/ui/icons/CodeBlock/index.js +14 -9
  183. package/dist/field/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  184. package/dist/field/lexical/ui/icons/DraggableBlock/light.svg +9 -0
  185. package/dist/field/lexical/ui/icons/H1/index.js +8 -6
  186. package/dist/field/lexical/ui/icons/H1/index.js.map +1 -1
  187. package/dist/field/lexical/ui/icons/H2/index.js +8 -6
  188. package/dist/field/lexical/ui/icons/H2/index.js.map +1 -1
  189. package/dist/field/lexical/ui/icons/H3/index.js +8 -6
  190. package/dist/field/lexical/ui/icons/H3/index.js.map +1 -1
  191. package/dist/field/lexical/ui/icons/H4/index.js +8 -6
  192. package/dist/field/lexical/ui/icons/H4/index.js.map +1 -1
  193. package/dist/field/lexical/ui/icons/H5/index.js +8 -6
  194. package/dist/field/lexical/ui/icons/H5/index.js.map +1 -1
  195. package/dist/field/lexical/ui/icons/H6/index.js +8 -6
  196. package/dist/field/lexical/ui/icons/H6/index.js.map +1 -1
  197. package/dist/field/lexical/ui/icons/HorizontalRule/index.js +11 -9
  198. package/dist/field/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
  199. package/dist/field/lexical/ui/icons/IndentDecrease/index.js +25 -18
  200. package/dist/field/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
  201. package/dist/field/lexical/ui/icons/IndentIncrease/index.js +25 -18
  202. package/dist/field/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
  203. package/dist/field/lexical/ui/icons/Italic/index.js +8 -6
  204. package/dist/field/lexical/ui/icons/Italic/index.js.map +1 -1
  205. package/dist/field/lexical/ui/icons/Link/index.js +26 -17
  206. package/dist/field/lexical/ui/icons/Link/index.js.map +1 -1
  207. package/dist/field/lexical/ui/icons/OrderedList/index.js +29 -21
  208. package/dist/field/lexical/ui/icons/OrderedList/index.js.map +1 -1
  209. package/dist/field/lexical/ui/icons/Relationship/index.js +26 -17
  210. package/dist/field/lexical/ui/icons/Relationship/index.js.map +1 -1
  211. package/dist/field/lexical/ui/icons/Strikethrough/index.js +14 -9
  212. package/dist/field/lexical/ui/icons/Strikethrough/index.js.map +1 -1
  213. package/dist/field/lexical/ui/icons/Subscript/index.js +8 -6
  214. package/dist/field/lexical/ui/icons/Subscript/index.js.map +1 -1
  215. package/dist/field/lexical/ui/icons/Superscript/index.js +8 -6
  216. package/dist/field/lexical/ui/icons/Superscript/index.js.map +1 -1
  217. package/dist/field/lexical/ui/icons/Text/index.js +8 -6
  218. package/dist/field/lexical/ui/icons/Text/index.js.map +1 -1
  219. package/dist/field/lexical/ui/icons/Underline/index.js +14 -9
  220. package/dist/field/lexical/ui/icons/Underline/index.js.map +1 -1
  221. package/dist/field/lexical/ui/icons/UnorderedList/index.js +45 -36
  222. package/dist/field/lexical/ui/icons/UnorderedList/index.js.map +1 -1
  223. package/dist/field/lexical/ui/icons/Upload/index.js +24 -18
  224. package/dist/field/lexical/ui/icons/Upload/index.js.map +1 -1
  225. package/dist/generateComponentMap.js +8 -8
  226. package/dist/generateComponentMap.js.map +1 -1
  227. package/dist/index.d.ts.map +1 -1
  228. package/dist/index.js +2 -0
  229. package/dist/index.js.map +1 -1
  230. package/dist/types.d.ts +7 -0
  231. package/dist/types.d.ts.map +1 -1
  232. package/dist/types.js.map +1 -1
  233. package/package.json +17 -13
  234. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +0 -1
  235. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.tsx"],"sourcesContent":["import type { SerializedLexicalNode, Spread } from 'lexical'\nimport type { EditorConfig, LexicalNode, NodeKey } from 'lexical'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { DecoratorNode } from 'lexical'\nimport * as React from 'react'\n\nexport type UnknownConvertedNodeData = {\n nodeData: unknown\n nodeType: string\n}\n\nexport type SerializedUnknownConvertedNode = Spread<\n {\n data: UnknownConvertedNodeData\n },\n SerializedLexicalNode\n>\n\nconst Component = React.lazy(() =>\n import('./Component.js').then((module) => ({\n default: module.UnknownConvertedNodeComponent,\n })),\n)\n\n/** @noInheritDoc */\nexport class UnknownConvertedNode extends DecoratorNode<JSX.Element> {\n __data: UnknownConvertedNodeData\n\n constructor({ data, key }: { data: UnknownConvertedNodeData; key?: NodeKey }) {\n super(key)\n this.__data = data\n }\n\n static clone(node: UnknownConvertedNode): UnknownConvertedNode {\n return new UnknownConvertedNode({\n data: node.__data,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'unknownConverted'\n }\n\n static importJSON(serializedNode: SerializedUnknownConvertedNode): UnknownConvertedNode {\n const node = $createUnknownConvertedNode({ data: serializedNode.data })\n return node\n }\n\n canInsertTextAfter(): true {\n return true\n }\n\n canInsertTextBefore(): true {\n return true\n }\n\n createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, 'unknownConverted')\n return element\n }\n\n decorate(): JSX.Element | null {\n return <Component data={this.__data} />\n }\n\n exportJSON(): SerializedUnknownConvertedNode {\n return {\n type: this.getType(),\n data: this.__data,\n version: 1,\n }\n }\n\n // Mutation\n\n isInline(): boolean {\n return true\n }\n\n updateDOM(prevNode: UnknownConvertedNode, dom: HTMLElement): boolean {\n return false\n }\n}\n\nexport function $createUnknownConvertedNode({\n data,\n}: {\n data: UnknownConvertedNodeData\n}): UnknownConvertedNode {\n return new UnknownConvertedNode({\n data,\n })\n}\n\nexport function $isUnknownConvertedNode(\n node: LexicalNode | null | undefined,\n): node is UnknownConvertedNode {\n return node instanceof UnknownConvertedNode\n}\n"],"names":["addClassNamesToElement","DecoratorNode","React","Component","lazy","then","module","default","UnknownConvertedNodeComponent","UnknownConvertedNode","__data","constructor","data","key","clone","node","__key","getType","importJSON","serializedNode","$createUnknownConvertedNode","canInsertTextAfter","canInsertTextBefore","createDOM","config","element","document","createElement","decorate","exportJSON","type","version","isInline","updateDOM","prevNode","dom","$isUnknownConvertedNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,SAASC,aAAa,QAAQ,UAAS;AACvC,YAAYC,WAAW,QAAO;AAc9B,MAAMC,0BAA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src/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.tsx"],"sourcesContent":["import type { SerializedLexicalNode, Spread } from 'lexical'\nimport type { EditorConfig, LexicalNode, NodeKey } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { DecoratorNode } from 'lexical'\nimport * as React from 'react'\n\nexport type UnknownConvertedNodeData = {\n nodeData: unknown\n nodeType: string\n}\n\nexport type SerializedUnknownConvertedNode = Spread<\n {\n data: UnknownConvertedNodeData\n },\n SerializedLexicalNode\n>\n\nconst Component = React.lazy(() =>\n import('./Component.js').then((module) => ({\n default: module.UnknownConvertedNodeComponent,\n })),\n)\n\n/** @noInheritDoc */\nexport class UnknownConvertedNode extends DecoratorNode<JSX.Element> {\n __data: UnknownConvertedNodeData\n\n constructor({ data, key }: { data: UnknownConvertedNodeData; key?: NodeKey }) {\n super(key)\n this.__data = data\n }\n\n static clone(node: UnknownConvertedNode): UnknownConvertedNode {\n return new UnknownConvertedNode({\n data: node.__data,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'unknownConverted'\n }\n\n static importJSON(serializedNode: SerializedUnknownConvertedNode): UnknownConvertedNode {\n const node = $createUnknownConvertedNode({ data: serializedNode.data })\n return node\n }\n\n canInsertTextAfter(): true {\n return true\n }\n\n canInsertTextBefore(): true {\n return true\n }\n\n createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, 'unknownConverted')\n return element\n }\n\n decorate(): JSX.Element | null {\n return <Component data={this.__data} />\n }\n\n exportJSON(): SerializedUnknownConvertedNode {\n return {\n type: this.getType(),\n data: this.__data,\n version: 1,\n }\n }\n\n // Mutation\n\n isInline(): boolean {\n return true\n }\n\n updateDOM(prevNode: UnknownConvertedNode, dom: HTMLElement): boolean {\n return false\n }\n}\n\nexport function $createUnknownConvertedNode({\n data,\n}: {\n data: UnknownConvertedNodeData\n}): UnknownConvertedNode {\n return new UnknownConvertedNode({\n data,\n })\n}\n\nexport function $isUnknownConvertedNode(\n node: LexicalNode | null | undefined,\n): node is UnknownConvertedNode {\n return node instanceof UnknownConvertedNode\n}\n"],"names":["addClassNamesToElement","DecoratorNode","React","Component","lazy","then","module","default","UnknownConvertedNodeComponent","UnknownConvertedNode","__data","constructor","data","key","clone","node","__key","getType","importJSON","serializedNode","$createUnknownConvertedNode","canInsertTextAfter","canInsertTextBefore","createDOM","config","element","document","createElement","decorate","exportJSON","type","version","isInline","updateDOM","prevNode","dom","$isUnknownConvertedNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAIA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,SAASC,aAAa,QAAQ,UAAS;AACvC,YAAYC,WAAW,QAAO;AAc9B,MAAMC,0BAAYD,MAAME,IAAI,CAAC,IAC3B,MAAM,CAAC,kBAAkBC,IAAI,CAAC,CAACC,SAAY,CAAA;YACzCC,SAASD,OAAOE,6BAA6B;QAC/C,CAAA;AAGF,kBAAkB,GAClB,OAAO,MAAMC,6BAA6BR;IACxCS,OAAgC;IAEhCC,YAAY,EAAEC,IAAI,EAAEC,GAAG,EAAqD,CAAE;QAC5E,KAAK,CAACA;QACN,IAAI,CAACH,MAAM,GAAGE;IAChB;IAEA,OAAOE,MAAMC,IAA0B,EAAwB;QAC7D,OAAO,IAAIN,qBAAqB;YAC9BG,MAAMG,KAAKL,MAAM;YACjBG,KAAKE,KAAKC,KAAK;QACjB;IACF;IAEA,OAAOC,UAAkB;QACvB,OAAO;IACT;IAEA,OAAOC,WAAWC,cAA8C,EAAwB;QACtF,MAAMJ,OAAOK,4BAA4B;YAAER,MAAMO,eAAeP,IAAI;QAAC;QACrE,OAAOG;IACT;IAEAM,qBAA2B;QACzB,OAAO;IACT;IAEAC,sBAA4B;QAC1B,OAAO;IACT;IAEAC,UAAUC,MAAoB,EAAe;QAC3C,MAAMC,UAAUC,SAASC,aAAa,CAAC;QACvC3B,uBAAuByB,SAAS;QAChC,OAAOA;IACT;IAEAG,WAA+B;QAC7B,qBAAO,KAACzB;YAAUS,MAAM,IAAI,CAACF,MAAM;;IACrC;IAEAmB,aAA6C;QAC3C,OAAO;YACLC,MAAM,IAAI,CAACb,OAAO;YAClBL,MAAM,IAAI,CAACF,MAAM;YACjBqB,SAAS;QACX;IACF;IAEA,WAAW;IAEXC,WAAoB;QAClB,OAAO;IACT;IAEAC,UAAUC,QAA8B,EAAEC,GAAgB,EAAW;QACnE,OAAO;IACT;AACF;AAEA,OAAO,SAASf,4BAA4B,EAC1CR,IAAI,EAGL;IACC,OAAO,IAAIH,qBAAqB;QAC9BG;IACF;AACF;AAEA,OAAO,SAASwB,wBACdrB,IAAoC;IAEpC,OAAOA,gBAAgBN;AACzB"}
@@ -1,8 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import React from 'react';
2
3
  import './index.scss';
3
4
  export const UnknownConvertedNodeComponent = (props)=>{
4
5
  const { data } = props;
5
- return /*#__PURE__*/ React.createElement("div", null, "Unknown converted Slate node: ", /*#__PURE__*/ React.createElement("strong", null, data?.nodeType));
6
+ return /*#__PURE__*/ _jsxs("div", {
7
+ children: [
8
+ "Unknown converted Slate node: ",
9
+ /*#__PURE__*/ _jsx("strong", {
10
+ children: data?.nodeType
11
+ })
12
+ ]
13
+ });
6
14
  };
7
15
 
8
16
  //# sourceMappingURL=Component.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.tsx"],"sourcesContent":["import React from 'react'\n\nimport type { UnknownConvertedNodeData } from './index.js'\n\nimport './index.scss'\n\ntype Props = {\n data: UnknownConvertedNodeData\n}\n\nexport const UnknownConvertedNodeComponent: React.FC<Props> = (props) => {\n const { data } = props\n\n return (\n <div>\n Unknown converted Slate node: <strong>{data?.nodeType}</strong>\n </div>\n )\n}\n"],"names":["React","UnknownConvertedNodeComponent","props","data","div","strong","nodeType"],"rangeMappings":";;;;;","mappings":"AAAA,OAAOA,WAAW,QAAO;AAIzB,OAAO,eAAc;AAMrB,OAAO,MAAMC,gCAAiD,CAACC;IAC7D,MAAM,EAAEC,IAAI,EAAE,GAAGD;IAEjB,qBACE,oBAACE,aAAI,gDAC2B,oBAACC,gBAAQF,MAAMG;AAGnD,EAAC"}
1
+ {"version":3,"sources":["../../../../../../../src/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.tsx"],"sourcesContent":["import React from 'react'\n\nimport type { UnknownConvertedNodeData } from './index.js'\n\nimport './index.scss'\n\ntype Props = {\n data: UnknownConvertedNodeData\n}\n\nexport const UnknownConvertedNodeComponent: React.FC<Props> = (props) => {\n const { data } = props\n\n return (\n <div>\n Unknown converted Slate node: <strong>{data?.nodeType}</strong>\n </div>\n )\n}\n"],"names":["React","UnknownConvertedNodeComponent","props","data","div","strong","nodeType"],"rangeMappings":";;;;;;;;;;;;;","mappings":";AAAA,OAAOA,WAAW,QAAO;AAIzB,OAAO,eAAc;AAMrB,OAAO,MAAMC,gCAAiD,CAACC;IAC7D,MAAM,EAAEC,IAAI,EAAE,GAAGD;IAEjB,qBACE,MAACE;;YAAI;0BAC2B,KAACC;0BAAQF,MAAMG;;;;AAGnD,EAAC"}
@@ -1,6 +1,6 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import type { SerializedLexicalNode, Spread } from 'lexical';
3
2
  import type { EditorConfig, LexicalNode, NodeKey } from 'lexical';
3
+ import type { JSX } from 'react';
4
4
  import { DecoratorNode } from 'lexical';
5
5
  export type UnknownConvertedNodeData = {
6
6
  nodeData: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC5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oBAAoB,CAE9B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAGvC,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG,MAAM,CACjD;IACE,IAAI,EAAE,wBAAwB,CAAA;CAC/B,EACD,qBAAqB,CACtB,CAAA;AAQD,oBAAoB;AACpB,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC;IAClE,MAAM,EAAE,wBAAwB,CAAA;gBAEpB,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE;IAK5E,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,oBAAoB,GAAG,oBAAoB;IAO9D,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,8BAA8B,GAAG,oBAAoB;IAKvF,kBAAkB,IAAI,IAAI;IAI1B,mBAAmB,IAAI,IAAI;IAI3B,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAM5C,QAAQ,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI;IAI9B,UAAU,IAAI,8BAA8B;IAU5C,QAAQ,IAAI,OAAO;IAInB,SAAS,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO;CAGrE;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,GACL,EAAE;IACD,IAAI,EAAE,wBAAwB,CAAA;CAC/B,GAAG,oBAAoB,CAIvB;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,oBAAoB,CAE9B"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { addClassNamesToElement } from '@lexical/utils';
2
3
  import { DecoratorNode } from 'lexical';
3
4
  import * as React from 'react';
@@ -37,7 +38,7 @@ const Component = /*#__PURE__*/ React.lazy(()=>import('./Component.js').then((mo
37
38
  return element;
38
39
  }
39
40
  decorate() {
40
- return /*#__PURE__*/ React.createElement(Component, {
41
+ return /*#__PURE__*/ _jsx(Component, {
41
42
  data: this.__data
42
43
  });
43
44
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"sourcesContent":["import type { SerializedLexicalNode, Spread } from 'lexical'\nimport type { EditorConfig, LexicalNode, NodeKey } from 'lexical'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { DecoratorNode } from 'lexical'\nimport * as React from 'react'\n\nexport type UnknownConvertedNodeData = {\n nodeData: unknown\n nodeType: string\n}\n\nexport type SerializedUnknownConvertedNode = Spread<\n {\n data: UnknownConvertedNodeData\n },\n SerializedLexicalNode\n>\n\nconst Component = React.lazy(() =>\n import('./Component.js').then((module) => ({\n default: module.UnknownConvertedNodeComponent,\n })),\n)\n\n/** @noInheritDoc */\nexport class UnknownConvertedNode extends DecoratorNode<JSX.Element> {\n __data: UnknownConvertedNodeData\n\n constructor({ data, key }: { data: UnknownConvertedNodeData; key?: NodeKey }) {\n super(key)\n this.__data = data\n }\n\n static clone(node: UnknownConvertedNode): UnknownConvertedNode {\n return new UnknownConvertedNode({\n data: node.__data,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'unknownConverted'\n }\n\n static importJSON(serializedNode: SerializedUnknownConvertedNode): UnknownConvertedNode {\n const node = $createUnknownConvertedNode({ data: serializedNode.data })\n return node\n }\n\n canInsertTextAfter(): true {\n return true\n }\n\n canInsertTextBefore(): true {\n return true\n }\n\n createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, 'unknownConverted')\n return element\n }\n\n decorate(): JSX.Element | null {\n return <Component data={this.__data} />\n }\n\n exportJSON(): SerializedUnknownConvertedNode {\n return {\n type: this.getType(),\n data: this.__data,\n version: 1,\n }\n }\n\n // Mutation\n\n isInline(): boolean {\n return true\n }\n\n updateDOM(prevNode: UnknownConvertedNode, dom: HTMLElement): boolean {\n return false\n }\n}\n\nexport function $createUnknownConvertedNode({\n data,\n}: {\n data: UnknownConvertedNodeData\n}): UnknownConvertedNode {\n return new UnknownConvertedNode({\n data,\n })\n}\n\nexport function $isUnknownConvertedNode(\n node: LexicalNode | null | undefined,\n): node is UnknownConvertedNode {\n return node instanceof UnknownConvertedNode\n}\n"],"names":["addClassNamesToElement","DecoratorNode","React","Component","lazy","then","module","default","UnknownConvertedNodeComponent","UnknownConvertedNode","__data","constructor","data","key","clone","node","__key","getType","importJSON","serializedNode","$createUnknownConvertedNode","canInsertTextAfter","canInsertTextBefore","createDOM","config","element","document","createElement","decorate","exportJSON","type","version","isInline","updateDOM","prevNode","dom","$isUnknownConvertedNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,SAASC,aAAa,QAAQ,UAAS;AACvC,YAAYC,WAAW,QAAO;AAc9B,MAAMC,0BAAYD,MAAME,IAAI,CAAC,IAC3B,MAAM,CAAC,kBAAkBC,IAAI,CAAC,CAACC,SAAY,CAAA;YACzCC,SAASD,OAAOE,6BAA6B;QAC/C,CAAA;AAGF,kBAAkB,GAClB,OAAO,MAAMC,6BAA6BR;IACxCS,OAAgC;IAEhCC,YAAY,EAAEC,IAAI,EAAEC,GAAG,EAAqD,CAAE;QAC5E,KAAK,CAACA;QACN,IAAI,CAACH,MAAM,GAAGE;IAChB;IAEA,OAAOE,MAAMC,IAA0B,EAAwB;QAC7D,OAAO,IAAIN,qBAAqB;YAC9BG,MAAMG,KAAKL,MAAM;YACjBG,KAAKE,KAAKC,KAAK;QACjB;IACF;IAEA,OAAOC,UAAkB;QACvB,OAAO;IACT;IAEA,OAAOC,WAAWC,cAA8C,EAAwB;QACtF,MAAMJ,OAAOK,4BAA4B;YAAER,MAAMO,eAAeP,IAAI;QAAC;QACrE,OAAOG;IACT;IAEAM,qBAA2B;QACzB,OAAO;IACT;IAEAC,sBAA4B;QAC1B,OAAO;IACT;IAEAC,UAAUC,MAAoB,EAAe;QAC3C,MAAMC,UAAUC,SAASC,aAAa,CAAC;QACvC3B,uBAAuByB,SAAS;QAChC,OAAOA;IACT;IAEAG,WAA+B;QAC7B,qBAAO,oBAACzB;YAAUS,MAAM,IAAI,CAACF,MAAM;;IACrC;IAEAmB,aAA6C;QAC3C,OAAO;YACLC,MAAM,IAAI,CAACb,OAAO;YAClBL,MAAM,IAAI,CAACF,MAAM;YACjBqB,SAAS;QACX;IACF;IAEA,WAAW;IAEXC,WAAoB;QAClB,OAAO;IACT;IAEAC,UAAUC,QAA8B,EAAEC,GAAgB,EAAW;QACnE,OAAO;IACT;AACF;AAEA,OAAO,SAASf,4BAA4B,EAC1CR,IAAI,EAGL;IACC,OAAO,IAAIH,qBAAqB;QAC9BG;IACF;AACF;AAEA,OAAO,SAASwB,wBACdrB,IAAoC;IAEpC,OAAOA,gBAAgBN;AACzB"}
1
+ {"version":3,"sources":["../../../../../../../src/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"sourcesContent":["import type { SerializedLexicalNode, Spread } from 'lexical'\nimport type { EditorConfig, LexicalNode, NodeKey } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { DecoratorNode } from 'lexical'\nimport * as React from 'react'\n\nexport type UnknownConvertedNodeData = {\n nodeData: unknown\n nodeType: string\n}\n\nexport type SerializedUnknownConvertedNode = Spread<\n {\n data: UnknownConvertedNodeData\n },\n SerializedLexicalNode\n>\n\nconst Component = React.lazy(() =>\n import('./Component.js').then((module) => ({\n default: module.UnknownConvertedNodeComponent,\n })),\n)\n\n/** @noInheritDoc */\nexport class UnknownConvertedNode extends DecoratorNode<JSX.Element> {\n __data: UnknownConvertedNodeData\n\n constructor({ data, key }: { data: UnknownConvertedNodeData; key?: NodeKey }) {\n super(key)\n this.__data = data\n }\n\n static clone(node: UnknownConvertedNode): UnknownConvertedNode {\n return new UnknownConvertedNode({\n data: node.__data,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'unknownConverted'\n }\n\n static importJSON(serializedNode: SerializedUnknownConvertedNode): UnknownConvertedNode {\n const node = $createUnknownConvertedNode({ data: serializedNode.data })\n return node\n }\n\n canInsertTextAfter(): true {\n return true\n }\n\n canInsertTextBefore(): true {\n return true\n }\n\n createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, 'unknownConverted')\n return element\n }\n\n decorate(): JSX.Element | null {\n return <Component data={this.__data} />\n }\n\n exportJSON(): SerializedUnknownConvertedNode {\n return {\n type: this.getType(),\n data: this.__data,\n version: 1,\n }\n }\n\n // Mutation\n\n isInline(): boolean {\n return true\n }\n\n updateDOM(prevNode: UnknownConvertedNode, dom: HTMLElement): boolean {\n return false\n }\n}\n\nexport function $createUnknownConvertedNode({\n data,\n}: {\n data: UnknownConvertedNodeData\n}): UnknownConvertedNode {\n return new UnknownConvertedNode({\n data,\n })\n}\n\nexport function $isUnknownConvertedNode(\n node: LexicalNode | null | undefined,\n): node is UnknownConvertedNode {\n return node instanceof UnknownConvertedNode\n}\n"],"names":["addClassNamesToElement","DecoratorNode","React","Component","lazy","then","module","default","UnknownConvertedNodeComponent","UnknownConvertedNode","__data","constructor","data","key","clone","node","__key","getType","importJSON","serializedNode","$createUnknownConvertedNode","canInsertTextAfter","canInsertTextBefore","createDOM","config","element","document","createElement","decorate","exportJSON","type","version","isInline","updateDOM","prevNode","dom","$isUnknownConvertedNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAIA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,SAASC,aAAa,QAAQ,UAAS;AACvC,YAAYC,WAAW,QAAO;AAc9B,MAAMC,0BAAYD,MAAME,IAAI,CAAC,IAC3B,MAAM,CAAC,kBAAkBC,IAAI,CAAC,CAACC,SAAY,CAAA;YACzCC,SAASD,OAAOE,6BAA6B;QAC/C,CAAA;AAGF,kBAAkB,GAClB,OAAO,MAAMC,6BAA6BR;IACxCS,OAAgC;IAEhCC,YAAY,EAAEC,IAAI,EAAEC,GAAG,EAAqD,CAAE;QAC5E,KAAK,CAACA;QACN,IAAI,CAACH,MAAM,GAAGE;IAChB;IAEA,OAAOE,MAAMC,IAA0B,EAAwB;QAC7D,OAAO,IAAIN,qBAAqB;YAC9BG,MAAMG,KAAKL,MAAM;YACjBG,KAAKE,KAAKC,KAAK;QACjB;IACF;IAEA,OAAOC,UAAkB;QACvB,OAAO;IACT;IAEA,OAAOC,WAAWC,cAA8C,EAAwB;QACtF,MAAMJ,OAAOK,4BAA4B;YAAER,MAAMO,eAAeP,IAAI;QAAC;QACrE,OAAOG;IACT;IAEAM,qBAA2B;QACzB,OAAO;IACT;IAEAC,sBAA4B;QAC1B,OAAO;IACT;IAEAC,UAAUC,MAAoB,EAAe;QAC3C,MAAMC,UAAUC,SAASC,aAAa,CAAC;QACvC3B,uBAAuByB,SAAS;QAChC,OAAOA;IACT;IAEAG,WAA+B;QAC7B,qBAAO,KAACzB;YAAUS,MAAM,IAAI,CAACF,MAAM;;IACrC;IAEAmB,aAA6C;QAC3C,OAAO;YACLC,MAAM,IAAI,CAACb,OAAO;YAClBL,MAAM,IAAI,CAACF,MAAM;YACjBqB,SAAS;QACX;IACF;IAEA,WAAW;IAEXC,WAAoB;QAClB,OAAO;IACT;IAEAC,UAAUC,QAA8B,EAAEC,GAAgB,EAAW;QACnE,OAAO;IACT;AACF;AAEA,OAAO,SAASf,4BAA4B,EAC1CR,IAAI,EAGL;IACC,OAAO,IAAIH,qBAAqB;QAC9BG;IACF;AACF;AAEA,OAAO,SAASwB,wBACdrB,IAAoC;IAEpC,OAAOA,gBAAgBN;AACzB"}
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
4
  import { useListDrawer } from '@payloadcms/ui/elements/ListDrawer';
4
5
  import { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical';
@@ -64,12 +65,19 @@ const RelationshipDrawerComponent = ({ enabledCollectionSlugs })=>{
64
65
  isDrawerOpen,
65
66
  enabledCollectionSlugs
66
67
  ]);
67
- return /*#__PURE__*/ React.createElement(ListDrawer, {
68
+ return /*#__PURE__*/ _jsx(ListDrawer, {
68
69
  onSelect: onSelect
69
70
  });
70
71
  };
71
72
  export const RelationshipDrawer = (props)=>{
72
- return props?.enabledCollectionSlugs?.length > 0 ? /*#__PURE__*/ React.createElement(RelationshipDrawerComponent, props) : /*#__PURE__*/ React.createElement(EnabledRelationshipsCondition, props, /*#__PURE__*/ React.createElement(RelationshipDrawerComponent, props));
73
+ return props?.enabledCollectionSlugs?.length > 0 ? /*#__PURE__*/ _jsx(RelationshipDrawerComponent, {
74
+ ...props
75
+ }) : /*#__PURE__*/ _jsx(EnabledRelationshipsCondition, {
76
+ ...props,
77
+ children: /*#__PURE__*/ _jsx(RelationshipDrawerComponent, {
78
+ ...props
79
+ })
80
+ });
73
81
  };
74
82
 
75
83
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useListDrawer } from '@payloadcms/ui/elements/ListDrawer'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { $createRelationshipNode } from '../nodes/RelationshipNode.js'\nimport { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js'\nimport { EnabledRelationshipsCondition } from '../utils/EnabledRelationshipsCondition.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst insertRelationship = ({\n editor,\n relationTo,\n replaceNodeKey,\n value,\n}: {\n editor: LexicalEditor\n relationTo: string\n replaceNodeKey: null | string\n value: number | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_COMMAND, {\n relationTo,\n value,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace($createRelationshipNode({ relationTo, value }))\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: null | string[]\n}\n\nconst RelationshipDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n const [selectedCollectionSlug, setSelectedCollectionSlug] = useState(\n () => enabledCollectionSlugs[0],\n )\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer, isDrawerOpen, openDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: selectedCollectionSlug,\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertRelationship({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: docID,\n })\n closeDrawer()\n },\n [editor, closeDrawer, replaceNodeKey],\n )\n\n useEffect(() => {\n // always reset back to first option\n // TODO: this is not working, see the ListDrawer component\n setSelectedCollectionSlug(enabledCollectionSlugs[0])\n }, [isDrawerOpen, enabledCollectionSlugs])\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const RelationshipDrawer = (props: Props): React.ReactNode => {\n return props?.enabledCollectionSlugs?.length > 0 ? ( // If enabledCollectionSlugs it overrides what EnabledRelationshipsCondition is doing\n <RelationshipDrawerComponent {...props} />\n ) : (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useLexicalComposerContext","useListDrawer","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","EnabledRelationshipsCondition","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","editor","relationTo","replaceNodeKey","value","dispatchCommand","update","node","replace","RelationshipDrawerComponent","enabledCollectionSlugs","selectedCollectionSlug","setSelectedCollectionSlug","setReplaceNodeKey","ListDrawer","ListDrawerToggler","closeDrawer","isDrawerOpen","openDrawer","collectionSlugs","selectedCollection","registerCommand","payload","nodeKey","onSelect","collectionSlug","docID","RelationshipDrawer","props","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,aAAa,EAAE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ACAV;IACF,GACA;QAACf;QAAQe;QAAab;KAAe;IAGvCT,UAAU;QACR,oCAAoC;QACpC,0DAA0D;QAC1DkB,0BAA0BF,sBAAsB,CAAC,EAAE;IACrD,GAAG;QAACO;QAAcP;KAAuB;IAEzC,qBAAO,oBAACI;QAAWU,UAAUA;;AAC/B;AAEA,OAAO,MAAMG,qBAAqB,CAACC;IACjC,OAAOA,OAAOlB,wBAAwBmB,SAAS,kBAC7C,oBAACpB,6BAAgCmB,uBAEjC,oBAAC9B,+BAAkC8B,qBACjC,oBAACnB,6BAAgCmB;AAGvC,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useListDrawer } from '@payloadcms/ui/elements/ListDrawer'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { $createRelationshipNode } from '../nodes/RelationshipNode.js'\nimport { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js'\nimport { EnabledRelationshipsCondition } from '../utils/EnabledRelationshipsCondition.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst insertRelationship = ({\n editor,\n relationTo,\n replaceNodeKey,\n value,\n}: {\n editor: LexicalEditor\n relationTo: string\n replaceNodeKey: null | string\n value: number | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_COMMAND, {\n relationTo,\n value,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace($createRelationshipNode({ relationTo, value }))\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: null | string[]\n}\n\nconst RelationshipDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n const [selectedCollectionSlug, setSelectedCollectionSlug] = useState(\n () => enabledCollectionSlugs[0],\n )\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer, isDrawerOpen, openDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: selectedCollectionSlug,\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertRelationship({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: docID,\n })\n closeDrawer()\n },\n [editor, closeDrawer, replaceNodeKey],\n )\n\n useEffect(() => {\n // always reset back to first option\n // TODO: this is not working, see the ListDrawer component\n setSelectedCollectionSlug(enabledCollectionSlugs[0])\n }, [isDrawerOpen, enabledCollectionSlugs])\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const RelationshipDrawer = (props: Props): React.ReactNode => {\n return props?.enabledCollectionSlugs?.length > 0 ? ( // If enabledCollectionSlugs it overrides what EnabledRelationshipsCondition is doing\n <RelationshipDrawerComponent {...props} />\n ) : (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useLexicalComposerContext","useListDrawer","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","EnabledRelationshipsCondition","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","editor","relationTo","replaceNodeKey","value","dispatchCommand","update","node","replace","RelationshipDrawerComponent","enabledCollectionSlugs","selectedCollectionSlug","setSelectedCollectionSlug","setReplaceNodeKey","ListDrawer","ListDrawerToggler","closeDrawer","isDrawerOpen","openDrawer","collectionSlugs","selectedCollection","registerCommand","payload","nodeKey","onSelect","collectionSlug","docID","RelationshipDrawer","props","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,aAAa,EAAEC,uBAAuB,QAAQ,UAAS;AAChE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,2BAA2B,QAAQ,sBAAqB;AACjE,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,uCAAuC,QAAQ,gBAAe;AAEvE,MAAMC,qBAAqB,CAAC,EAC1BC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,KAAK,EAMN;IACC,IAAI,CAACD,gBAAgB;QACnBF,OAAOI,eAAe,CAACR,6BAA6B;YAClDK;YACAE;QACF;IACF,OAAO;QACLH,OAAOK,MAAM,CAAC;YACZ,MAAMC,OAAOjB,cAAca;YAC3B,IAAII,MAAM;gBACRA,KAAKC,OAAO,CAACZ,wBAAwB;oBAAEM;oBAAYE;gBAAM;YAC3D;QACF;IACF;AACF;AAMA,MAAMK,8BAA+C,CAAC,EAAEC,sBAAsB,EAAE;IAC9E,MAAM,CAACT,OAAO,GAAGb;IACjB,MAAM,CAACuB,wBAAwBC,0BAA0B,GAAGjB,SAC1D,IAAMe,sBAAsB,CAAC,EAAE;IAEjC,MAAM,CAACP,gBAAgBU,kBAAkB,GAAGlB,SAAwB;IAEpE,MAAM,CAACmB,YAAYC,mBAAmB,EAAEC,WAAW,EAAEC,YAAY,EAAEC,UAAU,EAAE,CAAC,GAAG7B,cAAc;QAC/F8B,iBAAiBT;QACjBU,oBAAoBT;IACtB;IAEAjB,UAAU;QACR,OAAOO,OAAOoB,eAAe,CAG3BtB,yCACA,CAACuB;YACCT,kBAAkBS,SAASd,UAAUc,SAASd,QAAQe,UAAU;YAChEL;YACA,OAAO;QACT,GACA3B;IAEJ,GAAG;QAACU;QAAQiB;KAAW;IAEvB,MAAMM,WAAW/B,YACf,CAAC,EAAEgC,cAAc,EAAEC,KAAK,EAAE;QACxB1B,mBAAmB;YACjBC;YACAC,YAAYuB;YACZtB;YACAC,OAAOsB;QACT;QACAV;IACF,GACA;QAACf;QAAQe;QAAab;KAAe;IAGvCT,UAAU;QACR,oCAAoC;QACpC,0DAA0D;QAC1DkB,0BAA0BF,sBAAsB,CAAC,EAAE;IACrD,GAAG;QAACO;QAAcP;KAAuB;IAEzC,qBAAO,KAACI;QAAWU,UAAUA;;AAC/B;AAEA,OAAO,MAAMG,qBAAqB,CAACC;IACjC,OAAOA,OAAOlB,wBAAwBmB,SAAS,kBAC7C,KAACpB;QAA6B,GAAGmB,KAAK;uBAEtC,KAAC9B;QAA+B,GAAG8B,KAAK;kBACtC,cAAA,KAACnB;YAA6B,GAAGmB,KAAK;;;AAG5C,EAAC"}
@@ -1,6 +1,6 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
3
2
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
3
+ import type { JSX } from 'react';
4
4
  import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
5
5
  export type RelationshipData = {
6
6
  relationTo: string;
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/nodes/RelationshipNode.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,K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ACjC,IAAI,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,IAAI,gBAAgB,CAE1B"}
1
+ {"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/nodes/RelationshipNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAShF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,gBAAgB,EAAE,4BAA4B,CAAC,CAAA;AAgB/F,qBAAa,gBAAiB,SAAQ,kBAAkB;IACtD,MAAM,EAAE,gBAAgB,CAAA;gBAEZ,EACV,IAAI,EACJ,MAAM,EACN,GAAG,GACJ,EAAE;QACD,IAAI,EAAE,gBAAgB,CAAA;QACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;QAC1B,GAAG,CAAC,EAAE,OAAO,CAAA;KACd;IAKD,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB;IAQtD,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,SAAS,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,IAAI;IAiB3D,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,0BAA0B,GAAG,gBAAgB;IAc/E,MAAM,CAAC,QAAQ,IAAI,KAAK;IAIxB,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO;IAUlE,SAAS,IAAI,eAAe;IAU5B,UAAU,IAAI,0BAA0B;IASxC,OAAO,IAAI,gBAAgB;IAI3B,cAAc,IAAI,MAAM;IAIxB,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;CAItC;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAIhF;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,IAAI,gBAAgB,CAE1B"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
2
3
  import * as React from 'react';
3
4
  const RelationshipComponent = /*#__PURE__*/ React.lazy(()=>import('./components/RelationshipComponent.js').then((module)=>({
@@ -62,7 +63,7 @@ export class RelationshipNode extends DecoratorBlockNode {
62
63
  return false;
63
64
  }
64
65
  decorate(editor, config) {
65
- return /*#__PURE__*/ React.createElement(RelationshipComponent, {
66
+ return /*#__PURE__*/ _jsx(RelationshipComponent, {
66
67
  className: config.theme.relationship ?? 'LexicalEditorTheme__relationship',
67
68
  data: this.__data,
68
69
  format: this.__format,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/nodes/RelationshipNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport * as React from 'react'\n\nconst RelationshipComponent = React.lazy(() =>\n import('./components/RelationshipComponent.js').then((module) => ({\n default: module.RelationshipComponent,\n })),\n)\n\nexport type RelationshipData = {\n relationTo: string\n value: number | string\n}\n\nexport type SerializedRelationshipNode = Spread<RelationshipData, SerializedDecoratorBlockNode>\n\nfunction $relationshipElementToNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipNode extends DecoratorBlockNode {\n __data: RelationshipData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: RelationshipData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static clone(node: RelationshipNode): RelationshipNode {\n return new RelationshipNode({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'relationship'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToNode,\n priority: 2,\n }\n },\n }\n }\n\n static importJSON(serializedNode: SerializedRelationshipNode): RelationshipNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <RelationshipComponent\n className={config.theme.relationship ?? 'LexicalEditorTheme__relationship'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n element.setAttribute('data-lexical-relationship-id', String(this.__data?.value))\n element.setAttribute('data-lexical-relationship-relationTo', this.__data?.relationTo)\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedRelationshipNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: this.getType(),\n version: 2,\n }\n }\n\n getData(): RelationshipData {\n return this.getLatest().__data\n }\n\n getTextContent(): string {\n return `${this.__data?.relationTo} relation to ${this.__data?.value}`\n }\n\n setData(data: RelationshipData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n}\n\nexport function $createRelationshipNode(data: RelationshipData): RelationshipNode {\n return new RelationshipNode({\n data,\n })\n}\n\nexport function $isRelationshipNode(\n node: LexicalNode | RelationshipNode | null | undefined,\n): node is RelationshipNode {\n return node instanceof RelationshipNode\n}\n"],"names":["DecoratorBlockNode","React","RelationshipComponent","lazy","then","module","default","$relationshipElementToNode","domNode","id","getAttribute","relationTo","node","$createRelationshipNode","value","RelationshipNode","__data","constructor","data","format","key","clone","__format","__key","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","isInline","decorate","editor","config","className","theme","relationship","nodeKey","getKey","exportDOM","element","document","createElement","setAttribute","String","text","createTextNode","getTextContent","append","exportJSON","getData","type","getLatest","setData","writable","getWritable","$isRelationshipNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAaA,SAASA,kBAAkB,QAAQ,8CAA6C;AAChF,YAAYC,WAAW,QAAO;AAE9B,MAAMC,sCAAwBD,MAAME,IAAI,CAAC,IACvC,MAAM,CAAC,yCAAyCC,IAAI,CAAC,CAACC,SAAY,CAAA;YAChEC,SAASD,OAAOH,qBAAqB;QACvC,CAAA;AAUF,SAASK,2BAA2BC,OAAuB;IACzD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E,oBAACpC;YACCqC,WAAWD,OAAOE,KAAK,CAACC,YAAY,IAAI;YACxCvB,MAAM,IAAI,CAACF,MAAM;YACjBG,QAAQ,IAAI,CAACG,QAAQ;YACrBoB,SAAS,IAAI,CAACC,MAAM;;IAG1B;IACAC,YAA6B;QAC3B,MAAMC,UAAUC,SAASC,aAAa,CAAC;QACvCF,QAAQG,YAAY,CAAC,gCAAgCC,OAAO,IAAI,CAACjC,MAAM,EAAEF;QACzE+B,QAAQG,YAAY,CAAC,wCAAwC,IAAI,CAAChC,MAAM,EAAEL;QAE1E,MAAMuC,OAAOJ,SAASK,cAAc,CAAC,IAAI,CAACC,cAAc;QACxDP,QAAQQ,MAAM,CAACH;QACf,OAAO;YAAEL;QAAQ;IACnB;IAEAS,aAAyC;QACvC,OAAO;YACL,GAAG,KAAK,CAACA,YAAY;YACrB,GAAG,IAAI,CAACC,OAAO,EAAE;YACjBC,MAAM,IAAI,CAAChC,OAAO;YAClBQ,SAAS;QACX;IACF;IAEAuB,UAA4B;QAC1B,OAAO,IAAI,CAACE,SAAS,GAAGzC,MAAM;IAChC;IAEAoC,iBAAyB;QACvB,OAAO,CAAC,EAAE,IAAI,CAACpC,MAAM,EAAEL,WAAW,aAAa,EAAE,IAAI,CAACK,MAAM,EAAEF,MAAM,CAAC;IACvE;IAEA4C,QAAQxC,IAAsB,EAAQ;QACpC,MAAMyC,WAAW,IAAI,CAACC,WAAW;QACjCD,SAAS3C,MAAM,GAAGE;IACpB;AACF;AAEA,OAAO,SAASL,wBAAwBK,IAAsB;IAC5D,OAAO,IAAIH,iBAAiB;QAC1BG;IACF;AACF;AAEA,OAAO,SAAS2C,oBACdjD,IAAuD;IAEvD,OAAOA,gBAAgBG;AACzB"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/nodes/RelationshipNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport * as React from 'react'\n\nconst RelationshipComponent = React.lazy(() =>\n import('./components/RelationshipComponent.js').then((module) => ({\n default: module.RelationshipComponent,\n })),\n)\n\nexport type RelationshipData = {\n relationTo: string\n value: number | string\n}\n\nexport type SerializedRelationshipNode = Spread<RelationshipData, SerializedDecoratorBlockNode>\n\nfunction $relationshipElementToNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipNode extends DecoratorBlockNode {\n __data: RelationshipData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: RelationshipData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static clone(node: RelationshipNode): RelationshipNode {\n return new RelationshipNode({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'relationship'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToNode,\n priority: 2,\n }\n },\n }\n }\n\n static importJSON(serializedNode: SerializedRelationshipNode): RelationshipNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <RelationshipComponent\n className={config.theme.relationship ?? 'LexicalEditorTheme__relationship'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n element.setAttribute('data-lexical-relationship-id', String(this.__data?.value))\n element.setAttribute('data-lexical-relationship-relationTo', this.__data?.relationTo)\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedRelationshipNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: this.getType(),\n version: 2,\n }\n }\n\n getData(): RelationshipData {\n return this.getLatest().__data\n }\n\n getTextContent(): string {\n return `${this.__data?.relationTo} relation to ${this.__data?.value}`\n }\n\n setData(data: RelationshipData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n}\n\nexport function $createRelationshipNode(data: RelationshipData): RelationshipNode {\n return new RelationshipNode({\n data,\n })\n}\n\nexport function $isRelationshipNode(\n node: LexicalNode | RelationshipNode | null | undefined,\n): node is RelationshipNode {\n return node instanceof RelationshipNode\n}\n"],"names":["DecoratorBlockNode","React","RelationshipComponent","lazy","then","module","default","$relationshipElementToNode","domNode","id","getAttribute","relationTo","node","$createRelationshipNode","value","RelationshipNode","__data","constructor","data","format","key","clone","__format","__key","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","isInline","decorate","editor","config","className","theme","relationship","nodeKey","getKey","exportDOM","element","document","createElement","setAttribute","String","text","createTextNode","getTextContent","append","exportJSON","getData","type","getLatest","setData","writable","getWritable","$isRelationshipNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAcA,SAASA,kB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O,SAAS2C,oBACdjD,IAAuD;IAEvD,OAAOA,gBAAgBG;AACzB"}
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
4
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js';
4
5
  import { mergeRegister } from '@lexical/utils';
@@ -102,57 +103,76 @@ const Component = (props)=>{
102
103
  setSelected,
103
104
  onClick
104
105
  ]);
105
- return /*#__PURE__*/ React.createElement("div", {
106
+ return /*#__PURE__*/ _jsxs("div", {
106
107
  className: [
107
108
  baseClass,
108
109
  isSelected && `${baseClass}--selected`
109
110
  ].filter(Boolean).join(' '),
110
111
  contentEditable: false,
111
- ref: relationshipElemRef
112
- }, /*#__PURE__*/ React.createElement("div", {
113
- className: `${baseClass}__wrap`
114
- }, /*#__PURE__*/ React.createElement("p", {
115
- className: `${baseClass}__label`
116
- }, t('fields:labelRelationship', {
117
- label: getTranslation(relatedCollection.labels.singular, i18n)
118
- })), /*#__PURE__*/ React.createElement(DocumentDrawerToggler, {
119
- className: `${baseClass}__doc-drawer-toggler`
120
- }, /*#__PURE__*/ React.createElement("p", {
121
- className: `${baseClass}__title`
122
- }, data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id))), editor.isEditable() && /*#__PURE__*/ React.createElement("div", {
123
- className: `${baseClass}__actions`
124
- }, /*#__PURE__*/ React.createElement(Button, {
125
- buttonStyle: "icon-label",
126
- className: `${baseClass}__swapButton`,
127
- disabled: field?.readOnly,
128
- el: "div",
129
- icon: "swap",
130
- onClick: ()=>{
131
- editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {
132
- replace: {
133
- nodeKey
134
- }
135
- });
136
- },
137
- round: true,
138
- tooltip: t('fields:swapRelationship')
139
- }), /*#__PURE__*/ React.createElement(Button, {
140
- buttonStyle: "icon-label",
141
- className: `${baseClass}__removeButton`,
142
- disabled: field?.readOnly,
143
- icon: "x",
144
- onClick: (e)=>{
145
- e.preventDefault();
146
- removeRelationship();
147
- },
148
- round: true,
149
- tooltip: t('fields:removeRelationship')
150
- })), id && /*#__PURE__*/ React.createElement(DocumentDrawer, {
151
- onSave: updateRelationship
152
- }), children);
112
+ ref: relationshipElemRef,
113
+ children: [
114
+ /*#__PURE__*/ _jsxs("div", {
115
+ className: `${baseClass}__wrap`,
116
+ children: [
117
+ /*#__PURE__*/ _jsx("p", {
118
+ className: `${baseClass}__label`,
119
+ children: t('fields:labelRelationship', {
120
+ label: getTranslation(relatedCollection.labels.singular, i18n)
121
+ })
122
+ }),
123
+ /*#__PURE__*/ _jsx(DocumentDrawerToggler, {
124
+ className: `${baseClass}__doc-drawer-toggler`,
125
+ children: /*#__PURE__*/ _jsx("p", {
126
+ className: `${baseClass}__title`,
127
+ children: data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id
128
+ })
129
+ })
130
+ ]
131
+ }),
132
+ editor.isEditable() && /*#__PURE__*/ _jsxs("div", {
133
+ className: `${baseClass}__actions`,
134
+ children: [
135
+ /*#__PURE__*/ _jsx(Button, {
136
+ buttonStyle: "icon-label",
137
+ className: `${baseClass}__swapButton`,
138
+ disabled: field?.readOnly,
139
+ el: "div",
140
+ icon: "swap",
141
+ onClick: ()=>{
142
+ editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {
143
+ replace: {
144
+ nodeKey
145
+ }
146
+ });
147
+ },
148
+ round: true,
149
+ tooltip: t('fields:swapRelationship')
150
+ }),
151
+ /*#__PURE__*/ _jsx(Button, {
152
+ buttonStyle: "icon-label",
153
+ className: `${baseClass}__removeButton`,
154
+ disabled: field?.readOnly,
155
+ icon: "x",
156
+ onClick: (e)=>{
157
+ e.preventDefault();
158
+ removeRelationship();
159
+ },
160
+ round: true,
161
+ tooltip: t('fields:removeRelationship')
162
+ })
163
+ ]
164
+ }),
165
+ id && /*#__PURE__*/ _jsx(DocumentDrawer, {
166
+ onSave: updateRelationship
167
+ }),
168
+ children
169
+ ]
170
+ });
153
171
  };
154
172
  export const RelationshipComponent = (props)=>{
155
- return /*#__PURE__*/ React.createElement(Component, props);
173
+ return /*#__PURE__*/ _jsx(Component, {
174
+ ...props
175
+ });
156
176
  };
157
177
 
158
178
  //# sourceMappingURL=RelationshipComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport {\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js'\nimport { $isRelationshipNode } from '../RelationshipNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n children?: React.ReactNode\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n children,\n data: { relationTo, value: id },\n nodeKey,\n } = props\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { field } = useEditorConfigContext()\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDrawer],\n )\n\n const $onDelete = useCallback(\n (payload: KeyboardEvent) => {\n if (isSelected && $isNodeSelection($getSelection())) {\n const event: KeyboardEvent = payload\n event.preventDefault()\n const node = $getNodeByKey(nodeKey)\n if ($isRelationshipNode(node)) {\n node.remove()\n return true\n }\n }\n return false\n },\n [isSelected, nodeKey],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if relationshipElemRef.target or anything WITHIN relationshipElemRef.target was clicked\n if (\n event.target === relationshipElemRef.current ||\n relationshipElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={relationshipElemRef}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id}\n </p>\n </DocumentDrawerToggler>\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {id && <DocumentDrawer onSave={updateRelationship} />}\n {children}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"names":["useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useDocumentDrawer","usePayloadAPI","useConfig","useTranslation","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","$getNodeByKey","React","useCallback","useEffect","useReducer","useRef","useState","useEditorConfigContext","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","baseClass","initialParams","depth","Component","props","children","data","relationTo","value","id","nodeKey","relationshipElemRef","editor","isSelected","setSelected","clearSelection","field","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","$onDelete","payload","event","preventDefault","node","onClick","target","current","contains","shiftKey","registerCommand","div","className","filter","Boolean","join","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","readOnly","el","icon","dispatchCommand","replace","round","tooltip","e","onSave","RelationshipComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,OAAOC,mBAAmB,qCAAoC;AAC9D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SACEC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb,UAAS;AAChB,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC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,UAAU,UAAU,CAAC;SAAC,CAACsD,MAAM,CAACC,SAASC,IAAI,CAAC;QACpFC,iBAAiB;QACjBC,KAAK/C;qBAEL,oBAACyC;QAAIC,WAAW,CAAC,EAAErD,UAAU,MAAM,CAAC;qBAClC,oBAAC2D;QAAEN,WAAW,CAAC,EAAErD,UAAU,OAAO,CAAC;OAChC2B,EAAE,4BAA4B;QAC7BiC,OAAOlF,eAAe2C,kBAAkBwC,MAAM,CAACC,QAAQ,EAAEpC;IAC3D,mBAEF,oBAACO;QAAsBoB,WAAW,CAAC,EAAErD,UAAU,oBAAoB,CAAC;qBAClE,oBAAC2D;QAAEN,WAAW,CAAC,EAAErD,UAAU,OAAO,CAAC;OAChCM,OAAOA,IAAI,CAACe,mBAAmB0C,OAAOC,cAAc,KAAK,GAAGvD,OAIlEG,OAAOqD,UAAU,oBAChB,oBAACb;QAAIC,WAAW,CAAC,EAAErD,UAAU,SAAS,CAAC;qBACrC,oBAACrB;QACCuF,aAAY;QACZb,WAAW,CAAC,EAAErD,UAAU,YAAY,CAAC;QACrCmE,UAAUnD,OAAOoD;QACjBC,IAAG;QACHC,MAAK;QACLxB,SAAS;YACPlC,OAAO2D,eAAe,CAACzE,yCAAyC;gBAC9D0E,SAAS;oBAAE9D;gBAAQ;YACrB;QACF;QACA+D,OAAAA;QACAC,SAAS/C,EAAE;sBAEb,oBAAChD;QACCuF,aAAY;QACZb,WAAW,CAAC,EAAErD,UAAU,cAAc,CAAC;QACvCmE,UAAUnD,OAAOoD;QACjBE,MAAK;QACLxB,SAAS,CAAC6B;YACRA,EAAE/B,cAAc;YAChBR;QACF;QACAqC,OAAAA;QACAC,SAAS/C,EAAE;SAKhBlB,oBAAM,oBAACuB;QAAe4C,QAAQrC;QAC9BlC;AAGP;AAEA,OAAO,MAAMwE,wBAAwB,CAACzE;IACpC,qBAAO,oBAACD,WAAcC;AACxB,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport {\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js'\nimport { $isRelationshipNode } from '../RelationshipNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n children?: React.ReactNode\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n children,\n data: { relationTo, value: id },\n nodeKey,\n } = props\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { field } = useEditorConfigContext()\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDrawer],\n )\n\n const $onDelete = useCallback(\n (payload: KeyboardEvent) => {\n if (isSelected && $isNodeSelection($getSelection())) {\n const event: KeyboardEvent = payload\n event.preventDefault()\n const node = $getNodeByKey(nodeKey)\n if ($isRelationshipNode(node)) {\n node.remove()\n return true\n }\n }\n return false\n },\n [isSelected, nodeKey],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if relationshipElemRef.target or anything WITHIN relationshipElemRef.target was clicked\n if (\n event.target === relationshipElemRef.current ||\n relationshipElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={relationshipElemRef}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id}\n </p>\n </DocumentDrawerToggler>\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {id && <DocumentDrawer onSave={updateRelationship} />}\n {children}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"names":["useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useDocumentDrawer","usePayloadAPI","useConfig","useTranslation","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","$getNodeByKey","React","useCallback","useEffect","useReducer","useRef","useState","useEditorConfigContext","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","baseClass","initialParams","depth","Component","props","children","data","relationTo","value","id","nodeKey","relationshipElemRef","editor","isSelected","setSelected","clearSelection","field","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","$onDelete","payload","event","preventDefault","node","onClick","target","current","contains","shiftKey","registerCommand","div","className","filter","Boolean","join","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","readOnly","el","icon","dispatchCommand","replace","round","tooltip","e","onSave","RelationshipComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,OAAOC,mBAAmB,qCAAoC;AAC9D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SACEC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb,UAAS;AAChB,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAInF,SAASC,sBAAsB,QAAQ,4DAA2D;AAClG,SAASC,uCAAuC,QAAQ,2BAA0B;AAClF,SAASC,mBAAmB,QAAQ,yBAAwB;AAC5D,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAUA,MAAMC,Y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wC,MAAM,CAACC,QAAQ,EAAEpC;wBAC3D;;kCAEF,KAACO;wBAAsBoB,WAAW,CAAC,EAAErD,UAAU,oBAAoB,CAAC;kCAClE,cAAA,KAAC2D;4BAAEN,WAAW,CAAC,EAAErD,UAAU,OAAO,CAAC;sCAChCM,OAAOA,IAAI,CAACe,mBAAmB0C,OAAOC,cAAc,KAAK,GAAGvD;;;;;YAIlEG,OAAOqD,UAAU,oBAChB,MAACb;gBAAIC,WAAW,CAAC,EAAErD,UAAU,SAAS,CAAC;;kCACrC,KAACrB;wBACCuF,aAAY;wBACZb,WAAW,CAAC,EAAErD,UAAU,YAAY,CAAC;wBACrCmE,UAAUnD,OAAOoD;wBACjBC,IAAG;wBACHC,MAAK;wBACLxB,SAAS;4BACPlC,OAAO2D,eAAe,CAACzE,yCAAyC;gCAC9D0E,SAAS;oCAAE9D;gCAAQ;4BACrB;wBACF;wBACA+D,KAAK;wBACLC,SAAS/C,EAAE;;kCAEb,KAAChD;wBACCuF,aAAY;wBACZb,WAAW,CAAC,EAAErD,UAAU,cAAc,CAAC;wBACvCmE,UAAUnD,OAAOoD;wBACjBE,MAAK;wBACLxB,SAAS,CAAC6B;4BACRA,EAAE/B,cAAc;4BAChBR;wBACF;wBACAqC,KAAK;wBACLC,SAAS/C,EAAE;;;;YAKhBlB,oBAAM,KAACuB;gBAAe4C,QAAQrC;;YAC9BlC;;;AAGP;AAEA,OAAO,MAAMwE,wBAAwB,CAACzE;IACpC,qBAAO,KAACD;QAAW,GAAGC,KAAK;;AAC7B,EAAC"}
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
4
  import { $insertNodeToNearestRoot } from '@lexical/utils';
4
5
  import { useConfig } from '@payloadcms/ui/providers/Config';
@@ -42,7 +43,7 @@ export const RelationshipPlugin = ({ clientProps })=>{
42
43
  }, [
43
44
  editor
44
45
  ]);
45
- return /*#__PURE__*/ React.createElement(RelationshipDrawer, {
46
+ return /*#__PURE__*/ _jsx(RelationshipDrawer, {
46
47
  enabledCollectionSlugs: enabledRelations
47
48
  });
48
49
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\nimport React from 'react'\n\nimport type { PluginComponent } from '../../types.js'\nimport type { RelationshipFeatureProps } from '../feature.server.js'\nimport type { RelationshipData } from '../nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport const RelationshipPlugin: PluginComponent<RelationshipFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n let enabledRelations: string[] = null\n\n if (clientProps?.enabledCollections) {\n enabledRelations = clientProps?.enabledCollections\n } else if (clientProps?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !clientProps?.disabledCollections?.includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const relationshipNode = $createRelationshipNode(payload)\n // Insert relationship node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(relationshipNode)\n\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","React","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","clientProps","editor","collections","enabledRelations","enabledCollections","disabledCollections","filter","slug","includes","map","hasNodes","Error","registerCommand","payload","selection","relationshipNode","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","node","length","remove","enabledCollectionSlugs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,QACR,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AACjC,OAAOC,WAAW,QAAO;AAMzB,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,+BAA8B;AAExF,OAAO,MAAMC,8BAAgEN,cAC3E,+BACD;AAED,OAAO,MAAMO,qBAAgE,CAAC,EAAEC,WAAW,EAAE;IAC3F,MAAM,CAACC,OAAO,GAAGjB;IACjB,MAAM,EAAEkB,WAAW,EAAE,GAAGhB;IAExB,IAAIiB,mBAA6B;IAEjC,IAAIH,aAAaI,oBAAoB;QACnCD,mBAAmBH,aAAaI;IAClC,OAAO,IAAIJ,aAAaK,qBAAqB;QAC3CF,mBAAmBD,YAChBI,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAK,CAACP,aAAaK,qBAAqBG,SAASD,OACjEE,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACvB;IAEAd,UAAU;QACR,IAAI,CAACQ,OAAOS,QAAQ,CAAC;YAACb;SAAiB,GAAG;YACxC,MAAM,IAAIc,MAAM;QAClB;QAEA,OAAOV,OAAOW,eAAe,CAC3Bd,6BACA,CAACe;YACC,MAAMC,YAAY1B,mBAAmBD;YAErC,IAAIG,kBAAkBwB,YAAY;gBAChC,MAAMC,mBAAmBnB,wBAAwBiB;gBACjD,oIAAoI;gBACpI5B,yBAAyB8B;gBAEzB,MAAM,EAAEC,KAAK,EAAE,GAAGF;gBAClB,MAAMG,YAAYD,MAAME,OAAO;gBAE/B,+FAA+F;gBAC/F,0FAA0F;gBAC1F,IACE7B,iBAAiB4B,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXf,MAAM,CAAC,CAACgB,OAASjC,iBAAiBiC,OAAOC,MAAM,GAAG,GACrD;oBACAN,UAAUO,MAAM;gBAClB;YACF;YAEA,OAAO;QACT,GACAjC;IAEJ,GAAG;QAACU;KAAO;IAEX,qBAAO,oBAACN;QAAmB8B,wBAAwBtB;;AACrD,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\nimport React from 'react'\n\nimport type { PluginComponent } from '../../types.js'\nimport type { RelationshipFeatureProps } from '../feature.server.js'\nimport type { RelationshipData } from '../nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport const RelationshipPlugin: PluginComponent<RelationshipFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n let enabledRelations: string[] = null\n\n if (clientProps?.enabledCollections) {\n enabledRelations = clientProps?.enabledCollections\n } else if (clientProps?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !clientProps?.disabledCollections?.includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const relationshipNode = $createRelationshipNode(payload)\n // Insert relationship node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(relationshipNode)\n\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","React","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","clientProps","editor","collections","enabledRelations","enabledCollections","disabledCollections","filter","slug","includes","map","hasNodes","Error","registerCommand","payload","selection","relationshipNode","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","node","length","remove","enabledCollectionSlugs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,QACR,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AACjC,OAAOC,WAAW,QAAO;AAMzB,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,+BAA8B;AAExF,OAAO,MAAMC,8BAAgEN,cAC3E,+BACD;AAED,OAAO,MAAMO,qBAAgE,CAAC,EAAEC,WAAW,EAAE;IAC3F,MAAM,CAACC,OAAO,GAAGjB;IACjB,MAAM,EAAEkB,WAAW,EAAE,GAAGhB;IAExB,IAAIiB,mBAA6B;IAEjC,IAAIH,aAAaI,oBAAoB;QACnCD,mBAAmBH,aAAaI;IAClC,OAAO,IAAIJ,aAAaK,qBAAq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