@payloadcms/richtext-lexical 3.0.0-beta.106 → 3.0.0-beta.108
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/cell/index.js +1 -1
- package/dist/cell/index.js.map +1 -1
- package/dist/exports/client/Field-ETCEVZLL.js +2 -0
- package/dist/exports/client/Field-ETCEVZLL.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-F6JI75HS.js +2 -0
- package/dist/exports/client/{RelationshipComponent-Z5SZ5FFT.js.map → RelationshipComponent-F6JI75HS.js.map} +2 -2
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-76MVRKRT.js +2 -0
- package/dist/exports/client/chunk-76MVRKRT.js.map +7 -0
- package/dist/exports/client/{chunk-TXEIKM77.js → chunk-GD6LBQBJ.js} +2 -2
- package/dist/exports/client/chunk-GD6LBQBJ.js.map +7 -0
- package/dist/exports/client/chunk-HIGLONP6.js +2 -0
- package/dist/exports/client/chunk-HIGLONP6.js.map +7 -0
- package/dist/exports/client/{chunk-GK7ZKYHL.js → chunk-IIWHHN4J.js} +2 -2
- package/dist/exports/client/chunk-IIWHHN4J.js.map +7 -0
- package/dist/exports/client/{chunk-PY6JO5OH.js → chunk-JYCJEIVA.js} +2 -2
- package/dist/exports/client/{chunk-PY6JO5OH.js.map → chunk-JYCJEIVA.js.map} +2 -2
- package/dist/exports/client/{chunk-GTKNWSQW.js → chunk-N2PXHNGO.js} +2 -2
- package/dist/exports/client/{chunk-GTKNWSQW.js.map → chunk-N2PXHNGO.js.map} +2 -2
- package/dist/exports/client/{chunk-PECDZEZY.js → chunk-YREZUOA6.js} +2 -2
- package/dist/exports/client/{chunk-PECDZEZY.js.map → chunk-YREZUOA6.js.map} +2 -2
- package/dist/exports/client/component-4IBTSHL5.js +2 -0
- package/dist/exports/client/component-4IBTSHL5.js.map +7 -0
- package/dist/exports/client/{component-GAX6BHKZ.js → component-GQ5M6NF6.js} +2 -2
- package/dist/exports/client/component-P34B4EPY.js +2 -0
- package/dist/exports/client/component-P34B4EPY.js.map +7 -0
- package/dist/exports/client/componentInline-XX7FVAIV.js +2 -0
- package/dist/exports/client/{componentInline-HAGGWKA7.js.map → componentInline-XX7FVAIV.js.map} +2 -2
- package/dist/exports/client/index.js +7 -7
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/features/blockquote/server/index.d.ts +1 -1
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +5 -4
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +15 -5
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +4 -4
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +21 -11
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +2 -2
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts +2 -2
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js +4 -4
- 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 +4 -2
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +10 -4
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +2 -2
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/converters/html/converter/index.js +2 -2
- package/dist/features/converters/html/converter/index.js.map +1 -1
- package/dist/features/converters/html/field/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/server/index.js +2 -2
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/horizontalRule/client/component/index.d.ts +1 -1
- package/dist/features/horizontalRule/client/component/index.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +2 -2
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js +2 -1
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/link/client/index.js +1 -1
- package/dist/features/link/client/index.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -7
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js +2 -2
- package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +11 -6
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/link/nodes/types.d.ts +3 -3
- package/dist/features/link/nodes/types.d.ts.map +1 -1
- package/dist/features/link/nodes/types.js.map +1 -1
- package/dist/features/link/server/baseFields.d.ts +1 -1
- package/dist/features/link/server/baseFields.d.ts.map +1 -1
- package/dist/features/link/server/baseFields.js +3 -1
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +2 -2
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/features/link/server/transformExtraFields.d.ts +1 -1
- package/dist/features/link/server/transformExtraFields.d.ts.map +1 -1
- package/dist/features/link/server/transformExtraFields.js.map +1 -1
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/lists/shared/markdown.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.js +1 -0
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/blockquote/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/listItem/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/orderedList/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/unknown/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/unorderedList/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.js +1 -0
- package/dist/features/migrations/slateToLexical/converter/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/paragraph/server/index.d.ts +1 -1
- package/dist/features/paragraph/server/index.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +8 -6
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.js +3 -3
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +1 -1
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +1 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.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 +40 -41
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +33 -34
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +4 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts +3 -4
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +82 -64
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/types.d.ts +21 -11
- 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.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.js +1 -1
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
- package/dist/features/upload/client/drawer/index.js +2 -0
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/feature.server.js +3 -4
- package/dist/features/upload/server/feature.server.js.map +1 -1
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +11 -11
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.js +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -63
- package/dist/index.js.map +1 -1
- package/dist/lexical/EditorPlugin.d.ts.map +1 -1
- package/dist/lexical/EditorPlugin.js +2 -1
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +5 -5
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +8 -7
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.js +2 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/server/loader.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +11 -11
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +2 -2
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +1 -1
- 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 +9 -6
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +5 -5
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +9 -4
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js +3 -4
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -1
- package/dist/lexical/utils/rect.d.ts +4 -4
- package/dist/lexical/utils/setFloatingElemPosition.d.ts +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/populateGraphQL/populate.js +1 -1
- package/dist/populateGraphQL/populate.js.map +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts.map +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.js +5 -4
- package/dist/populateGraphQL/populateLexicalPopulationPromises.js.map +1 -1
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -3
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/generateComponentMap.d.ts.map +1 -1
- package/dist/utilities/generateComponentMap.js +1 -0
- package/dist/utilities/generateComponentMap.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/dist/validate/validateNodes.d.ts.map +1 -1
- package/dist/validate/validateNodes.js +2 -2
- package/dist/validate/validateNodes.js.map +1 -1
- package/package.json +13 -13
- package/dist/exports/client/Field-EL5TNVZW.js +0 -2
- package/dist/exports/client/Field-EL5TNVZW.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-Z5SZ5FFT.js +0 -2
- package/dist/exports/client/chunk-366OGJYE.js +0 -2
- package/dist/exports/client/chunk-366OGJYE.js.map +0 -7
- package/dist/exports/client/chunk-GK7ZKYHL.js.map +0 -7
- package/dist/exports/client/chunk-TXEIKM77.js.map +0 -7
- package/dist/exports/client/component-OVIYSCND.js +0 -2
- package/dist/exports/client/component-OVIYSCND.js.map +0 -7
- package/dist/exports/client/component-UJILB3MH.js +0 -2
- package/dist/exports/client/component-UJILB3MH.js.map +0 -7
- package/dist/exports/client/componentInline-HAGGWKA7.js +0 -2
- /package/dist/exports/client/{component-GAX6BHKZ.js.map → component-GQ5M6NF6.js.map} +0 -0
package/dist/field/index.js
CHANGED
|
@@ -37,7 +37,7 @@ export const RichTextField = props => {
|
|
|
37
37
|
if (finalSanitizedEditorConfig) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
const clientFeatures = richTextComponentMap
|
|
40
|
+
const clientFeatures = richTextComponentMap?.get("features");
|
|
41
41
|
const featureProvidersLocal = [];
|
|
42
42
|
for (const clientFeature of clientFeatures) {
|
|
43
43
|
featureProvidersLocal.push(clientFeature.clientFeature(clientFeature.clientFeatureProps));
|
package/dist/field/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","ShimmerEffect","React","lazy","Suspense","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextEditor","then","module","default","RichText","RichTextField","props","$","admin","t0","field","t1","lexicalEditorConfig","t2","undefined","richTextComponentMap","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","t3","t4","clientFeatures","get","featureProvidersLocal","clientFeature","push","clientFeatureProps","finalLexicalEditorConfig","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","t5","_jsx","fallback","height","editorConfig"],"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\n\nimport { ShimmerEffect } from '@payloadcms/ui'\nimport React, { lazy, Suspense, useEffect, useState } from 'react'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { GeneratedFeatureProviderComponent, LexicalRichTextFieldProps } 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'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<LexicalRichTextFieldProps> = (props) => {\n const {\n admin = {},\n field: { richTextComponentMap },\n lexicalEditorConfig,\n } = props\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<SanitizedClientEditorConfig>(null)\n\n useEffect(() => {\n if (finalSanitizedEditorConfig) {\n return\n }\n const clientFeatures: GeneratedFeatureProviderComponent[] = richTextComponentMap
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","ShimmerEffect","React","lazy","Suspense","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextEditor","then","module","default","RichText","RichTextField","props","$","admin","t0","field","t1","lexicalEditorConfig","t2","undefined","richTextComponentMap","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","t3","t4","clientFeatures","get","featureProvidersLocal","clientFeature","push","clientFeatureProps","finalLexicalEditorConfig","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","t5","_jsx","fallback","height","editorConfig"],"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\n\nimport { ShimmerEffect } from '@payloadcms/ui'\nimport React, { lazy, Suspense, useEffect, useState } from 'react'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { GeneratedFeatureProviderComponent, LexicalRichTextFieldProps } 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'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<LexicalRichTextFieldProps> = (props) => {\n const {\n admin = {},\n field: { richTextComponentMap },\n lexicalEditorConfig,\n } = props\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<null | SanitizedClientEditorConfig>(null)\n\n useEffect(() => {\n if (finalSanitizedEditorConfig) {\n return\n }\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 setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(resolvedClientFeatures, finalLexicalEditorConfig, admin),\n )\n }, [lexicalEditorConfig, richTextComponentMap, admin, finalSanitizedEditorConfig]) // TODO: Optimize this and use useMemo for this in the future. This might break sub-richtext-blocks from the blocks feature. Need to investigate\n\n return (\n <Suspense fallback={<ShimmerEffect height=\"35vh\" />}>\n {finalSanitizedEditorConfig && (\n <RichTextEditor {...props} editorConfig={finalSanitizedEditorCon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AA,CAAAE,IAAA,CAA2BD,aAAA,CAAAA,aAAA,CAA4BA,aAAA,CAAAE,kBAAgC;MAAA;MAGzF,MAAAC,wBAAA,GAAiCd,mBAAA,GAC7BA,mBAAA,GAAAf,0BACA;MAEJ,MAAA8B,sBAAA,GAA+B7B,kBAAA;QAAA8B,uBAAA;UAAAC,QAAA,EAEjBP,qBAAA;UAAAQ,OAAA,EACDJ;QAAA;MAAA,CAEb;MAEAT,6BAAA,CACElB,0BAAA,CAA2B4B,sBAAA,EAAwBD,wBAAA,EAA0BlB,KAAA;IAAA;IAE9EW,EAAA,IAACP,mBAAA,EAAqBG,oBAAA,EAAsBP,KAAA,EAAOQ,0BAAA;IAA2BT,CAAA,MAAAS,0BAAA;IAAAT,CAAA,MAAAQ,oBAAA;IAAAR,CAAA,MAAAK,mBAAA;IAAAL,CAAA,MAAAC,KAAA;IAAAD,CAAA,MAAAW,EAAA;IAAAX,CAAA,MAAAY,EAAA;EAAA;IAAAD,EAAA,GAAAX,CAAA;IAAAY,EAAA,GAAAZ,CAAA;EAAA;EA3BjFZ,SAAA,CAAUuB,EA2BV,EAAGC,EAA8E;EAAA,IAAAY,EAAA;EAAA,IAAAxB,CAAA,QAAAS,0BAAA,IAAAT,CAAA,QAAAD,KAAA;IAG/EyB,EAAA,GAAAC,IAAA,CAAAtC,QAAA;MAAAuC,QAAA,EAAoBD,IAAA,CAAAzC,aAAA;QAAA2C,MAAA,EAAsB;MAAA,C;gBACvClB,0BAAA,IACCgB,IAAA,CAAAhC,cAAA;QAAA,GAAoBM,KAAK;QAAA6B,YAAA,EAAgBnB;MAAA,C;;;;;;;;SAF7Ce,E;CAMJ","ignoreList":[]}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAg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tB,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEjE,mBAAmB,gBAAgB,CAAA;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AAExE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAExE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -9,13 +9,15 @@ import { getGenerateSchemaMap } from './utilities/generateSchemaMap.js';
|
|
|
9
9
|
import { recurseNodeTree } from './utilities/recurseNodeTree.js';
|
|
10
10
|
import { richTextValidateHOC } from './validate/index.js';
|
|
11
11
|
let defaultSanitizedServerEditorConfig = null;
|
|
12
|
+
let checkedDependencies = false;
|
|
12
13
|
export function lexicalEditor(props) {
|
|
13
14
|
return async ({
|
|
14
15
|
config,
|
|
15
16
|
isRoot,
|
|
16
17
|
parentIsLocalized
|
|
17
18
|
}) => {
|
|
18
|
-
if (process.env.NODE_ENV !== 'production' && process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true') {
|
|
19
|
+
if (process.env.NODE_ENV !== 'production' && process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true' && !checkedDependencies) {
|
|
20
|
+
checkedDependencies = true;
|
|
19
21
|
await checkDependencies({
|
|
20
22
|
dependencyGroups: [{
|
|
21
23
|
name: 'lexical',
|
|
@@ -156,7 +158,7 @@ export function lexicalEditor(props) {
|
|
|
156
158
|
value = await hook(args);
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
|
-
if (!finalSanitizedEditorConfig.features.nodeHooks
|
|
161
|
+
if (!finalSanitizedEditorConfig.features.nodeHooks?.afterChange?.size && !finalSanitizedEditorConfig.features.getSubFields?.size) {
|
|
160
162
|
return value;
|
|
161
163
|
}
|
|
162
164
|
const context = _context;
|
|
@@ -174,9 +176,10 @@ export function lexicalEditor(props) {
|
|
|
174
176
|
});
|
|
175
177
|
// eslint-disable-next-line prefer-const
|
|
176
178
|
for (let [id, node] of Object.entries(nodeIDMap)) {
|
|
177
|
-
const afterChangeHooks = finalSanitizedEditorConfig.features.nodeHooks
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
const afterChangeHooks = finalSanitizedEditorConfig.features.nodeHooks?.afterChange;
|
|
180
|
+
const afterChangeHooksForNode = afterChangeHooks?.get(node.type);
|
|
181
|
+
if (afterChangeHooksForNode) {
|
|
182
|
+
for (const hook of afterChangeHooksForNode) {
|
|
180
183
|
if (!originalNodeIDMap[id]) {
|
|
181
184
|
console.warn('(afterChange) No original node found for node with id', id, 'node:', node, 'path', path.join('.'));
|
|
182
185
|
continue;
|
|
@@ -192,9 +195,9 @@ export function lexicalEditor(props) {
|
|
|
192
195
|
});
|
|
193
196
|
}
|
|
194
197
|
}
|
|
195
|
-
const subFieldFn = finalSanitizedEditorConfig.features.getSubFields
|
|
196
|
-
const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData
|
|
197
|
-
if (subFieldFn) {
|
|
198
|
+
const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type);
|
|
199
|
+
const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(node.type);
|
|
200
|
+
if (subFieldFn && subFieldDataFn) {
|
|
198
201
|
const subFields = subFieldFn({
|
|
199
202
|
node,
|
|
200
203
|
req
|
|
@@ -267,7 +270,7 @@ export function lexicalEditor(props) {
|
|
|
267
270
|
value = await hook(args);
|
|
268
271
|
}
|
|
269
272
|
}
|
|
270
|
-
if (!finalSanitizedEditorConfig.features.nodeHooks
|
|
273
|
+
if (!finalSanitizedEditorConfig.features.nodeHooks?.afterRead?.size && !finalSanitizedEditorConfig.features.getSubFields?.size) {
|
|
271
274
|
return value;
|
|
272
275
|
}
|
|
273
276
|
const flattenedNodes = [];
|
|
@@ -276,34 +279,35 @@ export function lexicalEditor(props) {
|
|
|
276
279
|
nodes: value?.root?.children ?? []
|
|
277
280
|
});
|
|
278
281
|
for (let node of flattenedNodes) {
|
|
279
|
-
const afterReadHooks = finalSanitizedEditorConfig.features.nodeHooks
|
|
280
|
-
|
|
281
|
-
|
|
282
|
+
const afterReadHooks = finalSanitizedEditorConfig.features.nodeHooks?.afterRead;
|
|
283
|
+
const afterReadHooksForNode = afterReadHooks?.get(node.type);
|
|
284
|
+
if (afterReadHooksForNode) {
|
|
285
|
+
for (const hook of afterReadHooksForNode) {
|
|
282
286
|
node = await hook({
|
|
283
287
|
context,
|
|
284
|
-
currentDepth,
|
|
285
|
-
depth,
|
|
286
|
-
draft,
|
|
287
|
-
fallbackLocale,
|
|
288
|
-
fieldPromises,
|
|
289
|
-
findMany,
|
|
290
|
-
flattenLocales,
|
|
291
|
-
locale,
|
|
288
|
+
currentDepth: currentDepth,
|
|
289
|
+
depth: depth,
|
|
290
|
+
draft: draft,
|
|
291
|
+
fallbackLocale: fallbackLocale,
|
|
292
|
+
fieldPromises: fieldPromises,
|
|
293
|
+
findMany: findMany,
|
|
294
|
+
flattenLocales: flattenLocales,
|
|
295
|
+
locale: locale,
|
|
292
296
|
node,
|
|
293
|
-
overrideAccess,
|
|
297
|
+
overrideAccess: overrideAccess,
|
|
294
298
|
parentRichTextFieldPath: path,
|
|
295
299
|
parentRichTextFieldSchemaPath: schemaPath,
|
|
296
|
-
populationPromises,
|
|
300
|
+
populationPromises: populationPromises,
|
|
297
301
|
req,
|
|
298
|
-
showHiddenFields,
|
|
299
|
-
triggerAccessControl,
|
|
300
|
-
triggerHooks
|
|
302
|
+
showHiddenFields: showHiddenFields,
|
|
303
|
+
triggerAccessControl: triggerAccessControl,
|
|
304
|
+
triggerHooks: triggerHooks
|
|
301
305
|
});
|
|
302
306
|
}
|
|
303
307
|
}
|
|
304
|
-
const subFieldFn = finalSanitizedEditorConfig.features.getSubFields
|
|
305
|
-
const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData
|
|
306
|
-
if (subFieldFn) {
|
|
308
|
+
const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type);
|
|
309
|
+
const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(node.type);
|
|
310
|
+
if (subFieldFn && subFieldDataFn) {
|
|
307
311
|
const subFields = subFieldFn({
|
|
308
312
|
node,
|
|
309
313
|
req
|
|
@@ -316,23 +320,23 @@ export function lexicalEditor(props) {
|
|
|
316
320
|
afterReadTraverseFields({
|
|
317
321
|
collection,
|
|
318
322
|
context,
|
|
319
|
-
currentDepth,
|
|
320
|
-
depth,
|
|
323
|
+
currentDepth: currentDepth,
|
|
324
|
+
depth: depth,
|
|
321
325
|
doc: data,
|
|
322
|
-
draft,
|
|
323
|
-
fallbackLocale,
|
|
324
|
-
fieldPromises,
|
|
326
|
+
draft: draft,
|
|
327
|
+
fallbackLocale: fallbackLocale,
|
|
328
|
+
fieldPromises: fieldPromises,
|
|
325
329
|
fields: subFields,
|
|
326
|
-
findMany,
|
|
327
|
-
flattenLocales,
|
|
330
|
+
findMany: findMany,
|
|
331
|
+
flattenLocales: flattenLocales,
|
|
328
332
|
global,
|
|
329
|
-
locale,
|
|
330
|
-
overrideAccess,
|
|
333
|
+
locale: locale,
|
|
334
|
+
overrideAccess: overrideAccess,
|
|
331
335
|
path,
|
|
332
|
-
populationPromises,
|
|
336
|
+
populationPromises: populationPromises,
|
|
333
337
|
req,
|
|
334
338
|
schemaPath,
|
|
335
|
-
showHiddenFields,
|
|
339
|
+
showHiddenFields: showHiddenFields,
|
|
336
340
|
siblingDoc: data,
|
|
337
341
|
triggerAccessControl,
|
|
338
342
|
triggerHooks
|
|
@@ -366,7 +370,7 @@ export function lexicalEditor(props) {
|
|
|
366
370
|
value = await hook(args);
|
|
367
371
|
}
|
|
368
372
|
}
|
|
369
|
-
if (!finalSanitizedEditorConfig.features.nodeHooks
|
|
373
|
+
if (!finalSanitizedEditorConfig.features.nodeHooks?.beforeChange?.size && !finalSanitizedEditorConfig.features.getSubFields?.size) {
|
|
370
374
|
return value;
|
|
371
375
|
}
|
|
372
376
|
const context = _context;
|
|
@@ -383,7 +387,7 @@ export function lexicalEditor(props) {
|
|
|
383
387
|
nodeIDMap,
|
|
384
388
|
nodes: value?.root?.children ?? []
|
|
385
389
|
});
|
|
386
|
-
if (siblingDocWithLocales?.[field.name]) {
|
|
390
|
+
if (field.name && siblingDocWithLocales?.[field.name]) {
|
|
387
391
|
recurseNodeTree({
|
|
388
392
|
nodeIDMap: originalNodeWithLocalesIDMap,
|
|
389
393
|
nodes: siblingDocWithLocales[field.name]?.root?.children ?? []
|
|
@@ -391,31 +395,32 @@ export function lexicalEditor(props) {
|
|
|
391
395
|
}
|
|
392
396
|
// eslint-disable-next-line prefer-const
|
|
393
397
|
for (let [id, node] of Object.entries(nodeIDMap)) {
|
|
394
|
-
const beforeChangeHooks = finalSanitizedEditorConfig.features.nodeHooks
|
|
395
|
-
|
|
396
|
-
|
|
398
|
+
const beforeChangeHooks = finalSanitizedEditorConfig.features.nodeHooks?.beforeChange;
|
|
399
|
+
const beforeChangeHooksForNode = beforeChangeHooks?.get(node.type);
|
|
400
|
+
if (beforeChangeHooksForNode) {
|
|
401
|
+
for (const hook of beforeChangeHooksForNode) {
|
|
397
402
|
if (!originalNodeIDMap[id]) {
|
|
398
403
|
console.warn('(beforeChange) No original node found for node with id', id, 'node:', node, 'path', path.join('.'));
|
|
399
404
|
continue;
|
|
400
405
|
}
|
|
401
406
|
node = await hook({
|
|
402
407
|
context,
|
|
403
|
-
errors,
|
|
404
|
-
mergeLocaleActions,
|
|
408
|
+
errors: errors,
|
|
409
|
+
mergeLocaleActions: mergeLocaleActions,
|
|
405
410
|
node,
|
|
406
|
-
operation,
|
|
411
|
+
operation: operation,
|
|
407
412
|
originalNode: originalNodeIDMap[id],
|
|
408
413
|
originalNodeWithLocales: originalNodeWithLocalesIDMap[id],
|
|
409
414
|
parentRichTextFieldPath: path,
|
|
410
415
|
parentRichTextFieldSchemaPath: schemaPath,
|
|
411
416
|
req,
|
|
412
|
-
skipValidation
|
|
417
|
+
skipValidation: skipValidation
|
|
413
418
|
});
|
|
414
419
|
}
|
|
415
420
|
}
|
|
416
|
-
const subFieldFn = finalSanitizedEditorConfig.features.getSubFields
|
|
417
|
-
const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData
|
|
418
|
-
if (subFieldFn) {
|
|
421
|
+
const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type);
|
|
422
|
+
const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(node.type);
|
|
423
|
+
if (subFieldFn && subFieldDataFn) {
|
|
419
424
|
const subFields = subFieldFn({
|
|
420
425
|
node,
|
|
421
426
|
req
|
|
@@ -440,11 +445,11 @@ export function lexicalEditor(props) {
|
|
|
440
445
|
data,
|
|
441
446
|
doc: originalData,
|
|
442
447
|
docWithLocales: originalDataWithLocales ?? {},
|
|
443
|
-
errors,
|
|
448
|
+
errors: errors,
|
|
444
449
|
fields: subFields,
|
|
445
450
|
global,
|
|
446
|
-
mergeLocaleActions,
|
|
447
|
-
operation,
|
|
451
|
+
mergeLocaleActions: mergeLocaleActions,
|
|
452
|
+
operation: operation,
|
|
448
453
|
path,
|
|
449
454
|
req,
|
|
450
455
|
schemaPath,
|
|
@@ -505,7 +510,7 @@ export function lexicalEditor(props) {
|
|
|
505
510
|
}
|
|
506
511
|
}
|
|
507
512
|
// return value if there are NO hooks
|
|
508
|
-
if (!finalSanitizedEditorConfig.features.nodeHooks
|
|
513
|
+
if (!finalSanitizedEditorConfig.features.nodeHooks?.beforeValidate?.size && !finalSanitizedEditorConfig.features.nodeHooks?.afterChange?.size && !finalSanitizedEditorConfig.features.nodeHooks?.beforeChange?.size && !finalSanitizedEditorConfig.features.getSubFields?.size) {
|
|
509
514
|
return value;
|
|
510
515
|
}
|
|
511
516
|
/**
|
|
@@ -545,7 +550,7 @@ export function lexicalEditor(props) {
|
|
|
545
550
|
/**
|
|
546
551
|
* Now that the maps for all hooks are set up, we can run the validate hook
|
|
547
552
|
*/
|
|
548
|
-
if (!finalSanitizedEditorConfig.features.nodeHooks
|
|
553
|
+
if (!finalSanitizedEditorConfig.features.nodeHooks?.beforeValidate?.size) {
|
|
549
554
|
return value;
|
|
550
555
|
}
|
|
551
556
|
const nodeIDMap = {};
|
|
@@ -557,8 +562,9 @@ export function lexicalEditor(props) {
|
|
|
557
562
|
// eslint-disable-next-line prefer-const
|
|
558
563
|
for (let [id, node] of Object.entries(nodeIDMap)) {
|
|
559
564
|
const beforeValidateHooks = finalSanitizedEditorConfig.features.nodeHooks.beforeValidate;
|
|
560
|
-
|
|
561
|
-
|
|
565
|
+
const beforeValidateHooksForNode = beforeValidateHooks?.get(node.type);
|
|
566
|
+
if (beforeValidateHooksForNode) {
|
|
567
|
+
for (const hook of beforeValidateHooksForNode) {
|
|
562
568
|
if (!originalNodeIDMap[id]) {
|
|
563
569
|
console.warn('(beforeValidate) No original node found for node with id', id, 'node:', node, 'path', path.join('.'));
|
|
564
570
|
continue;
|
|
@@ -568,16 +574,16 @@ export function lexicalEditor(props) {
|
|
|
568
574
|
node,
|
|
569
575
|
operation,
|
|
570
576
|
originalNode: originalNodeIDMap[id],
|
|
571
|
-
overrideAccess,
|
|
577
|
+
overrideAccess: overrideAccess,
|
|
572
578
|
parentRichTextFieldPath: path,
|
|
573
579
|
parentRichTextFieldSchemaPath: schemaPath,
|
|
574
580
|
req
|
|
575
581
|
});
|
|
576
582
|
}
|
|
577
583
|
}
|
|
578
|
-
const subFieldFn = finalSanitizedEditorConfig.features.getSubFields
|
|
579
|
-
const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData
|
|
580
|
-
if (subFieldFn) {
|
|
584
|
+
const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type);
|
|
585
|
+
const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(node.type);
|
|
586
|
+
if (subFieldFn && subFieldDataFn) {
|
|
581
587
|
const subFields = subFieldFn({
|
|
582
588
|
node,
|
|
583
589
|
req
|
|
@@ -600,7 +606,7 @@ export function lexicalEditor(props) {
|
|
|
600
606
|
fields: subFields,
|
|
601
607
|
global,
|
|
602
608
|
operation,
|
|
603
|
-
overrideAccess,
|
|
609
|
+
overrideAccess: overrideAccess,
|
|
604
610
|
path,
|
|
605
611
|
req,
|
|
606
612
|
schemaPath,
|