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