@payloadcms/richtext-lexical 4.0.0-internal.cd47d20 → 4.0.0-internal.ce66a41
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-MT4FK3IP.js +2 -0
- package/dist/exports/client/Field-MT4FK3IP.js.map +7 -0
- package/dist/exports/client/chunk-3LRZDIIG.js +2 -0
- package/dist/exports/client/{chunk-LN6VX25I.js.map → chunk-3LRZDIIG.js.map} +2 -2
- package/dist/exports/client/chunk-ATPSL6IX.js +2 -0
- package/dist/exports/client/chunk-ATPSL6IX.js.map +7 -0
- package/dist/exports/client/componentInline-ZEP5JPTC.js +2 -0
- package/dist/exports/client/index.js +27 -27
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +43 -33
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/component/useBlockReordering.js +3 -3
- package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.css +0 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +30 -22
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +9 -0
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -0
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +95 -0
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -0
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js +3 -3
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +3 -3
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +4 -4
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/indent/client/IndentPlugin.d.ts.map +1 -1
- package/dist/features/indent/client/IndentPlugin.js +122 -1
- package/dist/features/indent/client/IndentPlugin.js.map +1 -1
- package/dist/features/indent/server/i18n.d.ts.map +1 -1
- package/dist/features/indent/server/i18n.js +74 -37
- package/dist/features/indent/server/i18n.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 +7 -5
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.css +0 -1
- package/dist/features/relationship/client/components/index.css +3 -6
- package/dist/features/table/client/plugins/TableActionMenuPlugin/index.css +0 -1
- package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.css +0 -3
- package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +2 -2
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.css +0 -1
- package/dist/features/typesServer.d.ts +13 -8
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.css +0 -2
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js +3 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.css +0 -1
- package/dist/field/Diff/converters/unknown/index.css +0 -1
- package/dist/field/Diff/converters/upload/index.css +0 -1
- package/dist/field/Diff/index.css +0 -2
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +8 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.css +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.css +21 -10
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +61 -64
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
- package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +2 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.css +0 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +1 -0
- package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.css +0 -2
- package/dist/lexical/ui/ContentEditable.d.ts +2 -1
- package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +21 -7
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/presets/llmInstructions.d.ts +2 -0
- package/dist/presets/llmInstructions.d.ts.map +1 -0
- package/dist/presets/llmInstructions.js +13 -0
- package/dist/presets/llmInstructions.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- 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/validate/hasText.d.ts +2 -2
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/package.json +22 -22
- package/dist/exports/client/Field-BPLEYPXV.js +0 -2
- package/dist/exports/client/Field-BPLEYPXV.js.map +0 -7
- package/dist/exports/client/bundled.css +0 -1
- package/dist/exports/client/chunk-ESITTE3C.js +0 -2
- package/dist/exports/client/chunk-ESITTE3C.js.map +0 -7
- package/dist/exports/client/chunk-LN6VX25I.js +0 -2
- package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
- package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts +0 -11
- package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +0 -1
- package/dist/features/blocks/client/component/removeEmptyArrayValues.js +0 -20
- package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +0 -1
- /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-ZEP5JPTC.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,aAAa,CAAA;AACpB,OAAO,8CAA8C,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,aAAa,CAAA;AACpB,OAAO,8CAA8C,CAAA;AAmBrD,MAAM,MAAM,mBAAmB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,IAAI;IACzF;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAkzBxD,CAAA"}
|
|
@@ -7,7 +7,7 @@ import { getTranslation } from '@payloadcms/translations';
|
|
|
7
7
|
import { Button, Collapsible, Drawer, EditDepthProvider, ErrorPill, Form, formatDrawerSlug, MoreIcon, Pill, Popup, PopupList, RenderFields, SectionTitle, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useFormSubmitted, useServerFunctions, useTranslation, XIcon } from '@payloadcms/ui';
|
|
8
8
|
import { abortAndIgnore } from '@payloadcms/ui/shared';
|
|
9
9
|
import { $getNodeByKey, $getRoot, SKIP_DOM_SELECTION_TAG } from 'lexical';
|
|
10
|
-
import { deepCopyObjectSimpleWithoutReactComponents
|
|
10
|
+
import { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared';
|
|
11
11
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
12
12
|
import { v4 as uuid } from 'uuid';
|
|
13
13
|
import './index.css';
|
|
@@ -15,10 +15,10 @@ import '../../../../utilities/fieldsDrawer/index.css';
|
|
|
15
15
|
import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
|
|
16
16
|
import { RegisterFormSubmit, useDrawerSubmit } from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js';
|
|
17
17
|
import { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
|
|
18
|
+
import { getCachedFormStateIfDataMatches, reduceFormStateToBlockData } from '../getCachedFormStateIfDataMatches.js';
|
|
18
19
|
import { $isBlockNode } from '../nodes/BlocksNode.js';
|
|
19
20
|
import { BlockContent, useBlockComponentContext } from './BlockContent.js';
|
|
20
21
|
import { BlockReordering } from './BlockReordering/index.js';
|
|
21
|
-
import { removeEmptyArrayValues } from './removeEmptyArrayValues.js';
|
|
22
22
|
export const BlockComponent = props => {
|
|
23
23
|
const {
|
|
24
24
|
cacheBuster,
|
|
@@ -69,31 +69,43 @@ export const BlockComponent = props => {
|
|
|
69
69
|
const [editor] = useLexicalComposerContext();
|
|
70
70
|
const isEditable = useLexicalEditable();
|
|
71
71
|
const blockType = formData.blockType;
|
|
72
|
+
const formDataRef = useRef(formData);
|
|
73
|
+
formDataRef.current = formData;
|
|
74
|
+
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
|
|
75
|
+
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
76
|
+
const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
|
|
77
|
+
const blockOrSlug = blocksField?.blocks?.[0];
|
|
78
|
+
const clientBlock = typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug;
|
|
72
79
|
const {
|
|
73
80
|
getFormState
|
|
74
81
|
} = useServerFunctions();
|
|
75
82
|
const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`;
|
|
76
83
|
const [initialState, setInitialState] = React.useState(() => {
|
|
77
84
|
// Initial form state that was calculated server-side. May have stale values
|
|
78
|
-
const
|
|
85
|
+
const cachedState = initialLexicalFormState?.[formData.id];
|
|
86
|
+
const cachedFormState = cachedState?.formState;
|
|
79
87
|
if (!cachedFormState) {
|
|
80
88
|
return false;
|
|
81
89
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
const matchingCachedState = getCachedFormStateIfDataMatches({
|
|
91
|
+
cachedFormState,
|
|
92
|
+
cachedSchemaPath: cachedState.schemaPath,
|
|
93
|
+
currentSchemaPath: schemaFieldsPath,
|
|
94
|
+
formData
|
|
95
|
+
});
|
|
96
|
+
if (!matchingCachedState) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
89
99
|
// Manually add blockName, as it's not part of cachedFormState
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
return {
|
|
101
|
+
...matchingCachedState,
|
|
102
|
+
blockName: {
|
|
103
|
+
initialValue: formData.blockName,
|
|
104
|
+
passesCondition: true,
|
|
105
|
+
valid: true,
|
|
106
|
+
value: formData.blockName
|
|
107
|
+
}
|
|
95
108
|
};
|
|
96
|
-
return mergedState;
|
|
97
109
|
});
|
|
98
110
|
const hasMounted = useRef(false);
|
|
99
111
|
const prevCacheBuster = useRef(cacheBuster);
|
|
@@ -192,9 +204,9 @@ export const BlockComponent = props => {
|
|
|
192
204
|
valid: true,
|
|
193
205
|
value: formData.blockName
|
|
194
206
|
};
|
|
195
|
-
const newFormStateData =
|
|
207
|
+
const newFormStateData = reduceFormStateToBlockData(deepCopyObjectSimpleWithoutReactComponents(state, {
|
|
196
208
|
excludeFiles: true
|
|
197
|
-
})
|
|
209
|
+
}));
|
|
198
210
|
// Things like default values may come back from the server => update the node with the new data
|
|
199
211
|
editor.update(() => {
|
|
200
212
|
const node = $getNodeByKey(nodeKey);
|
|
@@ -218,19 +230,14 @@ export const BlockComponent = props => {
|
|
|
218
230
|
}
|
|
219
231
|
}
|
|
220
232
|
};
|
|
221
|
-
if (formData && !initialState) {
|
|
233
|
+
if (clientBlock && formData && !initialState) {
|
|
222
234
|
void awaitInitialState();
|
|
223
235
|
}
|
|
224
236
|
return () => {
|
|
225
237
|
abortAndIgnore(abortController);
|
|
226
238
|
};
|
|
227
|
-
}, [getFormState, schemaFieldsPath, isEditable, id, CustomLabelFromProps, CustomBlockFromProps, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType]);
|
|
239
|
+
}, [getFormState, schemaFieldsPath, isEditable, id, CustomLabelFromProps, CustomBlockFromProps, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType, clientBlock]);
|
|
228
240
|
const [isCollapsed, setIsCollapsed] = React.useState(initialLexicalFormState?.[formData.id]?.collapsed ?? false);
|
|
229
|
-
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
|
|
230
|
-
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
231
|
-
const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
|
|
232
|
-
const blockOrSlug = blocksField?.blocks?.[0];
|
|
233
|
-
const clientBlock = typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug;
|
|
234
241
|
const {
|
|
235
242
|
i18n,
|
|
236
243
|
t
|
|
@@ -242,11 +249,15 @@ export const BlockComponent = props => {
|
|
|
242
249
|
abortAndIgnore(onChangeAbortControllerRef.current);
|
|
243
250
|
const controller = new AbortController();
|
|
244
251
|
onChangeAbortControllerRef.current = controller;
|
|
252
|
+
const blockData = reduceFormStateToBlockData(deepCopyObjectSimpleWithoutReactComponents(prevFormState, {
|
|
253
|
+
excludeFiles: true
|
|
254
|
+
}), formDataRef.current);
|
|
245
255
|
const {
|
|
246
256
|
state: newFormState
|
|
247
257
|
} = await getFormState({
|
|
248
258
|
id,
|
|
249
259
|
collectionSlug,
|
|
260
|
+
data: blockData,
|
|
250
261
|
docPermissions: {
|
|
251
262
|
fields: true
|
|
252
263
|
},
|
|
@@ -256,7 +267,7 @@ export const BlockComponent = props => {
|
|
|
256
267
|
}),
|
|
257
268
|
formState: prevFormState,
|
|
258
269
|
globalSlug,
|
|
259
|
-
|
|
270
|
+
initialBlockData: blockData,
|
|
260
271
|
operation: 'update',
|
|
261
272
|
readOnly: !isEditable,
|
|
262
273
|
renderAllFields: submit ? true : false,
|
|
@@ -269,11 +280,9 @@ export const BlockComponent = props => {
|
|
|
269
280
|
if (prevFormState.blockName) {
|
|
270
281
|
newFormState.blockName = prevFormState.blockName;
|
|
271
282
|
}
|
|
272
|
-
const newFormStateData_0 =
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
})
|
|
276
|
-
}), true);
|
|
283
|
+
const newFormStateData_0 = reduceFormStateToBlockData(deepCopyObjectSimpleWithoutReactComponents(newFormState, {
|
|
284
|
+
excludeFiles: true
|
|
285
|
+
}), blockData);
|
|
277
286
|
setTimeout(() => {
|
|
278
287
|
editor.update(() => {
|
|
279
288
|
const node_0 = $getNodeByKey(nodeKey);
|
|
@@ -428,7 +437,7 @@ export const BlockComponent = props => {
|
|
|
428
437
|
return;
|
|
429
438
|
}
|
|
430
439
|
// Handle controls before Lexical consumes keys using its retained text selection.
|
|
431
|
-
if (target.matches('.collapsible__drag') && [' ', 'ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab'].includes(event.key)) {
|
|
440
|
+
if (target.matches('.collapsible__drag') && (event.key !== 'Escape' || isReordering) && [' ', 'ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab'].includes(event.key)) {
|
|
432
441
|
onKeyDown(event);
|
|
433
442
|
event.stopPropagation();
|
|
434
443
|
} else if (event.key === 'Tab' && target.matches('.collapsible__toggle')) {
|
|
@@ -589,8 +598,9 @@ export const BlockComponent = props => {
|
|
|
589
598
|
fields: clientBlock?.fields ?? [],
|
|
590
599
|
initialState: initialState,
|
|
591
600
|
onChange: [onChange],
|
|
592
|
-
onSubmit:
|
|
601
|
+
onSubmit: formState_0 => {
|
|
593
602
|
// This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
|
|
603
|
+
const newData_1 = reduceFormStateToBlockData(formState_0, formDataRef.current);
|
|
594
604
|
newData_1.blockType = blockType;
|
|
595
605
|
editor.update(() => {
|
|
596
606
|
const node_1 = $getNodeByKey(nodeKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","MoreIcon","Pill","Popup","PopupList","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","XIcon","abortAndIgnore","$getNodeByKey","$getRoot","SKIP_DOM_SELECTION_TAG","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","RegisterFormSubmit","useDrawerSubmit","useLexicalDrawer","$isBlockNode","BlockContent","useBlockComponentContext","BlockReordering","removeEmptyArrayValues","BlockComponent","props","cacheBuster","className","baseClass","CustomBlock","CustomBlockFromProps","CustomLabel","CustomLabelFromProps","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","getFormState","schemaFieldsPath","initialState","setInitialState","cachedFormState","formState","mergedState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","blockName","passesCondition","valid","hasMounted","prevCacheBuster","current","formUuid","setCustomLabel","undefined","customComponents","BlockLabel","setCustomBlock","Block","resolvedCustomBlock","_jsx","isEditor","isJSXConverter","resolvedCustomLabel","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","excludeFiles","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","update","node","newData","setFields","tag","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","blockOrSlug","blocks","clientBlock","blocksMap","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","values","removeBlock","remove","rowIndex","setRowIndex","updateIndex","getEditorState","read","root","children","getChildren","blockCount","child","getKey","registerUpdateListener","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","buttonStyle","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","showDragHandle","showRowNumber","isReordering","move","onBlur","onKeyDown","reorderInstructionsID","targetIndex","onKeyDownCapture","event","target","altKey","ctrlKey","metaKey","closest","parentElement","currentTarget","matches","key","_jsxs","actions","button","buttonClassName","caret","horizontalAlign","popupType","render","close","ButtonGroup","buttonSize","direction","filter","Boolean","join","collapsibleStyle","dragHandleProps","attributes","role","tabIndex","listeners","header","String","padStart","pillStyle","admin","path","count","withMessage","onToggle","incomingCollapsedState","AfterCollapsible","_Fragment","blockID","headerActions","submitRef","BlockDrawer","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","style","display","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n MoreIcon,\n Pill,\n Popup,\n PopupList,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n XIcon,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, $getRoot, SKIP_DOM_SELECTION_TAG } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapBlockComponentProps } from '../../../../types/index.js'\nimport type { BlockFields } from '../../server/schema.js'\n\nimport './index.css'\nimport '../../../../utilities/fieldsDrawer/index.css'\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport {\n RegisterFormSubmit,\n useDrawerSubmit,\n} from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport {\n type BlockCollapsibleWithErrorProps,\n BlockContent,\n useBlockComponentContext,\n} from './BlockContent.js'\nimport { BlockReordering } from './BlockReordering/index.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\nexport type BlockComponentProps<TFormData extends Record<string, unknown> = BlockFields> = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly className: string\n /**\n * Custom block component from view map\n * Will be rendered with useBlockComponentContext hook.\n */\n readonly CustomBlock?: React.FC<ViewMapBlockComponentProps>\n /**\n * Custom block label from view map\n * Will be rendered with useBlockComponentContext hook.\n */\n readonly CustomLabel?: React.FC<ViewMapBlockComponentProps>\n readonly formData: TFormData\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<BlockComponentProps> = (props) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\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 const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n const mergedState = Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n\n // Manually add blockName, as it's not part of cachedFormState\n mergedState.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return mergedState\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist (CustomBlockFromProps/CustomLabelFromProps),\n // we render them directly with formData instead, so these states are unused.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n // When viewMap components exist, render directly with formData (always current from\n // the lexical node). When they don't, fall back to server-rendered state.\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useBlockComponentContext={useBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useBlockComponentContext={useBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n CustomLabelFromProps,\n CustomBlockFromProps,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient | undefined\n\n const blockOrSlug = blocksField?.blocks?.[0]\n const clientBlock: ClientBlock | undefined =\n typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\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 fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState, { excludeFiles: true }),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n }, 0)\n\n if (submit) {\n if (!CustomLabelFromProps) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n }\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n CustomBlockFromProps,\n CustomLabelFromProps,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const [rowIndex, setRowIndex] = React.useState<number>(0)\n\n useEffect(() => {\n const updateIndex = () => {\n editor.getEditorState().read(() => {\n const root = $getRoot()\n const children = root.getChildren()\n let blockCount = 0\n for (const child of children) {\n if ($isBlockNode(child)) {\n if (child.getKey() === nodeKey) {\n setRowIndex(blockCount)\n return\n }\n blockCount++\n }\n }\n })\n }\n updateIndex()\n return editor.registerUpdateListener(() => {\n updateIndex()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.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(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, isEditable, t, blockDisplayName, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [baseClass, isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n function BlockCollapsible({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n showDragHandle = true,\n showRowNumber = true,\n }: BlockCollapsibleWithErrorProps) {\n return (\n <BlockReordering editor={editor} nodeKey={nodeKey}>\n {({ isReordering, move, onBlur, onKeyDown, reorderInstructionsID, targetIndex }) => (\n <div\n className={`${baseClass}__container ${baseClass}-${blockType}`}\n onKeyDownCapture={(event) => {\n const target = event.target as HTMLElement\n\n if (\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n target.closest('.collapsible')?.parentElement !== event.currentTarget\n ) {\n return\n }\n // Handle controls before Lexical consumes keys using its retained text selection.\n if (\n target.matches('.collapsible__drag') &&\n [' ', 'ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab'].includes(event.key)\n ) {\n onKeyDown(event)\n event.stopPropagation()\n } else if (event.key === 'Tab' && target.matches('.collapsible__toggle')) {\n event.stopPropagation()\n }\n }}\n >\n <Collapsible\n actions={\n typeof Actions !== 'undefined' ? (\n Actions\n ) : isEditable ? (\n <Popup\n button={<MoreIcon />}\n buttonClassName={`${baseClass}__actions-button`}\n caret={false}\n horizontalAlign=\"right\"\n popupType=\"menu\"\n render={({ close }) => (\n <PopupList.ButtonGroup buttonSize=\"medium\">\n <PopupList.Button\n onClick={() => {\n close()\n move({ direction: -1 })\n }}\n >\n {t('general:moveUp')}\n </PopupList.Button>\n <PopupList.Button\n onClick={() => {\n close()\n move({ direction: 1 })\n }}\n >\n {t('general:moveDown')}\n </PopupList.Button>\n {((resolvedCustomBlock && editButton !== false) ||\n (!resolvedCustomBlock && editButton)) && (\n <PopupList.Button\n onClick={() => {\n toggleDrawer()\n close()\n }}\n >\n {t('general:edit')}\n </PopupList.Button>\n )}\n {removeButton !== false && (\n <PopupList.Button\n onClick={() => {\n removeBlock()\n close()\n }}\n >\n <XIcon />\n {t('general:remove')}\n </PopupList.Button>\n )}\n </PopupList.ButtonGroup>\n )}\n size=\"large\"\n />\n ) : null\n }\n className={[\n `${baseClass}__row`,\n fieldHasErrors\n ? `${baseClass}__row--has-errors`\n : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n dragHandleProps={\n showDragHandle && isEditable\n ? {\n id: nodeKey,\n attributes: {\n 'aria-describedby': reorderInstructionsID,\n 'aria-pressed': isReordering,\n role: 'button',\n tabIndex: 0,\n },\n listeners: { onBlur },\n }\n : undefined\n }\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof resolvedCustomLabel !== 'undefined' ? (\n resolvedCustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {showRowNumber && (\n <span className={`${baseClass}__block-number`}>\n {String(rowIndex + 1).padStart(2, '0')}\n </span>\n )}\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n AfterCollapsible={\n <>\n {collapsibleProps?.AfterCollapsible}\n <span className=\"sr-only\" role=\"status\">\n {isReordering ? `${t('general:order')}: ${(targetIndex ?? 0) + 1}` : ''}\n </span>\n </>\n }\n >\n <span className=\"sr-only\" id={reorderInstructionsID}>\n Space / Enter · {t('general:moveUp')} ↑ · {t('general:moveDown')} ↓ ·{' '}\n {t('general:cancel')} Escape\n </span>\n {children}\n </Collapsible>\n </div>\n )}\n </BlockReordering>\n )\n },\n [\n editor,\n resolvedCustomBlock,\n resolvedCustomLabel,\n blockDisplayName,\n baseClass,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n nodeKey,\n removeBlock,\n rowIndex,\n t,\n toggleDrawer,\n ],\n )\n\n const blockID = formData?.id\n\n const { headerActions, submitRef } = useDrawerSubmit()\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n headerActions={headerActions}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <div className=\"fields-drawer\">\n <RenderFields\n fields={clientBlock?.fields ?? []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <RegisterFormSubmit submitRef={submitRef} />\n </div>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n headerActions,\n submitRef,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <div data-block-drawer-slug={drawerSlug} style={{ display: 'contents' }}>\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = blockType\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={formUuid}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={resolvedCustomBlock}\n CustomLabel={resolvedCustomLabel}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n </div>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n resolvedCustomBlock,\n resolvedCustomLabel,\n blockType,\n drawerSlug,\n RemoveButton,\n EditButton,\n baseClass,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n formUuid,\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className={`${baseClass}-not-found`}>\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,EACdC,KAAK,QACA;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,QAAQ,EAAEC,sBAAsB,QAAQ;AAOhE,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC/D,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AAc+B,OAAA;YAC3B,IAAI8E,MAAA,IAAQ7F,YAAA,CAAa6F,MAAA,GAAO;cAC9BA,MAAA,CAAKE,SAAS,CAACD,SAAA,EAAwB;YACzC;UACF;UACA;UACA;UACA;YAAEE,GAAA,EAAK9G;UAAuB;UAEhCqD,YAAA;QACF;QACAvB,SAAA,EAAWA,SAAA;QACXrB,IAAA,EAAMuE,QAAA;kBAEN,aAAAQ,IAAA,CAACzE,YAAA;UACCQ,SAAA,EAAWA,SAAA;UACX6N,WAAA,EAAaA,WAAA;UACb3Q,WAAA,EAAa2M,gBAAA;UACb5J,WAAA,EAAa+D,mBAAA;UACb7D,WAAA,EAAaiE,mBAAA;UACb0E,UAAA,EAAYA,UAAA;UACZvH,UAAA,EAAYA,UAAA;UACZiN,UAAA,EAAYvI,WAAA,EAAa/E,MAAA,IAAU,EAAE;UACrCoB,YAAA,EAAcA,YAAA;UACdhC,OAAA,EAASA,OAAA;UACTsJ,YAAA,EAAcA;;;;EAKxB,GAAG,CACDC,gBAAA,EACAgE,WAAA,EACA7J,mBAAA,EACAI,mBAAA,EACAjC,SAAA,EACAR,UAAA,EACAiI,YAAA,EACAd,UAAA,EACA9I,SAAA,EACAiC,MAAA,EACAV,UAAA,EACAO,YAAA,EACAmE,WAAA,EAAa/E,MAAA,EACbuC,QAAA,EACAnB,YAAA,EACAhC,OAAA,EACA+F,QAAA,EACA9F,SAAA,CACD;EAED,IAAI,CAAC0F,WAAA,EAAa;IAChB,oBACEhC,IAAA,CAAC4F,gBAAA;MAAiBG,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAuB,KAAA,CAAC;QAAI1L,SAAA,EAAW,GAAGC,SAAA,YAAqB;mBAAE,kBACzBmC,SAAA,EAAU;;;EAIjC;EAEA,OAAO4B,KAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","MoreIcon","Pill","Popup","PopupList","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","XIcon","abortAndIgnore","$getNodeByKey","$getRoot","SKIP_DOM_SELECTION_TAG","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","RegisterFormSubmit","useDrawerSubmit","useLexicalDrawer","getCachedFormStateIfDataMatches","reduceFormStateToBlockData","$isBlockNode","BlockContent","useBlockComponentContext","BlockReordering","BlockComponent","props","cacheBuster","className","baseClass","CustomBlock","CustomBlockFromProps","CustomLabel","CustomLabelFromProps","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","formDataRef","current","componentMapRenderedBlockPath","clientSchemaMap","blocksField","blockOrSlug","blocks","clientBlock","blocksMap","getFormState","schemaFieldsPath","initialState","setInitialState","cachedState","cachedFormState","formState","matchingCachedState","cachedSchemaPath","currentSchemaPath","blockName","initialValue","passesCondition","valid","value","hasMounted","prevCacheBuster","formUuid","setCustomLabel","undefined","customComponents","BlockLabel","setCustomBlock","Block","resolvedCustomBlock","_jsx","isEditor","isJSXConverter","resolvedCustomLabel","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","excludeFiles","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","update","node","newData","setFields","tag","_components","isCollapsed","setIsCollapsed","collapsed","i18n","t","onChange","prevFormState","submit","controller","blockData","newFormState","setTimeout","rowErrorCount","formField","Object","values","removeBlock","remove","rowIndex","setRowIndex","updateIndex","getEditorState","read","root","children","getChildren","blockCount","child","getKey","registerUpdateListener","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","buttonStyle","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","showDragHandle","showRowNumber","isReordering","move","onBlur","onKeyDown","reorderInstructionsID","targetIndex","onKeyDownCapture","event","target","altKey","ctrlKey","metaKey","closest","parentElement","currentTarget","matches","key","_jsxs","actions","button","buttonClassName","caret","horizontalAlign","popupType","render","close","ButtonGroup","buttonSize","direction","filter","Boolean","join","collapsibleStyle","dragHandleProps","attributes","role","tabIndex","listeners","header","String","padStart","pillStyle","admin","path","count","withMessage","onToggle","incomingCollapsedState","AfterCollapsible","_Fragment","blockID","headerActions","submitRef","BlockDrawer","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","style","display","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n MoreIcon,\n Pill,\n Popup,\n PopupList,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n XIcon,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, $getRoot, SKIP_DOM_SELECTION_TAG } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapBlockComponentProps } from '../../../../types/index.js'\nimport type { BlockFields } from '../../server/schema.js'\n\nimport './index.css'\nimport '../../../../utilities/fieldsDrawer/index.css'\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport {\n RegisterFormSubmit,\n useDrawerSubmit,\n} from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport {\n getCachedFormStateIfDataMatches,\n reduceFormStateToBlockData,\n} from '../getCachedFormStateIfDataMatches.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport {\n type BlockCollapsibleWithErrorProps,\n BlockContent,\n useBlockComponentContext,\n} from './BlockContent.js'\nimport { BlockReordering } from './BlockReordering/index.js'\n\nexport type BlockComponentProps<TFormData extends Record<string, unknown> = BlockFields> = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly className: string\n /**\n * Custom block component from view map\n * Will be rendered with useBlockComponentContext hook.\n */\n readonly CustomBlock?: React.FC<ViewMapBlockComponentProps>\n /**\n * Custom block label from view map\n * Will be rendered with useBlockComponentContext hook.\n */\n readonly CustomLabel?: React.FC<ViewMapBlockComponentProps>\n readonly formData: TFormData\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<BlockComponentProps> = (props) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\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 const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n const formDataRef = useRef(formData)\n formDataRef.current = formData\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient | undefined\n\n const blockOrSlug = blocksField?.blocks?.[0]\n const clientBlock: ClientBlock | undefined =\n typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedState = initialLexicalFormState?.[formData.id]\n const cachedFormState = cachedState?.formState\n if (!cachedFormState) {\n return false\n }\n\n const matchingCachedState = getCachedFormStateIfDataMatches({\n cachedFormState,\n cachedSchemaPath: cachedState.schemaPath,\n currentSchemaPath: schemaFieldsPath,\n formData,\n })\n if (!matchingCachedState) {\n return false\n }\n\n // Manually add blockName, as it's not part of cachedFormState\n return {\n ...matchingCachedState,\n blockName: {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n }\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist (CustomBlockFromProps/CustomLabelFromProps),\n // we render them directly with formData instead, so these states are unused.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n // When viewMap components exist, render directly with formData (always current from\n // the lexical node). When they don't, fall back to server-rendered state.\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useBlockComponentContext={useBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useBlockComponentContext={useBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData = reduceFormStateToBlockData(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n }\n\n if (clientBlock && formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n CustomLabelFromProps,\n CustomBlockFromProps,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n clientBlock,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n const blockData = reduceFormStateToBlockData(\n deepCopyObjectSimpleWithoutReactComponents(prevFormState, { excludeFiles: true }),\n formDataRef.current,\n )\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n data: blockData,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n formState: prevFormState,\n globalSlug,\n initialBlockData: blockData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData = reduceFormStateToBlockData(\n deepCopyObjectSimpleWithoutReactComponents(newFormState, { excludeFiles: true }),\n blockData,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n }, 0)\n\n if (submit) {\n if (!CustomLabelFromProps) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n }\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n CustomBlockFromProps,\n CustomLabelFromProps,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const [rowIndex, setRowIndex] = React.useState<number>(0)\n\n useEffect(() => {\n const updateIndex = () => {\n editor.getEditorState().read(() => {\n const root = $getRoot()\n const children = root.getChildren()\n let blockCount = 0\n for (const child of children) {\n if ($isBlockNode(child)) {\n if (child.getKey() === nodeKey) {\n setRowIndex(blockCount)\n return\n }\n blockCount++\n }\n }\n })\n }\n updateIndex()\n return editor.registerUpdateListener(() => {\n updateIndex()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.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(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, isEditable, t, blockDisplayName, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [baseClass, isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n function BlockCollapsible({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n showDragHandle = true,\n showRowNumber = true,\n }: BlockCollapsibleWithErrorProps) {\n return (\n <BlockReordering editor={editor} nodeKey={nodeKey}>\n {({ isReordering, move, onBlur, onKeyDown, reorderInstructionsID, targetIndex }) => (\n <div\n className={`${baseClass}__container ${baseClass}-${blockType}`}\n onKeyDownCapture={(event) => {\n const target = event.target as HTMLElement\n\n if (\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n target.closest('.collapsible')?.parentElement !== event.currentTarget\n ) {\n return\n }\n // Handle controls before Lexical consumes keys using its retained text selection.\n if (\n target.matches('.collapsible__drag') &&\n (event.key !== 'Escape' || isReordering) &&\n [' ', 'ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab'].includes(event.key)\n ) {\n onKeyDown(event)\n event.stopPropagation()\n } else if (event.key === 'Tab' && target.matches('.collapsible__toggle')) {\n event.stopPropagation()\n }\n }}\n >\n <Collapsible\n actions={\n typeof Actions !== 'undefined' ? (\n Actions\n ) : isEditable ? (\n <Popup\n button={<MoreIcon />}\n buttonClassName={`${baseClass}__actions-button`}\n caret={false}\n horizontalAlign=\"right\"\n popupType=\"menu\"\n render={({ close }) => (\n <PopupList.ButtonGroup buttonSize=\"medium\">\n <PopupList.Button\n onClick={() => {\n close()\n move({ direction: -1 })\n }}\n >\n {t('general:moveUp')}\n </PopupList.Button>\n <PopupList.Button\n onClick={() => {\n close()\n move({ direction: 1 })\n }}\n >\n {t('general:moveDown')}\n </PopupList.Button>\n {((resolvedCustomBlock && editButton !== false) ||\n (!resolvedCustomBlock && editButton)) && (\n <PopupList.Button\n onClick={() => {\n toggleDrawer()\n close()\n }}\n >\n {t('general:edit')}\n </PopupList.Button>\n )}\n {removeButton !== false && (\n <PopupList.Button\n onClick={() => {\n removeBlock()\n close()\n }}\n >\n <XIcon />\n {t('general:remove')}\n </PopupList.Button>\n )}\n </PopupList.ButtonGroup>\n )}\n size=\"large\"\n />\n ) : null\n }\n className={[\n `${baseClass}__row`,\n fieldHasErrors\n ? `${baseClass}__row--has-errors`\n : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n dragHandleProps={\n showDragHandle && isEditable\n ? {\n id: nodeKey,\n attributes: {\n 'aria-describedby': reorderInstructionsID,\n 'aria-pressed': isReordering,\n role: 'button',\n tabIndex: 0,\n },\n listeners: { onBlur },\n }\n : undefined\n }\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof resolvedCustomLabel !== 'undefined' ? (\n resolvedCustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {showRowNumber && (\n <span className={`${baseClass}__block-number`}>\n {String(rowIndex + 1).padStart(2, '0')}\n </span>\n )}\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n AfterCollapsible={\n <>\n {collapsibleProps?.AfterCollapsible}\n <span className=\"sr-only\" role=\"status\">\n {isReordering ? `${t('general:order')}: ${(targetIndex ?? 0) + 1}` : ''}\n </span>\n </>\n }\n >\n <span className=\"sr-only\" id={reorderInstructionsID}>\n Space / Enter · {t('general:moveUp')} ↑ · {t('general:moveDown')} ↓ ·{' '}\n {t('general:cancel')} Escape\n </span>\n {children}\n </Collapsible>\n </div>\n )}\n </BlockReordering>\n )\n },\n [\n editor,\n resolvedCustomBlock,\n resolvedCustomLabel,\n blockDisplayName,\n baseClass,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n nodeKey,\n removeBlock,\n rowIndex,\n t,\n toggleDrawer,\n ],\n )\n\n const blockID = formData?.id\n\n const { headerActions, submitRef } = useDrawerSubmit()\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n headerActions={headerActions}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <div className=\"fields-drawer\">\n <RenderFields\n fields={clientBlock?.fields ?? []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <RegisterFormSubmit submitRef={submitRef} />\n </div>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n headerActions,\n submitRef,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <div data-block-drawer-slug={drawerSlug} style={{ display: 'contents' }}>\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n const newData = reduceFormStateToBlockData(\n formState,\n formDataRef.current,\n ) as BlockFields\n newData.blockType = blockType\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={formUuid}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={resolvedCustomBlock}\n CustomLabel={resolvedCustomLabel}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n </div>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n resolvedCustomBlock,\n resolvedCustomLabel,\n blockType,\n drawerSlug,\n RemoveButton,\n EditButton,\n baseClass,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n formUuid,\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className={`${baseClass}-not-found`}>\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,EACdC,KAAK,QACA;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,QAAQ,EAAEC,sBAAsB,QAAQ;AAOhE,SAASC,0CAA0C,QAAQ;AAC3D,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC/D,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAK3B,OAAO;AACP,OAAO;AACP,SAASC,sBAAsB,QAAQ;AACvC,SACEC,kBAAkB,EAClBC,eAAe,QACV;AACP,SAASC,gBAAgB,QAAQ;AACjC,SACEC,+BAA+B,EAC/BC,0BAA0B,QACrB;AACP,SAASC,YAAY,QAAQ;AAC7B,SAEEC,YAAY,EACZC,wBAAwB,QACnB;AACP,SAASC,eAAe,QAAQ;AAwBhC,OAAO,MAAMC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AO;cAC9BA,MAAA,CAAKE,SAAS,CAACD,SAAA,EAAS;YAC1B;UACF;UACA;UACA;UACA;YAAEE,GAAA,EAAKnH;UAAuB;UAEhCqD,YAAA;QACF;QACAvB,SAAA,EAAWA,SAAA;QACXtB,IAAA,EAAM6E,QAAA;kBAEN,aAAAQ,IAAA,CAAC7E,YAAA;UACCO,SAAA,EAAWA,SAAA;UACX4N,WAAA,EAAaA,WAAA;UACb1Q,WAAA,EAAa0M,gBAAA;UACb3J,WAAA,EAAaoE,mBAAA;UACblE,WAAA,EAAasE,mBAAA;UACboE,UAAA,EAAYA,UAAA;UACZtH,UAAA,EAAYA,UAAA;UACZgN,UAAA,EAAY5L,WAAA,EAAazB,MAAA,IAAU,EAAE;UACrC6B,YAAA,EAAcA,YAAA;UACdzC,OAAA,EAASA,OAAA;UACTqJ,YAAA,EAAcA;;;;EAKxB,GAAG,CACDC,gBAAA,EACAgE,WAAA,EACAvJ,mBAAA,EACAI,mBAAA,EACAtC,SAAA,EACAR,UAAA,EACAgI,YAAA,EACAd,UAAA,EACA7I,SAAA,EACAiC,MAAA,EACAV,UAAA,EACAO,YAAA,EACAa,WAAA,EAAazB,MAAA,EACb4C,QAAA,EACAf,YAAA,EACAzC,OAAA,EACA6F,QAAA,EACA5F,SAAA,CACD;EAED,IAAI,CAACoC,WAAA,EAAa;IAChB,oBACE2B,IAAA,CAACsF,gBAAA;MAAiBG,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAuB,KAAA,CAAC;QAAIzL,SAAA,EAAW,GAAGC,SAAA,YAAqB;mBAAE,kBACzBmC,SAAA,EAAU;;;EAIjC;EAEA,OAAOiC,KAAA;AACT","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $getNodeByKey, COMMAND_PRIORITY_HIGH,
|
|
1
|
+
import { $getNodeByKey, COMMAND_PRIORITY_HIGH, KEY_DOWN_COMMAND, SKIP_DOM_SELECTION_TAG } from 'lexical';
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
3
|
export function useBlockReordering({
|
|
4
4
|
editor,
|
|
@@ -9,9 +9,9 @@ export function useBlockReordering({
|
|
|
9
9
|
const isPointerDownRef = useRef(false);
|
|
10
10
|
const cancelAfterPointerRef = useRef(false);
|
|
11
11
|
const isReordering = targetIndex !== null;
|
|
12
|
-
useEffect(() => editor.registerCommand(
|
|
12
|
+
useEffect(() => editor.registerCommand(KEY_DOWN_COMMAND, event => {
|
|
13
13
|
const target = event?.target;
|
|
14
|
-
// Leave
|
|
14
|
+
// Leave action-menu keys to the controls instead of editing the retained selection.
|
|
15
15
|
return target instanceof HTMLElement && Boolean(editor.getElementByKey(nodeKey)?.contains(target)) && Boolean(target.closest('.collapsible__actions button'));
|
|
16
16
|
}, COMMAND_PRIORITY_HIGH), [editor, nodeKey]);
|
|
17
17
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlockReordering.js","names":["$getNodeByKey","COMMAND_PRIORITY_HIGH","KEY_ENTER_COMMAND","SKIP_DOM_SELECTION_TAG","useCallback","useEffect","useLayoutEffect","useRef","useState","useBlockReordering","editor","nodeKey","targetIndex","setTargetIndex","targetRef","isPointerDownRef","cancelAfterPointerRef","isReordering","registerCommand","event","target","HTMLElement","Boolean","getElementByKey","contains","closest","cancelTimer","onPointerDown","current","onPointerUp","setTimeout","document","addEventListener","removeEventListener","clearTimeout","restore","getEditorState","read","node","siblings","getParent","getChildren","currentIndex","getIndexWithinParent","undefined","elements","map","sibling","getKey","source","adjacent","sourceRect","getBoundingClientRect","targetRect","adjacentRect","isMovingDown","sourceOffset","bottom","top","siblingOffset","index","Math","min","max","element","translate","style","push","querySelector","scrollIntoView","block","forEach","reset","move","direction","isEditable","update","destination","insertBefore","insertAfter","onUpdate","requestAnimationFrame","header","focusTarget","focus","tag","onKeyDown","key","preventDefault","stopPropagation","count","getChildrenSize","onBlur"],"sources":["../../../../../src/features/blocks/client/component/useBlockReordering.ts"],"sourcesContent":["import type { LexicalEditor } from 'lexical'\nimport type { KeyboardEvent } from 'react'\n\nimport {\n $getNodeByKey,\n COMMAND_PRIORITY_HIGH,\n KEY_ENTER_COMMAND,\n SKIP_DOM_SELECTION_TAG,\n} from 'lexical'\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\n\nexport function useBlockReordering({\n editor,\n nodeKey,\n}: {\n editor: LexicalEditor\n nodeKey: string\n}) {\n const [targetIndex, setTargetIndex] = useState<null | number>(null)\n const targetRef = useRef<null | number>(null)\n const isPointerDownRef = useRef(false)\n const cancelAfterPointerRef = useRef(false)\n const isReordering = targetIndex !== null\n\n useEffect(\n () =>\n editor.registerCommand(\n KEY_ENTER_COMMAND,\n (event) => {\n const target = event?.target\n\n // Leave Enter to the menu controls instead of editing the retained text selection.\n return (\n target instanceof HTMLElement &&\n Boolean(editor.getElementByKey(nodeKey)?.contains(target)) &&\n Boolean(target.closest('.collapsible__actions button'))\n )\n },\n COMMAND_PRIORITY_HIGH,\n ),\n [editor, nodeKey],\n )\n\n useEffect(() => {\n if (!isReordering) {\n return\n }\n let cancelTimer: ReturnType<typeof setTimeout> | undefined\n const onPointerDown = () => {\n isPointerDownRef.current = true\n }\n const onPointerUp = () => {\n isPointerDownRef.current = false\n if (cancelAfterPointerRef.current) {\n // Let the click fire before restoring the preview's original positions.\n cancelTimer = setTimeout(() => {\n targetRef.current = null\n setTargetIndex(null)\n }, 0)\n }\n }\n\n document.addEventListener('pointerdown', onPointerDown, true)\n document.addEventListener('pointerup', onPointerUp, true)\n document.addEventListener('pointercancel', onPointerUp, true)\n return () => {\n document.removeEventListener('pointerdown', onPointerDown, true)\n document.removeEventListener('pointerup', onPointerUp, true)\n document.removeEventListener('pointercancel', onPointerUp, true)\n clearTimeout(cancelTimer)\n isPointerDownRef.current = false\n cancelAfterPointerRef.current = false\n }\n }, [isReordering])\n\n useLayoutEffect(() => {\n if (targetIndex === null) {\n return\n }\n const restore: (() => void)[] = []\n\n editor.getEditorState().read(() => {\n const node = $getNodeByKey(nodeKey)\n const siblings = node?.getParent()?.getChildren()\n const currentIndex = node?.getIndexWithinParent()\n\n if (!siblings || currentIndex === undefined || currentIndex === targetIndex) {\n return\n }\n const elements = siblings.map((sibling) => editor.getElementByKey(sibling.getKey()))\n const source = elements[currentIndex]\n const target = elements[targetIndex]\n const adjacent = elements[currentIndex + (targetIndex > currentIndex ? 1 : -1)]\n\n if (!source || !target || !adjacent) {\n return\n }\n const sourceRect = source.getBoundingClientRect()\n const targetRect = target.getBoundingClientRect()\n const adjacentRect = adjacent.getBoundingClientRect()\n const isMovingDown = targetIndex > currentIndex\n const sourceOffset = isMovingDown\n ? targetRect.bottom - sourceRect.bottom\n : targetRect.top - sourceRect.top\n const siblingOffset = isMovingDown\n ? sourceRect.top - adjacentRect.top\n : sourceRect.bottom - adjacentRect.bottom\n\n // Preview the pending order without committing an editor change until drop.\n for (\n let index = Math.min(currentIndex, targetIndex);\n index <= Math.max(currentIndex, targetIndex);\n index++\n ) {\n const element = elements[index]\n\n if (element) {\n const translate = element.style.translate\n\n restore.push(() => {\n element.style.translate = translate\n })\n element.style.translate = `0 ${index === currentIndex ? sourceOffset : siblingOffset}px`\n }\n }\n source.querySelector('.collapsible__drag')?.scrollIntoView({ block: 'nearest' })\n })\n\n return () => restore.forEach((reset) => reset())\n }, [editor, nodeKey, targetIndex])\n\n const move = useCallback(\n ({ direction, index }: { direction?: -1 | 1; index?: number }) => {\n if (!editor.isEditable()) {\n return\n }\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n const siblings = node?.getParent()?.getChildren()\n\n if (!node || !siblings) {\n return\n }\n const currentIndex = node.getIndexWithinParent()\n const destination = index ?? currentIndex + (direction ?? 0)\n const target = siblings[destination]\n\n if (target && target !== node) {\n if (destination < currentIndex) {\n target.insertBefore(node)\n } else {\n target.insertAfter(node)\n }\n }\n },\n {\n onUpdate: () => {\n // The block header is recreated when its row number changes.\n requestAnimationFrame(() => {\n const header = editor\n .getElementByKey(nodeKey)\n ?.querySelector('.collapsible__toggle-wrap')\n const focusTarget =\n header?.querySelector<HTMLElement>('.collapsible__drag') ??\n header?.querySelector<HTMLElement>('.LexicalEditorTheme__block__actions-button')\n\n focusTarget?.focus()\n })\n },\n tag: SKIP_DOM_SELECTION_TAG,\n },\n )\n },\n [editor, nodeKey],\n )\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (!editor.isEditable()) {\n return\n }\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault()\n event.stopPropagation()\n if (targetRef.current === null) {\n editor.getEditorState().read(() => {\n targetRef.current = $getNodeByKey(nodeKey)?.getIndexWithinParent() ?? null\n })\n setTargetIndex(targetRef.current)\n } else {\n move({ index: targetRef.current })\n targetRef.current = null\n setTargetIndex(null)\n }\n } else if (targetRef.current !== null) {\n if (event.key === 'Escape' || event.key === 'Tab') {\n targetRef.current = null\n setTargetIndex(null)\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n }\n } else if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault()\n event.stopPropagation()\n editor.getEditorState().read(() => {\n const count = $getNodeByKey(nodeKey)?.getParent()?.getChildrenSize() ?? 0\n targetRef.current = Math.max(\n 0,\n Math.min(count - 1, (targetRef.current ?? 0) + (event.key === 'ArrowDown' ? 1 : -1)),\n )\n })\n setTargetIndex(targetRef.current)\n }\n }\n },\n [editor, move, nodeKey],\n )\n\n const onBlur = useCallback(() => {\n if (isPointerDownRef.current) {\n cancelAfterPointerRef.current = true\n return\n }\n targetRef.current = null\n setTargetIndex(null)\n }, [])\n\n return { isReordering, move, onBlur, onKeyDown, targetIndex }\n}\n"],"mappings":"AAGA,SACEA,aAAa,EACbC,qBAAqB,EACrBC,iBAAiB,EACjBC,sBAAsB,QACjB;AACP,SAASC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAE1E,OA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AG;IACpBf,cAAA,CAAe;EACjB,GAAG,EAAE;EAEL,OAAO;IAAEI,YAAA;IAAcwD,IAAA;IAAMmB,MAAA;IAAQN,SAAA;IAAW1E;EAAY;AAC9D","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useBlockReordering.js","names":["$getNodeByKey","COMMAND_PRIORITY_HIGH","KEY_DOWN_COMMAND","SKIP_DOM_SELECTION_TAG","useCallback","useEffect","useLayoutEffect","useRef","useState","useBlockReordering","editor","nodeKey","targetIndex","setTargetIndex","targetRef","isPointerDownRef","cancelAfterPointerRef","isReordering","registerCommand","event","target","HTMLElement","Boolean","getElementByKey","contains","closest","cancelTimer","onPointerDown","current","onPointerUp","setTimeout","document","addEventListener","removeEventListener","clearTimeout","restore","getEditorState","read","node","siblings","getParent","getChildren","currentIndex","getIndexWithinParent","undefined","elements","map","sibling","getKey","source","adjacent","sourceRect","getBoundingClientRect","targetRect","adjacentRect","isMovingDown","sourceOffset","bottom","top","siblingOffset","index","Math","min","max","element","translate","style","push","querySelector","scrollIntoView","block","forEach","reset","move","direction","isEditable","update","destination","insertBefore","insertAfter","onUpdate","requestAnimationFrame","header","focusTarget","focus","tag","onKeyDown","key","preventDefault","stopPropagation","count","getChildrenSize","onBlur"],"sources":["../../../../../src/features/blocks/client/component/useBlockReordering.ts"],"sourcesContent":["import type { LexicalEditor } from 'lexical'\nimport type { KeyboardEvent } from 'react'\n\nimport {\n $getNodeByKey,\n COMMAND_PRIORITY_HIGH,\n KEY_DOWN_COMMAND,\n SKIP_DOM_SELECTION_TAG,\n} from 'lexical'\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\n\nexport function useBlockReordering({\n editor,\n nodeKey,\n}: {\n editor: LexicalEditor\n nodeKey: string\n}) {\n const [targetIndex, setTargetIndex] = useState<null | number>(null)\n const targetRef = useRef<null | number>(null)\n const isPointerDownRef = useRef(false)\n const cancelAfterPointerRef = useRef(false)\n const isReordering = targetIndex !== null\n\n useEffect(\n () =>\n editor.registerCommand(\n KEY_DOWN_COMMAND,\n (event) => {\n const target = event?.target\n\n // Leave action-menu keys to the controls instead of editing the retained selection.\n return (\n target instanceof HTMLElement &&\n Boolean(editor.getElementByKey(nodeKey)?.contains(target)) &&\n Boolean(target.closest('.collapsible__actions button'))\n )\n },\n COMMAND_PRIORITY_HIGH,\n ),\n [editor, nodeKey],\n )\n\n useEffect(() => {\n if (!isReordering) {\n return\n }\n let cancelTimer: ReturnType<typeof setTimeout> | undefined\n const onPointerDown = () => {\n isPointerDownRef.current = true\n }\n const onPointerUp = () => {\n isPointerDownRef.current = false\n if (cancelAfterPointerRef.current) {\n // Let the click fire before restoring the preview's original positions.\n cancelTimer = setTimeout(() => {\n targetRef.current = null\n setTargetIndex(null)\n }, 0)\n }\n }\n\n document.addEventListener('pointerdown', onPointerDown, true)\n document.addEventListener('pointerup', onPointerUp, true)\n document.addEventListener('pointercancel', onPointerUp, true)\n return () => {\n document.removeEventListener('pointerdown', onPointerDown, true)\n document.removeEventListener('pointerup', onPointerUp, true)\n document.removeEventListener('pointercancel', onPointerUp, true)\n clearTimeout(cancelTimer)\n isPointerDownRef.current = false\n cancelAfterPointerRef.current = false\n }\n }, [isReordering])\n\n useLayoutEffect(() => {\n if (targetIndex === null) {\n return\n }\n const restore: (() => void)[] = []\n\n editor.getEditorState().read(() => {\n const node = $getNodeByKey(nodeKey)\n const siblings = node?.getParent()?.getChildren()\n const currentIndex = node?.getIndexWithinParent()\n\n if (!siblings || currentIndex === undefined || currentIndex === targetIndex) {\n return\n }\n const elements = siblings.map((sibling) => editor.getElementByKey(sibling.getKey()))\n const source = elements[currentIndex]\n const target = elements[targetIndex]\n const adjacent = elements[currentIndex + (targetIndex > currentIndex ? 1 : -1)]\n\n if (!source || !target || !adjacent) {\n return\n }\n const sourceRect = source.getBoundingClientRect()\n const targetRect = target.getBoundingClientRect()\n const adjacentRect = adjacent.getBoundingClientRect()\n const isMovingDown = targetIndex > currentIndex\n const sourceOffset = isMovingDown\n ? targetRect.bottom - sourceRect.bottom\n : targetRect.top - sourceRect.top\n const siblingOffset = isMovingDown\n ? sourceRect.top - adjacentRect.top\n : sourceRect.bottom - adjacentRect.bottom\n\n // Preview the pending order without committing an editor change until drop.\n for (\n let index = Math.min(currentIndex, targetIndex);\n index <= Math.max(currentIndex, targetIndex);\n index++\n ) {\n const element = elements[index]\n\n if (element) {\n const translate = element.style.translate\n\n restore.push(() => {\n element.style.translate = translate\n })\n element.style.translate = `0 ${index === currentIndex ? sourceOffset : siblingOffset}px`\n }\n }\n source.querySelector('.collapsible__drag')?.scrollIntoView({ block: 'nearest' })\n })\n\n return () => restore.forEach((reset) => reset())\n }, [editor, nodeKey, targetIndex])\n\n const move = useCallback(\n ({ direction, index }: { direction?: -1 | 1; index?: number }) => {\n if (!editor.isEditable()) {\n return\n }\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n const siblings = node?.getParent()?.getChildren()\n\n if (!node || !siblings) {\n return\n }\n const currentIndex = node.getIndexWithinParent()\n const destination = index ?? currentIndex + (direction ?? 0)\n const target = siblings[destination]\n\n if (target && target !== node) {\n if (destination < currentIndex) {\n target.insertBefore(node)\n } else {\n target.insertAfter(node)\n }\n }\n },\n {\n onUpdate: () => {\n // The block header is recreated when its row number changes.\n requestAnimationFrame(() => {\n const header = editor\n .getElementByKey(nodeKey)\n ?.querySelector('.collapsible__toggle-wrap')\n const focusTarget =\n header?.querySelector<HTMLElement>('.collapsible__drag') ??\n header?.querySelector<HTMLElement>('.LexicalEditorTheme__block__actions-button')\n\n focusTarget?.focus()\n })\n },\n tag: SKIP_DOM_SELECTION_TAG,\n },\n )\n },\n [editor, nodeKey],\n )\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (!editor.isEditable()) {\n return\n }\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault()\n event.stopPropagation()\n if (targetRef.current === null) {\n editor.getEditorState().read(() => {\n targetRef.current = $getNodeByKey(nodeKey)?.getIndexWithinParent() ?? null\n })\n setTargetIndex(targetRef.current)\n } else {\n move({ index: targetRef.current })\n targetRef.current = null\n setTargetIndex(null)\n }\n } else if (targetRef.current !== null) {\n if (event.key === 'Escape' || event.key === 'Tab') {\n targetRef.current = null\n setTargetIndex(null)\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n }\n } else if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault()\n event.stopPropagation()\n editor.getEditorState().read(() => {\n const count = $getNodeByKey(nodeKey)?.getParent()?.getChildrenSize() ?? 0\n targetRef.current = Math.max(\n 0,\n Math.min(count - 1, (targetRef.current ?? 0) + (event.key === 'ArrowDown' ? 1 : -1)),\n )\n })\n setTargetIndex(targetRef.current)\n }\n }\n },\n [editor, move, nodeKey],\n )\n\n const onBlur = useCallback(() => {\n if (isPointerDownRef.current) {\n cancelAfterPointerRef.current = true\n return\n }\n targetRef.current = null\n setTargetIndex(null)\n }, [])\n\n return { isReordering, move, onBlur, onKeyDown, targetIndex }\n}\n"],"mappings":"AAGA,SACEA,aAAa,EACbC,qBAAqB,EACrBC,gBAAgB,EAChBC,sBAAsB,QACjB;AACP,SAASC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAE1E,OAAO,SAASC,mBAAmB;EACjCC,MAAM;EACNC;AAAO,CAIR;EACC,MAAM,CAACC,WAAA,EAAaC,cAAA,CAAe,GAAGL,QAAA,CAAwB;EAC9D,MAAMM,SAAA,GAAYP,MAAA,CAAsB;EACxC,MAAMQ,gBAAA,GAAmBR,MAAA,CAAO;EAChC,MAAMS,qBAAA,GAAwBT,MAAA,CAAO;EACrC,MAAMU,YAAA,GAAeL,WAAA,KAAgB;EAErCP,SAAA,CACE,MACEK,MAAA,CAAOQ,eAAe,CACpBhB,gBAAA,EACCiB,KAAA;IACC,MAAMC,MAAA,GAASD,KAAA,EAAOC,MAAA;IAEtB;IACA,OACEA,MAAA,YAAkBC,WAAA,IAClBC,OA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AAc;UACpBrE,KAAA,CAAMsE,eAAe;QACvB;MACF,OAAO,IAAItE,KAAA,CAAMoE,GAAG,KAAK,aAAapE,KAAA,CAAMoE,GAAG,KAAK,aAAa;QAC/DpE,KAAA,CAAMqE,cAAc;QACpBrE,KAAA,CAAMsE,eAAe;QACrB/E,MAAA,CAAO0B,cAAc,GAAGC,IAAI,CAAC;UAC3B,MAAMqD,KAAA,GAAQ1F,aAAA,CAAcW,OAAA,GAAU6B,SAAA,IAAamD,eAAA,MAAqB;UACxE7E,SAAA,CAAUc,OAAO,GAAGiC,IAAA,CAAKE,GAAG,CAC1B,GACAF,IAAA,CAAKC,GAAG,CAAC4B,KAAA,GAAQ,GAAG,CAAC5E,SAAA,CAAUc,OAAO,IAAI,MAAMT,KAAA,CAAMoE,GAAG,KAAK,cAAc,IAAI,CAAC;QAErF;QACA1E,cAAA,CAAeC,SAAA,CAAUc,OAAO;MAClC;IACF;EACF,GACA,CAAClB,MAAA,EAAQ+D,IAAA,EAAM9D,OAAA,CAAQ;EAGzB,MAAMiF,MAAA,GAASxF,WAAA,CAAY;IACzB,IAAIW,gBAAA,CAAiBa,OAAO,EAAE;MAC5BZ,qBAAA,CAAsBY,OAAO,GAAG;MAChC;IACF;IACAd,SAAA,CAAUc,OAAO,GAAG;IACpBf,cAAA,CAAe;EACjB,GAAG,EAAE;EAEL,OAAO;IAAEI,YAAA;IAAcwD,IAAA;IAAMmB,MAAA;IAAQN,SAAA;IAAW1E;EAAY;AAC9D","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkC,SAAS,EAAE,MAAM,SAAS,CAAA;AAuBxE,OAAO,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