@payloadcms/richtext-lexical 3.80.0-internal.60d6f94 → 3.80.0-internal.82dcece
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-OIMYWB22.js +2 -0
- package/dist/exports/client/Field-OIMYWB22.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-2S5Q7QYO.js +2 -0
- package/dist/exports/client/chunk-2S5Q7QYO.js.map +7 -0
- package/dist/exports/client/chunk-EZX4YW7S.js +12 -0
- package/dist/exports/client/chunk-EZX4YW7S.js.map +7 -0
- package/dist/exports/client/componentInline-NL25DNZ5.js +2 -0
- package/dist/exports/client/index.d.ts +0 -1
- 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/react/index.d.ts +1 -3
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js +0 -1
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.d.ts +4 -7
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +8 -9
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +4 -20
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +55 -112
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +14 -8
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +18 -67
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +2 -4
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +1 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +2 -4
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +1 -3
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/heading.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/heading.js +3 -1
- package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/link.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/link.js +7 -2
- package/dist/features/converters/lexicalToHtml/async/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/list.js +5 -1
- package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/table.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/table.js +2 -1
- package/dist/features/converters/lexicalToHtml/async/converters/table.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/text.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/text.js +2 -1
- package/dist/features/converters/lexicalToHtml/async/converters/text.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/upload.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js +11 -10
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/shared/cssColors.d.ts +5 -0
- package/dist/features/converters/lexicalToHtml/shared/cssColors.d.ts.map +1 -0
- package/dist/features/converters/lexicalToHtml/shared/cssColors.js +8 -0
- package/dist/features/converters/lexicalToHtml/shared/cssColors.js.map +1 -0
- package/dist/features/converters/lexicalToHtml/sync/converters/heading.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +3 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/link.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/link.js +7 -2
- package/dist/features/converters/lexicalToHtml/sync/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/list.js +5 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/table.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/table.js +2 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/table.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/text.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/text.js +2 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/text.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +11 -10
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +20 -6
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +5 -7
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +2 -17
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +4 -124
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +10 -14
- 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/Diff/converters/link.d.ts.map +1 -1
- package/dist/field/Diff/converters/link.js +7 -2
- package/dist/field/Diff/converters/link.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +19 -19
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts +0 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +35 -64
- 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 +0 -12
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +9 -7
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts +1 -0
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +6 -13
- 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 +2 -3
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +0 -4
- 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 +2 -12
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +2 -213
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +1 -14
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/types.d.ts +2 -329
- 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 +0 -1
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +1 -6
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +4 -10
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +6 -11
- package/dist/exports/client/Field-ESDONIMD.js +0 -2
- package/dist/exports/client/Field-ESDONIMD.js.map +0 -7
- package/dist/exports/client/chunk-VCJQ5B3S.js +0 -12
- package/dist/exports/client/chunk-VCJQ5B3S.js.map +0 -7
- package/dist/exports/client/chunk-YWIZCGSY.js +0 -2
- package/dist/exports/client/chunk-YWIZCGSY.js.map +0 -7
- package/dist/exports/client/componentInline-CBBUBQ7P.js +0 -2
- package/dist/exports/client/internal-client.d.ts +0 -3
- package/dist/exports/client/internal-client.d.ts.map +0 -1
- package/dist/field/RichTextViewProvider.d.ts +0 -86
- package/dist/field/RichTextViewProvider.d.ts.map +0 -1
- package/dist/field/RichTextViewProvider.js +0 -90
- package/dist/field/RichTextViewProvider.js.map +0 -1
- package/dist/field/ViewSelector.d.ts +0 -4
- package/dist/field/ViewSelector.d.ts.map +0 -1
- package/dist/field/ViewSelector.js +0 -89
- package/dist/field/ViewSelector.js.map +0 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +0 -2
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +0 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +0 -48
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +0 -1
- /package/dist/exports/client/{componentInline-CBBUBQ7P.js.map → componentInline-NL25DNZ5.js.map} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type { BlockComponentContextType } from '../../features/blocks/client/component/BlockContent.js';
|
|
2
1
|
export { type JSXConvertersFunction, RichText, } from '../../features/converters/lexicalToJSX/Component/index.js';
|
|
3
2
|
export { BlockquoteJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/blockquote.js';
|
|
4
3
|
export { HeadingJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/heading.js';
|
|
@@ -13,6 +12,5 @@ export { TextJSXConverter } from '../../features/converters/lexicalToJSX/convert
|
|
|
13
12
|
export { UploadJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/upload.js';
|
|
14
13
|
export { defaultJSXConverters } from '../../features/converters/lexicalToJSX/converter/defaultConverters.js';
|
|
15
14
|
export { convertLexicalNodesToJSX } from '../../features/converters/lexicalToJSX/converter/index.js';
|
|
16
|
-
export type { JSXConverter,
|
|
17
|
-
export type { ViewMapBlockComponentProps, ViewMapBlockEditorProps, ViewMapBlockJSXConverterProps, } from '../../types.js';
|
|
15
|
+
export type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent, } from '../../features/converters/lexicalToJSX/converter/types.js';
|
|
18
16
|
//# 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":"AAAA,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;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sEAAsE,CAAA;AAExG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAA;AAEtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uEAAuE,CAAA;AAC1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAA;AAC5G,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAA;AACpG,YAAY,EACV,YAAY,EACZ,aAAa,EACb,+BAA+B,GAChC,MAAM,2DAA2D,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// Export block context type for typing custom Block components
|
|
2
1
|
export { RichText } from '../../features/converters/lexicalToJSX/Component/index.js';
|
|
3
2
|
export { BlockquoteJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/blockquote.js';
|
|
4
3
|
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 {\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'\nexport { TableJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/table.js'\n\nexport { TextJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/text.js'\n\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'\nexport type {\n JSXConverter,\n JSXConverters,\n SerializedLexicalNodeWithParent,\n} from '../../features/converters/lexicalToJSX/converter/types.js'\n"],"mappings":"AAAA,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;AAChC,SAASC,iBAAiB,QAAQ;AAElC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,wBAAwB,QAAQ","ignoreList":[]}
|
|
@@ -51,11 +51,7 @@ export type BlockContentProps = {
|
|
|
51
51
|
baseClass: string;
|
|
52
52
|
BlockDrawer: React.FC;
|
|
53
53
|
Collapsible: React.FC<BlockCollapsibleWithErrorProps>;
|
|
54
|
-
|
|
55
|
-
* Custom block component (pre-rendered ReactNode).
|
|
56
|
-
*/
|
|
57
|
-
CustomBlock?: React.ReactNode;
|
|
58
|
-
CustomLabel: React.ReactNode;
|
|
54
|
+
CustomBlock: React.ReactNode;
|
|
59
55
|
EditButton: React.FC;
|
|
60
56
|
errorCount: number;
|
|
61
57
|
formSchema: ClientField[];
|
|
@@ -63,9 +59,9 @@ export type BlockContentProps = {
|
|
|
63
59
|
nodeKey: string;
|
|
64
60
|
RemoveButton: React.FC;
|
|
65
61
|
};
|
|
66
|
-
|
|
62
|
+
type BlockComponentContextType = {
|
|
67
63
|
BlockCollapsible: React.FC<BlockCollapsibleProps>;
|
|
68
|
-
} & Omit<BlockContentProps, 'Collapsible'
|
|
64
|
+
} & Omit<BlockContentProps, 'Collapsible'>;
|
|
69
65
|
export declare const useBlockComponentContext: () => BlockComponentContextType;
|
|
70
66
|
/**
|
|
71
67
|
* The actual content of the Block. This should be INSIDE a Form component,
|
|
@@ -73,4 +69,5 @@ export declare const useBlockComponentContext: () => BlockComponentContextType;
|
|
|
73
69
|
* not the whole document.
|
|
74
70
|
*/
|
|
75
71
|
export declare const BlockContent: React.FC<BlockContentProps>;
|
|
72
|
+
export {};
|
|
76
73
|
//# 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
|
|
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"}
|
|
@@ -9,6 +9,7 @@ const BlockComponentContext = /*#__PURE__*/createContext({
|
|
|
9
9
|
baseClass: 'LexicalEditorTheme__block',
|
|
10
10
|
BlockCollapsible: () => null,
|
|
11
11
|
BlockDrawer: () => null,
|
|
12
|
+
CustomBlock: null,
|
|
12
13
|
EditButton: () => null,
|
|
13
14
|
errorCount: 0,
|
|
14
15
|
formSchema: [],
|
|
@@ -26,12 +27,11 @@ export const BlockContent = props => {
|
|
|
26
27
|
const $ = _c(4);
|
|
27
28
|
const {
|
|
28
29
|
Collapsible,
|
|
29
|
-
CustomBlock,
|
|
30
|
-
CustomLabel,
|
|
31
30
|
...contextProps
|
|
32
31
|
} = props;
|
|
33
32
|
const {
|
|
34
33
|
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 = props_0 => {
|
|
44
44
|
const {
|
|
45
45
|
children,
|
|
46
46
|
...rest
|
|
47
|
-
} =
|
|
47
|
+
} = props_0;
|
|
48
48
|
return _jsx(Collapsible, {
|
|
49
49
|
errorCount,
|
|
50
50
|
fieldHasErrors,
|
|
@@ -60,12 +60,11 @@ export const BlockContent = props => {
|
|
|
60
60
|
t0 = $[3];
|
|
61
61
|
}
|
|
62
62
|
const CollapsibleWithErrorProps = t0;
|
|
63
|
-
const blockContextValue = {
|
|
64
|
-
...contextProps,
|
|
65
|
-
BlockCollapsible: CollapsibleWithErrorProps
|
|
66
|
-
};
|
|
67
63
|
return CustomBlock ? _jsxs(BlockComponentContext, {
|
|
68
|
-
value:
|
|
64
|
+
value: {
|
|
65
|
+
...contextProps,
|
|
66
|
+
BlockCollapsible: CollapsibleWithErrorProps
|
|
67
|
+
},
|
|
69
68
|
children: [CustomBlock, _jsx(BlockDrawer, {})]
|
|
70
69
|
}) : _jsx(CollapsibleWithErrorProps, {
|
|
71
70
|
children: _jsx(RenderFields, {
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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: 'LexicalEditorTheme__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,EAAEC,gBAAgB,QAAQ;AAC/C,OAAOC,KAAA,IAASC,aAAa,EAAEC,OAAO,QAAQ;AAoE9C,MAAMC,qBAAA,gBAAwBF,aAAA,CAAyC;EACrEG,SAAA,EAAW;EACXC,gBAAA,EAAkBA,CAAA,KAAM;EACxBC,WAAA,EAAaA,CAAA,KAAM;EACnBC,WAAA,EAAa;EACbC,UAAA,EAAYA,CAAA,KAAM;EAClBC,UAAA,EAAY;EACZC,UAAA,EAAY,EAAE;EACdC,YAAA,EAAc;EACdC,OAAA,EAAS;EACTC,YAAA,EAAcA,CAAA,KAAM;AACtB;AAEA,OAAO,MAAMC,wBAAA,GAA2BA,CAAA,KAAMd,KAAA,CAAMe,GAAG,CAACZ,qBAAA;AAExD;;;;;AAKA,OAAO,MAAMa,YAAA,GAA4CC,KAAA;EAAA,MAAAC,CAAA,GAAAtB,EAAA;EACvD;IAAAuB,WAAA;IAAA,GAAAC;EAAA,IAAyCH,KAAA;EAEzC;IAAAX,WAAA;IAAAC,WAAA;IAAAE,UAAA;IAAAC;EAAA,IAA6DU,YAAA;EAE7D,MAAAC,YAAA,GAAqBtB,gBAAA;EAErB,MAAAuB,cAAA,GAAuBD,YAAA,IAAgBZ,UAAA,IAAa;EACpD,MAAAc,UAAA,GAAmB1B,kBAAA;EAAA,IAAA2B,EAAA;EAAA,IAAAN,CAAA,QAAAC,WAAA,IAAAD,CAAA,QAAAT,UAAA,IAAAS,CAAA,QAAAI,cAAA;IAGXE,EAAA,GAAAC,OAAA;MACJ;QAAAC,QAAA;QAAA,GAAAC;MAAA,IAA8BV,OAAA;MAAA,OAE5BW,IAAA,CAACT,WAAA;QAAAV,UAAA;QAAAa,cAAA;QAAA,GAAwEK,IAAI;QAAAD;MAAA,C;;IAIjFR,CAAA,MAAAC,WAAA;IAAAD,CAAA,MAAAT,UAAA;IAAAS,CAAA,MAAAI,cAAA;IAAAJ,CAAA,MAAAM,EAAA;EAAA;IAAAA,EAAA,GAAAN,CAAA;EAAA;EARF,MAAAW,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,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ViewMapBlockComponentProps } from '../../../../types.js';
|
|
3
2
|
import type { BlockFields } from '../../server/nodes/BlocksNode.js';
|
|
4
3
|
import './index.scss';
|
|
5
|
-
|
|
4
|
+
type Props = {
|
|
6
5
|
/**
|
|
7
6
|
* Can be modified by the node in order to trigger the re-fetch of the initial state based on the
|
|
8
7
|
* formData. This is useful when node.setFields() is explicitly called from outside of the form - in
|
|
@@ -10,24 +9,9 @@ export type BlockComponentProps<TFormData extends Record<string, unknown> = Bloc
|
|
|
10
9
|
*/
|
|
11
10
|
readonly cacheBuster: number;
|
|
12
11
|
readonly className: string;
|
|
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
|
-
*/
|
|
12
|
+
readonly formData: BlockFields;
|
|
30
13
|
readonly nodeKey: string;
|
|
31
14
|
};
|
|
32
|
-
export declare const BlockComponent: React.FC<
|
|
15
|
+
export declare const BlockComponent: React.FC<Props>;
|
|
16
|
+
export {};
|
|
33
17
|
//# 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,
|
|
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;AAGnE,OAAO,cAAc,CAAA;AAMrB,KAAK,KAAK,GAAG;IACX;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,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,CA0kB1C,CAAA"}
|
|
@@ -13,14 +13,12 @@ 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
|
|
16
|
+
import { BlockContent } 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,
|
|
24
22
|
formData,
|
|
25
23
|
nodeKey
|
|
26
24
|
} = props;
|
|
@@ -103,54 +101,12 @@ export const BlockComponent = props => {
|
|
|
103
101
|
hasMounted.current = true;
|
|
104
102
|
}
|
|
105
103
|
}, [cacheBuster]);
|
|
106
|
-
const [
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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]);
|
|
104
|
+
const [CustomLabel, setCustomLabel] = React.useState(
|
|
105
|
+
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
106
|
+
initialState?.['_components']?.customComponents?.BlockLabel ?? undefined);
|
|
107
|
+
const [CustomBlock, setCustomBlock] = React.useState(
|
|
108
|
+
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
109
|
+
initialState?.['_components']?.customComponents?.Block ?? undefined);
|
|
154
110
|
// Initial state for newly created blocks
|
|
155
111
|
useEffect(() => {
|
|
156
112
|
const abortController = new AbortController();
|
|
@@ -201,12 +157,8 @@ export const BlockComponent = props => {
|
|
|
201
157
|
}
|
|
202
158
|
});
|
|
203
159
|
setInitialState(state);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
if (!CustomBlockFromProps) {
|
|
208
|
-
setCustomBlock(state._components?.customComponents?.Block ?? undefined);
|
|
209
|
-
}
|
|
160
|
+
setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined);
|
|
161
|
+
setCustomBlock(state._components?.customComponents?.Block ?? undefined);
|
|
210
162
|
}
|
|
211
163
|
};
|
|
212
164
|
if (formData && !initialState) {
|
|
@@ -215,7 +167,7 @@ export const BlockComponent = props => {
|
|
|
215
167
|
return () => {
|
|
216
168
|
abortAndIgnore(abortController);
|
|
217
169
|
};
|
|
218
|
-
}, [getFormState, schemaFieldsPath, isEditable, id,
|
|
170
|
+
}, [getFormState, schemaFieldsPath, isEditable, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType]);
|
|
219
171
|
const [isCollapsed, setIsCollapsed] = React.useState(initialLexicalFormState?.[formData.id]?.collapsed ?? false);
|
|
220
172
|
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
|
|
221
173
|
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
@@ -275,12 +227,8 @@ export const BlockComponent = props => {
|
|
|
275
227
|
});
|
|
276
228
|
}, 0);
|
|
277
229
|
if (submit) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
if (!CustomBlockFromProps) {
|
|
282
|
-
setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined);
|
|
283
|
-
}
|
|
230
|
+
setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined);
|
|
231
|
+
setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined);
|
|
284
232
|
let rowErrorCount = 0;
|
|
285
233
|
for (const formField of Object.values(newFormState)) {
|
|
286
234
|
if (formField?.valid === false) {
|
|
@@ -290,7 +238,7 @@ export const BlockComponent = props => {
|
|
|
290
238
|
setErrorCount(rowErrorCount);
|
|
291
239
|
}
|
|
292
240
|
return newFormState;
|
|
293
|
-
}, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, blockType, parentDocumentFields, isEditable, editor, nodeKey
|
|
241
|
+
}, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, blockType, parentDocumentFields, isEditable, editor, nodeKey]);
|
|
294
242
|
useEffect(() => {
|
|
295
243
|
return () => {
|
|
296
244
|
abortAndIgnore(onChangeAbortControllerRef.current);
|
|
@@ -377,7 +325,7 @@ export const BlockComponent = props => {
|
|
|
377
325
|
collapsibleStyle: fieldHasErrors ? 'error' : 'default',
|
|
378
326
|
header: /*#__PURE__*/_jsxs("div", {
|
|
379
327
|
className: `${baseClass}__block-header`,
|
|
380
|
-
children: [typeof Label !== 'undefined' ? Label : typeof
|
|
328
|
+
children: [typeof Label !== 'undefined' ? Label : typeof CustomLabel !== 'undefined' ? CustomLabel : /*#__PURE__*/_jsxs("div", {
|
|
381
329
|
className: `${baseClass}__block-label`,
|
|
382
330
|
children: [typeof CustomPill !== 'undefined' ? CustomPill : /*#__PURE__*/_jsx(Pill, {
|
|
383
331
|
className: `${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`,
|
|
@@ -395,7 +343,7 @@ export const BlockComponent = props => {
|
|
|
395
343
|
}), /*#__PURE__*/_jsx("div", {
|
|
396
344
|
className: `${baseClass}__block-actions`,
|
|
397
345
|
children: typeof Actions !== 'undefined' ? Actions : /*#__PURE__*/_jsxs(_Fragment, {
|
|
398
|
-
children: [
|
|
346
|
+
children: [CustomBlock && editButton !== false || !CustomBlock && editButton ? /*#__PURE__*/_jsx(EditButton, {}) : null, removeButton !== false && isEditable ? /*#__PURE__*/_jsx(RemoveButton, {}) : null]
|
|
399
347
|
})
|
|
400
348
|
})]
|
|
401
349
|
}),
|
|
@@ -408,7 +356,7 @@ export const BlockComponent = props => {
|
|
|
408
356
|
children: children
|
|
409
357
|
}, 0)
|
|
410
358
|
});
|
|
411
|
-
}, [
|
|
359
|
+
}, [CustomBlock, CustomLabel, EditButton, RemoveButton, blockDisplayName, baseClass, clientBlock?.admin?.disableBlockName, blockType, i18n, isCollapsed, onCollapsedChange, isEditable]);
|
|
412
360
|
const blockID = formData?.id;
|
|
413
361
|
const BlockDrawer = useMemo(() => () => /*#__PURE__*/_jsx(EditDepthProvider, {
|
|
414
362
|
children: /*#__PURE__*/_jsx(Drawer, {
|
|
@@ -438,54 +386,49 @@ export const BlockComponent = props => {
|
|
|
438
386
|
if (!initialState) {
|
|
439
387
|
return null;
|
|
440
388
|
}
|
|
441
|
-
return /*#__PURE__*/_jsx(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
389
|
+
return /*#__PURE__*/_jsx(Form, {
|
|
390
|
+
beforeSubmit: [async ({
|
|
391
|
+
formState
|
|
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();
|
|
445
413
|
},
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
el: "div",
|
|
457
|
-
fields: clientBlock?.fields ?? [],
|
|
414
|
+
submitted: submitted,
|
|
415
|
+
uuid: uuid(),
|
|
416
|
+
children: /*#__PURE__*/_jsx(BlockContent, {
|
|
417
|
+
baseClass: baseClass,
|
|
418
|
+
BlockDrawer: BlockDrawer,
|
|
419
|
+
Collapsible: BlockCollapsible,
|
|
420
|
+
CustomBlock: CustomBlock,
|
|
421
|
+
EditButton: EditButton,
|
|
422
|
+
errorCount: errorCount,
|
|
423
|
+
formSchema: clientBlock?.fields ?? [],
|
|
458
424
|
initialState: initialState,
|
|
459
|
-
|
|
460
|
-
|
|
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
|
-
})
|
|
425
|
+
nodeKey: nodeKey,
|
|
426
|
+
RemoveButton: RemoveButton
|
|
486
427
|
})
|
|
487
428
|
});
|
|
488
|
-
}, [BlockCollapsible, BlockDrawer,
|
|
429
|
+
}, [BlockCollapsible, BlockDrawer, CustomBlock, blockType, RemoveButton, EditButton, baseClass, editor, errorCount, toggleDrawer, clientBlock?.fields,
|
|
430
|
+
// DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.
|
|
431
|
+
initialState, nodeKey, onChange, submitted]);
|
|
489
432
|
if (!clientBlock) {
|
|
490
433
|
return /*#__PURE__*/_jsx(BlockCollapsible, {
|
|
491
434
|
disableBlockName: true,
|