@payloadcms/richtext-lexical 3.83.0-internal.06ac84e → 3.83.0-internal.86b7bfb
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.
- package/dist/exports/client/Field-4UEGQMIN.js +2 -0
- package/dist/exports/client/Field-4UEGQMIN.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-FTT5KJ6W.js +12 -0
- package/dist/exports/client/chunk-FTT5KJ6W.js.map +7 -0
- package/dist/exports/client/chunk-YWIZCGSY.js +2 -0
- package/dist/exports/client/chunk-YWIZCGSY.js.map +7 -0
- package/dist/exports/client/componentInline-CBBUBQ7P.js +2 -0
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +23 -23
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/client/internal-client.d.ts +3 -0
- package/dist/exports/client/internal-client.d.ts.map +1 -0
- package/dist/exports/react/index.d.ts +3 -1
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js +1 -0
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.d.ts +7 -4
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +9 -8
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +20 -4
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +112 -55
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +8 -14
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +67 -18
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +4 -2
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +3 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +4 -2
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +3 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +6 -20
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +7 -5
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +17 -2
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +133 -4
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +18 -6
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RichTextViewProvider.d.ts +86 -0
- package/dist/field/RichTextViewProvider.d.ts.map +1 -0
- package/dist/field/RichTextViewProvider.js +94 -0
- package/dist/field/RichTextViewProvider.js.map +1 -0
- package/dist/field/ViewSelector.d.ts +4 -0
- package/dist/field/ViewSelector.d.ts.map +1 -0
- package/dist/field/ViewSelector.js +89 -0
- package/dist/field/ViewSelector.js.map +1 -0
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts +1 -0
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +68 -36
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +12 -0
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +18 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +2 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +12 -3
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +3 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +4 -0
- package/dist/lexical/config/types.d.ts.map +1 -1
- package/dist/lexical/config/types.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +12 -2
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +213 -2
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +48 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +14 -1
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/types.d.ts +350 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +1 -0
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +6 -1
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +10 -4
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +12 -8
- package/dist/exports/client/Field-OIMYWB22.js +0 -2
- package/dist/exports/client/Field-OIMYWB22.js.map +0 -7
- package/dist/exports/client/chunk-2S5Q7QYO.js +0 -2
- package/dist/exports/client/chunk-2S5Q7QYO.js.map +0 -7
- package/dist/exports/client/chunk-EZX4YW7S.js +0 -12
- package/dist/exports/client/chunk-EZX4YW7S.js.map +0 -7
- package/dist/exports/client/componentInline-NL25DNZ5.js +0 -2
- /package/dist/exports/client/{componentInline-NL25DNZ5.js.map → componentInline-CBBUBQ7P.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-client.d.ts","sourceRoot":"","sources":["../../../src/exports/client/internal-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,wBAAwB,GACzB,MAAM,wDAAwD,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type { BlockComponentContextType } from '../../features/blocks/client/component/BlockContent.js';
|
|
1
2
|
export { type JSXConvertersFunction, RichText, } from '../../features/converters/lexicalToJSX/Component/index.js';
|
|
2
3
|
export { BlockquoteJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/blockquote.js';
|
|
3
4
|
export { HeadingJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/heading.js';
|
|
@@ -12,5 +13,6 @@ export { TextJSXConverter } from '../../features/converters/lexicalToJSX/convert
|
|
|
12
13
|
export { UploadJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/upload.js';
|
|
13
14
|
export { defaultJSXConverters } from '../../features/converters/lexicalToJSX/converter/defaultConverters.js';
|
|
14
15
|
export { convertLexicalNodesToJSX } from '../../features/converters/lexicalToJSX/converter/index.js';
|
|
15
|
-
export type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent, } from '../../features/converters/lexicalToJSX/converter/types.js';
|
|
16
|
+
export type { JSXConverter, JSXConverterArgs, JSXConverters, SerializedLexicalNodeWithParent, } from '../../features/converters/lexicalToJSX/converter/types.js';
|
|
17
|
+
export type { ViewMapBlockComponentProps, ViewMapBlockEditorProps, ViewMapBlockJSXConverterProps, } from '../../types.js';
|
|
16
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/react/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/react/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,yBAAyB,EAAE,MAAM,wDAAwD,CAAA;AACvG,OAAO,EACL,KAAK,qBAAqB,EAC1B,QAAQ,GACT,MAAM,2DAA2D,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2EAA2E,CAAA;AAClH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wEAAwE,CAAA;AAC5G,OAAO,EAAE,0BAA0B,EAAE,MAAM,+EAA+E,CAAA;AAC1H,OAAO,EAAE,qBAAqB,EAAE,MAAM,0EAA0E,CAAA;AAChH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAA;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAA;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0EAA0E,CAAA;AAChH,OAAO,EAAE,eAAe,EAAE,MAAM,oEAAoE,CAAA;AAEpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sEAAsE,CAAA;AAExG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAA;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uEAAuE,CAAA;AAC1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAA;AAC5G,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAA;AAEpG,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,+BAA+B,GAChC,MAAM,2DAA2D,CAAA;AAGlE,YAAY,EACV,0BAA0B,EAC1B,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Export block context type for typing custom Block components
|
|
1
2
|
export { RichText } from '../../features/converters/lexicalToJSX/Component/index.js';
|
|
2
3
|
export { BlockquoteJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/blockquote.js';
|
|
3
4
|
export { HeadingJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/heading.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RichText","BlockquoteJSXConverter","HeadingJSXConverter","HorizontalRuleJSXConverter","LinebreakJSXConverter","LinkJSXConverter","ListJSXConverter","ParagraphJSXConverter","TabJSXConverter","TableJSXConverter","TextJSXConverter","UploadJSXConverter","defaultJSXConverters","convertLexicalNodesToJSX"],"sources":["../../../src/exports/react/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["RichText","BlockquoteJSXConverter","HeadingJSXConverter","HorizontalRuleJSXConverter","LinebreakJSXConverter","LinkJSXConverter","ListJSXConverter","ParagraphJSXConverter","TabJSXConverter","TableJSXConverter","TextJSXConverter","UploadJSXConverter","defaultJSXConverters","convertLexicalNodesToJSX"],"sources":["../../../src/exports/react/index.ts"],"sourcesContent":["// Export block context type for typing custom Block components\nexport type { BlockComponentContextType } from '../../features/blocks/client/component/BlockContent.js'\nexport {\n type JSXConvertersFunction,\n RichText,\n} from '../../features/converters/lexicalToJSX/Component/index.js'\nexport { BlockquoteJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/blockquote.js'\nexport { HeadingJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/heading.js'\nexport { HorizontalRuleJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/horizontalRule.js'\nexport { LinebreakJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/linebreak.js'\nexport { LinkJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/link.js'\nexport { ListJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/list.js'\nexport { ParagraphJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/paragraph.js'\nexport { TabJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/tab.js'\n\nexport { TableJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/table.js'\n\nexport { TextJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/text.js'\nexport { UploadJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/upload.js'\nexport { defaultJSXConverters } from '../../features/converters/lexicalToJSX/converter/defaultConverters.js'\nexport { convertLexicalNodesToJSX } from '../../features/converters/lexicalToJSX/converter/index.js'\n\nexport type {\n JSXConverter,\n JSXConverterArgs,\n JSXConverters,\n SerializedLexicalNodeWithParent,\n} from '../../features/converters/lexicalToJSX/converter/types.js'\n\n// Export view map block props for typing custom Block components\nexport type {\n ViewMapBlockComponentProps,\n ViewMapBlockEditorProps,\n ViewMapBlockJSXConverterProps,\n} from '../../types.js'\n"],"mappings":"AAAA;AAEA,SAEEA,QAAQ,QACH;AACP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,eAAe,QAAQ;AAEhC,SAASC,iBAAiB,QAAQ;AAElC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,wBAAwB,QAAQ","ignoreList":[]}
|
|
@@ -51,7 +51,11 @@ export type BlockContentProps = {
|
|
|
51
51
|
baseClass: string;
|
|
52
52
|
BlockDrawer: React.FC;
|
|
53
53
|
Collapsible: React.FC<BlockCollapsibleWithErrorProps>;
|
|
54
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Custom block component (pre-rendered ReactNode).
|
|
56
|
+
*/
|
|
57
|
+
CustomBlock?: React.ReactNode;
|
|
58
|
+
CustomLabel: React.ReactNode;
|
|
55
59
|
EditButton: React.FC;
|
|
56
60
|
errorCount: number;
|
|
57
61
|
formSchema: ClientField[];
|
|
@@ -59,9 +63,9 @@ export type BlockContentProps = {
|
|
|
59
63
|
nodeKey: string;
|
|
60
64
|
RemoveButton: React.FC;
|
|
61
65
|
};
|
|
62
|
-
type BlockComponentContextType = {
|
|
66
|
+
export type BlockComponentContextType = {
|
|
63
67
|
BlockCollapsible: React.FC<BlockCollapsibleProps>;
|
|
64
|
-
} & Omit<BlockContentProps, 'Collapsible'>;
|
|
68
|
+
} & Omit<BlockContentProps, 'Collapsible' | 'CustomBlock' | 'CustomLabel'>;
|
|
65
69
|
export declare const useBlockComponentContext: () => BlockComponentContextType;
|
|
66
70
|
/**
|
|
67
71
|
* The actual content of the Block. This should be INSIDE a Form component,
|
|
@@ -69,5 +73,4 @@ export declare const useBlockComponentContext: () => BlockComponentContextType;
|
|
|
69
73
|
* not the whole document.
|
|
70
74
|
*/
|
|
71
75
|
export declare const BlockContent: React.FC<BlockContentProps>;
|
|
72
|
-
export {};
|
|
73
76
|
//# 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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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,MAAM,MAAM,yBAAyB,GAAG;IACtC,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAA;CAClD,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,aAAa,GAAG,aAAa,CAAC,CAAA;AAc1E,eAAO,MAAM,wBAAwB,iCAAyC,CAAA;AAE9E;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8CpD,CAAA"}
|
|
@@ -9,7 +9,6 @@ const BlockComponentContext = /*#__PURE__*/createContext({
|
|
|
9
9
|
baseClass: 'LexicalEditorTheme__block',
|
|
10
10
|
BlockCollapsible: () => null,
|
|
11
11
|
BlockDrawer: () => null,
|
|
12
|
-
CustomBlock: null,
|
|
13
12
|
EditButton: () => null,
|
|
14
13
|
errorCount: 0,
|
|
15
14
|
formSchema: [],
|
|
@@ -27,11 +26,12 @@ export const BlockContent = props => {
|
|
|
27
26
|
const $ = _c(4);
|
|
28
27
|
const {
|
|
29
28
|
Collapsible,
|
|
29
|
+
CustomBlock,
|
|
30
|
+
CustomLabel,
|
|
30
31
|
...contextProps
|
|
31
32
|
} = props;
|
|
32
33
|
const {
|
|
33
34
|
BlockDrawer,
|
|
34
|
-
CustomBlock,
|
|
35
35
|
errorCount,
|
|
36
36
|
formSchema
|
|
37
37
|
} = contextProps;
|
|
@@ -40,11 +40,11 @@ export const BlockContent = props => {
|
|
|
40
40
|
const isEditable = useLexicalEditable();
|
|
41
41
|
let t0;
|
|
42
42
|
if ($[0] !== Collapsible || $[1] !== errorCount || $[2] !== fieldHasErrors) {
|
|
43
|
-
t0 =
|
|
43
|
+
t0 = collapsibleProps => {
|
|
44
44
|
const {
|
|
45
45
|
children,
|
|
46
46
|
...rest
|
|
47
|
-
} =
|
|
47
|
+
} = collapsibleProps;
|
|
48
48
|
return _jsx(Collapsible, {
|
|
49
49
|
errorCount,
|
|
50
50
|
fieldHasErrors,
|
|
@@ -60,11 +60,12 @@ export const BlockContent = props => {
|
|
|
60
60
|
t0 = $[3];
|
|
61
61
|
}
|
|
62
62
|
const CollapsibleWithErrorProps = t0;
|
|
63
|
+
const blockContextValue = {
|
|
64
|
+
...contextProps,
|
|
65
|
+
BlockCollapsible: CollapsibleWithErrorProps
|
|
66
|
+
};
|
|
63
67
|
return CustomBlock ? _jsxs(BlockComponentContext, {
|
|
64
|
-
value:
|
|
65
|
-
...contextProps,
|
|
66
|
-
BlockCollapsible: CollapsibleWithErrorProps
|
|
67
|
-
},
|
|
68
|
+
value: blockContextValue,
|
|
68
69
|
children: [CustomBlock, _jsx(BlockDrawer, {})]
|
|
69
70
|
}) : _jsx(CollapsibleWithErrorProps, {
|
|
70
71
|
children: _jsx(RenderFields, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockContent.js","names":["c","_c","useLexicalEditable","RenderFields","useFormSubmitted","React","createContext","useMemo","BlockComponentContext","baseClass","BlockCollapsible","BlockDrawer","
|
|
1
|
+
{"version":3,"file":"BlockContent.js","names":["c","_c","useLexicalEditable","RenderFields","useFormSubmitted","React","createContext","useMemo","BlockComponentContext","baseClass","BlockCollapsible","BlockDrawer","EditButton","errorCount","formSchema","initialState","nodeKey","RemoveButton","useBlockComponentContext","use","BlockContent","props","$","Collapsible","CustomBlock","CustomLabel","contextProps","hasSubmitted","fieldHasErrors","isEditable","t0","collapsibleProps","children","rest","_jsx","CollapsibleWithErrorProps","blockContextValue","_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 /**\n * Custom block component (pre-rendered ReactNode).\n */\n CustomBlock?: React.ReactNode\n CustomLabel: 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\nexport type BlockComponentContextType = {\n BlockCollapsible: React.FC<BlockCollapsibleProps>\n} & Omit<BlockContentProps, 'Collapsible' | 'CustomBlock' | 'CustomLabel'>\n\nconst BlockComponentContext = createContext<BlockComponentContextType>({\n baseClass: 'LexicalEditorTheme__block',\n BlockCollapsible: () => null,\n BlockDrawer: () => 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, CustomBlock, CustomLabel, ...contextProps } = props\n\n const { BlockDrawer, 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 () => (collapsibleProps: BlockCollapsibleProps) => {\n const { children, ...rest } = collapsibleProps\n return (\n <Collapsible errorCount={errorCount} fieldHasErrors={fieldHasErrors} {...rest}>\n {children}\n </Collapsible>\n )\n },\n [Collapsible, fieldHasErrors, errorCount],\n )\n\n const blockContextValue: BlockComponentContextType = {\n ...contextProps,\n BlockCollapsible: CollapsibleWithErrorProps,\n }\n\n // Provide context for useBlockComponentContext() hook\n return CustomBlock ? (\n <BlockComponentContext value={blockContextValue}>\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,EAAEC,gBAAgB,QAAQ;AAC/C,OAAOC,KAAA,IAASC,aAAa,EAAEC,OAAO,QAAQ;AAwE9C,MAAMC,qBAAA,gBAAwBF,aAAA,CAAyC;EACrEG,SAAA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;IAAA8B,KAAA,EAA8BF,iBAAA;IAAAJ,QAAA,GAC3BR,WAAA,EACDU,IAAA,CAACvB,WAAA;EAAA,C,IAGHuB,IAAA,CAACC,yBAAA;IAAAH,QAAA,EACCE,IAAA,CAAA/B,YAAA;MAAAoC,MAAA,EACUzB,UAAA;MAAA0B,WAAA;MAAAC,eAAA,EAEQ;MAAAC,UAAA,EACJ;MAAAC,gBAAA,EACK;MAAAC,WAAA;MAAAC,QAAA,GAENhB;IAAA,C;;CAInB","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { ViewMapBlockComponentProps } from '../../../../types.js';
|
|
2
3
|
import type { BlockFields } from '../../server/nodes/BlocksNode.js';
|
|
3
4
|
import './index.scss';
|
|
4
|
-
type
|
|
5
|
+
export type BlockComponentProps<TFormData extends Record<string, unknown> = BlockFields> = {
|
|
5
6
|
/**
|
|
6
7
|
* Can be modified by the node in order to trigger the re-fetch of the initial state based on the
|
|
7
8
|
* formData. This is useful when node.setFields() is explicitly called from outside of the form - in
|
|
@@ -9,9 +10,24 @@ type Props = {
|
|
|
9
10
|
*/
|
|
10
11
|
readonly cacheBuster: number;
|
|
11
12
|
readonly className: string;
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Custom block component from view map
|
|
15
|
+
* Will be rendered with useBlockComponentContext hook.
|
|
16
|
+
*/
|
|
17
|
+
readonly CustomBlock?: React.FC<ViewMapBlockComponentProps>;
|
|
18
|
+
/**
|
|
19
|
+
* Custom block label from view map
|
|
20
|
+
* Will be rendered with useBlockComponentContext hook.
|
|
21
|
+
*/
|
|
22
|
+
readonly CustomLabel?: React.FC<ViewMapBlockComponentProps>;
|
|
23
|
+
/**
|
|
24
|
+
* The block's form data (field values).
|
|
25
|
+
*/
|
|
26
|
+
readonly formData: TFormData;
|
|
27
|
+
/**
|
|
28
|
+
* The unique key identifying this block node in the current editor instance.
|
|
29
|
+
*/
|
|
13
30
|
readonly nodeKey: string;
|
|
14
31
|
};
|
|
15
|
-
export declare const BlockComponent: React.FC<
|
|
16
|
-
export {};
|
|
32
|
+
export declare const BlockComponent: React.FC<BlockComponentProps>;
|
|
17
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAEnE,OAAO,cAAc,CAAA;AAWrB,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,CAmpBxD,CAAA"}
|
|
@@ -13,12 +13,14 @@ import { v4 as uuid } from 'uuid';
|
|
|
13
13
|
import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
|
|
14
14
|
import { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
|
|
15
15
|
import { $isBlockNode } from '../nodes/BlocksNode.js';
|
|
16
|
-
import { BlockContent } from './BlockContent.js';
|
|
16
|
+
import { BlockContent, useBlockComponentContext } from './BlockContent.js';
|
|
17
17
|
import { removeEmptyArrayValues } from './removeEmptyArrayValues.js';
|
|
18
18
|
export const BlockComponent = props => {
|
|
19
19
|
const {
|
|
20
20
|
cacheBuster,
|
|
21
21
|
className: baseClass,
|
|
22
|
+
CustomBlock: CustomBlockFromProps,
|
|
23
|
+
CustomLabel: CustomLabelFromProps,
|
|
22
24
|
formData,
|
|
23
25
|
nodeKey
|
|
24
26
|
} = props;
|
|
@@ -101,12 +103,54 @@ export const BlockComponent = props => {
|
|
|
101
103
|
hasMounted.current = true;
|
|
102
104
|
}
|
|
103
105
|
}, [cacheBuster]);
|
|
104
|
-
const [
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
const [formUuid] = React.useState(() => uuid());
|
|
107
|
+
// Server-rendered custom components (from admin.components, NOT viewMap).
|
|
108
|
+
// When viewMap components exist (CustomBlockFromProps/CustomLabelFromProps),
|
|
109
|
+
// we render them directly with formData instead, so these states are unused.
|
|
110
|
+
const [CustomLabel, setCustomLabel] = React.useState(() => {
|
|
111
|
+
if (CustomLabelFromProps) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
115
|
+
return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined;
|
|
116
|
+
});
|
|
117
|
+
const [CustomBlock, setCustomBlock] = React.useState(() => {
|
|
118
|
+
if (CustomBlockFromProps) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
122
|
+
return initialState?.['_components']?.customComponents?.Block ?? undefined;
|
|
123
|
+
});
|
|
124
|
+
// When viewMap components exist, render directly with formData (always current from
|
|
125
|
+
// the lexical node). When they don't, fall back to server-rendered state.
|
|
126
|
+
const resolvedCustomBlock = useMemo(() => {
|
|
127
|
+
if (CustomBlockFromProps) {
|
|
128
|
+
return /*#__PURE__*/_jsx(CustomBlockFromProps, {
|
|
129
|
+
className: baseClass,
|
|
130
|
+
formData: formData,
|
|
131
|
+
isEditor: true,
|
|
132
|
+
isJSXConverter: false,
|
|
133
|
+
nodeKey: nodeKey,
|
|
134
|
+
// eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call
|
|
135
|
+
useBlockComponentContext: useBlockComponentContext
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return CustomBlock;
|
|
139
|
+
}, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock]);
|
|
140
|
+
const resolvedCustomLabel = useMemo(() => {
|
|
141
|
+
if (CustomLabelFromProps) {
|
|
142
|
+
return /*#__PURE__*/_jsx(CustomLabelFromProps, {
|
|
143
|
+
className: baseClass,
|
|
144
|
+
formData: formData,
|
|
145
|
+
isEditor: true,
|
|
146
|
+
isJSXConverter: false,
|
|
147
|
+
nodeKey: nodeKey,
|
|
148
|
+
// eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call
|
|
149
|
+
useBlockComponentContext: useBlockComponentContext
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return CustomLabel;
|
|
153
|
+
}, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel]);
|
|
110
154
|
// Initial state for newly created blocks
|
|
111
155
|
useEffect(() => {
|
|
112
156
|
const abortController = new AbortController();
|
|
@@ -157,8 +201,12 @@ export const BlockComponent = props => {
|
|
|
157
201
|
}
|
|
158
202
|
});
|
|
159
203
|
setInitialState(state);
|
|
160
|
-
|
|
161
|
-
|
|
204
|
+
if (!CustomLabelFromProps) {
|
|
205
|
+
setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined);
|
|
206
|
+
}
|
|
207
|
+
if (!CustomBlockFromProps) {
|
|
208
|
+
setCustomBlock(state._components?.customComponents?.Block ?? undefined);
|
|
209
|
+
}
|
|
162
210
|
}
|
|
163
211
|
};
|
|
164
212
|
if (formData && !initialState) {
|
|
@@ -167,7 +215,7 @@ export const BlockComponent = props => {
|
|
|
167
215
|
return () => {
|
|
168
216
|
abortAndIgnore(abortController);
|
|
169
217
|
};
|
|
170
|
-
}, [getFormState, schemaFieldsPath, isEditable, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType]);
|
|
218
|
+
}, [getFormState, schemaFieldsPath, isEditable, id, CustomLabelFromProps, CustomBlockFromProps, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType]);
|
|
171
219
|
const [isCollapsed, setIsCollapsed] = React.useState(initialLexicalFormState?.[formData.id]?.collapsed ?? false);
|
|
172
220
|
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
|
|
173
221
|
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
@@ -227,8 +275,12 @@ export const BlockComponent = props => {
|
|
|
227
275
|
});
|
|
228
276
|
}, 0);
|
|
229
277
|
if (submit) {
|
|
230
|
-
|
|
231
|
-
|
|
278
|
+
if (!CustomLabelFromProps) {
|
|
279
|
+
setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined);
|
|
280
|
+
}
|
|
281
|
+
if (!CustomBlockFromProps) {
|
|
282
|
+
setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined);
|
|
283
|
+
}
|
|
232
284
|
let rowErrorCount = 0;
|
|
233
285
|
for (const formField of Object.values(newFormState)) {
|
|
234
286
|
if (formField?.valid === false) {
|
|
@@ -238,7 +290,7 @@ export const BlockComponent = props => {
|
|
|
238
290
|
setErrorCount(rowErrorCount);
|
|
239
291
|
}
|
|
240
292
|
return newFormState;
|
|
241
|
-
}, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, blockType, parentDocumentFields, isEditable, editor, nodeKey]);
|
|
293
|
+
}, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, blockType, parentDocumentFields, isEditable, editor, nodeKey, CustomBlockFromProps, CustomLabelFromProps]);
|
|
242
294
|
useEffect(() => {
|
|
243
295
|
return () => {
|
|
244
296
|
abortAndIgnore(onChangeAbortControllerRef.current);
|
|
@@ -325,7 +377,7 @@ export const BlockComponent = props => {
|
|
|
325
377
|
collapsibleStyle: fieldHasErrors ? 'error' : 'default',
|
|
326
378
|
header: /*#__PURE__*/_jsxs("div", {
|
|
327
379
|
className: `${baseClass}__block-header`,
|
|
328
|
-
children: [typeof Label !== 'undefined' ? Label : typeof
|
|
380
|
+
children: [typeof Label !== 'undefined' ? Label : typeof resolvedCustomLabel !== 'undefined' ? resolvedCustomLabel : /*#__PURE__*/_jsxs("div", {
|
|
329
381
|
className: `${baseClass}__block-label`,
|
|
330
382
|
children: [typeof CustomPill !== 'undefined' ? CustomPill : /*#__PURE__*/_jsx(Pill, {
|
|
331
383
|
className: `${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`,
|
|
@@ -343,7 +395,7 @@ export const BlockComponent = props => {
|
|
|
343
395
|
}), /*#__PURE__*/_jsx("div", {
|
|
344
396
|
className: `${baseClass}__block-actions`,
|
|
345
397
|
children: typeof Actions !== 'undefined' ? Actions : /*#__PURE__*/_jsxs(_Fragment, {
|
|
346
|
-
children: [
|
|
398
|
+
children: [resolvedCustomBlock && editButton !== false || !resolvedCustomBlock && editButton ? /*#__PURE__*/_jsx(EditButton, {}) : null, removeButton !== false && isEditable ? /*#__PURE__*/_jsx(RemoveButton, {}) : null]
|
|
347
399
|
})
|
|
348
400
|
})]
|
|
349
401
|
}),
|
|
@@ -356,7 +408,7 @@ export const BlockComponent = props => {
|
|
|
356
408
|
children: children
|
|
357
409
|
}, 0)
|
|
358
410
|
});
|
|
359
|
-
}, [
|
|
411
|
+
}, [resolvedCustomBlock, resolvedCustomLabel, EditButton, RemoveButton, blockDisplayName, baseClass, clientBlock?.admin?.disableBlockName, blockType, i18n, isCollapsed, onCollapsedChange, isEditable]);
|
|
360
412
|
const blockID = formData?.id;
|
|
361
413
|
const BlockDrawer = useMemo(() => () => /*#__PURE__*/_jsx(EditDepthProvider, {
|
|
362
414
|
children: /*#__PURE__*/_jsx(Drawer, {
|
|
@@ -386,49 +438,54 @@ export const BlockComponent = props => {
|
|
|
386
438
|
if (!initialState) {
|
|
387
439
|
return null;
|
|
388
440
|
}
|
|
389
|
-
return /*#__PURE__*/_jsx(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
// This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
|
|
394
|
-
return await onChange({
|
|
395
|
-
formState,
|
|
396
|
-
submit: true
|
|
397
|
-
});
|
|
398
|
-
}],
|
|
399
|
-
el: "div",
|
|
400
|
-
fields: clientBlock?.fields ?? [],
|
|
401
|
-
initialState: initialState,
|
|
402
|
-
onChange: [onChange],
|
|
403
|
-
onSubmit: (formState_0, newData_1) => {
|
|
404
|
-
// This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
|
|
405
|
-
newData_1.blockType = blockType;
|
|
406
|
-
editor.update(() => {
|
|
407
|
-
const node_1 = $getNodeByKey(nodeKey);
|
|
408
|
-
if (node_1 && $isBlockNode(node_1)) {
|
|
409
|
-
node_1.setFields(newData_1, true);
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
toggleDrawer();
|
|
441
|
+
return /*#__PURE__*/_jsx("div", {
|
|
442
|
+
"data-block-drawer-slug": drawerSlug,
|
|
443
|
+
style: {
|
|
444
|
+
display: 'contents'
|
|
413
445
|
},
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
446
|
+
children: /*#__PURE__*/_jsx(Form, {
|
|
447
|
+
beforeSubmit: [async ({
|
|
448
|
+
formState
|
|
449
|
+
}) => {
|
|
450
|
+
// This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
|
|
451
|
+
return await onChange({
|
|
452
|
+
formState,
|
|
453
|
+
submit: true
|
|
454
|
+
});
|
|
455
|
+
}],
|
|
456
|
+
el: "div",
|
|
457
|
+
fields: clientBlock?.fields ?? [],
|
|
424
458
|
initialState: initialState,
|
|
425
|
-
|
|
426
|
-
|
|
459
|
+
onChange: [onChange],
|
|
460
|
+
onSubmit: (formState_0, newData_1) => {
|
|
461
|
+
// This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
|
|
462
|
+
newData_1.blockType = blockType;
|
|
463
|
+
editor.update(() => {
|
|
464
|
+
const node_1 = $getNodeByKey(nodeKey);
|
|
465
|
+
if (node_1 && $isBlockNode(node_1)) {
|
|
466
|
+
node_1.setFields(newData_1, true);
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
toggleDrawer();
|
|
470
|
+
},
|
|
471
|
+
submitted: submitted,
|
|
472
|
+
uuid: formUuid,
|
|
473
|
+
children: /*#__PURE__*/_jsx(BlockContent, {
|
|
474
|
+
baseClass: baseClass,
|
|
475
|
+
BlockDrawer: BlockDrawer,
|
|
476
|
+
Collapsible: BlockCollapsible,
|
|
477
|
+
CustomBlock: resolvedCustomBlock,
|
|
478
|
+
CustomLabel: resolvedCustomLabel,
|
|
479
|
+
EditButton: EditButton,
|
|
480
|
+
errorCount: errorCount,
|
|
481
|
+
formSchema: clientBlock?.fields ?? [],
|
|
482
|
+
initialState: initialState,
|
|
483
|
+
nodeKey: nodeKey,
|
|
484
|
+
RemoveButton: RemoveButton
|
|
485
|
+
})
|
|
427
486
|
})
|
|
428
487
|
});
|
|
429
|
-
}, [BlockCollapsible, BlockDrawer,
|
|
430
|
-
// DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.
|
|
431
|
-
initialState, nodeKey, onChange, submitted]);
|
|
488
|
+
}, [BlockCollapsible, BlockDrawer, resolvedCustomBlock, resolvedCustomLabel, blockType, drawerSlug, RemoveButton, EditButton, baseClass, editor, errorCount, toggleDrawer, clientBlock?.fields, formUuid, initialState, nodeKey, onChange, submitted]);
|
|
432
489
|
if (!clientBlock) {
|
|
433
490
|
return /*#__PURE__*/_jsx(BlockCollapsible, {
|
|
434
491
|
disableBlockName: true,
|