@payloadcms/richtext-lexical 3.59.0-internal.ff6711a → 3.59.0

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 (160) hide show
  1. package/dist/exports/client/Field-EHRBYNHO.js +2 -0
  2. package/dist/exports/client/Field-EHRBYNHO.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-APF3CN47.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-APF3CN47.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/{chunk-TLQLXR6Q.js → chunk-2Y72RT72.js} +2 -2
  7. package/dist/exports/client/chunk-3BY5IZJD.js +2 -0
  8. package/dist/exports/client/chunk-3BY5IZJD.js.map +7 -0
  9. package/dist/exports/client/chunk-CYLMY5ZJ.js +2 -0
  10. package/dist/exports/client/chunk-CYLMY5ZJ.js.map +7 -0
  11. package/dist/exports/client/component-VDJI45F2.js +2 -0
  12. package/dist/exports/client/component-VDJI45F2.js.map +7 -0
  13. package/dist/exports/client/componentInline-7TPI7ZBC.js +2 -0
  14. package/dist/exports/client/index.d.ts +0 -3
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +10 -35
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/blocks/client/component/BlockContent.d.ts +27 -52
  19. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  20. package/dist/features/blocks/client/component/BlockContent.js +51 -48
  21. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  22. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +9 -2
  23. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
  24. package/dist/features/blocks/client/component/components/BlockCollapsible.js +25 -7
  25. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  26. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  27. package/dist/features/blocks/client/component/index.js +56 -71
  28. package/dist/features/blocks/client/component/index.js.map +1 -1
  29. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  30. package/dist/features/blocks/client/componentInline/index.js +11 -13
  31. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  32. package/dist/features/blocks/client/index.d.ts.map +1 -1
  33. package/dist/features/blocks/client/index.js +0 -5
  34. package/dist/features/blocks/client/index.js.map +1 -1
  35. package/dist/features/blocks/client/markdownTransformer.d.ts +17 -0
  36. package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
  37. package/dist/features/blocks/client/markdownTransformer.js +144 -0
  38. package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
  39. package/dist/features/blocks/server/index.js +1 -1
  40. package/dist/features/blocks/server/index.js.map +1 -1
  41. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
  42. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
  43. package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
  44. package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
  45. package/dist/features/blocks/server/{markdown/markdownTransformer.js → markdownTransformer.js} +48 -6
  46. package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
  47. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  48. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +3 -5
  49. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  50. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  51. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +1 -3
  52. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  53. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  54. package/dist/features/relationship/client/components/RelationshipComponent.js +9 -5
  55. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  56. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  57. package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -7
  58. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  59. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  60. package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -3
  61. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  62. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  63. package/dist/features/upload/client/component/index.js +5 -6
  64. package/dist/features/upload/client/component/index.js.map +1 -1
  65. package/dist/field/bundled.css +1 -1
  66. package/dist/field/rscEntry.d.ts.map +1 -1
  67. package/dist/field/rscEntry.js +0 -2
  68. package/dist/field/rscEntry.js.map +1 -1
  69. package/dist/index.d.ts +0 -1
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +0 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  74. package/dist/lexical/LexicalEditor.js +26 -20
  75. package/dist/lexical/LexicalEditor.js.map +1 -1
  76. package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
  77. package/dist/lexical/ui/icons/CodeBlock/index.js +15 -10
  78. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  79. package/dist/utilities/buildInitialState.d.ts +0 -1
  80. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  81. package/dist/utilities/buildInitialState.js +0 -1
  82. package/dist/utilities/buildInitialState.js.map +1 -1
  83. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  84. package/dist/utilities/fieldsDrawer/DrawerContent.js +3 -7
  85. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  86. package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
  87. package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
  88. package/package.json +6 -6
  89. package/dist/exports/client/Field-CJFETHA3.js +0 -2
  90. package/dist/exports/client/Field-CJFETHA3.js.map +0 -7
  91. package/dist/exports/client/RelationshipComponent-TSIENULZ.js +0 -2
  92. package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +0 -7
  93. package/dist/exports/client/chunk-BQCXN3B4.js +0 -2
  94. package/dist/exports/client/chunk-BQCXN3B4.js.map +0 -7
  95. package/dist/exports/client/chunk-XNERFY6G.js +0 -2
  96. package/dist/exports/client/chunk-XNERFY6G.js.map +0 -7
  97. package/dist/exports/client/component-CYFKY3IL.js +0 -2
  98. package/dist/exports/client/component-CYFKY3IL.js.map +0 -7
  99. package/dist/exports/client/componentInline-NGTRUSGB.js +0 -2
  100. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +0 -6
  101. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +0 -1
  102. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +0 -24
  103. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +0 -1
  104. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +0 -6
  105. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +0 -1
  106. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +0 -20
  107. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +0 -1
  108. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +0 -12
  109. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +0 -1
  110. package/dist/features/blocks/client/markdown/markdownTransformer.js +0 -348
  111. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +0 -1
  112. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +0 -5
  113. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +0 -1
  114. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +0 -156
  115. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +0 -1
  116. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +0 -61
  117. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +0 -1
  118. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +0 -99
  119. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +0 -1
  120. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +0 -4
  121. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +0 -1
  122. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +0 -17
  123. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +0 -1
  124. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +0 -4
  125. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +0 -1
  126. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +0 -26
  127. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +0 -1
  128. package/dist/features/blocks/premade/CodeBlock/converter.d.ts +0 -7
  129. package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +0 -1
  130. package/dist/features/blocks/premade/CodeBlock/converter.js +0 -46
  131. package/dist/features/blocks/premade/CodeBlock/converter.js.map +0 -1
  132. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +0 -2
  133. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +0 -1
  134. package/dist/features/blocks/premade/CodeBlock/converterClient.js +0 -4
  135. package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +0 -1
  136. package/dist/features/blocks/premade/CodeBlock/index.d.ts +0 -7
  137. package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +0 -1
  138. package/dist/features/blocks/premade/CodeBlock/index.js +0 -52
  139. package/dist/features/blocks/premade/CodeBlock/index.js.map +0 -1
  140. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +0 -6
  141. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +0 -1
  142. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +0 -27
  143. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +0 -1
  144. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +0 -7
  145. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +0 -1
  146. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +0 -22
  147. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +0 -1
  148. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
  149. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +0 -1
  150. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +0 -15
  151. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +0 -1
  152. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +0 -1
  153. package/dist/lexical/ui/icons/Collapse/index.d.ts +0 -3
  154. package/dist/lexical/ui/icons/Collapse/index.d.ts.map +0 -1
  155. package/dist/lexical/ui/icons/Collapse/index.js +0 -18
  156. package/dist/lexical/ui/icons/Collapse/index.js.map +0 -1
  157. /package/dist/exports/client/{chunk-TLQLXR6Q.js.map → chunk-2Y72RT72.js.map} +0 -0
  158. /package/dist/exports/client/{componentInline-NGTRUSGB.js.map → componentInline-7TPI7ZBC.js.map} +0 -0
  159. /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.d.ts → linesFromMatchToContentAndPropsString.d.ts} +0 -0
  160. /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.js → linesFromMatchToContentAndPropsString.js} +0 -0
@@ -1,56 +1,19 @@
1
- import type { CollapsibleProps } from '@payloadcms/ui/elements/Collapsible';
2
1
  import type { ClientField, FormState } from 'payload';
3
2
  import React from 'react';
4
- export type BlockCollapsibleProps = {
5
- /**
6
- * Replace the top-right portion of the header that renders the Edit and Remove buttons with custom content.
7
- * If this property is provided, the `removeButton` and `editButton` properties are ignored.
8
- */
9
- Actions?: React.ReactNode;
10
- children?: React.ReactNode;
11
- /**
12
- * Additional className to the collapsible wrapper
13
- */
14
- className?: string;
15
- /**
16
- * Props to pass to the underlying Collapsible component. You could use this to override the `Header` entirely, for example.
17
- */
18
- collapsibleProps?: Partial<CollapsibleProps>;
19
- /**
20
- * Whether to disable rendering the block name field in the header Label
21
- * @default false
22
- */
23
- disableBlockName?: boolean;
24
- /**
25
- * Whether to show the Edit button
26
- * If `Actions` is provided, this property is ignored.
27
- * @default true
28
- */
29
- editButton?: boolean;
30
- /**
31
- * Replace the default Label component with a custom Label
32
- */
33
- Label?: React.ReactNode;
34
- /**
35
- * Replace the default Pill component component that's rendered within the default Label component with a custom Pill.
36
- * This property has no effect if you provide a custom Label component via the `Label` property.
37
- */
38
- Pill?: React.ReactNode;
39
- /**
40
- * Whether to show the Remove button
41
- * If `Actions` is provided, this property is ignored.
42
- * @default true
43
- */
44
- removeButton?: boolean;
45
- };
46
- export type BlockCollapsibleWithErrorProps = {
47
- errorCount?: number;
48
- fieldHasErrors?: boolean;
49
- } & BlockCollapsibleProps;
50
- export type BlockContentProps = {
3
+ type Props = {
51
4
  baseClass: string;
52
5
  BlockDrawer: React.FC;
53
- Collapsible: React.FC<BlockCollapsibleWithErrorProps>;
6
+ Collapsible: React.FC<{
7
+ children?: React.ReactNode;
8
+ editButton?: boolean;
9
+ errorCount?: number;
10
+ fieldHasErrors?: boolean;
11
+ /**
12
+ * Override the default label with a custom label
13
+ */
14
+ Label?: React.ReactNode;
15
+ removeButton?: boolean;
16
+ }>;
54
17
  CustomBlock: React.ReactNode;
55
18
  EditButton: React.FC;
56
19
  errorCount: number;
@@ -60,14 +23,26 @@ export type BlockContentProps = {
60
23
  RemoveButton: React.FC;
61
24
  };
62
25
  type BlockComponentContextType = {
63
- BlockCollapsible: React.FC<BlockCollapsibleProps>;
64
- } & Omit<BlockContentProps, 'Collapsible'>;
26
+ BlockCollapsible?: React.FC<{
27
+ children?: React.ReactNode;
28
+ editButton?: boolean;
29
+ /**
30
+ * Override the default label with a custom label
31
+ */
32
+ Label?: React.ReactNode;
33
+ removeButton?: boolean;
34
+ }>;
35
+ EditButton?: React.FC;
36
+ initialState: false | FormState | undefined;
37
+ nodeKey?: string;
38
+ RemoveButton?: React.FC;
39
+ };
65
40
  export declare const useBlockComponentContext: () => BlockComponentContextType;
66
41
  /**
67
42
  * The actual content of the Block. This should be INSIDE a Form component,
68
43
  * scoped to the block. All format operations in here are thus scoped to the block's form, and
69
44
  * not the whole document.
70
45
  */
71
- export declare const BlockContent: React.FC<BlockContentProps>;
46
+ export declare const BlockContent: React.FC<Props>;
72
47
  export {};
73
48
  //# sourceMappingURL=BlockContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlockContent.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIrD,OAAO,KAAiC,MAAM,OAAO,CAAA;AAErD,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC5C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,GAAG,qBAAqB,CAAA;AAEzB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAA;IACrB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,8BAA8B,CAAC,CAAA;IACrD,WAAW,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B,UAAU,EAAE,KAAK,CAAC,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,WAAW,EAAE,CAAA;IACzB,YAAY,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAA;IAE3C,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,KAAK,CAAC,EAAE,CAAA;CACvB,CAAA;AAED,KAAK,yBAAyB,GAAG;IAC/B,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAA;CAClD,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAA;AAe1C,eAAO,MAAM,wBAAwB,iCAAyC,CAAA;AAE9E;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA6CpD,CAAA"}
1
+ {"version":3,"file":"BlockContent.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGrD,OAAO,KAAiC,MAAM,OAAO,CAAA;AAErD,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAA;IACrB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;QACpB,QAAQ,CAAC,EAAE,KAAK,C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/jsx-runtime";
5
- import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
6
5
  import { RenderFields, useFormSubmitted } from '@payloadcms/ui';
7
6
  import React, { createContext, useMemo } from 'react';
8
7
  const BlockComponentContext = /*#__PURE__*/createContext({
9
- baseClass: 'lexical-block',
10
- BlockCollapsible: () => null,
11
- BlockDrawer: () => null,
12
- CustomBlock: null,
13
- EditButton: () => null,
14
- errorCount: 0,
15
- formSchema: [],
16
- initialState: false,
17
- nodeKey: '',
18
- RemoveButton: () => null
8
+ initialState: false
19
9
  });
20
10
  export const useBlockComponentContext = () => React.use(BlockComponentContext);
21
11
  /**
@@ -24,34 +14,30 @@ export const useBlockComponentContext = () => React.use(BlockComponentContext);
24
14
  * not the whole document.
25
15
  */
26
16
  export const BlockContent = props => {
27
- const $ = _c(4);
28
- const {
29
- Collapsible,
30
- ...contextProps
31
- } = props;
17
+ const $ = _c(13);
32
18
  const {
33
19
  BlockDrawer,
20
+ Collapsible,
34
21
  CustomBlock,
22
+ EditButton,
35
23
  errorCount,
36
- formSchema
37
- } = contextProps;
24
+ formSchema,
25
+ initialState,
26
+ nodeKey,
27
+ RemoveButton
28
+ } = props;
38
29
  const hasSubmitted = useFormSubmitted();
39
30
  const fieldHasErrors = hasSubmitted && errorCount > 0;
40
- const isEditable = useLexicalEditable();
41
31
  let t0;
42
32
  if ($[0] !== Collapsible || $[1] !== errorCount || $[2] !== fieldHasErrors) {
43
- t0 = props_0 => {
44
- const {
45
- children,
46
- ...rest
47
- } = props_0;
48
- return _jsx(Collapsible, {
49
- errorCount,
50
- fieldHasErrors,
51
- ...rest,
52
- children
53
- });
54
- };
33
+ t0 = props_0 => _jsx(Collapsible, {
34
+ editButton: props_0.editButton,
35
+ errorCount,
36
+ fieldHasErrors,
37
+ Label: props_0.Label,
38
+ removeButton: props_0.removeButton,
39
+ children: props_0.children
40
+ });
55
41
  $[0] = Collapsible;
56
42
  $[1] = errorCount;
57
43
  $[2] = fieldHasErrors;
@@ -60,22 +46,39 @@ export const BlockContent = props => {
60
46
  t0 = $[3];
61
47
  }
62
48
  const CollapsibleWithErrorProps = t0;
63
- return CustomBlock ? _jsxs(BlockComponentContext, {
64
- value: {
65
- ...contextProps,
66
- BlockCollapsible: CollapsibleWithErrorProps
67
- },
68
- children: [CustomBlock, _jsx(BlockDrawer, {})]
69
- }) : _jsx(CollapsibleWithErrorProps, {
70
- children: _jsx(RenderFields, {
71
- fields: formSchema,
72
- forceRender: true,
73
- parentIndexPath: "",
74
- parentPath: "",
75
- parentSchemaPath: "",
76
- permissions: true,
77
- readOnly: !isEditable
78
- })
79
- });
49
+ let t1;
50
+ if ($[4] !== BlockDrawer || $[5] !== CollapsibleWithErrorProps || $[6] !== CustomBlock || $[7] !== EditButton || $[8] !== RemoveButton || $[9] !== formSchema || $[10] !== initialState || $[11] !== nodeKey) {
51
+ t1 = CustomBlock ? _jsxs(BlockComponentContext, {
52
+ value: {
53
+ BlockCollapsible: CollapsibleWithErrorProps,
54
+ EditButton,
55
+ initialState,
56
+ nodeKey,
57
+ RemoveButton
58
+ },
59
+ children: [CustomBlock, _jsx(BlockDrawer, {})]
60
+ }) : _jsx(CollapsibleWithErrorProps, {
61
+ children: _jsx(RenderFields, {
62
+ fields: formSchema,
63
+ forceRender: true,
64
+ parentIndexPath: "",
65
+ parentPath: "",
66
+ parentSchemaPath: "",
67
+ permissions: true
68
+ })
69
+ });
70
+ $[4] = BlockDrawer;
71
+ $[5] = CollapsibleWithErrorProps;
72
+ $[6] = CustomBlock;
73
+ $[7] = EditButton;
74
+ $[8] = RemoveButton;
75
+ $[9] = formSchema;
76
+ $[10] = initialState;
77
+ $[11] = nodeKey;
78
+ $[12] = t1;
79
+ } else {
80
+ t1 = $[12];
81
+ }
82
+ return t1;
80
83
  };
81
84
  //# sourceMappingURL=BlockContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlockContent.js","names":["c","_c","useLexicalEditable","RenderFields","useFormSubmitted","React","createContext","useMemo","BlockComponentContext","baseClass","BlockCollapsible","BlockDrawer","CustomBlock","EditButton","errorCount","formSchema","initialState","nodeKey","RemoveButton","useBlockComponentContext","use","BlockContent","props","$","Collapsible","contextProps","hasSubmitted","fieldHasErrors","isEditable","t0","props_0","children","rest","_jsx","CollapsibleWithErrorProps","_jsxs","value","fields","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","readOnly"],"sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"sourcesContent":["'use client'\nimport type { CollapsibleProps } from '@payloadcms/ui/elements/Collapsible'\nimport type { ClientField, FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { RenderFields, useFormSubmitted } from '@payloadcms/ui'\nimport React, { createContext, useMemo } from 'react'\n\nexport type BlockCollapsibleProps = {\n /**\n * Replace the top-right portion of the header that renders the Edit and Remove buttons with custom content.\n * If this property is provided, the `removeButton` and `editButton` properties are ignored.\n */\n Actions?: React.ReactNode\n children?: React.ReactNode\n /**\n * Additional className to the collapsible wrapper\n */\n className?: string\n /**\n * Props to pass to the underlying Collapsible component. You could use this to override the `Header` entirely, for example.\n */\n collapsibleProps?: Partial<CollapsibleProps>\n /**\n * Whether to disable rendering the block name field in the header Label\n * @default false\n */\n disableBlockName?: boolean\n /**\n * Whether to show the Edit button\n * If `Actions` is provided, this property is ignored.\n * @default true\n */\n editButton?: boolean\n /**\n * Replace the default Label component with a custom Label\n */\n Label?: React.ReactNode\n /**\n * Replace the default Pill component component that's rendered within the default Label component with a custom Pill.\n * This property has no effect if you provide a custom Label component via the `Label` property.\n */\n Pill?: React.ReactNode\n /**\n * Whether to show the Remove button\n * If `Actions` is provided, this property is ignored.\n * @default true\n */\n removeButton?: boolean\n}\n\nexport type BlockCollapsibleWithErrorProps = {\n errorCount?: number\n fieldHasErrors?: boolean\n} & BlockCollapsibleProps\n\nexport type BlockContentProps = {\n baseClass: string\n BlockDrawer: React.FC\n Collapsible: React.FC<BlockCollapsibleWithErrorProps>\n CustomBlock: React.ReactNode\n EditButton: React.FC\n errorCount: number\n formSchema: ClientField[]\n initialState: false | FormState | undefined\n\n nodeKey: string\n RemoveButton: React.FC\n}\n\ntype BlockComponentContextType = {\n BlockCollapsible: React.FC<BlockCollapsibleProps>\n} & Omit<BlockContentProps, 'Collapsible'>\n\nconst BlockComponentContext = createContext<BlockComponentContextType>({\n baseClass: 'lexical-block',\n BlockCollapsible: () => null,\n BlockDrawer: () => null,\n CustomBlock: null,\n EditButton: () => null,\n errorCount: 0,\n formSchema: [],\n initialState: false,\n nodeKey: '',\n RemoveButton: () => null,\n})\n\nexport const useBlockComponentContext = () => React.use(BlockComponentContext)\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<BlockContentProps> = (props) => {\n const { Collapsible, ...contextProps } = props\n\n const { BlockDrawer, CustomBlock, errorCount, formSchema } = contextProps\n\n const hasSubmitted = useFormSubmitted()\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n const isEditable = useLexicalEditable()\n\n const CollapsibleWithErrorProps = useMemo(\n () => (props: BlockCollapsibleProps) => {\n const { children, ...rest } = props\n return (\n <Collapsible errorCount={errorCount} fieldHasErrors={fieldHasErrors} {...rest}>\n {children}\n </Collapsible>\n )\n },\n [Collapsible, fieldHasErrors, errorCount],\n )\n\n return CustomBlock ? (\n <BlockComponentContext\n value={{\n ...contextProps,\n BlockCollapsible: CollapsibleWithErrorProps,\n }}\n >\n {CustomBlock}\n <BlockDrawer />\n </BlockComponentContext>\n ) : (\n <CollapsibleWithErrorProps>\n <RenderFields\n fields={formSchema}\n forceRender={true}\n parentIndexPath=\"\"\n parentPath={''}\n parentSchemaPath=\"\"\n permissions={true}\n readOnly={!isEditable}\n />\n </CollapsibleWithErrorProps>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,E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AAAW,yBAAA,GACQL,EAON;EACyC,OAGpCjB,WAAA,GACLuB,KAAA,CAAA3B,qBAAA;IAAA4B,KAAA;MAAA,GAEOX,YAAY;MAAAf,gBAAA,EACGwB;IAAA;IAAAH,QAAA,GAGnBnB,WAAA,EACDqB,IAAA,CAACtB,WAAA;EAAA,C,IAGHsB,IAAA,CAACC,yBAAA;IAAAH,QAAA,EACCE,IAAA,CAAA9B,YAAA;MAAAkC,MAAA,EACUtB,UAAA;MAAAuB,WAAA;MAAAC,eAAA,EAEQ;MAAAC,UAAA,EACJ;MAAAC,gBAAA,EACK;MAAAC,WAAA;MAAAC,QAAA,GAENf;IAAA,C;;CAInB","ignoreList":[]}
1
+ {"version":3,"file":"BlockContent.js","names":["c","_c","RenderFields","useFormSubmitted","React","createContext","useMemo","BlockComponentContext","initialState","useBlockComponentContext","use","BlockContent","props","$","BlockDrawer","Collapsible","CustomBlock","EditButton","errorCount","formSchema","nodeKey","RemoveButton","hasSubmitted","fieldHasErrors","t0","props_0","_jsx","editButton","Label","removeButton","children","CollapsibleWithErrorProps","t1","_jsxs","value","BlockCollapsible","fields","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, FormState } from 'payload'\n\nimport { RenderFields, useFormSubmitted } from '@payloadcms/ui'\nimport React, { createContext, useMemo } from 'react'\n\ntype Props = {\n baseClass: string\n BlockDrawer: React.FC\n Collapsible: React.FC<{\n children?: React.ReactNode\n editButton?: boolean\n errorCount?: number\n fieldHasErrors?: boolean\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }>\n CustomBlock: React.ReactNode\n EditButton: React.FC\n errorCount: number\n formSchema: ClientField[]\n initialState: false | FormState | undefined\n\n nodeKey: string\n RemoveButton: React.FC\n}\n\ntype BlockComponentContextType = {\n BlockCollapsible?: React.FC<{\n children?: React.ReactNode\n editButton?: boolean\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }>\n EditButton?: React.FC\n initialState: false | FormState | undefined\n\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst BlockComponentContext = createContext<BlockComponentContextType>({\n initialState: false,\n})\n\nexport const useBlockComponentContext = () => React.use(BlockComponentContext)\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 {\n BlockDrawer,\n Collapsible,\n CustomBlock,\n EditButton,\n errorCount,\n formSchema,\n initialState,\n nodeKey,\n RemoveButton,\n } = props\n\n const hasSubmitted = useFormSubmitted()\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const CollapsibleWithErrorProps = useMemo(\n () =>\n (props: {\n children?: React.ReactNode\n editButton?: boolean\n\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }) => (\n <Collapsible\n editButton={props.editButton}\n errorCount={errorCount}\n fieldHasErrors={fieldHasErrors}\n Label={props.Label}\n removeButton={props.removeButton}\n >\n {props.children}\n </Collapsible>\n ),\n [Collapsible, fieldHasErrors, errorCount],\n )\n\n return CustomBlock ? (\n <BlockComponentContext\n value={{\n BlockCollapsible: CollapsibleWithErrorProps,\n EditButton,\n initialState,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n <BlockDrawer />\n </BlockComponentContext>\n ) : (\n <CollapsibleWithErrorProps>\n <RenderFields\n fields={formSchema}\n forceRender={true}\n parentIndexPath=\"\"\n parentPath={''}\n parentSchemaPath=\"\"\n permissions={true}\n />\n </CollapsibleWithErrorProps>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,YAAY,EAAEC,gBAAgB,QAAQ;AAC/C,OAAOC,KAAA,IAASC,aAAa,EAAEC,OAAO,QAAQ;AA2C9C,MAAMC,qBAAA,gBAA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;MAAAS,QAAA,GAOnBd,WAAA,EACDU,IAAA,CAACZ,WAAA;IAAA,C,IAGHY,IAAA,CAACK,yBAAA;MAAAD,QAAA,EACCJ,IAAA,CAAAxB,YAAA;QAAAkC,MAAA,EACUjB,UAAA;QAAAkB,WAAA;QAAAC,eAAA,EAEQ;QAAAC,UAAA,EACJ;QAAAC,gBAAA,EACK;QAAAC,WAAA;MAAA,C;;;;;;;;;;;;;;SApBhBT,E;CAyBT","ignoreList":[]}
@@ -1,4 +1,11 @@
1
1
  import React from 'react';
2
- import { type BlockCollapsibleProps } from '../BlockContent.js';
3
- export declare const BlockCollapsible: React.FC<BlockCollapsibleProps>;
2
+ export declare const BlockCollapsible: React.FC<{
3
+ children?: React.ReactNode;
4
+ editButton?: boolean;
5
+ /**
6
+ * Override the default label with a custom label
7
+ */
8
+ Label?: React.ReactNode;
9
+ removeButton?: boolean;
10
+ }>;
4
11
  //# sourceMappingURL=BlockCollapsible.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlockCollapsible.d.ts","sourceRoot":"","sources":["../../../../../../src/features/blocks/client/component/components/BlockCollapsible.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,KAAK,qBAAqB,EAA4B,MAAM,oBAAoB,CAAA;AAEzF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAK5D,CAAA"}
1
+ {"version":3,"file":"BlockCollapsible.d.ts","sourceRoot":"","sources":["../../../../../../src/features/blocks/client/component/components/BlockCollapsible.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAQA,CAAA"}
@@ -1,19 +1,37 @@
1
1
  'use client';
2
2
 
3
+ import { c as _c } from "react/compiler-runtime";
3
4
  import { jsx as _jsx } from "react/jsx-runtime";
4
5
  import React from 'react';
5
6
  import { useBlockComponentContext } from '../BlockContent.js';
6
- export const BlockCollapsible = props => {
7
+ export const BlockCollapsible = t0 => {
8
+ const $ = _c(6);
7
9
  const {
8
10
  children,
9
- ...rest
10
- } = props;
11
+ editButton,
12
+ Label,
13
+ removeButton
14
+ } = t0;
11
15
  const {
12
16
  BlockCollapsible
13
17
  } = useBlockComponentContext();
14
- return BlockCollapsible ? _jsx(BlockCollapsible, {
15
- ...rest,
16
- children
17
- }) : null;
18
+ let t1;
19
+ if ($[0] !== BlockCollapsible || $[1] !== Label || $[2] !== children || $[3] !== editButton || $[4] !== removeButton) {
20
+ t1 = BlockCollapsible ? _jsx(BlockCollapsible, {
21
+ editButton,
22
+ Label,
23
+ removeButton,
24
+ children
25
+ }) : null;
26
+ $[0] = BlockCollapsible;
27
+ $[1] = Label;
28
+ $[2] = children;
29
+ $[3] = editButton;
30
+ $[4] = removeButton;
31
+ $[5] = t1;
32
+ } else {
33
+ t1 = $[5];
34
+ }
35
+ return t1;
18
36
  };
19
37
  //# sourceMappingURL=BlockCollapsible.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlockCollapsible.js","names":["React","useBlockComponentContext","BlockCollapsible","props","children","rest","_jsx"],"sources":["../../../../../../src/features/blocks/client/component/components/BlockCollapsible.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { type BlockCollapsibleProps, useBlockComponentContext } from '../BlockContent.js'\n\nexport const BlockCollapsible: React.FC<BlockCollapsibleProps> = (props) => {\n const { children, ...rest } = props\n const { BlockCollapsible } = useBlockComponentContext()\n\n return BlockCollapsible ? <BlockCollapsible {...rest}>{children}</BlockCollapsible> : null\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,SAAqCC,wBAAwB,QAAQ;AAErE,OAAO,MAAMC,gBAAA,GAAoDC,KAAA;EAC/D;IAAAC,QAAA;IAAA,GAAAC;EAAA,IAA8BF,KAAA;EAC9B;IAAAD;EAAA,IAA6BD,wBAAA;EAAA,OAEtBC,gBAAA,GAAmBI,IAAA,CAACJ,gBAAA;IAAA,GAAqBG,IAAI;IAAAD;EAAA,C,QAAkC;AAAA,CACxF","ignoreList":[]}
1
+ {"version":3,"file":"BlockCollapsible.js","names":["c","_c","React","useBlockComponentContext","BlockCollapsible","t0","$","children","editButton","Label","removeButton","t1","_jsx"],"sources":["../../../../../../src/features/blocks/client/component/components/BlockCollapsible.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { useBlockComponentContext } from '../BlockContent.js'\n\nexport const BlockCollapsible: React.FC<{\n children?: React.ReactNode\n editButton?: boolean\n\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n}> = ({ children, editButton, Label, removeButton }) => {\n const { BlockCollapsible } = useBlockComponentContext()\n\n return BlockCollapsible ? (\n <BlockCollapsible editButton={editButton} Label={Label} removeButton={removeButton}>\n {children}\n </BlockCollapsible>\n ) : null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,OAAOC,KAAA,MAAW;AAElB,SAASC,wBAAwB,QAAQ;AAEzC,OAAO,MAAMC,gBAAA,GASRC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAAC;IAAAM,QAAA;IAAAC,UAAA;IAAAC,KAAA;IAAAC;EAAA,IAAAL,EAA6C;EACjD;IAAAD;EAAA,IAA6BD,wBAAA;EAAA,IAAAQ,EAAA;EAAA,IAAAL,CAAA,QAAAF,gBAAA,IAAAE,CAAA,QAAAG,KAAA,IAAAH,CAAA,QAAAC,QAAA,IAAAD,CAAA,QAAAE,UAAA,IAAAF,CAAA,QAAAI,YAAA;IAEtBC,EAAA,GAAAP,gBAAA,GACLQ,IAAA,CAACR,gBAAA;MAAAI,UAAA;MAAAC,KAAA;MAAAC,YAAA;MAAAH;IAAA,C,QAGC;IAAAD,CAAA,MAAAF,gBAAA;IAAAE,CAAA,MAAAG,KAAA;IAAAH,CAAA,MAAAC,QAAA;IAAAD,CAAA,MAAAE,UAAA;IAAAF,CAAA,MAAAI,YAAA;IAAAJ,CAAA,MAAAK,EAAA;EAAA;IAAAA,EAAA,GAAAL,CAAA;EAAA;EAAA,OAJGK,EAIH;AAAA,CACN","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAgBtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAGnE,OAAO,cAAc,CAAA;AAMrB,KAAK,KAAK,GAAG;IACX;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAijB1C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAetE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAInE,OAAO,cAAc,CAAA;AAKrB,KAAK,KAAK,GAAG;IACX;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiiB1C,CAAA"}
@@ -7,7 +7,6 @@ import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from
7
7
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
8
8
  const baseClass = 'lexical-block';
9
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
10
- import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
11
10
  import { getTranslation } from '@payloadcms/translations';
12
11
  import { $getNodeByKey } from 'lexical';
13
12
  import { v4 as uuid } from 'uuid';
@@ -33,6 +32,8 @@ export const BlockComponent = props => {
33
32
  featureClientSchemaMap,
34
33
  field: parentLexicalRichTextField,
35
34
  initialLexicalFormState,
35
+ permissions,
36
+ readOnly,
36
37
  schemaPath
37
38
  },
38
39
  uuid: uuidFromContext
@@ -61,12 +62,10 @@ export const BlockComponent = props => {
61
62
  setDocFieldPreferences
62
63
  } = useDocumentInfo();
63
64
  const [editor] = useLexicalComposerContext();
64
- const isEditable = useLexicalEditable();
65
- const blockType = formData.blockType;
66
65
  const {
67
66
  getFormState
68
67
  } = useServerFunctions();
69
- const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`;
68
+ const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`;
70
69
  const [initialState, setInitialState] = React.useState(() => {
71
70
  return initialLexicalFormState?.[formData.id]?.formState ? {
72
71
  ...initialLexicalFormState?.[formData.id]?.formState,
@@ -92,10 +91,10 @@ export const BlockComponent = props => {
92
91
  }, [cacheBuster]);
93
92
  const [CustomLabel, setCustomLabel] = React.useState(
94
93
  // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
95
- initialState?.['_components']?.customComponents?.BlockLabel ?? undefined);
94
+ initialState?.['_components']?.customComponents?.BlockLabel);
96
95
  const [CustomBlock, setCustomBlock] = React.useState(
97
96
  // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
98
- initialState?.['_components']?.customComponents?.Block ?? undefined);
97
+ initialState?.['_components']?.customComponents?.Block);
99
98
  // Initial state for newly created blocks
100
99
  useEffect(() => {
101
100
  const abortController = new AbortController();
@@ -119,7 +118,6 @@ export const BlockComponent = props => {
119
118
  globalSlug,
120
119
  initialBlockData: formData,
121
120
  operation: 'update',
122
- readOnly: !isEditable,
123
121
  renderAllFields: true,
124
122
  schemaPath: schemaFieldsPath,
125
123
  signal: abortController.signal
@@ -137,13 +135,13 @@ export const BlockComponent = props => {
137
135
  const node = $getNodeByKey(nodeKey);
138
136
  if (node && $isBlockNode(node)) {
139
137
  const newData = newFormStateData;
140
- newData.blockType = blockType;
138
+ newData.blockType = formData.blockType;
141
139
  node.setFields(newData, true);
142
140
  }
143
141
  });
144
142
  setInitialState(state);
145
- setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined);
146
- setCustomBlock(state._components?.customComponents?.Block ?? undefined);
143
+ setCustomLabel(state._components?.customComponents?.BlockLabel);
144
+ setCustomBlock(state._components?.customComponents?.Block);
147
145
  }
148
146
  };
149
147
  if (formData && !initialState) {
@@ -152,9 +150,9 @@ export const BlockComponent = props => {
152
150
  return () => {
153
151
  abortAndIgnore(abortController);
154
152
  };
155
- }, [getFormState, schemaFieldsPath, isEditable, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType]);
153
+ }, [getFormState, schemaFieldsPath, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
156
154
  const [isCollapsed, setIsCollapsed] = React.useState(initialLexicalFormState?.[formData.id]?.collapsed ?? false);
157
- const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
155
+ const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`;
158
156
  const clientSchemaMap = featureClientSchemaMap['blocks'];
159
157
  const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
160
158
  const clientBlock = blocksField.blockReferences ? typeof blocksField?.blockReferences?.[0] === 'string' ? config.blocksMap[blocksField?.blockReferences?.[0]] : blocksField?.blockReferences?.[0] : blocksField?.blocks?.[0];
@@ -183,7 +181,6 @@ export const BlockComponent = props => {
183
181
  globalSlug,
184
182
  initialBlockFormState: prevFormState,
185
183
  operation: 'update',
186
- readOnly: !isEditable,
187
184
  renderAllFields: submit ? true : false,
188
185
  schemaPath: schemaFieldsPath,
189
186
  signal: controller.signal
@@ -202,14 +199,14 @@ export const BlockComponent = props => {
202
199
  const node_0 = $getNodeByKey(nodeKey);
203
200
  if (node_0 && $isBlockNode(node_0)) {
204
201
  const newData_0 = newFormStateData_0;
205
- newData_0.blockType = blockType;
202
+ newData_0.blockType = formData.blockType;
206
203
  node_0.setFields(newData_0, true);
207
204
  }
208
205
  });
209
206
  }, 0);
210
207
  if (submit) {
211
- setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined);
212
- setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined);
208
+ setCustomLabel(newFormState._components?.customComponents?.BlockLabel);
209
+ setCustomBlock(newFormState._components?.customComponents?.Block);
213
210
  let rowErrorCount = 0;
214
211
  for (const formField of Object.values(newFormState)) {
215
212
  if (formField?.valid === false) {
@@ -219,7 +216,7 @@ export const BlockComponent = props => {
219
216
  setErrorCount(rowErrorCount);
220
217
  }
221
218
  return newFormState;
222
- }, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, blockType, parentDocumentFields, isEditable, editor, nodeKey]);
219
+ }, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, formData.blockType, parentDocumentFields, editor, nodeKey]);
223
220
  useEffect(() => {
224
221
  return () => {
225
222
  abortAndIgnore(onChangeAbortControllerRef.current);
@@ -254,7 +251,7 @@ export const BlockComponent = props => {
254
251
  const EditButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
255
252
  buttonStyle: "icon-label",
256
253
  className: `${baseClass}__editButton`,
257
- disabled: !isEditable,
254
+ disabled: readOnly,
258
255
  el: "button",
259
256
  icon: "edit",
260
257
  onClick: e => {
@@ -273,11 +270,11 @@ export const BlockComponent = props => {
273
270
  tooltip: t('lexical:blocks:inlineBlocks:edit', {
274
271
  label: blockDisplayName
275
272
  })
276
- }), [blockDisplayName, t, isEditable, toggleDrawer]);
273
+ }), [blockDisplayName, readOnly, t, toggleDrawer]);
277
274
  const RemoveButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
278
275
  buttonStyle: "icon-label",
279
276
  className: `${baseClass}__removeButton`,
280
- disabled: !isEditable,
277
+ disabled: parentLexicalRichTextField?.admin?.readOnly || false,
281
278
  icon: "x",
282
279
  onClick: e_1 => {
283
280
  e_1.preventDefault();
@@ -285,65 +282,53 @@ export const BlockComponent = props => {
285
282
  },
286
283
  round: true,
287
284
  tooltip: "Remove Block"
288
- }), [isEditable, removeBlock]);
285
+ }), [parentLexicalRichTextField?.admin?.readOnly, removeBlock]);
289
286
  const BlockCollapsible = useMemo(() => ({
290
- Actions,
291
287
  children,
292
- className,
293
- collapsibleProps,
294
288
  disableBlockName,
295
289
  editButton,
296
290
  errorCount: errorCount_0,
297
291
  fieldHasErrors,
298
292
  Label,
299
- Pill: CustomPill,
300
293
  removeButton
301
- }) => {
302
- return /*#__PURE__*/_jsx("div", {
303
- className: baseClass + ' ' + baseClass + '-' + blockType,
304
- children: /*#__PURE__*/_jsx(Collapsible, {
305
- className: [`${baseClass}__row`, fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`, className].filter(Boolean).join(' '),
306
- collapsibleStyle: fieldHasErrors ? 'error' : 'default',
307
- header: /*#__PURE__*/_jsxs("div", {
308
- className: `${baseClass}__block-header`,
309
- children: [typeof Label !== 'undefined' ? Label : typeof CustomLabel !== 'undefined' ? CustomLabel : /*#__PURE__*/_jsxs("div", {
310
- className: `${baseClass}__block-label`,
311
- children: [typeof CustomPill !== 'undefined' ? CustomPill : /*#__PURE__*/_jsx(Pill, {
312
- className: `${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`,
313
- pillStyle: "white",
314
- size: "small",
315
- children: blockDisplayName ?? blockType
316
- }), !disableBlockName && !clientBlock?.admin?.disableBlockName && /*#__PURE__*/_jsx(SectionTitle, {
317
- path: "blockName",
318
- readOnly: !isEditable
319
- }), fieldHasErrors && /*#__PURE__*/_jsx(ErrorPill, {
320
- count: errorCount_0 ?? 0,
321
- i18n: i18n,
322
- withMessage: true
323
- })]
324
- }), /*#__PURE__*/_jsx("div", {
325
- className: `${baseClass}__block-actions`,
326
- children: typeof Actions !== 'undefined' ? Actions : /*#__PURE__*/_jsxs(_Fragment, {
327
- children: [CustomBlock && editButton !== false || !CustomBlock && editButton ? /*#__PURE__*/_jsx(EditButton, {}) : null, removeButton !== false && isEditable ? /*#__PURE__*/_jsx(RemoveButton, {}) : null]
328
- })
294
+ }) => /*#__PURE__*/_jsx("div", {
295
+ className: baseClass + ' ' + baseClass + '-' + formData.blockType,
296
+ children: /*#__PURE__*/_jsx(Collapsible, {
297
+ className: [`${baseClass}__row`, fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`].join(' '),
298
+ collapsibleStyle: fieldHasErrors ? 'error' : 'default',
299
+ header: /*#__PURE__*/_jsxs("div", {
300
+ className: `${baseClass}__block-header`,
301
+ children: [Label ?? CustomLabel ? Label ?? CustomLabel : /*#__PURE__*/_jsxs("div", {
302
+ children: [/*#__PURE__*/_jsx(Pill, {
303
+ className: `${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`,
304
+ pillStyle: "white",
305
+ size: "small",
306
+ children: blockDisplayName ?? formData?.blockType
307
+ }), !disableBlockName && !clientBlock?.admin?.disableBlockName && /*#__PURE__*/_jsx(SectionTitle, {
308
+ path: "blockName",
309
+ readOnly: parentLexicalRichTextField?.admin?.readOnly || false
310
+ }), fieldHasErrors && /*#__PURE__*/_jsx(ErrorPill, {
311
+ count: errorCount_0 ?? 0,
312
+ i18n: i18n,
313
+ withMessage: true
329
314
  })]
330
- }),
331
- isCollapsed: isCollapsed,
332
- onToggle: incomingCollapsedState => {
333
- onCollapsedChange(incomingCollapsedState);
334
- setIsCollapsed(incomingCollapsedState);
335
- },
336
- ...(collapsibleProps || {}),
337
- children: children
338
- }, 0)
339
- });
340
- }, [CustomBlock, CustomLabel, EditButton, RemoveButton, blockDisplayName, clientBlock?.admin?.disableBlockName, blockType, i18n, isCollapsed, onCollapsedChange, isEditable]);
341
- const blockID = formData?.id;
315
+ }), /*#__PURE__*/_jsxs("div", {
316
+ children: [CustomBlock && editButton !== false || !CustomBlock && editButton ? /*#__PURE__*/_jsx(EditButton, {}) : null, removeButton !== false && editor.isEditable() ? /*#__PURE__*/_jsx(RemoveButton, {}) : null]
317
+ })]
318
+ }),
319
+ isCollapsed: isCollapsed,
320
+ onToggle: incomingCollapsedState => {
321
+ onCollapsedChange(incomingCollapsedState);
322
+ setIsCollapsed(incomingCollapsedState);
323
+ },
324
+ children: children
325
+ }, 0)
326
+ }), [CustomBlock, CustomLabel, EditButton, RemoveButton, blockDisplayName, clientBlock?.admin?.disableBlockName, editor, formData.blockType, i18n, isCollapsed, onCollapsedChange, parentLexicalRichTextField?.admin?.readOnly]);
342
327
  const BlockDrawer = useMemo(() => () => /*#__PURE__*/_jsx(EditDepthProvider, {
343
328
  children: /*#__PURE__*/_jsx(Drawer, {
344
329
  className: '',
345
330
  slug: drawerSlug,
346
- title: t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {
331
+ title: t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {
347
332
  label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label')
348
333
  }),
349
334
  children: initialState ? /*#__PURE__*/_jsxs(_Fragment, {
@@ -356,14 +341,14 @@ export const BlockComponent = props => {
356
341
 
357
342
  parentSchemaPath: schemaFieldsPath,
358
343
  permissions: true,
359
- readOnly: !isEditable
344
+ readOnly: false
360
345
  }), /*#__PURE__*/_jsx(FormSubmit, {
361
346
  programmaticSubmit: true,
362
347
  children: t('fields:saveChanges')
363
348
  })]
364
349
  }) : null
365
350
  })
366
- }), [initialState, drawerSlug, blockID, blockDisplayName, t, isEditable, clientBlock?.fields, schemaFieldsPath]);
351
+ }), [initialState, drawerSlug, blockDisplayName, t, clientBlock?.fields, schemaFieldsPath, permissions]);
367
352
  // Memoized Form JSX
368
353
  const Block = useMemo(() => {
369
354
  if (!initialState) {
@@ -385,7 +370,7 @@ export const BlockComponent = props => {
385
370
  onChange: [onChange],
386
371
  onSubmit: (formState_0, newData_1) => {
387
372
  // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
388
- newData_1.blockType = blockType;
373
+ newData_1.blockType = formData.blockType;
389
374
  editor.update(() => {
390
375
  const node_1 = $getNodeByKey(nodeKey);
391
376
  if (node_1 && $isBlockNode(node_1)) {
@@ -409,7 +394,7 @@ export const BlockComponent = props => {
409
394
  RemoveButton: RemoveButton
410
395
  })
411
396
  });
412
- }, [BlockCollapsible, BlockDrawer, CustomBlock, blockType, RemoveButton, EditButton, editor, errorCount, toggleDrawer, clientBlock?.fields,
397
+ }, [BlockCollapsible, BlockDrawer, CustomBlock, clientBlock?.fields, RemoveButton, EditButton, editor, errorCount, toggleDrawer, clientBlock?.fields,
413
398
  // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.
414
399
  initialState, nodeKey, onChange, submitted]);
415
400
  if (!clientBlock) {
@@ -418,7 +403,7 @@ export const BlockComponent = props => {
418
403
  fieldHasErrors: true,
419
404
  children: /*#__PURE__*/_jsxs("div", {
420
405
  className: "lexical-block-not-found",
421
- children: ["Error: Block '", blockType, "' not found in the config but exists in the lexical data"]
406
+ children: ["Error: Block '", formData.blockType, "' not found in the config but exists in the lexical data"]
422
407
  })
423
408
  });
424
409
  }