@payloadcms/richtext-lexical 3.61.0-canary.5 → 3.61.0-internal.7d69f4e
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/rscEntry.d.ts +2 -10
- package/dist/cell/rscEntry.d.ts.map +1 -1
- package/dist/cell/rscEntry.js +1 -2
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/exports/client/Field-F2KOJLMQ.js +2 -0
- package/dist/exports/client/{Field-YYMTSGSP.js.map → Field-F2KOJLMQ.js.map} +3 -3
- package/dist/exports/client/RelationshipComponent-UCIWIEVD.js +2 -0
- package/dist/exports/client/RelationshipComponent-UCIWIEVD.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-52JG5GGJ.js +2 -0
- package/dist/exports/client/chunk-52JG5GGJ.js.map +7 -0
- package/dist/exports/client/component-5YLBQB5B.js +2 -0
- package/dist/exports/client/component-5YLBQB5B.js.map +7 -0
- package/dist/exports/client/componentInline-QEXUNJU4.js +2 -0
- package/dist/exports/client/index.js +21 -21
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/blocks/client/component/BlockContent.js +1 -1
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +1 -0
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +23 -20
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +2 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +6 -6
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +2 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +2 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -0
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js +6 -0
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js +3 -2
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/migrations/slateToLexical/feature.server.d.ts +29 -0
- package/dist/features/migrations/slateToLexical/feature.server.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/feature.server.js +18 -0
- package/dist/features/migrations/slateToLexical/feature.server.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +2 -2
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -0
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js +6 -0
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/typesServer.d.ts +2 -2
- 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 +1 -0
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +2 -2
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts +2 -2
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +2 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +2 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js +6 -0
- package/dist/features/upload/server/nodes/UploadNode.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 +48 -40
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +2 -3
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +3 -1
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -25
- package/dist/index.js.map +1 -1
- package/dist/lexical/config/client/loader.d.ts.map +1 -1
- package/dist/lexical/config/client/loader.js +2 -4
- package/dist/lexical/config/client/loader.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
- package/dist/lexical/theme/EditorTheme.js +3 -39
- package/dist/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +16 -9
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/editorConfigFactory.js +1 -1
- package/dist/utilities/editorConfigFactory.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts +2 -0
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +5 -13
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/{getDefaultSanitizedEditorConfig.d.ts → utilities/getDefaultSanitizedEditorConfig.d.ts} +1 -1
- package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -0
- package/dist/{getDefaultSanitizedEditorConfig.js → utilities/getDefaultSanitizedEditorConfig.js} +2 -2
- package/dist/utilities/getDefaultSanitizedEditorConfig.js.map +1 -0
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
- package/dist/utilities/initLexicalFeatures.js +12 -13
- package/dist/utilities/initLexicalFeatures.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-YYMTSGSP.js +0 -2
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js +0 -2
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js.map +0 -7
- package/dist/exports/client/chunk-RPFDD27K.js +0 -2
- package/dist/exports/client/chunk-RPFDD27K.js.map +0 -7
- package/dist/exports/client/component-WT25HAJA.js +0 -2
- package/dist/exports/client/component-WT25HAJA.js.map +0 -7
- package/dist/exports/client/componentInline-BVC77WQC.js +0 -2
- package/dist/getDefaultSanitizedEditorConfig.d.ts.map +0 -1
- package/dist/getDefaultSanitizedEditorConfig.js.map +0 -1
- /package/dist/exports/client/{componentInline-BVC77WQC.js.map → componentInline-QEXUNJU4.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentEditable.js","names":["c","_c","ContentEditable","useTranslation","React","LexicalContentEditable","t0","$","className","editorConfig","t","t1","admin","placeholder","_jsx","children"],"sources":["../../../src/lexical/ui/ContentEditable.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable.js'\nimport { useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\n\nimport
|
|
1
|
+
{"version":3,"file":"ContentEditable.js","names":["c","_c","useLexicalComposerContext","ContentEditable","useTranslation","React","LexicalContentEditable","t0","$","className","editorConfig","t","t1","getTheme","t2","admin","placeholder","theme","_jsx","children"],"sources":["../../../src/lexical/ui/ContentEditable.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable.js'\nimport { useTranslation } from '@payloadcms/ui'\n\nimport './ContentEditable.scss'\n\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../config/types.js'\n\nexport function LexicalContentEditable({\n className,\n editorConfig,\n}: {\n className?: string\n editorConfig: SanitizedClientEditorConfig\n}): JSX.Element {\n const { t } = useTranslation<{}, string>()\n const [_, { getTheme }] = useLexicalComposerContext()\n const theme = getTheme()\n\n return (\n <ContentEditable\n aria-placeholder={t('lexical:general:placeholder')}\n className={className ?? 'ContentEditable__root'}\n placeholder={\n <p className={theme?.placeholder}>\n {editorConfig?.admin?.placeholder ?? t('lexical:general:placeholder')}\n </p>\n }\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAI/B,YAAYC,KAAA,MAAW;AAIvB,OAAO,SAAAC,uBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAgC;IAAAQ,SAAA;IAAAC;EAAA,IAAAH,EAMtC;EACC;IAAAI;EAAA,IAAcP,cAAA;EACd,SAAAQ,EAAA,IAA0BV,yBAAA;EAAhB;IAAAW;EAAA,IAAAD,EAAY;EAAA,IAAAE,EAAA;EAAA,IAAAN,CAAA,QAAAC,SAAA,IAAAD,CAAA,QAAAE,YAAA,EAAAK,KAAA,EAAAC,WAAA,IAAAR,CAAA,QAAAK,QAAA,IAAAL,CAAA,QAAAG,CAAA;IACtB,MAAAM,KAAA,GAAcJ,QAAA;IAGZC,EAAA,GAAAI,IAAA,CAAAf,eAAA;MAAA,oBACoBQ,CAAA,CAAE;MAAAF,SAAA,EACTA,SAAA,IAAa;MAAAO,WAAA,EAEtBE,IAAA,CAAC;QAAAT,SAAA,EAAaQ,KAAA,EAAAD,WAAA;QAAAG,QAAA,EACXT,YAAA,EAAAK,KAAA,EAAAC,WAAA,IAAoCL,CAAA,CAAE;MAAA,C;;;;;;;;;;SAL7CG,E","ignoreList":[]}
|
package/dist/types.d.ts
CHANGED
|
@@ -84,11 +84,15 @@ export type LexicalRichTextFieldProps = {
|
|
|
84
84
|
admin?: LexicalFieldAdminClientProps;
|
|
85
85
|
clientFeatures: {
|
|
86
86
|
[featureKey: string]: {
|
|
87
|
-
clientFeatureProps?:
|
|
87
|
+
clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>;
|
|
88
88
|
clientFeatureProvider?: FeatureProviderProviderClient<any, any>;
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Part of the import map that contains client components for all lexical features of this field that
|
|
93
|
+
* have been added through `feature.componentImports`.
|
|
94
|
+
*/
|
|
95
|
+
featureClientImportMap?: Record<string, any>;
|
|
92
96
|
featureClientSchemaMap: FeatureClientSchemaMap;
|
|
93
97
|
initialLexicalFormState: InitialLexicalFormState;
|
|
94
98
|
lexicalEditorConfig: LexicalEditorConfig | undefined;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EACV,WAAW,EACX,+BAA+B,EAC/B,aAAa,EACb,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EACV,sBAAsB,EACtB,6BA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mBAAmB,CAAC,qBAAqB,EAAE,YAAY,EAAE,MAAM,CAAC,EAChE,qBAAqB,CACtB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,2BAA2B,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,aAAa,EAAE,6BAA6B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACtD,kBAAkB,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?:
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"mappings":"AAoJA","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getDefaultSanitizedEditorConfig } from '../getDefaultSanitizedEditorConfig.js';
|
|
2
1
|
import { defaultEditorConfig, defaultEditorFeatures } from '../lexical/config/server/default.js';
|
|
3
2
|
import { loadFeatures } from '../lexical/config/server/loader.js';
|
|
4
3
|
import { sanitizeServerFeatures } from '../lexical/config/server/sanitize.js';
|
|
4
|
+
import { getDefaultSanitizedEditorConfig } from './getDefaultSanitizedEditorConfig.js';
|
|
5
5
|
export const editorConfigFactory = {
|
|
6
6
|
default: async args => {
|
|
7
7
|
return getDefaultSanitizedEditorConfig({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorConfigFactory.js","names":["
|
|
1
|
+
{"version":3,"file":"editorConfigFactory.js","names":["defaultEditorConfig","defaultEditorFeatures","loadFeatures","sanitizeServerFeatures","getDefaultSanitizedEditorConfig","editorConfigFactory","default","args","config","parentIsLocalized","fromEditor","lexicalAdapter","editor","isRoot","sanitizedServerEditorConfig","editorConfig","fromFeatures","featuresInputToEditorConfig","sanitizedConfig","fromField","field","fromUnsanitizedField","lexicalAdapterProvider","features","rootEditor","rootEditorFeatures","defaultFeatures","rootFeatures","lexical","resolvedFeatureMap","unSanitizedEditorConfig"],"sources":["../../src/utilities/editorConfigFactory.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\nimport type { RichTextAdapterProvider, RichTextField, SanitizedConfig } from 'payload'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type {\n FeaturesInput,\n LexicalRichTextAdapter,\n LexicalRichTextAdapterProvider,\n} from '../types.js'\n\nimport { defaultEditorConfig, defaultEditorFeatures } from '../lexical/config/server/default.js'\nimport { loadFeatures } from '../lexical/config/server/loader.js'\nimport { sanitizeServerFeatures } from '../lexical/config/server/sanitize.js'\nimport { getDefaultSanitizedEditorConfig } from './getDefaultSanitizedEditorConfig.js'\n\nexport const editorConfigFactory = {\n default: async (args: {\n config: SanitizedConfig\n parentIsLocalized?: boolean\n }): Promise<SanitizedServerEditorConfig> => {\n return getDefaultSanitizedEditorConfig({\n config: args.config,\n parentIsLocalized: args.parentIsLocalized ?? false,\n })\n },\n /**\n * If you have instantiated a lexical editor and are accessing it outside a field (=> this is the unsanitized editor),\n * you can extract the editor config from it.\n * This is common if you define the editor in a re-usable module scope variable and pass it to the richText field.\n *\n * This is the least efficient way to get the editor config, and not recommended. It is recommended to extract the `features` arg\n * into a separate variable and use `fromFeatures` instead.\n */\n fromEditor: async (args: {\n config: SanitizedConfig\n editor: LexicalRichTextAdapterProvider\n isRoot?: boolean\n lexical?: LexicalEditorConfig\n parentIsLocalized?: boolean\n }): Promise<SanitizedServerEditorConfig> => {\n const lexicalAdapter: LexicalRichTextAdapter = await args.editor({\n config: args.config,\n isRoot: args.isRoot ?? false,\n parentIsLocalized: args.parentIsLocalized ?? false,\n })\n\n const sanitizedServerEditorConfig: SanitizedServerEditorConfig = lexicalAdapter.editorConfig\n return sanitizedServerEditorConfig\n },\n /**\n * Create a new editor config - behaves just like instantiating a new `lexicalEditor`\n */\n fromFeatures: async (args: {\n config: SanitizedConfig\n features?: FeaturesInput\n isRoot?: boolean\n lexical?: LexicalEditorConfig\n parentIsLocalized?: boolean\n }): Promise<SanitizedServerEditorConfig> => {\n return (await featuresInputToEditorConfig(args)).sanitizedConfig\n },\n fromField: (args: { field: RichTextField }): SanitizedServerEditorConfig => {\n const lexicalAdapter: LexicalRichTextAdapter = args.field.editor as LexicalRichTextAdapter\n\n const sanitizedServerEditorConfig: SanitizedServerEditorConfig = lexicalAdapter.editorConfig\n return sanitizedServerEditorConfig\n },\n fromUnsanitizedField: async (args: {\n config: SanitizedConfig\n field: RichTextField\n isRoot?: boolean\n parentIsLocalized?: boolean\n }): Promise<SanitizedServerEditorConfig> => {\n const lexicalAdapterProvider: RichTextAdapterProvider = args.field\n .editor as RichTextAdapterProvider\n\n const lexicalAdapter: LexicalRichTextAdapter = (await lexicalAdapterProvider({\n config: args.config,\n isRoot: args.isRoot ?? false,\n parentIsLocalized: args.parentIsLocalized ?? false,\n })) as LexicalRichTextAdapter\n\n const sanitizedServerEditorConfig: SanitizedServerEditorConfig = lexicalAdapter.editorConfig\n return sanitizedServerEditorConfig\n },\n}\n\nexport const featuresInputToEditorConfig = async (args: {\n config: SanitizedConfig\n features?: FeaturesInput\n isRoot?: boolean\n lexical?: LexicalEditorConfig\n parentIsLocalized?: boolean\n}): Promise<{\n features: FeatureProviderServer<unknown, unknown, unknown>[]\n resolvedFeatureMap: ResolvedServerFeatureMap\n sanitizedConfig: SanitizedServerEditorConfig\n}> => {\n let features: FeatureProviderServer<unknown, unknown, unknown>[] = []\n if (args.features && typeof args.features === 'function') {\n const rootEditor = args.config.editor\n let rootEditorFeatures: FeatureProviderServer<unknown, unknown, unknown>[] = []\n if (typeof rootEditor === 'object' && 'features' in rootEditor) {\n rootEditorFeatures = (rootEditor as LexicalRichTextAdapter).features\n }\n features = args.features({\n defaultFeatures: defaultEditorFeatures,\n rootFeatures: rootEditorFeatures,\n })\n } else {\n features = args.features as FeatureProviderServer<unknown, unknown, unknown>[]\n }\n\n if (!features) {\n features = defaultEditorFeatures\n }\n\n const lexical = args.lexical ?? defaultEditorConfig.lexical\n\n const resolvedFeatureMap = await loadFeatures({\n config: args.config,\n isRoot: args.isRoot ?? false,\n parentIsLocalized: args.parentIsLocalized ?? false,\n unSanitizedEditorConfig: {\n features,\n lexical,\n },\n })\n\n return {\n features,\n resolvedFeatureMap,\n sanitizedConfig: {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: args.lexical,\n resolvedFeatureMap,\n },\n }\n}\n"],"mappings":"AAWA,SAASA,mBAAmB,EAAEC,qBAAqB,QAAQ;AAC3D,SAASC,YAAY,QAAQ;AAC7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,+BAA+B,QAAQ;AAEhD,OAAO,MAAMC,mBAAA,GAAsB;EACjCC,OAAA,EAAS,MAAOC,IAAA;IAId,OA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CAAKgB,QAAQ,KAAK,YAAY;IACxD,MAAMC,UAAA,GAAajB,IAAA,CAAKC,MAAM,CAACI,MAAM;IACrC,IAAIa,kBAAA,GAAyE,EAAE;IAC/E,IAAI,OAAOD,UAAA,KAAe,YAAY,cAAcA,UAAA,EAAY;MAC9DC,kBAAA,GAAqBD,UAAC,CAAsCD,QAAQ;IACtE;IACAA,QAAA,GAAWhB,IAAA,CAAKgB,QAAQ,CAAC;MACvBG,eAAA,EAAiBzB,qBAAA;MACjB0B,YAAA,EAAcF;IAChB;EACF,OAAO;IACLF,QAAA,GAAWhB,IAAA,CAAKgB,QAAQ;EAC1B;EAEA,IAAI,CAACA,QAAA,EAAU;IACbA,QAAA,GAAWtB,qBAAA;EACb;EAEA,MAAM2B,OAAA,GAAUrB,IAAA,CAAKqB,OAAO,IAAI5B,mBAAA,CAAoB4B,OAAO;EAE3D,MAAMC,kBAAA,GAAqB,MAAM3B,YAAA,CAAa;IAC5CM,MAAA,EAAQD,IAAA,CAAKC,MAAM;IACnBK,MAAA,EAAQN,IAAA,CAAKM,MAAM,IAAI;IACvBJ,iBAAA,EAAmBF,IAAA,CAAKE,iBAAiB,IAAI;IAC7CqB,uBAAA,EAAyB;MACvBP,QAAA;MACAK;IACF;EACF;EAEA,OAAO;IACLL,QAAA;IACAM,kBAAA;IACAX,eAAA,EAAiB;MACfK,QAAA,EAAUpB,sBAAA,CAAuB0B,kBAAA;MACjCD,OAAA,EAASrB,IAAA,CAAKqB,OAAO;MACrBC;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { RichTextAdapter } from 'payload';
|
|
2
2
|
import type { ResolvedServerFeatureMap } from '../features/typesServer.js';
|
|
3
|
+
import type { LexicalEditorProps } from '../types.js';
|
|
3
4
|
export declare const getGenerateImportMap: (args: {
|
|
5
|
+
lexicalEditorArgs?: LexicalEditorProps;
|
|
4
6
|
resolvedFeatureMap: ResolvedServerFeatureMap;
|
|
5
7
|
}) => RichTextAdapter["generateImportMap"];
|
|
6
8
|
//# sourceMappingURL=generateImportMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CA+CtC,CAAA"}
|
|
@@ -9,7 +9,6 @@ export const getGenerateImportMap = args => ({
|
|
|
9
9
|
addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell');
|
|
10
10
|
addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField');
|
|
11
11
|
addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent');
|
|
12
|
-
// iterate just through args.resolvedFeatureMap.values()
|
|
13
12
|
for (const resolvedFeature of args.resolvedFeatureMap.values()) {
|
|
14
13
|
if ('componentImports' in resolvedFeature) {
|
|
15
14
|
if (typeof resolvedFeature.componentImports === 'function') {
|
|
@@ -20,22 +19,15 @@ export const getGenerateImportMap = args => ({
|
|
|
20
19
|
importMap,
|
|
21
20
|
imports
|
|
22
21
|
});
|
|
23
|
-
} else if (Array.isArray(resolvedFeature.componentImports)
|
|
24
|
-
resolvedFeature.componentImports
|
|
25
|
-
addToImportMap(component);
|
|
26
|
-
});
|
|
22
|
+
} else if (Array.isArray(resolvedFeature.componentImports)) {
|
|
23
|
+
addToImportMap(resolvedFeature.componentImports);
|
|
27
24
|
} else if (typeof resolvedFeature.componentImports === 'object') {
|
|
28
|
-
|
|
29
|
-
addToImportMap(component);
|
|
30
|
-
}
|
|
25
|
+
addToImportMap(Object.values(resolvedFeature.componentImports));
|
|
31
26
|
}
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
if (ClientComponent) {
|
|
35
|
-
addToImportMap(ClientComponent);
|
|
36
|
-
}
|
|
28
|
+
addToImportMap(resolvedFeature.ClientFeature);
|
|
37
29
|
/*
|
|
38
|
-
Now run for all possible sub-fields
|
|
30
|
+
* Now run for all possible sub-fields
|
|
39
31
|
*/
|
|
40
32
|
if (resolvedFeature.nodes?.length) {
|
|
41
33
|
for (const node of resolvedFeature.nodes) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","
|
|
1
|
+
{"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\n }\n }\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAK1C,OAAO,MAAMC,oBAAA,GACVC,IAAA,IAID,CAAC;EAAEC,cAAc;EAAEC,OAAO;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAO,CAAE;EACtDJ,cAAA,CAAe;EACfA,cAAA,CAAe;EACfA,cAAA,CAAe;EAEf,KAAK,MAAMK,eAAA,IAAmBN,IAAA,CAAKO,kBAAkB,CAACC,MAAM,IAAI;IAC9D,IAAI,sBAAsBF,eAAA,EAAiB;MACzC,IAAI,OAAOA,eAAA,CAAgBG,gBAAgB,KAAK,YAAY;QAC1DH,eAAA,CAAgBG,gBAAgB,CAAC;UAC/BR,cAAA;UACAC,OAAA;UACAC,MAAA;UACAC,SAAA;UACAC;QACF;MACF,OAAO,IAAIK,KAAA,CAAMC,OAAO,CAACL,eAAA,CAAgBG,gBAAgB,GAAG;QAC1DR,cAAA,CAAeK,eAAA,CAAgBG,gBAAgB;MACjD,OAAO,IAAI,OAAOH,eAAA,CAAgBG,gBAAgB,KAAK,UAAU;QAC/DR,cAAA,CAAeW,MAAA,CAAOJ,MAAM,CAACF,eAAA,CAAgBG,gBAAgB;MAC/D;IACF;IAEAR,cAAA,CAAeK,eAAA,CAAgBO,aAAa;IAE5C;;;IAGA,IAAIP,eAAA,CAAgBQ,KAAK,EAAEC,MAAA,EAAQ;MACjC,KAAK,MAAMC,IAAA,IAAQV,eAAA,CAAgBQ,KAAK,EAAE;QACxC,IAAI,OAAOE,IAAA,EAAMC,YAAA,KAAiB,YAAY;UAC5C;QACF;QACA,MAAMC,SAAA,GAAYF,IAAA,CAAKC,YAAY,CAAC,CAAC;QACrC,IAAIC,SAAA,EAAWH,MAAA,EAAQ;UACrBjB,yBAAA,CAA0B;YACxBG,cAAA;YACAC,OAAA;YACAC,MAAA;YACAgB,MAAA,EAAQD,SAAA;YACRd,SAAA;YACAC;UACF;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
|
package/dist/{getDefaultSanitizedEditorConfig.d.ts → utilities/getDefaultSanitizedEditorConfig.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SanitizedConfig } from 'payload';
|
|
2
|
-
import { type SanitizedServerEditorConfig } from '
|
|
2
|
+
import { type SanitizedServerEditorConfig } from '../index.js';
|
|
3
3
|
export declare const getDefaultSanitizedEditorConfig: (args: {
|
|
4
4
|
config: SanitizedConfig;
|
|
5
5
|
parentIsLocalized: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDefaultSanitizedEditorConfig.d.ts","sourceRoot":"","sources":["../../src/utilities/getDefaultSanitizedEditorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAgB9D,eAAO,MAAM,+BAA+B,SAAgB;IAC1D,MAAM,EAAE,eAAe,CAAA;IACvB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,KAAG,OAAO,CAAC,2BAA2B,CAoBtC,CAAA"}
|
package/dist/{getDefaultSanitizedEditorConfig.js → utilities/getDefaultSanitizedEditorConfig.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defaultEditorConfig } from '
|
|
2
|
-
import { sanitizeServerEditorConfig } from '
|
|
1
|
+
import { defaultEditorConfig } from '../lexical/config/server/default.js';
|
|
2
|
+
import { sanitizeServerEditorConfig } from '../lexical/config/server/sanitize.js';
|
|
3
3
|
let cachedDefaultSanitizedServerEditorConfig = global._payload_lexical_defaultSanitizedServerEditorConfig;
|
|
4
4
|
if (!cachedDefaultSanitizedServerEditorConfig) {
|
|
5
5
|
cachedDefaultSanitizedServerEditorConfig = global._payload_lexical_defaultSanitizedServerEditorConfig = null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDefaultSanitizedEditorConfig.js","names":["defaultEditorConfig","sanitizeServerEditorConfig","cachedDefaultSanitizedServerEditorConfig","global","_payload_lexical_defaultSanitizedServerEditorConfig","getDefaultSanitizedEditorConfig","args","config","parentIsLocalized","payload_lexical_defaultSanitizedServerEditorConfig"],"sources":["../../src/utilities/getDefaultSanitizedEditorConfig.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { type SanitizedServerEditorConfig } from '../index.js'\nimport { defaultEditorConfig } from '../lexical/config/server/default.js'\nimport { sanitizeServerEditorConfig } from '../lexical/config/server/sanitize.js'\n\nlet cachedDefaultSanitizedServerEditorConfig:\n | null\n | Promise<SanitizedServerEditorConfig>\n | SanitizedServerEditorConfig = (global as any)\n ._payload_lexical_defaultSanitizedServerEditorConfig\n\nif (!cachedDefaultSanitizedServerEditorConfig) {\n cachedDefaultSanitizedServerEditorConfig = (\n global as any\n )._payload_lexical_defaultSanitizedServerEditorConfig = null\n}\n\nexport const getDefaultSanitizedEditorConfig = async (args: {\n config: SanitizedConfig\n parentIsLocalized: boolean\n}): Promise<SanitizedServerEditorConfig> => {\n const { config, parentIsLocalized } = args\n\n if (cachedDefaultSanitizedServerEditorConfig) {\n return await cachedDefaultSanitizedServerEditorConfig\n }\n\n cachedDefaultSanitizedServerEditorConfig = sanitizeServerEditorConfig(\n defaultEditorConfig,\n config,\n parentIsLocalized,\n )\n ;(global as any).payload_lexical_defaultSanitizedServerEditorConfig =\n cachedDefaultSanitizedServerEditorConfig\n\n cachedDefaultSanitizedServerEditorConfig = await cachedDefaultSanitizedServerEditorConfig\n ;(global as any).payload_lexical_defaultSanitizedServerEditorConfig =\n cachedDefaultSanitizedServerEditorConfig\n\n return cachedDefaultSanitizedServerEditorConfig\n}\n"],"mappings":"AAGA,SAASA,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAE3C,IAAIC,wCAAA,GAG8BC,MAAC,CAChCC,mDAAmD;AAEtD,IAAI,CAACF,wCAAA,EAA0C;EAC7CA,wCAAA,GAA2CC,MACzC,CACAC,mDAAmD,GAAG;AAC1D;AAEA,OAAO,MAAMC,+BAAA,GAAkC,MAAOC,IAAA;EAIpD,MAAM;IAAEC,MAAM;IAAEC;EAAiB,CAAE,GAAGF,IAAA;EAEtC,IAAIJ,wCAAA,EAA0C;IAC5C,OAAO,MAAMA,wCAAA;EACf;EAEAA,wCAAA,GAA2CD,0BAAA,CACzCD,mBAAA,EACAO,MAAA,EACAC,iBAAA;EAEAL,MAAA,CAAeM,kDAAkD,GACjEP,wCAAA;EAEFA,wCAAA,GAA2C,MAAMA,wCAAA;EAC/CC,MAAA,CAAeM,kDAAkD,GACjEP,wCAAA;EAEF,OAAOA,wCAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initLexicalFeatures.d.ts","sourceRoot":"","sources":["../../src/utilities/initLexicalFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"initLexicalFeatures.d.ts","sourceRoot":"","sources":["../../src/utilities/initLexicalFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AACpF,KAAK,IAAI,GAAG;IACV,oBAAoB,EAAE,oBAAoB,CAAA;IAC1C,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,EAAE,2BAA2B,CAAA;IAClD,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG;IAC/C,cAAc,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAA;IAC3D,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3C,sBAAsB,EAAE,sBAAsB,CAAA;CAC/C,CA0FA"}
|
|
@@ -2,7 +2,7 @@ import { getFromImportMap } from 'payload/shared';
|
|
|
2
2
|
export function initLexicalFeatures(args) {
|
|
3
3
|
const clientFeatures = {};
|
|
4
4
|
// turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:
|
|
5
|
-
const resolvedFeatureMapArray =
|
|
5
|
+
const resolvedFeatureMapArray = [...args.sanitizedEditorConfig.resolvedFeatureMap].sort((a, b) => a[1].order - b[1].order);
|
|
6
6
|
const featureClientSchemaMap = {};
|
|
7
7
|
/**
|
|
8
8
|
* All modules added to the import map, keyed by the provided key, if feature.componentImports with type object is used
|
|
@@ -42,7 +42,7 @@ export function initLexicalFeatures(args) {
|
|
|
42
42
|
// as well, as it already called feature.generateSchemaMap for each feature.
|
|
43
43
|
// We will check for the existance resolvedFeature.generateSchemaMap to skip unnecessary loops for constructing featureSchemaMap, but we don't run it here
|
|
44
44
|
if (resolvedFeature.generateSchemaMap) {
|
|
45
|
-
const featureSchemaPath =
|
|
45
|
+
const featureSchemaPath = `${args.schemaPath}.lexical_internal_feature.${featureKey}`;
|
|
46
46
|
featureClientSchemaMap[featureKey] = {};
|
|
47
47
|
// Like args.fieldSchemaMap, we only want to include the sub-fields of the current feature
|
|
48
48
|
for (const [key, entry] of args.clientFieldSchemaMap.entries()) {
|
|
@@ -50,17 +50,16 @@ export function initLexicalFeatures(args) {
|
|
|
50
50
|
featureClientSchemaMap[featureKey][key] = 'fields' in entry ? entry.fields : [entry];
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
53
|
+
}
|
|
54
|
+
if (resolvedFeature.componentImports && typeof resolvedFeature.componentImports === 'object' && !Array.isArray(resolvedFeature.componentImports)) {
|
|
55
|
+
for (const [key, payloadComponent] of Object.entries(resolvedFeature.componentImports)) {
|
|
56
|
+
const resolvedComponent = getFromImportMap({
|
|
57
|
+
importMap: args.payload.importMap,
|
|
58
|
+
PayloadComponent: payloadComponent,
|
|
59
|
+
schemaPath: 'lexical-clientComponent',
|
|
60
|
+
silent: true
|
|
61
|
+
});
|
|
62
|
+
featureClientImportMap[`${resolvedFeature.key}.${key}`] = resolvedComponent;
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initLexicalFeatures.js","names":["getFromImportMap","initLexicalFeatures","args","clientFeatures","resolvedFeatureMapArray","
|
|
1
|
+
{"version":3,"file":"initLexicalFeatures.js","names":["getFromImportMap","initLexicalFeatures","args","clientFeatures","resolvedFeatureMapArray","sanitizedEditorConfig","resolvedFeatureMap","sort","a","b","order","featureClientSchemaMap","featureClientImportMap","featureKey","resolvedFeature","ClientFeaturePayloadComponent","ClientFeature","clientFeatureProvider","importMap","payload","PayloadComponent","schemaPath","silent","clientFeatureProps","key","clientProps","generateSchemaMap","featureSchemaPath","entry","clientFieldSchemaMap","entries","startsWith","fields","componentImports","Array","isArray","payloadComponent","Object","resolvedComponent"],"sources":["../../src/utilities/initLexicalFeatures.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport { type ClientFieldSchemaMap, type FieldSchemaMap, type Payload } from 'payload'\nimport { getFromImportMap } from 'payload/shared'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from '../features/typesClient.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { FeatureClientSchemaMap, LexicalRichTextFieldProps } from '../types.js'\ntype Args = {\n clientFieldSchemaMap: ClientFieldSchemaMap\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 featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n} {\n const clientFeatures: LexicalRichTextFieldProps['clientFeatures'] = {}\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = [...args.sanitizedEditorConfig.resolvedFeatureMap].sort(\n (a, b) => a[1].order - b[1].order,\n )\n\n const featureClientSchemaMap: FeatureClientSchemaMap = {}\n\n /**\n * All modules added to the import map, keyed by the provided key, if feature.componentImports with type object is used\n */\n const featureClientImportMap: Record<string, any> | undefined = {}\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: BaseClientFeatureProps<Record<string, any>> =\n 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 // 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)\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 = `${args.schemaPath}.lexical_internal_feature.${featureKey}`\n\n featureClientSchemaMap[featureKey] = {}\n\n // Like args.fieldSchemaMap, we only want to include the sub-fields of the current feature\n for (const [key, entry] of args.clientFieldSchemaMap.entries()) {\n if (key.startsWith(featureSchemaPath)) {\n featureClientSchemaMap[featureKey][key] = 'fields' in entry ? entry.fields : [entry]\n }\n }\n }\n\n if (\n resolvedFeature.componentImports &&\n typeof resolvedFeature.componentImports === 'object' &&\n !Array.isArray(resolvedFeature.componentImports)\n ) {\n for (const [key, payloadComponent] of Object.entries(resolvedFeature.componentImports)) {\n const resolvedComponent = getFromImportMap({\n importMap: args.payload.importMap,\n PayloadComponent: payloadComponent,\n schemaPath: 'lexical-clientComponent',\n silent: true,\n })\n\n featureClientImportMap[`${resolvedFeature.key}.${key}`] = resolvedComponent\n }\n }\n }\n return {\n clientFeatures,\n featureClientImportMap,\n featureClientSchemaMap,\n }\n}\n"],"mappings":"AAGA,SAASA,gBAAgB,QAAQ;AAkBjC,OAAO,SAASC,oBAAoBC,IAAU;EAK5C,MAAMC,cAAA,GAA8D,CAAC;EAErE;EACA,MAAMC,uBAAA,GAA0B,C,GAAIF,IAAA,CAAKG,qBAAqB,CAACC,kBAAkB,CAAC,CAACC,IAAI,CACrF,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAC,CAAC,EAAE,CAACE,KAAK,GAAGD,CAAC,CAAC,EAAE,CAACC,KAAK;EAGnC,MAAMC,sBAAA,GAAiD,CAAC;EAExD;;;EAGA,MAAMC,sBAAA,GAA0D,CAAC;EAEjE,KAAK,MAAM,CAACC,UAAA,EAAYC,eAAA,CAAgB,IAAIV,uBAAA,EAAyB;IACnED,cAAc,CAACU,UAAA,CAAW,GAAG,CAAC;IAE9B;;;IAGA,MAAME,6BAAA,GAAgCD,eAAA,CAAgBE,aAAa;IAEnE,IAAID,6BAAA,EAA+B;MACjC,MAAME,qBAAA,GAAwBjB,gBAAA,CAAgD;QAC5EkB,SAAA,EAAWhB,IAAA,CAAKiB,OAAO,CAACD,SAAS;QACjCE,gBAAA,EAAkBL,6BAAA;QAClBM,UAAA,EAAY;QACZC,MAAA,EAAQ;MACV;MAEA,IAAI,CAACL,qBAAA,EAAuB;QAC1B;MACF;MAEA,MAAMM,kBAAA,GACJT,eAAA,CAAgBS,kBAAkB,IAAI,CAAC;MACzCA,kBAAA,CAAmBV,UAAU,GAAGC,eAAA,CAAgBU,GAAG;MACnDD,kBAAA,CAAmBb,KAAK,GAAGI,eAAA,CAAgBJ,KAAK;MAChD,IACE,OAAOK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EACA,OAAO;IACLnC,cAAA;IACAS,sBAAA;IACAD;EACF;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.61.0-
|
|
3
|
+
"version": "3.61.0-internal.7d69f4e",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -374,8 +374,8 @@
|
|
|
374
374
|
"react-error-boundary": "4.1.2",
|
|
375
375
|
"ts-essentials": "10.0.3",
|
|
376
376
|
"uuid": "10.0.0",
|
|
377
|
-
"@payloadcms/translations": "3.61.0-
|
|
378
|
-
"@payloadcms/ui": "3.61.0-
|
|
377
|
+
"@payloadcms/translations": "3.61.0-internal.7d69f4e",
|
|
378
|
+
"@payloadcms/ui": "3.61.0-internal.7d69f4e"
|
|
379
379
|
},
|
|
380
380
|
"devDependencies": {
|
|
381
381
|
"@babel/cli": "7.27.2",
|
|
@@ -395,15 +395,15 @@
|
|
|
395
395
|
"esbuild-sass-plugin": "3.3.1",
|
|
396
396
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
397
397
|
"@payloadcms/eslint-config": "3.28.0",
|
|
398
|
-
"payload": "3.61.0-
|
|
398
|
+
"payload": "3.61.0-internal.7d69f4e"
|
|
399
399
|
},
|
|
400
400
|
"peerDependencies": {
|
|
401
401
|
"@faceless-ui/modal": "3.0.0",
|
|
402
402
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
403
403
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
404
404
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
405
|
-
"@payloadcms/next": "3.61.0-
|
|
406
|
-
"payload": "3.61.0-
|
|
405
|
+
"@payloadcms/next": "3.61.0-internal.7d69f4e",
|
|
406
|
+
"payload": "3.61.0-internal.7d69f4e"
|
|
407
407
|
},
|
|
408
408
|
"engines": {
|
|
409
409
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as we,e as ke,f as _,h as De,i as Te,j as ve,k as Me,l as Le}from"./chunk-AFXLIYGL.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as Dn,FieldError as Tn,FieldLabel as vn,RenderCustomComponent as bt,useEditDepth as Mn,useEffectEvent as Ln,useField as An}from"@payloadcms/ui";import{mergeFieldStyles as Bn}from"@payloadcms/ui/shared";import{dequal as In}from"dequal/lite";import Nt,{useCallback as Pt,useEffect as St,useMemo as _n,useState as Rt}from"react";import{ErrorBoundary as On}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as Rn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as wn}from"@payloadcms/ui";import*as xt from"react";import{useMemo as kn}from"react";import{c as cn}from"react/compiler-runtime";import{jsx as E,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as dn}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as un}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as mn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as fn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as pn}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as gn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as hn,COMMAND_PRIORITY_LOW as ht,FOCUS_COMMAND as yn}from"lexical";import*as q from"react";import{useEffect as xn,useState as En}from"react";import{jsx as Ae}from"react/jsx-runtime";import"react";var $=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ae(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ae(o.Component,{clientProps:e});import{c as Dt}from"react/compiler-runtime";import{copyToClipboard as Tt}from"@lexical/clipboard";import{useLexicalComposerContext as vt}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Mt}from"@lexical/utils";import Be from"bson-objectid";import{COMMAND_PRIORITY_LOW as Lt,COPY_COMMAND as At}from"lexical";import{useEffect as Bt}from"react";function Ie(){let t=Dt(3),[e]=vt(),o,r;return t[0]!==e?(o=()=>e.registerCommand(At,n=>(Tt(e,Mt(n,ClipboardEvent)?n:null).then(()=>{if(!(n instanceof ClipboardEvent)||!n.clipboardData)throw new Error("No clipboard event");let c=n.clipboardData.getData("application/x-lexical-editor");if(!c)return!0;let i=JSON.parse(c),l=u=>{if("fields"in u&&typeof u.fields=="object"&&u.fields!==null&&"id"in u.fields?u.fields.id=new Be.default().toHexString():"id"in u&&(u.id=new Be.default().toHexString()),u.children)for(let y of u.children)l(y)};for(let u of i.nodes)l(u);let d=JSON.stringify(i);n.clipboardData.setData("application/x-lexical-editor",d)}).catch(c=>{throw n instanceof ClipboardEvent&&n.clipboardData?.setData("application/x-lexical-editor",""),c}),!0),Lt),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),Bt(o,r),null}import{c as It}from"react/compiler-runtime";import{useLexicalComposerContext as _t}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Ot}from"@lexical/utils";import{$createNodeSelection as Ft,$getEditor as X,$getNearestNodeFromDOMNode as $t,$getSelection as re,$isDecoratorNode as K,$isElementNode as xe,$isLineBreakNode as Kt,$isNodeSelection as ie,$isRangeSelection as _e,$isRootOrShadowRoot as Ht,$isTextNode as jt,$setSelection as Oe,CLICK_COMMAND as zt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as Wt,KEY_ARROW_UP_COMMAND as Yt,KEY_BACKSPACE_COMMAND as Vt,KEY_DELETE_COMMAND as Gt,SELECTION_CHANGE_COMMAND as Ut}from"lexical";import{useEffect as qt}from"react";function Fe(){let t=It(3),[e]=_t(),o=oo,r,n;return t[0]!==e?(r=()=>Ot(e.registerCommand(zt,to,W),e.registerCommand(Gt,o,W),e.registerCommand(Vt,o,W),e.registerCommand(Ut,eo,W),e.registerCommand(Yt,Xt,W),e.registerCommand(Wt,Jt,W)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),qt(r,n),null}function Jt(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(K(i)){let u=X().getElementByKey(i.getKey());return u&&Z({element:u,node:i}),!0}if(!xe(i))return!0;let l=i.getFirstDescendant()??i;return l&&(ne(l,se)?.selectEnd(),t.preventDefault()),!0}if(!_e(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Qt),c=n?.getNextSibling();if(!n||c!==$e(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Qt(t){return $e(t)!==null}function Xt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(K(i)){let u=X().getElementByKey(i.getKey());return u?(Z({element:u,node:i}),t.preventDefault(),!0):!1}if(!xe(i))return!1;let l=i.getLastDescendant()??i;return l?(ne(l,se)?.selectStart(),t.preventDefault(),!0):!1}if(!_e(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Zt),c=n?.getPreviousSibling();if(!n||c!==Ke(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Zt(t){return Ke(t)!==null}function eo(){let t=io();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function to(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=ro(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Oe(null):Z(e),!0}function oo(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(no),!0):!1}function no(t){t.remove()}function ro(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=$t(e);return K(o)?{element:e,node:o}:void 0}function io(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return K(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Ft();o.add(e.getKey()),Oe(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(K(t)&&!t.isInline())return!0;if(!xe(t)||Ht(t))return!1;let e=t.getFirstChild(),o=e===null||Kt(e)||jt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function $e(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function Ke(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ee}from"react/jsx-runtime";import{useLexicalComposerContext as mo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as fo,isHTMLElement as po}from"lexical";import*as We from"react";import{useCallback as go,useEffect as ze,useRef as ho,useState as yo}from"react";import{createPortal as xo}from"react-dom";var Y=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:l,left:d,right:u,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,a=l+window.scrollY;if(o<s-c||o>a+c||e<d-n||e>u+n)return-1;(e<d||e>u)&&(i=e<d?e-d:e-u)}return i};import{$getNodeByKey as ae}from"lexical";function V(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(d,u)=>d?parseFloat(window.getComputedStyle(d)[u]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as so}from"lexical";function H(t){return t.getEditorState().read(()=>so().getChildrenKeys())}var lo=1,ao=-1,He=0,A={props:null,result:null};function co(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:l},startIndex:d=0,useEdgeAsDefault:u=!1}=t;if(o>0&&A.props&&A.result&&A.props.fuzzy===t.fuzzy&&A.props.horizontalOffset===t.horizontalOffset&&A.props.useEdgeAsDefault===t.useEdgeAsDefault&&co(A.props.point,t.point,o))return A.result;let y=e.getBoundingClientRect(),s=H(r),a={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(u){let g=r.getElementByKey(s[0]),m=r.getElementByKey(s[s.length-1]);if(g&&m){let[p,f]=[V(g),V(m)];if(l<p.top?(a.blockElem=g,a.distance=p.top-l,a.blockNode=ae(s[0]),a.foundAtIndex=0):l>f.bottom&&(a.distance=l-f.bottom,a.blockNode=ae(s[s.length-1]),a.blockElem=m,a.foundAtIndex=s.length-1),a?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let h=d,x=He;for(;h>=0&&h<s.length;){let g=s[h],m=r.getElementByKey(g);if(m===null)break;let p=new _(i+c,l),f=Me.fromDOMRect(V(m)),{marginBottom:C,marginTop:k}=le(m),S=f.generateNewRect({bottom:f.bottom+C,left:y.left,right:y.right,top:f.top-k}),{distance:b,isOnBottomSide:w,isOnTopSide:N}=S.distanceFromPoint(p);if(b===0){a.blockElem=m,a.blockNode=ae(g),a.foundAtIndex=h,a.distance=b,a.blockNode&&a.blockNode.getType()==="paragraph"&&a.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(a.blockElem=null,a.blockNode=null),a.isFoundNodeEmptyParagraph=!0);break}else n&&b<a.distance&&(a.blockElem=m,a.blockNode=ae(g),a.distance=b,a.foundAtIndex=h);x===He&&(N?x=ao:w?x=lo:x=1/0),h+=x}}),A.props=t,A.result={blockElem:a.blockElem,blockNode:a.blockNode,foundAtIndex:a.foundAtIndex,isFoundNodeEmptyParagraph:a.isFoundNodeEmptyParagraph},{blockElem:a.blockElem,blockNode:a.blockNode,foundAtIndex:a.foundAtIndex,isFoundNodeEmptyParagraph:a.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var uo=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function je(t){if(!t||uo.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 de(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),l=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))d=n.top+8-l.top;else{let s=je(t)?parseInt(c.lineHeight,10):0;d=n.top+(s-i.height)/2-l.top}let y=r;e.style.opacity="1",e.style.transform=`translate(${y}px, ${d}px)`}var Eo="add-block-menu",ue=1/0;function Co(t){return t===0?1/0:ue>=0&&ue<t?ue:Math.floor(t/2)}function bo(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),c=n?.admin?.hideGutter?-24:12,i=ho(null),[l,d]=yo(null);ze(()=>{function y(s){let a=s.target;if(!po(a))return;let h=Y(r,s.pageX,s.pageY,a);if(h===-1){d(null);return}if(ce(a,Eo))return;let x=H(t),{blockElem:g,blockNode:m,foundAtIndex:p}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-h,point:new _(s.x,s.y),returnEmptyParagraphs:!0,startIndex:Co(x.length),useEdgeAsDefault:!1});ue=p,g&&m&&(l?.node!==m||l?.elem!==g)&&d({elem:g,node:m})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,l]),ze(()=>{i.current&&l?.node&&de(l?.elem,i.current,e,c)},[e,l,c]);let u=go(y=>{let s=l;s?.node&&(t.update(()=>{let a=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(a=!1),!a){let h=fo();s?.node.insertAfter(h),setTimeout(()=>{s={elem:t.getElementByKey(h.getKey()),node:h},d(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(Te,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,l]);return xo(Ee(We.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{u(y)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function Ye(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=mo();return bo(r,o,r._editable)}import{jsx as me,jsxs as Po}from"react/jsx-runtime";import{useLexicalComposerContext as So}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ue}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as qe,$getNodeByKey as Ro,isHTMLElement as Ce}from"lexical";import*as et from"react";import{useEffect as be,useRef as fe,useState as Je}from"react";import{createPortal as wo}from"react-dom";var Ve=0,No=-24;var j=0;function Ge(t,e,o,r,n,c,i,l,d,u=!1){let{height:y,top:s}=r.getBoundingClientRect(),{top:a,width:h}=i.getBoundingClientRect(),{marginBottom:x,marginTop:g}=le(r),m=s,p=c>=s+y/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(p&&n?.elem&&n?.elem===r.nextElementSibling||!p&&n?.elem&&n?.elem===r.previousElementSibling)&&(j++,j<200&&(f=!0));else{j++;let b=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(p===n?.isBelow&&b===w||j<200)&&(f=!1)}if(f)return{isBelow:p,willStayInSamePosition:f};u?m+=y/2:p?m+=y+x/2:m-=g/2;let C=0;u||(p?C=-Ve:C=Ve);let k=m-a+C,S=No-e;return o.style.width=`calc(${h}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${k}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?p?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),j=0,{isBelow:p,willStayInSamePosition:f}}var ko="draggable-block-menu",Qe="application/x-lexical-drag-block",ee=1/0;function Xe(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function Do(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Ze(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function To(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),l=fe(!1),[d,u]=Je(null),[y,s]=Je(null),{editorConfig:a}=R(),h=a?.admin?.hideGutter?-44:-8;be(()=>{function m(p){let f=p.target;if(!Ce(f))return;let C=Y(r,p.pageX,p.pageY,f);if(C===-1){u(null);return}if(ce(f,ko))return;let k=H(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:w}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-C,point:new _(p.x,p.y),startIndex:Xe(k.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!w)&&d!==S&&u(S)}return document?.addEventListener("mousemove",m),()=>{document?.removeEventListener("mousemove",m)}},[r,e,t,d]),be(()=>{n.current&&de(d,n.current,e,h)},[e,d,h]),be(()=>{function m(f){if(!l.current)return!1;let[C]=Ue(f);if(C)return!1;let{pageY:k,target:S}=f;if(!Ce(S))return!1;let b=Y(r,f.pageX,f.pageY,S,100,50),w=H(t),{blockElem:N,foundAtIndex:M,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new _(f.x,f.y),startIndex:Xe(w.length),useEdgeAsDefault:!0,verbose:!0});ee=M;let D=c.current;if(N===null||D===null)return!1;if(d!==N){let{isBelow:T,willStayInSamePosition:J}=Ge(a?.admin?.hideGutter?"0px":"3rem",h+(a?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),D,N,y,k,e,f,i,I);f.preventDefault(),J||s({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:T})}else y?.elem&&(Ze(D,y.elem),s({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function p(f){if(!l.current)return!1;let[C]=Ue(f);if(C)return!1;let{dataTransfer:k,pageY:S,target:b}=f,w=k?.getData(Qe)||"";return t.update(()=>{let N=Ro(w);if(!N||!Ce(b))return!1;let M=Y(r,f.pageX,f.pageY,b,100,50),{blockElem:I,isFoundNodeEmptyParagraph:D}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-M,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let T=qe(I);if(!T)return!1;if(T===N)return!0;let{height:J,top:he}=V(I),z=S>=he+J/2+window.scrollY;D?(T.insertBefore(N),T.remove()):z?T.insertAfter(N):T.insertBefore(N),d!==null&&u(null),document.querySelectorAll(".lexical-block-highlighter").forEach(v=>{v.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let v=oe?.getBoundingClientRect();if(!v)return;let P=document.createElement("div");P.className="lexical-block-highlighter",P.style.backgroundColor="var(--theme-elevation-1000",P.style.transition="opacity 0.5s ease-in-out",P.style.zIndex="1",P.style.pointerEvents="none",P.style.boxSizing="border-box",P.style.borderRadius="4px",P.style.position="absolute",document.body.appendChild(P),P.style.opacity="0.1",P.style.height=`${v.height+8}px`,P.style.width=`${v.width+8}px`,P.style.top=`${v.top+window.scrollY-4}px`,P.style.left=`${v.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",m),document.addEventListener("drop",p),()=>{document.removeEventListener("dragover",m),document.removeEventListener("drop",p)}},[r,h,e,t,y,d,a?.admin?.hideGutter]);function x(m){let p=m.dataTransfer;if(!p||!d)return;Do(p,d);let f="";t.update(()=>{let C=qe(d);C&&(f=C.getKey())}),l.current=!0,p.setData(Qe,f)}function g(){l.current=!1,y?.elem&&Ze(c.current,y?.elem)}return wo(Po(et.Fragment,{children:[me("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:g,onDragStart:x,ref:n,type:"button",children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function tt(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=So();return To(r,o,r._editable)}import{c as vo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Lo,$getRoot as Ao}from"lexical";import"react";var ot="insert-paragraph-at-end",nt=()=>{let t=vo(2),[e]=Mo(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;return t[0]!==e?(r=Ne("div",{"aria-label":"Insert Paragraph",className:ot,onClick:()=>{e.update(Bo)},role:"button",tabIndex:0,children:Ne("div",{className:`${ot}-inside`,children:Ne("span",{children:"+"})})}),t[0]=e,t[1]=r):r=t[1],r};function Bo(){let t=Lo();Ao().append(t),t.select()}import{c as Io}from"react/compiler-runtime";import{useLexicalComposerContext as _o}from"@lexical/react/LexicalComposerContext";import*as rt from"react";var it=()=>{let t=Io(4),{editorConfig:e}=R(),[o]=_o(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>we(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),rt.useEffect(r,n),null};import{useLexicalComposerContext as Oo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Fo,$isRangeSelection as $o,RootNode as Ko}from"lexical";import{useEffect as Ho}from"react";function st(){let[t]=Oo();return Ho(()=>t.registerNodeTransform(Ko,e=>{let o=Fo();if($o(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(e.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[t]),null}import{useLexicalComposerContext as jo}from"@lexical/react/LexicalComposerContext";import{$getSelection as zo,COMMAND_PRIORITY_LOW as Wo,SELECT_ALL_COMMAND as Yo}from"lexical";import{useEffect as Vo}from"react";function lt(){let[t]=jo();return Vo(()=>t.registerCommand(Yo,()=>{if(zo())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Wo),[t]),null}import{jsx as U,jsxs as ct}from"react/jsx-runtime";import{useLexicalComposerContext as Uo}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as dt}from"@payloadcms/ui";import{useCallback as qo,useMemo as Jo,useState as Qo}from"react";import"react";import*as ut from"react-dom";import{c as Go}from"react/compiler-runtime";import"react";function at(t,e){let o=Go(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,l;return o[0]!==c||o[1]!==i||o[2]!==t?(l=d=>{let{query:u}=d,y="[^"+t+De+"\\s]",a=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+c+"}))$").exec(u);if(a!==null){let h=a[1],x=a[3];if(x.length>=i)return{leadOffset:a.index+h.length,matchingString:x,replaceableString:a[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=l):l=o[3],l}var B="slash-menu-popup";function Xo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=R(),{i18n:l}=dt(),d=`${B}__item ${B}__item-${e.key}`;t&&(d+=` ${B}__item--selected`);let u=e.key;return e.label&&(u=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:l,schemaPath:i}):e.label),u.length>25&&(u=u.substring(0,25)+"..."),ct("button",{"aria-selected":t,className:d,id:B+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${B}__item-text`,children:u})]},e.key)}function mt({anchorElem:t=document.body}){let[e]=Uo(),[o,r]=Qo(null),{editorConfig:n}=R(),{i18n:c}=dt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=R(),d=at("/",{minLength:0}),u=qo(()=>{let s=[];for(let a of n.features.slashMenu.dynamicGroups)if(o){let h=a({editor:e,queryString:o});s=s.concat(h)}return s},[e,o,n?.features]),y=Jo(()=>{let s=[];for(let a of n?.features.slashMenu.groups??[])s.push(a);if(o){s=s.map(h=>{let x=h.items.filter(g=>{let m=g.key;return g.label&&(m=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):g.label),new RegExp(o,"gi").exec(m)?!0:g.keywords!=null?g.keywords.some(p=>new RegExp(o,"gi").exec(p)):!1});return x.length?{...h,items:x}:null}),s=s.filter(h=>h!=null);let a=u();for(let h of a){let x=s.find(g=>g.key===h.key);x?s=s.filter(g=>g.key!==h.key):x={...h,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,n?.features.slashMenu.groups,u,i,c,l]);return U(ve,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:a,selectItemAndCleanUp:h,setSelectedItemKey:x})=>s.current&&y.length?ut.createPortal(U("div",{className:B,children:y.map(g=>{let m=g.key;return g.label&&i&&(m=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):g.label),ct("div",{className:`${B}__group ${B}__group-${g.key}`,children:[U("div",{className:`${B}__group-title`,children:m}),g.items.map((p,f)=>U(Xo,{index:f,isSelected:a===p.key,item:p,onClick:()=>{x(p.key),h(p)},onMouseEnter:()=>{x(p.key)},ref:C=>{p.ref={current:C}}},p.key))]},g.key)})}),s.current):null,onQueryChange:r,triggerFn:d})}import{c as Zo}from"react/compiler-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as tn,TextNode as on}from"lexical";import{useEffect as nn}from"react";function ft(t){let e=Zo(6),{features:o}=t,[r]=en(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=rn(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(on,l=>{i.forEach(d=>{l.hasFormat(d)&&l.toggleFormat(d)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],nn(n,c),null}function rn(t){let e=Object.keys(tn),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as sn}from"react/compiler-runtime";import{jsx as pt}from"react/jsx-runtime";import{ContentEditable as ln}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as an}from"@payloadcms/ui";import"react";function gt(t){let e=sn(4),{className:o,editorConfig:r}=t,{t:n}=an(),c;return e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n?(c=pt(ln,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:pt("p",{className:"editor-placeholder",children:r?.admin?.placeholder??n("lexical:general:placeholder")})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c):c=e[3],c}var yt=t=>{let e=cn(12),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=R(),[l]=dn(),d=gn(),[u,y]=En(null),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=m=>{m!==null&&y(m)},e[0]=s):s=e[0];let a=s,h,x;e[1]!==l||e[2]!==i?(h=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},p=()=>{i.blurEditor(i)},f=l.registerCommand(yn,()=>(m(),!0),ht),C=l.registerCommand(hn,()=>(p(),!0),ht);return()=>{f(),C(),i.parentEditor?.unregisterChild?.(i.uuid)}},x=[l,i],e[1]=l,e[2]=i,e[3]=h,e[4]=x):(h=e[3],x=e[4]),xn(h,x);let g;return e[5]!==o||e[6]!==r||e[7]!==u||e[8]!==d||e[9]!==n||e[10]!==c?(g=te(q.Fragment,{children:[o.features.plugins?.map(Cn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(bn),E(pn,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:a,children:E(gt,{editorConfig:o})})}),ErrorBoundary:un}),E(st,{}),d&&E(nt,{}),E(Fe,{}),E(Ie,{}),E(ft,{features:o.features}),E(lt,{}),d&&E(fn,{ignoreSelectionChange:!0,onChange:(m,p,f)=>{(!f.has("focus")||f.size>1)&&c?.(m,p,f)}}),u&&te(q.Fragment,{children:[!n&&d&&te(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:E(tt,{anchorElem:u}),o.admin?.hideAddBlockButton?null:E(Ye,{anchorElem:u})]}),o.features.plugins?.map(m=>{if(m.position==="floatingAnchorElem"&&!(m.desktopOnly===!0&&n))return E($,{anchorElem:u,clientProps:m.clientProps,plugin:m},m.key)}),d&&E(q.Fragment,{children:E(mt,{anchorElem:u})})]}),d&&te(q.Fragment,{children:[E(mn,{}),o?.features?.markdownTransformers?.length>0&&E(it,{})]}),o.features.plugins?.map(Nn),o.features.plugins?.map(Pn)]}),o.features.plugins?.map(Sn)]}),e[5]=o,e[6]=r,e[7]=u,e[8]=d,e[9]=n,e[10]=c,e[11]=g):g=e[11],g};function Cn(t){if(t.position==="aboveContainer")return E($,{clientProps:t.clientProps,plugin:t},t.key)}function bn(t){if(t.position==="top")return E($,{clientProps:t.clientProps,plugin:t},t.key)}function Nn(t){if(t.position==="normal")return E($,{clientProps:t.clientProps,plugin:t},t.key)}function Pn(t){if(t.position==="bottom")return E($,{clientProps:t.clientProps,plugin:t},t.key)}function Sn(t){if(t.position==="belowContainer")return E($,{clientProps:t.clientProps,plugin:t},t.key)}var Et=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(Et,{providers:e.slice(1),children:t})}):O(o,{children:t})},Ct=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:l}=t,d=R(),u=wn(),y=xt.useRef(null),s=kn(()=>{if(l&&typeof l!="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(l));if(l&&Array.isArray(l)&&!("root"in l))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/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)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/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:i!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:Le({editorConfig:o}),onError:a=>{throw a},theme:o.lexical.theme}},[o]);return s?O(Rn,{initialConfig:s,children:O(Re,{editorConfig:o,editorContainerRef:y,fieldProps:r,parentContext:d?.editDepth===u?d:void 0,children:O(Et,{providers:o.features.providers,children:O(yt,{editorConfig:o,editorContainerRef:y,isSmallWidthViewport:n,onChange:c})})})},e+s.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",Fn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:l,required:d},path:u,readOnly:y,validate:s}=t,a=y||c,h=Mn(),x=Pt((L,Q)=>typeof s=="function"?s(L,{...Q,required:d}):!0,[s,d]),{customComponents:{AfterInput:g,BeforeInput:m,Description:p,Error:f,Label:C}={},disabled:k,initialValue:S,path:b,setValue:w,showError:N,value:M}=An({potentiallyStalePath:u,validate:x}),I=a||k,[D,T]=Rt(!1),[J,he]=Rt(),ye=Nt.useRef(S),z=Nt.useRef(M);St(()=>{let L=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==D&&T(Q)};return L(),window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L)}},[D]);let Pe=[pe,"field-type",r,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!D?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${h}`,v=ke(),P=Pt(L=>{v(()=>{let Se=L.toJSON();z.current=Se,w(Se)})},[w,v]),wt=_n(()=>Bn(o),[o]),kt=Ln(L=>{z.current!==M&&!In(JSON.parse(JSON.stringify(z.current)),M)&&(ye.current=L,z.current=M,he(new Date))});return St(()=>{Object.is(S,ye.current)||kt(S)},[S]),ge("div",{className:Pe,style:wt,children:[F(bt,{CustomComponent:f,Fallback:F(Tn,{path:b,showError:N})}),C||F(vn,{label:i,localized:l,path:b,required:d}),ge("div",{className:`${pe}__wrap`,children:[ge(On,{fallbackRender:$n,onReset:()=>{},children:[m,F(Ct,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:D,onChange:P,readOnly:I,value:M},JSON.stringify({path:b,rerenderProviderKey:J})),g]}),F(bt,{CustomComponent:p,Fallback:F(Dn,{description:n,path:b})})]})]},oe)};function $n({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Ms=Fn;export{Ms as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-YYMTSGSP.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as h}from"./chunk-DBWINSQN.js";import{a as f}from"./chunk-F26IQ5RE.js";import{jsx as o,jsxs as c}from"react/jsx-runtime";import{useLexicalComposerContext as S}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as j}from"@lexical/react/useLexicalEditable";import{getTranslation as B}from"@payloadcms/translations";import{Button as b,useConfig as L,usePayloadAPI as A,useTranslation as I}from"@payloadcms/ui";import{$getNodeByKey as P}from"lexical";import k,{useCallback as H,useReducer as K,useRef as M,useState as O}from"react";var e="lexical-relationship",_={depth:0},X=g=>{let{data:{relationTo:R,value:l},nodeKey:a}=g;if(typeof l=="object")throw new Error("Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.");let v=M(null),[s]=S(),i=j(),{config:{routes:{api:C},serverURL:x},getEntityConfig:N}=L(),[t]=O(()=>N({collectionSlug:R})),{i18n:$,t:n}=I(),[u,w]=K(r=>r+1,0),[{data:m},{setParams:d}]=A(`${x}${C}/${t.slug}/${l}`,{initialParams:_}),{closeDocumentDrawer:p,DocumentDrawer:D,DocumentDrawerToggler:E}=f({id:l,collectionSlug:t.slug}),T=H(()=>{s.update(()=>{P(a)?.remove()})},[s,a]),y=k.useCallback(()=>{d({..._,cacheBust:u}),p(),w()},[u,d,p]);return c("div",{className:e,contentEditable:!1,ref:v,children:[c("div",{className:`${e}__wrap`,children:[o("p",{className:`${e}__label`,children:n("fields:labelRelationship",{label:t.labels?.singular?B(t.labels?.singular,$):t.slug})}),o(E,{className:`${e}__doc-drawer-toggler`,children:o("p",{className:`${e}__title`,children:m?m[t?.admin?.useAsTitle||"id"]:l})})]}),i&&c("div",{className:`${e}__actions`,children:[o(b,{buttonStyle:"icon-label",className:`${e}__swapButton`,disabled:!i,el:"button",icon:"swap",onClick:()=>{a&&s.dispatchCommand(h,{replace:{nodeKey:a}})},round:!0,tooltip:n("fields:swapRelationship")}),o(b,{buttonStyle:"icon-label",className:`${e}__removeButton`,disabled:!i,icon:"x",onClick:r=>{r.preventDefault(),T()},round:!0,tooltip:n("fields:removeRelationship")})]}),!!l&&o(D,{onSave:y})]})};export{X as RelationshipComponent};
|
|
2
|
-
//# sourceMappingURL=RelationshipComponent-JXQOFHXF.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/features/relationship/client/components/RelationshipComponent.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport './index.scss'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nexport const RelationshipComponent: React.FC<Props> = (props) => {\n const {\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const [relatedCollection] = useState(() => getEntityConfig({ collectionSlug: relationTo }))\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey!)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(() => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n return (\n <div className={baseClass} contentEditable={false} ref={relationshipElemRef}>\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\n </p>\n </DocumentDrawerToggler>\n </div>\n {isEditable && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n"],
|
|
5
|
-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E,2BAAA,OAKhB,CAAC,CAACnB,GAAS4C,EAACf,EAAA,CAAemC,OAAQ1B,MAG1C",
|
|
6
|
-
"names": ["useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "useConfig", "usePayloadAPI", "useTranslation", "$getNodeByKey", "React", "useCallback", "useReducer", "useRef", "useState", "baseClass", "initialParams", "depth", "RelationshipComponent", "props", "data", "relationTo", "value", "nodeKey", "Error", "relationshipElemRef", "useRef", "editor", "useLexicalComposerContext", "isEditable", "useLexicalEditable", "config", "routes", "api", "serverURL", "getEntityConfig", "useConfig", "relatedCollection", "useState", "collectionSlug", "i18n", "t", "useTranslation", "cacheBust", "dispatchCacheBust", "useReducer", "state", "setParams", "usePayloadAPI", "slug", "closeDocumentDrawer", "DocumentDrawer", "DocumentDrawerToggler", "useLexicalDocumentDrawer", "id", "removeRelationship", "useCallback", "update", "$getNodeByKey", "remove", "updateRelationship", "React", "_jsxs", "className", "contentEditable", "ref", "_jsx", "label", "labels", "singular", "getTranslation", "admin", "useAsTitle", "Button", "buttonStyle", "disabled", "el", "icon", "onClick", "dispatchCommand", "INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND", "replace", "round", "tooltip", "e", "preventDefault", "onSave"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as ie}from"./chunk-INBEEENE.js";import{b as se}from"./chunk-BZZVLW4U.js";import{jsx as r,jsxs as b,Fragment as Ne}from"react/jsx-runtime";import $,{createContext as ve,useCallback as A,useEffect as N,useMemo as v,useRef as S}from"react";import{useLexicalComposerContext as $e}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Oe}from"@lexical/react/useLexicalEditable";import{getTranslation as ce}from"@payloadcms/translations";import{Button as ae,Drawer as Te,EditDepthProvider as Re,Form as Pe,formatDrawerSlug as Le,FormSubmit as Ee,RenderFields as je,ShimmerEffect as Me,useConfig as Ae,useDocumentForm as Je,useDocumentInfo as Ke,useEditDepth as ze,useServerFunctions as He,useTranslation as Ve}from"@payloadcms/ui";import{abortAndIgnore as J}from"@payloadcms/ui/shared";import{$getNodeByKey as K}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as z,reduceFieldsToValues as We}from"payload/shared";import{v4 as qe}from"uuid";import{jsx as _e}from"react/jsx-runtime";import ye from"bson-objectid";import{$applyNodeReplacement as Fe}from"lexical";import De from"react";import Be from"bson-objectid";import{$applyNodeReplacement as xe,DecoratorNode as Se}from"lexical";var x=class extends Se{__cacheBuster;__fields;constructor({cacheBuster:e,fields:t,key:l}){super(l),this.__fields=t,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return Ce(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(){let e=document.createElement("span");return e.classList.add("inline-block-container"),e}decorate(e,t){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let t=document.createTextNode(this.getTextContent());return e.append(t),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e,t){let l=this.getWritable();l.__fields=e,t||l.__cacheBuster++}updateDOM(){return!1}};function Ce(s){return xe(new x({fields:{...s,id:s?.id||new Be.default().toHexString()}}))}var we=De.lazy(()=>import("./componentInline-BVC77WQC.js").then(s=>({default:s.InlineBlockComponent}))),I=class extends x{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return Ie(e.fields)}decorate(e,t){return _e(we,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ie(s){return Fe(new I({fields:{...s,id:s?.id||new ye.default().toHexString()}}))}function M(s){return s instanceof I}var p="inline-block",ue=ve({initialState:!1}),ht=()=>$.use(ue),gt=s=>{let{cacheBuster:e,formData:t,nodeKey:l}=s,[f]=$e(),c=Oe(),{i18n:O,t:m}=Ve(),{createdInlineBlock:H,fieldProps:{featureClientSchemaMap:de,initialLexicalFormState:me,schemaPath:V},setCreatedInlineBlock:W,uuid:pe}=se(),{fields:C}=Je(),{getFormState:_}=He(),fe=ze(),q=S(!1),[a,T]=$.useState(()=>me?.[t.id]?.formState),G=S(!1),Q=S(e);N(()=>{G.current?(Q.current!==e&&T(!1),Q.current=e):G.current=!0},[e]);let[R,U]=$.useState(a?._components?.customComponents?.BlockLabel),[X,Y]=$.useState(a?._components?.customComponents?.Block),Z=Le({slug:`lexical-inlineBlocks-create-${pe}-${t.id}`,depth:fe}),{toggleDrawer:k}=ie(Z,!0),be=S(null),{id:y,collectionSlug:F,getDocPreferences:D,globalSlug:w}=Ke(),{config:ke}=Ae(),he=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${t.blockType}`,h=de.blocks?.[he]?.[0],u=h.blockReferences?typeof h?.blockReferences?.[0]=="string"?ke.blocksMap[h?.blockReferences?.[0]]:h?.blockReferences?.[0]:h?.blocks?.[0],ee=u?.fields??[];N(()=>{!q.current&&H?.getKey()===l&&(ee.length>2&&k(),W?.(void 0),q.current=!0)},[ee.length,H,l,W,k]);let te=A(()=>{f.update(()=>{K(l)?.remove()})},[f,l]),g=u?.labels?.singular?ce(u?.labels.singular,O):u?.slug,P=S(new AbortController),B=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${u?.slug}.fields`;N(()=>{let n=new AbortController;return t&&!a&&(async()=>{let{state:o}=await _({id:y,collectionSlug:F,data:t,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:z(C),globalSlug:w,initialBlockData:t,initialBlockFormState:t,operation:"update",readOnly:!c,renderAllFields:!0,schemaPath:B,signal:n.signal});if(o){let d=We(z(o),!0);f.update(()=>{let j=K(l);if(j&&M(j)){let le=d;le.blockType=t.blockType,j.setFields(le,!0)}}),T(o),U(o._components?.customComponents?.BlockLabel),Y(o._components?.customComponents?.Block)}})(),()=>{J(n)}},[_,f,l,c,B,y,t,a,F,w,D,C]);let ne=A(async({formState:n,submit:i})=>{J(P.current);let o=new AbortController;P.current=o;let{state:d}=await _({id:y,collectionSlug:F,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:z(C),formState:n,globalSlug:w,initialBlockFormState:n,operation:"update",readOnly:!c,renderAllFields:!!i,schemaPath:B,signal:o.signal});return d?(i&&(U(d._components?.customComponents?.BlockLabel),Y(d._components?.customComponents?.Block)),d):n},[_,y,F,D,C,w,c,B]);N(()=>{let n=(i,o)=>Object.keys(o).some(d=>o[d]&&i[d]!==o[d].value);return()=>{a&&n(t,a)&&T(!1),J(P.current)}},[t,a]);let ge=A((n,i)=>{i.blockType=t.blockType,f.update(()=>{let o=K(l);o&&M(o)&&o.setFields(i,!0)})},[f,l,t]),L=v(()=>()=>r(ae,{buttonStyle:"icon-label",className:`${p}__removeButton`,disabled:!c,icon:"x",onClick:n=>{n.preventDefault(),te()},round:!0,size:"small",tooltip:m("lexical:blocks:inlineBlocks:remove",{label:g})}),[g,c,te,m]),oe=v(()=>()=>r(ae,{buttonStyle:"icon-label",className:`${p}__editButton`,disabled:!c,el:"button",icon:"edit",onClick:()=>{k()},round:!0,size:"small",tooltip:m("lexical:blocks:inlineBlocks:edit",{label:g})}),[g,c,m,k]),E=v(()=>({children:n,className:i})=>r("div",{className:[p,p+"-"+t.blockType,i].filter(Boolean).join(" "),ref:be,children:n}),[t.blockType]),re=v(()=>R?()=>R:()=>r("div",{children:u?.labels?ce(u?.labels.singular,O):""}),[R,u?.labels,O]);return u?b(Pe,{beforeSubmit:[async({formState:n})=>await ne({formState:n,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:u?.fields,initialState:a||{},onChange:[ne],onSubmit:(n,i)=>{ge(n,i),k()},uuid:qe(),children:[r(Re,{children:r(Te,{className:"",slug:Z,title:m(`lexical:blocks:inlineBlocks:${t?.id?"edit":"create"}`,{label:g??m("lexical:blocks:inlineBlocks:label")}),children:a?b(Ne,{children:[r(je,{fields:u?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:B,permissions:!0,readOnly:!c}),r(Ee,{programmaticSubmit:!0,children:m("fields:saveChanges")})]}):null})}),X?r(ue,{value:{EditButton:oe,initialState:a,InlineBlockContainer:E,Label:re,nodeKey:l,RemoveButton:L},children:X}):b(E,{children:[a?r(re,{}):r(Me,{height:"15px",width:"40px"}),c?b("div",{className:`${p}__actions`,children:[r(oe,{}),r(L,{})]}):null]})]}):b(E,{className:`${p}-not-found`,children:[b("span",{children:["Error: Block '",t.blockType,"' not found"]}),c?r("div",{className:`${p}__actions`,children:r(L,{})}):null]})};export{ht as a,gt as b,I as c,Ie as d,M as e};
|
|
2
|
-
//# sourceMappingURL=chunk-RPFDD27K.js.map
|