@payloadcms/richtext-lexical 3.0.0-beta.95 → 3.0.0-beta.97

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 (179) hide show
  1. package/dist/exports/client/Field-MPDY6IHA.js +2 -0
  2. package/dist/exports/client/Field-MPDY6IHA.js.map +7 -0
  3. package/dist/exports/client/{RelationshipComponent-EZORSGUZ.js → RelationshipComponent-CPYVT3XN.js} +2 -2
  4. package/dist/exports/client/bundled.css +1 -1
  5. package/dist/exports/client/{chunk-TD7O23AB.js → chunk-BR57XNHD.js} +2 -2
  6. package/dist/exports/client/{chunk-TD7O23AB.js.map → chunk-BR57XNHD.js.map} +1 -1
  7. package/dist/exports/client/{chunk-UJDWBQ2K.js → chunk-EPEFKP5H.js} +2 -2
  8. package/dist/exports/client/{chunk-UJDWBQ2K.js.map → chunk-EPEFKP5H.js.map} +1 -1
  9. package/dist/exports/client/chunk-GK7ZKYHL.js +2 -0
  10. package/dist/exports/client/chunk-GK7ZKYHL.js.map +7 -0
  11. package/dist/exports/client/{chunk-OLSILJA6.js → chunk-MFAXC4ZA.js} +2 -2
  12. package/dist/exports/client/{chunk-OLSILJA6.js.map → chunk-MFAXC4ZA.js.map} +2 -2
  13. package/dist/exports/client/{chunk-V2LKLT2F.js → chunk-PECDZEZY.js} +3 -3
  14. package/dist/exports/client/{chunk-V2LKLT2F.js.map → chunk-PECDZEZY.js.map} +3 -3
  15. package/dist/exports/client/{chunk-YL453UOS.js → chunk-XIBMVIFW.js} +2 -2
  16. package/dist/exports/client/{chunk-YL453UOS.js.map → chunk-XIBMVIFW.js.map} +1 -1
  17. package/dist/exports/client/{component-2YLEVOFH.js → component-3EGTURAI.js} +2 -2
  18. package/dist/exports/client/{component-2YLEVOFH.js.map → component-3EGTURAI.js.map} +1 -1
  19. package/dist/exports/client/{component-7RAP75FW.js → component-BRCRMQID.js} +2 -2
  20. package/dist/exports/client/{component-7RAP75FW.js.map → component-BRCRMQID.js.map} +1 -1
  21. package/dist/exports/client/{component-LLWMZU6K.js → component-GAX6BHKZ.js} +2 -2
  22. package/dist/exports/client/{componentInline-YSHGRL2J.js → componentInline-RETIC4OV.js} +2 -2
  23. package/dist/exports/client/index.d.ts +2 -2
  24. package/dist/exports/client/index.d.ts.map +1 -1
  25. package/dist/exports/client/index.js +5 -5
  26. package/dist/exports/client/index.js.map +4 -4
  27. package/dist/features/blocks/client/component/index.js.map +1 -1
  28. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  29. package/dist/features/blocks/server/index.d.ts.map +1 -1
  30. package/dist/features/blocks/server/index.js +27 -25
  31. package/dist/features/blocks/server/index.js.map +1 -1
  32. package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -1
  33. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  34. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  35. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +1 -1
  36. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  37. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  38. package/dist/features/converters/html/converter/index.d.ts +5 -5
  39. package/dist/features/converters/html/converter/index.d.ts.map +1 -1
  40. package/dist/features/converters/html/converter/index.js.map +1 -1
  41. package/dist/features/converters/html/converter/types.d.ts +1 -1
  42. package/dist/features/converters/html/converter/types.d.ts.map +1 -1
  43. package/dist/features/converters/html/converter/types.js.map +1 -1
  44. package/dist/features/converters/html/field/index.d.ts.map +1 -1
  45. package/dist/features/converters/html/field/index.js +3 -1
  46. package/dist/features/converters/html/field/index.js.map +1 -1
  47. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +1 -1
  48. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  49. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  50. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts +1 -1
  51. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  52. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  53. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
  54. package/dist/features/experimental_table/client/utils/debounce.js +4 -4
  55. package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
  56. package/dist/features/experimental_table/client/utils/useDebounce.js.map +1 -1
  57. package/dist/features/experimental_table/server/index.d.ts.map +1 -1
  58. package/dist/features/experimental_table/server/index.js +3 -1
  59. package/dist/features/experimental_table/server/index.js.map +1 -1
  60. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  61. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +1 -1
  62. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  63. package/dist/features/link/client/index.js +1 -1
  64. package/dist/features/link/client/index.js.map +1 -1
  65. package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
  66. package/dist/features/link/client/plugins/autoLink/index.js +3 -1
  67. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  68. package/dist/features/link/client/plugins/floatingLinkEditor/index.d.ts.map +1 -1
  69. package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
  70. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  71. package/dist/features/link/nodes/LinkNode.js +2 -2
  72. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  73. package/dist/features/link/server/index.d.ts.map +1 -1
  74. package/dist/features/link/server/index.js +2 -0
  75. package/dist/features/link/server/index.js.map +1 -1
  76. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
  77. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  78. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  79. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
  80. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  81. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  82. package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -1
  83. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  84. package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -1
  85. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  86. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +2 -2
  87. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  88. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +10 -4
  89. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  90. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts +2 -2
  91. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  92. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +6 -6
  93. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  94. package/dist/features/typesClient.d.ts +6 -6
  95. package/dist/features/typesClient.d.ts.map +1 -1
  96. package/dist/features/typesClient.js.map +1 -1
  97. package/dist/features/typesServer.d.ts +9 -8
  98. package/dist/features/typesServer.d.ts.map +1 -1
  99. package/dist/features/typesServer.js.map +1 -1
  100. package/dist/features/upload/client/component/index.js.map +1 -1
  101. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  102. package/dist/features/upload/client/nodes/UploadNode.js +1 -1
  103. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  104. package/dist/features/upload/server/feature.server.d.ts.map +1 -1
  105. package/dist/features/upload/server/feature.server.js +5 -1
  106. package/dist/features/upload/server/feature.server.js.map +1 -1
  107. package/dist/field/Field.js +1 -1
  108. package/dist/field/Field.js.map +1 -1
  109. package/dist/field/bundled.css +1 -1
  110. package/dist/field/index.js +1 -1
  111. package/dist/field/index.js.map +1 -1
  112. package/dist/index.d.ts +2 -2
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +7 -5
  115. package/dist/index.js.map +1 -1
  116. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  117. package/dist/lexical/LexicalEditor.js +5 -5
  118. package/dist/lexical/LexicalEditor.js.map +1 -1
  119. package/dist/lexical/LexicalProvider.js +1 -1
  120. package/dist/lexical/LexicalProvider.js.map +1 -1
  121. package/dist/lexical/config/client/EditorConfigProvider.d.ts +1 -1
  122. package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  123. package/dist/lexical/config/client/EditorConfigProvider.js +1 -1
  124. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  125. package/dist/lexical/config/client/sanitize.js +1 -1
  126. package/dist/lexical/config/client/sanitize.js.map +1 -1
  127. package/dist/lexical/config/server/loader.d.ts +2 -1
  128. package/dist/lexical/config/server/loader.d.ts.map +1 -1
  129. package/dist/lexical/config/server/loader.js +2 -0
  130. package/dist/lexical/config/server/loader.js.map +1 -1
  131. package/dist/lexical/config/server/sanitize.d.ts +1 -1
  132. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  133. package/dist/lexical/config/server/sanitize.js +2 -1
  134. package/dist/lexical/config/server/sanitize.js.map +1 -1
  135. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +3 -3
  136. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  137. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +5 -3
  138. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  139. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +1 -1
  140. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  141. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  142. package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  143. package/dist/lexical/plugins/SlashMenu/index.js +1 -1
  144. package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
  145. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  146. package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts.map +1 -1
  147. package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.js +3 -1
  148. package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.js.map +1 -1
  149. package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -1
  150. package/dist/lexical/utils/nodeFormat.d.ts +2 -2
  151. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  152. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  153. package/dist/lexical/utils/rect.d.ts.map +1 -1
  154. package/dist/lexical/utils/rect.js.map +1 -1
  155. package/dist/lexical/utils/url.d.ts.map +1 -1
  156. package/dist/lexical/utils/url.js +18 -6
  157. package/dist/lexical/utils/url.js.map +1 -1
  158. package/dist/types.d.ts +2 -1
  159. package/dist/types.d.ts.map +1 -1
  160. package/dist/types.js.map +1 -1
  161. package/dist/utilities/createServerFeature.d.ts +1 -0
  162. package/dist/utilities/createServerFeature.d.ts.map +1 -1
  163. package/dist/utilities/createServerFeature.js +2 -0
  164. package/dist/utilities/createServerFeature.js.map +1 -1
  165. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  166. package/dist/validate/index.js +1 -1
  167. package/dist/validate/index.js.map +1 -1
  168. package/dist/validate/validateNodes.d.ts +2 -2
  169. package/dist/validate/validateNodes.d.ts.map +1 -1
  170. package/dist/validate/validateNodes.js +2 -2
  171. package/dist/validate/validateNodes.js.map +1 -1
  172. package/package.json +8 -6
  173. package/dist/exports/client/Field-SUWHJ4HF.js +0 -2
  174. package/dist/exports/client/Field-SUWHJ4HF.js.map +0 -7
  175. package/dist/exports/client/chunk-YSI2QILQ.js +0 -2
  176. package/dist/exports/client/chunk-YSI2QILQ.js.map +0 -7
  177. /package/dist/exports/client/{RelationshipComponent-EZORSGUZ.js.map → RelationshipComponent-CPYVT3XN.js.map} +0 -0
  178. /package/dist/exports/client/{component-LLWMZU6K.js.map → component-GAX6BHKZ.js.map} +0 -0
  179. /package/dist/exports/client/{componentInline-YSHGRL2J.js.map → componentInline-RETIC4OV.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/features/blocks/client/plugin/commands.ts", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
4
- "sourcesContent": ["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nimport type { InsertBlockPayload } from './index.js'\n\nexport const INSERT_BLOCK_COMMAND: LexicalCommand<InsertBlockPayload> =\n createCommand('INSERT_BLOCK_COMMAND')\n\nexport const INSERT_INLINE_BLOCK_COMMAND: LexicalCommand<Partial<InsertBlockPayload>> =\n createCommand('INSERT_INLINE_BLOCK_COMMAND')\n\nexport const OPEN_INLINE_BLOCK_DRAWER_COMMAND: LexicalCommand<{\n fields: Partial<InsertBlockPayload>\n nodeKey?: string\n}> = createCommand('OPEN_INLINE_BLOCK_DRAWER_COMMAND')\n", "'use client'\nimport type {\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type { SerializedServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type SerializedInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\nimport { deepCopyObjectSimple } from 'payload/shared'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nexport type SerializedServerInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedServerInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return null\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const fieldsCopy = deepCopyObjectSimple(fields)\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n\n updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | ServerInlineBlockNode | null | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
4
+ "sourcesContent": ["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nimport type { InsertBlockPayload } from './index.js'\n\nexport const INSERT_BLOCK_COMMAND: LexicalCommand<InsertBlockPayload> =\n createCommand('INSERT_BLOCK_COMMAND')\n\nexport const INSERT_INLINE_BLOCK_COMMAND: LexicalCommand<Partial<InsertBlockPayload>> =\n createCommand('INSERT_INLINE_BLOCK_COMMAND')\n\nexport const OPEN_INLINE_BLOCK_DRAWER_COMMAND: LexicalCommand<{\n fields: Partial<InsertBlockPayload>\n nodeKey?: string\n}> = createCommand('OPEN_INLINE_BLOCK_DRAWER_COMMAND')\n", "'use client'\nimport type {\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type { SerializedServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type SerializedInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\nimport { deepCopyObjectSimple } from 'payload/shared'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nexport type SerializedServerInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedServerInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return null\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const fieldsCopy = deepCopyObjectSimple(fields)\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n\n updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
5
5
  "mappings": "AAGA,OAASA,iBAAAA,MAAqB,UAIvB,IAAMC,EACXD,EAAc,sBAAA,EAEHE,EACXF,EAAc,6BAAA,EAEHG,EAGRH,EAAc,kCAAA,0CCPnB,OAAOI,MAAc,gBACrB,OAAOC,MAAyB,QCGhC,OAAOC,MAAc,gBACrB,OAASC,iBAAAA,MAAqB,UAC9B,OAASC,wBAAAA,MAA4B,iBAmB9B,IAAMC,EAAN,cAAoCF,CAAA,CACzCG,SAEAC,YAAY,CAAEC,OAAAA,EAAQC,IAAAA,CAAG,EAAkD,CACzE,MAAMA,CAAA,EACN,KAAKH,SAAWE,CAClB,CAEA,OAAOE,MAAMC,EAAoD,CAC/D,OAAO,IAAI,KAAK,CACdH,OAAQG,EAAKL,SACbG,IAAKE,EAAKC,KACZ,CAAA,CACF,CAEA,OAAOC,SAAkB,CACvB,MAAO,aACT,CAEA,OAAOC,WAAqD,CAC1D,MAAO,CAAC,CACV,CAEA,OAAOC,WAAWC,EAAwE,CAExF,OADaC,EAA6BD,EAAeR,MAAM,CAEjE,CAEA,OAAOU,UAAkB,CACvB,MAAO,EACT,CAEAC,WAAY,CACV,MAAO,EACT,CACAC,WAAY,CACV,IAAMC,EAAUC,SAASC,cA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B,EAAA,CAAqBmB,SAAU,KAAKC,UAAS,EAAIC,QAAS,KAAKC,OAAM,GAC/E,CAEAC,YAA8C,CAC5C,OAAO,MAAMA,WAAA,CACf,CACF,EAEO,SAASV,EAAuBC,EAAwC,CAC7E,OAAO,IAAIR,EAAgB,CACzBQ,OAAQ,CACN,GAAGA,EACHU,GAAIV,GAAQU,IAAM,IAAIC,EAASpB,QAAO,EAAGqB,YAAW,CACtD,CACF,CAAA,CACF,CAEO,SAASC,EACdlB,EAAsD,CAEtD,OAAOA,aAAgBH,CACzB",
6
6
  "names": ["createCommand", "INSERT_BLOCK_COMMAND", "INSERT_INLINE_BLOCK_COMMAND", "OPEN_INLINE_BLOCK_DRAWER_COMMAND", "ObjectID", "React", "ObjectID", "DecoratorNode", "deepCopyObjectSimple", "ServerInlineBlockNode", "__fields", "constructor", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getLatest", "setFields", "fieldsCopy", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "editor", "config", "_jsx", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use client";import{a as U,b as A,c as P,f as I}from"./chunk-TD7O23AB.js";import{b as v}from"./chunk-OLSILJA6.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";import{useLexicalComposerContext as te}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as oe}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as le}from"@lexical/utils";import{getTranslation as K}from"@payloadcms/translations";import{Button as w,DrawerToggler as ae,File as re,formatDrawerSlug as ie,useConfig as ne,useDocumentDrawer as se,useEditDepth as de,useModal as ce,usePayloadAPI as ue,useTranslation as me}from"@payloadcms/ui";import{$getNodeByKey as N,$getSelection as pe,$isNodeSelection as fe,CLICK_COMMAND as ge,COMMAND_PRIORITY_LOW as S,KEY_BACKSPACE_COMMAND as he,KEY_DELETE_COMMAND as _e}from"lexical";import{useCallback as d,useEffect as Ce,useId as De,useReducer as be,useRef as ve,useState as we}from"react";var o="lexical-upload",j={depth:0},Ne=c=>{let{data:{fields:B,relationTo:$,value:n},nodeKey:a}=c;if(typeof n=="object")throw new Error("Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.");let{config:{collections:F,routes:{api:k},serverURL:W}}=ne(),h=ve(null),{closeModal:x}=ce(),{uuid:Y}=v(),z=de(),[l]=te(),[r,u,_]=oe(a),{editorConfig:H,field:C}=v(),{i18n:R,t:m}=me(),[E,q]=be(e=>e+1,0),[i]=we(()=>F.find(e=>e.slug===$)),G=De(),p=ie({slug:"lexical-upload-drawer-"+Y+G,depth:z}),[J,Q,{closeDrawer:y}]=se({id:n,collectionSlug:i.slug}),[{data:f},{setParams:M}]=ue(`${W}${k}/${i.slug}/${n}`,{initialParams:j}),L=f?.thumbnailURL||f?.url,V=d(()=>{l.update(()=>{N(a).remove()})},[l,a]),X=d(e=>{M({...j,cacheBust:E}),q(),y()},[M,E,y]),D=d(e=>{if(r&&fe(pe())){e.preventDefault();let g=N(a);if(I(g))return g.remove(),!0}return!1},[r,a]),O=d(e=>e.target===h.current||h.current?.contains(e.target)?(e.shiftKey?u(!r):r||(_(),u(!0)),!0):!1,[r,u,_]);Ce(()=>le(l.registerCommand(ge,O,S),l.registerCommand(_e,D,S),l.registerCommand(he,D,S)),[_,l,r,a,D,u,O]);let T=H?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[i.slug]?.hasExtraFields,Z=d((e,g)=>{l.update(()=>{let b=N(a);if(b){let ee={...b.getData(),fields:g};b.setData(ee)}}),x(p)},[x,l,p,a]);return s("div",{className:[o,r&&`${o}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:h,children:[s("div",{className:`${o}__card`,children:[s("div",{className:`${o}__topRow`,children:[t("div",{className:`${o}__thumbnail`,children:L?t("img",{alt:f?.filename,"data-lexical-upload-id":n,"data-lexical-upload-relation-to":$,src:L}):t(re,{})}),s("div",{className:`${o}__topRowRightPanel`,children:[t("div",{className:`${o}__collectionLabel`,children:K(i.labels.singular,R)}),l.isEditable()&&s("div",{className:`${o}__actions`,children:[T?t(ae,{className:`${o}__upload-drawer-toggler`,disabled:C?.admin?.readOnly,slug:p,children:t(w,{buttonStyle:"icon-label",el:"div",icon:"edit",onClick:e=>{e.preventDefault()},round:!0,tooltip:m("fields:editRelationship")})}):null,t(w,{buttonStyle:"icon-label",disabled:C?.admin?.readOnly,el:"div",icon:"swap",onClick:()=>{l.dispatchCommand(P,{replace:{nodeKey:a}})},round:!0,tooltip:m("fields:swapUpload")}),t(w,{buttonStyle:"icon-label",className:`${o}__removeButton`,disabled:C?.admin?.readOnly,icon:"x",onClick:e=>{e.preventDefault(),V()},round:!0,tooltip:m("fields:removeUpload")})]})]})]}),t("div",{className:`${o}__bottomRow`,children:t(Q,{className:`${o}__doc-drawer-toggler`,children:t("strong",{children:f?.filename})})})]}),n&&t(J,{onSave:X}),T?t(U,{data:B,drawerSlug:p,drawerTitle:m("general:editLabel",{label:K(i.labels.singular,R)}),featureKey:"upload",handleDrawerSubmit:Z,schemaPathSuffix:i.slug}):null]})},Ke=c=>t(A,{...c,uploads:!0,children:t(Ne,{...c})});export{Ke as UploadComponent};
2
- //# sourceMappingURL=component-2YLEVOFH.js.map
1
+ "use client";import{a as U,b as A,c as P,f as I}from"./chunk-BR57XNHD.js";import{b as v}from"./chunk-MFAXC4ZA.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";import{useLexicalComposerContext as te}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as oe}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as le}from"@lexical/utils";import{getTranslation as K}from"@payloadcms/translations";import{Button as w,DrawerToggler as ae,File as re,formatDrawerSlug as ie,useConfig as ne,useDocumentDrawer as se,useEditDepth as de,useModal as ce,usePayloadAPI as ue,useTranslation as me}from"@payloadcms/ui";import{$getNodeByKey as N,$getSelection as pe,$isNodeSelection as fe,CLICK_COMMAND as ge,COMMAND_PRIORITY_LOW as S,KEY_BACKSPACE_COMMAND as he,KEY_DELETE_COMMAND as _e}from"lexical";import{useCallback as d,useEffect as Ce,useId as De,useReducer as be,useRef as ve,useState as we}from"react";var o="lexical-upload",j={depth:0},Ne=c=>{let{data:{fields:B,relationTo:$,value:n},nodeKey:a}=c;if(typeof n=="object")throw new Error("Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.");let{config:{collections:F,routes:{api:k},serverURL:W}}=ne(),h=ve(null),{closeModal:x}=ce(),{uuid:Y}=v(),z=de(),[l]=te(),[r,u,_]=oe(a),{editorConfig:H,field:C}=v(),{i18n:R,t:m}=me(),[E,q]=be(e=>e+1,0),[i]=we(()=>F.find(e=>e.slug===$)),G=De(),p=ie({slug:"lexical-upload-drawer-"+Y+G,depth:z}),[J,Q,{closeDrawer:y}]=se({id:n,collectionSlug:i.slug}),[{data:f},{setParams:M}]=ue(`${W}${k}/${i.slug}/${n}`,{initialParams:j}),L=f?.thumbnailURL||f?.url,V=d(()=>{l.update(()=>{N(a).remove()})},[l,a]),X=d(e=>{M({...j,cacheBust:E}),q(),y()},[M,E,y]),D=d(e=>{if(r&&fe(pe())){e.preventDefault();let g=N(a);if(I(g))return g.remove(),!0}return!1},[r,a]),O=d(e=>e.target===h.current||h.current?.contains(e.target)?(e.shiftKey?u(!r):r||(_(),u(!0)),!0):!1,[r,u,_]);Ce(()=>le(l.registerCommand(ge,O,S),l.registerCommand(_e,D,S),l.registerCommand(he,D,S)),[_,l,r,a,D,u,O]);let T=H?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[i.slug]?.hasExtraFields,Z=d((e,g)=>{l.update(()=>{let b=N(a);if(b){let ee={...b.getData(),fields:g};b.setData(ee)}}),x(p)},[x,l,p,a]);return s("div",{className:[o,r&&`${o}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:h,children:[s("div",{className:`${o}__card`,children:[s("div",{className:`${o}__topRow`,children:[t("div",{className:`${o}__thumbnail`,children:L?t("img",{alt:f?.filename,"data-lexical-upload-id":n,"data-lexical-upload-relation-to":$,src:L}):t(re,{})}),s("div",{className:`${o}__topRowRightPanel`,children:[t("div",{className:`${o}__collectionLabel`,children:K(i.labels.singular,R)}),l.isEditable()&&s("div",{className:`${o}__actions`,children:[T?t(ae,{className:`${o}__upload-drawer-toggler`,disabled:C?.admin?.readOnly,slug:p,children:t(w,{buttonStyle:"icon-label",el:"div",icon:"edit",onClick:e=>{e.preventDefault()},round:!0,tooltip:m("fields:editRelationship")})}):null,t(w,{buttonStyle:"icon-label",disabled:C?.admin?.readOnly,el:"div",icon:"swap",onClick:()=>{l.dispatchCommand(P,{replace:{nodeKey:a}})},round:!0,tooltip:m("fields:swapUpload")}),t(w,{buttonStyle:"icon-label",className:`${o}__removeButton`,disabled:C?.admin?.readOnly,icon:"x",onClick:e=>{e.preventDefault(),V()},round:!0,tooltip:m("fields:removeUpload")})]})]})]}),t("div",{className:`${o}__bottomRow`,children:t(Q,{className:`${o}__doc-drawer-toggler`,children:t("strong",{children:f?.filename})})})]}),n&&t(J,{onSave:X}),T?t(U,{data:B,drawerSlug:p,drawerTitle:m("general:editLabel",{label:K(i.labels.singular,R)}),featureKey:"upload",handleDrawerSubmit:Z,schemaPathSuffix:i.slug}):null]})},Ke=c=>t(A,{...c,uploads:!0,children:t(Ne,{...c})});export{Ke as UploadComponent};
2
+ //# sourceMappingURL=component-3EGTURAI.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/features/upload/client/component/index.tsx"],
4
- "sourcesContent": ["'use client'\nimport type { ClientCollectionConfig, Data } from 'payload'\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 {\n Button,\n DrawerToggler,\n File,\n formatDrawerSlug,\n useConfig,\n useDocumentDrawer,\n useEditDepth,\n useModal,\n usePayloadAPI,\n useTranslation,\n} 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, useId, useReducer, useRef, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../../typesClient.js'\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadNode } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { EnabledRelationshipsCondition } from '../../../relationship/client/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { $isUploadNode } from '../nodes/UploadNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.',\n )\n }\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n const { closeModal } = useModal()\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const componentID = useId()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-upload-drawer-` + uuid + componentID, // There can be multiple upload components, each with their own drawer, in one single editor => separate them by componentID\n depth: editDepth,\n })\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (data: Data) => {\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 dispatchCacheBust()\n closeDrawer()\n },\n [setParams, cacheBust, closeDrawer],\n )\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n if (isSelected && $isNodeSelection($getSelection())) {\n event.preventDefault()\n const node = $getNodeByKey(nodeKey)\n if ($isUploadNode(node)) {\n node.remove()\n return true\n }\n }\n return false\n },\n [isSelected, nodeKey],\n )\n const onClick = useCallback(\n (event: MouseEvent) => {\n // Check if uploadRef.target or anything WITHIN uploadRef.target was clicked\n if (event.target === uploadRef.current || uploadRef.current?.contains(event.target as Node)) {\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 const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.sanitizedClientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n const onExtraFieldsDrawerSubmit = useCallback(\n (_, data) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: UploadNode | null = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n\n closeModal(drawerSlug)\n },\n [closeModal, editor, drawerSlug, nodeKey],\n )\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={uploadRef}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? (\n <img\n alt={data?.filename}\n data-lexical-upload-id={value}\n data-lexical-upload-relation-to={relationTo}\n src={thumbnailSRC}\n />\n ) : (\n <File />\n )}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.admin?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value && <DocumentDrawer onSave={updateUpload} />}\n {hasExtraFields ? (\n <FieldsDrawer\n data={fields}\n drawerSlug={drawerSlug}\n drawerTitle={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n featureKey=\"upload\"\n handleDrawerSubmit={onExtraFieldsDrawerSubmit}\n schemaPathSuffix={relatedCollection.slug}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],
4
+ "sourcesContent": ["'use client'\nimport type { ClientCollectionConfig, Data } from 'payload'\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 {\n Button,\n DrawerToggler,\n File,\n formatDrawerSlug,\n useConfig,\n useDocumentDrawer,\n useEditDepth,\n useModal,\n usePayloadAPI,\n useTranslation,\n} 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, useId, useReducer, useRef, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../../typesClient.js'\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadNode } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { EnabledRelationshipsCondition } from '../../../relationship/client/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { $isUploadNode } from '../nodes/UploadNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.',\n )\n }\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n const { closeModal } = useModal()\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const componentID = useId()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-upload-drawer-` + uuid + componentID, // There can be multiple upload components, each with their own drawer, in one single editor => separate them by componentID\n depth: editDepth,\n })\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (data: Data) => {\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 dispatchCacheBust()\n closeDrawer()\n },\n [setParams, cacheBust, closeDrawer],\n )\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n if (isSelected && $isNodeSelection($getSelection())) {\n event.preventDefault()\n const node = $getNodeByKey(nodeKey)\n if ($isUploadNode(node)) {\n node.remove()\n return true\n }\n }\n return false\n },\n [isSelected, nodeKey],\n )\n const onClick = useCallback(\n (event: MouseEvent) => {\n // Check if uploadRef.target or anything WITHIN uploadRef.target was clicked\n if (event.target === uploadRef.current || uploadRef.current?.contains(event.target as Node)) {\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 const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.sanitizedClientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n const onExtraFieldsDrawerSubmit = useCallback(\n (_, data) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: null | UploadNode = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n\n closeModal(drawerSlug)\n },\n [closeModal, editor, drawerSlug, nodeKey],\n )\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={uploadRef}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? (\n <img\n alt={data?.filename}\n data-lexical-upload-id={value}\n data-lexical-upload-relation-to={relationTo}\n src={thumbnailSRC}\n />\n ) : (\n <File />\n )}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.admin?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value && <DocumentDrawer onSave={updateUpload} />}\n {hasExtraFields ? (\n <FieldsDrawer\n data={fields}\n drawerSlug={drawerSlug}\n drawerTitle={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n featureKey=\"upload\"\n handleDrawerSubmit={onExtraFieldsDrawerSubmit}\n schemaPathSuffix={relatedCollection.slug}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],
5
5
  "mappings": "oKAGA,OAASA,6BAAAA,OAAiC,2CAC1C,OAASC,2BAAAA,OAA+B,4CACxC,OAASC,iBAAAA,OAAqB,iBAC9B,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,iBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,aAAAA,GACAC,qBAAAA,GACAC,gBAAAA,GACAC,YAAAA,GACAC,iBAAAA,GACAC,kBAAAA,OACK,iBACP,OACEC,iBAAAA,EACAC,iBAAAA,GACAC,oBAAAA,GACAC,iBAAAA,GACAC,wBAAAA,EACAC,yBAAAA,GACAC,sBAAAA,OACK,UACP,OAAgBC,eAAAA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AEJoE,EAACa,EAAA,CACCC,YAAY,aACZJ,SAAUhF,GAAOiF,OAAOC,SACxBG,GAAG,MACHC,KAAK,OACL7C,QAASA,IAAA,CACPhD,EAAOiG,gBAAgBC,EAAmC,CACxDC,QAAS,CAAEnH,QAAAA,CAAQ,CACrB,CAAA,CACF,EACA+G,MAAK,GACLC,QAASvF,EAAE,mBAAA,IAEboE,EAACa,EAAA,CACCC,YAAY,aACZpB,UAAW,GAAGhG,CAAA,iBACdgH,SAAUhF,GAAOiF,OAAOC,SACxBI,KAAK,IACL7C,QAAU8C,GAAA,CACRA,EAAEjD,eAAc,EAChBV,EAAA,CACF,EACA4D,MAAK,GACLC,QAASvF,EAAE,qBAAA,aAMrBoE,EAAC,MAAA,CAAIN,UAAW,GAAGhG,CAAA,uBACjBsG,EAACpD,EAAA,CAAsB8C,UAAW,GAAGhG,CAAA,gCACnCsG,EAAC,SAAA,UAAQjG,GAAMmG,kBAIpBhG,GAAS8F,EAACrD,EAAA,CAAe4E,OAAQ5D,IACjCoB,EACCiB,EAACwB,EAAA,CACCzH,KAAMC,EACNyC,WAAYA,EACZgF,YAAa7F,EAAE,oBAAqB,CAClC8F,MAAOrB,EAAenE,EAAkBoE,OAAOC,SAAU5E,CAAA,CAC3D,CAAA,EACAgG,WAAW,SACXC,mBAAoBzC,EACpB0C,iBAAkB3F,EAAkBI,OAEpC,IAAA,GAGV,EAEawF,GAAmBhI,GAE5BkG,EAAC+B,EAAA,CAA+B,GAAGjI,EAAOkI,QAAO,YAC/ChC,EAACnG,GAAA,CAAW,GAAGC",
6
6
  "names": ["useLexicalComposerContext", "useLexicalNodeSelection", "mergeRegister", "getTranslation", "Button", "DrawerToggler", "File", "formatDrawerSlug", "useConfig", "useDocumentDrawer", "useEditDepth", "useModal", "usePayloadAPI", "useTranslation", "$getNodeByKey", "$getSelection", "$isNodeSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "useCallback", "useEffect", "useId", "useReducer", "useRef", "useState", "baseClass", "initialParams", "depth", "Component", "props", "data", "fields", "relationTo", "value", "nodeKey", "Error", "config", "collections", "routes", "api", "serverURL", "useConfig", "uploadRef", "useRef", "closeModal", "useModal", "uuid", "useEditorConfigContext", "editDepth", "useEditDepth", "editor", "useLexicalComposerContext", "isSelected", "setSelected", "clearSelection", "useLexicalNodeSelection", "editorConfig", "field", "i18n", "t", "useTranslation", "cacheBust", "dispatchCacheBust", "useReducer", "state", "relatedCollection", "useState", "find", "coll", "slug", "componentID", "useId", "drawerSlug", "formatDrawerSlug", "DocumentDrawer", "DocumentDrawerToggler", "closeDrawer", "useDocumentDrawer", "id", "collectionSlug", "setParams", "usePayloadAPI", "thumbnailSRC", "thumbnailURL", "url", "removeUpload", "useCallback", "update", "$getNodeByKey", "remove", "updateUpload", "$onDelete", "event", "$isNodeSelection", "$getSelection", "preventDefault", "node", "$isUploadNode", "onClick", "target", "current", "contains", "shiftKey", "useEffect", "mergeRegister", "registerCommand", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_DELETE_COMMAND", "KEY_BACKSPACE_COMMAND", "hasExtraFields", "resolvedFeatureMap", "get", "sanitizedClientFeatureProps", "onExtraFieldsDrawerSubmit", "_", "uploadNode", "newData", "getData", "setData", "_jsxs", "className", "filter", "Boolean", "join", "contentEditable", "ref", "_jsx", "alt", "filename", "src", "File", "getTranslation", "labels", "singular", "isEditable", "DrawerToggler", "disabled", "admin", "readOnly", "Button", "buttonStyle", "el", "icon", "e", "round", "tooltip", "dispatchCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "replace", "onSave", "FieldsDrawer", "drawerTitle", "label", "featureKey", "handleDrawerSubmit", "schemaPathSuffix", "UploadComponent", "EnabledRelationshipsCondition", "uploads"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use client";import{b as T}from"./chunk-OLSILJA6.js";import{jsx as f,jsxs as le}from"react/jsx-runtime";import{Collapsible as se,Form as ie,Pill as ne,RenderComponent as ae,SectionTitle as re,ShimmerEffect as ce,useConfig as de,useDocumentInfo as me,useFieldProps as ue,useFormSubmitted as fe,useTranslation as pe}from"@payloadcms/ui";import{useCallback as be,useEffect as he,useMemo as ke,useState as ye}from"react";import{getTranslation as _e}from"@payloadcms/translations";import{getFormState as I}from"@payloadcms/ui/shared";import{v4 as Ce}from"uuid";import{jsx as k,jsxs as B}from"react/jsx-runtime";import{useLexicalComposerContext as q}from"@lexical/react/LexicalComposerContext.js";import{getTranslation as H}from"@payloadcms/translations";import{Button as W,Collapsible as z,ErrorPill as G,Pill as J,RenderComponent as Q,RenderFields as X,SectionTitle as Y,useDocumentInfo as Z,useFormSubmitted as ee,useTranslation as oe}from"@payloadcms/ui";import{dequal as te}from"dequal/lite";import{$getNodeByKey as O}from"lexical";import A,{useCallback as E}from"react";import{c as K}from"react/compiler-runtime";import{useAllFormFields as V}from"@payloadcms/ui";import{reduceFieldsToValues as D}from"payload/shared";import{useEffect as M}from"react";function w({fields:i}){for(let e in i){let o=i[e];Array.isArray(o.rows)&&"value"in o&&(o.disableFormData=!0)}return i}var j=i=>{let e=K(8),{onChange:o}=i,[l]=V(),d,s;e[0]!==l?(s=w({fields:l}),d=D(s,!0),e[0]=l,e[1]=d,e[2]=s):(d=e[1],s=e[2]);let m=d,t,a;return e[3]!==o||e[4]!==s||e[5]!==m?(t=()=>{o&&o({fullFieldsWithValues:s,newFormData:m})},a=[m,o,s],e[3]=o,e[4]=s,e[5]=m,e[6]=t,e[7]=a):(t=e[6],a=e[7]),M(t,a),null};function L(i){for(let e in i){let o=i[e];Array.isArray(o)&&!o?.length?delete i[e]:o&&typeof o=="object"?L(o):o==null&&delete i[e]}}var U=i=>{let{baseClass:e,clientBlock:o,field:l,formSchema:d,nodeKey:s,schemaPath:m}=i,{formData:t}=i,{i18n:a}=oe(),[u]=q(),{getDocPreferences:x,setDocFieldPreferences:P}=Z(),[p,N]=A.useState(()=>{let r=!1;return x().then(c=>{let h=c?.fields[l.name]?.collapsed;h&&h.includes(t.id)&&(r=!0,N(!0))}),r}),F=ee(),[n,S]=A.useState(0),C=F&&n>0,$=[`${e}__row`,C?`${e}__row--has-errors`:`${e}__row--no-errors`].filter(Boolean).join(" "),R=E(({fullFieldsWithValues:r,newFormData:c})=>{if(c.id=t.id,c.blockType=t.blockType,L(c),L(t),te(t,c)||setTimeout(()=>{u.update(()=>{let _=O(s);_&&(t=c,_.setFields(c))})},0),F){let _=0;for(let h of Object.values(r))h?.valid===!1&&_++;S(_)}},[u,s,F,t]),v=E(r=>{x().then(c=>{let h=c?.fields[l.name]?.collapsed,g=h&&h?.length?h:[];r?g.includes(t.id)||g.push(t.id):g.includes(t.id)&&g.splice(g.indexOf(t.id),1),P(l.name,{collapsed:g,hello:"hi"})})},[x,l.name,P,t.id]),b=E(()=>{u.update(()=>{O(s).remove()})},[u,s]);return B(A.Fragment,{children:[k(z,{className:$,collapsibleStyle:C?"error":"default",header:o?.admin?.components?.Label?k(Q,{clientProps:{blockKind:"lexicalBlock",formData:t},mappedComponent:o.admin.components.Label}):B("div",{className:`${e}__block-header`,children:[B("div",{children:[k(J,{className:`${e}__block-pill ${e}__block-pill-${t?.blockType}`,pillStyle:"white",children:typeof o?.labels.singular=="string"?H(o?.labels.singular,a):o.slug}),k(Y,{path:"blockName",readOnly:l?.admin?.readOnly}),C&&k(G,{count:n,i18n:a,withMessage:!0})]}),u.isEditable()&&k(W,{buttonStyle:"icon-label",className:`${e}__removeButton`,disabled:l?.admin?.readOnly,icon:"x",onClick:r=>{r.preventDefault(),b()},round:!0,tooltip:"Remove Block"})]}),isCollapsed:p,onToggle:r=>{v(r),N(r)},children:k(X,{className:`${e}__fields`,fields:d,forceRender:!0,margins:"small",path:"",readOnly:!1,schemaPath:m})},0),k(j,{onChange:R})]})};var y="lexical-block",We=i=>{let{formData:e,nodeKey:o}=i,{config:l}=de(),d=fe(),{id:s}=me(),{path:m,schemaPath:t}=ue(),{field:a}=T(),[u,x]=ye(!1),{field:{richTextComponentMap:P}}=T(),p=`${t}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${e.blockType}`,n=P.get("lexical_internal_feature.blocks.fields.lexical_blocks")[0].blocks.find(v=>v.slug===e.blockType);he(()=>{e&&(async()=>{let b=await I({apiRoute:l.routes.api,body:{id:s,data:e,operation:"update",schemaPath:p},serverURL:l.serverURL});b&&(b.blockName={initialValue:"",passesCondition:!0,valid:!0,value:e.blockName},x(b))})()},[l.routes.api,l.serverURL,p,s]);let S=be(async({formState:v})=>{let b=await I({apiRoute:l.routes.api,body:{id:s,formState:v,operation:"update",schemaPath:p},serverURL:l.serverURL});return b.blockName={initialValue:"",passesCondition:!0,valid:!0,value:e.blockName},b},[l.routes.api,l.serverURL,s,p,e.blockName]),{i18n:C}=pe(),$=[`${y}__row`,`${y}__row--no-errors`].filter(Boolean).join(" "),R=ke(()=>n&&u!==!1?f(ie,{beforeSubmit:[S],fields:n.fields,initialState:u,onChange:[S],submitted:d,uuid:Ce(),children:f(U,{baseClass:y,clientBlock:n,field:a,formData:e,formSchema:n.fields,nodeKey:o,path:`${m}.lexical_internal_feature.blocks.${e.blockType}`,schemaPath:p})}):f(se,{className:$,collapsibleStyle:"default",header:n?.admin?.components?.Label?f(ae,{clientProps:{blockKind:"lexicalBlock",formData:e},mappedComponent:n.admin.components.Label}):f("div",{className:`${y}__block-header`,children:le("div",{children:[f(ne,{className:`${y}__block-pill ${y}__block-pill-${e?.blockType}`,pillStyle:"white",children:n&&typeof n.labels.singular=="string"?_e(n.labels.singular,C):n.slug}),f(re,{path:"blockName",readOnly:a?.admin?.readOnly})]})}),children:f(ce,{height:"35vh"})},0),[n,u,S,d,a,o,m,p,$,C]);return f("div",{className:y+" "+y+"-"+e.blockType,children:R})};export{We as BlockComponent};
2
- //# sourceMappingURL=component-7RAP75FW.js.map
1
+ "use client";import{b as T}from"./chunk-MFAXC4ZA.js";import{jsx as f,jsxs as le}from"react/jsx-runtime";import{Collapsible as se,Form as ie,Pill as ne,RenderComponent as ae,SectionTitle as re,ShimmerEffect as ce,useConfig as de,useDocumentInfo as me,useFieldProps as ue,useFormSubmitted as fe,useTranslation as pe}from"@payloadcms/ui";import{useCallback as be,useEffect as he,useMemo as ke,useState as ye}from"react";import{getTranslation as _e}from"@payloadcms/translations";import{getFormState as I}from"@payloadcms/ui/shared";import{v4 as Ce}from"uuid";import{jsx as k,jsxs as B}from"react/jsx-runtime";import{useLexicalComposerContext as q}from"@lexical/react/LexicalComposerContext.js";import{getTranslation as H}from"@payloadcms/translations";import{Button as W,Collapsible as z,ErrorPill as G,Pill as J,RenderComponent as Q,RenderFields as X,SectionTitle as Y,useDocumentInfo as Z,useFormSubmitted as ee,useTranslation as oe}from"@payloadcms/ui";import{dequal as te}from"dequal/lite";import{$getNodeByKey as O}from"lexical";import A,{useCallback as E}from"react";import{c as K}from"react/compiler-runtime";import{useAllFormFields as V}from"@payloadcms/ui";import{reduceFieldsToValues as D}from"payload/shared";import{useEffect as M}from"react";function w({fields:i}){for(let e in i){let o=i[e];Array.isArray(o.rows)&&"value"in o&&(o.disableFormData=!0)}return i}var j=i=>{let e=K(8),{onChange:o}=i,[l]=V(),d,s;e[0]!==l?(s=w({fields:l}),d=D(s,!0),e[0]=l,e[1]=d,e[2]=s):(d=e[1],s=e[2]);let m=d,t,a;return e[3]!==o||e[4]!==s||e[5]!==m?(t=()=>{o&&o({fullFieldsWithValues:s,newFormData:m})},a=[m,o,s],e[3]=o,e[4]=s,e[5]=m,e[6]=t,e[7]=a):(t=e[6],a=e[7]),M(t,a),null};function L(i){for(let e in i){let o=i[e];Array.isArray(o)&&!o?.length?delete i[e]:o&&typeof o=="object"?L(o):o==null&&delete i[e]}}var U=i=>{let{baseClass:e,clientBlock:o,field:l,formSchema:d,nodeKey:s,schemaPath:m}=i,{formData:t}=i,{i18n:a}=oe(),[u]=q(),{getDocPreferences:x,setDocFieldPreferences:P}=Z(),[p,N]=A.useState(()=>{let r=!1;return x().then(c=>{let h=c?.fields[l.name]?.collapsed;h&&h.includes(t.id)&&(r=!0,N(!0))}),r}),F=ee(),[n,S]=A.useState(0),C=F&&n>0,$=[`${e}__row`,C?`${e}__row--has-errors`:`${e}__row--no-errors`].filter(Boolean).join(" "),R=E(({fullFieldsWithValues:r,newFormData:c})=>{if(c.id=t.id,c.blockType=t.blockType,L(c),L(t),te(t,c)||setTimeout(()=>{u.update(()=>{let _=O(s);_&&(t=c,_.setFields(c))})},0),F){let _=0;for(let h of Object.values(r))h?.valid===!1&&_++;S(_)}},[u,s,F,t]),v=E(r=>{x().then(c=>{let h=c?.fields[l.name]?.collapsed,g=h&&h?.length?h:[];r?g.includes(t.id)||g.push(t.id):g.includes(t.id)&&g.splice(g.indexOf(t.id),1),P(l.name,{collapsed:g,hello:"hi"})})},[x,l.name,P,t.id]),b=E(()=>{u.update(()=>{O(s).remove()})},[u,s]);return B(A.Fragment,{children:[k(z,{className:$,collapsibleStyle:C?"error":"default",header:o?.admin?.components?.Label?k(Q,{clientProps:{blockKind:"lexicalBlock",formData:t},mappedComponent:o.admin.components.Label}):B("div",{className:`${e}__block-header`,children:[B("div",{children:[k(J,{className:`${e}__block-pill ${e}__block-pill-${t?.blockType}`,pillStyle:"white",children:typeof o?.labels.singular=="string"?H(o?.labels.singular,a):o.slug}),k(Y,{path:"blockName",readOnly:l?.admin?.readOnly}),C&&k(G,{count:n,i18n:a,withMessage:!0})]}),u.isEditable()&&k(W,{buttonStyle:"icon-label",className:`${e}__removeButton`,disabled:l?.admin?.readOnly,icon:"x",onClick:r=>{r.preventDefault(),b()},round:!0,tooltip:"Remove Block"})]}),isCollapsed:p,onToggle:r=>{v(r),N(r)},children:k(X,{className:`${e}__fields`,fields:d,forceRender:!0,margins:"small",path:"",readOnly:!1,schemaPath:m})},0),k(j,{onChange:R})]})};var y="lexical-block",We=i=>{let{formData:e,nodeKey:o}=i,{config:l}=de(),d=fe(),{id:s}=me(),{path:m,schemaPath:t}=ue(),{field:a}=T(),[u,x]=ye(!1),{field:{richTextComponentMap:P}}=T(),p=`${t}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${e.blockType}`,n=P.get("lexical_internal_feature.blocks.fields.lexical_blocks")[0].blocks.find(v=>v.slug===e.blockType);he(()=>{e&&(async()=>{let b=await I({apiRoute:l.routes.api,body:{id:s,data:e,operation:"update",schemaPath:p},serverURL:l.serverURL});b&&(b.blockName={initialValue:"",passesCondition:!0,valid:!0,value:e.blockName},x(b))})()},[l.routes.api,l.serverURL,p,s]);let S=be(async({formState:v})=>{let b=await I({apiRoute:l.routes.api,body:{id:s,formState:v,operation:"update",schemaPath:p},serverURL:l.serverURL});return b.blockName={initialValue:"",passesCondition:!0,valid:!0,value:e.blockName},b},[l.routes.api,l.serverURL,s,p,e.blockName]),{i18n:C}=pe(),$=[`${y}__row`,`${y}__row--no-errors`].filter(Boolean).join(" "),R=ke(()=>n&&u!==!1?f(ie,{beforeSubmit:[S],fields:n.fields,initialState:u,onChange:[S],submitted:d,uuid:Ce(),children:f(U,{baseClass:y,clientBlock:n,field:a,formData:e,formSchema:n.fields,nodeKey:o,path:`${m}.lexical_internal_feature.blocks.${e.blockType}`,schemaPath:p})}):f(se,{className:$,collapsibleStyle:"default",header:n?.admin?.components?.Label?f(ae,{clientProps:{blockKind:"lexicalBlock",formData:e},mappedComponent:n.admin.components.Label}):f("div",{className:`${y}__block-header`,children:le("div",{children:[f(ne,{className:`${y}__block-pill ${y}__block-pill-${e?.blockType}`,pillStyle:"white",children:n&&typeof n.labels.singular=="string"?_e(n.labels.singular,C):n.slug}),f(re,{path:"blockName",readOnly:a?.admin?.readOnly})]})}),children:f(ce,{height:"35vh"})},0),[n,u,S,d,a,o,m,p,$,C]);return f("div",{className:y+" "+y+"-"+e.blockType,children:R})};export{We as BlockComponent};
2
+ //# sourceMappingURL=component-BRCRMQID.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/features/blocks/client/component/index.tsx", "../../../src/features/blocks/client/component/BlockContent.tsx", "../../../src/features/blocks/client/component/FormSavePlugin.tsx", "../../../src/features/blocks/client/component/removeEmptyArrayValues.ts"],
4
- "sourcesContent": ["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\n\nimport {\n Collapsible,\n Form,\n Pill,\n RenderComponent,\n SectionTitle,\n ShimmerEffect,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nconst baseClass = 'lexical-block'\nimport type { BlockFieldClient, FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey?: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const { config } = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<FormState | false>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${formData.blockType}`\n\n const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_blocks`\n const blocksField: BlockFieldClient = richTextComponentMap.get(componentMapRenderedBlockPath)[0]\n\n const clientBlock = blocksField.blocks.find((block) => block.slug === formData.blockType)\n\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: formData,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n if (state) {\n state.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n setInitialState(state)\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id]) // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n const formState = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n formState.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return formState\n },\n\n [config.routes.api, config.serverURL, id, schemaFieldsPath, formData.blockName],\n )\n const { i18n } = useTranslation()\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return clientBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n fields={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n clientBlock={clientBlock}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={clientBlock.fields}\n nodeKey={nodeKey}\n path={`${path}.lexical_internal_feature.blocks.${formData.blockType}`}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {clientBlock && typeof clientBlock.labels.singular === 'string'\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly}\n />\n </div>\n </div>\n )\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n clientBlock,\n initialState,\n onChange,\n submitted,\n parentLexicalRichTextField,\n nodeKey,\n path,\n schemaFieldsPath,\n classNames,\n i18n,\n ])\n\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n", "'use client'\nimport type { ClientBlock, ClientField, CollapsedPreferences, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderComponent,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../../types.js'\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\nimport type { BlockNode } from '../nodes/BlocksNode.js'\n\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n clientBlock: ClientBlock\n field: LexicalRichTextFieldProps['field']\n formData: BlockFields\n formSchema: ClientField[]\n nodeKey: string\n path: string\n schemaPath: string\n}\n\n// Recursively remove all undefined values from even being present in formData, as they will\n// cause isDeepEqual to return false if, for example, formData has a key that fields.data\n// does not have, even if it's undefined.\n// Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n// Inside of fields.data however, that sub-blocks blockName property does not exist at all.\nfunction removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const { baseClass, clientBlock, field, formSchema, nodeKey, schemaPath } = props\n let { formData } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(() => {\n let initialState = false\n\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n if (collapsedArray && collapsedArray.includes(formData.id)) {\n initialState = true\n setIsCollapsed(true)\n }\n })\n return initialState\n })\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: BlockFields\n }) => {\n newFormData.id = formData.id\n newFormData.blockType = formData.blockType\n\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node: BlockNode = $getNodeByKey(nodeKey)\n if (node) {\n formData = newFormData\n node.setFields(newFormData)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof clientBlock?.labels.singular === 'string'\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.admin?.readOnly} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n )\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fields={formSchema}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n", "'use client'\nimport type { Data, FormState } from 'payload'\nimport type React from 'react'\n\nimport { useAllFormFields } from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { useEffect } from 'react'\n\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n onChange?: ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => void\n}\n\nexport const FormSavePlugin: React.FC<Props> = (props) => {\n const { onChange } = props\n\n const [_fields] = useAllFormFields()\n\n const fields = removeEmptyArrayValues({ fields: _fields })\n\n // Pass in fields, and indicate if you'd like to \"unflatten\" field data.\n // The result below will reflect the data stored in the form at the given time\n const newFormData = reduceFieldsToValues(fields, true)\n\n useEffect(() => {\n if (onChange) {\n onChange({ fullFieldsWithValues: fields, newFormData })\n }\n }, [newFormData, onChange, fields])\n\n return null\n}\n", "'use client'\nimport type { FormState } from 'payload'\n\n/**\n * By default, if an array field is empty, it will be included in the form state with a value of 0.\n * We do not need this behavior here, By setting `disableFormData` to true, we can prevent the field from being included in the form state\n * like that.\n * @param fields form state\n */\nexport function removeEmptyArrayValues({ fields }: { fields: FormState }): FormState {\n for (const key in fields) {\n const field = fields[key]\n if (Array.isArray(field.rows) && 'value' in field) {\n field.disableFormData = true\n }\n }\n return fields\n}\n"],
4
+ "sourcesContent": ["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\n\nimport {\n Collapsible,\n Form,\n Pill,\n RenderComponent,\n SectionTitle,\n ShimmerEffect,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nconst baseClass = 'lexical-block'\nimport type { BlockFieldClient, FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey?: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const { config } = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<false | FormState>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${formData.blockType}`\n\n const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_blocks`\n const blocksField: BlockFieldClient = richTextComponentMap.get(componentMapRenderedBlockPath)[0]\n\n const clientBlock = blocksField.blocks.find((block) => block.slug === formData.blockType)\n\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: formData,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n if (state) {\n state.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n setInitialState(state)\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id]) // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n const formState = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n formState.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return formState\n },\n\n [config.routes.api, config.serverURL, id, schemaFieldsPath, formData.blockName],\n )\n const { i18n } = useTranslation()\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return clientBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n fields={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n clientBlock={clientBlock}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={clientBlock.fields}\n nodeKey={nodeKey}\n path={`${path}.lexical_internal_feature.blocks.${formData.blockType}`}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {clientBlock && typeof clientBlock.labels.singular === 'string'\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly}\n />\n </div>\n </div>\n )\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n clientBlock,\n initialState,\n onChange,\n submitted,\n parentLexicalRichTextField,\n nodeKey,\n path,\n schemaFieldsPath,\n classNames,\n i18n,\n ])\n\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n", "'use client'\nimport type { ClientBlock, ClientField, CollapsedPreferences, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderComponent,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../../types.js'\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\nimport type { BlockNode } from '../nodes/BlocksNode.js'\n\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n clientBlock: ClientBlock\n field: LexicalRichTextFieldProps['field']\n formData: BlockFields\n formSchema: ClientField[]\n nodeKey: string\n path: string\n schemaPath: string\n}\n\n// Recursively remove all undefined values from even being present in formData, as they will\n// cause isDeepEqual to return false if, for example, formData has a key that fields.data\n// does not have, even if it's undefined.\n// Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n// Inside of fields.data however, that sub-blocks blockName property does not exist at all.\nfunction removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const { baseClass, clientBlock, field, formSchema, nodeKey, schemaPath } = props\n let { formData } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(() => {\n let initialState = false\n\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n if (collapsedArray && collapsedArray.includes(formData.id)) {\n initialState = true\n setIsCollapsed(true)\n }\n })\n return initialState\n })\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: BlockFields\n }) => {\n newFormData.id = formData.id\n newFormData.blockType = formData.blockType\n\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node: BlockNode = $getNodeByKey(nodeKey)\n if (node) {\n formData = newFormData\n node.setFields(newFormData)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof clientBlock?.labels.singular === 'string'\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.admin?.readOnly} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n )\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fields={formSchema}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n", "'use client'\nimport type { Data, FormState } from 'payload'\nimport type React from 'react'\n\nimport { useAllFormFields } from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { useEffect } from 'react'\n\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n onChange?: ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => void\n}\n\nexport const FormSavePlugin: React.FC<Props> = (props) => {\n const { onChange } = props\n\n const [_fields] = useAllFormFields()\n\n const fields = removeEmptyArrayValues({ fields: _fields })\n\n // Pass in fields, and indicate if you'd like to \"unflatten\" field data.\n // The result below will reflect the data stored in the form at the given time\n const newFormData = reduceFieldsToValues(fields, true)\n\n useEffect(() => {\n if (onChange) {\n onChange({ fullFieldsWithValues: fields, newFormData })\n }\n }, [newFormData, onChange, fields])\n\n return null\n}\n", "'use client'\nimport type { FormState } from 'payload'\n\n/**\n * By default, if an array field is empty, it will be included in the form state with a value of 0.\n * We do not need this behavior here, By setting `disableFormData` to true, we can prevent the field from being included in the form state\n * like that.\n * @param fields form state\n */\nexport function removeEmptyArrayValues({ fields }: { fields: FormState }): FormState {\n for (const key in fields) {\n const field = fields[key]\n if (Array.isArray(field.rows) && 'value' in field) {\n field.disableFormData = true\n }\n }\n return fields\n}\n"],
5
5
  "mappings": "wGAIA,OACEA,eAAAA,GACAC,QAAAA,GACAC,QAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,mBAAAA,GACAC,iBAAAA,GACAC,oBAAAA,GACAC,kBAAAA,OACK,iBACP,OAAgBC,eAAAA,GAAaC,aAAAA,GAAWC,WAAAA,GAASC,YAAAA,OAAgB,QAKjE,OAASC,kBAAAA,OAAsB,2BAC/B,OAASC,gBAAAA,MAAoB,wBAC7B,OAASC,MAAMC,OAAY,yDCrB3B,OAASC,6BAAAA,MAAiC,2CAC1C,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,eAAAA,EACAC,aAAAA,EACAC,QAAAA,EACAC,mBAAAA,EACAC,gBAAAA,EACAC,gBAAAA,EACAC,mBAAAA,EACAC,oBAAAA,GAC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D,EAED,OAAOQ,EAAC,MAAA,CAAIQ,UAAWhE,EAAY,IAAMA,EAAY,IAAMG,EAASmB,mBAAYgC,GAClF",
6
6
  "names": ["Collapsible", "Form", "Pill", "RenderComponent", "SectionTitle", "ShimmerEffect", "useConfig", "useDocumentInfo", "useFieldProps", "useFormSubmitted", "useTranslation", "useCallback", "useEffect", "useMemo", "useState", "getTranslation", "getFormState", "v4", "uuid", "useLexicalComposerContext", "getTranslation", "Button", "Collapsible", "ErrorPill", "Pill", "RenderComponent", "RenderFields", "SectionTitle", "useDocumentInfo", "useFormSubmitted", "useTranslation", "dequal", "$getNodeByKey", "React", "useCallback", "c", "_c", "useAllFormFields", "reduceFieldsToValues", "useEffect", "removeEmptyArrayValues", "fields", "key", "field", "Array", "isArray", "rows", "disableFormData", "FormSavePlugin", "props", "$", "_c", "onChange", "_fields", "useAllFormFields", "t0", "fields", "removeEmptyArrayValues", "reduceFieldsToValues", "newFormData", "t1", "t2", "fullFieldsWithValues", "useEffect", "removeUndefinedAndNullAndEmptyArraysRecursively", "obj", "key", "value", "Array", "isArray", "length", "BlockContent", "props", "baseClass", "clientBlock", "field", "formSchema", "nodeKey", "schemaPath", "formData", "i18n", "useTranslation", "editor", "useLexicalComposerContext", "getDocPreferences", "setDocFieldPreferences", "useDocumentInfo", "isCollapsed", "setIsCollapsed", "React", "useState", "initialState", "then", "currentDocPreferences", "collapsedArray", "fields", "name", "collapsed", "includes", "id", "hasSubmitted", "useFormSubmitted", "errorCount", "setErrorCount", "fieldHasErrors", "classNames", "filter", "Boolean", "join", "onFormChange", "useCallback", "fullFieldsWithValues", "newFormData", "blockType", "dequal", "setTimeout", "update", "node", "$getNodeByKey", "setFields", "rowErrorCount", "formField", "Object", "values", "valid", "onCollapsedChange", "changedCollapsed", "newCollapsed", "push", "splice", "indexOf", "hello", "removeBlock", "remove", "_jsxs", "Fragment", "_jsx", "Collapsible", "className", "collapsibleStyle", "header", "admin", "components", "Label", "RenderComponent", "clientProps", "blockKind", "mappedComponent", "Pill", "pillStyle", "labels", "singular", "getTranslation", "slug", "SectionTitle", "path", "readOnly", "ErrorPill", "count", "withMessage", "isEditable", "Button", "buttonStyle", "disabled", "icon", "onClick", "e", "preventDefault", "round", "tooltip", "onToggle", "incomingCollapsedState", "RenderFields", "forceRender", "margins", "FormSavePlugin", "onChange", "baseClass", "BlockComponent", "props", "formData", "nodeKey", "config", "useConfig", "submitted", "useFormSubmitted", "id", "useDocumentInfo", "path", "schemaPath", "useFieldProps", "field", "parentLexicalRichTextField", "useEditorConfigContext", "initialState", "setInitialState", "useState", "richTextComponentMap", "schemaFieldsPath", "blockType", "clientBlock", "get", "blocks", "find", "block", "slug", "useEffect", "state", "getFormState", "apiRoute", "routes", "api", "body", "data", "operation", "serverURL", "blockName", "initialValue", "passesCondition", "valid", "value", "onChange", "useCallback", "formState", "prevFormState", "i18n", "useTranslation", "classNames", "filter", "Boolean", "join", "formContent", "useMemo", "_jsx", "Form", "beforeSubmit", "fields", "uuid", "BlockContent", "formSchema", "Collapsible", "className", "collapsibleStyle", "header", "admin", "components", "Label", "RenderComponent", "clientProps", "blockKind", "mappedComponent", "_jsxs", "Pill", "pillStyle", "labels", "singular", "getTranslation", "SectionTitle", "readOnly", "ShimmerEffect", "height"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use client";import{d as E}from"./chunk-V2LKLT2F.js";import{c as K}from"react/compiler-runtime";import{useLexicalComposerContext as y}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as M}from"@lexical/react/useLexicalNodeSelection.js";import{addClassNamesToElement as S,mergeRegister as _,removeClassNamesFromElement as D}from"@lexical/utils";import{$getNodeByKey as A,$getSelection as O,$isNodeSelection as $,CLICK_COMMAND as L,COMMAND_PRIORITY_LOW as d,KEY_BACKSPACE_COMMAND as R,KEY_DELETE_COMMAND as x}from"lexical";import{useEffect as p}from"react";var N="selected";function P(g){let e=K(16),{nodeKey:t}=g,[o]=y(),[r,n,i]=M(t),m;e[0]!==r||e[1]!==t?(m=l=>{if(r&&$(O())){l.preventDefault();let C=A(t);if(E(C))return C.remove(),!0}return!1},e[0]=r,e[1]=t,e[2]=m):m=e[2];let s=m,c,f;e[3]!==o||e[4]!==t||e[5]!==i||e[6]!==n||e[7]!==r||e[8]!==s?(c=()=>_(o.registerCommand(L,l=>{let C=o.getElementByKey(t);return l.target===C?(l.shiftKey||i(),n(!r),!0):!1},d),o.registerCommand(x,s,d),o.registerCommand(R,s,d)),f=[i,o,r,t,s,n],e[3]=o,e[4]=t,e[5]=i,e[6]=n,e[7]=r,e[8]=s,e[9]=c,e[10]=f):(c=e[9],f=e[10]),p(c,f);let a,u;return e[11]!==o||e[12]!==t||e[13]!==r?(a=()=>{let l=o.getElementByKey(t);l!==null&&(r?S(l,N):D(l,N))},u=[o,r,t],e[11]=o,e[12]=t,e[13]=r,e[14]=a,e[15]=u):(a=e[14],u=e[15]),p(a,u),null}export{P as HorizontalRuleComponent};
2
- //# sourceMappingURL=component-LLWMZU6K.js.map
1
+ "use client";import{d as E}from"./chunk-PECDZEZY.js";import{c as K}from"react/compiler-runtime";import{useLexicalComposerContext as y}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as M}from"@lexical/react/useLexicalNodeSelection.js";import{addClassNamesToElement as S,mergeRegister as _,removeClassNamesFromElement as D}from"@lexical/utils";import{$getNodeByKey as A,$getSelection as O,$isNodeSelection as $,CLICK_COMMAND as L,COMMAND_PRIORITY_LOW as d,KEY_BACKSPACE_COMMAND as R,KEY_DELETE_COMMAND as x}from"lexical";import{useEffect as p}from"react";var N="selected";function P(g){let e=K(16),{nodeKey:t}=g,[o]=y(),[r,n,i]=M(t),m;e[0]!==r||e[1]!==t?(m=l=>{if(r&&$(O())){l.preventDefault();let C=A(t);if(E(C))return C.remove(),!0}return!1},e[0]=r,e[1]=t,e[2]=m):m=e[2];let s=m,c,f;e[3]!==o||e[4]!==t||e[5]!==i||e[6]!==n||e[7]!==r||e[8]!==s?(c=()=>_(o.registerCommand(L,l=>{let C=o.getElementByKey(t);return l.target===C?(l.shiftKey||i(),n(!r),!0):!1},d),o.registerCommand(x,s,d),o.registerCommand(R,s,d)),f=[i,o,r,t,s,n],e[3]=o,e[4]=t,e[5]=i,e[6]=n,e[7]=r,e[8]=s,e[9]=c,e[10]=f):(c=e[9],f=e[10]),p(c,f);let a,u;return e[11]!==o||e[12]!==t||e[13]!==r?(a=()=>{let l=o.getElementByKey(t);l!==null&&(r?S(l,N):D(l,N))},u=[o,r,t],e[11]=o,e[12]=t,e[13]=r,e[14]=a,e[15]=u):(a=e[14],u=e[15]),p(a,u),null}export{P as HorizontalRuleComponent};
2
+ //# sourceMappingURL=component-GAX6BHKZ.js.map
@@ -1,2 +1,2 @@
1
- "use client";import{c as N,f as x}from"./chunk-YL453UOS.js";import{b as p}from"./chunk-OLSILJA6.js";import{jsx as a,jsxs as E}from"react/jsx-runtime";import{useCallback as f,useEffect as I,useRef as K}from"react";import{useLexicalComposerContext as L}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as S}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as $}from"@lexical/utils";import{getTranslation as M}from"@payloadcms/translations";import{Button as v,RenderComponent as h,useTranslation as A}from"@payloadcms/ui";import{$getNodeByKey as D,$getSelection as T,$isNodeSelection as P,CLICK_COMMAND as j,COMMAND_PRIORITY_LOW as b,KEY_BACKSPACE_COMMAND as Y,KEY_DELETE_COMMAND as z}from"lexical";var s="inline-block",le=y=>{let{formData:r,nodeKey:o}=y,[e]=L(),{i18n:C,t:k}=A(),{field:_}=p(),m=K(null),[l,c,d]=S(o),{field:{richTextComponentMap:O}}=p(),t=O.get("lexical_internal_feature.blocks.fields.lexical_inline_blocks")[0].blocks.find(n=>n.slug===r.blockType),R=f(()=>{e.update(()=>{D(o).remove()})},[e,o]),u=f(n=>{if(l&&P(T())){n.preventDefault();let i=D(o);if(x(i))return i.remove(),!0}return!1},[l,o]),g=f(n=>{let i=n;return i.target===m.current||m.current?.contains(i.target)?(i.shiftKey?c(!l):l||(d(),c(!0)),!0):!1},[l,c,d]);I(()=>$(e.registerCommand(j,g,b),e.registerCommand(z,u,b),e.registerCommand(Y,u,b)),[d,e,l,o,u,c,g]);let B=t?.labels?.singular?M(t.labels.singular,C):t.slug;return E("div",{className:[s,s+"-"+r.blockType,l&&`${s}--selected`].filter(Boolean).join(" "),ref:m,children:[t?.admin?.components?.Label?a(h,{clientProps:{blockKind:"lexicalInlineBlock",formData:r},mappedComponent:t.admin.components.Label}):a("div",{children:M(t.labels?.singular,C)}),e.isEditable()&&E("div",{className:`${s}__actions`,children:[a(v,{buttonStyle:"icon-label",className:`${s}__editButton`,disabled:_?.admin?.readOnly,el:"div",icon:"edit",onClick:()=>{e.dispatchCommand(N,{fields:r,nodeKey:o})},round:!0,size:"small",tooltip:k("lexical:blocks:inlineBlocks:edit",{label:B})}),a(v,{buttonStyle:"icon-label",className:`${s}__removeButton`,disabled:_?.admin?.readOnly,icon:"x",onClick:n=>{n.preventDefault(),R()},round:!0,size:"small",tooltip:k("lexical:blocks:inlineBlocks:remove",{label:B})})]})]})};export{le as InlineBlockComponent};
2
- //# sourceMappingURL=componentInline-YSHGRL2J.js.map
1
+ "use client";import{c as N,f as x}from"./chunk-XIBMVIFW.js";import{b as p}from"./chunk-MFAXC4ZA.js";import{jsx as a,jsxs as E}from"react/jsx-runtime";import{useCallback as f,useEffect as I,useRef as K}from"react";import{useLexicalComposerContext as L}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as S}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as $}from"@lexical/utils";import{getTranslation as M}from"@payloadcms/translations";import{Button as v,RenderComponent as h,useTranslation as A}from"@payloadcms/ui";import{$getNodeByKey as D,$getSelection as T,$isNodeSelection as P,CLICK_COMMAND as j,COMMAND_PRIORITY_LOW as b,KEY_BACKSPACE_COMMAND as Y,KEY_DELETE_COMMAND as z}from"lexical";var s="inline-block",le=y=>{let{formData:r,nodeKey:o}=y,[e]=L(),{i18n:C,t:k}=A(),{field:_}=p(),m=K(null),[l,c,d]=S(o),{field:{richTextComponentMap:O}}=p(),t=O.get("lexical_internal_feature.blocks.fields.lexical_inline_blocks")[0].blocks.find(n=>n.slug===r.blockType),R=f(()=>{e.update(()=>{D(o).remove()})},[e,o]),u=f(n=>{if(l&&P(T())){n.preventDefault();let i=D(o);if(x(i))return i.remove(),!0}return!1},[l,o]),g=f(n=>{let i=n;return i.target===m.current||m.current?.contains(i.target)?(i.shiftKey?c(!l):l||(d(),c(!0)),!0):!1},[l,c,d]);I(()=>$(e.registerCommand(j,g,b),e.registerCommand(z,u,b),e.registerCommand(Y,u,b)),[d,e,l,o,u,c,g]);let B=t?.labels?.singular?M(t.labels.singular,C):t.slug;return E("div",{className:[s,s+"-"+r.blockType,l&&`${s}--selected`].filter(Boolean).join(" "),ref:m,children:[t?.admin?.components?.Label?a(h,{clientProps:{blockKind:"lexicalInlineBlock",formData:r},mappedComponent:t.admin.components.Label}):a("div",{children:M(t.labels?.singular,C)}),e.isEditable()&&E("div",{className:`${s}__actions`,children:[a(v,{buttonStyle:"icon-label",className:`${s}__editButton`,disabled:_?.admin?.readOnly,el:"div",icon:"edit",onClick:()=>{e.dispatchCommand(N,{fields:r,nodeKey:o})},round:!0,size:"small",tooltip:k("lexical:blocks:inlineBlocks:edit",{label:B})}),a(v,{buttonStyle:"icon-label",className:`${s}__removeButton`,disabled:_?.admin?.readOnly,icon:"x",onClick:n=>{n.preventDefault(),R()},round:!0,size:"small",tooltip:k("lexical:blocks:inlineBlocks:remove",{label:B})})]})]})};export{le as InlineBlockComponent};
2
+ //# sourceMappingURL=componentInline-RETIC4OV.js.map
@@ -44,13 +44,13 @@ export { getSelectedNode } from '../../lexical/utils/getSelectedNode.js';
44
44
  export { isHTMLElement } from '../../lexical/utils/guard.js';
45
45
  export { joinClasses } from '../../lexical/utils/joinClasses.js';
46
46
  export { createBlockNode } from '../../lexical/utils/markdown/createBlockNode.js';
47
- export { Point, isPoint } from '../../lexical/utils/point.js';
47
+ export { isPoint, Point } from '../../lexical/utils/point.js';
48
48
  export { Rect } from '../../lexical/utils/rect.js';
49
49
  export { setFloatingElemPosition } from '../../lexical/utils/setFloatingElemPosition.js';
50
50
  export { setFloatingElemPositionForLinkEditor } from '../../lexical/utils/setFloatingElemPositionForLinkEditor.js';
51
51
  export { addSwipeDownListener, addSwipeLeftListener, addSwipeRightListener, addSwipeUpListener, } from '../../lexical/utils/swipe.js';
52
52
  export { createClientFeature } from '../../utilities/createClientFeature.js';
53
- export { DETAIL_TYPE_TO_DETAIL, DOUBLE_LINE_BREAK, ELEMENT_FORMAT_TO_TYPE, ELEMENT_TYPE_TO_FORMAT, IS_ALL_FORMATTING, LTR_REGEX, NON_BREAKING_SPACE, NodeFormat, RTL_REGEX, TEXT_MODE_TO_TYPE, TEXT_TYPE_TO_FORMAT, TEXT_TYPE_TO_MODE, } from '../../lexical/utils/nodeFormat.js';
53
+ export { DETAIL_TYPE_TO_DETAIL, DOUBLE_LINE_BREAK, ELEMENT_FORMAT_TO_TYPE, ELEMENT_TYPE_TO_FORMAT, IS_ALL_FORMATTING, LTR_REGEX, NodeFormat, NON_BREAKING_SPACE, RTL_REGEX, TEXT_MODE_TO_TYPE, TEXT_TYPE_TO_FORMAT, TEXT_TYPE_TO_MODE, } from '../../lexical/utils/nodeFormat.js';
54
54
  export { ENABLE_SLASH_MENU_COMMAND } from '../../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js';
55
55
  export { getEnabledNodes } from '../../lexical/nodes/index.js';
56
56
  export { $createUploadNode, $isUploadNode, UploadNode, } from '../../features/upload/client/nodes/UploadNode.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAA;AAE5F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,kBAA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O,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAA;AACxF,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAA;AAElH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAE5E,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mCAAmC,CAAA;AAE1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,qEAAqE,CAAA;AAE/G,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE9D,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,UAAU,GACX,MAAM,kDAAkD,CAAA;AAEzD,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,8DAA8D,CAAA;AAErE,OAAO,EACL,eAAe,EACf,WAAW,EACX,QAAQ,EACR,mBAAmB,GACpB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,YAAY,GACb,MAAM,2CAA2C,CAAA;AAElD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,MAAM,kDAAkD,CAAA;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAA;AAE5F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AACzE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