@payloadcms/richtext-lexical 3.73.0 → 3.74.0-internal.097fb57
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-OX545XLB.js +2 -0
- package/dist/exports/client/Field-OX545XLB.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-3KBZSLPR.js +12 -0
- package/dist/exports/client/chunk-3KBZSLPR.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/client/internal-client.d.ts +3 -0
- package/dist/exports/client/internal-client.d.ts.map +1 -0
- 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/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/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +11 -6
- 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 +152 -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 +11 -6
- package/dist/exports/client/Field-HJGV32KA.js +0 -2
- package/dist/exports/client/Field-HJGV32KA.js.map +0 -7
- package/dist/exports/client/chunk-EZX4YW7S.js +0 -12
- package/dist/exports/client/chunk-EZX4YW7S.js.map +0 -7
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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,IAAI,mBAAmB,EACnC,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,WAAW,EACX,+BAA+B,EAC/B,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACZ,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uDAAuD,CAAA;AAC7F,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAC5E,OAAO,KAAK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B,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA;AAEvE,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,CACpE,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?: 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 DecoratorNode,\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\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\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 node: {\n _originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode\n } & DecoratorNode<React.ReactNode>\n } & Omit<WithinEditorArgs, 'node'>),\n ) => React.ReactNode\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 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 [viewKey: string]: {\n admin?: LexicalFieldAdminClientProps\n lexical?: LexicalEditorConfig\n nodes: LexicalEditorNodeMap<TNodes>\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":"AAmUA","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.
|
|
3
|
+
"version": "3.74.0-internal.097fb57",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"types": "./dist/exports/client/index.d.ts",
|
|
34
34
|
"default": "./dist/exports/client/index.js"
|
|
35
35
|
},
|
|
36
|
+
"./internal-client": {
|
|
37
|
+
"import": "./dist/exports/client/internal-client.js",
|
|
38
|
+
"types": "./dist/exports/client/internal-client.d.ts",
|
|
39
|
+
"default": "./dist/exports/client/internal-client.js"
|
|
40
|
+
},
|
|
36
41
|
"./react": {
|
|
37
42
|
"import": "./dist/exports/react/index.js",
|
|
38
43
|
"types": "./dist/exports/react/index.d.ts",
|
|
@@ -374,8 +379,8 @@
|
|
|
374
379
|
"react-error-boundary": "4.1.2",
|
|
375
380
|
"ts-essentials": "10.0.3",
|
|
376
381
|
"uuid": "10.0.0",
|
|
377
|
-
"@payloadcms/translations": "3.
|
|
378
|
-
"@payloadcms/ui": "3.
|
|
382
|
+
"@payloadcms/translations": "3.74.0-internal.097fb57",
|
|
383
|
+
"@payloadcms/ui": "3.74.0-internal.097fb57"
|
|
379
384
|
},
|
|
380
385
|
"devDependencies": {
|
|
381
386
|
"@babel/cli": "7.27.2",
|
|
@@ -394,7 +399,7 @@
|
|
|
394
399
|
"esbuild": "0.27.1",
|
|
395
400
|
"esbuild-sass-plugin": "3.3.1",
|
|
396
401
|
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
397
|
-
"payload": "3.
|
|
402
|
+
"payload": "3.74.0-internal.097fb57",
|
|
398
403
|
"@payloadcms/eslint-config": "3.28.0"
|
|
399
404
|
},
|
|
400
405
|
"peerDependencies": {
|
|
@@ -402,8 +407,8 @@
|
|
|
402
407
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
403
408
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
404
409
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
405
|
-
"
|
|
406
|
-
"
|
|
410
|
+
"@payloadcms/next": "3.74.0-internal.097fb57",
|
|
411
|
+
"payload": "3.74.0-internal.097fb57"
|
|
407
412
|
},
|
|
408
413
|
"engines": {
|
|
409
414
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as ke,e as Te,f as F,h as De,i as Le,j as ve,k as Me,l as _e}from"./chunk-EZX4YW7S.js";import{a as we,b as R}from"./chunk-BZZVLW4U.js";import{jsx as B,jsxs as ge}from"react/jsx-runtime";import{BulkUploadProvider as _n,FieldDescription as An,FieldError as Bn,FieldLabel as On,RenderCustomComponent as St,useEditDepth as In,useEffectEvent as Fn,useField as $n}from"@payloadcms/ui";import{mergeFieldStyles as Kn}from"@payloadcms/ui/shared";import{dequal as Hn}from"dequal/lite";import Pt,{useCallback as Rt,useEffect as wt,useMemo as jn,useState as kt}from"react";import{ErrorBoundary as zn}from"react-error-boundary";import"./bundled.css";import{jsx as $}from"react/jsx-runtime";import{LexicalComposer as Ln}from"@lexical/react/LexicalComposer.js";import{useEditDepth as vn}from"@payloadcms/ui";import*as Ct from"react";import{useMemo as Mn}from"react";import{c as pn}from"react/compiler-runtime";import{jsx as E,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as gn}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as hn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as yn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as xn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as En}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as Cn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as bn,COMMAND_PRIORITY_LOW as xt,FOCUS_COMMAND as Nn}from"lexical";import*as J from"react";import{useEffect as Sn,useState as Pn}from"react";import{jsx as Ae}from"react/jsx-runtime";import"react";var K=({anchorElem:e,clientProps:t,plugin:o})=>o.position==="floatingAnchorElem"&&e?o.Component&&Ae(o.Component,{anchorElem:e,clientProps:t}):o.Component&&Ae(o.Component,{clientProps:t});import{c as Lt}from"react/compiler-runtime";import{copyToClipboard as Be}from"@lexical/clipboard";import{useLexicalComposerContext as vt}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Mt}from"@lexical/utils";import Oe from"bson-objectid";import{$getSelection as _t,$isNodeSelection as At,COMMAND_PRIORITY_LOW as Bt,COPY_COMMAND as Ot}from"lexical";import{useEffect as It}from"react";var xe=e=>{if("fields"in e&&typeof e.fields=="object"&&e.fields!==null&&"id"in e.fields?e.fields.id=new Oe.default().toHexString():"id"in e&&(e.id=new Oe.default().toHexString()),e.children)for(let t of e.children)xe(t)};function Ie(){let e=Lt(3),[t]=vt(),o,r;return e[0]!==t?(o=()=>t.registerCommand(Ot,n=>{let d=_t();if(At(d)){let s=d.getNodes()[0]?.exportJSON(),c=JSON.parse(JSON.stringify(s));xe(c);let u={namespace:t._config.namespace,nodes:[c]},y=JSON.stringify(u);return Be(t,null,{"application/x-lexical-editor":y,"text/plain":""}).catch(Ft),!0}return Be(t,Mt(n,ClipboardEvent)?n:null).then(()=>{if(!(n instanceof ClipboardEvent)||!n.clipboardData)throw new Error("No clipboard event");let i=n.clipboardData.getData("application/x-lexical-editor");if(!i)return!0;let s=JSON.parse(i);for(let u of s.nodes)xe(u);let c=JSON.stringify(s);n.clipboardData.setData("application/x-lexical-editor",c)}).catch(i=>{throw n instanceof ClipboardEvent&&n.clipboardData?.setData("application/x-lexical-editor",""),i}),!0},Bt),r=[t],e[0]=t,e[1]=o,e[2]=r):(o=e[1],r=e[2]),It(o,r),null}function Ft(e){throw e}import{c as $t}from"react/compiler-runtime";import{useLexicalComposerContext as Kt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Ht}from"@lexical/utils";import{$createNodeSelection as jt,$getEditor as X,$getNearestNodeFromDOMNode as zt,$getSelection as re,$isDecoratorNode as H,$isElementNode as Ee,$isLineBreakNode as Wt,$isNodeSelection as ie,$isRangeSelection as Fe,$isRootOrShadowRoot as Yt,$isTextNode as Vt,$setSelection as $e,CLICK_COMMAND as Gt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as Ut,KEY_ARROW_UP_COMMAND as Jt,KEY_BACKSPACE_COMMAND as qt,KEY_DELETE_COMMAND as Qt,SELECTION_CHANGE_COMMAND as Xt}from"lexical";import{useEffect as Zt}from"react";function Ke(){let e=$t(3),[t]=Kt(),o=so,r,n;return e[0]!==t?(r=()=>Ht(t.registerCommand(Gt,io,W),t.registerCommand(Qt,o,W),t.registerCommand(qt,o,W),t.registerCommand(Xt,ro,W),t.registerCommand(Jt,oo,W),t.registerCommand(Ut,eo,W)),n=[t],e[0]=t,e[1]=r,e[2]=n):(r=e[1],n=e[2]),Zt(r,n),null}function eo(e){let t=re();if(ie(t)){e.preventDefault();let i=t.getNodes()[0]?.getNextSibling();if(H(i)){let u=X().getElementByKey(i.getKey());return u&&Z({element:u,node:i}),!0}if(!Ee(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),e.preventDefault()),!0}if(!Fe(t))return!1;let r=(t.isBackward()?t.anchor:t.focus).getNode(),n=ne(r,to),d=n?.getNextSibling();if(!n||d!==He(n))return!1;if(H(d)){let i=X().getElementByKey(d.getKey());if(i)return Z({element:i,node:d}),e.preventDefault(),!0}return!1}function to(e){return He(e)!==null}function oo(e){let t=re();if(ie(t)){let i=t.getNodes()[0]?.getPreviousSibling();if(H(i)){let u=X().getElementByKey(i.getKey());return u?(Z({element:u,node:i}),e.preventDefault(),!0):!1}if(!Ee(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),e.preventDefault(),!0):!1}if(!Fe(t))return!1;let r=(t.isBackward()?t.anchor:t.focus).getNode(),n=ne(r,no),d=n?.getPreviousSibling();if(!n||d!==je(n))return!1;if(H(d)){let i=X().getElementByKey(d.getKey());if(i)return Z({element:i,node:d}),e.preventDefault(),!0}return!1}function no(e){return je(e)!==null}function ro(){let e=co();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),e?(e.element?.classList.add("decorator-selected"),!0):!1}function io(e){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let t=ao(e);if(!t)return!0;let{target:o}=e;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?$e(null):Z(t),!0}function so(e){let t=re();return ie(t)?(e.preventDefault(),t.getNodes().forEach(lo),!0):!1}function lo(e){e.remove()}function ao(e){if(!(e.target instanceof HTMLElement))return;let t=e.target.closest('[data-lexical-decorator="true"]');if(!(t instanceof HTMLElement))return;let o=zt(t);return H(o)?{element:t,node:o}:void 0}function co(){let e=re();if(!ie(e))return;let t=e.getNodes();if(t.length!==1)return;let o=t[0];return H(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:e,node:t}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=jt();o.add(t.getKey()),$e(o),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.classList.add("decorator-selected")}function se(e){if(H(e)&&!e.isInline())return!0;if(!Ee(e)||Yt(e))return!1;let t=e.getFirstChild(),o=t===null||Wt(t)||Vt(t)||t.isInline();return!e.isInline()&&e.canBeEmpty()!==!1&&o}function He(e){let t=e.getNextSibling();for(;t!==null;){if(se(t))return t;t=t.getNextSibling()}return null}function je(e){let t=e.getPreviousSibling();for(;t!==null;){if(se(t))return t;t=t.getPreviousSibling()}return null}import{jsx as Ce}from"react/jsx-runtime";import{useLexicalComposerContext as ho}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as yo,isHTMLElement as xo}from"lexical";import*as Ve from"react";import{useCallback as Eo,useEffect as Ye,useRef as Co,useState as bo}from"react";import{createPortal as No}from"react-dom";var Y=(e,t,o,r,n=50,d=25)=>{let i=0;if(e&&!e.contains(r)){let{bottom:s,left:c,right:u,top:y}=e.getBoundingClientRect(),l=y+window.scrollY,a=s+window.scrollY;if(o<l-d||o>a+d||t<c-n||t>u+n)return-1;(t<c||t>u)&&(i=t<c?t-c:t-u)}return i};import{$getNodeByKey as ae}from"lexical";function V(e){let t=e.getBoundingClientRect(),o=getComputedStyle(e).getPropertyValue("transform");if(!o||o==="none")return t;let r=o.split(",").pop();return t.y=t.y-Number(r?.replace(")","")),t}function le(e){let t=(c,u)=>c?parseFloat(window.getComputedStyle(c)[u]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(e),n=t(e.previousElementSibling,"marginBottom"),d=t(e.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),d),marginTop:i}}import{$getRoot as uo}from"lexical";function j(e){return e.getEditorState().read(()=>uo().getChildrenKeys())}var mo=1,fo=-1,ze=0,_={props:null,result:null};function po(e,t,o=20){let r=e.x-t.x,n=e.y-t.y;return r*r+n*n<=o*o}function G(e){let{anchorElem:t,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:d=0,point:{x:i,y:s},startIndex:c=0,useEdgeAsDefault:u=!1}=e;if(o>0&&_.props&&_.result&&_.props.fuzzy===e.fuzzy&&_.props.horizontalOffset===e.horizontalOffset&&_.props.useEdgeAsDefault===e.useEdgeAsDefault&&po(_.props.point,e.point,o))return _.result;let y=t.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=ze;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=Me.fromDOMRect(V(m)),{marginBottom:C,marginTop:k}=le(m),P=f.generateNewRect({bottom:f.bottom+C,left:y.left,right:y.right,top:f.top-k}),{distance:b,isOnBottomSide:w,isOnTopSide:N}=P.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&&!e.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===ze&&(N?x=fo:w?x=mo:x=1/0),h+=x}}),_.props=e,_.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(e,t){return!!e.closest(`.${t}`)}var go=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function We(e){if(!e||go.includes(e.tagName)||e.offsetHeight===0||e.offsetWidth===0)return!1;let t=window.getComputedStyle(e);return!(t.display==="table-cell"||t.position==="absolute"||t.visibility==="hidden"||t.opacity==="0")}function de(e,t,o,r=0){if(!e){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}let n=e.getBoundingClientRect(),d=window.getComputedStyle(e),i=t.getBoundingClientRect(),s=o.getBoundingClientRect(),c;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(l=>e.classList.contains(l)||e.firstElementChild?.classList.contains(l)))c=n.top+8-s.top;else{let l=We(e)?parseInt(d.lineHeight,10):0;c=n.top+(l-i.height)/2-s.top}let y=r;t.style.opacity="1",t.style.transform=`translate(${y}px, ${c}px)`}var So="add-block-menu",ue=1/0;function Po(e){return e===0?1/0:ue>=0&&ue<e?ue:Math.floor(e/2)}function Ro(e,t,o){let r=t.parentElement,{editorConfig:n}=R(),d=n?.admin?.hideGutter?-24:12,i=Co(null),[s,c]=bo(null);Ye(()=>{function y(l){let a=l.target;if(!xo(a))return;let h=Y(r,l.pageX,l.pageY,a);if(h===-1){c(null);return}if(ce(a,So))return;let x=j(e),{blockElem:g,blockNode:m,foundAtIndex:p}=G({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-h,point:new F(l.x,l.y),returnEmptyParagraphs:!0,startIndex:Po(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,t,e,s]),Ye(()=>{i.current&&s?.node&&de(s?.elem,i.current,t,d)},[t,s,d]);let u=Eo(y=>{let l=s;l?.node&&(e.update(()=>{let a=!0;if((l?.node.getType()!=="paragraph"||l.node.getTextContent()!=="")&&(a=!1),!a){let h=yo();l?.node.insertAfter(h),setTimeout(()=>{l={elem:e.getElementByKey(h.getKey()),node:h},c(l)},0)}}),setTimeout(()=>{e.update(()=>{e.focus(),l?.node&&"select"in l.node&&typeof l.node.select=="function"&&l.node.select()})},1),setTimeout(()=>{e.dispatchCommand(Le,{node:l?.node})},2),y.stopPropagation(),y.preventDefault())},[e,s]);return No(Ce(Ve.Fragment,{children:Ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{u(y)},ref:i,type:"button",children:Ce("div",{className:o?"icon":""})})}),t)}function Ge(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[r]=ho();return Ro(r,o,r._editable)}import{jsx as me,jsxs as ko}from"react/jsx-runtime";import{useLexicalComposerContext as To}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as qe}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Qe,$getNodeByKey as Do,isHTMLElement as be}from"lexical";import*as ot from"react";import{useEffect as Ne,useRef as fe,useState as Xe}from"react";import{createPortal as Lo}from"react-dom";var Ue=0,wo=-24;var z=0;function Je(e,t,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=-Ue:C=Ue);let k=m-a+C,P=wo-t;return o.style.width=`calc(${h}px - ${e})`,o.style.opacity=".8",o.style.transform=`translate(${P}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 vo="draggable-block-menu",Ze="application/x-lexical-drag-block",ee=1/0;function et(e){return e===0?1/0:ee>=0&&ee<e?ee:Math.floor(e/2)}function Mo(e,t){let{transform:o}=t.style;e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function tt(e,t){e&&(e.style.opacity="0"),t&&(t.style.opacity="",t.style.marginBottom="",t.style.marginTop="")}function _o(e,t,o){let r=t.parentElement,n=fe(null),d=fe(null),i=fe(null),s=fe(!1),[c,u]=Xe(null),[y,l]=Xe(null),{editorConfig:a}=R(),h=a?.admin?.hideGutter?-44:-8;Ne(()=>{function m(p){let f=p.target;if(!be(f))return;let C=Y(r,p.pageX,p.pageY,f);if(C===-1){u(null);return}if(ce(f,vo))return;let k=j(e),{blockElem:P,foundAtIndex:b,isFoundNodeEmptyParagraph:w}=G({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-C,point:new F(p.x,p.y),startIndex:et(k.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!P&&!w)&&c!==P&&u(P)}return document?.addEventListener("mousemove",m),()=>{document?.removeEventListener("mousemove",m)}},[r,t,e,c]),Ne(()=>{n.current&&de(c,n.current,t,h)},[t,c,h]),Ne(()=>{function m(f){if(!s.current)return!1;let[C]=qe(f);if(C)return!1;let{pageY:k,target:P}=f;if(!be(P))return!1;let b=Y(r,f.pageX,f.pageY,P,100,50),w=j(e),{blockElem:N,foundAtIndex:v,isFoundNodeEmptyParagraph:O}=G({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-b,point:new F(f.x,f.y),startIndex:et(w.length),useEdgeAsDefault:!0,verbose:!0});ee=v;let T=d.current;if(N===null||T===null)return!1;if(c!==N){let{isBelow:D,willStayInSamePosition:q}=Je(a?.admin?.hideGutter?"0px":"3rem",h+(a?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,N,y,k,t,f,i,O);f.preventDefault(),q||l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:D})}else y?.elem&&(tt(T,y.elem),l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function p(f){if(!s.current)return!1;let[C]=qe(f);if(C)return!1;let{dataTransfer:k,pageY:P,target:b}=f,w=k?.getData(Ze)||"";return e.update(()=>{let N=Do(w);if(!N||!be(b))return!1;let v=Y(r,f.pageX,f.pageY,b,100,50),{blockElem:O,isFoundNodeEmptyParagraph:T}=G({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-v,point:new F(f.x,f.y),useEdgeAsDefault:!0});if(!O)return!1;let D=Qe(O);if(!D)return!1;if(D===N)return!0;let{height:q,top:he}=V(O),I=P>=he+q/2+window.scrollY;T?(D.insertBefore(N),D.remove()):I?D.insertAfter(N):D.insertBefore(N),c!==null&&u(null),document.querySelectorAll(".lexical-block-highlighter").forEach(L=>{L.remove()});let oe=e.getElementByKey(N.getKey());setTimeout(()=>{let L=oe?.getBoundingClientRect();if(!L)return;let S=document.createElement("div");S.className="lexical-block-highlighter",S.style.backgroundColor="var(--theme-elevation-1000",S.style.transition="opacity 0.5s ease-in-out",S.style.zIndex="1",S.style.pointerEvents="none",S.style.boxSizing="border-box",S.style.borderRadius="4px",S.style.position="absolute",document.body.appendChild(S),S.style.opacity="0.1",S.style.height=`${L.height+8}px`,S.style.width=`${L.width+8}px`,S.style.top=`${L.top+window.scrollY-4}px`,S.style.left=`${L.left-4}px`,setTimeout(()=>{S.style.opacity="0",setTimeout(()=>{S.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",m),document.addEventListener("drop",p),()=>{document.removeEventListener("dragover",m),document.removeEventListener("drop",p)}},[r,h,t,e,y,c,a?.admin?.hideGutter]);function x(m){let p=m.dataTransfer;if(!p||!c)return;Mo(p,c);let f="";e.update(()=>{let C=Qe(c);C&&(f=C.getKey())}),s.current=!0,p.setData(Ze,f)}function g(){s.current=!1,y?.elem&&tt(d.current,y?.elem)}return Lo(ko(ot.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})]}),t)}function nt(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[r]=To();return _o(r,o,r._editable)}import{c as Ao}from"react/compiler-runtime";import{jsx as Se}from"react/jsx-runtime";import{useLexicalComposerContext as Bo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Oo,$getRoot as Io}from"lexical";import"react";var rt="insert-paragraph-at-end",it=()=>{let e=Ao(2),[t]=Bo(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;return e[0]!==t?(r=Se("div",{"aria-label":"Insert Paragraph",className:rt,onClick:()=>{t.update(Fo)},role:"button",tabIndex:0,children:Se("div",{className:`${rt}-inside`,children:Se("span",{children:"+"})})}),e[0]=t,e[1]=r):r=e[1],r};function Fo(){let e=Oo();Io().append(e),e.select()}import{c as $o}from"react/compiler-runtime";import{useLexicalComposerContext as Ko}from"@lexical/react/LexicalComposerContext";import*as st from"react";var lt=()=>{let e=$o(4),{editorConfig:t}=R(),[o]=Ko(),r,n;return e[0]!==o||e[1]!==t.features.markdownTransformers?(r=()=>ke(o,t.features.markdownTransformers??[]),n=[o,t.features.markdownTransformers],e[0]=o,e[1]=t.features.markdownTransformers,e[2]=r,e[3]=n):(r=e[2],n=e[3]),st.useEffect(r,n),null};import{useLexicalComposerContext as Ho}from"@lexical/react/LexicalComposerContext";import{$getSelection as jo,$isRangeSelection as zo,RootNode as Wo}from"lexical";import{useEffect as Yo}from"react";function at(){let[e]=Ho();return Yo(()=>e.registerNodeTransform(Wo,t=>{let o=jo();if(zo(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(t.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}),[e]),null}import{useLexicalComposerContext as Vo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Go,COMMAND_PRIORITY_LOW as Uo,SELECT_ALL_COMMAND as Jo}from"lexical";import{useEffect as qo}from"react";function ct(){let[e]=Vo();return qo(()=>e.registerCommand(Jo,()=>{if(Go())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Uo),[e]),null}import{jsx as U,jsxs as ut}from"react/jsx-runtime";import{useLexicalComposerContext as Xo}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as mt}from"@payloadcms/ui";import{useCallback as Zo,useMemo as en,useState as tn}from"react";import"react";import*as ft from"react-dom";import{c as Qo}from"react/compiler-runtime";import"react";function dt(e,t){let o=Qo(4),{maxLength:r,minLength:n}=t,d=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==d||o[1]!==i||o[2]!==e?(s=c=>{let{query:u}=c,y="[^"+e+De+"\\s]",a=new RegExp("(^|\\s|\\()(["+e+"]((?:"+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]=e,o[3]=s):s=o[3],s}var A="slash-menu-popup";function on({isSelected:e,item:t,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:d,schemaPath:i}}=R(),{i18n:s}=mt(),c=`${A}__item ${A}__item-${t.key}`;e&&(c+=` ${A}__item--selected`);let u=t.key;return t.label&&(u=typeof t.label=="function"?t.label({featureClientSchemaMap:d,i18n:s,schemaPath:i}):t.label),u.length>25&&(u=u.substring(0,25)+"..."),ut("button",{"aria-selected":e,className:c,id:A+"__item-"+t.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[t?.Icon&&U(t.Icon,{}),U("span",{className:`${A}__item-text`,children:u})]},t.key)}function pt({anchorElem:e=document.body}){let[t]=Xo(),[o,r]=tn(null),{editorConfig:n}=R(),{i18n:d}=mt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),c=dt("/",{minLength:0}),u=Zo(()=>{let l=[];for(let a of n.features.slashMenu.dynamicGroups)if(o){let h=a({editor:t,queryString:o});l=l.concat(h)}return l},[t,o,n?.features]),y=en(()=>{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:e,groups:y,menuRenderFn:(l,{selectedItemKey:a,selectItemAndCleanUp:h,setSelectedItemKey:x})=>l.current&&y.length?ft.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),ut("div",{className:`${A}__group ${A}__group-${g.key}`,children:[U("div",{className:`${A}__group-title`,children:m}),g.items.map((p,f)=>U(on,{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 nn}from"react/compiler-runtime";import{useLexicalComposerContext as rn}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as sn,TextNode as ln}from"lexical";import{useEffect as an}from"react";function gt(e){let t=nn(6),{features:o}=e,[r]=rn(),n;t[0]!==r||t[1]!==o.enabledFormats?(n=()=>{let i=cn(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(ln,s=>{i.forEach(c=>{s.hasFormat(c)&&s.toggleFormat(c)})})},t[0]=r,t[1]=o.enabledFormats,t[2]=n):n=t[2];let d;return t[3]!==r||t[4]!==o?(d=[r,o],t[3]=r,t[4]=o,t[5]=d):d=t[5],an(n,d),null}function cn(e){let t=Object.keys(sn),o=new Set(e);return t.filter(r=>!o.has(r))}import{c as dn}from"react/compiler-runtime";import{jsx as ht}from"react/jsx-runtime";import{useLexicalComposerContext as un}from"@lexical/react/LexicalComposerContext";import{ContentEditable as mn}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as fn}from"@payloadcms/ui";import"react";function yt(e){let t=dn(5),{className:o,editorConfig:r}=e,{t:n}=fn(),[,d]=un(),{getTheme:i}=d,s;if(t[0]!==o||t[1]!==r?.admin?.placeholder||t[2]!==i||t[3]!==n){let c=i();s=ht(mn,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:ht("p",{className:c?.placeholder,children:r?.admin?.placeholder??n("lexical:general:placeholder")})}),t[0]=o,t[1]=r?.admin?.placeholder,t[2]=i,t[3]=n,t[4]=s}else s=t[4];return s}var Et=e=>{let t=pn(12),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:d}=e,i=R(),[s]=gn(),c=Cn(),[u,y]=Pn(null),l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{m!==null&&y(m)},t[0]=l):l=t[0];let a=l,h,x;t[1]!==s||t[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(Nn,()=>(m(),!0),xt),C=s.registerCommand(bn,()=>(p(),!0),xt);return()=>{f(),C(),i.parentEditor?.unregisterChild?.(i.uuid)}},x=[s,i],t[1]=s,t[2]=i,t[3]=h,t[4]=x):(h=t[3],x=t[4]),Sn(h,x);let g;return t[5]!==o||t[6]!==r||t[7]!==u||t[8]!==c||t[9]!==n||t[10]!==d?(g=te(J.Fragment,{children:[o.features.plugins?.map(Rn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(wn),E(En,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:a,children:E(yt,{editorConfig:o})})}),ErrorBoundary:hn}),E(at,{}),c&&E(it,{}),E(Ke,{}),E(Ie,{}),E(gt,{features:o.features}),E(ct,{}),c&&E(xn,{ignoreSelectionChange:!0,onChange:(m,p,f)=>{(!f.has("focus")||f.size>1)&&d?.(m,p,f)}}),u&&te(J.Fragment,{children:[!n&&c&&te(J.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:E(nt,{anchorElem:u}),o.admin?.hideAddBlockButton?null:E(Ge,{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(J.Fragment,{children:E(pt,{anchorElem:u})})]}),c&&te(J.Fragment,{children:[E(yn,{}),o?.features?.markdownTransformers?.length>0&&E(lt,{})]}),o.features.plugins?.map(kn),o.features.plugins?.map(Tn)]}),o.features.plugins?.map(Dn)]}),t[5]=o,t[6]=r,t[7]=u,t[8]=c,t[9]=n,t[10]=d,t[11]=g):g=t[11],g};function Rn(e){if(e.position==="aboveContainer")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function wn(e){if(e.position==="top")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function kn(e){if(e.position==="normal")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Tn(e){if(e.position==="bottom")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Dn(e){if(e.position==="belowContainer")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}var bt=({children:e,providers:t})=>{if(!t?.length)return e;let o=t[0];return t.length>1?$(o,{children:$(bt,{providers:t.slice(1),children:e})}):$(o,{children:e})},Nt=e=>{let{composerKey:t,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:d,readOnly:i,value:s}=e,c=R(),u=vn(),y=Ct.useRef(null),l=Mn(()=>{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:_e({editorConfig:o}),onError:a=>{throw a},theme:o.lexical.theme}},[o]);return l?$(Ln,{initialConfig:l,children:$(we,{editorConfig:o,editorContainerRef:y,fieldProps:r,parentContext:c?.editDepth===u?c:void 0,children:$(bt,{providers:o.features.providers,children:$(Et,{editorConfig:o,editorContainerRef:y,isSmallWidthViewport:n,onChange:d})})})},t+l.editable):$("p",{children:"Loading..."})};var pe="rich-text-lexical",Wn=e=>{let{editorConfig:t,field:o,field:{admin:{className:r,description:n,readOnly:d}={},label:i,localized:s,required:c},path:u,readOnly:y,validate:l}=e,a=y||d,h=In(),x=Rt((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:P,path:b,setValue:w,showError:N,value:v}=$n({potentiallyStalePath:u,validate:x}),O=a||k,[T,D]=kt(!1),[q,he]=kt(),ye=Pt.useRef(P),I=Pt.useRef(v);wt(()=>{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",O&&`${pe}--read-only`,t?.admin?.hideGutter!==!0&&!T?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${h}`,L=Te(),S=Rt(M=>{L(()=>{let Re=M.toJSON();I.current=Re,w(Re)})},[w,L]),Tt=jn(()=>Kn(o),[o]),Dt=Fn(M=>{I.current!==v&&!Hn(I.current!=null?JSON.parse(JSON.stringify(I.current)):I.current,v)&&(ye.current=M,I.current=v,he(new Date))});return wt(()=>{Object.is(P,ye.current)||Dt(P)},[P]),ge("div",{className:Pe,style:Tt,children:[B(St,{CustomComponent:f,Fallback:B(Bn,{path:b,showError:N})}),C||B(On,{label:i,localized:s,path:b,required:c}),ge("div",{className:`${pe}__wrap`,children:[ge(zn,{fallbackRender:Yn,onReset:()=>{},children:[m,B(_n,{drawerSlugPrefix:b,children:B(Nt,{composerKey:oe,editorConfig:t,fieldProps:e,isSmallWidthViewport:T,onChange:S,readOnly:O,value:v},JSON.stringify({path:b,rerenderProviderKey:q}))}),g]}),B(St,{CustomComponent:p,Fallback:B(An,{description:n,path:b})})]})]},oe)};function Yn({error:e}){return ge("div",{className:"errorBoundary",role:"alert",children:[B("p",{children:"Something went wrong:"}),B("pre",{style:{color:"red"},children:e.message})]})}var Fs=Wn;export{Fs as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-HJGV32KA.js.map
|