@payloadcms/richtext-lexical 3.65.0-internal.098b771 → 3.65.0-internal.19683e7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/Field-CFLUGR3C.js +2 -0
- package/dist/exports/client/Field-CFLUGR3C.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-6NIGQP6A.js +12 -0
- package/dist/exports/client/chunk-6NIGQP6A.js.map +7 -0
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +20 -20
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/react/index.d.ts +1 -1
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +9 -1
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -14
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +4 -2
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +16 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +76 -4
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.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/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +10 -5
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RichTextViewProvider.d.ts +83 -0
- package/dist/field/RichTextViewProvider.d.ts.map +1 -0
- package/dist/field/RichTextViewProvider.js +87 -0
- package/dist/field/RichTextViewProvider.js.map +1 -0
- package/dist/field/ViewSelector.d.ts +4 -0
- package/dist/field/ViewSelector.d.ts.map +1 -0
- package/dist/field/ViewSelector.js +89 -0
- package/dist/field/ViewSelector.js.map +1 -0
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts +1 -0
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +47 -29
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +12 -0
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +2 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +12 -3
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +3 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +4 -0
- package/dist/lexical/config/types.d.ts.map +1 -1
- package/dist/lexical/config/types.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +12 -2
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +195 -2
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +48 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
- package/dist/types.d.ts +136 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +1 -0
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +6 -1
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +10 -4
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-QUXIGJRC.js +0 -2
- package/dist/exports/client/Field-QUXIGJRC.js.map +0 -7
- package/dist/exports/client/chunk-AFXLIYGL.js +0 -12
- package/dist/exports/client/chunk-AFXLIYGL.js.map +0 -7
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?: 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
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n EditorConfig,\n LexicalEditor,\n EditorConfig as LexicalEditorConfig,\n LexicalNode,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n PayloadComponent,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport type { JSXConverterArgs } from './features/converters/lexicalToJSX/converter/types.js'\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 {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from './nodeTypes.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\ntype WithinEditorArgs = {\n config: EditorConfig\n editor: LexicalEditor\n node: LexicalNode\n}\n\nexport type NodeMapValue<\n TNode extends { [key: string]: any; type?: string } = SerializedLexicalNode,\n> = {\n /**\n * Provide a react component to render the node.\n *\n * **JSX Converter:** Always works. Takes priority over `html`.\n *\n * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.\n */\n Component?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n } & WithinEditorArgs),\n ) => JSX.Element\n /**\n * Provide a function to create the DOM element for the node.\n *\n * **JSX Converter:** Not used (only `Component` and `html` work).\n *\n * **Lexical Editor:** Always works (renders in `createDOM` method).\n * - For ElementNodes: This is the standard way to customize rendering.\n * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.\n */\n createDOM?: (args: WithinEditorArgs) => HTMLElement\n /**\n * Provide HTML string or function to render the node.\n *\n * **JSX Converter:** Always works (ignored if `Component` is provided).\n *\n * **Lexical Editor behavior depends on node type:**\n *\n * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.\n *\n * - **DecoratorNodes (have both `createDOM` and `decorate`):**\n * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`\n * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`\n * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content\n * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)\n */\n html?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n } & WithinEditorArgs),\n ) => string\n}\n\n/**\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorNodeMap<\n TNodes extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: NodeMapValue<any>\n }\n | NodeMapValue<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<\n Extract<TNodes, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapValue<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? SerializedBlockNode<Extract<B, { blockType: K }>>\n : SerializedBlockNode\n >\n }\n inlineBlocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapValue<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? SerializedInlineBlockNode<Extract<B, { blockType: K }>>\n : SerializedInlineBlockNode\n >\n }\n unknown?: NodeMapValue<SerializedLexicalNode>\n}\n\n/**\n * A map of views, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorViewMap = {\n [viewKey: string]: {\n admin?: LexicalFieldAdminClientProps\n lexical?: LexicalEditorConfig\n nodes: LexicalEditorNodeMap\n }\n}\n\n/**\n * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function\n */\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n /**\n * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\n views?: PayloadComponent\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 views?: LexicalEditorViewMap\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":"AAqTA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAiDtC,CAAA"}
|
|
@@ -9,6 +9,7 @@ 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
|
+
addToImportMap(args.lexicalEditorArgs?.views);
|
|
12
13
|
for (const resolvedFeature of args.resolvedFeatureMap.values()) {
|
|
13
14
|
if ('componentImports' in resolvedFeature) {
|
|
14
15
|
if (typeof resolvedFeature.componentImports === 'function') {
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","lexicalEditorArgs","views","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 addToImportMap(args.lexicalEditorArgs?.views)\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;EAEfA,cAAA,CAAeD,IAAA,CAAKM,iBAAiB,EAAEC,KAAA;EAEvC,KAAK,MAAMC,eAAA,IAAmBR,IAAA,CAAKS,kBAAkB,CAACC,MAAM,IAAI;IAC9D,IAAI,sBAAsBF,eAAA,EAAiB;MACzC,IAAI,OAAOA,eAAA,CAAgBG,gBAAgB,KAAK,YAAY;QAC1DH,eAAA,CAAgBG,gBAAgB,CAAC;UAC/BV,cAAA;UACAC,OAAA;UACAC,MAAA;UACAC,SAAA;UACAC;QACF;MACF,OAAO,IAAIO,KAAA,CAAMC,OAAO,CAACL,eAAA,CAAgBG,gBAAgB,GAAG;QAC1DV,cAAA,CAAeO,eAAA,CAAgBG,gBAAgB;MACjD,OAAO,IAAI,OAAOH,eAAA,CAAgBG,gBAAgB,KAAK,UAAU;QAC/DV,cAAA,CAAea,MAAA,CAAOJ,MAAM,CAACF,eAAA,CAAgBG,gBAAgB;MAC/D;IACF;IAEAV,cAAA,CAAeO,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;UACrBnB,yBAAA,CAA0B;YACxBG,cAAA;YACAC,OAAA;YACAC,MAAA;YACAkB,MAAA,EAAQD,SAAA;YACRhB,SAAA;YACAC;UACF;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* This function checks if the editor state is empty (has any text). If the editor state has no nodes,
|
|
4
|
+
* or only an empty paragraph node (no TextNode with length > 0), it returns false.
|
|
5
|
+
* Otherwise, it returns true.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasText(value: null | SerializedEditorState<SerializedLexicalNode> | undefined): value is SerializedEditorState<SerializedLexicalNode>;
|
|
3
8
|
//# sourceMappingURL=hasText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,SAAS,GACrE,
|
|
1
|
+
{"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,SAAS,GACrE,KAAK,IAAI,qBAAqB,CAAC,qBAAqB,CAAC,CA6BvD"}
|
package/dist/validate/hasText.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This function checks if the editor state is empty (has any text). If the editor state has no nodes,
|
|
3
|
+
* or only an empty paragraph node (no TextNode with length > 0), it returns false.
|
|
4
|
+
* Otherwise, it returns true.
|
|
5
|
+
*/export function hasText(value) {
|
|
2
6
|
const hasChildren = !!value?.root?.children?.length;
|
|
7
|
+
if (!hasChildren) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
3
10
|
let hasOnlyEmptyParagraph = false;
|
|
4
11
|
if (value?.root?.children?.length === 1) {
|
|
5
12
|
if (value?.root?.children[0]?.type === 'paragraph') {
|
|
@@ -16,10 +23,9 @@ export function hasText(value) {
|
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
|
-
if (
|
|
26
|
+
if (hasOnlyEmptyParagraph) {
|
|
20
27
|
return false;
|
|
21
|
-
} else {
|
|
22
|
-
return true;
|
|
23
28
|
}
|
|
29
|
+
return true;
|
|
24
30
|
}
|
|
25
31
|
//# sourceMappingURL=hasText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasText.js","names":["hasText","value","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild"],"sources":["../../src/validate/hasText.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\nexport function hasText(\n value: null | SerializedEditorState<SerializedLexicalNode> | undefined,\n):
|
|
1
|
+
{"version":3,"file":"hasText.js","names":["hasText","value","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild"],"sources":["../../src/validate/hasText.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\n/**\n * This function checks if the editor state is empty (has any text). If the editor state has no nodes,\n * or only an empty paragraph node (no TextNode with length > 0), it returns false.\n * Otherwise, it returns true.\n */\nexport function hasText(\n value: null | SerializedEditorState<SerializedLexicalNode> | undefined,\n): value is SerializedEditorState<SerializedLexicalNode> {\n const hasChildren = !!value?.root?.children?.length\n if (!hasChildren) {\n return false\n }\n\n let hasOnlyEmptyParagraph = false\n if (value?.root?.children?.length === 1) {\n if (value?.root?.children[0]?.type === 'paragraph') {\n const paragraphNode = value?.root?.children[0] as SerializedParagraphNode\n\n if (!paragraphNode?.children || paragraphNode?.children?.length === 0) {\n hasOnlyEmptyParagraph = true\n } else if (paragraphNode?.children?.length === 1) {\n const paragraphNodeChild = paragraphNode?.children[0]\n if (paragraphNodeChild?.type === 'text') {\n if (!(paragraphNodeChild as SerializedTextNode | undefined)?.['text']?.length) {\n hasOnlyEmptyParagraph = true\n }\n }\n }\n }\n }\n\n if (hasOnlyEmptyParagraph) {\n return false\n }\n\n return true\n}\n"],"mappings":"AAOA;;;;GAKA,OAAO,SAASA,QACdC,KAAsE;EAEtE,MAAMC,WAAA,GAAc,CAAC,CAACD,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA;EAC7C,IAAI,CAACH,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAII,qBAAA,GAAwB;EAC5B,IAAIL,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA,KAAW,GAAG;IACvC,IAAIJ,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE,EAAEG,IAAA,KAAS,aAAa;MAClD,MAAMC,aAAA,GAAgBP,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE;MAE9C,IAAI,CAACI,aAAA,EAAeJ,QAAA,IAAYI,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QACrEC,qBAAA,GAAwB;MAC1B,OAAO,IAAIE,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QAChD,MAAMI,kBAAA,GAAqBD,aAAA,EAAeJ,QAAQ,CAAC,EAAE;QACrD,IAAIK,kBAAA,EAAoBF,IAAA,KAAS,QAAQ;UACvC,IAAI,CAAEE,kBAAA,GAAwD,OAAO,EAAEJ,MAAA,EAAQ;YAC7EC,qBAAA,GAAwB;UAC1B;QACF;MACF;IACF;EACF;EAEA,IAAIA,qBAAA,EAAuB;IACzB,OAAO;EACT;EAEA,OAAO;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.65.0-internal.
|
|
3
|
+
"version": "3.65.0-internal.19683e7",
|
|
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.65.0-internal.
|
|
378
|
-
"@payloadcms/ui": "3.65.0-internal.
|
|
377
|
+
"@payloadcms/translations": "3.65.0-internal.19683e7",
|
|
378
|
+
"@payloadcms/ui": "3.65.0-internal.19683e7"
|
|
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.65.0-internal.
|
|
398
|
+
"payload": "3.65.0-internal.19683e7"
|
|
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.65.0-internal.
|
|
406
|
-
"payload": "3.65.0-internal.
|
|
405
|
+
"@payloadcms/next": "3.65.0-internal.19683e7",
|
|
406
|
+
"payload": "3.65.0-internal.19683e7"
|
|
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 F,h as Te,i as De,j as ve,k as Le,l as Me}from"./chunk-AFXLIYGL.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as B,jsxs as ge}from"react/jsx-runtime";import{BulkUploadProvider as Dn,FieldDescription as vn,FieldError as Ln,FieldLabel as Mn,RenderCustomComponent as bt,useEditDepth as _n,useEffectEvent as An,useField as Bn}from"@payloadcms/ui";import{mergeFieldStyles as In}from"@payloadcms/ui/shared";import{dequal as On}from"dequal/lite";import Nt,{useCallback as Pt,useEffect as St,useMemo as Fn,useState as Rt}from"react";import{ErrorBoundary as $n}from"react-error-boundary";import"./bundled.css";import{jsx as $}from"react/jsx-runtime";import{LexicalComposer as wn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as kn}from"@payloadcms/ui";import*as xt from"react";import{useMemo as Tn}from"react";import{c as dn}from"react/compiler-runtime";import{jsx as E,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as un}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as mn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as fn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as pn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as gn}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as hn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as yn,COMMAND_PRIORITY_LOW as ht,FOCUS_COMMAND as xn}from"lexical";import*as q from"react";import{useEffect as En,useState as Cn}from"react";import{jsx as _e}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&_e(o.Component,{anchorElem:t,clientProps:e}):o.Component&&_e(o.Component,{clientProps:e});import{c as Tt}from"react/compiler-runtime";import{copyToClipboard as Dt}from"@lexical/clipboard";import{useLexicalComposerContext as vt}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Lt}from"@lexical/utils";import Ae from"bson-objectid";import{COMMAND_PRIORITY_LOW as Mt,COPY_COMMAND as _t}from"lexical";import{useEffect as At}from"react";function Be(){let t=Tt(3),[e]=vt(),o,r;return t[0]!==e?(o=()=>e.registerCommand(_t,n=>(Dt(e,Lt(n,ClipboardEvent)?n:null).then(()=>{if(!(n instanceof ClipboardEvent)||!n.clipboardData)throw new Error("No clipboard event");let d=n.clipboardData.getData("application/x-lexical-editor");if(!d)return!0;let i=JSON.parse(d),s=u=>{if("fields"in u&&typeof u.fields=="object"&&u.fields!==null&&"id"in u.fields?u.fields.id=new Ae.default().toHexString():"id"in u&&(u.id=new Ae.default().toHexString()),u.children)for(let y of u.children)s(y)};for(let u of i.nodes)s(u);let c=JSON.stringify(i);n.clipboardData.setData("application/x-lexical-editor",c)}).catch(d=>{throw n instanceof ClipboardEvent&&n.clipboardData?.setData("application/x-lexical-editor",""),d}),!0),Mt),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),At(o,r),null}import{c as Bt}from"react/compiler-runtime";import{useLexicalComposerContext as It}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 H,$isElementNode as xe,$isLineBreakNode as Kt,$isNodeSelection as ie,$isRangeSelection as Ie,$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=Bt(3),[e]=It(),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(H(i)){let u=X().getElementByKey(i.getKey());return u&&Z({element:u,node:i}),!0}if(!xe(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Ie(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Qt),d=n?.getNextSibling();if(!n||d!==$e(n))return!1;if(H(d)){let i=X().getElementByKey(d.getKey());if(i)return Z({element:i,node:d}),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(H(i)){let u=X().getElementByKey(i.getKey());return u?(Z({element:u,node:i}),t.preventDefault(),!0):!1}if(!xe(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Ie(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Zt),d=n?.getPreviousSibling();if(!n||d!==Ke(n))return!1;if(H(d)){let i=X().getElementByKey(d.getKey());if(i)return Z({element:i,node:d}),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 H(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 H(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(H(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,d=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:c,right:u,top:y}=t.getBoundingClientRect(),l=y+window.scrollY,a=s+window.scrollY;if(o<l-d||o>a+d||e<c-n||e>u+n)return-1;(e<c||e>u)&&(i=e<c?e-c: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=(c,u)=>c?parseFloat(window.getComputedStyle(c)[u]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),d=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),d),marginTop:i}}import{$getRoot as so}from"lexical";function j(t){return t.getEditorState().read(()=>so().getChildrenKeys())}var lo=1,ao=-1,He=0,_={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:d=0,point:{x:i,y:s},startIndex:c=0,useEdgeAsDefault:u=!1}=t;if(o>0&&_.props&&_.result&&_.props.fuzzy===t.fuzzy&&_.props.horizontalOffset===t.horizontalOffset&&_.props.useEdgeAsDefault===t.useEdgeAsDefault&&co(_.props.point,t.point,o))return _.result;let y=e.getBoundingClientRect(),l=j(r),a={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(u){let g=r.getElementByKey(l[0]),m=r.getElementByKey(l[l.length-1]);if(g&&m){let[p,f]=[V(g),V(m)];if(s<p.top?(a.blockElem=g,a.distance=p.top-s,a.blockNode=ae(l[0]),a.foundAtIndex=0):s>f.bottom&&(a.distance=s-f.bottom,a.blockNode=ae(l[l.length-1]),a.blockElem=m,a.foundAtIndex=l.length-1),a?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let h=c,x=He;for(;h>=0&&h<l.length;){let g=l[h],m=r.getElementByKey(g);if(m===null)break;let p=new F(i+d,s),f=Le.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}}),_.props=t,_.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(),d=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),c;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(l=>t.classList.contains(l)||t.firstElementChild?.classList.contains(l)))c=n.top+8-s.top;else{let l=je(t)?parseInt(d.lineHeight,10):0;c=n.top+(l-i.height)/2-s.top}let y=r;e.style.opacity="1",e.style.transform=`translate(${y}px, ${c}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(),d=n?.admin?.hideGutter?-24:12,i=ho(null),[s,c]=yo(null);ze(()=>{function y(l){let a=l.target;if(!po(a))return;let h=Y(r,l.pageX,l.pageY,a);if(h===-1){c(null);return}if(ce(a,Eo))return;let x=j(t),{blockElem:g,blockNode:m,foundAtIndex:p}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-h,point:new F(l.x,l.y),returnEmptyParagraphs:!0,startIndex:Co(x.length),useEdgeAsDefault:!1});ue=p,g&&m&&(s?.node!==m||s?.elem!==g)&&c({elem:g,node:m})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,s]),ze(()=>{i.current&&s?.node&&de(s?.elem,i.current,e,d)},[e,s,d]);let u=go(y=>{let l=s;l?.node&&(t.update(()=>{let a=!0;if((l?.node.getType()!=="paragraph"||l.node.getTextContent()!=="")&&(a=!1),!a){let h=fo();l?.node.insertAfter(h),setTimeout(()=>{l={elem:t.getElementByKey(h.getKey()),node:h},c(l)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),l?.node&&"select"in l.node&&typeof l.node.select=="function"&&l.node.select()})},1),setTimeout(()=>{t.dispatchCommand(De,{node:l?.node})},2),y.stopPropagation(),y.preventDefault())},[t,s]);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 z=0;function Ge(t,e,o,r,n,d,i,s,c,u=!1){let{height:y,top:l}=r.getBoundingClientRect(),{top:a,width:h}=i.getBoundingClientRect(),{marginBottom:x,marginTop:g}=le(r),m=l,p=d>=l+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)&&(z++,z<200&&(f=!0));else{z++;let b=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(p===n?.isBelow&&b===w||z<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="")),z=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 To(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 Do(t,e,o){let r=e.parentElement,n=fe(null),d=fe(null),i=fe(null),s=fe(!1),[c,u]=Je(null),[y,l]=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=j(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:w}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-C,point:new F(p.x,p.y),startIndex:Xe(k.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!w)&&c!==S&&u(S)}return document?.addEventListener("mousemove",m),()=>{document?.removeEventListener("mousemove",m)}},[r,e,t,c]),be(()=>{n.current&&de(c,n.current,e,h)},[e,c,h]),be(()=>{function m(f){if(!s.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=j(t),{blockElem:N,foundAtIndex:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new F(f.x,f.y),startIndex:Xe(w.length),useEdgeAsDefault:!0,verbose:!0});ee=L;let T=d.current;if(N===null||T===null)return!1;if(c!==N){let{isBelow:D,willStayInSamePosition:J}=Ge(a?.admin?.hideGutter?"0px":"3rem",h+(a?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,N,y,k,e,f,i,I);f.preventDefault(),J||l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:D})}else y?.elem&&(Ze(T,y.elem),l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function p(f){if(!s.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 L=Y(r,f.pageX,f.pageY,b,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-L,point:new F(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let D=qe(I);if(!D)return!1;if(D===N)return!0;let{height:J,top:he}=V(I),O=S>=he+J/2+window.scrollY;T?(D.insertBefore(N),D.remove()):O?D.insertAfter(N):D.insertBefore(N),c!==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,c,a?.admin?.hideGutter]);function x(m){let p=m.dataTransfer;if(!p||!c)return;To(p,c);let f="";t.update(()=>{let C=qe(c);C&&(f=C.getKey())}),s.current=!0,p.setData(Qe,f)}function g(){s.current=!1,y?.elem&&Ze(d.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:d}),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 Do(r,o,r._editable)}import{c as vo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as Lo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Mo,$getRoot as _o}from"lexical";import"react";var ot="insert-paragraph-at-end",nt=()=>{let t=vo(2),[e]=Lo(),{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(Ao)},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 Ao(){let t=Mo();_o().append(t),t.select()}import{c as Bo}from"react/compiler-runtime";import{useLexicalComposerContext as Io}from"@lexical/react/LexicalComposerContext";import*as rt from"react";var it=()=>{let t=Bo(4),{editorConfig:e}=R(),[o]=Io(),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,d=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==d||o[1]!==i||o[2]!==t?(s=c=>{let{query:u}=c,y="[^"+t+Te+"\\s]",a=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+d+"}))$").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]=d,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var A="slash-menu-popup";function Xo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:d,schemaPath:i}}=R(),{i18n:s}=dt(),c=`${A}__item ${A}__item-${e.key}`;t&&(c+=` ${A}__item--selected`);let u=e.key;return e.label&&(u=typeof e.label=="function"?e.label({featureClientSchemaMap:d,i18n:s,schemaPath:i}):e.label),u.length>25&&(u=u.substring(0,25)+"..."),ct("button",{"aria-selected":t,className:c,id:A+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${A}__item-text`,children:u})]},e.key)}function mt({anchorElem:t=document.body}){let[e]=Uo(),[o,r]=Qo(null),{editorConfig:n}=R(),{i18n:d}=dt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),c=at("/",{minLength:0}),u=qo(()=>{let l=[];for(let a of n.features.slashMenu.dynamicGroups)if(o){let h=a({editor:e,queryString:o});l=l.concat(h)}return l},[e,o,n?.features]),y=Jo(()=>{let l=[];for(let a of n?.features.slashMenu.groups??[])l.push(a);if(o){l=l.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:d,schemaPath:s}):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}),l=l.filter(h=>h!=null);let a=u();for(let h of a){let x=l.find(g=>g.key===h.key);x?l=l.filter(g=>g.key!==h.key):x={...h,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),l.push(x)}}return l},[o,n?.features.slashMenu.groups,u,i,d,s]);return U(ve,{anchorElem:t,groups:y,menuRenderFn:(l,{selectedItemKey:a,selectItemAndCleanUp:h,setSelectedItemKey:x})=>l.current&&y.length?ut.createPortal(U("div",{className:A,children:y.map(g=>{let m=g.key;return g.label&&i&&(m=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:d,schemaPath:s}):g.label),ct("div",{className:`${A}__group ${A}__group-${g.key}`,children:[U("div",{className:`${A}__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)})}),l.current):null,onQueryChange:r,triggerFn:c})}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,s=>{i.forEach(c=>{s.hasFormat(c)&&s.toggleFormat(c)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let d;return e[3]!==r||e[4]!==o?(d=[r,o],e[3]=r,e[4]=o,e[5]=d):d=e[5],nn(n,d),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{useLexicalComposerContext as ln}from"@lexical/react/LexicalComposerContext";import{ContentEditable as an}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as cn}from"@payloadcms/ui";import"react";function gt(t){let e=sn(5),{className:o,editorConfig:r}=t,{t:n}=cn(),[,d]=ln(),{getTheme:i}=d,s;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==i||e[3]!==n){let c=i();s=pt(an,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:pt("p",{className:c?.placeholder,children:r?.admin?.placeholder??n("lexical:general:placeholder")})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=i,e[3]=n,e[4]=s}else s=e[4];return s}var yt=t=>{let e=dn(12),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:d}=t,i=R(),[s]=un(),c=hn(),[u,y]=Cn(null),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{m!==null&&y(m)},e[0]=l):l=e[0];let a=l,h,x;e[1]!==s||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=s.registerCommand(xn,()=>(m(),!0),ht),C=s.registerCommand(yn,()=>(p(),!0),ht);return()=>{f(),C(),i.parentEditor?.unregisterChild?.(i.uuid)}},x=[s,i],e[1]=s,e[2]=i,e[3]=h,e[4]=x):(h=e[3],x=e[4]),En(h,x);let g;return e[5]!==o||e[6]!==r||e[7]!==u||e[8]!==c||e[9]!==n||e[10]!==d?(g=te(q.Fragment,{children:[o.features.plugins?.map(bn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Nn),E(gn,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:a,children:E(gt,{editorConfig:o})})}),ErrorBoundary:mn}),E(st,{}),c&&E(nt,{}),E(Fe,{}),E(Be,{}),E(ft,{features:o.features}),E(lt,{}),c&&E(pn,{ignoreSelectionChange:!0,onChange:(m,p,f)=>{(!f.has("focus")||f.size>1)&&d?.(m,p,f)}}),u&&te(q.Fragment,{children:[!n&&c&&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(K,{anchorElem:u,clientProps:m.clientProps,plugin:m},m.key)}),c&&E(q.Fragment,{children:E(mt,{anchorElem:u})})]}),c&&te(q.Fragment,{children:[E(fn,{}),o?.features?.markdownTransformers?.length>0&&E(it,{})]}),o.features.plugins?.map(Pn),o.features.plugins?.map(Sn)]}),o.features.plugins?.map(Rn)]}),e[5]=o,e[6]=r,e[7]=u,e[8]=c,e[9]=n,e[10]=d,e[11]=g):g=e[11],g};function bn(t){if(t.position==="aboveContainer")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Nn(t){if(t.position==="top")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Pn(t){if(t.position==="normal")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Sn(t){if(t.position==="bottom")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Rn(t){if(t.position==="belowContainer")return E(K,{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,{children:$(Et,{providers:e.slice(1),children:t})}):$(o,{children:t})},Ct=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:d,readOnly:i,value:s}=t,c=R(),u=kn(),y=xt.useRef(null),l=Tn(()=>{if(s&&typeof s!="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(s));if(s&&Array.isArray(s)&&!("root"in s))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(s&&"jsonContent"in s)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:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Me({editorConfig:o}),onError:a=>{throw a},theme:o.lexical.theme}},[o]);return l?$(wn,{initialConfig:l,children:$(Re,{editorConfig:o,editorContainerRef:y,fieldProps:r,parentContext:c?.editDepth===u?c:void 0,children:$(Et,{providers:o.features.providers,children:$(yt,{editorConfig:o,editorContainerRef:y,isSmallWidthViewport:n,onChange:d})})})},e+l.editable):$("p",{children:"Loading..."})};var pe="rich-text-lexical",Kn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:d}={},label:i,localized:s,required:c},path:u,readOnly:y,validate:l}=t,a=y||d,h=_n(),x=Pt((M,Q)=>typeof l=="function"?l(M,{...Q,required:c}):!0,[l,c]),{customComponents:{AfterInput:g,BeforeInput:m,Description:p,Error:f,Label:C}={},disabled:k,initialValue:S,path:b,setValue:w,showError:N,value:L}=Bn({potentiallyStalePath:u,validate:x}),I=a||k,[T,D]=Rt(!1),[J,he]=Rt(),ye=Nt.useRef(S),O=Nt.useRef(L);St(()=>{let M=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==T&&D(Q)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[T]);let Pe=[pe,"field-type",r,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!T?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${h}`,v=ke(),P=Pt(M=>{v(()=>{let Se=M.toJSON();O.current=Se,w(Se)})},[w,v]),wt=Fn(()=>In(o),[o]),kt=An(M=>{O.current!==L&&!On(O.current!=null?JSON.parse(JSON.stringify(O.current)):O.current,L)&&(ye.current=M,O.current=L,he(new Date))});return St(()=>{Object.is(S,ye.current)||kt(S)},[S]),ge("div",{className:Pe,style:wt,children:[B(bt,{CustomComponent:f,Fallback:B(Ln,{path:b,showError:N})}),C||B(Mn,{label:i,localized:s,path:b,required:c}),ge("div",{className:`${pe}__wrap`,children:[ge($n,{fallbackRender:Hn,onReset:()=>{},children:[m,B(Dn,{drawerSlugPrefix:b,children:B(Ct,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:T,onChange:P,readOnly:I,value:L},JSON.stringify({path:b,rerenderProviderKey:J}))}),g]}),B(bt,{CustomComponent:p,Fallback:B(vn,{description:n,path:b})})]})]},oe)};function Hn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[B("p",{children:"Something went wrong:"}),B("pre",{style:{color:"red"},children:t.message})]})}var As=Kn;export{As as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-QUXIGJRC.js.map
|