@payloadcms/richtext-lexical 3.0.0-beta.126 → 3.0.0-beta.128
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/LICENSE.md +1 -1
- package/dist/cell/rscEntry.d.ts +12 -0
- package/dist/cell/rscEntry.d.ts.map +1 -0
- package/dist/cell/rscEntry.js +82 -0
- package/dist/cell/rscEntry.js.map +1 -0
- package/dist/exports/client/Field-SHUAQNQD.js +2 -0
- package/dist/exports/client/Field-SHUAQNQD.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-IMM4CFBE.js +2 -0
- package/dist/exports/client/RelationshipComponent-IMM4CFBE.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-NEO76RJK.js → chunk-352SHIZR.js} +2 -2
- package/dist/exports/client/chunk-75T7MDBH.js +2 -0
- package/dist/exports/client/chunk-75T7MDBH.js.map +7 -0
- package/dist/exports/client/{chunk-XY4TCSM7.js → chunk-O4IOO4EU.js} +2 -2
- package/dist/exports/client/chunk-OOBB5GCO.js +2 -0
- package/dist/exports/client/chunk-OOBB5GCO.js.map +7 -0
- package/dist/exports/client/chunk-PDAZFJVO.js +2 -0
- package/dist/exports/client/chunk-PDAZFJVO.js.map +7 -0
- package/dist/exports/client/{chunk-32KXGBIQ.js → chunk-ZOYGBIAN.js} +2 -2
- package/dist/exports/client/component-EHTN2BHZ.js +2 -0
- package/dist/exports/client/component-EHTN2BHZ.js.map +7 -0
- package/dist/exports/client/component-YE2TDR5O.js +2 -0
- package/dist/exports/client/component-YE2TDR5O.js.map +7 -0
- package/dist/exports/client/componentInline-N5LJ2LY2.js +2 -0
- package/dist/exports/client/componentInline-N5LJ2LY2.js.map +7 -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 +8 -8
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/rsc.d.ts +3 -0
- package/dist/exports/server/rsc.d.ts.map +1 -0
- package/dist/exports/server/rsc.js +3 -0
- package/dist/exports/server/rsc.js.map +1 -0
- package/dist/features/blocks/client/component/BlockContent.d.ts +1 -0
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +15 -15
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +68 -52
- 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 +14 -19
- 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 +26 -24
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js +83 -75
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +20 -10
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js +8 -5
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js +25 -14
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +19 -7
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +16 -3
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +58 -19
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +38 -32
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js +3 -1
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/format/bold/feature.client.d.ts.map +1 -1
- package/dist/features/format/bold/feature.client.js +2 -1
- package/dist/features/format/bold/feature.client.js.map +1 -1
- package/dist/features/format/inlineCode/feature.client.d.ts.map +1 -1
- package/dist/features/format/inlineCode/feature.client.js +2 -1
- package/dist/features/format/inlineCode/feature.client.js.map +1 -1
- package/dist/features/format/italic/feature.client.d.ts.map +1 -1
- package/dist/features/format/italic/feature.client.js +2 -1
- package/dist/features/format/italic/feature.client.js.map +1 -1
- package/dist/features/format/strikethrough/feature.client.d.ts.map +1 -1
- package/dist/features/format/strikethrough/feature.client.js +2 -1
- package/dist/features/format/strikethrough/feature.client.js.map +1 -1
- package/dist/features/format/subscript/feature.client.d.ts.map +1 -1
- package/dist/features/format/subscript/feature.client.js +2 -1
- package/dist/features/format/subscript/feature.client.js.map +1 -1
- package/dist/features/format/superscript/feature.client.d.ts.map +1 -1
- package/dist/features/format/superscript/feature.client.js +2 -1
- package/dist/features/format/superscript/feature.client.js.map +1 -1
- package/dist/features/format/underline/feature.client.d.ts.map +1 -1
- package/dist/features/format/underline/feature.client.js +2 -1
- package/dist/features/format/underline/feature.client.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 +52 -15
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/server/i18n.d.ts.map +1 -1
- package/dist/features/link/server/i18n.js +64 -32
- package/dist/features/link/server/i18n.js.map +1 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +3 -1
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/features/link/server/validate.d.ts.map +1 -1
- package/dist/features/link/server/validate.js +8 -5
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +6 -4
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +77 -49
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +93 -52
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +2 -2
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +25 -22
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/types.d.ts +3 -1
- package/dist/features/toolbars/types.d.ts.map +1 -1
- package/dist/features/toolbars/types.js.map +1 -1
- package/dist/features/typesServer.d.ts +4 -17
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +8 -4
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/server/feature.server.d.ts.map +1 -1
- package/dist/features/upload/server/feature.server.js +3 -1
- package/dist/features/upload/server/feature.server.js.map +1 -1
- package/dist/features/upload/server/validate.d.ts.map +1 -1
- package/dist/features/upload/server/validate.js +7 -4
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +27 -41
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +26 -27
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +9 -0
- package/dist/field/rscEntry.d.ts.map +1 -0
- package/dist/field/rscEntry.js +37 -0
- package/dist/field/rscEntry.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -14
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +2 -2
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts +4 -3
- package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +5 -5
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +4 -4
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +14 -5
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +2 -2
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +5 -5
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +3 -2
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +15 -24
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +6 -4
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +6 -4
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
- package/dist/lexical/theme/EditorTheme.js +0 -2
- package/dist/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/types.d.ts +15 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.d.ts +1 -0
- package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +25 -20
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +99 -143
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +2 -3
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/utilities/generateSchemaMap.d.ts.map +1 -1
- package/dist/utilities/generateSchemaMap.js +13 -10
- package/dist/utilities/generateSchemaMap.js.map +1 -1
- package/dist/utilities/initLexicalFeatures.d.ts +18 -0
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -0
- package/dist/utilities/initLexicalFeatures.js +95 -0
- package/dist/utilities/initLexicalFeatures.js.map +1 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +5 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/useLexicalFeature.d.ts.map +1 -1
- package/dist/utilities/useLexicalFeature.js +12 -4
- package/dist/utilities/useLexicalFeature.js.map +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +1 -1
- package/dist/validate/index.js.map +1 -1
- package/package.json +43 -35
- package/dist/cell/index.d.ts +0 -9
- package/dist/cell/index.d.ts.map +0 -1
- package/dist/cell/index.js +0 -120
- package/dist/cell/index.js.map +0 -1
- package/dist/exports/client/Field-Y47DV2NP.js +0 -2
- package/dist/exports/client/Field-Y47DV2NP.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-LBWKOBGF.js +0 -2
- package/dist/exports/client/RelationshipComponent-LBWKOBGF.js.map +0 -7
- package/dist/exports/client/chunk-7SR2HYD6.js +0 -2
- package/dist/exports/client/chunk-7SR2HYD6.js.map +0 -7
- package/dist/exports/client/chunk-GD6LBQBJ.js +0 -2
- package/dist/exports/client/chunk-GD6LBQBJ.js.map +0 -7
- package/dist/exports/client/chunk-IIWHHN4J.js +0 -2
- package/dist/exports/client/chunk-IIWHHN4J.js.map +0 -7
- package/dist/exports/client/component-4TP4L5EV.js +0 -2
- package/dist/exports/client/component-4TP4L5EV.js.map +0 -7
- package/dist/exports/client/component-XMR5NN36.js +0 -2
- package/dist/exports/client/component-XMR5NN36.js.map +0 -7
- package/dist/exports/client/componentInline-NUDJIIQ4.js +0 -2
- package/dist/exports/client/componentInline-NUDJIIQ4.js.map +0 -7
- package/dist/utilities/generateComponentMap.d.ts +0 -6
- package/dist/utilities/generateComponentMap.d.ts.map +0 -1
- package/dist/utilities/generateComponentMap.js +0 -93
- package/dist/utilities/generateComponentMap.js.map +0 -1
- /package/dist/exports/client/{chunk-NEO76RJK.js.map → chunk-352SHIZR.js.map} +0 -0
- /package/dist/exports/client/{chunk-XY4TCSM7.js.map → chunk-O4IOO4EU.js.map} +0 -0
- /package/dist/exports/client/{chunk-32KXGBIQ.js.map → chunk-ZOYGBIAN.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/exports/server/rsc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc.js","names":["RscEntryLexicalCell","RscEntryLexicalField"],"sources":["../../../src/exports/server/rsc.ts"],"sourcesContent":["export { RscEntryLexicalCell } from '../../cell/rscEntry.js'\nexport { RscEntryLexicalField } from '../../field/rscEntry.js'\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ;AACpC,SAASC,oBAAoB,QAAQ","ignoreList":[]}
|
|
@@ -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,WAAW,EAAmC,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,WAAW,EAAE,WAAW,EAAmC,MAAM,SAAS,CAAA;AAiBxF,OAAO,KAAiC,MAAM,OAAO,CAAA;AAErD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAMnE,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,WAAW,CAAA;IACxB,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAA;IACzC,QAAQ,EAAE,WAAW,CAAA;IACrB,UAAU,EAAE,WAAW,EAAE,CAAA;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAoBD;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAmLxC,CAAA"}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
5
5
|
import { getTranslation } from '@payloadcms/translations';
|
|
6
|
-
import { Button, Collapsible, ErrorPill, Pill,
|
|
6
|
+
import { Button, Collapsible, ErrorPill, Pill, RenderFields, SectionTitle, useDocumentInfo, useFormSubmitted, useTranslation } from '@payloadcms/ui';
|
|
7
7
|
import { dequal } from 'dequal/lite';
|
|
8
8
|
import { $getNodeByKey } from 'lexical';
|
|
9
9
|
import React, { useCallback, useEffect } from 'react';
|
|
10
|
+
import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
|
|
10
11
|
import { $isBlockNode } from '../nodes/BlocksNode.js';
|
|
11
12
|
import { FormSavePlugin } from './FormSavePlugin.js';
|
|
12
13
|
// Recursively remove all undefined values from even being present in formData, as they will
|
|
@@ -37,12 +38,19 @@ export const BlockContent = props => {
|
|
|
37
38
|
clientBlock,
|
|
38
39
|
field,
|
|
39
40
|
formSchema,
|
|
41
|
+
Label,
|
|
40
42
|
nodeKey,
|
|
43
|
+
path,
|
|
41
44
|
schemaPath
|
|
42
45
|
} = props;
|
|
43
46
|
let {
|
|
44
47
|
formData
|
|
45
48
|
} = props;
|
|
49
|
+
const {
|
|
50
|
+
fieldProps: {
|
|
51
|
+
permissions
|
|
52
|
+
}
|
|
53
|
+
} = useEditorConfigContext();
|
|
46
54
|
const {
|
|
47
55
|
i18n
|
|
48
56
|
} = useTranslation();
|
|
@@ -51,6 +59,7 @@ export const BlockContent = props => {
|
|
|
51
59
|
// Remember, these preferences are scoped to the whole document, not just this form. This
|
|
52
60
|
// is important to consider for the data path used in setDocFieldPreferences
|
|
53
61
|
const {
|
|
62
|
+
docPermissions,
|
|
54
63
|
getDocPreferences,
|
|
55
64
|
setDocFieldPreferences
|
|
56
65
|
} = useDocumentInfo();
|
|
@@ -134,13 +143,7 @@ export const BlockContent = props => {
|
|
|
134
143
|
children: [/*#__PURE__*/_jsx(Collapsible, {
|
|
135
144
|
className: classNames,
|
|
136
145
|
collapsibleStyle: fieldHasErrors ? 'error' : 'default',
|
|
137
|
-
header:
|
|
138
|
-
clientProps: {
|
|
139
|
-
blockKind: 'lexicalBlock',
|
|
140
|
-
formData
|
|
141
|
-
},
|
|
142
|
-
mappedComponent: clientBlock.admin.components.Label
|
|
143
|
-
}) : /*#__PURE__*/_jsxs("div", {
|
|
146
|
+
header: Label || /*#__PURE__*/_jsxs("div", {
|
|
144
147
|
className: `${baseClass}__block-header`,
|
|
145
148
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
146
149
|
children: [/*#__PURE__*/_jsx(Pill, {
|
|
@@ -174,15 +177,12 @@ export const BlockContent = props => {
|
|
|
174
177
|
setIsCollapsed(incomingCollapsedState);
|
|
175
178
|
},
|
|
176
179
|
children: /*#__PURE__*/_jsx(RenderFields, {
|
|
177
|
-
className: `${baseClass}__fields`,
|
|
178
180
|
fields: formSchema,
|
|
179
181
|
forceRender: true,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
,
|
|
183
|
-
|
|
184
|
-
readOnly: false,
|
|
185
|
-
schemaPath: schemaPath
|
|
182
|
+
parentIndexPath: "",
|
|
183
|
+
parentPath: '',
|
|
184
|
+
parentSchemaPath: "",
|
|
185
|
+
permissions: permissions
|
|
186
186
|
})
|
|
187
187
|
}, 0), /*#__PURE__*/_jsx(FormSavePlugin, {
|
|
188
188
|
onChange: onFormChange
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockContent.js","names":["useLexicalComposerContext","getTranslation","Button","Collapsible","ErrorPill","Pill","RenderComponent","RenderFields","SectionTitle","useDocumentInfo","useFormSubmitted","useTranslation","dequal","$getNodeByKey","React","useCallback","useEffect","$isBlockNode","FormSavePlugin","removeUndefinedAndNullAndEmptyArraysRecursively","obj","key","value","Array","isArray","length","undefined","BlockContent","props","baseClass","clientBlock","field","formSchema","nodeKey","schemaPath","formData","i18n","editor","getDocPreferences","setDocFieldPreferences","isCollapsed","setIsCollapsed","useState","then","currentDocPreferences","currentFieldPreferences","fields","name","collapsedArray","collapsed","includes","id","hasSubmitted","errorCount","setErrorCount","fieldHasErrors","classNames","filter","Boolean","join","onFormChange","fullFieldsWithValues","newFormData","blockType","setTimeout","update","node","setFields","rowErrorCount","formField","Object","values","valid","onCollapsedChange","changedCollapsed","newCollapsed","push","splice","indexOf","hello","removeBlock","remove","_jsxs","Fragment","_jsx","className","collapsibleStyle","header","admin","components","Label","clientProps","blockKind","mappedComponent","pillStyle","labels","singular","slug","path","readOnly","count","withMessage","isEditable","buttonStyle","disabled","icon","onClick","e","preventDefault","round","tooltip","onToggle","incomingCollapsedState","forceRender","margins","onChange"],"sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"sourcesContent":["'use client'\nimport type { ClientBlock, ClientField, CollapsedPreferences, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderComponent,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useEffect } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../../types.js'\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n clientBlock: ClientBlock\n field: LexicalRichTextFieldProps['field']\n formData: BlockFields\n formSchema: ClientField[]\n nodeKey: string\n path: string\n schemaPath: string\n}\n\n// Recursively remove all undefined values from even being present in formData, as they will\n// cause isDeepEqual to return false if, for example, formData has a key that fields.data\n// does not have, even if it's undefined.\n// Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n// Inside of fields.data however, that sub-blocks blockName property does not exist at all.\nfunction removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n}\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 { baseClass, clientBlock, field, formSchema, nodeKey, schemaPath } = props\n let { formData } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>()\n\n useEffect(() => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n setIsCollapsed(collapsedArray ? collapsedArray.includes(formData.id) : false)\n })\n }, [field.name, formData.id, getDocPreferences])\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: BlockFields\n }) => {\n newFormData.id = formData.id\n newFormData.blockType = formData.blockType\n\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n formData = newFormData\n node.setFields(newFormData)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n if (typeof isCollapsed !== 'boolean') {\n return null\n }\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof clientBlock?.labels?.singular === 'string'\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.admin?.readOnly || false} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n )\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fields={formSchema}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,IAAI,EACJC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,eAAe,EACfC,gBAAgB,EAChBC,cAAc,QACT;AACP,SAASC,MAAM,QAAQ;AACvB,SAASC,aAAa,QAAQ;AAC9B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,QAAQ;AAK9C,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAa/B;AACA;AACA;AACA;AACA;AACA,SAASC,gDAAgDC,GAAW;EAClE,KAAK,MAAMC,GAAA,IAAOD,GAAA,EAAK;IACrB,MAAME,KAAA,GAAQF,GAAG,CAACC,GAAA,CAAI;IACtB,IAAIE,KAAA,CAAMC,OAAO,CAACF,KAAA,KAAU,CAACA,KAAA,EAAOG,MAAA,EAAQ;MAC1C,OAAOL,GAAG,CAACC,GAAA,CAAI;IACjB,OAAO,IAAIC,KAAA,IAAS,OAAOA,KAAA,KAAU,UAAU;MAC7CH,+CAAA,CAAgDG,KAAA;IAClD,OAAO,IAAIA,KAAA,KAAUI,SAAA,IAAaJ,KAAA,KAAU,MAAM;MAChD,OAAOF,GAAG,CAACC,GAAA,CA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ent.js","names":["useLexicalComposerContext","getTranslation","Button","Collapsible","ErrorPill","Pill","RenderFields","SectionTitle","useDocumentInfo","useFormSubmitted","useTranslation","dequal","$getNodeByKey","React","useCallback","useEffect","useEditorConfigContext","$isBlockNode","FormSavePlugin","removeUndefinedAndNullAndEmptyArraysRecursively","obj","key","value","Array","isArray","length","undefined","BlockContent","props","baseClass","clientBlock","field","formSchema","Label","nodeKey","path","schemaPath","formData","fieldProps","permissions","i18n","editor","docPermissions","getDocPreferences","setDocFieldPreferences","isCollapsed","setIsCollapsed","useState","then","currentDocPreferences","currentFieldPreferences","fields","name","collapsedArray","collapsed","includes","id","hasSubmitted","errorCount","setErrorCount","fieldHasErrors","classNames","filter","Boolean","join","onFormChange","fullFieldsWithValues","newFormData","blockType","setTimeout","update","node","setFields","rowErrorCount","formField","Object","values","valid","onCollapsedChange","changedCollapsed","newCollapsed","push","splice","indexOf","hello","removeBlock","remove","_jsxs","Fragment","_jsx","className","collapsibleStyle","header","pillStyle","labels","singular","slug","readOnly","admin","count","withMessage","isEditable","buttonStyle","disabled","icon","onClick","e","preventDefault","round","tooltip","onToggle","incomingCollapsedState","forceRender","parentIndexPath","parentPath","parentSchemaPath","onChange"],"sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"sourcesContent":["'use client'\nimport type { ClientBlock, ClientField, CollapsedPreferences, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useEffect } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../../types.js'\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n clientBlock: ClientBlock\n field: LexicalRichTextFieldProps['field']\n formData: BlockFields\n formSchema: ClientField[]\n Label?: React.ReactNode\n nodeKey: string\n path: string\n schemaPath: string\n}\n\n// Recursively remove all undefined values from even being present in formData, as they will\n// cause isDeepEqual to return false if, for example, formData has a key that fields.data\n// does not have, even if it's undefined.\n// Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n// Inside of fields.data however, that sub-blocks blockName property does not exist at all.\nfunction removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n}\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 { baseClass, clientBlock, field, formSchema, Label, nodeKey, path, schemaPath } = props\n let { formData } = props\n const {\n fieldProps: { permissions },\n } = useEditorConfigContext()\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { docPermissions, getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>()\n\n useEffect(() => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n setIsCollapsed(collapsedArray ? collapsedArray.includes(formData.id) : false)\n })\n }, [field.name, formData.id, getDocPreferences])\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: BlockFields\n }) => {\n newFormData.id = formData.id\n newFormData.blockType = formData.blockType\n\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n formData = newFormData\n node.setFields(newFormData)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n if (typeof isCollapsed !== 'boolean') {\n return null\n }\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n Label || (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof clientBlock?.labels?.singular === 'string'\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.admin?.readOnly || false} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n )\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n fields={formSchema}\n forceRender={true}\n parentIndexPath=\"\"\n parentPath={''}\n parentSchemaPath=\"\"\n permissions={permissions} // TODO: Pass field permissions\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,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AAW,GAAG7D,SAAA,gBAAyB;UACvC0E,QAAA,EAAUxE,KAAA,EAAOmE,KAAA,EAAOD,QAAA;UACxBO,IAAA,EAAK;UACLC,OAAA,EAAUC,CAAA;YACRA,CAAA,CAAEC,cAAc;YAChBtB,WAAA;UACF;UACAuB,KAAK;UACLC,OAAA,EAAQ;;;MAMlBhE,WAAA,EAAaA,WAAA;MAEbiE,QAAA,EAAWC,sBAAA;QACTjC,iBAAA,CAAkBiC,sBAAA;QAClBjE,cAAA,CAAeiE,sBAAA;MACjB;gBAEA,aAAAtB,IAAA,CAACnF,YAAA;QACC6C,MAAA,EAAQnB,UAAA;QACRgF,WAAA,EAAa;QACbC,eAAA,EAAgB;QAChBC,UAAA,EAAY;QACZC,gBAAA,EAAiB;QACjB5E,WAAA,EAAaA;;OAZV,I,aAgBPkD,IAAA,CAACvE,cAAA;MAAekG,QAAA,EAAUnD;;;AAGhC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAOhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAInE,OAAO,cAAc,CAAA;AAErB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACnC,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,CAuM1C,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { Collapsible, Form, Pill,
|
|
5
|
-
import
|
|
4
|
+
import { Collapsible, Form, Pill, SectionTitle, ShimmerEffect, useDocumentInfo, useFormSubmitted, useServerFunctions, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import { abortAndIgnore } from '@payloadcms/ui/shared';
|
|
6
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
7
|
const baseClass = 'lexical-block';
|
|
7
8
|
import { getTranslation } from '@payloadcms/translations';
|
|
8
|
-
import { getFormState } from '@payloadcms/ui/shared';
|
|
9
9
|
import { v4 as uuid } from 'uuid';
|
|
10
10
|
import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
|
|
11
11
|
import { BlockContent } from './BlockContent.js';
|
|
@@ -14,44 +14,54 @@ export const BlockComponent = props => {
|
|
|
14
14
|
formData,
|
|
15
15
|
nodeKey
|
|
16
16
|
} = props;
|
|
17
|
-
const {
|
|
18
|
-
config
|
|
19
|
-
} = useConfig();
|
|
20
17
|
const submitted = useFormSubmitted();
|
|
21
18
|
const {
|
|
22
|
-
id
|
|
19
|
+
id,
|
|
20
|
+
collectionSlug,
|
|
21
|
+
globalSlug
|
|
23
22
|
} = useDocumentInfo();
|
|
24
23
|
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
fieldProps: {
|
|
25
|
+
featureClientSchemaMap,
|
|
26
|
+
field: parentLexicalRichTextField,
|
|
27
|
+
path,
|
|
28
|
+
schemaPath
|
|
29
|
+
}
|
|
30
30
|
} = useEditorConfigContext();
|
|
31
|
+
const onChangeAbortControllerRef = useRef(new AbortController());
|
|
32
|
+
const {
|
|
33
|
+
docPermissions,
|
|
34
|
+
getDocPreferences
|
|
35
|
+
} = useDocumentInfo();
|
|
36
|
+
const {
|
|
37
|
+
getFormState
|
|
38
|
+
} = useServerFunctions();
|
|
31
39
|
const [initialState, setInitialState] = useState(false);
|
|
40
|
+
const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`;
|
|
41
|
+
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`;
|
|
42
|
+
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
43
|
+
const blocksField = clientSchemaMap[componentMapRenderedBlockPath][0];
|
|
44
|
+
const clientBlock = blocksField.blocks[0];
|
|
32
45
|
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
} = useEditorConfigContext();
|
|
37
|
-
const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${formData.blockType}`;
|
|
38
|
-
const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_blocks`;
|
|
39
|
-
const blocksField = richTextComponentMap?.get(componentMapRenderedBlockPath)[0];
|
|
40
|
-
const clientBlock = blocksField.blocks.find(block => block.slug === formData.blockType);
|
|
46
|
+
i18n
|
|
47
|
+
} = useTranslation();
|
|
41
48
|
// Field Schema
|
|
42
49
|
useEffect(() => {
|
|
50
|
+
const abortController = new AbortController();
|
|
43
51
|
const awaitInitialState = async () => {
|
|
44
52
|
const {
|
|
45
53
|
state
|
|
46
54
|
} = await getFormState({
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
id,
|
|
56
|
+
collectionSlug,
|
|
57
|
+
data: formData,
|
|
58
|
+
docPermissions,
|
|
59
|
+
docPreferences: await getDocPreferences(),
|
|
60
|
+
globalSlug,
|
|
61
|
+
operation: 'update',
|
|
62
|
+
renderAllFields: true,
|
|
63
|
+
schemaPath: schemaFieldsPath,
|
|
64
|
+
signal: abortController.signal
|
|
55
65
|
});
|
|
56
66
|
if (state) {
|
|
57
67
|
state.blockName = {
|
|
@@ -66,35 +76,47 @@ export const BlockComponent = props => {
|
|
|
66
76
|
if (formData) {
|
|
67
77
|
void awaitInitialState();
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
return () => {
|
|
80
|
+
abortAndIgnore(abortController);
|
|
81
|
+
};
|
|
82
|
+
}, [getFormState, schemaFieldsPath, id, collectionSlug, globalSlug, getDocPreferences, docPermissions]);
|
|
71
83
|
const onChange = useCallback(async ({
|
|
72
84
|
formState: prevFormState
|
|
73
85
|
}) => {
|
|
86
|
+
abortAndIgnore(onChangeAbortControllerRef.current);
|
|
87
|
+
const controller = new AbortController();
|
|
88
|
+
onChangeAbortControllerRef.current = controller;
|
|
74
89
|
const {
|
|
75
|
-
state:
|
|
90
|
+
state: newFormState
|
|
76
91
|
} = await getFormState({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
id,
|
|
93
|
+
collectionSlug,
|
|
94
|
+
docPermissions,
|
|
95
|
+
docPreferences: await getDocPreferences(),
|
|
96
|
+
formState: prevFormState,
|
|
97
|
+
globalSlug,
|
|
98
|
+
operation: 'update',
|
|
99
|
+
schemaPath: schemaFieldsPath,
|
|
100
|
+
signal: controller.signal
|
|
85
101
|
});
|
|
86
|
-
|
|
102
|
+
if (!newFormState) {
|
|
103
|
+
return prevFormState;
|
|
104
|
+
}
|
|
105
|
+
newFormState.blockName = {
|
|
87
106
|
initialValue: '',
|
|
88
107
|
passesCondition: true,
|
|
89
108
|
valid: true,
|
|
90
109
|
value: formData.blockName
|
|
91
110
|
};
|
|
92
|
-
return
|
|
93
|
-
}, [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
return newFormState;
|
|
112
|
+
}, [getFormState, id, collectionSlug, docPermissions, getDocPreferences, globalSlug, schemaFieldsPath, formData.blockName]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
return () => {
|
|
115
|
+
abortAndIgnore(onChangeAbortControllerRef.current);
|
|
116
|
+
};
|
|
117
|
+
}, []);
|
|
97
118
|
const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ');
|
|
119
|
+
const Label = clientBlock?.admin?.components?.Label;
|
|
98
120
|
// Memoized Form JSX
|
|
99
121
|
const formContent = useMemo(() => {
|
|
100
122
|
return clientBlock && initialState !== false ? /*#__PURE__*/_jsx(Form, {
|
|
@@ -117,13 +139,7 @@ export const BlockComponent = props => {
|
|
|
117
139
|
}) : /*#__PURE__*/_jsx(Collapsible, {
|
|
118
140
|
className: classNames,
|
|
119
141
|
collapsibleStyle: "default",
|
|
120
|
-
header: clientBlock?.admin?.components?.Label ? /*#__PURE__*/_jsx(
|
|
121
|
-
clientProps: {
|
|
122
|
-
blockKind: 'lexicalBlock',
|
|
123
|
-
formData
|
|
124
|
-
},
|
|
125
|
-
mappedComponent: clientBlock.admin.components.Label
|
|
126
|
-
}) : /*#__PURE__*/_jsx("div", {
|
|
142
|
+
header: clientBlock?.admin?.components?.Label ? Label : /*#__PURE__*/_jsx("div", {
|
|
127
143
|
className: `${baseClass}__block-header`,
|
|
128
144
|
children: /*#__PURE__*/_jsxs("div", {
|
|
129
145
|
children: [/*#__PURE__*/_jsx(Pill, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Collapsible","Form","Pill","RenderComponent","SectionTitle","ShimmerEffect","useConfig","useDocumentInfo","useFieldProps","useFormSubmitted","useTranslation","React","useCallback","useEffect","useMemo","useState","baseClass","getTranslation","getFormState","v4","uuid","useEditorConfigContext","BlockContent","BlockComponent","props","formData","nodeKey","config","submitted","id","path","schemaPath","field","parentLexicalRichTextField","initialState","setInitialState","richTextComponentMap","schemaFieldsPath","blockType","componentMapRenderedBlockPath","blocksField","get","clientBlock","blocks","find","block","slug","awaitInitialState","state","apiRoute","routes","api","body","data","operation","serverURL","blockName","initialValue","passesCondition","valid","value","onChange","formState","prevFormState","i18n","classNames","filter","Boolean","join","formContent","_jsx","beforeSubmit","fields","formSchema","className","collapsibleStyle","header","admin","components","Label","clientProps","blockKind","mappedComponent","_jsxs","pillStyle","labels","singular","readOnly","height"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Collapsible,\n Form,\n Pill,\n RenderComponent,\n SectionTitle,\n ShimmerEffect,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nconst baseClass = 'lexical-block'\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const { config } = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<false | FormState>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${formData.blockType}`\n\n const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_blocks`\n const blocksField: BlocksFieldClient = richTextComponentMap?.get(componentMapRenderedBlockPath)[0]\n\n const clientBlock = blocksField.blocks.find((block) => block.slug === formData.blockType)\n\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: formData,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n if (state) {\n state.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n setInitialState(state)\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id]) // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n\n const onChange = useCallback(\n async ({ formState: prevFormState }) => {\n const { state: formState } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n formState.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return formState\n },\n\n [config.routes.api, config.serverURL, id, schemaFieldsPath, formData.blockName],\n )\n const { i18n } = useTranslation()\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return clientBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n fields={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n clientBlock={clientBlock}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={clientBlock.fields}\n nodeKey={nodeKey}\n path={`${path}.lexical_internal_feature.blocks.${formData.blockType}`}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {clientBlock && typeof clientBlock.labels?.singular === 'string'\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n </div>\n </div>\n )\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n clientBlock,\n initialState,\n onChange,\n submitted,\n parentLexicalRichTextField,\n nodeKey,\n path,\n schemaFieldsPath,\n classNames,\n i18n,\n ])\n\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n"],"mappings":"AAAA;;;AAEA,SACEA,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,eAAe,EACfC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,QACT;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAEjE,MAAMC,SAAA,GAAY;AAGlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,cAAA,GAAmCC,KAAA;EAC9C,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGF,KAAA;EAC9B,MAAM;IAAEG;EAAM,CAAE,GAAGrB,SAAA;EACnB,MAAMsB,SAAA,GAAYnB,gBAAA;EAClB,MAAM;IAAEoB;EAAE,CAAE,GAAGtB,eAAA;EACf,MAAM;IAAEuB,IAAI;IAAEC;EAAU,CAAE,GAAGvB,aAAA;EAC7B,MAAM;IAAEwB,KAAA,EAAOC;EAA0B,CAAE,GAAGZ,sBAAA;EAE9C,MAAM,CAACa,YAAA,EAAcC,eAAA,CAAgB,GAAGpB,QAAA,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index.js","names":["Collapsible","Form","Pill","SectionTitle","ShimmerEffect","useDocumentInfo","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","React","useCallback","useEffect","useMemo","useRef","useState","baseClass","getTranslation","v4","uuid","useEditorConfigContext","BlockContent","BlockComponent","props","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","path","schemaPath","onChangeAbortControllerRef","AbortController","docPermissions","getDocPreferences","getFormState","initialState","setInitialState","schemaFieldsPath","blockType","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blocks","i18n","abortController","awaitInitialState","state","data","docPreferences","operation","renderAllFields","signal","blockName","initialValue","passesCondition","valid","value","onChange","formState","prevFormState","current","controller","newFormState","classNames","filter","Boolean","join","Label","admin","components","formContent","_jsx","beforeSubmit","fields","formSchema","className","collapsibleStyle","header","_jsxs","pillStyle","labels","singular","slug","readOnly","height"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Collapsible,\n Form,\n Pill,\n SectionTitle,\n ShimmerEffect,\n useDocumentInfo,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nconst baseClass = 'lexical-block'\nimport { getTranslation } from '@payloadcms/translations'\nimport { type BlocksFieldClient, type FormState } from 'payload'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: { featureClientSchemaMap, field: parentLexicalRichTextField, path, schemaPath },\n } = useEditorConfigContext()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const { docPermissions, getDocPreferences } = useDocumentInfo()\n\n const { getFormState } = useServerFunctions()\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[\n componentMapRenderedBlockPath\n ][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n const { i18n } = useTranslation()\n\n // Field Schema\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions,\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n setInitialState(state)\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n docPermissions,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions,\n docPreferences: await getDocPreferences(),\n formState: prevFormState,\n globalSlug,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n newFormState.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n docPermissions,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n formData.blockName,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n const Label = clientBlock?.admin?.components?.Label\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return clientBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n fields={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n clientBlock={clientBlock}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={clientBlock.fields}\n nodeKey={nodeKey}\n path={`${path}.lexical_internal_feature.blocks.${formData.blockType}`}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n clientBlock?.admin?.components?.Label ? (\n Label\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {clientBlock && typeof clientBlock.labels?.singular === 'string'\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n </div>\n </div>\n )\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n clientBlock,\n initialState,\n onChange,\n submitted,\n parentLexicalRichTextField,\n nodeKey,\n path,\n schemaFieldsPath,\n classNames,\n i18n,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ])\n\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n"],"mappings":"AAAA;;;AAEA,SACEA,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,YAAY,EACZC,aAAa,EACbC,eAAe,EACfC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAEzE,MAAMC,SAAA,GAAY;AAClB,SAASC,cAAc,QAAQ;AAE/B,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,cAAA,GAAmCC,KAAA;EAC9C,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGF,KAAA;EAC9B,MAAMG,SAAA,GAAYpB,gBAAA;EAClB,MAAM;IAAEqB,EAAE;IAAEC,cAAc;IAAEC;EAAU,CAAE,GAAGxB,eAAA;EAC3C,MAAM;IACJyB,UAAA,EAAY;MAAEC,sBAAsB;MAAEC,KAAA,EAAOC,0BAA0B;MAAEC,IAAI;MAAEC;IAAU;EAAE,CAC5F,GAAGf,sBAAA;EACJ,MAAMgB,0BAAA,GAA6BtB,MAAA,CAAO,IAAIuB,eAAA;EAC9C,MAAM;IAAEC,cAAc;IAAEC;EAAiB,CAAE,GAAGlC,eAAA;EAE9C,MAAM;IAAEmC;EAAY,CAAE,GAAGjC,kBAAA;EAEzB,MAAM,CAACkC,YAAA,EAAcC,eAAA,CAAgB,GAAG3B,QAAA,CAAwC;EAEhF,MAAM4B,gBAAA,GAAmB,GAAGR,UAAA,mDAA6DX,QAAA,CAASoB,SAAS,SAAS;EAEpH,MAAMC,6BAAA,GAAgC,GAAGV,UAAA,mDAA6DX,QAAA,CAASoB,SAAS,EAAE;EAE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A,CAASoB,SAAS;cAAGiC;;AAClF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAoB7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAKrE,OAAO,cAAc,CAAA;AAErB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAoB7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAKrE,OAAO,cAAc,CAAA;AAErB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiIhD,CAAA"}
|
|
@@ -7,7 +7,7 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
|
|
|
7
7
|
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
8
8
|
import { mergeRegister } from '@lexical/utils';
|
|
9
9
|
import { getTranslation } from '@payloadcms/translations';
|
|
10
|
-
import { Button,
|
|
10
|
+
import { Button, useTranslation } from '@payloadcms/ui';
|
|
11
11
|
import { $getNodeByKey, $getSelection, $isNodeSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND } from 'lexical';
|
|
12
12
|
import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
|
|
13
13
|
import { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js';
|
|
@@ -23,18 +23,18 @@ export const InlineBlockComponent = props => {
|
|
|
23
23
|
t
|
|
24
24
|
} = useTranslation();
|
|
25
25
|
const {
|
|
26
|
-
|
|
26
|
+
fieldProps: {
|
|
27
|
+
featureClientSchemaMap,
|
|
28
|
+
readOnly,
|
|
29
|
+
schemaPath
|
|
30
|
+
}
|
|
27
31
|
} = useEditorConfigContext();
|
|
28
32
|
const inlineBlockElemElemRef = useRef(null);
|
|
29
33
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} = useEditorConfigContext();
|
|
35
|
-
const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_inline_blocks`;
|
|
36
|
-
const blocksField = richTextComponentMap?.get(componentMapRenderedBlockPath)[0];
|
|
37
|
-
const clientBlock = blocksField.blocks.find(block => block.slug === formData.blockType);
|
|
34
|
+
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`;
|
|
35
|
+
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
36
|
+
const blocksField = clientSchemaMap[componentMapRenderedBlockPath][0];
|
|
37
|
+
const clientBlock = blocksField.blocks[0];
|
|
38
38
|
const removeInlineBlock = useCallback(() => {
|
|
39
39
|
editor.update(() => {
|
|
40
40
|
$getNodeByKey(nodeKey)?.remove();
|
|
@@ -74,23 +74,18 @@ export const InlineBlockComponent = props => {
|
|
|
74
74
|
return mergeRegister(editor.registerCommand(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW));
|
|
75
75
|
}, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick]);
|
|
76
76
|
const blockDisplayName = clientBlock?.labels?.singular ? getTranslation(clientBlock.labels.singular, i18n) : clientBlock?.slug;
|
|
77
|
+
const Label = clientBlock?.admin?.components?.Label;
|
|
77
78
|
return /*#__PURE__*/_jsxs("div", {
|
|
78
79
|
className: [baseClass, baseClass + '-' + formData.blockType, isSelected && `${baseClass}--selected`].filter(Boolean).join(' '),
|
|
79
80
|
ref: inlineBlockElemElemRef,
|
|
80
|
-
children: [
|
|
81
|
-
clientProps: {
|
|
82
|
-
blockKind: 'lexicalInlineBlock',
|
|
83
|
-
formData
|
|
84
|
-
},
|
|
85
|
-
mappedComponent: clientBlock.admin.components.Label
|
|
86
|
-
}) : /*#__PURE__*/_jsx("div", {
|
|
81
|
+
children: [Label ? Label : /*#__PURE__*/_jsx("div", {
|
|
87
82
|
children: getTranslation(clientBlock.labels.singular, i18n)
|
|
88
83
|
}), editor.isEditable() && /*#__PURE__*/_jsxs("div", {
|
|
89
84
|
className: `${baseClass}__actions`,
|
|
90
85
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
91
86
|
buttonStyle: "icon-label",
|
|
92
87
|
className: `${baseClass}__editButton`,
|
|
93
|
-
disabled:
|
|
88
|
+
disabled: readOnly,
|
|
94
89
|
el: "div",
|
|
95
90
|
icon: "edit",
|
|
96
91
|
onClick: () => {
|
|
@@ -107,7 +102,7 @@ export const InlineBlockComponent = props => {
|
|
|
107
102
|
}), /*#__PURE__*/_jsx(Button, {
|
|
108
103
|
buttonStyle: "icon-label",
|
|
109
104
|
className: `${baseClass}__removeButton`,
|
|
110
|
-
disabled:
|
|
105
|
+
disabled: readOnly,
|
|
111
106
|
icon: "x",
|
|
112
107
|
onClick: e => {
|
|
113
108
|
e.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useRef","baseClass","useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","RenderComponent","useTranslation","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","useEditorConfigContext","$isInlineBlockNode","OPEN_INLINE_BLOCK_DRAWER_COMMAND","InlineBlockComponent","props","formData","nodeKey","editor","i18n","t","field","inlineBlockElemElemRef","isSelected","setSelected","clearSelection","richTextComponentMap","componentMapRenderedBlockPath","blocksField","get","clientBlock","blocks","find","block","slug","blockType","removeInlineBlock","update","remove","$onDelete","event","deleteSelection","preventDefault","getNodes","forEach","node","onClick","payload","target","current","contains","shiftKey","registerCommand","blockDisplayName","labels","singular","_jsxs","className","filter","Boolean","join","ref","admin","components","Label","_jsx","clientProps","blockKind","mappedComponent","isEditable","buttonStyle","disabled","readOnly","el","icon","dispatchCommand","fields","round","size","tooltip","label","e"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useEffect, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, RenderComponent, useTranslation } from '@payloadcms/ui'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\n\nimport type { InlineBlockFields } from '../nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport { OPEN_INLINE_BLOCK_DRAWER_COMMAND } from '../plugin/commands.js'\nimport './index.scss'\n\ntype Props = {\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const { field } = useEditorConfigContext()\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_inline_blocks`\n const blocksField: BlocksFieldClient = richTextComponentMap?.get(componentMapRenderedBlockPath)[0]\n const clientBlock = blocksField.blocks.find((block) => block.slug === formData.blockType)\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n return (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalInlineBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div>{getTranslation(clientBlock!.labels!.singular, i18n)}</div>\n )}\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={field?.admin?.readOnly}\n el=\"div\"\n icon=\"edit\"\n onClick={() => {\n editor.dispatchCommand(OPEN_INLINE_BLOCK_DRAWER_COMMAND, {\n fields: formData,\n nodeKey,\n })\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ;AACtD,MAAMC,SAAA,GAAY;AAIlB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,uBAAuB,QAAQ;AACxC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,EAAEC,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;UACRA,CAAA,CAAEvC,cAAc;UAChBN,iBAAA;QACF;QACAyC,KAAK;QACLC,IAAA,EAAK;QACLC,OAAA,EAAS3D,CAAA,CAAE,sCAAsC;UAAE4D,KAAA,EAAO3B;QAAiB;;;;AAMvF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useRef","baseClass","useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useTranslation","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","useEditorConfigContext","$isInlineBlockNode","OPEN_INLINE_BLOCK_DRAWER_COMMAND","InlineBlockComponent","props","formData","nodeKey","editor","i18n","t","fieldProps","featureClientSchemaMap","readOnly","schemaPath","inlineBlockElemElemRef","isSelected","setSelected","clearSelection","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blocks","removeInlineBlock","update","remove","$onDelete","event","deleteSelection","preventDefault","getNodes","forEach","node","onClick","payload","target","current","contains","shiftKey","registerCommand","blockDisplayName","labels","singular","slug","Label","admin","components","_jsxs","className","filter","Boolean","join","ref","_jsx","isEditable","buttonStyle","disabled","el","icon","dispatchCommand","fields","round","size","tooltip","label","e"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useEffect, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useTranslation } from '@payloadcms/ui'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\n\nimport type { InlineBlockFields } from '../nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport { OPEN_INLINE_BLOCK_DRAWER_COMMAND } from '../plugin/commands.js'\nimport './index.scss'\n\ntype Props = {\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: { featureClientSchemaMap, readOnly, schemaPath },\n } = useEditorConfigContext()\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[\n componentMapRenderedBlockPath\n ][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const Label = clientBlock?.admin?.components?.Label\n\n return (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {Label ? Label : <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>}\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"div\"\n icon=\"edit\"\n onClick={() => {\n editor.dispatchCommand(OPEN_INLINE_BLOCK_DRAWER_COMMAND, {\n fields: formData,\n nodeKey,\n })\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ;AACtD,MAAMC,SAAA,GAAY;AA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sC,KAAK;QACLC,IAAA,EAAK;QACLC,OAAA,EAASvD,CAAA,CAAE,sCAAsC;UAAEwD,KAAA,EAAOxB;QAAiB;;;;AAMvF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/client/index.tsx"],"names":[],"mappings":"AAiBA,MAAM,MAAM,wBAAwB,GAAG;IACrC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,sBAAsB,EAAE,MAAM,EAAE,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/client/index.tsx"],"names":[],"mappings":"AAiBA,MAAM,MAAM,wBAAwB,GAAG;IACrC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,sBAAsB,EAAE,MAAM,EAAE,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,mBAAmB,gHAkL7B,CAAA"}
|