@payloadcms/richtext-lexical 3.0.2 → 3.0.3-canary.5abb7d5

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 (162) hide show
  1. package/dist/exports/client/Field-CO3ZH6ER.js +2 -0
  2. package/dist/exports/client/Field-CO3ZH6ER.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-XOQBVKA3.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-XOQBVKA3.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/{chunk-C7S3V4EB.js → chunk-DOK5S7LE.js} +2 -2
  7. package/dist/exports/client/chunk-DOK5S7LE.js.map +7 -0
  8. package/dist/exports/client/{chunk-U7O7EYCP.js → chunk-FBDJRK3A.js} +2 -2
  9. package/dist/exports/client/{chunk-U7O7EYCP.js.map → chunk-FBDJRK3A.js.map} +2 -2
  10. package/dist/exports/client/chunk-LMCV6WAN.js +12 -0
  11. package/dist/exports/client/chunk-LMCV6WAN.js.map +7 -0
  12. package/dist/exports/client/chunk-ZTAS32RX.js +2 -0
  13. package/dist/exports/client/{chunk-MI5HS4QX.js.map → chunk-ZTAS32RX.js.map} +3 -3
  14. package/dist/exports/client/{component-H3EYQ5KG.js → component-D6PKVJ2K.js} +2 -2
  15. package/dist/exports/client/component-D6PKVJ2K.js.map +7 -0
  16. package/dist/exports/client/componentInline-XC7SFQPN.js +2 -0
  17. package/dist/exports/client/index.d.ts +3 -0
  18. package/dist/exports/client/index.d.ts.map +1 -1
  19. package/dist/exports/client/index.js +11 -11
  20. package/dist/exports/client/index.js.map +3 -3
  21. package/dist/exports/server/ast/mdx.d.ts.map +1 -1
  22. package/dist/exports/server/ast/mdx.js +6 -0
  23. package/dist/exports/server/ast/mdx.js.map +1 -1
  24. package/dist/features/blockquote/server/index.d.ts.map +1 -1
  25. package/dist/features/blockquote/server/index.js +2 -1
  26. package/dist/features/blockquote/server/index.js.map +1 -1
  27. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  28. package/dist/features/blocks/client/component/index.js +2 -0
  29. package/dist/features/blocks/client/component/index.js.map +1 -1
  30. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts +1 -1
  31. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -1
  32. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
  33. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  34. package/dist/features/blocks/client/componentInline/index.js +2 -0
  35. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  36. package/dist/features/blocks/client/index.d.ts.map +1 -1
  37. package/dist/features/blocks/client/index.js.map +1 -1
  38. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
  39. package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
  40. package/dist/features/converters/html/converter/converters/paragraph.d.ts.map +1 -1
  41. package/dist/features/converters/html/converter/converters/paragraph.js +2 -1
  42. package/dist/features/converters/html/converter/converters/paragraph.js.map +1 -1
  43. package/dist/features/converters/html/converter/defaultConverters.d.ts +1 -1
  44. package/dist/features/converters/html/converter/defaultConverters.d.ts.map +1 -1
  45. package/dist/features/converters/html/converter/defaultConverters.js.map +1 -1
  46. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
  47. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +23 -17
  48. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  49. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  50. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +4 -2
  51. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  52. package/dist/features/experimental_table/client/utils/debounce.d.ts.map +1 -1
  53. package/dist/features/experimental_table/client/utils/debounce.js +3 -0
  54. package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
  55. package/dist/features/experimental_table/client/utils/useDebounce.d.ts +1 -5
  56. package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +1 -1
  57. package/dist/features/experimental_table/client/utils/useDebounce.js +40 -10
  58. package/dist/features/experimental_table/client/utils/useDebounce.js.map +1 -1
  59. package/dist/features/heading/server/index.d.ts.map +1 -1
  60. package/dist/features/heading/server/index.js +2 -1
  61. package/dist/features/heading/server/index.js.map +1 -1
  62. package/dist/features/lists/checklist/server/index.js.map +1 -1
  63. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  64. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  65. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  66. package/dist/features/relationship/client/components/RelationshipComponent.js +1 -3
  67. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  68. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  69. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
  70. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  71. package/dist/features/relationship/server/nodes/RelationshipNode.js +3 -3
  72. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  73. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts +2 -2
  74. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  75. package/dist/features/toolbars/fixed/client/Toolbar/index.js +51 -69
  76. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  77. package/dist/features/toolbars/inline/client/Toolbar/index.js +31 -51
  78. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  79. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  80. package/dist/features/toolbars/shared/ToolbarButton/index.js +152 -62
  81. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  82. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +1 -1
  83. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  84. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +4 -2
  85. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  86. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  87. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +8 -20
  88. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  89. package/dist/features/typesClient.d.ts +39 -36
  90. package/dist/features/typesClient.d.ts.map +1 -1
  91. package/dist/features/typesClient.js.map +1 -1
  92. package/dist/features/typesServer.d.ts.map +1 -1
  93. package/dist/features/typesServer.js.map +1 -1
  94. package/dist/features/upload/client/component/index.js.map +1 -1
  95. package/dist/features/upload/client/drawer/index.js.map +1 -1
  96. package/dist/features/upload/client/nodes/UploadNode.d.ts +1 -1
  97. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  98. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  99. package/dist/features/upload/client/plugin/index.d.ts +2 -2
  100. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  101. package/dist/features/upload/client/plugin/index.js.map +1 -1
  102. package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -1
  103. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  104. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  105. package/dist/field/Field.d.ts +1 -1
  106. package/dist/field/Field.d.ts.map +1 -1
  107. package/dist/field/Field.js +2 -1
  108. package/dist/field/Field.js.map +1 -1
  109. package/dist/field/bundled.css +1 -1
  110. package/dist/field/rscEntry.js +1 -1
  111. package/dist/field/rscEntry.js.map +1 -1
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +5 -0
  114. package/dist/index.js.map +1 -1
  115. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  116. package/dist/lexical/LexicalProvider.js.map +1 -1
  117. package/dist/lexical/config/client/sanitize.js.map +1 -1
  118. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  119. package/dist/lexical/config/server/sanitize.js +1 -0
  120. package/dist/lexical/config/server/sanitize.js.map +1 -1
  121. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +2 -3
  122. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  123. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +139 -88
  124. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  125. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +2 -3
  126. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  127. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +4 -7
  128. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  129. package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  130. package/dist/lexical/plugins/SlashMenu/index.js +8 -14
  131. package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
  132. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
  133. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +1 -0
  134. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  135. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts +1 -1
  136. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
  137. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js +1 -1
  138. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js.map +1 -1
  139. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  140. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  141. package/dist/utilities/generateImportMap.js +4 -1
  142. package/dist/utilities/generateImportMap.js.map +1 -1
  143. package/dist/utilities/jsx/jsx.d.ts.map +1 -1
  144. package/dist/utilities/jsx/jsx.js +1 -0
  145. package/dist/utilities/jsx/jsx.js.map +1 -1
  146. package/dist/utilities/migrateSlateToLexical/index.d.ts.map +1 -1
  147. package/dist/utilities/migrateSlateToLexical/index.js +1 -1
  148. package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
  149. package/dist/validate/index.d.ts.map +1 -1
  150. package/dist/validate/index.js.map +1 -1
  151. package/package.json +6 -6
  152. package/dist/exports/client/Field-IS3XMKMO.js +0 -2
  153. package/dist/exports/client/Field-IS3XMKMO.js.map +0 -7
  154. package/dist/exports/client/RelationshipComponent-2RT3YXUT.js +0 -2
  155. package/dist/exports/client/RelationshipComponent-2RT3YXUT.js.map +0 -7
  156. package/dist/exports/client/chunk-C7S3V4EB.js.map +0 -7
  157. package/dist/exports/client/chunk-CBUZKU7S.js +0 -12
  158. package/dist/exports/client/chunk-CBUZKU7S.js.map +0 -7
  159. package/dist/exports/client/chunk-MI5HS4QX.js +0 -2
  160. package/dist/exports/client/component-H3EYQ5KG.js.map +0 -7
  161. package/dist/exports/client/componentInline-ZGO3K4TA.js +0 -2
  162. /package/dist/exports/client/{componentInline-ZGO3K4TA.js.map → componentInline-XC7SFQPN.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipComponent.js","names":["useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","React","useCallback","useEffect","useReducer","useRef","useState","useEditorConfigContext","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","baseClass","initialParams","depth","Component","props","data","relationTo","value","nodeKey","Error","relationshipElemRef","editor","isSelected","setSelected","clearSelection","fieldProps","readOnly","config","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","$onDelete","payload","deleteSelection","event","preventDefault","getNodes","forEach","node","onClick","target","current","contains","shiftKey","registerCommand","_jsxs","className","filter","Boolean","join","contentEditable","ref","_jsx","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","el","icon","dispatchCommand","replace","round","tooltip","e","onSave","RelationshipComponent"],"sources":["../../../../../src/features/relationship/client/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, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { $isRelationshipNode } from '../nodes/RelationshipNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey!)\n const {\n fieldProps: { readOnly },\n } = useEditorConfigContext()\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\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}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\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 closeDocumentDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDocumentDrawer],\n )\n\n const $onDelete = useCallback(\n (payload: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n const event: KeyboardEvent = payload\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isRelationshipNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\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: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\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={readOnly}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={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 {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,uBAAuB,QAAQ;AACxC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,EAAEC,SAAS,EAAEC,aAAa,EAAEC,cAAc,QAAQ;AACjE,SACEC,aAAa,EACbC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAI5E,SAASC,sBAAsB,QAAQ;AACvC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,uCAAuC,QAAQ;AACxD,SAASC,mBAAmB,QAAQ;AAGpC,MAAMC,SAAA,GAAY;AAElB,MAAMC,aAAA,GAAgB;EACpBC,KAAA,EAAO;AACT;AASA,MAAMC,SAAA,GAA8BC,KAAA;EAClC,MAAM;IACJC,IAAA,EAAM;MAAEC,UAAU;MAAEC;IAAK,CAAE;IAC3BC;EAAO,CACR,GAAGJ,KAAA;EAEJ,IAAI,OAAOG,KAAA,KAAU,UAAU;IAC7B,MAAM,IAAIE,KAAA,CACR;EAEJ;EAEA,MAAMC,mBAAA,GAAsBhB,MAAA,CAA8B;EAE1D,MAAM,CAACiB,MAAA,CAAO,GAAGpC,yBAAA;EACjB,MAAM,CAACqC,UAAA,EAAYC,WAAA,EAAaC,cAAA,CAAe,GAAGtC,uBAAA,CAAwBgC,OAAA;EAC1E,MAAM;IACJO,UAAA,EAAY;MAAEC;IAAQ;EAAE,CACzB,GAAGpB,sBAAA;EACJ,MAAM;IACJqB,MAAA,EAAQ;MACNC,WAAW;MACXC,MAAA,EAAQ;QAAEC;MAAG,CAAE;MAC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LvB,OAAA,EAAU4B,CAAA;UACRA,CAAA,CAAEhC,cAAc;UAChBT,kBAAA;QACF;QACAuC,KAAK;QACLC,OAAA,EAASlD,CAAA,CAAE;;QAKhB,CAAC,CAACrB,KAAA,iBAASyD,IAAA,CAAC9B,cAAA;MAAe8C,MAAA,EAAQvC;;;AAG1C;AAEA,OAAO,MAAMwC,qBAAA,GAAyB7E,KAAA;EACpC,oBAAO4D,IAAA,CAAC7D,SAAA;IAAW,GAAGC;;AACxB","ignoreList":[]}
1
+ {"version":3,"file":"RelationshipComponent.js","names":["useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","React","useCallback","useEffect","useReducer","useRef","useState","useEditorConfigContext","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","baseClass","initialParams","depth","Component","props","data","relationTo","value","nodeKey","Error","relationshipElemRef","editor","isSelected","setSelected","clearSelection","fieldProps","readOnly","config","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","collectionSlug","removeRelationship","update","remove","updateRelationship","$onDelete","payload","deleteSelection","event","preventDefault","getNodes","forEach","node","onClick","target","current","contains","shiftKey","registerCommand","_jsxs","className","filter","Boolean","join","contentEditable","ref","_jsx","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","el","icon","dispatchCommand","replace","round","tooltip","e","onSave","RelationshipComponent"],"sources":["../../../../../src/features/relationship/client/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, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { $isRelationshipNode } from '../nodes/RelationshipNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey!)\n const {\n fieldProps: { readOnly },\n } = useEditorConfigContext()\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\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}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\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 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 closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n const $onDelete = useCallback(\n (payload: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n const event: KeyboardEvent = payload\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isRelationshipNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\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: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\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={readOnly}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={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 {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,uBAAuB,QAAQ;AACxC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,EAAEC,SAAS,EAAEC,aAAa,EAAEC,cAAc,QAAQ;AACjE,SACEC,aAAa,EACbC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAI5E,SAASC,sBAAsB,QAAQ;AACvC,SAASC,wBAAwB,QAAQ;A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IAAI,CAACiB,iBAAA,EAAmB6C,KAAA,EAAOC,UAAA,IAAc,KAAK,GAAG7D;;;QAIlEI,MAAA,CAAO0D,UAAU,mBAChBb,KAAA,CAAC;MAAIC,SAAA,EAAW,GAAGzD,SAAA,WAAoB;8BACrC+D,IAAA,CAACpF,MAAA;QACC2F,WAAA,EAAY;QACZb,SAAA,EAAW,GAAGzD,SAAA,cAAuB;QACrCuE,QAAA,EAAUvD,QAAA;QACVwD,EAAA,EAAG;QACHC,IAAA,EAAK;QACLvB,OAAA,EAASA,CAAA;UACP,IAAI1C,OAAA,EAAS;YACXG,MAAA,CAAO+D,eAAe,CAAC5E,uCAAA,EAAyC;cAC9D6E,OAAA,EAAS;gBAAEnE;cAAQ;YACrB;UACF;QACF;QACAoE,KAAK;QACLC,OAAA,EAASjD,CAAA,CAAE;uBAEbmC,IAAA,CAACpF,MAAA;QACC2F,WAAA,EAAY;QACZb,SAAA,EAAW,GAAGzD,SAAA,gBAAyB;QACvCuE,QAAA,EAAUvD,QAAA;QACVyD,IAAA,EAAK;QACLvB,OAAA,EAAU4B,CAAA;UACRA,CAAA,CAAEhC,cAAc;UAChBR,kBAAA;QACF;QACAsC,KAAK;QACLC,OAAA,EAASjD,CAAA,CAAE;;QAKhB,CAAC,CAACrB,KAAA,iBAASwD,IAAA,CAAC7B,cAAA;MAAe6C,MAAA,EAAQtC;;;AAG1C;AAEA,OAAO,MAAMuC,qBAAA,GAAyB5E,KAAA;EACpC,oBAAO2D,IAAA,CAAC5D,SAAA;IAAW,GAAGC;;AACxB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","useLexicalListDrawer","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","EnabledRelationshipsCondition","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","editor","relationTo","replaceNodeKey","value","dispatchCommand","update","node","replace","RelationshipDrawerComponent","t0","$","enabledCollectionSlugs","t1","selectedCollectionSlug","setSelectedCollectionSlug","setReplaceNodeKey","t2","undefined","t3","collectionSlugs","selectedCollection","closeListDrawer","isListDrawerOpen","ListDrawer","openListDrawer","t4","t5","registerCommand","payload","nodeKey","t6","t7","collectionSlug","docID","onSelect","t8","t9","_jsx","RelationshipDrawer","props","length"],"sources":["../../../../../src/features/relationship/client/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useLexicalListDrawer } from '../../../../utilities/fieldsDrawer/useLexicalListDrawer.js'\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 { closeListDrawer, isListDrawerOpen, ListDrawer, openListDrawer } = useLexicalListDrawer({\n collectionSlugs: enabledCollectionSlugs ? enabledCollectionSlugs : undefined,\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 openListDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openListDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertRelationship({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: docID,\n })\n closeListDrawer()\n },\n [editor, closeListDrawer, 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 }, [isListDrawerOpen, enabledCollectionSlugs])\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const RelationshipDrawer = (props: Props): React.ReactNode => {\n return (props?.enabledCollectionSlugs?.length ?? -1) > 0 ? ( // If enabledCollectionSlugs it overrides what EnabledRelationshipsCondition is doing\n <RelationshipDrawerComponent {...props} />\n ) : (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,uBAAuB,QAAQ;AACvD,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAExD,SAASC,oBAAoB,QAAQ;AACrC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,6BAA6B,QAAQ;AAC9C,SAASC,uCAAuC,QAAQ;AAExD,MAAMC,kBAAA,GAAqBA,CAAC;EAC1BC,MAAM;EACNC,UAAU;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,EAAA;EAAA;IAAAA,EAAA,GAAArB,CAAA;EAAA;EAAA,IAAAyB,EAAA;EAAA,IAAAzB,CAAA,SAAAY,gBAAA,IAAAZ,CAAA,SAAAC,sBAAA;IAAGwB,EAAA,IAACb,gBAAA,EAAkBX,sBAAA;IAAuBD,CAAA,OAAAY,gBAAA;IAAAZ,CAAA,OAAAC,sBAAA;IAAAD,CAAA,OAAAyB,EAAA;EAAA;IAAAA,EAAA,GAAAzB,CAAA;EAAA;EAJ7ClB,SAAA,CAAUuC,EAIV,EAAGI,EAA0C;EAAA,IAAAC,EAAA;EAAA,IAAA1B,CAAA,SAAAwB,QAAA,IAAAxB,CAAA,SAAAa,UAAA;IAEtCa,EAAA,GAAAC,IAAA,CAACd,UAAA;MAAAW;IAAA,C;;;;;;;SAADE,E;CACT;AAEA,OAAO,MAAME,kBAAA,GAAsBC,KAAA;EACjC,OAAO,CAACA,KAAA,EAAO5B,sBAAA,EAAwB6B,MAAA,IAAU,CAAC,KAAK,iBACrDH,IAAA,CAAC7B,2BAAA;IAA6B,GAAG+B;oBAEjCF,IAAA,CAACxC,6BAAA;IAA+B,GAAG0C,KAAK;cACtC,aAAAF,IAAA,CAAC7B,2BAAA;MAA6B,GAAG+B;;;AAGvC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","useLexicalListDrawer","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","EnabledRelationshipsCondition","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","editor","relationTo","replaceNodeKey","value","dispatchCommand","update","node","replace","RelationshipDrawerComponent","t0","$","enabledCollectionSlugs","t1","selectedCollectionSlug","setSelectedCollectionSlug","setReplaceNodeKey","t2","undefined","t3","collectionSlugs","selectedCollection","closeListDrawer","isListDrawerOpen","ListDrawer","openListDrawer","t4","t5","registerCommand","payload","nodeKey","t6","t7","collectionSlug","docID","onSelect","t8","t9","_jsx","RelationshipDrawer","props","length"],"sources":["../../../../../src/features/relationship/client/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useLexicalListDrawer } from '../../../../utilities/fieldsDrawer/useLexicalListDrawer.js'\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 { closeListDrawer, isListDrawerOpen, ListDrawer, openListDrawer } = useLexicalListDrawer({\n collectionSlugs: enabledCollectionSlugs ? enabledCollectionSlugs : undefined,\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 openListDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openListDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }: { collectionSlug: string; docID: number | string }) => {\n insertRelationship({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: docID,\n })\n closeListDrawer()\n },\n [editor, closeListDrawer, 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 }, [isListDrawerOpen, enabledCollectionSlugs])\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const RelationshipDrawer = (props: Props): React.ReactNode => {\n return (props?.enabledCollectionSlugs?.length ?? -1) > 0 ? ( // If enabledCollectionSlugs it overrides what EnabledRelationshipsCondition is doing\n <RelationshipDrawerComponent {...props} />\n ) : (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,uBAAuB,QAAQ;AACvD,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAExD,SAASC,oBAAoB,QAAQ;AACrC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,6BAA6B,QAAQ;AAC9C,SAASC,uCAAuC,QAAQ;AAExD,MAAMC,kBAAA,GAAqBA,CAAC;EAC1BC,MAAM;EACNC,UAAU;EACVC,cAAc;EACdC;AAAK,CAMN;EACC,IAAI,CAACD,cAAA,EAAgB;IACnBF,MAAA,CAAOI,eAAe,CAACR,2BAAA,EAA6B;MAClDK,UAAA;MACAE;IACF;EACF,OAAO;IACLH,MAAA,CAAOK,MAAM,CAAC;MACZ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uBD,CAAA,OAAAY,gBAAA;IAAAZ,CAAA,OAAAC,sBAAA;IAAAD,CAAA,OAAAyB,EAAA;EAAA;IAAAA,EAAA,GAAAzB,CAAA;EAAA;EAJ7ClB,SAAA,CAAUuC,EAIV,EAAGI,EAA0C;EAAA,IAAAC,EAAA;EAAA,IAAA1B,CAAA,SAAAwB,QAAA,IAAAxB,CAAA,SAAAa,UAAA;IAEtCa,EAAA,GAAAC,IAAA,CAACd,UAAA;MAAAW;IAAA,C;;;;;;;SAADE,E;CACT;AAEA,OAAO,MAAME,kBAAA,GAAsBC,KAAA;EACjC,OAAO,CAACA,KAAA,EAAO5B,sBAAA,EAAwB6B,MAAA,IAAU,CAAC,KAAK,iBACrDH,IAAA,CAAC7B,2BAAA;IAA6B,GAAG+B;oBAEjCF,IAAA,CAACxC,6BAAA;IAA+B,GAAG0C,KAAK;cACtC,aAAAF,IAAA,CAAC7B,2BAAA;MAA6B,GAAG+B;;;AAGvC","ignoreList":[]}
@@ -25,7 +25,7 @@ export declare class RelationshipServerNode extends DecoratorBlockNode {
25
25
  static importDOM(): DOMConversionMap<HTMLDivElement> | null;
26
26
  static importJSON(serializedNode: SerializedRelationshipNode): RelationshipServerNode;
27
27
  static isInline(): false;
28
- decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null;
28
+ decorate(_editor: LexicalEditor, _config: EditorConfig): JSX.Element | null;
29
29
  exportDOM(): DOMExportOutput;
30
30
  exportJSON(): SerializedRelationshipNode;
31
31
  getData(): RelationshipData;
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/server/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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AAO,IAAI,gBAAgB;IAI3B,cAAc,IAAI,MAAM;IAIxB,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;CAItC;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,gBAAgB,GAAG,sBAAsB,CAI5F;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,sBAAsB,GAAG,SAAS,GAC5D,IAAI,IAAI,sBAAsB,CAEhC"}
1
+ {"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/server/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,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAEhF,MAAM,MAAM,gBAAgB,GAAG;KAC5B,eAAe,IAAI,cAAc,GAAG;QACnC,UAAU,EAAE,eAAe,CAAA;QAC3B,KAAK,EAAE,sBAAsB,CAAC,eAAe,CAAC,GAAG,MAAM,GAAG,MAAM,CAAA;KACjE;CACF,CAAC,cAAc,CAAC,CAAA;AAEjB,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,IAAI,EAAE,cAAc,CAAA;CACrB,GAAG,MAAM,CAAC,gBAAgB,EAAE,4BAA4B,CAAC,CAAA;AAgB1D,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,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,sBAAsB,GAAG,sBAAsB;IAQlE,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,sBAAsB;IAcrF,MAAM,CAAC,QAAQ,IAAI,KAAK;IAIxB,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI;IAI3E,SAAS,IAAI,eAAe;IAa5B,UAAU,IAAI,0BAA0B;IASxC,OAAO,IAAI,gBAAgB;IAI3B,cAAc,IAAI,MAAM;IAIxB,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;CAItC;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,gBAAgB,GAAG,sBAAsB,CAI5F;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,sBAAsB,GAAG,SAAS,GAC5D,IAAI,IAAI,sBAAsB,CAEhC"}
@@ -61,12 +61,12 @@ export class RelationshipServerNode extends DecoratorBlockNode {
61
61
  static isInline() {
62
62
  return false;
63
63
  }
64
- decorate(editor, config) {
64
+ decorate(_editor, _config) {
65
65
  return null;
66
66
  }
67
67
  exportDOM() {
68
68
  const element = document.createElement('div');
69
- element.setAttribute('data-lexical-relationship-id', String(this.__data?.value));
69
+ element.setAttribute('data-lexical-relationship-id', String(typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value));
70
70
  element.setAttribute('data-lexical-relationship-relationTo', this.__data?.relationTo);
71
71
  const text = document.createTextNode(this.getTextContent());
72
72
  element.append(text);
@@ -86,7 +86,7 @@ export class RelationshipServerNode extends DecoratorBlockNode {
86
86
  return this.getLatest().__data;
87
87
  }
88
88
  getTextContent() {
89
- return `${this.__data?.relationTo} relation to ${this.__data?.value}`;
89
+ return `${this.__data?.relationTo} relation to ${typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value}`;
90
90
  }
91
91
  setData(data) {
92
92
  const writable = this.getWritable();
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipNode.js","names":["DecoratorBlockNode","$relationshipElementToServerNode","domNode","id","getAttribute","relationTo","node","$createServerRelationshipNode","value","RelationshipServerNode","__data","constructor","data","format","key","clone","__format","__key","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","isInline","decorate","editor","config","exportDOM","element","document","createElement","setAttribute","String","text","createTextNode","getTextContent","append","exportJSON","getData","type","getLatest","setData","writable","getWritable","$isServerRelationshipNode"],"sources":["../../../../../src/features/relationship/server/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 { CollectionSlug, DataFromCollectionSlug } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\n\nexport type RelationshipData = {\n [TCollectionSlug in CollectionSlug]: {\n relationTo: TCollectionSlug\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\nexport type SerializedRelationshipNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'relationship'\n} & Spread<RelationshipData, SerializedDecoratorBlockNode>\n\nfunction $relationshipElementToServerNode(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 = $createServerRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipServerNode 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: RelationshipServerNode): RelationshipServerNode {\n return new this({\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: $relationshipElementToServerNode,\n priority: 2,\n }\n },\n }\n }\n\n static importJSON(serializedNode: SerializedRelationshipNode): RelationshipServerNode {\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 = $createServerRelationshipNode(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 | null {\n return null\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: 'relationship',\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 $createServerRelationshipNode(data: RelationshipData): RelationshipServerNode {\n return new RelationshipServerNode({\n data,\n })\n}\n\nexport function $isServerRelationshipNode(\n node: LexicalNode | null | RelationshipServerNode | undefined,\n): node is RelationshipServerNode {\n return node instanceof RelationshipServerNode\n}\n"],"mappings":"AAeA,SAASA,kBAAkB,QAAQ;AAcnC,SAASC,iCAAiCC,OAAuB;EAC/D,MAAMC,EAAA,GAAKD,OAAA,CAAQE,YAAY,CAAC;EAChC,MAAMC,UAAA,GAAaH,OAAA,CAAQE,YAAY,CAAC;EAExC,IAAID,EAAA,IAAM,QAAQE,UAAA,IAAc,MAAM;IACpC,MAAMC,IAAA,GAAOC,6BAAA,CAA8B;MACzCF,UAAA;MACAG,KAAA,EAAOL;IACT;IACA,OAAO;MAAEG;IAAK;EAChB;EACA,OAAO;AACT;AAEA,OAAO,MAAMG,sBAAA,SAA+BT,kBAAA;EAC1CU,MAAA;EAEAC,YAAY;IACVC,IAAI;IACJC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACD,MAAA,EAAQC,GAAA;IACd,IAAI,CAACJ,MAAM,GAAGE,IAAA;EAChB;EAEA,OAAOG,MAAMT,IAA4B,EAA0B;IACjE,OAAO,IAAI,IAAI,CAAC;MACdM,IAAA,EAAMN,IAAA,CAAKI,MAAM;MACjBG,MAAA,EAAQP,IAAA,CAAKU,QAAQ;MACrBF,GAAA,EAAKR,IAAA,CAAKW;IACZ;EACF;EAEA,OAAOC,QAAA,EAAkB;IACvB,OAAO;EACT;EAEA,OAAOC,UAAA,EAAqD;IAC1D,OAAO;MACLC,GAAA,EAAMlB,OAAA;QACJ,IACE,CAACA,OAAA,CAAQmB,YAAY,CAAC,2CACtB,CAACnB,OAAA,CAAQmB,YAAY,CAAC,iCACtB;UACA,OAAO;QACT;QACA,OAAO;UACLC,UAAA,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AAO,GAAG,IAAI,CAAC/B,MAAM,EAAEL,UAAA,gBAA0B,IAAI,CAACK,MAAM,EAAEF,KAAA,EAAO;EACvE;EAEAuC,QAAQnC,IAAsB,EAAQ;IACpC,MAAMoC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAAStC,MAAM,GAAGE,IAAA;EACpB;AACF;AAEA,OAAO,SAASL,8BAA8BK,IAAsB;EAClE,OAAO,IAAIH,sBAAA,CAAuB;IAChCG;EACF;AACF;AAEA,OAAO,SAASsC,0BACd5C,IAA6D;EAE7D,OAAOA,IAAA,YAAgBG,sBAAA;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"RelationshipNode.js","names":["DecoratorBlockNode","$relationshipElementToServerNode","domNode","id","getAttribute","relationTo","node","$createServerRelationshipNode","value","RelationshipServerNode","__data","constructor","data","format","key","clone","__format","__key","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","isInline","decorate","_editor","_config","exportDOM","element","document","createElement","setAttribute","String","text","createTextNode","getTextContent","append","exportJSON","getData","type","getLatest","setData","writable","getWritable","$isServerRelationshipNode"],"sources":["../../../../../src/features/relationship/server/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 { CollectionSlug, DataFromCollectionSlug } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\n\nexport type RelationshipData = {\n [TCollectionSlug in CollectionSlug]: {\n relationTo: TCollectionSlug\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\nexport type SerializedRelationshipNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'relationship'\n} & Spread<RelationshipData, SerializedDecoratorBlockNode>\n\nfunction $relationshipElementToServerNode(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 = $createServerRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipServerNode 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: RelationshipServerNode): RelationshipServerNode {\n return new this({\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: $relationshipElementToServerNode,\n priority: 2,\n }\n },\n }\n }\n\n static importJSON(serializedNode: SerializedRelationshipNode): RelationshipServerNode {\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 = $createServerRelationshipNode(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 | null {\n return null\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n element.setAttribute(\n 'data-lexical-relationship-id',\n String(typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value),\n )\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: 'relationship',\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 ${typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value}`\n }\n\n setData(data: RelationshipData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n}\n\nexport function $createServerRelationshipNode(data: RelationshipData): RelationshipServerNode {\n return new RelationshipServerNode({\n data,\n })\n}\n\nexport function $isServerRelationshipNode(\n node: LexicalNode | null | RelationshipServerNode | undefined,\n): node is RelationshipServerNode {\n return node instanceof RelationshipServerNode\n}\n"],"mappings":"AAeA,SAASA,kBAAkB,QAAQ;AAcnC,SAASC,iCAAiCC,OAAuB;EAC/D,MAAMC,EAAA,GAAKD,OAAA,CAAQE,YAAY,CAAC;EAChC,MAAMC,UAAA,GAAaH,OAAA,CAAQE,YAAY,CAAC;EAExC,IAAID,EAAA,IAAM,QAAQE,UAAA,IAAc,MAAM;IACpC,MAAMC,IAAA,GAAOC,6BAAA,CAA8B;MACzCF,UAAA;MACAG,KAAA,EAAOL;IACT;IACA,OAAO;MAAEG;IAAK;EAChB;EACA,OAAO;AACT;AAEA,OAAO,MAAMG,sBAAA,SAA+BT,kBAAA;EAC1CU,MAAA;EAEAC,YAAY;IACVC,IAAI;IACJC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACD,MAAA,EAAQC,GAAA;IACd,IAAI,CAACJ,MAAM,GAAGE,IAAA;EAChB;EAEA,OAAOG,MAAMT,IAA4B,EAA0B;IACjE,OAAO,IAAI,IAAI,CAAC;MACdM,IAAA,EAAMN,IAAA,CAAKI,MAAM;MACjBG,MAAA,EAAQP,IAAA,CAAKU,QAAQ;MACrBF,GAAA,EAAKR,IAAA,CAAKW;IACZ;EACF;EAEA,OAAOC,QAAA,EAAkB;IACvB,OAAO;EACT;EAEA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AAA;IACf,OAAO;MAAEL;IAAQ;EACnB;EAEAS,WAAA,EAAyC;IACvC,OAAO;MACL,GAAG,KAAK,CAACA,UAAA,EAAY;MACrB,GAAG,IAAI,CAACC,OAAO,EAAE;MACjBC,IAAA,EAAM;MACNnB,OAAA,EAAS;IACX;EACF;EAEAkB,QAAA,EAA4B;IAC1B,OAAO,IAAI,CAACE,SAAS,GAAGpC,MAAM;EAChC;EAEA+B,eAAA,EAAyB;IACvB,OAAO,GAAG,IAAI,CAAC/B,MAAM,EAAEL,UAAA,gBAA0B,OAAO,IAAI,CAACK,MAAM,EAAEF,KAAA,KAAU,WAAW,IAAI,CAACE,MAAM,EAAEF,KAAA,EAAOL,EAAA,GAAK,IAAI,CAACO,MAAM,EAAEF,KAAA,EAAO;EACzI;EAEAuC,QAAQnC,IAAsB,EAAQ;IACpC,MAAMoC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAAStC,MAAM,GAAGE,IAAA;EACpB;AACF;AAEA,OAAO,SAASL,8BAA8BK,IAAsB;EAClE,OAAO,IAAIH,sBAAA,CAAuB;IAChCG;EACF;AACF;AAEA,OAAO,SAASsC,0BACd5C,IAA6D;EAE7D,OAAOA,IAAA,YAAgBG,sBAAA;AACzB","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import type { PluginComponentWithAnchor } from '../../../../typesClient.js';
1
+ import type { PluginComponent } from '../../../../typesClient.js';
2
2
  import type { FixedToolbarFeatureProps } from '../../server/index.js';
3
3
  import './index.scss';
4
- export declare const FixedToolbarPlugin: PluginComponentWithAnchor<FixedToolbarFeatureProps>;
4
+ export declare const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps>;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAE3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAKrE,OAAO,cAAc,CAAA;AAiPrB,eAAO,MAAM,kBAAkB,EAAE,yBAAyB,CAAC,wBAAwB,CAqClF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAKrE,OAAO,cAAc,CAAA;AAqPrB,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,CAkCxE,CAAA"}
@@ -31,7 +31,7 @@ function ButtonGroupItem({
31
31
  }, item.key);
32
32
  }
33
33
  function ToolbarGroupComponent(t0) {
34
- const $ = _c(26);
34
+ const $ = _c(18);
35
35
  const {
36
36
  anchorElem,
37
37
  editor,
@@ -112,68 +112,48 @@ function ToolbarGroupComponent(t0) {
112
112
  const onActiveChange = t4;
113
113
  const t5 = `fixed-toolbar__group fixed-toolbar__group-${group.key}`;
114
114
  let t6;
115
- if ($[8] !== group || $[9] !== DropdownIcon || $[10] !== anchorElem || $[11] !== editor || $[12] !== dropdownLabel || $[13] !== onActiveChange) {
116
- t6 = group.type === "dropdown" && group.items.length && (DropdownIcon ? _jsx(ToolbarDropdown, {
117
- anchorElem,
118
- editor,
119
- group,
120
- Icon: DropdownIcon,
121
- itemsContainerClassNames: ["fixed-toolbar__dropdown-items"],
122
- label: dropdownLabel,
123
- maxActiveItems: 1,
124
- onActiveChange
125
- }) : _jsx(ToolbarDropdown, {
126
- anchorElem,
127
- editor,
128
- group,
129
- itemsContainerClassNames: ["fixed-toolbar__dropdown-items"],
130
- label: dropdownLabel,
131
- maxActiveItems: 1,
132
- onActiveChange
133
- }));
115
+ if ($[8] !== group || $[9] !== DropdownIcon || $[10] !== anchorElem || $[11] !== editor || $[12] !== dropdownLabel || $[13] !== onActiveChange || $[14] !== editorConfig.features.toolbarFixed || $[15] !== index || $[16] !== t5) {
116
+ t6 = _jsxs("div", {
117
+ className: t5,
118
+ children: [group.type === "dropdown" && group.items.length ? DropdownIcon ? _jsx(ToolbarDropdown, {
119
+ anchorElem,
120
+ editor,
121
+ group,
122
+ Icon: DropdownIcon,
123
+ itemsContainerClassNames: ["fixed-toolbar__dropdown-items"],
124
+ label: dropdownLabel,
125
+ maxActiveItems: 1,
126
+ onActiveChange
127
+ }) : _jsx(ToolbarDropdown, {
128
+ anchorElem,
129
+ editor,
130
+ group,
131
+ itemsContainerClassNames: ["fixed-toolbar__dropdown-items"],
132
+ label: dropdownLabel,
133
+ maxActiveItems: 1,
134
+ onActiveChange
135
+ }) : null, group.type === "buttons" && group.items.length ? group.items.map(item_0 => _jsx(ButtonGroupItem, {
136
+ anchorElem,
137
+ editor,
138
+ item: item_0
139
+ }, item_0.key)) : null, index < editorConfig.features.toolbarFixed?.groups.length - 1 && _jsx("div", {
140
+ className: "divider"
141
+ })]
142
+ }, group.key);
134
143
  $[8] = group;
135
144
  $[9] = DropdownIcon;
136
145
  $[10] = anchorElem;
137
146
  $[11] = editor;
138
147
  $[12] = dropdownLabel;
139
148
  $[13] = onActiveChange;
140
- $[14] = t6;
149
+ $[14] = editorConfig.features.toolbarFixed;
150
+ $[15] = index;
151
+ $[16] = t5;
152
+ $[17] = t6;
141
153
  } else {
142
- t6 = $[14];
154
+ t6 = $[17];
143
155
  }
144
- let t7;
145
- if ($[15] !== group || $[16] !== anchorElem || $[17] !== editor) {
146
- t7 = group.type === "buttons" && group.items.length && group.items.map(item_0 => _jsx(ButtonGroupItem, {
147
- anchorElem,
148
- editor,
149
- item: item_0
150
- }, item_0.key));
151
- $[15] = group;
152
- $[16] = anchorElem;
153
- $[17] = editor;
154
- $[18] = t7;
155
- } else {
156
- t7 = $[18];
157
- }
158
- let t8;
159
- if ($[19] !== editorConfig.features.toolbarFixed || $[20] !== index || $[21] !== t6 || $[22] !== t7 || $[23] !== t5 || $[24] !== group.key) {
160
- t8 = _jsxs("div", {
161
- className: t5,
162
- children: [t6, t7, index < editorConfig.features.toolbarFixed?.groups.length - 1 && _jsx("div", {
163
- className: "divider"
164
- })]
165
- }, group.key);
166
- $[19] = editorConfig.features.toolbarFixed;
167
- $[20] = index;
168
- $[21] = t6;
169
- $[22] = t7;
170
- $[23] = t5;
171
- $[24] = group.key;
172
- $[25] = t8;
173
- } else {
174
- t8 = $[25];
175
- }
176
- return t8;
156
+ return t6;
177
157
  }
178
158
  function FixedToolbar({
179
159
  anchorElem,
@@ -215,14 +195,18 @@ function FixedToolbar({
215
195
  // we only need to check for vertical overlap
216
196
  const overlapping = !(currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom);
217
197
  if (overlapping) {
218
- currentToolbarElem.className = 'fixed-toolbar fixed-toolbar--overlapping';
219
- parentToolbarElem.className = 'fixed-toolbar fixed-toolbar--hide';
198
+ currentToolbarElem.classList.remove('fixed-toolbar');
199
+ currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping');
200
+ parentToolbarElem.classList.remove('fixed-toolbar');
201
+ parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide');
220
202
  } else {
221
203
  if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {
222
204
  return;
223
205
  }
224
- currentToolbarElem.className = 'fixed-toolbar';
225
- parentToolbarElem.className = 'fixed-toolbar';
206
+ currentToolbarElem.classList.remove('fixed-toolbar--overlapping');
207
+ currentToolbarElem.classList.add('fixed-toolbar');
208
+ parentToolbarElem.classList.remove('fixed-toolbar--hide');
209
+ parentToolbarElem.classList.add('fixed-toolbar');
226
210
  }
227
211
  }, 50, [currentToolbarRef, parentToolbarElem, y]);
228
212
  return /*#__PURE__*/_jsx("div", {
@@ -259,9 +243,8 @@ const getParentEditorWithFixedToolbar = editorConfigContext => {
259
243
  return false;
260
244
  };
261
245
  export const FixedToolbarPlugin = t0 => {
262
- const $ = _c(7);
246
+ const $ = _c(6);
263
247
  const {
264
- anchorElem,
265
248
  clientProps
266
249
  } = t0;
267
250
  const [currentEditor] = useLexicalComposerContext();
@@ -273,7 +256,7 @@ export const FixedToolbarPlugin = t0 => {
273
256
  const editorConfig = clientProps.applyToFocusedEditor ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig : currentEditorConfig;
274
257
  let t1;
275
258
  let t2;
276
- if ($[0] !== editorConfigContext || $[1] !== clientProps?.disableIfParentHasFixedToolbar || $[2] !== editorConfig || $[3] !== anchorElem || $[4] !== editor) {
259
+ if ($[0] !== editorConfigContext || $[1] !== clientProps?.disableIfParentHasFixedToolbar || $[2] !== editorConfig || $[3] !== editor) {
277
260
  t2 = Symbol.for("react.early_return_sentinel");
278
261
  bb0: {
279
262
  const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext);
@@ -288,7 +271,7 @@ export const FixedToolbarPlugin = t0 => {
288
271
  break bb0;
289
272
  }
290
273
  t1 = _jsx(FixedToolbar, {
291
- anchorElem,
274
+ anchorElem: document.body,
292
275
  editor,
293
276
  editorConfig,
294
277
  parentWithFixedToolbar
@@ -297,13 +280,12 @@ export const FixedToolbarPlugin = t0 => {
297
280
  $[0] = editorConfigContext;
298
281
  $[1] = clientProps?.disableIfParentHasFixedToolbar;
299
282
  $[2] = editorConfig;
300
- $[3] = anchorElem;
301
- $[4] = editor;
302
- $[5] = t1;
303
- $[6] = t2;
283
+ $[3] = editor;
284
+ $[4] = t1;
285
+ $[5] = t2;
304
286
  } else {
305
- t1 = $[5];
306
- t2 = $[6];
287
+ t1 = $[4];
288
+ t2 = $[5];
307
289
  }
308
290
  if (t2 !== Symbol.for("react.early_return_sentinel")) {
309
291
  return t2;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","ButtonGroupItem","anchorElem","editor","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","t0","$","editorConfig","group","index","i18n","fieldProps","t1","featureClientSchemaMap","schemaPath","dropdownLabel","setDropdownLabel","useState","undefined","DropdownIcon","setDropdownIcon","t2","t3","type","items","length","useEffect","t4","t5","activeItems","label","substring","onActiveChange","t6","Icon","itemsContainerClassNames","maxActiveItems","t7","map","item_0","t8","features","toolbarFixed","_jsxs","className","children","groups","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","onFocus","event","stopPropagation","ref","isEditable","Fragment","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","Symbol","for","bb0"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponentWithAnchor } from '../../../../typesClient.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonGroupItem({\n anchorElem,\n editor,\n item,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton editor={editor} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n}): React.ReactNode {\n const { i18n } = useTranslation()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n const [dropdownLabel, setDropdownLabel] = React.useState<string | undefined>(undefined)\n const [DropdownIcon, setDropdownIcon] = React.useState<React.FC | undefined>(undefined)\n\n React.useEffect(() => {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n } else {\n setDropdownIcon(undefined)\n }\n }, [group])\n\n const onActiveChange = React.useCallback(\n ({ activeItems }: { activeItems: ToolbarGroupItem[] }) => {\n if (!activeItems.length) {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n setDropdownLabel(undefined)\n } else {\n setDropdownIcon(undefined)\n setDropdownLabel(undefined)\n }\n return\n }\n const item = activeItems[0]\n\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n setDropdownLabel(label)\n setDropdownIcon(() => item.ChildComponent)\n },\n [group, i18n, featureClientSchemaMap, schemaPath],\n )\n\n return (\n <div className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`} key={group.key}>\n {group.type === 'dropdown' &&\n group.items.length &&\n (DropdownIcon ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={1}\n onActiveChange={onActiveChange}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={1}\n onActiveChange={onActiveChange}\n />\n ))}\n {group.type === 'buttons' &&\n group.items.length &&\n group.items.map((item) => {\n return (\n <ButtonGroupItem anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n })}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n\n const { y } = useScrollInfo()\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.className = 'fixed-toolbar fixed-toolbar--overlapping'\n parentToolbarElem.className = 'fixed-toolbar fixed-toolbar--hide'\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.className = 'fixed-toolbar'\n parentToolbarElem.className = 'fixed-toolbar'\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n >\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponentWithAnchor<FixedToolbarFeatureProps> = ({\n anchorElem,\n clientProps,\n}) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AAQxB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAGhC,SAASC,gBAAgB;EACvBC,UAAU;EACVC,MAAM;EACNC;AAAI,CAKL;EACC,IAAIA,IAAA,CAAKC,SAAS,EAAE;IAClB,OACED,IAAA,EAAMC,SAAA,iBACJC,IAAA,CAACF,IAAA,CAAKC,SAAS;MAACH,UAAA,EAAYA,UAAA;MAAYC,MAAA,EAAQA,MAAA;MAAQC,IAAA,EAAMA;OAAWA,IAAA,CAAKG,GAAG;EAGvF;EAEA,IAAI,CAACH,IAAA,CAAKI,cAAc,EAAE;IACxB,OAAO;EACT;EAEA,oBACEF,IAAA,CAACP,aAAA;IAAcI,MAAA,EAAQA,MAAA;IAAQC,IAAA,EAAMA,IAAA;cACnC,aAAAE,IAAA,CAACF,IAAA,CAAKI,cAAc;KAD0BJ,IAAA,CAAKG,GAAG;AAI5D;AAEA,SAAAE,sBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAApB,EAAA;EAA+B;IAAAW,UAAA;I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sBAAA,GAA+B2B,+BAAA,CAAgCC,mBAAA;MAAA,IAE3D7B,WAAA,EAAAM,8BAAA;QAAA,IACEL,sBAAA;UACK5B,EAAA;UAAA,MAAAmE,GAAA;QAAA;MAAA;MAAA,KAINjF,YAAA,EAAAkC,QAAA,EAAAC,YAAA,EAAAI,MAAA,EAAArB,MAAA;QACIJ,EAAA;QAAA,MAAAmE,GAAA;MAAA;MAIP5E,EAAA,GAAAX,IAAA,CAAA8C,YAAA;QAAAlD,UAAA;QAAAC,MAAA;QAAAS,YAAA;QAAA0C;MAAA,C;;;;;;;;;;;;;;;;SAAArC,E;CAOJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","ButtonGroupItem","anchorElem","editor","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","t0","$","editorConfig","group","index","i18n","fieldProps","t1","featureClientSchemaMap","schemaPath","dropdownLabel","setDropdownLabel","useState","undefined","DropdownIcon","setDropdownIcon","t2","t3","type","items","length","useEffect","t4","t5","activeItems","label","substring","onActiveChange","t6","features","toolbarFixed","_jsxs","className","children","Icon","itemsContainerClassNames","maxActiveItems","map","item_0","groups","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","onFocus","event","stopPropagation","ref","isEditable","Fragment","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","Symbol","for","bb0","document","body"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonGroupItem({\n anchorElem,\n editor,\n item,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton editor={editor} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n const [dropdownLabel, setDropdownLabel] = React.useState<string | undefined>(undefined)\n const [DropdownIcon, setDropdownIcon] = React.useState<React.FC | undefined>(undefined)\n\n React.useEffect(() => {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n } else {\n setDropdownIcon(undefined)\n }\n }, [group])\n\n const onActiveChange = React.useCallback(\n ({ activeItems }: { activeItems: ToolbarGroupItem[] }) => {\n if (!activeItems.length) {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n setDropdownLabel(undefined)\n } else {\n setDropdownIcon(undefined)\n setDropdownLabel(undefined)\n }\n return\n }\n const item = activeItems[0]\n\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n setDropdownLabel(label)\n setDropdownIcon(() => item.ChildComponent)\n },\n [group, i18n, featureClientSchemaMap, schemaPath],\n )\n\n return (\n <div className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`} key={group.key}>\n {group.type === 'dropdown' && group.items.length ? (\n DropdownIcon ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={1}\n onActiveChange={onActiveChange}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={1}\n onActiveChange={onActiveChange}\n />\n )\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n return (\n <ButtonGroupItem anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n\n const { y } = useScrollInfo()\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n >\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AAQxB,SAASC,sBAA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AmD4E,mBAAA,GACnDA,mBAAA;EAAA,IAAAvE,EAAA;EAAA,IAAAS,EAAA;EAAA,IAAAf,CAAA,QAAAuE,mBAAA,IAAAvE,CAAA,QAAAwC,WAAA,EAAAM,8BAAA,IAAA9C,CAAA,QAAAC,YAAA,IAAAD,CAAA,QAAAR,MAAA;IAMOuB,EAAA,GAAAiE,MAAA,CAAAC,GAAA;IAAAC,GAAA;MAJX,MAAAzC,sBAAA,GAA+B6B,+BAAA,CAAgCC,mBAAA;MAAA,IAE3D/B,WAAA,EAAAM,8BAAA;QAAA,IACEL,sBAAA;UACK1B,EAAA;UAAA,MAAAmE,GAAA;QAAA;MAAA;MAAA,KAINjF,YAAA,EAAA2B,QAAA,EAAAC,YAAA,EAAAS,MAAA,EAAAnB,MAAA;QACIJ,EAAA;QAAA,MAAAmE,GAAA;MAAA;MAIP5E,EAAA,GAAAX,IAAA,CAAA4C,YAAA;QAAAhD,UAAA,EAAA4F,QAAA,CAAAC,IAAA;QAAA5F,MAAA;QAAAS,YAAA;QAAAwC;MAAA,C;;;;;;;;;;;;;;;SAAAnC,E;CAOJ","ignoreList":[]}
@@ -35,7 +35,7 @@ function ButtonGroupItem({
35
35
  }, item.key);
36
36
  }
37
37
  function ToolbarGroupComponent(t0) {
38
- const $ = _c(22);
38
+ const $ = _c(14);
39
39
  const {
40
40
  anchorElem,
41
41
  editor,
@@ -90,63 +90,43 @@ function ToolbarGroupComponent(t0) {
90
90
  const onActiveChange = t3;
91
91
  const t4 = `inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`;
92
92
  let t5;
93
- if ($[5] !== group || $[6] !== DropdownIcon || $[7] !== anchorElem || $[8] !== editor || $[9] !== onActiveChange) {
94
- t5 = group.type === "dropdown" && group.items.length && (DropdownIcon ? _jsx(ToolbarDropdown, {
95
- anchorElem,
96
- editor,
97
- group,
98
- Icon: DropdownIcon,
99
- maxActiveItems: 1,
100
- onActiveChange
101
- }) : _jsx(ToolbarDropdown, {
102
- anchorElem,
103
- editor,
104
- group,
105
- maxActiveItems: 1,
106
- onActiveChange
107
- }));
93
+ if ($[5] !== group || $[6] !== DropdownIcon || $[7] !== anchorElem || $[8] !== editor || $[9] !== onActiveChange || $[10] !== editorConfig.features.toolbarInline || $[11] !== index || $[12] !== t4) {
94
+ t5 = _jsxs("div", {
95
+ className: t4,
96
+ children: [group.type === "dropdown" && group.items.length ? DropdownIcon ? _jsx(ToolbarDropdown, {
97
+ anchorElem,
98
+ editor,
99
+ group,
100
+ Icon: DropdownIcon,
101
+ maxActiveItems: 1,
102
+ onActiveChange
103
+ }) : _jsx(ToolbarDropdown, {
104
+ anchorElem,
105
+ editor,
106
+ group,
107
+ maxActiveItems: 1,
108
+ onActiveChange
109
+ }) : null, group.type === "buttons" && group.items.length ? group.items.map(item_0 => _jsx(ButtonGroupItem, {
110
+ anchorElem,
111
+ editor,
112
+ item: item_0
113
+ }, item_0.key)) : null, index < editorConfig.features.toolbarInline?.groups.length - 1 && _jsx("div", {
114
+ className: "divider"
115
+ })]
116
+ }, group.key);
108
117
  $[5] = group;
109
118
  $[6] = DropdownIcon;
110
119
  $[7] = anchorElem;
111
120
  $[8] = editor;
112
121
  $[9] = onActiveChange;
113
- $[10] = t5;
122
+ $[10] = editorConfig.features.toolbarInline;
123
+ $[11] = index;
124
+ $[12] = t4;
125
+ $[13] = t5;
114
126
  } else {
115
- t5 = $[10];
127
+ t5 = $[13];
116
128
  }
117
- let t6;
118
- if ($[11] !== group || $[12] !== anchorElem || $[13] !== editor) {
119
- t6 = group.type === "buttons" && group.items.length && group.items.map(item_0 => _jsx(ButtonGroupItem, {
120
- anchorElem,
121
- editor,
122
- item: item_0
123
- }, item_0.key));
124
- $[11] = group;
125
- $[12] = anchorElem;
126
- $[13] = editor;
127
- $[14] = t6;
128
- } else {
129
- t6 = $[14];
130
- }
131
- let t7;
132
- if ($[15] !== editorConfig.features.toolbarInline || $[16] !== index || $[17] !== t5 || $[18] !== t6 || $[19] !== t4 || $[20] !== group.key) {
133
- t7 = _jsxs("div", {
134
- className: t4,
135
- children: [t5, t6, index < editorConfig.features.toolbarInline?.groups.length - 1 && _jsx("div", {
136
- className: "divider"
137
- })]
138
- }, group.key);
139
- $[15] = editorConfig.features.toolbarInline;
140
- $[16] = index;
141
- $[17] = t5;
142
- $[18] = t6;
143
- $[19] = t4;
144
- $[20] = group.key;
145
- $[21] = t7;
146
- } else {
147
- t7 = $[21];
148
- }
149
- return t7;
129
+ return t5;
150
130
  }
151
131
  function InlineToolbar({
152
132
  anchorElem,