@payloadcms/richtext-lexical 3.0.0-beta.127 → 3.0.0-beta.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/cell/rscEntry.d.ts +12 -0
- package/dist/cell/rscEntry.d.ts.map +1 -0
- package/dist/cell/rscEntry.js +82 -0
- package/dist/cell/rscEntry.js.map +1 -0
- package/dist/exports/client/Field-SHUAQNQD.js +2 -0
- package/dist/exports/client/Field-SHUAQNQD.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-IMM4CFBE.js +2 -0
- package/dist/exports/client/RelationshipComponent-IMM4CFBE.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-NEO76RJK.js → chunk-352SHIZR.js} +2 -2
- package/dist/exports/client/chunk-75T7MDBH.js +2 -0
- package/dist/exports/client/chunk-75T7MDBH.js.map +7 -0
- package/dist/exports/client/{chunk-XY4TCSM7.js → chunk-O4IOO4EU.js} +2 -2
- package/dist/exports/client/chunk-OOBB5GCO.js +2 -0
- package/dist/exports/client/chunk-OOBB5GCO.js.map +7 -0
- package/dist/exports/client/chunk-PDAZFJVO.js +2 -0
- package/dist/exports/client/chunk-PDAZFJVO.js.map +7 -0
- package/dist/exports/client/{chunk-32KXGBIQ.js → chunk-ZOYGBIAN.js} +2 -2
- package/dist/exports/client/component-EHTN2BHZ.js +2 -0
- package/dist/exports/client/component-EHTN2BHZ.js.map +7 -0
- package/dist/exports/client/component-YE2TDR5O.js +2 -0
- package/dist/exports/client/component-YE2TDR5O.js.map +7 -0
- package/dist/exports/client/componentInline-N5LJ2LY2.js +2 -0
- package/dist/exports/client/componentInline-N5LJ2LY2.js.map +7 -0
- package/dist/exports/client/index.d.ts +0 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +8 -8
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/rsc.d.ts +3 -0
- package/dist/exports/server/rsc.d.ts.map +1 -0
- package/dist/exports/server/rsc.js +3 -0
- package/dist/exports/server/rsc.js.map +1 -0
- package/dist/features/blocks/client/component/BlockContent.d.ts +1 -0
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +15 -15
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +68 -52
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +14 -19
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +26 -24
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js +83 -75
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +20 -10
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js +8 -5
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js +25 -14
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +19 -7
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +16 -3
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +58 -19
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +38 -32
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js +3 -1
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/format/bold/feature.client.d.ts.map +1 -1
- package/dist/features/format/bold/feature.client.js +2 -1
- package/dist/features/format/bold/feature.client.js.map +1 -1
- package/dist/features/format/inlineCode/feature.client.d.ts.map +1 -1
- package/dist/features/format/inlineCode/feature.client.js +2 -1
- package/dist/features/format/inlineCode/feature.client.js.map +1 -1
- package/dist/features/format/italic/feature.client.d.ts.map +1 -1
- package/dist/features/format/italic/feature.client.js +2 -1
- package/dist/features/format/italic/feature.client.js.map +1 -1
- package/dist/features/format/strikethrough/feature.client.d.ts.map +1 -1
- package/dist/features/format/strikethrough/feature.client.js +2 -1
- package/dist/features/format/strikethrough/feature.client.js.map +1 -1
- package/dist/features/format/subscript/feature.client.d.ts.map +1 -1
- package/dist/features/format/subscript/feature.client.js +2 -1
- package/dist/features/format/subscript/feature.client.js.map +1 -1
- package/dist/features/format/superscript/feature.client.d.ts.map +1 -1
- package/dist/features/format/superscript/feature.client.js +2 -1
- package/dist/features/format/superscript/feature.client.js.map +1 -1
- package/dist/features/format/underline/feature.client.d.ts.map +1 -1
- package/dist/features/format/underline/feature.client.js +2 -1
- package/dist/features/format/underline/feature.client.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +52 -15
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/server/i18n.d.ts.map +1 -1
- package/dist/features/link/server/i18n.js +64 -32
- package/dist/features/link/server/i18n.js.map +1 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +3 -1
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/features/link/server/validate.d.ts.map +1 -1
- package/dist/features/link/server/validate.js +8 -5
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +6 -4
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +77 -49
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +93 -52
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +2 -2
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +25 -22
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/types.d.ts +3 -1
- package/dist/features/toolbars/types.d.ts.map +1 -1
- package/dist/features/toolbars/types.js.map +1 -1
- package/dist/features/typesServer.d.ts +4 -17
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +8 -4
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/server/feature.server.d.ts.map +1 -1
- package/dist/features/upload/server/feature.server.js +3 -1
- package/dist/features/upload/server/feature.server.js.map +1 -1
- package/dist/features/upload/server/validate.d.ts.map +1 -1
- package/dist/features/upload/server/validate.js +7 -4
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +27 -41
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +26 -27
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +9 -0
- package/dist/field/rscEntry.d.ts.map +1 -0
- package/dist/field/rscEntry.js +37 -0
- package/dist/field/rscEntry.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -14
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +2 -2
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts +4 -3
- package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +5 -5
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +4 -4
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +14 -5
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +2 -2
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +5 -5
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +3 -2
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +15 -24
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +6 -4
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +6 -4
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
- package/dist/lexical/theme/EditorTheme.js +0 -2
- package/dist/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/types.d.ts +15 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.d.ts +1 -0
- package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +25 -20
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +99 -143
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +2 -3
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/utilities/generateSchemaMap.d.ts.map +1 -1
- package/dist/utilities/generateSchemaMap.js +13 -10
- package/dist/utilities/generateSchemaMap.js.map +1 -1
- package/dist/utilities/initLexicalFeatures.d.ts +18 -0
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -0
- package/dist/utilities/initLexicalFeatures.js +95 -0
- package/dist/utilities/initLexicalFeatures.js.map +1 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +5 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/useLexicalFeature.d.ts.map +1 -1
- package/dist/utilities/useLexicalFeature.js +12 -4
- package/dist/utilities/useLexicalFeature.js.map +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +1 -1
- package/dist/validate/index.js.map +1 -1
- package/package.json +43 -35
- package/dist/cell/index.d.ts +0 -9
- package/dist/cell/index.d.ts.map +0 -1
- package/dist/cell/index.js +0 -120
- package/dist/cell/index.js.map +0 -1
- package/dist/exports/client/Field-Y47DV2NP.js +0 -2
- package/dist/exports/client/Field-Y47DV2NP.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-LBWKOBGF.js +0 -2
- package/dist/exports/client/RelationshipComponent-LBWKOBGF.js.map +0 -7
- package/dist/exports/client/chunk-7SR2HYD6.js +0 -2
- package/dist/exports/client/chunk-7SR2HYD6.js.map +0 -7
- package/dist/exports/client/chunk-GD6LBQBJ.js +0 -2
- package/dist/exports/client/chunk-GD6LBQBJ.js.map +0 -7
- package/dist/exports/client/chunk-IIWHHN4J.js +0 -2
- package/dist/exports/client/chunk-IIWHHN4J.js.map +0 -7
- package/dist/exports/client/component-4TP4L5EV.js +0 -2
- package/dist/exports/client/component-4TP4L5EV.js.map +0 -7
- package/dist/exports/client/component-XMR5NN36.js +0 -2
- package/dist/exports/client/component-XMR5NN36.js.map +0 -7
- package/dist/exports/client/componentInline-NUDJIIQ4.js +0 -2
- package/dist/exports/client/componentInline-NUDJIIQ4.js.map +0 -7
- package/dist/utilities/generateComponentMap.d.ts +0 -6
- package/dist/utilities/generateComponentMap.d.ts.map +0 -1
- package/dist/utilities/generateComponentMap.js +0 -93
- package/dist/utilities/generateComponentMap.js.map +0 -1
- /package/dist/exports/client/{chunk-NEO76RJK.js.map → chunk-352SHIZR.js.map} +0 -0
- /package/dist/exports/client/{chunk-XY4TCSM7.js.map → chunk-O4IOO4EU.js.map} +0 -0
- /package/dist/exports/client/{chunk-32KXGBIQ.js.map → chunk-ZOYGBIAN.js.map} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { getFromImportMap } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
2
|
+
import { createClientFields, deepCopyObjectSimple } from 'payload';
|
|
3
|
+
export function initLexicalFeatures(args) {
|
|
4
|
+
const clientFeatures = {};
|
|
5
|
+
const fieldSchemaMap = Object.fromEntries(new Map(args.fieldSchemaMap));
|
|
6
|
+
//&const value = deepCopyObjectSimple(args.fieldState.value)
|
|
7
|
+
// turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:
|
|
8
|
+
const resolvedFeatureMapArray = Array.from(args.sanitizedEditorConfig.resolvedFeatureMap.entries()).sort((a, b) => a[1].order - b[1].order);
|
|
9
|
+
const featureClientSchemaMap = {};
|
|
10
|
+
for (const [featureKey, resolvedFeature] of resolvedFeatureMapArray) {
|
|
11
|
+
clientFeatures[featureKey] = {};
|
|
12
|
+
/**
|
|
13
|
+
* Handle client features
|
|
14
|
+
*/
|
|
15
|
+
const ClientFeaturePayloadComponent = resolvedFeature.ClientFeature;
|
|
16
|
+
if (ClientFeaturePayloadComponent) {
|
|
17
|
+
const clientFeatureProvider = getFromImportMap({
|
|
18
|
+
importMap: args.payload.importMap,
|
|
19
|
+
PayloadComponent: ClientFeaturePayloadComponent,
|
|
20
|
+
schemaPath: 'lexical-clientComponent',
|
|
21
|
+
silent: true
|
|
22
|
+
});
|
|
23
|
+
if (!clientFeatureProvider) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const clientFeatureProps = resolvedFeature.clientFeatureProps ?? {};
|
|
27
|
+
clientFeatureProps.featureKey = resolvedFeature.key;
|
|
28
|
+
clientFeatureProps.order = resolvedFeature.order;
|
|
29
|
+
if (typeof ClientFeaturePayloadComponent === 'object' && ClientFeaturePayloadComponent.clientProps) {
|
|
30
|
+
clientFeatureProps.clientProps = ClientFeaturePayloadComponent.clientProps;
|
|
31
|
+
}
|
|
32
|
+
// As clientFeatureProvider is a client function, we cannot execute it on the server here. Thus, the client will have to execute clientFeatureProvider with its props
|
|
33
|
+
clientFeatures[featureKey] = {
|
|
34
|
+
clientFeatureProps,
|
|
35
|
+
clientFeatureProvider
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Handle sub-fields (formstate of those)ttt
|
|
40
|
+
*/ // The args.fieldSchemaMap generated before in buildFormState should contain all of lexical features' sub-field schemas
|
|
41
|
+
// as well, as it already called feature.generateSchemaMap for each feature.
|
|
42
|
+
// We will check for the existance resolvedFeature.generateSchemaMap to skip unnecessary loops for constructing featureSchemaMap, but we don't run it here
|
|
43
|
+
if (resolvedFeature.generateSchemaMap) {
|
|
44
|
+
const featureSchemaPath = [...args.schemaPath.split('.'), 'lexical_internal_feature', featureKey].join('.');
|
|
45
|
+
const featurePath = [...args.path.split('.'), 'lexical_internal_feature', featureKey].join('.');
|
|
46
|
+
// Like args.fieldSchemaMap, we only want to include the sub-fields of the current feature
|
|
47
|
+
const featureSchemaMap = {};
|
|
48
|
+
for (const key in fieldSchemaMap) {
|
|
49
|
+
const state = fieldSchemaMap[key];
|
|
50
|
+
if (key.startsWith(featureSchemaPath)) {
|
|
51
|
+
featureSchemaMap[key] = state;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
featureClientSchemaMap[featureKey] = {};
|
|
55
|
+
for (const key in featureSchemaMap) {
|
|
56
|
+
const state = featureSchemaMap[key];
|
|
57
|
+
const clientFields = createClientFields({
|
|
58
|
+
clientFields: 'fields' in state ? deepCopyObjectSimple(state.fields) : [deepCopyObjectSimple(state)],
|
|
59
|
+
defaultIDType: args.payload.config.db.defaultIDType,
|
|
60
|
+
disableAddingID: true,
|
|
61
|
+
fields: 'fields' in state ? state.fields : [state],
|
|
62
|
+
i18n: args.i18n
|
|
63
|
+
});
|
|
64
|
+
featureClientSchemaMap[featureKey][key] = clientFields;
|
|
65
|
+
}
|
|
66
|
+
/*
|
|
67
|
+
This is for providing an initial form state. Right now we only want to provide the clientfields though
|
|
68
|
+
const schemaMap: {
|
|
69
|
+
[key: string]: FieldState
|
|
70
|
+
} = {}
|
|
71
|
+
const lexicalDeepIterate = (editorState) => {
|
|
72
|
+
console.log('STATE', editorState)
|
|
73
|
+
if (
|
|
74
|
+
editorState &&
|
|
75
|
+
typeof editorState === 'object' &&
|
|
76
|
+
'children' in editorState &&
|
|
77
|
+
Array.isArray(editorState.children)
|
|
78
|
+
) {
|
|
79
|
+
for (const childKey in editorState.children) {
|
|
80
|
+
const childState = editorState.children[childKey]
|
|
81
|
+
if (childState && typeof childState === 'object') {
|
|
82
|
+
lexicalDeepIterate(childState)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
lexicalDeepIterate(value.root)*/
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
clientFeatures,
|
|
92
|
+
featureClientSchemaMap
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=initLexicalFeatures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initLexicalFeatures.js","names":["getFromImportMap","createClientFields","deepCopyObjectSimple","initLexicalFeatures","args","clientFeatures","fieldSchemaMap","Object","fromEntries","Map","resolvedFeatureMapArray","Array","from","sanitizedEditorConfig","resolvedFeatureMap","entries","sort","a","b","order","featureClientSchemaMap","featureKey","resolvedFeature","ClientFeaturePayloadComponent","ClientFeature","clientFeatureProvider","importMap","payload","PayloadComponent","schemaPath","silent","clientFeatureProps","key","clientProps","generateSchemaMap","featureSchemaPath","split","join","featurePath","path","featureSchemaMap","state","startsWith","clientFields","fields","defaultIDType","config","db","disableAddingID","i18n"],"sources":["../../src/utilities/initLexicalFeatures.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport { getFromImportMap } from '@payloadcms/ui/elements/RenderServerComponent'\nimport {\n type ClientField,\n createClientFields,\n deepCopyObjectSimple,\n type FieldSchemaMap,\n type Payload,\n} from 'payload'\n\nimport type { FeatureProviderProviderClient } from '../features/typesClient.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { FeatureClientSchemaMap, LexicalRichTextFieldProps } from '../types.js'\ntype Args = {\n fieldSchemaMap: FieldSchemaMap\n i18n: I18nClient\n path: string\n payload: Payload\n sanitizedEditorConfig: SanitizedServerEditorConfig\n schemaPath: string\n}\n\nexport function initLexicalFeatures(args: Args): {\n clientFeatures: LexicalRichTextFieldProps['clientFeatures']\n featureClientSchemaMap: FeatureClientSchemaMap\n} {\n const clientFeatures: LexicalRichTextFieldProps['clientFeatures'] = {}\n\n const fieldSchemaMap = Object.fromEntries(new Map(args.fieldSchemaMap))\n //&const value = deepCopyObjectSimple(args.fieldState.value)\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = Array.from(\n args.sanitizedEditorConfig.resolvedFeatureMap.entries(),\n ).sort((a, b) => a[1].order - b[1].order)\n\n const featureClientSchemaMap: FeatureClientSchemaMap = {}\n\n for (const [featureKey, resolvedFeature] of resolvedFeatureMapArray) {\n clientFeatures[featureKey] = {}\n\n /**\n * Handle client features\n */\n const ClientFeaturePayloadComponent = resolvedFeature.ClientFeature\n\n if (ClientFeaturePayloadComponent) {\n const clientFeatureProvider = getFromImportMap<FeatureProviderProviderClient>({\n importMap: args.payload.importMap,\n PayloadComponent: ClientFeaturePayloadComponent,\n schemaPath: 'lexical-clientComponent',\n silent: true,\n })\n\n if (!clientFeatureProvider) {\n continue\n }\n\n const clientFeatureProps = resolvedFeature.clientFeatureProps ?? {}\n clientFeatureProps.featureKey = resolvedFeature.key\n clientFeatureProps.order = resolvedFeature.order\n if (\n typeof ClientFeaturePayloadComponent === 'object' &&\n ClientFeaturePayloadComponent.clientProps\n ) {\n clientFeatureProps.clientProps = ClientFeaturePayloadComponent.clientProps\n }\n\n // As clientFeatureProvider is a client function, we cannot execute it on the server here. Thus, the client will have to execute clientFeatureProvider with its props\n clientFeatures[featureKey] = { clientFeatureProps, clientFeatureProvider }\n }\n\n /**\n * Handle sub-fields (formstate of those)ttt\n */\n // The args.fieldSchemaMap generated before in buildFormState should contain all of lexical features' sub-field schemas\n // as well, as it already called feature.generateSchemaMap for each feature.\n // We will check for the existance resolvedFeature.generateSchemaMap to skip unnecessary loops for constructing featureSchemaMap, but we don't run it here\n if (resolvedFeature.generateSchemaMap) {\n const featureSchemaPath = [\n ...args.schemaPath.split('.'),\n 'lexical_internal_feature',\n featureKey,\n ].join('.')\n\n const featurePath = [...args.path.split('.'), 'lexical_internal_feature', featureKey].join(\n '.',\n )\n\n // Like args.fieldSchemaMap, we only want to include the sub-fields of the current feature\n const featureSchemaMap: typeof fieldSchemaMap = {}\n for (const key in fieldSchemaMap) {\n const state = fieldSchemaMap[key]\n\n if (key.startsWith(featureSchemaPath)) {\n featureSchemaMap[key] = state\n }\n }\n\n featureClientSchemaMap[featureKey] = {}\n\n for (const key in featureSchemaMap) {\n const state = featureSchemaMap[key]\n\n const clientFields = createClientFields({\n clientFields: ('fields' in state\n ? deepCopyObjectSimple(state.fields)\n : [deepCopyObjectSimple(state)]) as ClientField[],\n defaultIDType: args.payload.config.db.defaultIDType,\n disableAddingID: true,\n fields: 'fields' in state ? state.fields : [state],\n i18n: args.i18n,\n })\n featureClientSchemaMap[featureKey][key] = clientFields\n }\n\n /*\n This is for providing an initial form state. Right now we only want to provide the clientfields though\n const schemaMap: {\n [key: string]: FieldState\n } = {}\n\n const lexicalDeepIterate = (editorState) => {\n console.log('STATE', editorState)\n\n if (\n editorState &&\n typeof editorState === 'object' &&\n 'children' in editorState &&\n Array.isArray(editorState.children)\n ) {\n for (const childKey in editorState.children) {\n const childState = editorState.children[childKey]\n\n if (childState && typeof childState === 'object') {\n lexicalDeepIterate(childState)\n }\n }\n }\n }\n\n lexicalDeepIterate(value.root)*/\n }\n }\n return {\n clientFeatures,\n featureClientSchemaMap,\n }\n}\n"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ;AACjC,SAEEC,kBAAkB,EAClBC,oBAAoB,QAGf;AAcP,OAAO,SAASC,oBAAoBC,IAAU;EAI5C,MAAMC,cAAA,GAA8D,CAAC;EAErE,MAAMC,cAAA,GAAiBC,MAAA,CAAOC,WAAW,CAAC,IAAIC,GAAA,CAAIL,IAAA,CAAKE,cAAc;EACrE;EAEA;EACA,MAAMI,uBAAA,GAA0BC,KAAA,CAAMC,IAAI,CACxCR,IAAA,CAAKS,qBAAqB,CAACC,kBAAkB,CAACC,OAAO,IACrDC,IAAI,CAAC,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAC,CAAC,EAAE,CAACE,KAAK,GAAGD,CAAC,CAAC,EAAE,CAACC,KAAK;EAExC,MAAMC,sBAAA,GAAiD,CAAC;EAExD,KAAK,MAAM,CAACC,UAAA,EAAYC,eAAA,CAAgB,IAAIZ,uBAAA,EAAyB;IACnEL,cAAc,CAACgB,UAAA,CAAW,GAAG,CAAC;IAE9B;;;IAGA,MAAME,6BAAA,GAAgCD,eAAA,CAAgBE,aAAa;IAEnE,IAAID,6BAAA,EAA+B;MACjC,MAAME,qBAAA,GAAwBzB,gBAAA,CAAgD;QAC5E0B,SAAA,EAAWtB,IAAA,CAAKuB,OAAO,CAACD,SAAS;QACjCE,gBAAA,EAAkBL,6BAAA;QAClBM,UAAA,EAAY;QACZC,MAA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YF,KAAA,GACvBvC,oBAAA,CAAqBuC,KAAA,CAAMG,MAAM,IACjC,CAAC1C,oBAAA,CAAqBuC,KAAA,EAAO;UACjCI,aAAA,EAAezC,IAAA,CAAKuB,OAAO,CAACmB,MAAM,CAACC,EAAE,CAACF,aAAa;UACnDG,eAAA,EAAiB;UACjBJ,MAAA,EAAQ,YAAYH,KAAA,GAAQA,KAAA,CAAMG,MAAM,GAAG,CAACH,KAAA,CAAM;UAClDQ,IAAA,EAAM7C,IAAA,CAAK6C;QACb;QACA7B,sBAAsB,CAACC,UAAA,CAAW,CAACW,GAAA,CAAI,GAAGW,YAAA;MAC5C;MAEA;;;;;;;;;;;;;;;;;;;;;;IA0BF;EACF;EACA,OAAO;IACLtC,cAAA;IACAe;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeDocumentFieldsRecursively.d.ts","sourceRoot":"","sources":["../../../src/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AASpC,KAAK,wBAAwB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAE7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,gCAAgC,6BAI1C,wBAAwB,KAAG,
|
|
1
|
+
{"version":3,"file":"upgradeDocumentFieldsRecursively.d.ts","sourceRoot":"","sources":["../../../src/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AASpC,KAAK,wBAAwB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAE7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,gCAAgC,6BAI1C,wBAAwB,KAAG,MAoF7B,CAAA"}
|
|
@@ -66,7 +66,11 @@ export const upgradeDocumentFieldsRecursively = ({
|
|
|
66
66
|
editorConfig: editor.editorConfig
|
|
67
67
|
})
|
|
68
68
|
});
|
|
69
|
-
headlessEditor.
|
|
69
|
+
headlessEditor.update(() => {
|
|
70
|
+
headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState));
|
|
71
|
+
}, {
|
|
72
|
+
discrete: true
|
|
73
|
+
});
|
|
70
74
|
// get editor state
|
|
71
75
|
data[field.name] = headlessEditor.getEditorState().toJSON();
|
|
72
76
|
found++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeDocumentFieldsRecursively.js","names":["createHeadlessEditor","fieldAffectsData","fieldHasSubFields","fieldIsArrayType","tabHasName","getEnabledNodes","upgradeDocumentFieldsRecursively","data","fields","found","field","name","type","tabs","forEach","tab","Array","isArray","row","i","block","blocks","find","slug","blockType","_","editor","features","length","editorState","headlessEditor","nodes","editorConfig","setEditorState","parseEditorState","getEditorState","toJSON"],"sources":["../../../src/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.ts"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { Field } from 'payload'\n\nimport { createHeadlessEditor } from '@lexical/headless'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsArrayType, tabHasName } from 'payload/shared'\n\nimport type { LexicalRichTextAdapter } from '../../types.js'\n\nimport { getEnabledNodes } from '../../lexical/nodes/index.js'\n\ntype NestedRichTextFieldsArgs = {\n data: Record<string, unknown>\n\n fields: Field[]\n found: number\n}\n\nexport const upgradeDocumentFieldsRecursively = ({\n data,\n fields,\n found,\n}: NestedRichTextFieldsArgs): number => {\n for (const field of fields) {\n if (fieldHasSubFields(field) && !fieldIsArrayType(field)) {\n if (fieldAffectsData(field) && typeof data[field.name] === 'object') {\n found += upgradeDocumentFieldsRecursively({\n data: data[field.name] as Record<string, unknown>,\n fields: field.fields,\n found,\n })\n } else {\n found += upgradeDocumentFieldsRecursively({\n data,\n fields: field.fields,\n found,\n })\n }\n } else if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n found += upgradeDocumentFieldsRecursively({\n data: (tabHasName(tab) ? data[tab.name] : data) as Record<string, unknown>,\n fields: tab.fields,\n found,\n })\n })\n } else if (Array.isArray(data[field.name])) {\n if (field.type === 'blocks') {\n ;(data[field.name] as Record<string, unknown>[]).forEach((row, i) => {\n const block = field.blocks.find(({ slug }) => slug === row?.blockType)\n if (block) {\n found += upgradeDocumentFieldsRecursively({\n data: (data[field.name] as Record<string, unknown>[])[i],\n fields: block.fields,\n found,\n })\n }\n })\n }\n\n if (field.type === 'array') {\n ;(data[field.name] as Record<string, unknown>[]).forEach((_, i) => {\n found += upgradeDocumentFieldsRecursively({\n data: (data[field.name] as Record<string, unknown>[])[i],\n fields: field.fields,\n found,\n })\n })\n }\n }\n\n if (\n field.type === 'richText' &&\n data[field.name] &&\n !Array.isArray(data[field.name]) &&\n 'root' in (data[field.name] as Record<string, unknown>)\n ) {\n // Lexical richText\n const editor: LexicalRichTextAdapter = field.editor as LexicalRichTextAdapter\n if (editor && typeof editor === 'object') {\n if ('features' in editor && editor.features?.length) {\n // Load lexical editor into lexical, then save it immediately\n const editorState = data[field.name] as SerializedEditorState\n\n const headlessEditor = createHeadlessEditor({\n nodes: getEnabledNodes({\n editorConfig: editor.editorConfig,\n }),\n })\n headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState))\n\n // get editor state\n data[field.name] = headlessEditor.getEditorState().toJSON()\n\n found++\n }\n }\n }\n }\n\n return found\n}\n"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,UAAU,QAAQ;AAIlF,SAASC,eAAe,QAAQ;AAShC,OAAO,MAAMC,gCAAA,GAAmCA,CAAC;EAC/CC,IA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IAAK,CAACG,KAAA,CAAMC,IAAI,CAAC,CAA+BQ,CAAA,CAAE;cACxDX,MAAA,EAAQY,KAAA,CAAMZ,MAAM;cACpBC;YACF;UACF;QACF;MACF;MAEA,IAAIC,KAAA,CAAME,IAAI,KAAK,SAAS;QACxBL,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC,CAA+BG,OAAO,CAAC,CAACW,CAAA,EAAGN,CAAA;UAC3DV,KAAA,IAASH,gCAAA,CAAiC;YACxCC,IAAA,EAAMA,IAAK,CAACG,KAAA,CAAMC,IAAI,CAAC,CAA+BQ,CAAA,CAAE;YACxDX,MAAA,EAAQE,KAAA,CAAMF,MAAM;YACpBC;UACF;QACF;MACF;IACF;IAEA,IACEC,KAAA,CAAME,IAAI,KAAK,cACfL,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC,IAChB,CAACK,KAAA,CAAMC,OAAO,CAACV,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC,KAC/B,UAAWJ,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC,EAC3B;MACA;MACA,MAAMe,MAAA,GAAiChB,KAAA,CAAMgB,MAAM;MACnD,IAAIA,MAAA,IAAU,OAAOA,MAAA,KAAW,UAAU;QACxC,IAAI,cAAcA,MAAA,IAAUA,MAAA,CAAOC,QAAQ,EAAEC,MAAA,EAAQ;UACnD;UACA,MAAMC,WAAA,GAActB,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC;UAEpC,MAAMmB,cAAA,GAAiB9B,oBAAA,CAAqB;YAC1C+B,KAAA,EAAO1B,eAAA,CAAgB;cACrB2B,YAAA,EAAcN,MAAA,CAAOM;YACvB;UACF;UACAF,cAAA,CAAeG,
|
|
1
|
+
{"version":3,"file":"upgradeDocumentFieldsRecursively.js","names":["createHeadlessEditor","fieldAffectsData","fieldHasSubFields","fieldIsArrayType","tabHasName","getEnabledNodes","upgradeDocumentFieldsRecursively","data","fields","found","field","name","type","tabs","forEach","tab","Array","isArray","row","i","block","blocks","find","slug","blockType","_","editor","features","length","editorState","headlessEditor","nodes","editorConfig","update","setEditorState","parseEditorState","discrete","getEditorState","toJSON"],"sources":["../../../src/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.ts"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { Field } from 'payload'\n\nimport { createHeadlessEditor } from '@lexical/headless'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsArrayType, tabHasName } from 'payload/shared'\n\nimport type { LexicalRichTextAdapter } from '../../types.js'\n\nimport { getEnabledNodes } from '../../lexical/nodes/index.js'\n\ntype NestedRichTextFieldsArgs = {\n data: Record<string, unknown>\n\n fields: Field[]\n found: number\n}\n\nexport const upgradeDocumentFieldsRecursively = ({\n data,\n fields,\n found,\n}: NestedRichTextFieldsArgs): number => {\n for (const field of fields) {\n if (fieldHasSubFields(field) && !fieldIsArrayType(field)) {\n if (fieldAffectsData(field) && typeof data[field.name] === 'object') {\n found += upgradeDocumentFieldsRecursively({\n data: data[field.name] as Record<string, unknown>,\n fields: field.fields,\n found,\n })\n } else {\n found += upgradeDocumentFieldsRecursively({\n data,\n fields: field.fields,\n found,\n })\n }\n } else if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n found += upgradeDocumentFieldsRecursively({\n data: (tabHasName(tab) ? data[tab.name] : data) as Record<string, unknown>,\n fields: tab.fields,\n found,\n })\n })\n } else if (Array.isArray(data[field.name])) {\n if (field.type === 'blocks') {\n ;(data[field.name] as Record<string, unknown>[]).forEach((row, i) => {\n const block = field.blocks.find(({ slug }) => slug === row?.blockType)\n if (block) {\n found += upgradeDocumentFieldsRecursively({\n data: (data[field.name] as Record<string, unknown>[])[i],\n fields: block.fields,\n found,\n })\n }\n })\n }\n\n if (field.type === 'array') {\n ;(data[field.name] as Record<string, unknown>[]).forEach((_, i) => {\n found += upgradeDocumentFieldsRecursively({\n data: (data[field.name] as Record<string, unknown>[])[i],\n fields: field.fields,\n found,\n })\n })\n }\n }\n\n if (\n field.type === 'richText' &&\n data[field.name] &&\n !Array.isArray(data[field.name]) &&\n 'root' in (data[field.name] as Record<string, unknown>)\n ) {\n // Lexical richText\n const editor: LexicalRichTextAdapter = field.editor as LexicalRichTextAdapter\n if (editor && typeof editor === 'object') {\n if ('features' in editor && editor.features?.length) {\n // Load lexical editor into lexical, then save it immediately\n const editorState = data[field.name] as SerializedEditorState\n\n const headlessEditor = createHeadlessEditor({\n nodes: getEnabledNodes({\n editorConfig: editor.editorConfig,\n }),\n })\n headlessEditor.update(\n () => {\n headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState))\n },\n { discrete: true },\n )\n\n // get editor state\n data[field.name] = headlessEditor.getEditorState().toJSON()\n\n found++\n }\n }\n }\n }\n\n return found\n}\n"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,UAAU,QAAQ;AAIlF,SAASC,eAAe,QAAQ;AAShC,OAAO,MAAMC,gCAAA,GAAmCA,CAAC;EAC/CC,IAAI;EACJC,MAAM;EACNC;AAAK,CACoB;EACzB,KAAK,MAAMC,KAAA,IAASF,MAAA,EAAQ;IAC1B,IAAIN,iBAAA,CAAkBQ,KAAA,KAAU,CAACP,gBAAA,CAAiBO,KAAA,GAAQ;MACxD,IAAIT,gBAAA,CAAiBS,KAAA,KAAU,OAAOH,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC,KAAK,UAAU;QACnEF,KAAA,IAASH,gCAAA,CAAiC;UACxCC,IAAA,EAAMA,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC;UACtBH,MAAA,EAAQE,KAAA,CAAMF,MAAM;UACpBC;QACF;MACF,OAAO;QACLA,KAAA,IAASH,gCAAA,CAAiC;UACxCC,IAAA;UACAC,MAAA,EAAQE,KAAA,CAAMF,MAAM;UACpBC;QACF;MACF;IACF,OAAO,IAAIC,KAAA,CAAME,IAAI,KAAK,QAAQ;MAChCF,KAAA,CAAMG,IAAI,CAACC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AAC,KAC/B,UAAWJ,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC,EAC3B;MACA;MACA,MAAMe,MAAA,GAAiChB,KAAA,CAAMgB,MAAM;MACnD,IAAIA,MAAA,IAAU,OAAOA,MAAA,KAAW,UAAU;QACxC,IAAI,cAAcA,MAAA,IAAUA,MAAA,CAAOC,QAAQ,EAAEC,MAAA,EAAQ;UACnD;UACA,MAAMC,WAAA,GAActB,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC;UAEpC,MAAMmB,cAAA,GAAiB9B,oBAAA,CAAqB;YAC1C+B,KAAA,EAAO1B,eAAA,CAAgB;cACrB2B,YAAA,EAAcN,MAAA,CAAOM;YACvB;UACF;UACAF,cAAA,CAAeG,MAAM,CACnB;YACEH,cAAA,CAAeI,cAAc,CAACJ,cAAA,CAAeK,gBAAgB,CAACN,WAAA;UAChE,GACA;YAAEO,QAAA,EAAU;UAAK;UAGnB;UACA7B,IAAI,CAACG,KAAA,CAAMC,IAAI,CAAC,GAAGmB,cAAA,CAAeO,cAAc,GAAGC,MAAM;UAEzD7B,KAAA;QACF;MACF;IACF;EACF;EAEA,OAAOA,KAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLexicalFeature.d.ts","sourceRoot":"","sources":["../../src/utilities/useLexicalFeature.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"useLexicalFeature.d.ts","sourceRoot":"","sources":["../../src/utilities/useLexicalFeature.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIvE,eAAO,MAAM,iBAAiB,GAAI,kBAAkB,cACtC,MAAM,WACT,qBAAqB,CAAC,kBAAkB,CAAC,SAenD,CAAA"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useAddClientFunction
|
|
3
|
+
import { useAddClientFunction } from '@payloadcms/ui';
|
|
4
|
+
import { useEditorConfigContext } from '../lexical/config/client/EditorConfigProvider.js';
|
|
4
5
|
export const useLexicalFeature = (featureKey, feature) => {
|
|
6
|
+
const {
|
|
7
|
+
fieldProps: t0
|
|
8
|
+
} = useEditorConfigContext();
|
|
5
9
|
const {
|
|
6
10
|
schemaPath: schemaPathFromFieldProps
|
|
7
|
-
} =
|
|
8
|
-
const tableCell =
|
|
9
|
-
|
|
11
|
+
} = t0;
|
|
12
|
+
const tableCell = {
|
|
13
|
+
cellProps: {
|
|
14
|
+
schemaPath: []
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const schemaPathFromCellProps = tableCell?.cellProps?.schemaPath ? tableCell?.cellProps?.schemaPath.join(".") : null;
|
|
10
18
|
const schemaPath = schemaPathFromCellProps || schemaPathFromFieldProps;
|
|
11
19
|
useAddClientFunction(`lexicalFeature.${schemaPath}.${featureKey}`, feature);
|
|
12
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLexicalFeature.js","names":["useAddClientFunction","
|
|
1
|
+
{"version":3,"file":"useLexicalFeature.js","names":["useAddClientFunction","useEditorConfigContext","useLexicalFeature","featureKey","feature","fieldProps","t0","schemaPath","schemaPathFromFieldProps","tableCell","cellProps","schemaPathFromCellProps","join"],"sources":["../../src/utilities/useLexicalFeature.tsx"],"sourcesContent":["'use client'\n\nimport { useAddClientFunction } from '@payloadcms/ui'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\n\nimport { useEditorConfigContext } from '../lexical/config/client/EditorConfigProvider.js'\n\nexport const useLexicalFeature = <ClientFeatureProps,>(\n featureKey: string,\n feature: FeatureProviderClient<ClientFeatureProps>,\n) => {\n const {\n fieldProps: { schemaPath: schemaPathFromFieldProps },\n } = useEditorConfigContext()\n const tableCell = { cellProps: { schemaPath: [] } } // TODO: get tableCell from props\n // const tableCell = useTableCell()\n\n const schemaPathFromCellProps = tableCell?.cellProps?.schemaPath\n ? tableCell?.cellProps?.schemaPath.join('.')\n : null\n\n const schemaPath = schemaPathFromCellProps || schemaPathFromFieldProps // schemaPathFromCellProps needs to have priority, as there can be cells within fields (e.g. list drawers) and the cell schemaPath needs to be used there - not the parent field schemaPath. There cannot be fields within cells.\n\n useAddClientFunction(`lexicalFeature.${schemaPath}.${featureKey}`, feature)\n}\n"],"mappings":"AAAA;;AAEA,SAASA,oBAAoB,QAAQ;AAIrC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,iBAAA,GAAoBA,CAAAC,UAAA,EAAAC,OAAA;EAI/B;IAAAC,UAAA,EAAAC;EAAA,IAEIL,sBAAA;EADU;IAAAM,UAAA,EAAAC;EAAA,IAAAF,EAAwC;EAEtD,MAAAG,SAAA;IAAAC,SAAA;MAAAH,UAAA;IAAA;EAAA;EAGA,MAAAI,uBAAA,GAAgCF,SAAA,EAAAC,SAAA,EAAAH,UAAA,GAC5BE,SAAA,EAAAC,SAAA,EAAAH,UAAA,CAAAK,IAAA,CAAsC,WACtC;EAEJ,MAAAL,UAAA,GAAmBI,uBAAA,IAA2BH,wBAAA;EAE9CR,oBAAA,CAAqB,kBAAkBO,UAAA,IAAcJ,UAAA,EAAY,EAAEC,OAAA;AAAA,CACrE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAA2B,MAAM,SAAS,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAI7E,eAAO,MAAM,mBAAmB,sBAE7B;IACD,YAAY,EAAE,2BAA2B,CAAA;CAC1C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAA2B,MAAM,SAAS,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAI7E,eAAO,MAAM,mBAAmB,sBAE7B;IACD,YAAY,EAAE,2BAA2B,CAAA;CAC1C,8GAuDA,CAAA"}
|
package/dist/validate/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export const richTextValidateHOC = ({
|
|
|
15
15
|
if (value?.root?.children?.length === 1) {
|
|
16
16
|
if (value?.root?.children[0]?.type === 'paragraph') {
|
|
17
17
|
const paragraphNode = value?.root?.children[0];
|
|
18
|
-
if (paragraphNode?.children?.length === 0) {
|
|
18
|
+
if (!paragraphNode?.children || paragraphNode?.children?.length === 0) {
|
|
19
19
|
hasOnlyEmptyParagraph = true;
|
|
20
20
|
} else if (paragraphNode?.children?.length === 1) {
|
|
21
21
|
const paragraphNodeChild = paragraphNode?.children[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["validateNodes","richTextValidateHOC","editorConfig","richTextValidate","value","options","req","t","required","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild","rootNodes","Array","isArray","nodes","nodeValidations","features","validations","validation"],"sources":["../../src/validate/index.ts"],"sourcesContent":["import type { SerializedEditorState, SerializedParagraphNode } from 'lexical'\nimport type { RichTextField, Validate } from 'payload'\n\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\n\nimport { validateNodes } from './validateNodes.js'\n\nexport const richTextValidateHOC = ({\n editorConfig,\n}: {\n editorConfig: SanitizedServerEditorConfig\n}) => {\n const richTextValidate: Validate<SerializedEditorState, unknown, unknown, RichTextField> = async (\n value,\n options,\n ) => {\n const {\n req: { t },\n required,\n } = options\n\n if (required) {\n const hasChildren = !!value?.root?.children?.length\n\n let hasOnlyEmptyParagraph = false\n if (value?.root?.children?.length === 1) {\n if (value?.root?.children[0]?.type === 'paragraph') {\n const paragraphNode = value?.root?.children[0] as SerializedParagraphNode\n if (paragraphNode?.children?.length === 0) {\n hasOnlyEmptyParagraph = true\n } else if (paragraphNode?.children?.length === 1) {\n const paragraphNodeChild = paragraphNode?.children[0]\n if (paragraphNodeChild.type === 'text') {\n if (!paragraphNodeChild?.['text']?.length) {\n hasOnlyEmptyParagraph = true\n }\n }\n }\n }\n }\n\n if (!hasChildren || hasOnlyEmptyParagraph) {\n return t('validation:required')\n }\n }\n\n // Traverse through nodes and validate them. Just like a node can hook into the population process (e.g. link or relationship nodes),\n // they can also hook into the validation process. E.g. a block node probably has fields with validation rules.\n\n const rootNodes = value?.root?.children\n if (rootNodes && Array.isArray(rootNodes) && rootNodes?.length) {\n return await validateNodes({\n nodes: rootNodes,\n nodeValidations: editorConfig.features.validations,\n validation: {\n options,\n value,\n },\n })\n }\n\n return true\n }\n\n return richTextValidate\n}\n"],"mappings":"AAKA,SAASA,aAAa,QAAQ;AAE9B,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC;AAAY,CAGb;EACC,MAAMC,gBAAA,GAAqF,MAAAA,CACzFC,KAAA,EACAC,OAAA;IAEA,MAAM;MACJC,GAAA,EAAK;QAAEC;MAAC,CAAE;MACVC;IAAQ,CACT,GAAGH,OAAA;IAEJ,IAAIG,QAAA,EAAU;MACZ,MAAMC,WAAA,GAAc,CAAC,CAACL,KAAA,EAAOM,IAAA,EAAMC,QAAA,EAAUC,MAAA;MAE7C,IAAIC,qBAAA,GAAwB;MAC5B,IAAIT,KAAA,EAAOM,IAAA,EAAMC,QAAA,EAAUC,MAAA,KAAW,GAAG;QACvC,IAAIR,KAAA,EAAOM,IAAA,EAAMC,QAAQ,CAAC,EAAE,EAAEG,IAAA,KAAS,aAAa;UAClD,MAAMC,aAAA,GAAgBX,KAAA,EAAOM,IAAA,EAAMC,QAAQ,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"index.js","names":["validateNodes","richTextValidateHOC","editorConfig","richTextValidate","value","options","req","t","required","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild","rootNodes","Array","isArray","nodes","nodeValidations","features","validations","validation"],"sources":["../../src/validate/index.ts"],"sourcesContent":["import type { SerializedEditorState, SerializedParagraphNode } from 'lexical'\nimport type { RichTextField, Validate } from 'payload'\n\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\n\nimport { validateNodes } from './validateNodes.js'\n\nexport const richTextValidateHOC = ({\n editorConfig,\n}: {\n editorConfig: SanitizedServerEditorConfig\n}) => {\n const richTextValidate: Validate<SerializedEditorState, unknown, unknown, RichTextField> = async (\n value,\n options,\n ) => {\n const {\n req: { t },\n required,\n } = options\n\n if (required) {\n const hasChildren = !!value?.root?.children?.length\n\n let hasOnlyEmptyParagraph = false\n if (value?.root?.children?.length === 1) {\n if (value?.root?.children[0]?.type === 'paragraph') {\n const paragraphNode = value?.root?.children[0] as SerializedParagraphNode\n\n if (!paragraphNode?.children || paragraphNode?.children?.length === 0) {\n hasOnlyEmptyParagraph = true\n } else if (paragraphNode?.children?.length === 1) {\n const paragraphNodeChild = paragraphNode?.children[0]\n if (paragraphNodeChild.type === 'text') {\n if (!paragraphNodeChild?.['text']?.length) {\n hasOnlyEmptyParagraph = true\n }\n }\n }\n }\n }\n\n if (!hasChildren || hasOnlyEmptyParagraph) {\n return t('validation:required')\n }\n }\n\n // Traverse through nodes and validate them. Just like a node can hook into the population process (e.g. link or relationship nodes),\n // they can also hook into the validation process. E.g. a block node probably has fields with validation rules.\n\n const rootNodes = value?.root?.children\n if (rootNodes && Array.isArray(rootNodes) && rootNodes?.length) {\n return await validateNodes({\n nodes: rootNodes,\n nodeValidations: editorConfig.features.validations,\n validation: {\n options,\n value,\n },\n })\n }\n\n return true\n }\n\n return richTextValidate\n}\n"],"mappings":"AAKA,SAASA,aAAa,QAAQ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Z,aAAA,CAAc;QACzBoB,KAAA,EAAOH,SAAA;QACPI,eAAA,EAAiBnB,YAAA,CAAaoB,QAAQ,CAACC,WAAW;QAClDC,UAAA,EAAY;UACVnB,OAAA;UACAD;QACF;MACF;IACF;IAEA,OAAO;EACT;EAEA,OAAOD,gBAAA;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.129",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
13
|
+
"maintainers": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Payload",
|
|
16
|
+
"email": "info@payloadcms.com",
|
|
17
|
+
"url": "https://payloadcms.com"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
13
20
|
"sideEffects": false,
|
|
14
21
|
"type": "module",
|
|
15
22
|
"exports": {
|
|
@@ -23,15 +30,15 @@
|
|
|
23
30
|
"types": "./dist/exports/client/index.d.ts",
|
|
24
31
|
"default": "./dist/exports/client/index.js"
|
|
25
32
|
},
|
|
33
|
+
"./rsc": {
|
|
34
|
+
"import": "./dist/exports/server/rsc.js",
|
|
35
|
+
"types": "./dist/exports/server/rsc.d.ts",
|
|
36
|
+
"default": "./dist/exports/server/rsc.js"
|
|
37
|
+
},
|
|
26
38
|
"./migrate": {
|
|
27
39
|
"import": "./dist/exports/server/migrate.js",
|
|
28
40
|
"types": "./dist/exports/server/migrate.d.ts",
|
|
29
41
|
"default": "./dist/exports/server/migrate.js"
|
|
30
|
-
},
|
|
31
|
-
"./generateComponentMap": {
|
|
32
|
-
"import": "./dist/utilities/generateComponentMap.js",
|
|
33
|
-
"types": "./dist/utilities/generateComponentMap.d.ts",
|
|
34
|
-
"default": "./dist/utilities/generateComponentMap.js"
|
|
35
42
|
}
|
|
36
43
|
},
|
|
37
44
|
"main": "./dist/index.js",
|
|
@@ -40,24 +47,25 @@
|
|
|
40
47
|
"dist"
|
|
41
48
|
],
|
|
42
49
|
"dependencies": {
|
|
43
|
-
"@lexical/headless": "0.
|
|
44
|
-
"@lexical/link": "0.
|
|
45
|
-
"@lexical/list": "0.
|
|
46
|
-
"@lexical/mark": "0.
|
|
47
|
-
"@lexical/markdown": "0.
|
|
48
|
-
"@lexical/react": "0.
|
|
49
|
-
"@lexical/rich-text": "0.
|
|
50
|
-
"@lexical/selection": "0.
|
|
51
|
-
"@lexical/utils": "0.
|
|
50
|
+
"@lexical/headless": "0.20.0",
|
|
51
|
+
"@lexical/link": "0.20.0",
|
|
52
|
+
"@lexical/list": "0.20.0",
|
|
53
|
+
"@lexical/mark": "0.20.0",
|
|
54
|
+
"@lexical/markdown": "0.20.0",
|
|
55
|
+
"@lexical/react": "0.20.0",
|
|
56
|
+
"@lexical/rich-text": "0.20.0",
|
|
57
|
+
"@lexical/selection": "0.20.0",
|
|
58
|
+
"@lexical/utils": "0.20.0",
|
|
52
59
|
"@types/uuid": "10.0.0",
|
|
53
60
|
"bson-objectid": "2.0.4",
|
|
54
61
|
"dequal": "2.0.3",
|
|
55
62
|
"escape-html": "1.0.3",
|
|
56
|
-
"lexical": "0.
|
|
63
|
+
"lexical": "0.20.0",
|
|
57
64
|
"react-error-boundary": "4.0.13",
|
|
65
|
+
"ts-essentials": "10.0.3",
|
|
58
66
|
"uuid": "10.0.0",
|
|
59
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
60
|
-
"@payloadcms/ui": "3.0.0-beta.
|
|
67
|
+
"@payloadcms/translations": "3.0.0-beta.129",
|
|
68
|
+
"@payloadcms/ui": "3.0.0-beta.129"
|
|
61
69
|
},
|
|
62
70
|
"devDependencies": {
|
|
63
71
|
"@babel/cli": "^7.24.5",
|
|
@@ -65,39 +73,39 @@
|
|
|
65
73
|
"@babel/preset-env": "^7.24.5",
|
|
66
74
|
"@babel/preset-react": "^7.24.1",
|
|
67
75
|
"@babel/preset-typescript": "^7.24.1",
|
|
68
|
-
"@lexical/eslint-plugin": "0.
|
|
76
|
+
"@lexical/eslint-plugin": "0.20.0",
|
|
69
77
|
"@types/escape-html": "1.0.4",
|
|
70
78
|
"@types/json-schema": "7.0.15",
|
|
71
79
|
"@types/node": "22.5.4",
|
|
72
80
|
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
73
81
|
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
|
|
74
|
-
"babel-plugin-react-compiler": "0.0.0-experimental-
|
|
82
|
+
"babel-plugin-react-compiler": "0.0.0-experimental-24ec0eb-20240918",
|
|
75
83
|
"babel-plugin-transform-remove-imports": "^1.8.0",
|
|
76
84
|
"esbuild": "0.23.1",
|
|
77
85
|
"esbuild-sass-plugin": "3.3.1",
|
|
78
|
-
"eslint-plugin-react-compiler": "
|
|
86
|
+
"eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
79
87
|
"swc-plugin-transform-remove-imports": "1.15.0",
|
|
80
88
|
"@payloadcms/eslint-config": "3.0.0-beta.112",
|
|
81
|
-
"payload": "3.0.0-beta.
|
|
89
|
+
"payload": "3.0.0-beta.129"
|
|
82
90
|
},
|
|
83
91
|
"peerDependencies": {
|
|
84
92
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
85
93
|
"@faceless-ui/scroll-info": "2.0.0-beta.0",
|
|
86
|
-
"@lexical/headless": "0.
|
|
87
|
-
"@lexical/link": "0.
|
|
88
|
-
"@lexical/list": "0.
|
|
89
|
-
"@lexical/mark": "0.
|
|
90
|
-
"@lexical/markdown": "0.
|
|
91
|
-
"@lexical/react": "0.
|
|
92
|
-
"@lexical/rich-text": "0.
|
|
93
|
-
"@lexical/selection": "0.
|
|
94
|
-
"@lexical/table": "0.
|
|
95
|
-
"@lexical/utils": "0.
|
|
96
|
-
"lexical": "0.
|
|
94
|
+
"@lexical/headless": "0.20.0",
|
|
95
|
+
"@lexical/link": "0.20.0",
|
|
96
|
+
"@lexical/list": "0.20.0",
|
|
97
|
+
"@lexical/mark": "0.20.0",
|
|
98
|
+
"@lexical/markdown": "0.20.0",
|
|
99
|
+
"@lexical/react": "0.20.0",
|
|
100
|
+
"@lexical/rich-text": "0.20.0",
|
|
101
|
+
"@lexical/selection": "0.20.0",
|
|
102
|
+
"@lexical/table": "0.20.0",
|
|
103
|
+
"@lexical/utils": "0.20.0",
|
|
104
|
+
"lexical": "0.20.0",
|
|
97
105
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
98
106
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
99
|
-
"@payloadcms/next": "3.0.0-beta.
|
|
100
|
-
"payload": "3.0.0-beta.
|
|
107
|
+
"@payloadcms/next": "3.0.0-beta.129",
|
|
108
|
+
"payload": "3.0.0-beta.129"
|
|
101
109
|
},
|
|
102
110
|
"engines": {
|
|
103
111
|
"node": "^18.20.2 || >=20.9.0"
|
package/dist/cell/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EditorConfig as LexicalEditorConfig } from 'lexical';
|
|
2
|
-
import type { CellComponentProps, RichTextFieldClient } from 'payload';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import type { LexicalFieldAdminProps } from '../types.js';
|
|
5
|
-
export declare const RichTextCell: React.FC<{
|
|
6
|
-
readonly admin?: LexicalFieldAdminProps;
|
|
7
|
-
readonly lexicalEditorConfig: LexicalEditorConfig;
|
|
8
|
-
} & CellComponentProps<RichTextFieldClient>>;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/cell/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cell/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAOtE,OAAO,KAA6B,MAAM,OAAO,CAAA;AAIjD,OAAO,KAAK,EAAqC,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAS5F,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CACjC;IACE,QAAQ,CAAC,KAAK,CAAC,EAAE,sBAAsB,CAAA;IACvC,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAA;CAClD,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAuH5C,CAAA"}
|
package/dist/cell/index.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { createHeadlessEditor } from '@lexical/headless';
|
|
5
|
-
import { useConfig, useTableCell } from '@payloadcms/ui';
|
|
6
|
-
import { formatAdminURL } from '@payloadcms/ui/shared';
|
|
7
|
-
import { $getRoot } from 'lexical';
|
|
8
|
-
import LinkImport from 'next/link.js';
|
|
9
|
-
import React, { useEffect, useMemo } from 'react';
|
|
10
|
-
import { defaultEditorLexicalConfig } from '../lexical/config/client/default.js';
|
|
11
|
-
import { loadClientFeatures } from '../lexical/config/client/loader.js';
|
|
12
|
-
import { sanitizeClientEditorConfig } from '../lexical/config/client/sanitize.js';
|
|
13
|
-
import { getEnabledNodes } from '../lexical/nodes/index.js';
|
|
14
|
-
const Link = LinkImport.default || LinkImport;
|
|
15
|
-
export const RichTextCell = props => {
|
|
16
|
-
const {
|
|
17
|
-
admin,
|
|
18
|
-
field: {
|
|
19
|
-
richTextComponentMap
|
|
20
|
-
},
|
|
21
|
-
lexicalEditorConfig
|
|
22
|
-
} = props;
|
|
23
|
-
const [preview, setPreview] = React.useState('Loading...');
|
|
24
|
-
const {
|
|
25
|
-
cellData,
|
|
26
|
-
cellProps,
|
|
27
|
-
columnIndex,
|
|
28
|
-
customCellContext,
|
|
29
|
-
rowData
|
|
30
|
-
} = useTableCell();
|
|
31
|
-
const {
|
|
32
|
-
config: {
|
|
33
|
-
routes: {
|
|
34
|
-
admin: adminRoute
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
} = useConfig();
|
|
38
|
-
const {
|
|
39
|
-
link
|
|
40
|
-
} = cellProps || {};
|
|
41
|
-
let WrapElement = 'span';
|
|
42
|
-
const wrapElementProps = {};
|
|
43
|
-
const isLink = link !== undefined ? link : columnIndex === 0;
|
|
44
|
-
if (isLink) {
|
|
45
|
-
WrapElement = Link;
|
|
46
|
-
wrapElementProps.href = customCellContext?.collectionSlug ? formatAdminURL({
|
|
47
|
-
adminRoute,
|
|
48
|
-
path: `/collections/${customCellContext?.collectionSlug}/${rowData.id}`
|
|
49
|
-
}) : '';
|
|
50
|
-
}
|
|
51
|
-
const finalSanitizedEditorConfig = useMemo(() => {
|
|
52
|
-
const clientFeatures = richTextComponentMap?.get('features');
|
|
53
|
-
const featureProvidersLocal = [];
|
|
54
|
-
for (const clientFeature of clientFeatures) {
|
|
55
|
-
featureProvidersLocal.push(clientFeature.clientFeature(clientFeature.clientFeatureProps));
|
|
56
|
-
}
|
|
57
|
-
const finalLexicalEditorConfig = lexicalEditorConfig ? lexicalEditorConfig : defaultEditorLexicalConfig;
|
|
58
|
-
const resolvedClientFeatures = loadClientFeatures({
|
|
59
|
-
unSanitizedEditorConfig: {
|
|
60
|
-
features: featureProvidersLocal,
|
|
61
|
-
lexical: finalLexicalEditorConfig
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return sanitizeClientEditorConfig(resolvedClientFeatures, finalLexicalEditorConfig);
|
|
65
|
-
}, [richTextComponentMap, lexicalEditorConfig]);
|
|
66
|
-
finalSanitizedEditorConfig.admin = admin;
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
let dataToUse = cellData;
|
|
69
|
-
if (dataToUse == null || !finalSanitizedEditorConfig) {
|
|
70
|
-
setPreview('');
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// Transform data through load hooks
|
|
74
|
-
if (finalSanitizedEditorConfig?.features?.hooks?.load?.length) {
|
|
75
|
-
finalSanitizedEditorConfig.features.hooks.load.forEach(hook => {
|
|
76
|
-
dataToUse = hook({
|
|
77
|
-
incomingEditorState: dataToUse
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (!dataToUse || typeof dataToUse !== 'object') {
|
|
82
|
-
setPreview('');
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
// If data is from Slate and not Lexical
|
|
86
|
-
if (Array.isArray(dataToUse) && !('root' in dataToUse)) {
|
|
87
|
-
setPreview('');
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
// If data is from payload-plugin-lexical
|
|
91
|
-
if ('jsonContent' in dataToUse) {
|
|
92
|
-
setPreview('');
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
// initialize headless editor
|
|
96
|
-
const headlessEditor = createHeadlessEditor({
|
|
97
|
-
namespace: finalSanitizedEditorConfig.lexical.namespace,
|
|
98
|
-
nodes: getEnabledNodes({
|
|
99
|
-
editorConfig: finalSanitizedEditorConfig
|
|
100
|
-
}),
|
|
101
|
-
theme: finalSanitizedEditorConfig.lexical.theme
|
|
102
|
-
});
|
|
103
|
-
headlessEditor.setEditorState(headlessEditor.parseEditorState(dataToUse));
|
|
104
|
-
const textContent = headlessEditor.getEditorState().read(() => {
|
|
105
|
-
return $getRoot().getTextContent();
|
|
106
|
-
}) || '';
|
|
107
|
-
// Limiting the number of characters shown is done in a CSS rule
|
|
108
|
-
setPreview(textContent);
|
|
109
|
-
}, [cellData, finalSanitizedEditorConfig]);
|
|
110
|
-
if (isLink) {
|
|
111
|
-
return /*#__PURE__*/_jsx(WrapElement, {
|
|
112
|
-
...wrapElementProps,
|
|
113
|
-
children: preview
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
return /*#__PURE__*/_jsx("span", {
|
|
117
|
-
children: preview
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cell/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createHeadlessEditor","useConfig","useTableCell","formatAdminURL","$getRoot","LinkImport","React","useEffect","useMemo","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","getEnabledNodes","Link","default","RichTextCell","props","admin","field","richTextComponentMap","lexicalEditorConfig","preview","setPreview","useState","cellData","cellProps","columnIndex","customCellContext","rowData","config","routes","adminRoute","link","WrapElement","wrapElementProps","isLink","undefined","href","collectionSlug","path","id","finalSanitizedEditorConfig","clientFeatures","get","featureProvidersLocal","clientFeature","push","clientFeatureProps","finalLexicalEditorConfig","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","dataToUse","hooks","load","length","forEach","hook","incomingEditorState","Array","isArray","headlessEditor","namespace","nodes","editorConfig","theme","setEditorState","parseEditorState","textContent","getEditorState","read","getTextContent","_jsx"],"sources":["../../src/cell/index.tsx"],"sourcesContent":["'use client'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\nimport type { CellComponentProps, RichTextFieldClient } from 'payload'\n\nimport { createHeadlessEditor } from '@lexical/headless'\nimport { useConfig, useTableCell } from '@payloadcms/ui'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { $getRoot } from 'lexical'\nimport LinkImport from 'next/link.js'\nimport React, { useEffect, useMemo } from 'react'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { GeneratedFeatureProviderComponent, LexicalFieldAdminProps } from '../types.js'\n\nimport { defaultEditorLexicalConfig } from '../lexical/config/client/default.js'\nimport { loadClientFeatures } from '../lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from '../lexical/config/client/sanitize.js'\nimport { getEnabledNodes } from '../lexical/nodes/index.js'\n\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nexport const RichTextCell: React.FC<\n {\n readonly admin?: LexicalFieldAdminProps\n readonly lexicalEditorConfig: LexicalEditorConfig\n } & CellComponentProps<RichTextFieldClient>\n> = (props) => {\n const {\n admin,\n field: { richTextComponentMap },\n lexicalEditorConfig,\n } = props\n\n const [preview, setPreview] = React.useState('Loading...')\n\n const { cellData, cellProps, columnIndex, customCellContext, rowData } = useTableCell()\n\n const {\n config: {\n routes: { admin: adminRoute },\n },\n } = useConfig()\n\n const { link } = cellProps || {}\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n type?: 'button'\n } = {}\n\n const isLink = link !== undefined ? link : columnIndex === 0\n\n if (isLink) {\n WrapElement = Link\n wrapElementProps.href = customCellContext?.collectionSlug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${customCellContext?.collectionSlug}/${rowData.id}`,\n })\n : ''\n }\n\n const finalSanitizedEditorConfig = useMemo<SanitizedClientEditorConfig>(() => {\n const clientFeatures: GeneratedFeatureProviderComponent[] = richTextComponentMap?.get(\n 'features',\n ) as GeneratedFeatureProviderComponent[]\n\n const featureProvidersLocal: FeatureProviderClient<any, any>[] = []\n for (const clientFeature of clientFeatures) {\n featureProvidersLocal.push(clientFeature.clientFeature(clientFeature.clientFeatureProps))\n }\n\n const finalLexicalEditorConfig = lexicalEditorConfig\n ? lexicalEditorConfig\n : defaultEditorLexicalConfig\n\n const resolvedClientFeatures = loadClientFeatures({\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: finalLexicalEditorConfig,\n },\n })\n\n return sanitizeClientEditorConfig(resolvedClientFeatures, finalLexicalEditorConfig)\n }, [richTextComponentMap, lexicalEditorConfig])\n\n finalSanitizedEditorConfig.admin = admin\n\n useEffect(() => {\n let dataToUse = cellData\n if (dataToUse == null || !finalSanitizedEditorConfig) {\n setPreview('')\n return\n }\n\n // Transform data through load hooks\n if (finalSanitizedEditorConfig?.features?.hooks?.load?.length) {\n finalSanitizedEditorConfig.features.hooks.load.forEach((hook) => {\n dataToUse = hook({ incomingEditorState: dataToUse })\n })\n }\n\n if (!dataToUse || typeof dataToUse !== 'object') {\n setPreview('')\n return\n }\n\n // If data is from Slate and not Lexical\n if (Array.isArray(dataToUse) && !('root' in dataToUse)) {\n setPreview('')\n return\n }\n\n // If data is from payload-plugin-lexical\n if ('jsonContent' in dataToUse) {\n setPreview('')\n return\n }\n\n // initialize headless editor\n const headlessEditor = createHeadlessEditor({\n namespace: finalSanitizedEditorConfig.lexical.namespace,\n nodes: getEnabledNodes({ editorConfig: finalSanitizedEditorConfig }),\n theme: finalSanitizedEditorConfig.lexical.theme,\n })\n headlessEditor.setEditorState(headlessEditor.parseEditorState(dataToUse))\n\n const textContent =\n headlessEditor.getEditorState().read(() => {\n return $getRoot().getTextContent()\n }) || ''\n\n // Limiting the number of characters shown is done in a CSS rule\n setPreview(textContent)\n }, [cellData, finalSanitizedEditorConfig])\n\n if (isLink) {\n return <WrapElement {...wrapElementProps}>{preview}</WrapElement>\n }\n\n return <span>{preview}</span>\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,SAAS,EAAEC,YAAY,QAAQ;AACxC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,OAAOC,UAAA,MAAgB;AACvB,OAAOC,KAAA,IAASC,SAAS,EAAEC,OAAO,QAAQ;AAM1C,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,eAAe,QAAQ;AAEhC,MAAMC,IAAA,GAAQR,UAAA,CAAWS,OAAO,IAAIT,UAAA;AAEpC,OAAO,MAAMU,YAAA,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AAI,CAAC;MACnC,OAAOnE,QAAA,GAAWoE,cAAc;IAClC,MAAM;IAER;IACAlD,UAAA,CAAW+C,WAAA;EACb,GAAG,CAAC7C,QAAA,EAAUiB,0BAAA,CAA2B;EAEzC,IAAIN,MAAA,EAAQ;IACV,oBAAOsC,IAAA,CAACxC,WAAA;MAAa,GAAGC,gBAAgB;gBAAGb;;EAC7C;EAEA,oBAAOoD,IAAA,CAAC;cAAMpD;;AAChB","ignoreList":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as ue,b as H,c as B,e as pe,f as ge,g as he,h as ye}from"./chunk-IIWHHN4J.js";import{a as fe,b as R}from"./chunk-GD6LBQBJ.js";import{jsx as $,jsxs as ce}from"react/jsx-runtime";import{FieldDescription as Ut,FieldError as Vt,FieldLabel as qt,useEditDepth as Jt,useField as Qt,useFieldProps as Xt,withCondition as Zt}from"@payloadcms/ui";import{useCallback as eo}from"react";import{ErrorBoundary as to}from"react-error-boundary";import{jsx as I}from"react/jsx-runtime";import{LexicalComposer as Yt}from"@lexical/react/LexicalComposer.js";import*as qe from"react";import{useMemo as Ve}from"react";import{c as Bt}from"react/compiler-runtime";import{jsx as k,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as It}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as At}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Dt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Ft}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Ot}from"@lexical/react/LexicalRichTextPlugin.js";import{TabIndentationPlugin as _t}from"@lexical/react/LexicalTabIndentationPlugin.js";import{BLUR_COMMAND as $t,COMMAND_PRIORITY_LOW as Ge,FOCUS_COMMAND as Ht}from"lexical";import*as W from"react";import{useEffect as We,useState as Ye}from"react";import{jsx as xe}from"react/jsx-runtime";import"react";var F=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&xe(o.Component,{anchorElem:t,clientProps:e}):o.Component&&xe(o.Component,{clientProps:e});import{jsx as le}from"react/jsx-runtime";import{useLexicalComposerContext as rt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as it}from"lexical";import*as Ne from"react";import{useCallback as st,useEffect as Ce,useRef as lt,useState as at}from"react";import{createPortal as ct}from"react-dom";var j=(t,e,o,a,r=50,d=25)=>{let f=0;if(t&&!t.contains(a)){let{bottom:c,left:m,right:p,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,n=c+window.scrollY;if(o<s-d||o>n+d||e<m-r||e>p+r)return-1;(e<m||e>p)&&(f=e<m?e-m:e-p)}return f};import{$getNodeByKey as Z}from"lexical";function z(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let a=o.split(",").pop();return e.y=e.y-Number(a?.replace(")","")),e}function X(t){let e=(m,p)=>m?parseFloat(window.getComputedStyle(m)[p]):0,{marginBottom:o,marginTop:a}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),d=e(t.nextElementSibling,"marginTop"),f=Math.max(parseFloat(a),r);return{marginBottom:Math.max(parseFloat(o),d),marginTop:f}}import{$getRoot as Ze}from"lexical";function O(t){return t.getEditorState().read(()=>Ze().getChildrenKeys())}var et=1,tt=-1,Ee=0,L={props:null,result:null};function ot(t,e,o=20){let a=t.x-e.x,r=t.y-e.y;return a*a+r*r<=o*o}function K(t){let{anchorElem:e,cache_threshold:o=20,editor:a,fuzzy:r=!1,horizontalOffset:d=0,point:{x:f,y:c},startIndex:m=0,useEdgeAsDefault:p=!1}=t;if(o>0&&L.props&&L.result&&L.props.fuzzy===t.fuzzy&&L.props.horizontalOffset===t.horizontalOffset&&L.props.useEdgeAsDefault===t.useEdgeAsDefault&&ot(L.props.point,t.point,o))return L.result;let y=e.getBoundingClientRect(),s=O(a),n={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return a.getEditorState().read(()=>{if(p){let[h,l]=[a.getElementByKey(s[0]),a.getElementByKey(s[s.length-1])];if(h&&l){let[g,i]=[z(h),z(l)];if(c<g.top?(n.blockElem=h,n.distance=g.top-c,n.blockNode=Z(s[0]),n.foundAtIndex=0):c>i.bottom&&(n.distance=c-i.bottom,n.blockNode=Z(s[s.length-1]),n.blockElem=l,n.foundAtIndex=s.length-1),n?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let u=m,x=Ee;for(;u>=0&&u<s.length;){let h=s[u],l=a.getElementByKey(h);if(l===null)break;let g=new B(f+d,c),i=ye.fromDOMRect(z(l)),{marginBottom:E,marginTop:C}=X(l),P=i.generateNewRect({bottom:i.bottom+E,left:y.left,right:y.right,top:i.top-C}),{distance:N,isOnBottomSide:S,isOnTopSide:w}=P.distanceFromPoint(g);if(N===0){n.blockElem=l,n.blockNode=Z(h),n.foundAtIndex=u,n.distance=N,n.blockNode&&n.blockNode.getType()==="paragraph"&&n.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(n.blockElem=null,n.blockNode=null),n.isFoundNodeEmptyParagraph=!0);break}else r&&N<n.distance&&(n.blockElem=l,n.blockNode=Z(h),n.distance=N,n.foundAtIndex=u);x===Ee&&(w?x=tt:S?x=et:x=1/0),u+=x}}),L.props=t,L.result={blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph},{blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var nt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function be(t){if(!t||nt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function te(t,e,o,a=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),d=window.getComputedStyle(t),f=e.getBoundingClientRect(),c=o.getBoundingClientRect(),m;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))m=r.top+8-c.top;else{let s=be(t)?parseInt(d.lineHeight,10):0;m=r.top+(s-f.height)/2-c.top}let y=a;e.style.opacity="1",e.style.transform=`translate(${y}px, ${m}px)`}var dt="add-block-menu",oe=1/0;function mt(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function ut(t,e,o){let a=e.parentElement,{editorConfig:r}=R(),d=r?.admin?.hideGutter?-24:12,f=lt(null),[c,m]=at(null);Ce(()=>{function y(s){let n=s.target;if(!H(n))return;let u=j(a,s.pageX,s.pageY,n);if(u===-1){m(null);return}if(ee(n,dt))return;let x=O(t),{blockElem:h,blockNode:l,foundAtIndex:g}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-u,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:mt(x.length),useEdgeAsDefault:!1});oe=g,h&&l&&(c?.node!==l||c?.elem!==h)&&m({elem:h,node:l})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[a,e,t,c]),Ce(()=>{f.current&&c?.node&&te(c?.elem,f.current,e,d)},[e,c,d]);let p=st(y=>{let s=c;s?.node&&(t.update(()=>{let n=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(n=!1),!n){let u=it();s?.node.insertAfter(u),setTimeout(()=>{s={elem:t.getElementByKey(u.getKey()),node:u},m(s)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),s?.node&&"select"in s.node&&typeof s.node.select=="function"&&s.node.select()})},1),setTimeout(()=>{t.dispatchCommand(ge,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,c]);return ct(le(Ne.Fragment,{children:le("button",{className:"icon add-block-menu",onClick:y=>{p(y)},ref:f,type:"button",children:le("div",{className:o?"icon":""})})}),e)}function Pe({anchorElem:t=document.body}){let[e]=rt();return ut(e,t,e._editable)}import{jsx as ne,jsxs as pt}from"react/jsx-runtime";import{useLexicalComposerContext as gt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Re}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Te,$getNodeByKey as ht}from"lexical";import*as Be from"react";import{useEffect as ae,useRef as re,useState as Se}from"react";import{createPortal as yt}from"react-dom";var we=0,ft=-24;var _=0;function ke(t,e,o,a,r,d,f,c,m,p=!1){let{height:y,top:s}=a.getBoundingClientRect(),{top:n,width:u}=f.getBoundingClientRect(),{marginBottom:x,marginTop:h}=X(a),l=s,g=d>=s+y/2+window.scrollY,i=!1;if(r?.elem)if(a!==r?.elem)(g&&r?.elem&&r?.elem===a.nextElementSibling||!g&&r?.elem&&r?.elem===a.previousElementSibling)&&(_++,_<200&&(i=!0));else{_++;let N=r?.boundingBox?.y,S=a.getBoundingClientRect().y;(g===r?.isBelow&&N===S||_<200)&&(i=!1)}if(i)return{isBelow:g,willStayInSamePosition:i};p?l+=y/2:g?l+=y+x/2:l-=h/2;let E=0;p||(g?E=-we:E=we);let C=l-n+E,P=ft-e;return o.style.width=`calc(${u}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${P}px, calc(${C}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===a?g?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),_=0,{isBelow:g,willStayInSamePosition:i}}var xt="draggable-block-menu",ve="application/x-lexical-drag-block",V=1/0;function Le(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function Et(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Me(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function bt(t,e,o){let a=e.parentElement,r=re(null),d=re(null),f=re(null),c=re(!1),[m,p]=Se(null),[y,s]=Se(null),{editorConfig:n}=R(),u=n?.admin?.hideGutter?-44:-8;ae(()=>{function l(g){let i=g.target;if(!H(i))return;let E=j(a,g.pageX,g.pageY,i);if(E===-1){p(null);return}if(ee(i,xt))return;let C=O(t),{blockElem:P,foundAtIndex:N,isFoundNodeEmptyParagraph:S}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(g.x,g.y),startIndex:Le(C.length),useEdgeAsDefault:!1,verbose:!1});V=N,!(!P&&!S)&&m!==P&&p(P)}return document?.addEventListener("mousemove",l),()=>{document?.removeEventListener("mousemove",l)}},[a,e,t,m]),ae(()=>{r.current&&te(m,r.current,e,u)},[e,m,u]),ae(()=>{function l(i){if(!c.current)return!1;let[E]=Re(i);if(E)return!1;let{pageY:C,target:P}=i;if(!H(P))return!1;let N=j(a,i.pageX,i.pageY,P,100,50),S=O(t),{blockElem:w,foundAtIndex:Y,isFoundNodeEmptyParagraph:A}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-N,point:new B(i.x,i.y),startIndex:Le(S.length),useEdgeAsDefault:!0,verbose:!0});V=Y;let D=d.current;if(w===null||D===null)return!1;if(m!==w){let{isBelow:T,willStayInSamePosition:U}=ke(n?.admin?.hideGutter?"0px":"3rem",u+(n?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),D,w,y,C,e,i,f,A);i.preventDefault(),U||s({boundingBox:w.getBoundingClientRect(),elem:w,isBelow:T})}else y?.elem&&(Me(D,y.elem),s({boundingBox:w.getBoundingClientRect(),elem:w,isBelow:!1}));return!0}function g(i){if(!c.current)return!1;let[E]=Re(i);if(E)return!1;let{dataTransfer:C,pageY:P,target:N}=i,S=C?.getData(ve)||"";return t.update(()=>{let w=ht(S);if(!w||!H(N))return!1;let Y=j(a,i.pageX,i.pageY,N,100,50),{blockElem:A,isFoundNodeEmptyParagraph:D}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-Y,point:new B(i.x,i.y),useEdgeAsDefault:!0});if(!A)return!1;let T=Te(A);if(!T)return!1;if(T===w)return!0;let{height:U,top:se}=z(A),J=P>=se+U/2+window.scrollY;D?(T.insertBefore(w),T.remove()):J?T.insertAfter(w):T.insertBefore(w),m!==null&&p(null),document.querySelectorAll(".lexical-block-highlighter").forEach(v=>{v.remove()});let Q=t.getElementByKey(w.getKey());setTimeout(()=>{let v=Q?.getBoundingClientRect();if(!v)return;let b=document.createElement("div");b.className="lexical-block-highlighter",b.style.backgroundColor="var(--theme-elevation-1000",b.style.transition="opacity 0.5s ease-in-out",b.style.zIndex="1",b.style.pointerEvents="none",b.style.boxSizing="border-box",b.style.borderRadius="4px",b.style.position="absolute",document.body.appendChild(b),b.style.opacity="0.1",b.style.height=`${v.height+8}px`,b.style.width=`${v.width+8}px`,b.style.top=`${v.top+window.scrollY-4}px`,b.style.left=`${v.left-4}px`,setTimeout(()=>{b.style.opacity="0",setTimeout(()=>{b.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",l),document.addEventListener("drop",g),()=>{document.removeEventListener("dragover",l),document.removeEventListener("drop",g)}},[a,u,e,t,y,m,n?.admin?.hideGutter]);function x(l){let g=l.dataTransfer;if(!g||!m)return;Et(g,m);let i="";t.update(()=>{let E=Te(m);E&&(i=E.getKey())}),c.current=!0,g.setData(ve,i)}function h(){c.current=!1,y?.elem&&Me(d.current,y?.elem)}return yt(pt(Be.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:h,onDragStart:x,ref:r,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:d}),ne("div",{className:"debug-highlight",ref:f})]}),e)}function Ie({anchorElem:t=document.body}){let[e]=gt();return bt(e,t,e._editable)}import{c as Ct}from"react/compiler-runtime";import{jsx as Nt}from"react/jsx-runtime";import{MarkdownShortcutPlugin as Pt}from"@lexical/react/LexicalMarkdownShortcutPlugin.js";import"react";var Ae=()=>{let t=Ct(2),{editorConfig:e}=R(),o;return t[0]!==e.features.markdownTransformers?(o=Nt(Pt,{transformers:e.features.markdownTransformers}),t[0]=e.features.markdownTransformers,t[1]=o):o=t[1],o};import{jsx as G,jsxs as Oe}from"react/jsx-runtime";import{useLexicalComposerContext as kt}from"@lexical/react/LexicalComposerContext.js";import{useFieldProps as _e,useTranslation as $e}from"@payloadcms/ui";import{useCallback as Fe,useMemo as Rt,useState as Tt}from"react";import"react";import*as He from"react-dom";import{c as wt}from"react/compiler-runtime";import"react";function De(t,e){let o=wt(4),{maxLength:a,minLength:r}=e,d=a===void 0?75:a,f=r===void 0?1:r,c;return o[0]!==t||o[1]!==d||o[2]!==f?(c=m=>{let{query:p}=m,y="[^"+t+pe+"\\s]",n=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+d+"}))$").exec(p);if(n!==null){let u=n[1],x=n[3];if(x.length>=f)return{leadOffset:n.index+u.length,matchingString:x,replaceableString:n[2]}}return null},o[0]=t,o[1]=d,o[2]=f,o[3]=c):c=o[3],c}var M="slash-menu-popup";function St({isSelected:t,item:e,onClick:o,onMouseEnter:a}){let{field:{richTextComponentMap:r}}=R(),{schemaPath:d}=_e(),{i18n:f}=$e(),c=`${M}__item ${M}__item-${e.key}`;t&&(c+=` ${M}__item--selected`);let m=e.key;return e.label&&(m=typeof e.label=="function"?e.label({i18n:f,richTextComponentMap:r,schemaPath:d}):e.label),m.length>25&&(m=m.substring(0,25)+"..."),Oe("button",{"aria-selected":t,className:c,id:M+"__item-"+e.key,onClick:o,onMouseEnter:a,ref:p=>{e.ref={current:p}},role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&G(e.Icon,{}),G("span",{className:`${M}__item-text`,children:m})]},e.key)}function je({anchorElem:t=document.body}){let[e]=kt(),[o,a]=Tt(null),{editorConfig:r}=R(),{i18n:d}=$e(),{field:{richTextComponentMap:f}}=R(),{schemaPath:c}=_e(),m=De("/",{minLength:0}),p=Fe(()=>{let n=[];for(let u of r.features.slashMenu.dynamicGroups)if(o){let x=u({editor:e,queryString:o});n=n.concat(x)}return n},[e,o,r?.features]),y=Rt(()=>{let n=[];for(let u of r?.features.slashMenu.groups??[])n.push(u);if(o){n=n.map(x=>{let h=x.items.filter(l=>{let g=l.key;return l.label&&(g=typeof l.label=="function"?l.label({i18n:d,richTextComponentMap:f,schemaPath:c}):l.label),new RegExp(o,"gi").exec(g)?!0:l.keywords!=null?l.keywords.some(i=>new RegExp(o,"gi").exec(i)):!1});return h.length?{...x,items:h}:null}),n=n.filter(x=>x!=null);let u=p();for(let x of u){let h=n.find(l=>l.key===x.key);h?n=n.filter(l=>l.key!==x.key):h={...x,items:[]},h?.items?.length&&(h.items=h.items.concat(h.items)),n.push(h)}}return n},[p,o,r?.features,d]),s=Fe((n,u,x,h)=>{u&&e.update(()=>{u.remove()}),n.onSelect({editor:e,queryString:h}),x()},[e]);return G(he,{anchorElem:t,groups:y,menuRenderFn:(n,{selectedItemKey:u,selectItemAndCleanUp:x,setSelectedItemKey:h})=>n.current&&y.length?He.createPortal(G("div",{className:M,children:y.map(l=>{let g=l.key;return l.label&&f&&(g=typeof l.label=="function"?l.label({i18n:d,richTextComponentMap:f,schemaPath:c}):l.label),Oe("div",{className:`${M}__group ${M}__group-${l.key}`,children:[G("div",{className:`${M}__group-title`,children:g}),l.items.map((i,E)=>G(St,{index:E,isSelected:u===i.key,item:i,onClick:()=>{h(i.key),x(i)},onMouseEnter:()=>{h(i.key)}},i.key))]},l.key)})}),n.current):null,onQueryChange:a,onSelectItem:s,triggerFn:m})}import{c as vt}from"react/compiler-runtime";import{jsx as ze}from"react/jsx-runtime";import{ContentEditable as Lt}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Mt}from"@payloadcms/ui";import"react";function Ke(t){let e=vt(3),{className:o}=t,{t:a}=Mt(),r;return e[0]!==a||e[1]!==o?(r=ze(Lt,{"aria-placeholder":a("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:ze("p",{className:"editor-placeholder",children:a("lexical:general:placeholder")})}),e[0]=a,e[1]=o,e[2]=r):r=e[2],r}var Ue=t=>{let e=Bt(22),{editorConfig:o,editorContainerRef:a,onChange:r}=t,d=R(),[f]=It(),[c,m]=Ye(null),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=i=>{i!==null&&m(i)},e[0]=p):p=e[0];let y=p,s,n;e[1]!==d||e[2]!==f?(s=()=>{if(!d?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}d?.parentEditor?.uuid&&d.parentEditor?.registerChild(d.uuid,d);let i=()=>{d.focusEditor(d)},E=()=>{d.blurEditor(d)},C=f.registerCommand(Ht,()=>(i(),!0),Ge),P=f.registerCommand($t,()=>(E(),!0),Ge);return()=>{C(),P(),d.parentEditor?.unregisterChild?.(d.uuid)}},n=[f,d],e[1]=d,e[2]=f,e[3]=s,e[4]=n):(s=e[3],n=e[4]),We(s,n);let[u,x]=Ye(!1),h,l;e[5]!==u?(h=()=>{let i=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==u&&x(E)};return i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},l=[u],e[5]=u,e[6]=h,e[7]=l):(h=e[6],l=e[7]),We(h,l);let g;if(e[8]!==o.features||e[9]!==r||e[10]!==c||e[11]!==u||e[12]!==f||e[13]!==a){let i;e[15]!==r?(i=(C,P,N)=>{(!N.has("focus")||N.size>1)&&r?.(C,P,N)},e[15]=r,e[16]=i):i=e[16];let E;e[17]!==c||e[18]!==u||e[19]!==f||e[20]!==o?(E=c&&q(W.Fragment,{children:[!u&&f.isEditable()&&q(W.Fragment,{children:[k(Ie,{anchorElem:c}),k(Pe,{anchorElem:c})]}),o.features.plugins?.map(C=>{if(C.position==="floatingAnchorElem"&&!(C.desktopOnly===!0&&u))return k(F,{anchorElem:c,clientProps:C.clientProps,plugin:C},C.key)}),f.isEditable()&&k(W.Fragment,{children:k(je,{anchorElem:c})})]}),e[17]=c,e[18]=u,e[19]=f,e[20]=o,e[21]=E):E=e[21],g=q(W.Fragment,{children:[o.features.plugins?.map(jt),q("div",{className:"editor-container",ref:a,children:[o.features.plugins?.map(zt),k(Ot,{contentEditable:k("div",{className:"editor-scroller",children:k("div",{className:"editor",ref:y,children:k(Ke,{})})}),ErrorBoundary:At}),k(Ft,{ignoreSelectionChange:!0,onChange:i}),E,f.isEditable()&&q(W.Fragment,{children:[k(Dt,{}),o?.features?.markdownTransformers?.length>0&&k(Ae,{})]}),k(_t,{}),o.features.plugins?.map(Kt),o.features.plugins?.map(Gt)]}),o.features.plugins?.map(Wt)]}),e[8]=o.features,e[9]=r,e[10]=c,e[11]=u,e[12]=f,e[13]=a,e[14]=g}else g=e[14];return g};function jt(t){if(t.position==="aboveContainer")return k(F,{clientProps:t.clientProps,plugin:t},t.key)}function zt(t){if(t.position==="top")return k(F,{clientProps:t.clientProps,plugin:t},t.key)}function Kt(t){if(t.position==="normal")return k(F,{clientProps:t.clientProps,plugin:t},t.key)}function Gt(t){if(t.position==="bottom")return k(F,{clientProps:t.clientProps,plugin:t},t.key)}function Wt(t){if(t.position==="belowContainer")return k(F,{clientProps:t.clientProps,plugin:t},t.key)}var Je=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?I(o,{children:I(Je,{providers:e.slice(1),children:t})}):I(o,{children:t})},Qe=t=>{let{composerKey:e,editorConfig:o,field:a,onChange:r,readOnly:d,value:f}=t,c=R(),m=qe.useRef(null),p=Ve(()=>{let s=f;return o?.features?.hooks?.load?.length&&o.features.hooks.load.forEach(n=>{s=n({incomingEditorState:s})}),s},[o,f]),y=Ve(()=>{if(p&&typeof p!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(p));if(p&&Array.isArray(p)&&!("root"in p))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/beta/lexical/migration#migration-via-migration-script-recommended");if(p&&"jsonContent"in p)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/beta/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:d!==!0,editorState:p!=null?JSON.stringify(p):void 0,namespace:o.lexical.namespace,nodes:ue({editorConfig:o}),onError:s=>{throw s},theme:o.lexical.theme}},[o,p,d]);return y?I(Yt,{initialConfig:y,children:I(fe,{editorConfig:o,editorContainerRef:m,field:a,parentContext:c,children:I(Je,{providers:o.features.providers,children:I(Ue,{editorConfig:o,editorContainerRef:m,onChange:r})})})},e+y.editable):I("p",{children:"Loading..."})};import"./bundled.css";var ie="rich-text-lexical",oo=t=>{let{descriptionProps:e,editorConfig:o,errorProps:a,field:{name:r,_path:d,admin:{className:f,components:c,readOnly:m,style:p,width:y}={},required:s},field:n,labelProps:u,readOnly:x,validate:h}=t,l=c?.Description,g=c?.Error,i=c?.Label,E=x||m,C=Jt(),P=eo((v,b)=>{if(typeof h=="function")return h(v,{...b,props:t,required:s})},[h,s]),{path:N,readOnly:S}=Xt(),w=Qt({path:N??d??r,validate:P}),{formInitializing:Y,formProcessing:A,initialValue:D,path:T,setValue:U,showError:se,value:de}=w,J=E||S||A||Y,me=[ie,"field-type",f,se&&"error",J&&`${ie}--read-only`,o?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),Q=`${T}.${C}`;return ce("div",{className:me,style:{...p,width:y},children:[$(Vt,{CustomError:g,path:T,...a||{},alignCaret:"left",field:n}),$(qt,{Label:i,...u||{},field:n}),ce("div",{className:`${ie}__wrap`,children:[$(to,{fallbackRender:no,onReset:()=>{},children:$(Qe,{composerKey:Q,editorConfig:o,field:n,onChange:v=>{let b=v.toJSON();o?.features?.hooks?.save?.length&&o.features.hooks.save.forEach(Xe=>{b=Xe({incomingEditorState:b})}),U(b)},readOnly:J,value:de},JSON.stringify({initialValue:D,path:T}))}),$(Ut,{Description:l,...e||{},field:n})]})]},Q)};function no({error:t}){return ce("div",{className:"errorBoundary",role:"alert",children:[$("p",{children:"Something went wrong:"}),$("pre",{style:{color:"red"},children:t.message})]})}var dr=Zt(oo);export{dr as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-Y47DV2NP.js.map
|