@payloadcms/richtext-lexical 3.59.0-internal.d8b427e → 3.59.0-internal.ee5f42c
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-2MCIQXRP.js → Field-EHRBYNHO.js} +2 -2
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-TLQLXR6Q.js → chunk-2Y72RT72.js} +2 -2
- package/dist/exports/client/chunk-3BY5IZJD.js +2 -0
- package/dist/exports/client/chunk-3BY5IZJD.js.map +7 -0
- package/dist/exports/client/componentInline-7TPI7ZBC.js +2 -0
- package/dist/exports/client/index.d.ts +0 -3
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -35
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/client/component/BlockContent.d.ts +27 -52
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +51 -45
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +9 -2
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +25 -7
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +50 -62
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +1 -0
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +0 -5
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdownTransformer.d.ts +17 -0
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/client/markdownTransformer.js +144 -0
- package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/server/i18n.js +38 -38
- package/dist/features/blocks/server/i18n.js.map +1 -1
- package/dist/features/blocks/server/index.js +1 -1
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/server/{markdown/markdownTransformer.js → markdownTransformer.js} +48 -6
- package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
- package/dist/field/RenderLexical/index.d.ts.map +1 -1
- package/dist/field/RenderLexical/index.js +1 -0
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +15 -10
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/chunk-K47TNP5J.js +0 -2
- package/dist/exports/client/chunk-K47TNP5J.js.map +0 -7
- package/dist/exports/client/componentInline-AGFSKAY4.js +0 -2
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +0 -6
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +0 -24
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +0 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +0 -6
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +0 -20
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +0 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +0 -12
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.js +0 -348
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +0 -5
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +0 -151
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +0 -61
- package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +0 -89
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +0 -4
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +0 -17
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +0 -4
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +0 -26
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts +0 -7
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converter.js +0 -46
- package/dist/features/blocks/premade/CodeBlock/converter.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +0 -2
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converterClient.js +0 -4
- package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/index.d.ts +0 -7
- package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/index.js +0 -52
- package/dist/features/blocks/premade/CodeBlock/index.js.map +0 -1
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +0 -6
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +0 -27
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +0 -1
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +0 -7
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +0 -22
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +0 -1
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +0 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +0 -15
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +0 -1
- package/dist/lexical/ui/icons/Collapse/index.d.ts +0 -3
- package/dist/lexical/ui/icons/Collapse/index.d.ts.map +0 -1
- package/dist/lexical/ui/icons/Collapse/index.js +0 -18
- package/dist/lexical/ui/icons/Collapse/index.js.map +0 -1
- /package/dist/exports/client/{Field-2MCIQXRP.js.map → Field-EHRBYNHO.js.map} +0 -0
- /package/dist/exports/client/{chunk-TLQLXR6Q.js.map → chunk-2Y72RT72.js.map} +0 -0
- /package/dist/exports/client/{componentInline-AGFSKAY4.js.map → componentInline-7TPI7ZBC.js.map} +0 -0
- /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.d.ts → linesFromMatchToContentAndPropsString.d.ts} +0 -0
- /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
|
-
|
|
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<
|
|
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
|
|
64
|
-
|
|
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<
|
|
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,
|
|
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,CAAC,SAAS,CAAA;QAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB;;WAEG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;QACvB,YAAY,CAAC,EAAE,OAAO,CAAA;KACvB,CAAC,CAAA;IACF,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,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;QAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB;;WAEG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;QACvB,YAAY,CAAC,EAAE,OAAO,CAAA;KACvB,CAAC,CAAA;IACF,UAAU,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACrB,YAAY,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAA;IAE3C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;CACxB,CAAA;AAMD,eAAO,MAAM,wBAAwB,iCAAyC,CAAA;AAE9E;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAmExC,CAAA"}
|
|
@@ -5,16 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import { RenderFields, useFormSubmitted } from '@payloadcms/ui';
|
|
6
6
|
import React, { createContext, useMemo } from 'react';
|
|
7
7
|
const BlockComponentContext = /*#__PURE__*/createContext({
|
|
8
|
-
|
|
9
|
-
BlockCollapsible: () => null,
|
|
10
|
-
BlockDrawer: () => null,
|
|
11
|
-
CustomBlock: null,
|
|
12
|
-
EditButton: () => null,
|
|
13
|
-
errorCount: 0,
|
|
14
|
-
formSchema: [],
|
|
15
|
-
initialState: false,
|
|
16
|
-
nodeKey: '',
|
|
17
|
-
RemoveButton: () => null
|
|
8
|
+
initialState: false
|
|
18
9
|
});
|
|
19
10
|
export const useBlockComponentContext = () => React.use(BlockComponentContext);
|
|
20
11
|
/**
|
|
@@ -23,33 +14,30 @@ export const useBlockComponentContext = () => React.use(BlockComponentContext);
|
|
|
23
14
|
* not the whole document.
|
|
24
15
|
*/
|
|
25
16
|
export const BlockContent = props => {
|
|
26
|
-
const $ = _c(
|
|
27
|
-
const {
|
|
28
|
-
Collapsible,
|
|
29
|
-
...contextProps
|
|
30
|
-
} = props;
|
|
17
|
+
const $ = _c(13);
|
|
31
18
|
const {
|
|
32
19
|
BlockDrawer,
|
|
20
|
+
Collapsible,
|
|
33
21
|
CustomBlock,
|
|
22
|
+
EditButton,
|
|
34
23
|
errorCount,
|
|
35
|
-
formSchema
|
|
36
|
-
|
|
24
|
+
formSchema,
|
|
25
|
+
initialState,
|
|
26
|
+
nodeKey,
|
|
27
|
+
RemoveButton
|
|
28
|
+
} = props;
|
|
37
29
|
const hasSubmitted = useFormSubmitted();
|
|
38
30
|
const fieldHasErrors = hasSubmitted && errorCount > 0;
|
|
39
31
|
let t0;
|
|
40
32
|
if ($[0] !== Collapsible || $[1] !== errorCount || $[2] !== fieldHasErrors) {
|
|
41
|
-
t0 = props_0 => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
...rest,
|
|
50
|
-
children
|
|
51
|
-
});
|
|
52
|
-
};
|
|
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
|
+
});
|
|
53
41
|
$[0] = Collapsible;
|
|
54
42
|
$[1] = errorCount;
|
|
55
43
|
$[2] = fieldHasErrors;
|
|
@@ -58,21 +46,39 @@ export const BlockContent = props => {
|
|
|
58
46
|
t0 = $[3];
|
|
59
47
|
}
|
|
60
48
|
const CollapsibleWithErrorProps = t0;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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;
|
|
77
83
|
};
|
|
78
84
|
//# sourceMappingURL=BlockContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockContent.js","names":["c","_c","RenderFields","useFormSubmitted","React","createContext","useMemo","BlockComponentContext","
|
|
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,gBAAwBF,aAAA,CAAyC;EACrEG,YAAA,EAAc;AAChB;AAEA,OAAO,MAAMC,wBAAA,GAA2BA,CAAA,KAAML,KAAA,CAAMM,GAAG,CAACH,qBAAA;AAExD;;;;;AAKA,OAAO,MAAMI,YAAA,GAAgCC,KAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EAC3C;IAAAa,WAAA;IAAAC,WAAA;IAAAC,WAAA;IAAAC,UAAA;IAAAC,UAAA;IAAAC,UAAA;IAAAX,YAAA;IAAAY,OAAA;IAAAC;EAAA,IAUIT,KAAA;EAEJ,MAAAU,YAAA,GAAqBnB,gBAAA;EAErB,MAAAoB,cAAA,GAAuBD,YAAA,IAAgBJ,UAAA,IAAa;EAAA,IAAAM,EAAA;EAAA,IAAAX,CAAA,QAAAE,WAAA,IAAAF,CAAA,QAAAK,UAAA,IAAAL,CAAA,QAAAU,cAAA;IAIhDC,EAAA,GAAAC,OAAA,IAUEC,IAAA,CAACX,WAAA;MAAAY,UAAA,EACaf,OAAA,CAAAe,UAAA;MAAAT,UAAA;MAAAK,cAAA;MAAAK,KAAA,EAGLhB,OAAA,CAAAgB,KAAA;MAAAC,YAAA,EACOjB,OAAA,CAAAiB,YAAA;MAAAC,QAAA,EAEblB,OAAA,CAAAkB;IAAA,C;;;;;;;;EAnBT,MAAAC,yBAAA,GAEIP,E;EAoBuC,IAAAQ,EAAA;EAAA,IAAAnB,CAAA,QAAAC,WAAA,IAAAD,CAAA,QAAAkB,yBAAA,IAAAlB,CAAA,QAAAG,WAAA,IAAAH,CAAA,QAAAI,UAAA,IAAAJ,CAAA,QAAAQ,YAAA,IAAAR,CAAA,QAAAM,UAAA,IAAAN,CAAA,SAAAL,YAAA,IAAAK,CAAA,SAAAO,OAAA;IAGpCY,EAAA,GAAAhB,WAAA,GACLiB,KAAA,CAAA1B,qBAAA;MAAA2B,KAAA;QAAAC,gBAAA,EAEsBJ,yBAAA;QAAAd,UAAA;QAAAT,YAAA;QAAAY,OAAA;QAAAC;MAAA;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
|
-
|
|
3
|
-
|
|
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;
|
|
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 =
|
|
7
|
+
export const BlockCollapsible = t0 => {
|
|
8
|
+
const $ = _c(6);
|
|
7
9
|
const {
|
|
8
10
|
children,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
editButton,
|
|
12
|
+
Label,
|
|
13
|
+
removeButton
|
|
14
|
+
} = t0;
|
|
11
15
|
const {
|
|
12
16
|
BlockCollapsible
|
|
13
17
|
} = useBlockComponentContext();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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","
|
|
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;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,
|
|
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"}
|
|
@@ -32,6 +32,7 @@ export const BlockComponent = props => {
|
|
|
32
32
|
featureClientSchemaMap,
|
|
33
33
|
field: parentLexicalRichTextField,
|
|
34
34
|
initialLexicalFormState,
|
|
35
|
+
permissions,
|
|
35
36
|
readOnly,
|
|
36
37
|
schemaPath
|
|
37
38
|
},
|
|
@@ -61,11 +62,10 @@ export const BlockComponent = props => {
|
|
|
61
62
|
setDocFieldPreferences
|
|
62
63
|
} = useDocumentInfo();
|
|
63
64
|
const [editor] = useLexicalComposerContext();
|
|
64
|
-
const blockType = formData.blockType;
|
|
65
65
|
const {
|
|
66
66
|
getFormState
|
|
67
67
|
} = useServerFunctions();
|
|
68
|
-
const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`;
|
|
68
|
+
const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`;
|
|
69
69
|
const [initialState, setInitialState] = React.useState(() => {
|
|
70
70
|
return initialLexicalFormState?.[formData.id]?.formState ? {
|
|
71
71
|
...initialLexicalFormState?.[formData.id]?.formState,
|
|
@@ -91,10 +91,10 @@ export const BlockComponent = props => {
|
|
|
91
91
|
}, [cacheBuster]);
|
|
92
92
|
const [CustomLabel, setCustomLabel] = React.useState(
|
|
93
93
|
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
94
|
-
initialState?.['_components']?.customComponents?.BlockLabel
|
|
94
|
+
initialState?.['_components']?.customComponents?.BlockLabel);
|
|
95
95
|
const [CustomBlock, setCustomBlock] = React.useState(
|
|
96
96
|
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
97
|
-
initialState?.['_components']?.customComponents?.Block
|
|
97
|
+
initialState?.['_components']?.customComponents?.Block);
|
|
98
98
|
// Initial state for newly created blocks
|
|
99
99
|
useEffect(() => {
|
|
100
100
|
const abortController = new AbortController();
|
|
@@ -135,13 +135,13 @@ export const BlockComponent = props => {
|
|
|
135
135
|
const node = $getNodeByKey(nodeKey);
|
|
136
136
|
if (node && $isBlockNode(node)) {
|
|
137
137
|
const newData = newFormStateData;
|
|
138
|
-
newData.blockType = blockType;
|
|
138
|
+
newData.blockType = formData.blockType;
|
|
139
139
|
node.setFields(newData, true);
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
142
|
setInitialState(state);
|
|
143
|
-
setCustomLabel(state._components?.customComponents?.BlockLabel
|
|
144
|
-
setCustomBlock(state._components?.customComponents?.Block
|
|
143
|
+
setCustomLabel(state._components?.customComponents?.BlockLabel);
|
|
144
|
+
setCustomBlock(state._components?.customComponents?.Block);
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
if (formData && !initialState) {
|
|
@@ -150,9 +150,9 @@ export const BlockComponent = props => {
|
|
|
150
150
|
return () => {
|
|
151
151
|
abortAndIgnore(abortController);
|
|
152
152
|
};
|
|
153
|
-
}, [getFormState, schemaFieldsPath, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields
|
|
153
|
+
}, [getFormState, schemaFieldsPath, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
|
|
154
154
|
const [isCollapsed, setIsCollapsed] = React.useState(initialLexicalFormState?.[formData.id]?.collapsed ?? false);
|
|
155
|
-
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
|
|
155
|
+
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`;
|
|
156
156
|
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
157
157
|
const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
|
|
158
158
|
const clientBlock = blocksField.blockReferences ? typeof blocksField?.blockReferences?.[0] === 'string' ? config.blocksMap[blocksField?.blockReferences?.[0]] : blocksField?.blockReferences?.[0] : blocksField?.blocks?.[0];
|
|
@@ -199,14 +199,14 @@ export const BlockComponent = props => {
|
|
|
199
199
|
const node_0 = $getNodeByKey(nodeKey);
|
|
200
200
|
if (node_0 && $isBlockNode(node_0)) {
|
|
201
201
|
const newData_0 = newFormStateData_0;
|
|
202
|
-
newData_0.blockType = blockType;
|
|
202
|
+
newData_0.blockType = formData.blockType;
|
|
203
203
|
node_0.setFields(newData_0, true);
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
206
|
}, 0);
|
|
207
207
|
if (submit) {
|
|
208
|
-
setCustomLabel(newFormState._components?.customComponents?.BlockLabel
|
|
209
|
-
setCustomBlock(newFormState._components?.customComponents?.Block
|
|
208
|
+
setCustomLabel(newFormState._components?.customComponents?.BlockLabel);
|
|
209
|
+
setCustomBlock(newFormState._components?.customComponents?.Block);
|
|
210
210
|
let rowErrorCount = 0;
|
|
211
211
|
for (const formField of Object.values(newFormState)) {
|
|
212
212
|
if (formField?.valid === false) {
|
|
@@ -216,7 +216,7 @@ export const BlockComponent = props => {
|
|
|
216
216
|
setErrorCount(rowErrorCount);
|
|
217
217
|
}
|
|
218
218
|
return newFormState;
|
|
219
|
-
}, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, blockType, parentDocumentFields, editor, nodeKey]);
|
|
219
|
+
}, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, formData.blockType, parentDocumentFields, editor, nodeKey]);
|
|
220
220
|
useEffect(() => {
|
|
221
221
|
return () => {
|
|
222
222
|
abortAndIgnore(onChangeAbortControllerRef.current);
|
|
@@ -284,63 +284,51 @@ export const BlockComponent = props => {
|
|
|
284
284
|
tooltip: "Remove Block"
|
|
285
285
|
}), [parentLexicalRichTextField?.admin?.readOnly, removeBlock]);
|
|
286
286
|
const BlockCollapsible = useMemo(() => ({
|
|
287
|
-
Actions,
|
|
288
287
|
children,
|
|
289
|
-
className,
|
|
290
|
-
collapsibleProps,
|
|
291
288
|
disableBlockName,
|
|
292
289
|
editButton,
|
|
293
290
|
errorCount: errorCount_0,
|
|
294
291
|
fieldHasErrors,
|
|
295
292
|
Label,
|
|
296
|
-
Pill: CustomPill,
|
|
297
293
|
removeButton
|
|
298
|
-
}) => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
children: [
|
|
307
|
-
className: `${baseClass}__block-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
i18n: i18n,
|
|
319
|
-
withMessage: true
|
|
320
|
-
})]
|
|
321
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
322
|
-
className: `${baseClass}__block-actions`,
|
|
323
|
-
children: typeof Actions !== 'undefined' ? Actions : /*#__PURE__*/_jsxs(_Fragment, {
|
|
324
|
-
children: [CustomBlock && editButton !== false || !CustomBlock && editButton ? /*#__PURE__*/_jsx(EditButton, {}) : null, removeButton !== false && editor.isEditable() ? /*#__PURE__*/_jsx(RemoveButton, {}) : null]
|
|
325
|
-
})
|
|
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
|
|
326
314
|
})]
|
|
327
|
-
}),
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
},
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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]);
|
|
339
327
|
const BlockDrawer = useMemo(() => () => /*#__PURE__*/_jsx(EditDepthProvider, {
|
|
340
328
|
children: /*#__PURE__*/_jsx(Drawer, {
|
|
341
329
|
className: '',
|
|
342
330
|
slug: drawerSlug,
|
|
343
|
-
title: t(`lexical:blocks:inlineBlocks:${
|
|
331
|
+
title: t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {
|
|
344
332
|
label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label')
|
|
345
333
|
}),
|
|
346
334
|
children: initialState ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -360,7 +348,7 @@ export const BlockComponent = props => {
|
|
|
360
348
|
})]
|
|
361
349
|
}) : null
|
|
362
350
|
})
|
|
363
|
-
}), [initialState, drawerSlug,
|
|
351
|
+
}), [initialState, drawerSlug, blockDisplayName, t, clientBlock?.fields, schemaFieldsPath, permissions]);
|
|
364
352
|
// Memoized Form JSX
|
|
365
353
|
const Block = useMemo(() => {
|
|
366
354
|
if (!initialState) {
|
|
@@ -382,7 +370,7 @@ export const BlockComponent = props => {
|
|
|
382
370
|
onChange: [onChange],
|
|
383
371
|
onSubmit: (formState_0, newData_1) => {
|
|
384
372
|
// This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
|
|
385
|
-
newData_1.blockType = blockType;
|
|
373
|
+
newData_1.blockType = formData.blockType;
|
|
386
374
|
editor.update(() => {
|
|
387
375
|
const node_1 = $getNodeByKey(nodeKey);
|
|
388
376
|
if (node_1 && $isBlockNode(node_1)) {
|
|
@@ -406,7 +394,7 @@ export const BlockComponent = props => {
|
|
|
406
394
|
RemoveButton: RemoveButton
|
|
407
395
|
})
|
|
408
396
|
});
|
|
409
|
-
}, [BlockCollapsible, BlockDrawer, CustomBlock,
|
|
397
|
+
}, [BlockCollapsible, BlockDrawer, CustomBlock, clientBlock?.fields, RemoveButton, EditButton, editor, errorCount, toggleDrawer, clientBlock?.fields,
|
|
410
398
|
// DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.
|
|
411
399
|
initialState, nodeKey, onChange, submitted]);
|
|
412
400
|
if (!clientBlock) {
|
|
@@ -415,7 +403,7 @@ export const BlockComponent = props => {
|
|
|
415
403
|
fieldHasErrors: true,
|
|
416
404
|
children: /*#__PURE__*/_jsxs("div", {
|
|
417
405
|
className: "lexical-block-not-found",
|
|
418
|
-
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"]
|
|
419
407
|
})
|
|
420
408
|
});
|
|
421
409
|
}
|