@payloadcms/richtext-lexical 4.0.0-internal.5f0cd13 → 4.0.0-internal.688c4d0

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 (156) hide show
  1. package/dist/@types/assets.d.js +2 -0
  2. package/dist/@types/assets.d.js.map +1 -0
  3. package/dist/cell/rscEntry.d.ts.map +1 -1
  4. package/dist/cell/rscEntry.js +5 -5
  5. package/dist/cell/rscEntry.js.map +1 -1
  6. package/dist/exports/client/Field-VYBSMSRY.js +2 -0
  7. package/dist/exports/client/Field-VYBSMSRY.js.map +7 -0
  8. package/dist/exports/client/bundled.css +1 -1
  9. package/dist/exports/client/chunk-5VIL27GI.js +2 -0
  10. package/dist/exports/client/chunk-5VIL27GI.js.map +7 -0
  11. package/dist/exports/client/chunk-ESITTE3C.js +2 -0
  12. package/dist/exports/client/chunk-ESITTE3C.js.map +7 -0
  13. package/dist/exports/client/chunk-UD4DQ4AK.js +2 -0
  14. package/dist/exports/client/chunk-UD4DQ4AK.js.map +7 -0
  15. package/dist/exports/client/{component-HKTAZ77E.js → component-PHZQBOJE.js} +2 -2
  16. package/dist/exports/client/componentInline-H24N7GUG.js +2 -0
  17. package/dist/exports/client/index.d.ts +1 -0
  18. package/dist/exports/client/index.d.ts.map +1 -1
  19. package/dist/exports/client/index.js +25 -25
  20. package/dist/exports/client/index.js.map +4 -4
  21. package/dist/exports/server/rsc.browser.d.ts +11 -0
  22. package/dist/exports/server/rsc.browser.d.ts.map +1 -0
  23. package/dist/exports/server/rsc.browser.js +10 -0
  24. package/dist/exports/server/rsc.browser.js.map +1 -0
  25. package/dist/features/blocks/client/component/index.d.ts +1 -0
  26. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  27. package/dist/features/blocks/client/component/index.js +16 -8
  28. package/dist/features/blocks/client/component/index.js.map +1 -1
  29. package/dist/features/blocks/client/componentInline/index.d.ts +1 -0
  30. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  31. package/dist/features/blocks/client/componentInline/index.js +15 -7
  32. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  33. package/dist/features/blocks/client/index.d.ts.map +1 -1
  34. package/dist/features/blocks/client/index.js +4 -2
  35. package/dist/features/blocks/client/index.js.map +1 -1
  36. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -1
  37. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
  38. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  39. package/dist/features/blocks/server/index.d.ts.map +1 -1
  40. package/dist/features/blocks/server/index.js +6 -8
  41. package/dist/features/blocks/server/index.js.map +1 -1
  42. package/dist/features/blocks/server/schema.d.ts +5 -5
  43. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  44. package/dist/features/blocks/server/schema.js +26 -23
  45. package/dist/features/blocks/server/schema.js.map +1 -1
  46. package/dist/features/converters/lexicalToHtml/async/types.d.ts +13 -15
  47. package/dist/features/converters/lexicalToHtml/async/types.d.ts.map +1 -1
  48. package/dist/features/converters/lexicalToHtml/async/types.js.map +1 -1
  49. package/dist/features/converters/lexicalToHtml/sync/types.d.ts +13 -15
  50. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  51. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  52. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -2
  53. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  54. package/dist/features/converters/lexicalToJSX/Component/index.js +5 -4
  55. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  56. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +12 -14
  57. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  58. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  59. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts +12 -14
  60. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts.map +1 -1
  61. package/dist/features/converters/lexicalToPlaintext/sync/types.js.map +1 -1
  62. package/dist/features/experimental_table/server/schema.d.ts.map +1 -1
  63. package/dist/features/experimental_table/server/schema.js +6 -3
  64. package/dist/features/experimental_table/server/schema.js.map +1 -1
  65. package/dist/features/link/server/schema.d.ts.map +1 -1
  66. package/dist/features/link/server/schema.js +10 -7
  67. package/dist/features/link/server/schema.js.map +1 -1
  68. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  69. package/dist/features/relationship/server/schema.js +5 -8
  70. package/dist/features/relationship/server/schema.js.map +1 -1
  71. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  72. package/dist/features/upload/client/component/index.css +2 -2
  73. package/dist/features/upload/server/schema.d.ts +4 -4
  74. package/dist/features/upload/server/schema.d.ts.map +1 -1
  75. package/dist/features/upload/server/schema.js +34 -18
  76. package/dist/features/upload/server/schema.js.map +1 -1
  77. package/dist/field/bundled.css +1 -1
  78. package/dist/field/clientEntry.d.ts +29 -0
  79. package/dist/field/clientEntry.d.ts.map +1 -0
  80. package/dist/field/clientEntry.js +86 -0
  81. package/dist/field/clientEntry.js.map +1 -0
  82. package/dist/field/index.css +13 -12
  83. package/dist/field/index.js +1 -1
  84. package/dist/field/index.js.map +1 -1
  85. package/dist/field/rscEntry.d.ts.map +1 -1
  86. package/dist/field/rscEntry.js +2 -0
  87. package/dist/field/rscEntry.js.map +1 -1
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +47 -4
  90. package/dist/index.js.map +1 -1
  91. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  92. package/dist/lexical/LexicalEditor.js +36 -2
  93. package/dist/lexical/LexicalEditor.js.map +1 -1
  94. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  95. package/dist/lexical/LexicalProvider.js +22 -7
  96. package/dist/lexical/LexicalProvider.js.map +1 -1
  97. package/dist/lexical/config/client/loader.d.ts.map +1 -1
  98. package/dist/lexical/config/client/loader.js +5 -1
  99. package/dist/lexical/config/client/loader.js.map +1 -1
  100. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  101. package/dist/types/builtInNodes.d.ts.map +1 -1
  102. package/dist/types/builtInNodes.js +17 -17
  103. package/dist/types/builtInNodes.js.map +1 -1
  104. package/dist/types/index.d.ts +16 -16
  105. package/dist/types/index.d.ts.map +1 -1
  106. package/dist/types/index.js.map +1 -1
  107. package/dist/types/jsonSchemaHelpers.d.ts +2 -0
  108. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  109. package/dist/types/jsonSchemaHelpers.js +7 -3
  110. package/dist/types/jsonSchemaHelpers.js.map +1 -1
  111. package/dist/types/nodeTypes.d.ts +51 -9
  112. package/dist/types/nodeTypes.d.ts.map +1 -1
  113. package/dist/types/nodeTypes.js +3 -3
  114. package/dist/types/nodeTypes.js.map +1 -1
  115. package/dist/types/schema.d.ts.map +1 -1
  116. package/dist/types/schema.js +12 -2
  117. package/dist/types/schema.js.map +1 -1
  118. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  119. package/dist/utilities/applyBaseFilterToFields.js +1 -2
  120. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  121. package/dist/utilities/buildEditorState.d.ts +17 -3
  122. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  123. package/dist/utilities/buildEditorState.js +8 -0
  124. package/dist/utilities/buildEditorState.js.map +1 -1
  125. package/dist/utilities/buildInitialState.d.ts +2 -1
  126. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  127. package/dist/utilities/buildInitialState.js.map +1 -1
  128. package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
  129. package/dist/utilities/fieldsDrawer/Drawer.js +19 -10
  130. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  131. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts +4 -1
  132. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  133. package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -7
  134. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  135. package/dist/utilities/fieldsDrawer/index.css +16 -0
  136. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts +29 -0
  137. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts.map +1 -0
  138. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js +97 -0
  139. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -0
  140. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  141. package/dist/utilities/generateImportMap.js +7 -3
  142. package/dist/utilities/generateImportMap.js.map +1 -1
  143. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +1 -1
  144. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  145. package/package.json +9 -8
  146. package/dist/exports/client/Field-G5Z2HM5Y.js +0 -2
  147. package/dist/exports/client/Field-G5Z2HM5Y.js.map +0 -7
  148. package/dist/exports/client/chunk-6QWQ7JV4.js +0 -2
  149. package/dist/exports/client/chunk-6QWQ7JV4.js.map +0 -7
  150. package/dist/exports/client/chunk-INBEEENE.js +0 -2
  151. package/dist/exports/client/chunk-INBEEENE.js.map +0 -7
  152. package/dist/exports/client/chunk-UAKNDD6R.js +0 -2
  153. package/dist/exports/client/chunk-UAKNDD6R.js.map +0 -7
  154. package/dist/exports/client/componentInline-D3A6OW76.js +0 -2
  155. /package/dist/exports/client/{component-HKTAZ77E.js.map → component-PHZQBOJE.js.map} +0 -0
  156. /package/dist/exports/client/{componentInline-D3A6OW76.js.map → componentInline-H24N7GUG.js.map} +0 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Browser-condition stub for `@payloadcms/richtext-lexical/rsc`.
3
+ *
4
+ * Bundlers serving the client graph load this file via the `"browser"` export
5
+ * condition in `package.json`. The real implementations rely on server-only
6
+ * APIs and must never be evaluated in a browser context.
7
+ */
8
+ export declare const RscEntryLexicalCell: () => null;
9
+ export declare const LexicalDiffComponent: () => null;
10
+ export declare const RscEntryLexicalField: () => null;
11
+ //# sourceMappingURL=rsc.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsc.browser.d.ts","sourceRoot":"","sources":["../../../src/exports/server/rsc.browser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,mBAAmB,YAAa,CAAA;AAC7C,eAAO,MAAM,oBAAoB,YAAa,CAAA;AAC9C,eAAO,MAAM,oBAAoB,YAAa,CAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Browser-condition stub for `@payloadcms/richtext-lexical/rsc`.
3
+ *
4
+ * Bundlers serving the client graph load this file via the `"browser"` export
5
+ * condition in `package.json`. The real implementations rely on server-only
6
+ * APIs and must never be evaluated in a browser context.
7
+ */export const RscEntryLexicalCell = () => null;
8
+ export const LexicalDiffComponent = () => null;
9
+ export const RscEntryLexicalField = () => null;
10
+ //# sourceMappingURL=rsc.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsc.browser.js","names":["RscEntryLexicalCell","LexicalDiffComponent","RscEntryLexicalField"],"sources":["../../../src/exports/server/rsc.browser.ts"],"sourcesContent":["/**\n * Browser-condition stub for `@payloadcms/richtext-lexical/rsc`.\n *\n * Bundlers serving the client graph load this file via the `\"browser\"` export\n * condition in `package.json`. The real implementations rely on server-only\n * APIs and must never be evaluated in a browser context.\n */\n\nexport const RscEntryLexicalCell = () => null\nexport const LexicalDiffComponent = () => null\nexport const RscEntryLexicalField = () => null\n"],"mappings":"AAAA;;;;;;GAQA,OAAO,MAAMA,mBAAA,GAAsBA,CAAA,KAAM;AACzC,OAAO,MAAMC,oBAAA,GAAuBA,CAAA,KAAM;AAC1C,OAAO,MAAMC,oBAAA,GAAuBA,CAAA,KAAM","ignoreList":[]}
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import type { ViewMapBlockComponentProps } from '../../../../types/index.js';
3
3
  import type { BlockFields } from '../../server/schema.js';
4
4
  import './index.css';
5
+ import '../../../../utilities/fieldsDrawer/index.css';
5
6
  export type BlockComponentProps<TFormData extends Record<string, unknown> = BlockFields> = {
6
7
  /**
7
8
  * Can be modified by the node in order to trigger the re-fetch of the initial state based on the
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAsCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,aAAa,CAAA;AAWpB,MAAM,MAAM,mBAAmB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,IAAI;IACzF;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAuuBxD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,aAAa,CAAA;AACpB,OAAO,8CAA8C,CAAA;AAerD,MAAM,MAAM,mBAAmB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,IAAI;IACzF;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA0uBxD,CAAA"}
@@ -1,17 +1,19 @@
1
1
  'use client';
2
2
 
3
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
5
5
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
6
6
  import { getTranslation } from '@payloadcms/translations';
7
- import { Button, Collapsible, Drawer, EditDepthProvider, ErrorPill, Form, formatDrawerSlug, FormSubmit, MoreIcon, Pill, Popup, PopupList, RenderFields, SectionTitle, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useFormSubmitted, useServerFunctions, useTranslation, XIcon } from '@payloadcms/ui';
7
+ import { Button, Collapsible, Drawer, EditDepthProvider, ErrorPill, Form, formatDrawerSlug, MoreIcon, Pill, Popup, PopupList, RenderFields, SectionTitle, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useFormSubmitted, useServerFunctions, useTranslation, XIcon } from '@payloadcms/ui';
8
8
  import { abortAndIgnore } from '@payloadcms/ui/shared';
9
9
  import { $getNodeByKey, $getRoot, SKIP_DOM_SELECTION_TAG } from 'lexical';
10
10
  import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared';
11
11
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
12
12
  import { v4 as uuid } from 'uuid';
13
13
  import './index.css';
14
+ import '../../../../utilities/fieldsDrawer/index.css';
14
15
  import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
16
+ import { RegisterFormSubmit, useDrawerSubmit } from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js';
15
17
  import { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
16
18
  import { $isBlockNode } from '../nodes/BlocksNode.js';
17
19
  import { BlockContent, useBlockComponentContext } from './BlockContent.js';
@@ -226,7 +228,8 @@ export const BlockComponent = props => {
226
228
  const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
227
229
  const clientSchemaMap = featureClientSchemaMap['blocks'];
228
230
  const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
229
- const clientBlock = blocksField.blockReferences ? typeof blocksField?.blockReferences?.[0] === 'string' ? config.blocksMap[blocksField?.blockReferences?.[0]] : blocksField?.blockReferences?.[0] : blocksField?.blocks?.[0];
231
+ const blockOrSlug = blocksField?.blocks?.[0];
232
+ const clientBlock = typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug;
230
233
  const {
231
234
  i18n,
232
235
  t
@@ -477,14 +480,20 @@ export const BlockComponent = props => {
477
480
  });
478
481
  }, [resolvedCustomBlock, resolvedCustomLabel, blockDisplayName, baseClass, clientBlock?.admin?.disableBlockName, blockType, i18n, isCollapsed, onCollapsedChange, isEditable, nodeKey, removeBlock, rowIndex, t, toggleDrawer]);
479
482
  const blockID = formData?.id;
483
+ const {
484
+ headerActions,
485
+ submitRef
486
+ } = useDrawerSubmit();
480
487
  const BlockDrawer = useMemo(() => () => /*#__PURE__*/_jsx(EditDepthProvider, {
481
488
  children: /*#__PURE__*/_jsx(Drawer, {
482
489
  className: '',
490
+ headerActions: headerActions,
483
491
  slug: drawerSlug,
484
492
  title: t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {
485
493
  label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label')
486
494
  }),
487
- children: initialState ? /*#__PURE__*/_jsxs(_Fragment, {
495
+ children: initialState ? /*#__PURE__*/_jsxs("div", {
496
+ className: "fields-drawer",
488
497
  children: [/*#__PURE__*/_jsx(RenderFields, {
489
498
  fields: clientBlock?.fields ?? [],
490
499
  forceRender: true,
@@ -493,13 +502,12 @@ export const BlockComponent = props => {
493
502
  parentSchemaPath: schemaFieldsPath,
494
503
  permissions: true,
495
504
  readOnly: !isEditable
496
- }), /*#__PURE__*/_jsx(FormSubmit, {
497
- programmaticSubmit: true,
498
- children: t('fields:saveChanges')
505
+ }), /*#__PURE__*/_jsx(RegisterFormSubmit, {
506
+ submitRef: submitRef
499
507
  })]
500
508
  }) : null
501
509
  })
502
- }), [initialState, drawerSlug, blockID, blockDisplayName, t, isEditable, clientBlock?.fields, schemaFieldsPath]);
510
+ }), [initialState, drawerSlug, blockID, blockDisplayName, t, isEditable, clientBlock?.fields, schemaFieldsPath, headerActions, submitRef]);
503
511
  // Memoized Form JSX
504
512
  const Block = useMemo(() => {
505
513
  if (!initialState) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","MoreIcon","Pill","Popup","PopupList","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","XIcon","abortAndIgnore","$getNodeByKey","$getRoot","SKIP_DOM_SELECTION_TAG","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","useBlockComponentContext","removeEmptyArrayValues","BlockComponent","props","cacheBuster","className","baseClass","CustomBlock","CustomBlockFromProps","CustomLabel","CustomLabelFromProps","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","getFormState","schemaFieldsPath","initialState","setInitialState","cachedFormState","formState","mergedState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","blockName","passesCondition","valid","hasMounted","prevCacheBuster","current","formUuid","setCustomLabel","undefined","customComponents","BlockLabel","setCustomBlock","Block","resolvedCustomBlock","_jsx","isEditor","isJSXConverter","resolvedCustomLabel","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","excludeFiles","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","update","node","newData","setFields","tag","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","values","removeBlock","remove","rowIndex","setRowIndex","updateIndex","getEditorState","read","root","children","getChildren","blockCount","child","getKey","registerUpdateListener","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","buttonStyle","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","showDragHandle","showRowNumber","actions","button","buttonClassName","caret","horizontalAlign","render","close","_jsxs","ButtonGroup","buttonSize","filter","Boolean","join","collapsibleStyle","dragHandleProps","attributes","role","tabIndex","listeners","header","String","padStart","pillStyle","admin","path","count","withMessage","onToggle","incomingCollapsedState","blockID","BlockDrawer","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","style","display","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n MoreIcon,\n Pill,\n Popup,\n PopupList,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n XIcon,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, $getRoot, SKIP_DOM_SELECTION_TAG } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapBlockComponentProps } from '../../../../types/index.js'\nimport type { BlockFields } from '../../server/schema.js'\n\nimport './index.css'\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport {\n type BlockCollapsibleWithErrorProps,\n BlockContent,\n useBlockComponentContext,\n} from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\nexport type BlockComponentProps<TFormData extends Record<string, unknown> = BlockFields> = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly className: string\n /**\n * Custom block component from view map\n * Will be rendered with useBlockComponentContext hook.\n */\n readonly CustomBlock?: React.FC<ViewMapBlockComponentProps>\n /**\n * Custom block label from view map\n * Will be rendered with useBlockComponentContext hook.\n */\n readonly CustomLabel?: React.FC<ViewMapBlockComponentProps>\n /**\n * The block's form data (field values).\n */\n readonly formData: TFormData\n /**\n * The unique key identifying this block node in the current editor instance.\n */\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<BlockComponentProps> = (props) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\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 const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n const mergedState = Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n\n // Manually add blockName, as it's not part of cachedFormState\n mergedState.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return mergedState\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist (CustomBlockFromProps/CustomLabelFromProps),\n // we render them directly with formData instead, so these states are unused.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n // When viewMap components exist, render directly with formData (always current from\n // the lexical node). When they don't, fall back to server-rendered state.\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useBlockComponentContext={useBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useBlockComponentContext={useBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n CustomLabelFromProps,\n CustomBlockFromProps,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState, { excludeFiles: true }),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n }, 0)\n\n if (submit) {\n if (!CustomLabelFromProps) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n }\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n CustomBlockFromProps,\n CustomLabelFromProps,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const [rowIndex, setRowIndex] = React.useState<number>(0)\n\n useEffect(() => {\n const updateIndex = () => {\n editor.getEditorState().read(() => {\n const root = $getRoot()\n const children = root.getChildren()\n let blockCount = 0\n for (const child of children) {\n if ($isBlockNode(child)) {\n if (child.getKey() === nodeKey) {\n setRowIndex(blockCount)\n return\n }\n blockCount++\n }\n }\n })\n }\n updateIndex()\n return editor.registerUpdateListener(() => {\n updateIndex()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.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(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, isEditable, t, blockDisplayName, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [baseClass, isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n showDragHandle = true,\n showRowNumber = true,\n }: BlockCollapsibleWithErrorProps) => {\n return (\n <div className={`${baseClass}__container ${baseClass}-${blockType}`}>\n <Collapsible\n actions={\n typeof Actions !== 'undefined' ? (\n Actions\n ) : isEditable ? (\n <Popup\n button={<MoreIcon />}\n buttonClassName={`${baseClass}__actions-button`}\n caret={false}\n horizontalAlign=\"right\"\n render={({ close }) => (\n <PopupList.ButtonGroup buttonSize=\"medium\">\n {((resolvedCustomBlock && editButton !== false) ||\n (!resolvedCustomBlock && editButton)) && (\n <PopupList.Button\n onClick={() => {\n toggleDrawer()\n close()\n }}\n >\n {t('general:edit')}\n </PopupList.Button>\n )}\n {removeButton !== false && (\n <PopupList.Button\n onClick={() => {\n removeBlock()\n close()\n }}\n >\n <XIcon />\n {t('general:remove')}\n </PopupList.Button>\n )}\n </PopupList.ButtonGroup>\n )}\n size=\"large\"\n />\n ) : null\n }\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n dragHandleProps={\n showDragHandle\n ? {\n id: nodeKey,\n attributes: { role: 'button', tabIndex: 0 },\n listeners: {},\n }\n : undefined\n }\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof resolvedCustomLabel !== 'undefined' ? (\n resolvedCustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {showRowNumber && (\n <span className={`${baseClass}__block-number`}>\n {String(rowIndex + 1).padStart(2, '0')}\n </span>\n )}\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n >\n {children}\n </Collapsible>\n </div>\n )\n },\n [\n resolvedCustomBlock,\n resolvedCustomLabel,\n blockDisplayName,\n baseClass,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n nodeKey,\n removeBlock,\n rowIndex,\n t,\n toggleDrawer,\n ],\n )\n\n const blockID = formData?.id\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields ?? []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <div data-block-drawer-slug={drawerSlug} style={{ display: 'contents' }}>\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = blockType\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={formUuid}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={resolvedCustomBlock}\n CustomLabel={resolvedCustomLabel}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n </div>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n resolvedCustomBlock,\n resolvedCustomLabel,\n blockType,\n drawerSlug,\n RemoveButton,\n EditButton,\n baseClass,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n formUuid,\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className={`${baseClass}-not-found`}>\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,EACdC,KAAK,QACA;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,QAAQ,EAAEC,sBAAsB,QAAQ;AAOhE,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC/D,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAK3B,OAAO;AACP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,YAAY,QAAQ;AAC7B,SAEEC,YAAY,EACZC,wBAAwB,QACnB;AACP,SAASC,sBAAsB,QAAQ;AA8BvC,OAAO,MAAMC,cAAA,GAAiDC,KAAA;EAC5D,MAAM;IACJC,WAAW;IACXC,SAAA,EAAWC,SAAS;IACpBC,WAAA,EAAaC,oBAAoB;IACjCC,WAAA,EAAaC,oBAAoB;IACjCC,QAAQ;IACRC;EAAO,CACR,GAAGT,KAAA;EAEJ,MAAMU,SAAA,GAAYlC,gBAAA;EAClB,MAAM;IAAEmC,EAAE;IAAEC,cAAc;IAAEC;EAAU,CAAE,GAAGvC,eAAA;EAC3C,MAAM;IACJwC,UAAA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KAAA,CAAC;QAAIhL,SAAA,EAAW,GAAGC,SAAA,YAAqB;mBAAE,kBACzBmC,SAAA,EAAU;;;EAIjC;EAEA,OAAO4B,KAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","MoreIcon","Pill","Popup","PopupList","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","XIcon","abortAndIgnore","$getNodeByKey","$getRoot","SKIP_DOM_SELECTION_TAG","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","RegisterFormSubmit","useDrawerSubmit","useLexicalDrawer","$isBlockNode","BlockContent","useBlockComponentContext","removeEmptyArrayValues","BlockComponent","props","cacheBuster","className","baseClass","CustomBlock","CustomBlockFromProps","CustomLabel","CustomLabelFromProps","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","getFormState","schemaFieldsPath","initialState","setInitialState","cachedFormState","formState","mergedState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","blockName","passesCondition","valid","hasMounted","prevCacheBuster","current","formUuid","setCustomLabel","undefined","customComponents","BlockLabel","setCustomBlock","Block","resolvedCustomBlock","_jsx","isEditor","isJSXConverter","resolvedCustomLabel","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","excludeFiles","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","update","node","newData","setFields","tag","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","blockOrSlug","blocks","clientBlock","blocksMap","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","values","removeBlock","remove","rowIndex","setRowIndex","updateIndex","getEditorState","read","root","children","getChildren","blockCount","child","getKey","registerUpdateListener","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","buttonStyle","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","showDragHandle","showRowNumber","actions","button","buttonClassName","caret","horizontalAlign","render","close","_jsxs","ButtonGroup","buttonSize","filter","Boolean","join","collapsibleStyle","dragHandleProps","attributes","role","tabIndex","listeners","header","String","padStart","pillStyle","admin","path","count","withMessage","onToggle","incomingCollapsedState","blockID","headerActions","submitRef","BlockDrawer","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","style","display","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n MoreIcon,\n Pill,\n Popup,\n PopupList,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n XIcon,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, $getRoot, SKIP_DOM_SELECTION_TAG } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapBlockComponentProps } from '../../../../types/index.js'\nimport type { BlockFields } from '../../server/schema.js'\n\nimport './index.css'\nimport '../../../../utilities/fieldsDrawer/index.css'\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport {\n RegisterFormSubmit,\n useDrawerSubmit,\n} from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport {\n type BlockCollapsibleWithErrorProps,\n BlockContent,\n useBlockComponentContext,\n} from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\nexport type BlockComponentProps<TFormData extends Record<string, unknown> = BlockFields> = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly className: string\n /**\n * Custom block component from view map\n * Will be rendered with useBlockComponentContext hook.\n */\n readonly CustomBlock?: React.FC<ViewMapBlockComponentProps>\n /**\n * Custom block label from view map\n * Will be rendered with useBlockComponentContext hook.\n */\n readonly CustomLabel?: React.FC<ViewMapBlockComponentProps>\n /**\n * The block's form data (field values).\n */\n readonly formData: TFormData\n /**\n * The unique key identifying this block node in the current editor instance.\n */\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<BlockComponentProps> = (props) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\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 const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n const mergedState = Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n\n // Manually add blockName, as it's not part of cachedFormState\n mergedState.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return mergedState\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist (CustomBlockFromProps/CustomLabelFromProps),\n // we render them directly with formData instead, so these states are unused.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n // When viewMap components exist, render directly with formData (always current from\n // the lexical node). When they don't, fall back to server-rendered state.\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useBlockComponentContext={useBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useBlockComponentContext={useBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n CustomLabelFromProps,\n CustomBlockFromProps,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient | undefined\n\n const blockOrSlug = blocksField?.blocks?.[0]\n const clientBlock: ClientBlock | undefined =\n typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState, { excludeFiles: true }),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n }, 0)\n\n if (submit) {\n if (!CustomLabelFromProps) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n }\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n CustomBlockFromProps,\n CustomLabelFromProps,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const [rowIndex, setRowIndex] = React.useState<number>(0)\n\n useEffect(() => {\n const updateIndex = () => {\n editor.getEditorState().read(() => {\n const root = $getRoot()\n const children = root.getChildren()\n let blockCount = 0\n for (const child of children) {\n if ($isBlockNode(child)) {\n if (child.getKey() === nodeKey) {\n setRowIndex(blockCount)\n return\n }\n blockCount++\n }\n }\n })\n }\n updateIndex()\n return editor.registerUpdateListener(() => {\n updateIndex()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.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(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, isEditable, t, blockDisplayName, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [baseClass, isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n showDragHandle = true,\n showRowNumber = true,\n }: BlockCollapsibleWithErrorProps) => {\n return (\n <div className={`${baseClass}__container ${baseClass}-${blockType}`}>\n <Collapsible\n actions={\n typeof Actions !== 'undefined' ? (\n Actions\n ) : isEditable ? (\n <Popup\n button={<MoreIcon />}\n buttonClassName={`${baseClass}__actions-button`}\n caret={false}\n horizontalAlign=\"right\"\n render={({ close }) => (\n <PopupList.ButtonGroup buttonSize=\"medium\">\n {((resolvedCustomBlock && editButton !== false) ||\n (!resolvedCustomBlock && editButton)) && (\n <PopupList.Button\n onClick={() => {\n toggleDrawer()\n close()\n }}\n >\n {t('general:edit')}\n </PopupList.Button>\n )}\n {removeButton !== false && (\n <PopupList.Button\n onClick={() => {\n removeBlock()\n close()\n }}\n >\n <XIcon />\n {t('general:remove')}\n </PopupList.Button>\n )}\n </PopupList.ButtonGroup>\n )}\n size=\"large\"\n />\n ) : null\n }\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n dragHandleProps={\n showDragHandle\n ? {\n id: nodeKey,\n attributes: { role: 'button', tabIndex: 0 },\n listeners: {},\n }\n : undefined\n }\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof resolvedCustomLabel !== 'undefined' ? (\n resolvedCustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {showRowNumber && (\n <span className={`${baseClass}__block-number`}>\n {String(rowIndex + 1).padStart(2, '0')}\n </span>\n )}\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n >\n {children}\n </Collapsible>\n </div>\n )\n },\n [\n resolvedCustomBlock,\n resolvedCustomLabel,\n blockDisplayName,\n baseClass,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n nodeKey,\n removeBlock,\n rowIndex,\n t,\n toggleDrawer,\n ],\n )\n\n const blockID = formData?.id\n\n const { headerActions, submitRef } = useDrawerSubmit()\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n headerActions={headerActions}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <div className=\"fields-drawer\">\n <RenderFields\n fields={clientBlock?.fields ?? []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <RegisterFormSubmit submitRef={submitRef} />\n </div>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n headerActions,\n submitRef,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <div data-block-drawer-slug={drawerSlug} style={{ display: 'contents' }}>\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = blockType\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={formUuid}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={resolvedCustomBlock}\n CustomLabel={resolvedCustomLabel}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n </div>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n resolvedCustomBlock,\n resolvedCustomLabel,\n blockType,\n drawerSlug,\n RemoveButton,\n EditButton,\n baseClass,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n formUuid,\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className={`${baseClass}-not-found`}>\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,EACdC,KAAK,QACA;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,QAAQ,EAAEC,sBAAsB,QAAQ;AAOhE,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC/D,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAK3B,OAAO;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vH,UAAA,EAAYA,UAAA;UACZ4L,UAAA,EAAYlH,WAAA,EAAa/E,MAAA,IAAU,EAAE;UACrCoB,YAAA,EAAcA,YAAA;UACdhC,OAAA,EAASA,OAAA;UACTsJ,YAAA,EAAcA;;;;EAKxB,GAAG,CACDC,gBAAA,EACA2C,WAAA,EACAxI,mBAAA,EACAI,mBAAA,EACAjC,SAAA,EACAR,UAAA,EACAiI,YAAA,EACAd,UAAA,EACA9I,SAAA,EACAiC,MAAA,EACAV,UAAA,EACAO,YAAA,EACAmE,WAAA,EAAa/E,MAAA,EACbuC,QAAA,EACAnB,YAAA,EACAhC,OAAA,EACA+F,QAAA,EACA9F,SAAA,CACD;EAED,IAAI,CAAC0F,WAAA,EAAa;IAChB,oBACEhC,IAAA,CAAC4F,gBAAA;MAAiBG,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAa,KAAA,CAAC;QAAIhL,SAAA,EAAW,GAAGC,SAAA,YAAqB;mBAAE,kBACzBmC,SAAA,EAAU;;;EAIjC;EAEA,OAAO4B,KAAA;AACT","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import type { FormState } from 'payload';
2
2
  import './index.css';
3
+ import '../../../../utilities/fieldsDrawer/index.css';
3
4
  import React from 'react';
4
5
  import type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js';
5
6
  import type { InlineBlockFields } from '../../server/schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAwC,SAAS,EAAE,MAAM,SAAS,CAAA;AAwB9E,OAAO,aAAa,CAAA;AAGpB,OAAO,KAAiE,MAAM,OAAO,CAAA;AAGrF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAA;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAA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B,CAAA;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAUhE,MAAM,MAAM,yBAAyB,CACnC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,iBAAiB,IAC3D;IACF,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,gCAAgC,CAAC,CAAA;IACjE,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,gCAAgC,CAAC,CAAA;CAClE,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC,CAAA;AAE9F,MAAM,MAAM,+BAA+B,GAAG;IAC5C,UAAU,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACrB,YAAY,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAA;IAC3C,oBAAoB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAA;IAC9D,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;CACxB,CAAA;AAMD,eAAO,MAAM,8BAA8B,uCAA+C,CAAA;AAE1F,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,CA+fvF,CAAA"}
@@ -1,17 +1,19 @@
1
1
  'use client';
2
2
 
3
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
5
5
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
6
6
  import { getTranslation } from '@payloadcms/translations';
7
- import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, FormSubmit, RenderFields, ShimmerEffect, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation } from '@payloadcms/ui';
7
+ import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, RenderFields, ShimmerEffect, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation } from '@payloadcms/ui';
8
8
  import { abortAndIgnore } from '@payloadcms/ui/shared';
9
9
  import { $getNodeByKey, SKIP_DOM_SELECTION_TAG } from 'lexical';
10
10
  import './index.css';
11
+ import '../../../../utilities/fieldsDrawer/index.css';
11
12
  import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared';
12
13
  import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react';
13
14
  import { v4 as uuid } from 'uuid';
14
15
  import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
16
+ import { RegisterFormSubmit, useDrawerSubmit } from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js';
15
17
  import { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
16
18
  import { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js';
17
19
  const InlineBlockComponentContext = /*#__PURE__*/createContext({
@@ -142,7 +144,8 @@ export const InlineBlockComponent = props => {
142
144
  const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`;
143
145
  const clientSchemaMap = featureClientSchemaMap['blocks'];
144
146
  const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
145
- const clientBlock = blocksField.blockReferences ? typeof blocksField?.blockReferences?.[0] === 'string' ? config.blocksMap[blocksField?.blockReferences?.[0]] : blocksField?.blockReferences?.[0] : blocksField?.blocks?.[0];
147
+ const blockOrSlug = blocksField?.blocks?.[0];
148
+ const clientBlock = typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug;
146
149
  const clientBlockFields = clientBlock?.fields ?? [];
147
150
  // Open drawer on "mount"
148
151
  useEffect(() => {
@@ -304,6 +307,10 @@ export const InlineBlockComponent = props => {
304
307
  tag: SKIP_DOM_SELECTION_TAG
305
308
  });
306
309
  }, [editor, nodeKey, formData]);
310
+ const {
311
+ headerActions,
312
+ submitRef
313
+ } = useDrawerSubmit();
307
314
  const RemoveButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
308
315
  buttonStyle: "ghost",
309
316
  className: `${baseClass}__removeButton`,
@@ -397,11 +404,13 @@ export const InlineBlockComponent = props => {
397
404
  children: [/*#__PURE__*/_jsx(EditDepthProvider, {
398
405
  children: /*#__PURE__*/_jsx(Drawer, {
399
406
  className: '',
407
+ headerActions: headerActions,
400
408
  slug: drawerSlug,
401
409
  title: t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {
402
410
  label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label')
403
411
  }),
404
- children: initialState ? /*#__PURE__*/_jsxs(_Fragment, {
412
+ children: initialState ? /*#__PURE__*/_jsxs("div", {
413
+ className: "fields-drawer",
405
414
  children: [/*#__PURE__*/_jsx(RenderFields, {
406
415
  fields: clientBlock?.fields,
407
416
  forceRender: true,
@@ -410,9 +419,8 @@ export const InlineBlockComponent = props => {
410
419
  parentSchemaPath: schemaFieldsPath,
411
420
  permissions: true,
412
421
  readOnly: !isEditable
413
- }), /*#__PURE__*/_jsx(FormSubmit, {
414
- programmaticSubmit: true,
415
- children: t('fields:saveChanges')
422
+ }), /*#__PURE__*/_jsx(RegisterFormSubmit, {
423
+ submitRef: submitRef
416
424
  })]
417
425
  }) : null
418
426
  })