@payloadcms/richtext-lexical 4.0.0-internal.cd47d20 → 4.0.0-internal.ce66a41
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-MT4FK3IP.js +2 -0
- package/dist/exports/client/Field-MT4FK3IP.js.map +7 -0
- package/dist/exports/client/chunk-3LRZDIIG.js +2 -0
- package/dist/exports/client/{chunk-LN6VX25I.js.map → chunk-3LRZDIIG.js.map} +2 -2
- package/dist/exports/client/chunk-ATPSL6IX.js +2 -0
- package/dist/exports/client/chunk-ATPSL6IX.js.map +7 -0
- package/dist/exports/client/componentInline-ZEP5JPTC.js +2 -0
- package/dist/exports/client/index.js +27 -27
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +43 -33
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/component/useBlockReordering.js +3 -3
- package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.css +0 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +30 -22
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +9 -0
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -0
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +95 -0
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -0
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js +3 -3
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +3 -3
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +4 -4
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/indent/client/IndentPlugin.d.ts.map +1 -1
- package/dist/features/indent/client/IndentPlugin.js +122 -1
- package/dist/features/indent/client/IndentPlugin.js.map +1 -1
- package/dist/features/indent/server/i18n.d.ts.map +1 -1
- package/dist/features/indent/server/i18n.js +74 -37
- package/dist/features/indent/server/i18n.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +7 -5
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.css +0 -1
- package/dist/features/relationship/client/components/index.css +3 -6
- package/dist/features/table/client/plugins/TableActionMenuPlugin/index.css +0 -1
- package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.css +0 -3
- package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +2 -2
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.css +0 -1
- package/dist/features/typesServer.d.ts +13 -8
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.css +0 -2
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js +3 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.css +0 -1
- package/dist/field/Diff/converters/unknown/index.css +0 -1
- package/dist/field/Diff/converters/upload/index.css +0 -1
- package/dist/field/Diff/index.css +0 -2
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +8 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.css +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.css +21 -10
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +61 -64
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
- package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +2 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.css +0 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +1 -0
- package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.css +0 -2
- package/dist/lexical/ui/ContentEditable.d.ts +2 -1
- package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +21 -7
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/presets/llmInstructions.d.ts +2 -0
- package/dist/presets/llmInstructions.d.ts.map +1 -0
- package/dist/presets/llmInstructions.js +13 -0
- package/dist/presets/llmInstructions.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/buildInitialState.d.ts +1 -0
- package/dist/utilities/buildInitialState.d.ts.map +1 -1
- package/dist/utilities/buildInitialState.js +1 -0
- package/dist/utilities/buildInitialState.js.map +1 -1
- package/dist/validate/hasText.d.ts +2 -2
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/package.json +22 -22
- package/dist/exports/client/Field-BPLEYPXV.js +0 -2
- package/dist/exports/client/Field-BPLEYPXV.js.map +0 -7
- package/dist/exports/client/bundled.css +0 -1
- package/dist/exports/client/chunk-ESITTE3C.js +0 -2
- package/dist/exports/client/chunk-ESITTE3C.js.map +0 -7
- package/dist/exports/client/chunk-LN6VX25I.js +0 -2
- package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
- package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts +0 -11
- package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +0 -1
- package/dist/features/blocks/client/component/removeEmptyArrayValues.js +0 -20
- package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +0 -1
- /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-ZEP5JPTC.js.map} +0 -0
|
@@ -4,16 +4,23 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
6
6
|
import { ContentEditable } from '@lexical/react/LexicalContentEditable.js';
|
|
7
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
7
8
|
import { useTranslation } from '@payloadcms/ui';
|
|
8
9
|
import './ContentEditable.css';
|
|
9
10
|
import * as React from 'react';
|
|
11
|
+
import { useEditorConfigContext } from '../config/client/EditorConfigProvider.js';
|
|
10
12
|
export function LexicalContentEditable(t0) {
|
|
11
|
-
const $ = _c(
|
|
13
|
+
const $ = _c(9);
|
|
12
14
|
const {
|
|
13
15
|
className,
|
|
14
|
-
editorConfig
|
|
16
|
+
editorConfig,
|
|
17
|
+
instructionsID
|
|
15
18
|
} = t0;
|
|
16
19
|
const {
|
|
20
|
+
fieldProps
|
|
21
|
+
} = useEditorConfigContext();
|
|
22
|
+
const {
|
|
23
|
+
i18n,
|
|
17
24
|
t
|
|
18
25
|
} = useTranslation();
|
|
19
26
|
const [, t1] = useLexicalComposerContext();
|
|
@@ -21,10 +28,13 @@ export function LexicalContentEditable(t0) {
|
|
|
21
28
|
getTheme
|
|
22
29
|
} = t1;
|
|
23
30
|
let t2;
|
|
24
|
-
if ($[0] !== className || $[1] !== editorConfig?.admin?.placeholder || $[2] !==
|
|
31
|
+
if ($[0] !== className || $[1] !== editorConfig?.admin?.placeholder || $[2] !== fieldProps.field.label || $[3] !== fieldProps.field.required || $[4] !== getTheme || $[5] !== i18n || $[6] !== instructionsID || $[7] !== t) {
|
|
25
32
|
const theme = getTheme();
|
|
26
33
|
t2 = _jsx(ContentEditable, {
|
|
34
|
+
"aria-describedby": instructionsID,
|
|
35
|
+
"aria-label": getTranslation(fieldProps.field.label || "", i18n),
|
|
27
36
|
"aria-placeholder": t("lexical:general:placeholder"),
|
|
37
|
+
"aria-required": fieldProps.field.required || undefined,
|
|
28
38
|
className: className ?? "ContentEditable__root",
|
|
29
39
|
placeholder: _jsx("p", {
|
|
30
40
|
className: theme?.placeholder,
|
|
@@ -33,11 +43,15 @@ export function LexicalContentEditable(t0) {
|
|
|
33
43
|
});
|
|
34
44
|
$[0] = className;
|
|
35
45
|
$[1] = editorConfig?.admin?.placeholder;
|
|
36
|
-
$[2] =
|
|
37
|
-
$[3] =
|
|
38
|
-
$[4] =
|
|
46
|
+
$[2] = fieldProps.field.label;
|
|
47
|
+
$[3] = fieldProps.field.required;
|
|
48
|
+
$[4] = getTheme;
|
|
49
|
+
$[5] = i18n;
|
|
50
|
+
$[6] = instructionsID;
|
|
51
|
+
$[7] = t;
|
|
52
|
+
$[8] = t2;
|
|
39
53
|
} else {
|
|
40
|
-
t2 = $[
|
|
54
|
+
t2 = $[8];
|
|
41
55
|
}
|
|
42
56
|
return t2;
|
|
43
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentEditable.js","names":["c","_c","useLexicalComposerContext","ContentEditable","useTranslation","React","LexicalContentEditable","t0","$","className","editorConfig","t","t1","getTheme","t2","admin","placeholder","theme","_jsx","children"],"sources":["../../../src/lexical/ui/ContentEditable.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable.js'\nimport { useTranslation } from '@payloadcms/ui'\n\nimport './ContentEditable.css'\n\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../config/types.js'\n\nexport function LexicalContentEditable({\n className,\n editorConfig,\n}: {\n className?: string\n editorConfig: SanitizedClientEditorConfig\n}): JSX.Element {\n const { t } = useTranslation<{}, string>()\n const [_, { getTheme }] = useLexicalComposerContext()\n const theme = getTheme()\n
|
|
1
|
+
{"version":3,"file":"ContentEditable.js","names":["c","_c","useLexicalComposerContext","ContentEditable","getTranslation","useTranslation","React","useEditorConfigContext","LexicalContentEditable","t0","$","className","editorConfig","instructionsID","fieldProps","i18n","t","t1","getTheme","t2","admin","placeholder","field","label","required","theme","_jsx","undefined","children"],"sources":["../../../src/lexical/ui/ContentEditable.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport { useTranslation } from '@payloadcms/ui'\n\nimport './ContentEditable.css'\n\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../config/types.js'\n\nimport { useEditorConfigContext } from '../config/client/EditorConfigProvider.js'\n\nexport function LexicalContentEditable({\n className,\n editorConfig,\n instructionsID,\n}: {\n className?: string\n editorConfig: SanitizedClientEditorConfig\n instructionsID?: string\n}): JSX.Element {\n const { fieldProps } = useEditorConfigContext()\n const { i18n, t } = useTranslation<{}, string>()\n const [_, { getTheme }] = useLexicalComposerContext()\n const theme = getTheme()\n return (\n <ContentEditable\n aria-describedby={instructionsID}\n aria-label={getTranslation(fieldProps.field.label || '', i18n)}\n aria-placeholder={t('lexical:general:placeholder')}\n aria-required={fieldProps.field.required || undefined}\n className={className ?? 'ContentEditable__root'}\n placeholder={\n <p className={theme?.placeholder}>\n {editorConfig?.admin?.placeholder ?? t('lexical:general:placeholder')}\n </p>\n }\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAE/B,OAAO;AAEP,YAAYC,KAAA,MAAW;AAIvB,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,SAAAC,uBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EAAgC;IAAAU,SAAA;IAAAC,YAAA;IAAAC;EAAA,IAAAJ,EAQtC;EACC;IAAAK;EAAA,IAAuBP,sBAAA;EACvB;IAAAQ,IAAA;IAAAC;EAAA,IAAoBX,cAAA;EACpB,SAAAY,EAAA,IAA0Bf,yBAAA;EAAhB;IAAAgB;EAAA,IAAAD,EAAY;EAAA,IAAAE,EAAA;EAAA,IAAAT,CAAA,QAAAC,SAAA,IAAAD,CAAA,QAAAE,YAAA,EAAAQ,KAAA,EAAAC,WAAA,IAAAX,CAAA,QAAAI,UAAA,CAAAQ,KAAA,CAAAC,KAAA,IAAAb,CAAA,QAAAI,UAAA,CAAAQ,KAAA,CAAAE,QAAA,IAAAd,CAAA,QAAAQ,QAAA,IAAAR,CAAA,QAAAK,IAAA,IAAAL,CAAA,QAAAG,cAAA,IAAAH,CAAA,QAAAM,CAAA;IACtB,MAAAS,KAAA,GAAcP,QAAA;IAEZC,EAAA,GAAAO,IAAA,CAAAvB,eAAA;MAAA,oBACoBU,cAAA;MAAA,cACNT,cAAA,CAAeU,UAAA,CAAAQ,KAAA,CAAAC,KAAA,IAA0B,IAAIR,IAAA;MAAA,oBACvCC,CAAA,CAAE;MAAA,iBACLF,UAAA,CAAAQ,KAAA,CAAAE,QAAA,IAAAG,SAA6B;MAAAhB,SAAA,EACjCA,SAAA,IAAa;MAAAU,WAAA,EAEtBK,IAAA,CAAC;QAAAf,SAAA,EAAac,KAAA,EAAAJ,WAAA;QAAAO,QAAA,EACXhB,YAAA,EAAAQ,KAAA,EAAAC,WAAA,IAAoCL,CAAA,CAAE;MAAA,C;;;;;;;;;;;;;;SAR7CG,E","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const getLLMInstructionsFeatures: () => (import("../index.js").FeatureProviderServer<undefined, undefined, undefined> | import("../index.js").FeatureProviderServer<undefined, undefined, null> | import("../index.js").FeatureProviderServer<import("../features/toolbars/fixed/server/index.js").FixedToolbarFeatureProps, import("../features/toolbars/fixed/server/index.js").FixedToolbarFeatureProps, import("../features/toolbars/fixed/server/index.js").FixedToolbarFeatureProps> | import("../index.js").FeatureProviderServer<import("../features/heading/server/index.js").HeadingFeatureProps, import("../features/heading/server/index.js").HeadingFeatureProps, import("../features/heading/server/index.js").HeadingFeatureProps>)[];
|
|
2
|
+
//# sourceMappingURL=llmInstructions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmInstructions.d.ts","sourceRoot":"","sources":["../../src/presets/llmInstructions.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,0BAA0B,orBAUtC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BoldFeature } from '../features/format/bold/feature.server.js';
|
|
2
|
+
import { ItalicFeature } from '../features/format/italic/feature.server.js';
|
|
3
|
+
import { StrikethroughFeature } from '../features/format/strikethrough/feature.server.js';
|
|
4
|
+
import { HeadingFeature } from '../features/heading/server/index.js';
|
|
5
|
+
import { OrderedListFeature } from '../features/lists/orderedList/server/index.js';
|
|
6
|
+
import { UnorderedListFeature } from '../features/lists/unorderedList/server/index.js';
|
|
7
|
+
import { ParagraphFeature } from '../features/paragraph/server/index.js';
|
|
8
|
+
import { FixedToolbarFeature } from '../features/toolbars/fixed/server/index.js';
|
|
9
|
+
import { InlineToolbarFeature } from '../features/toolbars/inline/server/index.js';
|
|
10
|
+
export const getLLMInstructionsFeatures = () => [ParagraphFeature(), HeadingFeature({
|
|
11
|
+
enabledHeadingSizes: ['h2', 'h3', 'h4']
|
|
12
|
+
}), BoldFeature(), ItalicFeature(), StrikethroughFeature(), UnorderedListFeature(), OrderedListFeature(), FixedToolbarFeature(), InlineToolbarFeature()];
|
|
13
|
+
//# sourceMappingURL=llmInstructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmInstructions.js","names":["BoldFeature","ItalicFeature","StrikethroughFeature","HeadingFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","FixedToolbarFeature","InlineToolbarFeature","getLLMInstructionsFeatures","enabledHeadingSizes"],"sources":["../../src/presets/llmInstructions.ts"],"sourcesContent":["import { BoldFeature } from '../features/format/bold/feature.server.js'\nimport { ItalicFeature } from '../features/format/italic/feature.server.js'\nimport { StrikethroughFeature } from '../features/format/strikethrough/feature.server.js'\nimport { HeadingFeature } from '../features/heading/server/index.js'\nimport { OrderedListFeature } from '../features/lists/orderedList/server/index.js'\nimport { UnorderedListFeature } from '../features/lists/unorderedList/server/index.js'\nimport { ParagraphFeature } from '../features/paragraph/server/index.js'\nimport { FixedToolbarFeature } from '../features/toolbars/fixed/server/index.js'\nimport { InlineToolbarFeature } from '../features/toolbars/inline/server/index.js'\n\nexport const getLLMInstructionsFeatures = () => [\n ParagraphFeature(),\n HeadingFeature({ enabledHeadingSizes: ['h2', 'h3', 'h4'] }),\n BoldFeature(),\n ItalicFeature(),\n StrikethroughFeature(),\n UnorderedListFeature(),\n OrderedListFeature(),\n FixedToolbarFeature(),\n InlineToolbarFeature(),\n]\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,0BAAA,GAA6BA,CAAA,KAAM,CAC9CH,gBAAA,IACAH,cAAA,CAAe;EAAEO,mBAAA,EAAqB,CAAC,MAAM,MAAM;AAAM,IACzDV,WAAA,IACAC,aAAA,IACAC,oBAAA,IACAG,oBAAA,IACAD,kBAAA,IACAG,mBAAA,IACAC,oBAAA,GACD","ignoreList":[]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DecoratorNode, EditorConfig, LexicalEditor, EditorConfig as LexicalEditorConfig, LexicalNode, SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
2
|
-
import type { ClientField, DefaultServerCellComponentProps, LabelFunction,
|
|
2
|
+
import type { ClientField, DefaultServerCellComponentProps, LabelFunction, MarkdownRichTextAdapter, PayloadComponent, RichTextField, RichTextFieldClient, RichTextFieldClientProps, SanitizedConfig, ServerFieldBase, StaticLabel } from 'payload';
|
|
3
3
|
import type { BlockComponentContextType } from '../features/blocks/client/component/BlockContent.js';
|
|
4
4
|
export type { BlockComponentContextType };
|
|
5
5
|
import type { BlockComponentProps } from '../features/blocks/client/component/index.js';
|
|
@@ -409,7 +409,7 @@ export type LexicalEditorProps = {
|
|
|
409
409
|
export type LexicalRichTextAdapter = {
|
|
410
410
|
editorConfig: SanitizedServerEditorConfig;
|
|
411
411
|
features: FeatureProviderServer<any, any, any>[];
|
|
412
|
-
} &
|
|
412
|
+
} & MarkdownRichTextAdapter<SerializedEditorState, AdapterProps>;
|
|
413
413
|
export type LexicalRichTextAdapterProvider =
|
|
414
414
|
/**
|
|
415
415
|
* This is being called during the payload sanitization process
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.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,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAA;AACpG,YAAY,EAAE,yBAAyB,EAAE,CAAA;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAA;AACzG,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,+BAA+B,EAChC,MAAM,wDAAwD,CAAA;AAC/D,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,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+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/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.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'\n\nimport type { BlockComponentContextType } from '../features/blocks/client/component/BlockContent.js'\nexport type { BlockComponentContextType }\nimport type { BlockComponentProps } from '../features/blocks/client/component/index.js'\nimport type { InlineBlockComponentContextType } from '../features/blocks/client/componentInline/index.js'\nimport type {\n JSXConverterArgs,\n JSXConverters,\n SerializedLexicalNodeWithParent,\n} 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 { InitialLexicalFormState } from '../utilities/buildInitialState.js'\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from './nodeTypes.js'\n\n/**\n * Base constraint for serialized Lexical node types.\n * Used as the generic constraint for node map types.\n * Extends the base SerializedLexicalNode with optional type for flexibility.\n */\nexport type SerializedNodeBase = { type?: string }\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<TNode extends SerializedNodeBase = SerializedLexicalNode> = {\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\ntype SharedViewMapBlockEditorProps<TNode extends SerializedBlockNode | SerializedInlineBlockNode> =\n {\n /**\n * True when rendering in the admin editor.\n */\n isEditor: true\n /**\n * False when rendering in the admin editor.\n */\n isJSXConverter: false\n } & Pick<BlockComponentProps<TNode['fields']>, 'className' | 'formData' | 'nodeKey'>\n\n/**\n * Props passed to a custom Block component in editor mode.\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockEditorProps<TNode extends SerializedBlockNode> = {\n /**\n * Hook to access block UI components (BlockCollapsible, EditButton, etc.).\n * Call this inside your component to get the context values.\n * Passed as a prop so you don't need to import from @payloadcms/richtext-lexical/client.\n */\n useBlockComponentContext: () => BlockComponentContextType\n} & SharedViewMapBlockEditorProps<TNode>\n\n/**\n * Props passed to a custom Block component in editor mode.\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapInlineBlockEditorProps<TNode extends SerializedInlineBlockNode> = {\n useInlineBlockComponentContext: () => InlineBlockComponentContextType\n} & SharedViewMapBlockEditorProps<TNode>\n\n/**\n * Props passed to a custom Block component in JSX converter mode (frontend).\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockJSXConverterProps<\n TNode extends SerializedBlockNode | SerializedInlineBlockNode =\n | SerializedBlockNode\n | SerializedInlineBlockNode,\n> = {\n /**\n * Index of this node among its siblings.\n */\n childIndex: number\n /**\n * Available JSX converters for nested content.\n */\n converters: JSXConverters\n /**\n * The block's form data (field values).\n */\n formData: TNode['fields']\n /**\n * False when rendering via JSX converter (frontend).\n */\n isEditor: false\n /**\n * True when rendering via JSX converter (frontend).\n */\n isJSXConverter: true\n /**\n * The serialized block node.\n */\n node: TNode\n /**\n * Function to convert child nodes to JSX.\n */\n nodesToJSX: (args: {\n converters?: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => React.ReactNode[]\n /**\n * The parent node in the tree.\n */\n parent: SerializedLexicalNodeWithParent\n}\n\n/**\n * Props passed to a custom Block component in a view map.\n * This is a discriminated union - use `isEditor` to narrow the type.\n *\n * When `isEditor` is true, you're in the admin editor with access to `blockContext`.\n * When `isEditor` is false, you're in the frontend JSX converter with `nodesToJSX`.\n *\n * @example\n * ```tsx\n * const MyBlock: React.FC<ViewMapBlockComponentProps> = (props) => {\n * if (props.isEditor) {\n * // Admin editor - blockContext available\n * const { BlockCollapsible, EditButton } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * // Frontend - readonly render\n * return <div>{props.formData.title}</div>\n * }\n * ```\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockComponentProps<TNode extends SerializedBlockNode = SerializedBlockNode> =\n | ViewMapBlockEditorProps<TNode>\n | ViewMapBlockJSXConverterProps<TNode>\n\nexport type ViewMapInlineBlockComponentProps<\n TNode extends SerializedInlineBlockNode = SerializedInlineBlockNode,\n> = ViewMapBlockJSXConverterProps<TNode> | ViewMapInlineBlockEditorProps<TNode>\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapBlockValue<TNode extends SerializedBlockNode = SerializedBlockNode> = {\n /**\n * A React component that replaces the entire block, including the header/collapsible.\n * Works for both admin editor and frontend JSX conversion.\n *\n * Use `isEditor` to discriminate between modes:\n * - Editor mode: `blockContext` is available with UI components (BlockCollapsible, EditButton, etc.)\n * - JSX converter mode: `nodesToJSX` is available for rendering nested content\n *\n * @example\n * ```tsx\n * Block: (props) => {\n * if (props.isEditor) {\n * const { BlockCollapsible } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * return <div>{props.formData.title}</div>\n * }\n * ```\n */\n Block?: React.FC<ViewMapBlockComponentProps<TNode>>\n /**\n * A React component that replaces the block label.\n * Use `useBlockComponentContext()` hook to access block context.\n */\n Label?: React.FC<ViewMapBlockComponentProps<TNode>>\n} & Pick<NodeMapValue<TNode>, 'Component' | 'createDOM' | 'html'>\n\nexport type NodeMapInlineBlockValue<\n TNode extends SerializedInlineBlockNode = SerializedInlineBlockNode,\n> = {\n /**\n * A React component that replaces the entire block, including the header/collapsible.\n * Works for both admin editor and frontend JSX conversion.\n *\n * Use `isEditor` to discriminate between modes:\n * - Editor mode: `blockContext` is available with UI components (BlockCollapsible, EditButton, etc.)\n * - JSX converter mode: `nodesToJSX` is available for rendering nested content\n *\n * @example\n * ```tsx\n * InlineBlock: (props) => {\n * if (props.isEditor) {\n * const { BlockCollapsible } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * return <div>{props.formData.title}</div>\n * }\n * ```\n */\n Block?: React.FC<ViewMapInlineBlockComponentProps<TNode>>\n /**\n * A React component that replaces the block label.\n * Use `useBlockComponentContext()` hook to access block context.\n */\n Label?: React.FC<ViewMapInlineBlockComponentProps<TNode>>\n} & Pick<NodeMapValue<TNode>, 'Component' | 'createDOM' | 'html'>\n\n/**\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorNodeMap<\n TNodes extends SerializedNodeBase =\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 // The index signature must include NodeMapBlockValue in the nested blockSlug mapping because\n // 'blocks' and 'inlineBlocks' properties use NodeMapBlockValue (which adds Block/Label props).\n // TypeScript requires that intersection properties be assignable to index signatures.\n [key: string]:\n | {\n [blockSlug: string]: NodeMapBlockValue<any> | NodeMapInlineBlockValue<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<TNodes, { type: 'block' }> &\n SerializedBlockNode)['fields']['blockType']]?: NodeMapBlockValue<\n Extract<\n Extract<TNodes, { type: 'block' }> & SerializedBlockNode,\n { fields: { blockType: K } }\n >\n >\n }\n inlineBlocks?: {\n [K in (Extract<TNodes, { type: 'inlineBlock' }> &\n SerializedInlineBlockNode)['fields']['blockType']]?: NodeMapInlineBlockValue<\n Extract<\n Extract<TNodes, { type: 'inlineBlock' }> & SerializedInlineBlockNode,\n { fields: { blockType: K } }\n >\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 ClientFeaturesMap = {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n}\n\nexport type LexicalEditorViewMap<\n TNodes extends SerializedNodeBase =\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 /**\n * Transform the client features for this view.\n * Receives the full clientFeatures map and should return a (potentially modified) map.\n * Can be used to remove features or add new ones per-view.\n *\n * @example Remove toolbars\n * ```ts\n * filterFeatures: (features) => {\n * const { toolbarFixed, toolbarInline, ...rest } = features\n * return rest\n * }\n * ```\n */\n filterFeatures?: (clientFeatures: ClientFeaturesMap) => ClientFeaturesMap\n /**\n * Lexical editor configuration. Can be an object or a function that receives the default config.\n * Using a function avoids needing to import defaultEditorLexicalConfig.\n *\n * @example\n * ```ts\n * lexical: (defaultConfig) => ({\n * ...defaultConfig,\n * theme: { ...defaultConfig.theme, paragraph: 'my-paragraph' },\n * })\n * ```\n */\n lexical?: ((defaultConfig: LexicalEditorConfig) => LexicalEditorConfig) | 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 }) => 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: ClientFeaturesMap\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 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":"AAyhBA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.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 MarkdownRichTextAdapter,\n PayloadComponent,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type { BlockComponentContextType } from '../features/blocks/client/component/BlockContent.js'\nexport type { BlockComponentContextType }\nimport type { BlockComponentProps } from '../features/blocks/client/component/index.js'\nimport type { InlineBlockComponentContextType } from '../features/blocks/client/componentInline/index.js'\nimport type {\n JSXConverterArgs,\n JSXConverters,\n SerializedLexicalNodeWithParent,\n} 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 { InitialLexicalFormState } from '../utilities/buildInitialState.js'\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from './nodeTypes.js'\n\n/**\n * Base constraint for serialized Lexical node types.\n * Used as the generic constraint for node map types.\n * Extends the base SerializedLexicalNode with optional type for flexibility.\n */\nexport type SerializedNodeBase = { type?: string }\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<TNode extends SerializedNodeBase = SerializedLexicalNode> = {\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\ntype SharedViewMapBlockEditorProps<TNode extends SerializedBlockNode | SerializedInlineBlockNode> =\n {\n /**\n * True when rendering in the admin editor.\n */\n isEditor: true\n /**\n * False when rendering in the admin editor.\n */\n isJSXConverter: false\n } & Pick<BlockComponentProps<TNode['fields']>, 'className' | 'formData' | 'nodeKey'>\n\n/**\n * Props passed to a custom Block component in editor mode.\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockEditorProps<TNode extends SerializedBlockNode> = {\n /**\n * Hook to access block UI components (BlockCollapsible, EditButton, etc.).\n * Call this inside your component to get the context values.\n * Passed as a prop so you don't need to import from @payloadcms/richtext-lexical/client.\n */\n useBlockComponentContext: () => BlockComponentContextType\n} & SharedViewMapBlockEditorProps<TNode>\n\n/**\n * Props passed to a custom Block component in editor mode.\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapInlineBlockEditorProps<TNode extends SerializedInlineBlockNode> = {\n useInlineBlockComponentContext: () => InlineBlockComponentContextType\n} & SharedViewMapBlockEditorProps<TNode>\n\n/**\n * Props passed to a custom Block component in JSX converter mode (frontend).\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockJSXConverterProps<\n TNode extends SerializedBlockNode | SerializedInlineBlockNode =\n | SerializedBlockNode\n | SerializedInlineBlockNode,\n> = {\n /**\n * Index of this node among its siblings.\n */\n childIndex: number\n /**\n * Available JSX converters for nested content.\n */\n converters: JSXConverters\n /**\n * The block's form data (field values).\n */\n formData: TNode['fields']\n /**\n * False when rendering via JSX converter (frontend).\n */\n isEditor: false\n /**\n * True when rendering via JSX converter (frontend).\n */\n isJSXConverter: true\n /**\n * The serialized block node.\n */\n node: TNode\n /**\n * Function to convert child nodes to JSX.\n */\n nodesToJSX: (args: {\n converters?: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => React.ReactNode[]\n /**\n * The parent node in the tree.\n */\n parent: SerializedLexicalNodeWithParent\n}\n\n/**\n * Props passed to a custom Block component in a view map.\n * This is a discriminated union - use `isEditor` to narrow the type.\n *\n * When `isEditor` is true, you're in the admin editor with access to `blockContext`.\n * When `isEditor` is false, you're in the frontend JSX converter with `nodesToJSX`.\n *\n * @example\n * ```tsx\n * const MyBlock: React.FC<ViewMapBlockComponentProps> = (props) => {\n * if (props.isEditor) {\n * // Admin editor - blockContext available\n * const { BlockCollapsible, EditButton } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * // Frontend - readonly render\n * return <div>{props.formData.title}</div>\n * }\n * ```\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockComponentProps<TNode extends SerializedBlockNode = SerializedBlockNode> =\n | ViewMapBlockEditorProps<TNode>\n | ViewMapBlockJSXConverterProps<TNode>\n\nexport type ViewMapInlineBlockComponentProps<\n TNode extends SerializedInlineBlockNode = SerializedInlineBlockNode,\n> = ViewMapBlockJSXConverterProps<TNode> | ViewMapInlineBlockEditorProps<TNode>\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapBlockValue<TNode extends SerializedBlockNode = SerializedBlockNode> = {\n /**\n * A React component that replaces the entire block, including the header/collapsible.\n * Works for both admin editor and frontend JSX conversion.\n *\n * Use `isEditor` to discriminate between modes:\n * - Editor mode: `blockContext` is available with UI components (BlockCollapsible, EditButton, etc.)\n * - JSX converter mode: `nodesToJSX` is available for rendering nested content\n *\n * @example\n * ```tsx\n * Block: (props) => {\n * if (props.isEditor) {\n * const { BlockCollapsible } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * return <div>{props.formData.title}</div>\n * }\n * ```\n */\n Block?: React.FC<ViewMapBlockComponentProps<TNode>>\n /**\n * A React component that replaces the block label.\n * Use `useBlockComponentContext()` hook to access block context.\n */\n Label?: React.FC<ViewMapBlockComponentProps<TNode>>\n} & Pick<NodeMapValue<TNode>, 'Component' | 'createDOM' | 'html'>\n\nexport type NodeMapInlineBlockValue<\n TNode extends SerializedInlineBlockNode = SerializedInlineBlockNode,\n> = {\n /**\n * A React component that replaces the entire block, including the header/collapsible.\n * Works for both admin editor and frontend JSX conversion.\n *\n * Use `isEditor` to discriminate between modes:\n * - Editor mode: `blockContext` is available with UI components (BlockCollapsible, EditButton, etc.)\n * - JSX converter mode: `nodesToJSX` is available for rendering nested content\n *\n * @example\n * ```tsx\n * InlineBlock: (props) => {\n * if (props.isEditor) {\n * const { BlockCollapsible } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * return <div>{props.formData.title}</div>\n * }\n * ```\n */\n Block?: React.FC<ViewMapInlineBlockComponentProps<TNode>>\n /**\n * A React component that replaces the block label.\n * Use `useBlockComponentContext()` hook to access block context.\n */\n Label?: React.FC<ViewMapInlineBlockComponentProps<TNode>>\n} & Pick<NodeMapValue<TNode>, 'Component' | 'createDOM' | 'html'>\n\n/**\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorNodeMap<\n TNodes extends SerializedNodeBase =\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 // The index signature must include NodeMapBlockValue in the nested blockSlug mapping because\n // 'blocks' and 'inlineBlocks' properties use NodeMapBlockValue (which adds Block/Label props).\n // TypeScript requires that intersection properties be assignable to index signatures.\n [key: string]:\n | {\n [blockSlug: string]: NodeMapBlockValue<any> | NodeMapInlineBlockValue<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<TNodes, { type: 'block' }> &\n SerializedBlockNode)['fields']['blockType']]?: NodeMapBlockValue<\n Extract<\n Extract<TNodes, { type: 'block' }> & SerializedBlockNode,\n { fields: { blockType: K } }\n >\n >\n }\n inlineBlocks?: {\n [K in (Extract<TNodes, { type: 'inlineBlock' }> &\n SerializedInlineBlockNode)['fields']['blockType']]?: NodeMapInlineBlockValue<\n Extract<\n Extract<TNodes, { type: 'inlineBlock' }> & SerializedInlineBlockNode,\n { fields: { blockType: K } }\n >\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 ClientFeaturesMap = {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n}\n\nexport type LexicalEditorViewMap<\n TNodes extends SerializedNodeBase =\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 /**\n * Transform the client features for this view.\n * Receives the full clientFeatures map and should return a (potentially modified) map.\n * Can be used to remove features or add new ones per-view.\n *\n * @example Remove toolbars\n * ```ts\n * filterFeatures: (features) => {\n * const { toolbarFixed, toolbarInline, ...rest } = features\n * return rest\n * }\n * ```\n */\n filterFeatures?: (clientFeatures: ClientFeaturesMap) => ClientFeaturesMap\n /**\n * Lexical editor configuration. Can be an object or a function that receives the default config.\n * Using a function avoids needing to import defaultEditorLexicalConfig.\n *\n * @example\n * ```ts\n * lexical: (defaultConfig) => ({\n * ...defaultConfig,\n * theme: { ...defaultConfig.theme, paragraph: 'my-paragraph' },\n * })\n * ```\n */\n lexical?: ((defaultConfig: LexicalEditorConfig) => LexicalEditorConfig) | 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} & MarkdownRichTextAdapter<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 }) => 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: ClientFeaturesMap\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 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":"AAyhBA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;QACrB,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,YAAY,CAAC,EAAE,GAAG,CAAA;QAClB,KAAK,EAAE,aAAa,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB,sBAAsB,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,SAAS,CAAA;QACpB,WAAW,CAAC,EAAE,yBAAyB,CAAA;QACvC,WAAW,EAAE,mBAAmB,CAAA;QAChC,eAAe,EAAE,iBAAiB,CAAA;QAClC,aAAa,EAAE,GAAG,CAAA;QAClB,GAAG,EAAE,cAAc,CAAA;KACpB,CAAA;IACD,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,YAAY,EAAE,oBAAoB,EAClC,QAAQ,GACT,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA6D1C"}
|
|
@@ -43,6 +43,7 @@ export async function buildInitialState({
|
|
|
43
43
|
initialState[id] = {};
|
|
44
44
|
}
|
|
45
45
|
initialState[id].formState = formStateResult;
|
|
46
|
+
initialState[id].schemaPath = schemaFieldsPath;
|
|
46
47
|
if (node.type === 'block') {
|
|
47
48
|
const currentFieldPreferences = context.preferences?.fields?.[context.field.name];
|
|
48
49
|
const collapsedArray = currentFieldPreferences?.collapsed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildInitialState.js","names":["fieldSchemasToFormState","buildInitialState","context","initialState","initialStateFromArgs","nodeData","node","children","type","blockNode","id","fields","schemaFieldsPath","lexicalFieldSchemaPath","blockType","formStateResult","clientFieldSchemaMap","collectionSlug","data","documentData","fieldSchemaMap","get","initialBlockData","operation","permissions","preferences","readOnly","disabled","renderAllFields","renderFieldFn","req","schemaPath","formState","currentFieldPreferences","field","name","collapsedArray","collapsed","Array","isArray","includes"],"sources":["../../src/utilities/buildInitialState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type {\n ClientFieldSchemaMap,\n ComponentRenderer,\n DocumentPreferences,\n FieldSchemaMap,\n FormState,\n Operation,\n PayloadRequest,\n RichTextField,\n SanitizedFieldPermissions,\n} from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { SerializedBlockNode } from '../types/nodeTypes.js'\n\nexport type InitialLexicalFormState = {\n [nodeID: string]: {\n [key: string]: any\n formState?: FormState\n }\n}\n\ntype Props = {\n context: {\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n disabled?: boolean\n documentData?: any\n field: RichTextField\n fieldSchemaMap: FieldSchemaMap\n id?: number | string\n lexicalFieldSchemaPath: string\n operation: Operation\n permissions?: SanitizedFieldPermissions\n preferences: DocumentPreferences\n renderComponent: ComponentRenderer\n renderFieldFn: any\n req: PayloadRequest\n }\n initialState?: InitialLexicalFormState\n nodeData: SerializedLexicalNode[]\n}\n\nexport async function buildInitialState({\n context,\n initialState: initialStateFromArgs,\n nodeData,\n}: Props): Promise<InitialLexicalFormState> {\n let initialState: InitialLexicalFormState = initialStateFromArgs ?? {}\n for (const node of nodeData) {\n if ('children' in node) {\n initialState = await buildInitialState({\n context,\n initialState,\n nodeData: node.children as SerializedLexicalNode[],\n })\n }\n\n if (node.type === 'block' || node.type === 'inlineBlock') {\n const blockNode = node as SerializedBlockNode\n const id = blockNode?.fields?.id\n if (!id) {\n continue\n }\n\n const schemaFieldsPath =\n node.type === 'block'\n ? `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockNode.fields.blockType}.fields`\n : `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockNode.fields.blockType}.fields`\n\n // Build form state for the block\n\n const formStateResult = await fieldSchemasToFormState({\n id: context.id,\n clientFieldSchemaMap: context.clientFieldSchemaMap,\n collectionSlug: context.collectionSlug,\n data: blockNode.fields,\n documentData: context.documentData,\n fields: (context.fieldSchemaMap.get(schemaFieldsPath) as any)?.fields,\n fieldSchemaMap: context.fieldSchemaMap,\n initialBlockData: blockNode.fields,\n operation: context.operation as any, // TODO: Type\n permissions: true,\n preferences: context.preferences,\n readOnly: context.disabled,\n renderAllFields: true, // If this function runs, the parent lexical field is being re-rendered => thus we can assume all its sub-fields need to be re-rendered\n renderFieldFn: context.renderFieldFn,\n req: context.req,\n schemaPath: schemaFieldsPath,\n })\n\n if (!initialState[id]) {\n initialState[id] = {}\n }\n\n initialState[id].formState = formStateResult\n\n if (node.type === 'block') {\n const currentFieldPreferences = context.preferences?.fields?.[context.field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n if (Array.isArray(collapsedArray) && collapsedArray.includes(id)) {\n initialState[id].collapsed = true\n }\n }\n }\n }\n return initialState\n}\n"],"mappings":"AAaA,SAASA,uBAAuB,QAAQ;
|
|
1
|
+
{"version":3,"file":"buildInitialState.js","names":["fieldSchemasToFormState","buildInitialState","context","initialState","initialStateFromArgs","nodeData","node","children","type","blockNode","id","fields","schemaFieldsPath","lexicalFieldSchemaPath","blockType","formStateResult","clientFieldSchemaMap","collectionSlug","data","documentData","fieldSchemaMap","get","initialBlockData","operation","permissions","preferences","readOnly","disabled","renderAllFields","renderFieldFn","req","schemaPath","formState","currentFieldPreferences","field","name","collapsedArray","collapsed","Array","isArray","includes"],"sources":["../../src/utilities/buildInitialState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type {\n ClientFieldSchemaMap,\n ComponentRenderer,\n DocumentPreferences,\n FieldSchemaMap,\n FormState,\n Operation,\n PayloadRequest,\n RichTextField,\n SanitizedFieldPermissions,\n} from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { SerializedBlockNode } from '../types/nodeTypes.js'\n\nexport type InitialLexicalFormState = {\n [nodeID: string]: {\n [key: string]: any\n formState?: FormState\n schemaPath?: string\n }\n}\n\ntype Props = {\n context: {\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n disabled?: boolean\n documentData?: any\n field: RichTextField\n fieldSchemaMap: FieldSchemaMap\n id?: number | string\n lexicalFieldSchemaPath: string\n operation: Operation\n permissions?: SanitizedFieldPermissions\n preferences: DocumentPreferences\n renderComponent: ComponentRenderer\n renderFieldFn: any\n req: PayloadRequest\n }\n initialState?: InitialLexicalFormState\n nodeData: SerializedLexicalNode[]\n}\n\nexport async function buildInitialState({\n context,\n initialState: initialStateFromArgs,\n nodeData,\n}: Props): Promise<InitialLexicalFormState> {\n let initialState: InitialLexicalFormState = initialStateFromArgs ?? {}\n for (const node of nodeData) {\n if ('children' in node) {\n initialState = await buildInitialState({\n context,\n initialState,\n nodeData: node.children as SerializedLexicalNode[],\n })\n }\n\n if (node.type === 'block' || node.type === 'inlineBlock') {\n const blockNode = node as SerializedBlockNode\n const id = blockNode?.fields?.id\n if (!id) {\n continue\n }\n\n const schemaFieldsPath =\n node.type === 'block'\n ? `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockNode.fields.blockType}.fields`\n : `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockNode.fields.blockType}.fields`\n\n // Build form state for the block\n\n const formStateResult = await fieldSchemasToFormState({\n id: context.id,\n clientFieldSchemaMap: context.clientFieldSchemaMap,\n collectionSlug: context.collectionSlug,\n data: blockNode.fields,\n documentData: context.documentData,\n fields: (context.fieldSchemaMap.get(schemaFieldsPath) as any)?.fields,\n fieldSchemaMap: context.fieldSchemaMap,\n initialBlockData: blockNode.fields,\n operation: context.operation as any, // TODO: Type\n permissions: true,\n preferences: context.preferences,\n readOnly: context.disabled,\n renderAllFields: true, // If this function runs, the parent lexical field is being re-rendered => thus we can assume all its sub-fields need to be re-rendered\n renderFieldFn: context.renderFieldFn,\n req: context.req,\n schemaPath: schemaFieldsPath,\n })\n\n if (!initialState[id]) {\n initialState[id] = {}\n }\n\n initialState[id].formState = formStateResult\n initialState[id].schemaPath = schemaFieldsPath\n\n if (node.type === 'block') {\n const currentFieldPreferences = context.preferences?.fields?.[context.field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n if (Array.isArray(collapsedArray) && collapsedArray.includes(id)) {\n initialState[id].collapsed = true\n }\n }\n }\n }\n return initialState\n}\n"],"mappings":"AAaA,SAASA,uBAAuB,QAAQ;AAiCxC,OAAO,eAAeC,kBAAkB;EACtCC,OAAO;EACPC,YAAA,EAAcC,oBAAoB;EAClC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AAQyB,QAAQ;QAC1BC,eAAA,EAAiB;QACjBC,aAAA,EAAe3B,OAAA,CAAQ2B,aAAa;QACpCC,GAAA,EAAK5B,OAAA,CAAQ4B,GAAG;QAChBC,UAAA,EAAYnB;MACd;MAEA,IAAI,CAACT,YAAY,CAACO,EAAA,CAAG,EAAE;QACrBP,YAAY,CAACO,EAAA,CAAG,GAAG,CAAC;MACtB;MAEAP,YAAY,CAACO,EAAA,CAAG,CAACsB,SAAS,GAAGjB,eAAA;MAC7BZ,YAAY,CAACO,EAAA,CAAG,CAACqB,UAAU,GAAGnB,gBAAA;MAE9B,IAAIN,IAAA,CAAKE,IAAI,KAAK,SAAS;QACzB,MAAMyB,uBAAA,GAA0B/B,OAAA,CAAQuB,WAAW,EAAEd,MAAA,GAAST,OAAA,CAAQgC,KAAK,CAACC,IAAI,CAAC;QACjF,MAAMC,cAAA,GAAiBH,uBAAA,EAAyBI,SAAA;QAChD,IAAIC,KAAA,CAAMC,OAAO,CAACH,cAAA,KAAmBA,cAAA,CAAeI,QAAQ,CAAC9B,EAAA,GAAK;UAChEP,YAAY,CAACO,EAAA,CAAG,CAAC2B,SAAS,GAAG;QAC/B;MACF;IACF;EACF;EACA,OAAOlC,YAAA;AACT","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { SerializedEditorState
|
|
1
|
+
import type { SerializedEditorState } from 'lexical';
|
|
2
2
|
/**
|
|
3
3
|
* This function checks if the editor state is empty (has any text). If the editor state has no nodes,
|
|
4
4
|
* or only an empty paragraph node (no TextNode with length > 0), it returns false.
|
|
5
5
|
* Otherwise, it returns true.
|
|
6
6
|
*/
|
|
7
|
-
export declare function hasText(value: null | SerializedEditorState
|
|
7
|
+
export declare function hasText(value: null | SerializedEditorState | undefined): value is SerializedEditorState;
|
|
8
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,
|
|
1
|
+
{"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAA+C,MAAM,SAAS,CAAA;AAEjG;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,GAAG,SAAS,GAC9C,KAAK,IAAI,qBAAqB,CA6BhC"}
|
|
@@ -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 {
|
|
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 { SerializedEditorState, SerializedParagraphNode, SerializedTextNode } 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 | undefined,\n): value is SerializedEditorState {\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":"AAEA;;;;GAKA,OAAO,SAASA,QACdC,KAA+C;EAE/C,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/dist/validate/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import type { RichTextField, Validate } from 'payload';
|
|
|
3
3
|
import type { SanitizedServerEditorConfig } from '../lexical/config/types.js';
|
|
4
4
|
export declare const richTextValidateHOC: ({ editorConfig, }: {
|
|
5
5
|
editorConfig: SanitizedServerEditorConfig;
|
|
6
|
-
}) => Validate<SerializedEditorState
|
|
6
|
+
}) => Validate<SerializedEditorState, unknown, unknown, RichTextField>;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAK7E,eAAO,MAAM,mBAAmB,sBAE7B;IACD,YAAY,EAAE,2BAA2B,CAAA;CAC1C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAK7E,eAAO,MAAM,mBAAmB,sBAE7B;IACD,YAAY,EAAE,2BAA2B,CAAA;CAC1C,qEAiCA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.ce66a41",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -417,25 +417,25 @@
|
|
|
417
417
|
]
|
|
418
418
|
},
|
|
419
419
|
"dependencies": {
|
|
420
|
-
"@lexical/clipboard": "0.
|
|
421
|
-
"@lexical/headless": "0.
|
|
422
|
-
"@lexical/html": "0.
|
|
423
|
-
"@lexical/link": "0.
|
|
424
|
-
"@lexical/list": "0.
|
|
425
|
-
"@lexical/mark": "0.
|
|
426
|
-
"@lexical/markdown": "0.
|
|
427
|
-
"@lexical/react": "0.
|
|
428
|
-
"@lexical/rich-text": "0.
|
|
429
|
-
"@lexical/selection": "0.
|
|
430
|
-
"@lexical/table": "0.
|
|
431
|
-
"@lexical/utils": "0.
|
|
420
|
+
"@lexical/clipboard": "0.52.0",
|
|
421
|
+
"@lexical/headless": "0.52.0",
|
|
422
|
+
"@lexical/html": "0.52.0",
|
|
423
|
+
"@lexical/link": "0.52.0",
|
|
424
|
+
"@lexical/list": "0.52.0",
|
|
425
|
+
"@lexical/mark": "0.52.0",
|
|
426
|
+
"@lexical/markdown": "0.52.0",
|
|
427
|
+
"@lexical/react": "0.52.0",
|
|
428
|
+
"@lexical/rich-text": "0.52.0",
|
|
429
|
+
"@lexical/selection": "0.52.0",
|
|
430
|
+
"@lexical/table": "0.52.0",
|
|
431
|
+
"@lexical/utils": "0.52.0",
|
|
432
432
|
"acorn": "8.16.0",
|
|
433
433
|
"bson-objectid": "2.0.4",
|
|
434
434
|
"csstype": "3.2.3",
|
|
435
435
|
"dequal": "2.0.3",
|
|
436
436
|
"escape-html": "1.0.3",
|
|
437
437
|
"jsox": "1.2.125",
|
|
438
|
-
"lexical": "0.
|
|
438
|
+
"lexical": "0.52.0",
|
|
439
439
|
"mdast-util-from-markdown": "2.0.3",
|
|
440
440
|
"mdast-util-mdx-jsx": "3.2.0",
|
|
441
441
|
"micromark-extension-mdx-jsx": "3.0.2",
|
|
@@ -443,8 +443,8 @@
|
|
|
443
443
|
"react-error-boundary": "6.1.1",
|
|
444
444
|
"ts-essentials": "10.0.3",
|
|
445
445
|
"uuid": "14.0.0",
|
|
446
|
-
"@payloadcms/
|
|
447
|
-
"@payloadcms/
|
|
446
|
+
"@payloadcms/translations": "4.0.0-internal.ce66a41",
|
|
447
|
+
"@payloadcms/ui": "4.0.0-internal.ce66a41"
|
|
448
448
|
},
|
|
449
449
|
"devDependencies": {
|
|
450
450
|
"@babel/cli": "7.27.2",
|
|
@@ -452,26 +452,26 @@
|
|
|
452
452
|
"@babel/preset-env": "7.27.2",
|
|
453
453
|
"@babel/preset-react": "7.27.1",
|
|
454
454
|
"@babel/preset-typescript": "7.27.1",
|
|
455
|
-
"@lexical/eslint-plugin": "0.
|
|
455
|
+
"@lexical/eslint-plugin": "0.52.0",
|
|
456
456
|
"@types/escape-html": "1.0.4",
|
|
457
457
|
"@types/json-schema": "7.0.15",
|
|
458
458
|
"@types/node": "24.12.3",
|
|
459
|
-
"@types/react": "19.
|
|
460
|
-
"@types/react-dom": "19.
|
|
459
|
+
"@types/react": "19.3.0",
|
|
460
|
+
"@types/react-dom": "19.3.0",
|
|
461
461
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
|
462
462
|
"babel-plugin-transform-remove-imports": "^1.8.0",
|
|
463
463
|
"esbuild": "0.27.1",
|
|
464
464
|
"esbuild-sass-plugin": "3.3.1",
|
|
465
465
|
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
466
466
|
"@payloadcms/eslint-config": "3.28.0",
|
|
467
|
-
"payload": "4.0.0-internal.
|
|
467
|
+
"payload": "4.0.0-internal.ce66a41"
|
|
468
468
|
},
|
|
469
469
|
"peerDependencies": {
|
|
470
|
-
"@faceless-ui/modal": "3.0.
|
|
470
|
+
"@faceless-ui/modal": "3.0.2",
|
|
471
471
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
472
472
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
473
473
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
474
|
-
"payload": "4.0.0-internal.
|
|
474
|
+
"payload": "4.0.0-internal.ce66a41"
|
|
475
475
|
},
|
|
476
476
|
"engines": {
|
|
477
477
|
"node": ">=24.15.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{b as Ie,c as $e,e as j,f as z,h as Fe,i as Ke,j as je,k as ze,l as Re,m as Te,n as He}from"./chunk-LN6VX25I.js";import{a as Be,b as R}from"./chunk-RJ5MAOKZ.js";import{jsx as D,jsxs as ce}from"react/jsx-runtime";import{BulkUploadProvider as gn,FieldDescription as hn,FieldError as yn,FieldLabel as xn,isFieldRTL as bn,RenderCustomComponent as Kt,useConfig as Cn,useEditDepth as En,useEffectEvent as Nn,useField as wn,useLocale as Sn}from"@payloadcms/ui";import{mergeFieldStyles as Pn}from"@payloadcms/ui/shared";import{dequal as Rn}from"dequal/lite";import jt,{useCallback as zt,useEffect as Ht,useMemo as Tn,useState as Vt}from"react";import{ErrorBoundary as _n}from"react-error-boundary";import"./bundled.css";import{jsx as H}from"react/jsx-runtime";import{LexicalComposer as sn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as ln}from"@payloadcms/ui";import*as Ot from"react";import{useMemo as an}from"react";import{c as Hr}from"react/compiler-runtime";import{jsx as E,jsxs as ae}from"react/jsx-runtime";import{useLexicalComposerContext as Vr}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Wr}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Yr}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Gr}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Ur}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as Jr}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as qr,COMMAND_PRIORITY_LOW as At,FOCUS_COMMAND as Qr}from"lexical";import*as ee from"react";import{useEffect as Xr,useState as Zr}from"react";import{jsx as Ve}from"react/jsx-runtime";import"react";var V=({anchorElem:e,clientProps:t,plugin:o})=>o.position==="floatingAnchorElem"&&e?o.Component&&Ve(o.Component,{anchorElem:e,clientProps:t}):o.Component&&Ve(o.Component,{clientProps:t});import{c as Yt}from"react/compiler-runtime";import{copyToClipboard as We}from"@lexical/clipboard";import{useLexicalComposerContext as Gt}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Ut}from"@lexical/utils";import Ye from"bson-objectid";import{$getSelection as Jt,$isNodeSelection as qt,COMMAND_PRIORITY_LOW as Qt,COPY_COMMAND as Xt}from"lexical";import{useEffect as Zt}from"react";var _e=e=>{if("fields"in e&&typeof e.fields=="object"&&e.fields!==null&&"id"in e.fields?e.fields.id=new Ye.default().toHexString():"id"in e&&(e.id=new Ye.default().toHexString()),e.children)for(let t of e.children)_e(t)};function Ge(){let e=Yt(3),[t]=Gt(),o,n;return e[0]!==t?(o=()=>t.registerCommand(Xt,r=>{let i=Jt();if(qt(i)){let s=i.getNodes()[0]?.exportJSON(),u=JSON.parse(JSON.stringify(s));_e(u);let d={namespace:t._config.namespace,nodes:[u]},f=JSON.stringify(d);return We(t,null,{"application/x-lexical-editor":f,"text/plain":""}).catch(eo),!0}return We(t,Ut(r,ClipboardEvent)?r:null).then(()=>{if(!(r instanceof ClipboardEvent)||!r.clipboardData)throw new Error("No clipboard event");let l=r.clipboardData.getData("application/x-lexical-editor");if(!l)return!0;let s=JSON.parse(l);for(let d of s.nodes)_e(d);let u=JSON.stringify(s);r.clipboardData.setData("application/x-lexical-editor",u)}).catch(l=>{throw r instanceof ClipboardEvent&&r.clipboardData?.setData("application/x-lexical-editor",""),l}),!0},Qt),n=[t],e[0]=t,e[1]=o,e[2]=n):(o=e[1],n=e[2]),Zt(o,n),null}function eo(e){throw e}import{c as to}from"react/compiler-runtime";import{useLexicalComposerContext as oo}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ue,mergeRegister as ro}from"@lexical/utils";import{$createNodeSelection as no,$getEditor as ne,$getNearestNodeFromDOMNode as io,$getSelection as de,$isDecoratorNode as W,$isElementNode as ve,$isLineBreakNode as so,$isNodeSelection as fe,$isRangeSelection as Ue,$isRootOrShadowRoot as lo,$isTextNode as ao,$setSelection as Je,CLICK_COMMAND as co,COMMAND_PRIORITY_LOW as J,KEY_ARROW_DOWN_COMMAND as uo,KEY_ARROW_UP_COMMAND as fo,KEY_BACKSPACE_COMMAND as mo,KEY_DELETE_COMMAND as po,SELECTION_CHANGE_COMMAND as go}from"lexical";import{useEffect as ho}from"react";function qe(){let e=to(3),[t]=oo(),o=wo,n,r;return e[0]!==t?(n=()=>ro(t.registerCommand(co,No,J),t.registerCommand(po,o,J),t.registerCommand(mo,o,J),t.registerCommand(go,Eo,J),t.registerCommand(fo,bo,J),t.registerCommand(uo,yo,J)),r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),ho(n,r),null}function yo(e){let t=de();if(fe(t)){e.preventDefault();let l=t.getNodes()[0]?.getNextSibling();if(W(l)){let d=ne().getElementByKey(l.getKey());return d&&ie({element:d,node:l}),!0}if(!ve(l))return!0;let s=l.getFirstDescendant()??l;return s&&(ue(s,me)?.selectEnd(),e.preventDefault()),!0}if(!Ue(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=ue(n,xo),i=r?.getNextSibling();if(!r||i!==Qe(r))return!1;if(W(i)){let l=ne().getElementByKey(i.getKey());if(l)return ie({element:l,node:i}),e.preventDefault(),!0}return!1}function xo(e){return Qe(e)!==null}function bo(e){let t=de();if(fe(t)){let l=t.getNodes()[0]?.getPreviousSibling();if(W(l)){let d=ne().getElementByKey(l.getKey());return d?(ie({element:d,node:l}),e.preventDefault(),!0):!1}if(!ve(l))return!1;let s=l.getLastDescendant()??l;return s?(ue(s,me)?.selectStart(),e.preventDefault(),!0):!1}if(!Ue(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=ue(n,Co),i=r?.getPreviousSibling();if(!r||i!==Xe(r))return!1;if(W(i)){let l=ne().getElementByKey(i.getKey());if(l)return ie({element:l,node:i}),e.preventDefault(),!0}return!1}function Co(e){return Xe(e)!==null}function Eo(){let e=Ro();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),e?(e.element?.classList.add("decorator-selected"),!0):!1}function No(e){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let t=Po(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"]')?Je(null):ie(t),!0}function wo(e){let t=de();return fe(t)?(e.preventDefault(),t.getNodes().forEach(So),!0):!1}function So(e){e.remove()}function Po(e){if(!(e.target instanceof HTMLElement))return;let t=e.target.closest('[data-lexical-decorator="true"]');if(!(t instanceof HTMLElement))return;let o=io(t);return W(o)?{element:t,node:o}:void 0}function Ro(){let e=de();if(!fe(e))return;let t=e.getNodes();if(t.length!==1)return;let o=t[0];return W(o)?{decorator:o,element:ne().getElementByKey(o.getKey())}:void 0}function ie({element:e,node:t}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=no();o.add(t.getKey()),Je(o),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.classList.add("decorator-selected")}function me(e){if(W(e)&&!e.isInline())return!0;if(!ve(e)||lo(e))return!1;let t=e.getFirstChild(),o=t===null||so(t)||ao(t)||t.isInline();return!e.isInline()&&e.canBeEmpty()!==!1&&o}function Qe(e){let t=e.getNextSibling();for(;t!==null;){if(me(t))return t;t=t.getNextSibling()}return null}function Xe(e){let t=e.getPreviousSibling();for(;t!==null;){if(me(t))return t;t=t.getPreviousSibling()}return null}import{jsx as ke}from"react/jsx-runtime";import{useLexicalComposerContext as Lo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Ao,isHTMLElement as Mo}from"lexical";import*as ot from"react";import{useCallback as Oo,useEffect as tt,useRef as Bo,useState as Io}from"react";import{createPortal as $o}from"react-dom";var q=(e,t,o,n,r=50,i=25)=>{let l=0;if(e&&!e.contains(n)){let{bottom:s,left:u,right:d,top:f}=e.getBoundingClientRect(),c=f+window.scrollY,a=s+window.scrollY;if(o<c-i||o>a+i||t<u-r||t>d+r)return-1;(t<u||t>d)&&(l=t<u?t-u:t-d)}return l};import{$getNodeByKey as ge}from"lexical";function Q(e){let t=e.getBoundingClientRect(),o=getComputedStyle(e).getPropertyValue("transform");if(!o||o==="none")return t;let n=o.split(",").pop();return t.y=t.y-Number(n?.replace(")","")),t}function pe(e){let t=(u,d)=>u?parseFloat(window.getComputedStyle(u)[d]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(e),r=t(e.previousElementSibling,"marginBottom"),i=t(e.nextElementSibling,"marginTop"),l=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),i),marginTop:l}}import{$getRoot as To}from"lexical";function Y(e){return e.getEditorState().read(()=>To().getChildrenKeys())}var _o=1,vo=-1,Ze=0,O={props:null,result:null};function ko(e,t,o=20){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=o*o}function X(e){let{anchorElem:t,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:i=0,point:{x:l,y:s},startIndex:u=0,useEdgeAsDefault:d=!1}=e;if(o>0&&O.props&&O.result&&O.props.fuzzy===e.fuzzy&&O.props.horizontalOffset===e.horizontalOffset&&O.props.useEdgeAsDefault===e.useEdgeAsDefault&&ko(O.props.point,e.point,o))return O.result;let f=t.getBoundingClientRect(),c=Y(n),a={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(d){let m=n.getElementByKey(c[0]),p=n.getElementByKey(c[c.length-1]);if(m&&p){let[g,C]=[Q(m),Q(p)];if(s<g.top?(a.blockElem=m,a.distance=g.top-s,a.blockNode=ge(c[0]),a.foundAtIndex=0):s>C.bottom&&(a.distance=s-C.bottom,a.blockNode=ge(c[c.length-1]),a.blockElem=p,a.foundAtIndex=c.length-1),a?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let h=u,y=Ze;for(;h>=0&&h<c.length;){let m=c[h],p=n.getElementByKey(m);if(p===null)break;let g=new z(l+i,s),C=ze.fromDOMRect(Q(p)),{marginBottom:b,marginTop:N}=pe(p),x=C.generateNewRect({bottom:C.bottom+b,left:f.left,right:f.right,top:C.top-N}),{distance:P,isOnBottomSide:_,isOnTopSide:T}=x.distanceFromPoint(g);if(P===0){a.blockElem=p,a.blockNode=ge(m),a.foundAtIndex=h,a.distance=P,a.blockNode&&a.blockNode.getType()==="paragraph"&&a.blockNode.getTextContent()===""&&(!r&&!e.returnEmptyParagraphs&&(a.blockElem=null,a.blockNode=null),a.isFoundNodeEmptyParagraph=!0);break}else r&&P<a.distance&&(a.blockElem=p,a.blockNode=ge(m),a.distance=P,a.foundAtIndex=h);y===Ze&&(T?y=vo:_?y=_o:y=1/0),h+=y}}),O.props=e,O.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 he(e,t){return!!e.closest(`.${t}`)}var Do=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function et(e){if(!e||Do.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 ye(e,t,o,n=0){if(!e){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}let r=e.getBoundingClientRect(),i=window.getComputedStyle(e),l=t.getBoundingClientRect(),s=o.getBoundingClientRect(),u;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(c=>e.classList.contains(c)||e.firstElementChild?.classList.contains(c)))u=r.top+8-s.top;else{let c=et(e)?parseInt(i.lineHeight,10):0;u=r.top+(c-l.height)/2-s.top}let f=n;t.style.opacity="1",t.style.transform=`translate(${f}px, ${u}px)`}var Fo="add-block-menu",xe=1/0;function Ko(e){return e===0?1/0:xe>=0&&xe<e?xe:Math.floor(e/2)}function jo(e,t,o){let n=t.parentElement,{editorConfig:r}=R(),i=r?.admin?.hideGutter?-24:12,l=Bo(null),[s,u]=Io(null);tt(()=>{function f(c){let a=c.target;if(!Mo(a))return;let h=q(n,c.pageX,c.pageY,a);if(h===-1){u(null);return}if(he(a,Fo))return;let y=Y(e),{blockElem:m,blockNode:p,foundAtIndex:g}=X({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-h,point:new z(c.x,c.y),returnEmptyParagraphs:!0,startIndex:Ko(y.length),useEdgeAsDefault:!1});xe=g,m&&p&&(s?.node!==p||s?.elem!==m)&&u({elem:m,node:p})}return document?.addEventListener("mousemove",f),()=>{document?.removeEventListener("mousemove",f)}},[n,t,e,s]),tt(()=>{l.current&&s?.node&&ye(s?.elem,l.current,t,i)},[t,s,i]);let d=Oo(f=>{let c=s;c?.node&&(e.update(()=>{let a=!0;if((c?.node.getType()!=="paragraph"||c.node.getTextContent()!=="")&&(a=!1),!a){let h=Ao();c?.node.insertAfter(h),setTimeout(()=>{c={elem:e.getElementByKey(h.getKey()),node:h},u(c)},0)}}),setTimeout(()=>{e.update(()=>{e.focus(),c?.node&&"select"in c.node&&typeof c.node.select=="function"&&c.node.select()})},1),setTimeout(()=>{e.dispatchCommand(Ke,{node:c?.node})},2),f.stopPropagation(),f.preventDefault())},[e,s]);return $o(ke(ot.Fragment,{children:ke("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:f=>{d(f)},ref:l,type:"button",children:ke("div",{className:o?"icon":""})})}),t)}function rt(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=Lo();return jo(n,o,n._editable)}import{jsx as be,jsxs as ct}from"react/jsx-runtime";import{useLexicalComposerContext as Jo}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ut}from"@lexical/rich-text";import{useTranslation as qo}from"@payloadcms/ui";import{$getNearestNodeFromDOMNode as dt,$getNodeByKey as Qo,isHTMLElement as De}from"lexical";import*as ht from"react";import{useEffect as Le,useId as Xo,useRef as se,useState as ft}from"react";import{createPortal as Zo}from"react-dom";var nt=0,zo=-24;var G=0;function it(e,t,o,n,r,i,l,s,u,d=!1){let{height:f,top:c}=n.getBoundingClientRect(),{top:a,width:h}=l.getBoundingClientRect(),{marginBottom:y,marginTop:m}=pe(n),p=c,g=i>=c+f/2+window.scrollY,C=!1;if(r?.elem)if(n!==r?.elem)(g&&r?.elem&&r?.elem===n.nextElementSibling||!g&&r?.elem&&r?.elem===n.previousElementSibling)&&(G++,G<200&&(C=!0));else{G++;let P=r?.boundingBox?.y,_=n.getBoundingClientRect().y;(g===r?.isBelow&&P===_||G<200)&&(C=!1)}if(C)return{isBelow:g,willStayInSamePosition:C};d?p+=f/2:g?p+=f+y/2:p-=m/2;let b=0;d||(g?b=-nt:b=nt);let N=p-a+b,x=zo-t;return o.style.width=`calc(${h}px - ${e} - var(--spacer-5))`,o.style.opacity=".8",o.style.transform=`translate(${x}px, calc(${N}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?g?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),G=0,{isBelow:g,willStayInSamePosition:C}}import{mergeRegister as Ho}from"@lexical/utils";import{$getSelection as Vo,$isNodeSelection as Wo,$isRangeSelection as Yo,COMMAND_PRIORITY_HIGH as st,KEY_ARROW_DOWN_COMMAND as Go,KEY_ARROW_UP_COMMAND as Uo}from"lexical";import{useEffect as lt}from"react";function at({editor:e,instructionsID:t}){lt(()=>{let o=({direction:n,event:r})=>{if(!e.isEditable()||!r.altKey||!r.shiftKey||r.ctrlKey||r.metaKey)return!1;let i=Vo(),s=(Yo(i)&&i.isCollapsed()?i.anchor.getNode():Wo(i)&&i.getNodes().length===1?i.getNodes()[0]:null)?.getTopLevelElement();if(!s)return!1;r.preventDefault();let u=n===-1?s.getPreviousSibling():s.getNextSibling();return u&&(n===-1?u.insertBefore(s):u.insertAfter(s)),!0};return Ho(e.registerCommand(Uo,n=>o({direction:-1,event:n}),st),e.registerCommand(Go,n=>o({direction:1,event:n}),st))},[e]),lt(()=>{let o,n=e.registerRootListener(r=>{if(o?.(),!r)return;let i=r.getAttribute("aria-describedby");r.setAttribute("aria-describedby",[i,t].filter(Boolean).join(" ")),o=()=>{i===null?r.removeAttribute("aria-describedby"):r.setAttribute("aria-describedby",i)}});return()=>{n(),o?.()}},[e,t])}var er="draggable-block-menu",mt="application/x-lexical-drag-block",le=1/0;function pt(e){return e===0?1/0:le>=0&&le<e?le:Math.floor(e/2)}function tr(e,t){let{transform:o}=t.style;e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function gt(e,t){e&&(e.style.opacity="0"),t&&(t.style.opacity="",t.style.marginBottom="",t.style.marginTop="")}function or(e,t,o){let n=t.parentElement,r=Xo(),{t:i}=qo();at({editor:e,instructionsID:r});let l=se(null),s=se(null),u=se(null),d=se(!1),f=se([]),[c,a]=ft(null),[h,y]=ft(null),{editorConfig:m}=R(),p=m?.admin?.hideGutter?-44:-8;Le(()=>{function b(N){let x=N.target;if(!De(x))return;let P=q(n,N.pageX,N.pageY,x);if(P===-1){a(null);return}if(he(x,er))return;let _=Y(e),{blockElem:T,foundAtIndex:I,isFoundNodeEmptyParagraph:L}=X({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-P,point:new z(N.x,N.y),startIndex:pt(_.length),useEdgeAsDefault:!1,verbose:!1});le=I,!(!T&&!L)&&c!==T&&a(T)}return document?.addEventListener("mousemove",b),()=>{document?.removeEventListener("mousemove",b)}},[n,t,e,c]),Le(()=>{l.current&&ye(c,l.current,t,p)},[t,c,p]),Le(()=>{function b(x){if(!d.current)return!1;let[P]=ut(x);if(P)return!1;let{pageY:_,target:T}=x;if(!De(T))return!1;let I=q(n,x.pageX,x.pageY,T,100,50),L=Y(e),{blockElem:w,foundAtIndex:U,isFoundNodeEmptyParagraph:$}=X({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-I,point:new z(x.x,x.y),startIndex:pt(L.length),useEdgeAsDefault:!0,verbose:!0});le=U;let v=s.current;if(w===null||v===null)return!1;if(x.preventDefault(),x.dataTransfer.dropEffect="move",c!==w){let{isBelow:k,willStayInSamePosition:F}=it(m?.admin?.hideGutter?"0px":"var(--spacer-5)",p+(m?.admin?.hideGutter?l?.current?.getBoundingClientRect()?.width??0:-(l?.current?.getBoundingClientRect()?.width??0)),v,w,h,_,t,x,u,$);F||y({boundingBox:w.getBoundingClientRect(),elem:w,isBelow:k})}else h?.elem&&(gt(v,h.elem),y({boundingBox:w.getBoundingClientRect(),elem:w,isBelow:!1}));return!0}function N(x){if(!d.current)return!1;let[P]=ut(x);if(P)return!1;let{dataTransfer:_,pageY:T,target:I}=x,L=_?.getData(mt)||"";return e.update(()=>{let w=Qo(L);if(!w||!De(I))return!1;let U=q(n,x.pageX,x.pageY,I,100,50),{blockElem:$,isFoundNodeEmptyParagraph:v}=X({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-U,point:new z(x.x,x.y),useEdgeAsDefault:!0});if(!$)return!1;let k=dt($);if(!k)return!1;if(k===w)return!0;let{height:F,top:Ce}=Q($),Ee=T>=Ce+F/2+window.scrollY;v?(k.insertBefore(w),k.remove()):Ee?k.insertAfter(w):k.insertBefore(w),c!==null&&a(null),document.querySelectorAll(".lexical-block-highlighter").forEach(A=>{A.remove()});let K=e.getElementByKey(w.getKey()),we=setTimeout(()=>{let A=K?.getBoundingClientRect();if(!A)return;let S=document.createElement("div");S.className="lexical-block-highlighter",S.style.backgroundColor="var(--color-bg-inverse)",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=`${A.height+8}px`,S.style.width=`${A.width+8}px`,S.style.top=`${A.top+window.scrollY-4}px`,S.style.left=`${A.left-4}px`;let Se=setTimeout(()=>{S.style.opacity="0";let Pe=setTimeout(()=>{S.remove()},500);f.current.push(Pe)},1e3);f.current.push(Se)},120);f.current.push(we)}),!0}return document.addEventListener("dragover",b),document.addEventListener("drop",N),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",N),f.current.forEach(clearTimeout),f.current=[]}},[n,p,t,e,h,c,m?.admin?.hideGutter]);function g(b){let N=b.dataTransfer;if(!N||!c)return;tr(N,c),N.effectAllowed="move";let x="";e.update(()=>{let P=dt(c);P&&(x=P.getKey())}),d.current=!0,N.setData(mt,x)}function C(){d.current=!1,h?.elem&>(s.current,h?.elem)}return Zo(ct(ht.Fragment,{children:[ct("span",{className:"sr-only",id:r,children:[i("general:moveUp"),": Alt + Shift + \u2191. ",i("general:moveDown"),": Alt + Shift + \u2193."]}),be("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:C,onDragStart:g,ref:l,type:"button",children:be("div",{className:o?"icon":""})}),be("div",{className:"draggable-block-target-line",ref:s}),be("div",{className:"debug-highlight",ref:u})]}),t)}function yt(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=Jo();return or(n,o,n._editable)}import{c as rr}from"react/compiler-runtime";import{jsx as Ae}from"react/jsx-runtime";import{useLexicalComposerContext as nr}from"@lexical/react/LexicalComposerContext";import{useTranslation as ir}from"@payloadcms/ui";import{$createParagraphNode as sr,$getRoot as lr}from"lexical";import"react";var xt="insert-paragraph-at-end",bt=()=>{let e=rr(5),[t]=nr(),{editorConfig:o}=R(),{t:n}=ir();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;e[0]!==t?(r=()=>{t.update(ar)},e[0]=t,e[1]=r):r=e[1];let i=r,l;return e[2]!==i||e[3]!==n?(l=Ae("button",{"aria-label":n("lexical:general:insertParagraph"),className:xt,onClick:i,type:"button",children:Ae("span",{className:`${xt}-inside`,children:Ae(Ie,{size:16})})}),e[2]=i,e[3]=n,e[4]=l):l=e[4],l};function ar(){let e=sr();lr().append(e),e.select()}import{c as cr}from"react/compiler-runtime";import{registerMarkdownShortcuts as ur}from"@lexical/markdown";import{useLexicalComposerContext as dr}from"@lexical/react/LexicalComposerContext";import*as Ct from"react";var Et=()=>{let e=cr(4),{editorConfig:t}=R(),[o]=dr(),n,r;return e[0]!==o||e[1]!==t.features.markdownTransformers?(n=()=>ur(o,t.features.markdownTransformers??[]),r=[o,t.features.markdownTransformers],e[0]=o,e[1]=t.features.markdownTransformers,e[2]=n,e[3]=r):(n=e[2],r=e[3]),Ct.useEffect(n,r),null};import{c as fr}from"react/compiler-runtime";import{useLexicalComposerContext as mr}from"@lexical/react/LexicalComposerContext.js";import{$getRoot as pr}from"lexical";import{useEffect as gr}from"react";function hr(e){e.update(()=>{let t=o=>{let n=o.getType();if((n==="block"||n==="inlineBlock")&&o.markDirty(),"getChildren"in o&&typeof o.getChildren=="function")for(let r of o.getChildren())t(r)};t(pr())})}function Nt(){let e=fr(5),[t]=mr(),{currentView:o,views:n}=j(),r,i;return e[0]!==o||e[1]!==t||e[2]!==n?(r=()=>{n&&(o==="default"?n.default?Re(t,n.default?.nodes):Te(t):n[o]&&(Te(t),Re(t,n[o]?.nodes)),hr(t))},i=[t,n,o],e[0]=o,e[1]=t,e[2]=n,e[3]=r,e[4]=i):(r=e[3],i=e[4]),gr(r,i),null}import{useLexicalComposerContext as yr}from"@lexical/react/LexicalComposerContext";import{$getSelection as xr,$isRangeSelection as br,RootNode as Cr}from"lexical";import{useEffect as Er}from"react";function wt(){let[e]=yr();return Er(()=>e.registerNodeTransform(Cr,t=>{let o=xr();if(br(o)){let n=o.anchor.getNode(),r=o.focus.getNode();(!n.isAttached()||!r.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 Nr}from"@lexical/react/LexicalComposerContext";import{$getSelection as wr,COMMAND_PRIORITY_LOW as Sr,SELECT_ALL_COMMAND as Pr}from"lexical";import{useEffect as Rr}from"react";function St(){let[e]=Nr();return Rr(()=>e.registerCommand(Pr,()=>{if(wr())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Sr),[e]),null}import{jsx as Z,jsxs as Rt}from"react/jsx-runtime";import{useLexicalComposerContext as _r}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as Tt}from"@payloadcms/ui";import{useCallback as vr,useMemo as kr,useState as Dr}from"react";import"react";import*as _t from"react-dom";import{c as Tr}from"react/compiler-runtime";import"react";function Pt(e,t){let o=Tr(4),{maxLength:n,minLength:r}=t,i=n===void 0?75:n,l=r===void 0?1:r,s;return o[0]!==i||o[1]!==l||o[2]!==e?(s=u=>{let{query:d}=u,f="[^"+e+Fe+"\\s]",a=new RegExp("(^|\\s|\\()(["+e+"]((?:"+f+"){0,"+i+"}))$").exec(d);if(a!==null){let h=a[1],y=a[3];if(y.length>=l)return{leadOffset:a.index+h.length,matchingString:y,replaceableString:a[2]}}return null},o[0]=i,o[1]=l,o[2]=e,o[3]=s):s=o[3],s}var B="slash-menu-popup";function Lr({isSelected:e,item:t,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=R(),{i18n:s}=Tt(),u=`${B}__item ${B}__item-${t.key}`;e&&(u+=` ${B}__item--selected`);let d=t.key;return t.label&&(d=typeof t.label=="function"?t.label({featureClientSchemaMap:i,i18n:s,schemaPath:l}):t.label),d.length>25&&(d=d.substring(0,25)+"..."),Rt("button",{"aria-selected":e,className:u,id:B+"__item-"+t.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[t?.Icon&&Z(t.Icon,{}),Z("span",{className:`${B}__item-text`,children:d})]},t.key)}function vt({anchorElem:e=document.body}){let[t]=_r(),[o,n]=Dr(null),{editorConfig:r}=R(),{i18n:i}=Tt(),{fieldProps:{featureClientSchemaMap:l,schemaPath:s}}=R(),u=Pt("/",{minLength:0}),d=vr(()=>{let c=[];for(let a of r.features.slashMenu.dynamicGroups)if(o){let h=a({editor:t,queryString:o});c=c.concat(h)}return c},[t,o,r?.features]),f=kr(()=>{let c=[];for(let a of r?.features.slashMenu.groups??[])c.push(a);if(o){let a=o.toLowerCase().replace(/[\s\-_]/g,"");c=c.map(y=>{let m=y.items.filter(p=>{let g=p.key;return p.label&&(g=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:i,schemaPath:s}):p.label),new RegExp(o,"gi").exec(g)||g.toLowerCase().replace(/[\s\-_]/g,"").includes(a)?!0:p.keywords!=null?p.keywords.some(b=>new RegExp(o,"gi").exec(b)?!0:b.toLowerCase().replace(/[\s\-_]/g,"").includes(a)):!1});return m.length?{...y,items:m}:null}),c=c.filter(y=>y!=null);let h=d();for(let y of h){let m=c.find(p=>p.key===y.key);m?c=c.filter(p=>p.key!==y.key):m={...y,items:[]},m?.items?.length&&(m.items=m.items.concat(m.items)),c.push(m)}}return c},[o,r?.features.slashMenu.groups,d,l,i,s]);return Z(je,{anchorElem:e,groups:f,menuRenderFn:(c,{selectedItemKey:a,selectItemAndCleanUp:h,setSelectedItemKey:y})=>c.current&&f.length?_t.createPortal(Z("div",{className:B,"data-theme":"dark",children:f.map(m=>{let p=m.key;return m.label&&l&&(p=typeof m.label=="function"?m.label({featureClientSchemaMap:l,i18n:i,schemaPath:s}):m.label),Rt("div",{className:`${B}__group ${B}__group-${m.key}`,children:[Z("div",{className:`${B}__group-title`,children:p}),m.items.map((g,C)=>Z(Lr,{index:C,isSelected:a===g.key,item:g,onClick:()=>{y(g.key),h(g)},onMouseEnter:()=>{y(g.key)},ref:b=>{g.ref={current:b}}},g.key))]},m.key)})}),c.current):null,onQueryChange:n,triggerFn:u})}import{c as Ar}from"react/compiler-runtime";import{useLexicalComposerContext as Mr}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Or,TextNode as Br}from"lexical";import{useEffect as Ir}from"react";function kt(e){let t=Ar(6),{features:o}=e,[n]=Mr(),r;t[0]!==n||t[1]!==o.enabledFormats?(r=()=>{let l=$r(o.enabledFormats);if(l.length!==0)return n.registerNodeTransform(Br,s=>{l.forEach(u=>{s.hasFormat(u)&&s.toggleFormat(u)})})},t[0]=n,t[1]=o.enabledFormats,t[2]=r):r=t[2];let i;return t[3]!==n||t[4]!==o?(i=[n,o],t[3]=n,t[4]=o,t[5]=i):i=t[5],Ir(r,i),null}function $r(e){let t=Object.keys(Or),o=new Set(e);return t.filter(n=>!o.has(n))}import{c as Fr}from"react/compiler-runtime";import{jsx as Dt}from"react/jsx-runtime";import{useLexicalComposerContext as Kr}from"@lexical/react/LexicalComposerContext";import{ContentEditable as jr}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as zr}from"@payloadcms/ui";import"react";function Lt(e){let t=Fr(5),{className:o,editorConfig:n}=e,{t:r}=zr(),[,i]=Kr(),{getTheme:l}=i,s;if(t[0]!==o||t[1]!==n?.admin?.placeholder||t[2]!==l||t[3]!==r){let u=l();s=Dt(jr,{"aria-placeholder":r("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Dt("p",{className:u?.placeholder,children:n?.admin?.placeholder??r("lexical:general:placeholder")})}),t[0]=o,t[1]=n?.admin?.placeholder,t[2]=l,t[3]=r,t[4]=s}else s=t[4];return s}var Mt=e=>{let t=Hr(13),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:i,rtl:l}=e,s=R(),[u]=Vr(),d=Jr(),[f,c]=Zr(null),a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=g=>{g!==null&&c(g)},t[0]=a):a=t[0];let h=a,y,m;t[1]!==u||t[2]!==s?(y=()=>{if(!s?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}s?.parentEditor?.uuid&&s.parentEditor?.registerChild(s.uuid,s);let g=()=>{s.focusEditor(s)},C=()=>{s.blurEditor(s)},b=u.registerCommand(Qr,()=>(g(),!0),At),N=u.registerCommand(qr,()=>(C(),!0),At);return()=>{b(),N(),s.parentEditor?.unregisterChild?.(s.uuid)}},m=[u,s],t[1]=u,t[2]=s,t[3]=y,t[4]=m):(y=t[3],m=t[4]),Xr(y,m);let p;return t[5]!==o||t[6]!==n||t[7]!==f||t[8]!==d||t[9]!==r||t[10]!==i||t[11]!==l?(p=ae(ee.Fragment,{children:[o.features.plugins?.map(en),ae("div",{className:"editor-container",dir:l?"rtl":void 0,ref:n,children:[o.features.plugins?.map(tn),E(Ur,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:h,children:E(Lt,{editorConfig:o})})}),ErrorBoundary:Wr}),E(wt,{}),d&&E(bt,{}),E(qe,{}),E(Ge,{}),E(kt,{features:o.features}),E(St,{}),E(Nt,{}),d&&E(Gr,{ignoreSelectionChange:!0,onChange:(g,C,b)=>{(!b.has("focus")||b.size>1)&&i?.(g,C,b)}}),f&&ae(ee.Fragment,{children:[!r&&d&&ae(ee.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:E(yt,{anchorElem:f}),o.admin?.hideAddBlockButton?null:E(rt,{anchorElem:f})]}),o.features.plugins?.map(g=>{if(g.position==="floatingAnchorElem"&&!(g.desktopOnly===!0&&r))return E(V,{anchorElem:f,clientProps:g.clientProps,plugin:g},g.key)}),d&&E(ee.Fragment,{children:E(vt,{anchorElem:f})})]}),d&&ae(ee.Fragment,{children:[E(Yr,{}),o?.features?.markdownTransformers?.length>0&&E(Et,{})]}),o.features.plugins?.map(on),o.features.plugins?.map(rn)]}),o.features.plugins?.map(nn)]}),t[5]=o,t[6]=n,t[7]=f,t[8]=d,t[9]=r,t[10]=i,t[11]=l,t[12]=p):p=t[12],p};function en(e){if(e.position==="aboveContainer")return E(V,{clientProps:e.clientProps,plugin:e},e.key)}function tn(e){if(e.position==="top")return E(V,{clientProps:e.clientProps,plugin:e},e.key)}function on(e){if(e.position==="normal")return E(V,{clientProps:e.clientProps,plugin:e},e.key)}function rn(e){if(e.position==="bottom")return E(V,{clientProps:e.clientProps,plugin:e},e.key)}function nn(e){if(e.position==="belowContainer")return E(V,{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?H(o,{children:H(Bt,{providers:t.slice(1),children:e})}):H(o,{children:e})},It=e=>{let{composerKey:t,editorConfig:o,fieldProps:n,isSmallWidthViewport:r,onChange:i,readOnly:l,rtl:s,value:u}=e,{currentView:d,views:f}=j(),c=R(),a=ln(),h=Ot.useRef(null),y=an(()=>{if(u&&typeof u!="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(u));if(u&&Array.isArray(u)&&!("root"in u))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(u&&"jsonContent"in u)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");let m=f?.[d]?.nodes;return{editable:l!==!0,editorState:u!=null?JSON.stringify(u):void 0,namespace:o.lexical.namespace,nodes:He({editorConfig:o,nodeViews:m}),onError:p=>{throw p},theme:o.lexical.theme}},[o,f,d]);return y?H(sn,{initialConfig:y,children:H(Be,{editorConfig:o,editorContainerRef:h,fieldProps:n,parentContext:c?.editDepth===a?c:void 0,children:H(Bt,{providers:o.features.providers,children:H(Mt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:r,onChange:i,rtl:s})})})},t+y.editable+d):H("p",{children:"Loading..."})};import{c as cn}from"react/compiler-runtime";import{jsx as te,jsxs as un}from"react/jsx-runtime";import{ChevronIcon as dn,Popup as fn,PopupList as $t}from"@payloadcms/ui";import"react";function Ft(){let e=cn(5),{currentView:t,setCurrentView:o,views:n}=j();if(!n||Object.keys(n).length===0)return null;let r,i;if(e[0]!==t||e[1]!==o||e[2]!==n){i=Symbol.for("react.early_return_sentinel");e:{let l=Object.keys(n);if(!l.some(pn)){i=null;break e}let u=["default",...l.filter(mn)],d=t.charAt(0).toUpperCase()+t.slice(1);r=te("div",{className:"lexical-view-selector",children:te(fn,{button:un("button",{className:"lexical-view-selector__button",type:"button",children:[te("span",{className:"lexical-view-selector__label",children:d}),te(dn,{className:"lexical-view-selector__icon"})]}),buttonType:"custom",horizontalAlign:"left",popupType:"menu",render:f=>{let{close:c}=f;return te($t.ButtonGroup,{children:u.map(a=>{let h=a.charAt(0).toUpperCase()+a.slice(1);return te($t.Button,{active:a===t,disabled:a===t,onClick:()=>{o?.(a),c()},children:h},a)})})},size:"large"})})}e[0]=t,e[1]=o,e[2]=n,e[3]=r,e[4]=i}else r=e[3],i=e[4];return i!==Symbol.for("react.early_return_sentinel")?i:r}function mn(e){return e!=="default"}function pn(e){return e!=="default"}var oe="rich-text-lexical",vn=e=>{let{editorConfig:t,field:o,field:{admin:{className:n,description:r,readOnly:i}={},label:l,localized:s,required:u},path:d,readOnly:f,schemaPath:c,validate:a}=e,h=f||i,y=Sn(),{config:{localization:m}}=Cn(),p=bn({fieldLocalized:s,locale:y,localizationConfig:m||void 0}),g=En(),{isControlledByParent:C}=j(),b=zt((M,re)=>typeof a=="function"?a(M,{...re,required:u}):!0,[a,u]),{customComponents:{AfterInput:N,BeforeInput:x,Description:P,Error:_,Label:T}={},disabled:I,initialValue:L,path:w,setValue:U,showError:$,value:v}=wn({potentiallyStalePath:d,validate:b}),k=h||I,[F,Ce]=Vt(!1),[Me,Ee]=Vt(),Ne=jt.useRef(L),K=jt.useRef(v);Ht(()=>{let M=()=>{let re=window.matchMedia("(max-width: 768px)").matches;re!==F&&Ce(re)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[F]);let we=["field-type",oe,n,$&&"error",k&&`${oe}--read-only`,t?.admin?.hideGutter!==!0&&!F?`${oe}--show-gutter`:null].filter(Boolean).join(" "),A=`${w}.${g}`,S=$e(),Se=zt(M=>{S(()=>{let Oe=M.toJSON();K.current=Oe,U(Oe)})},[U,S]),Pe=Tn(()=>Pn(o),[o]),Wt=Nn(M=>{K.current!==v&&!Rn(K.current!=null?JSON.parse(JSON.stringify(K.current)):K.current,v)&&(Ne.current=M,K.current=v,Ee(new Date))});return Ht(()=>{Object.is(L,Ne.current)||Wt(L)},[L]),ce("div",{className:we,"data-field-path":w,"data-field-schemapath":c,"data-lexical-view":t?.view,style:Pe,children:[ce("div",{className:`${oe}__label-row`,children:[T||D(xn,{label:l,localized:s,path:w,required:u}),!C&&D(Ft,{})]}),ce("div",{className:`${oe}__wrap`,children:[D(Kt,{CustomComponent:_,Fallback:D(yn,{path:w,showError:$})}),ce(_n,{fallbackRender:kn,onReset:()=>{},children:[x,D("div",{className:`${oe}__editor-content`,children:D(gn,{modalSlugPrefix:`lexical-${w}`,children:D(It,{composerKey:A,editorConfig:t,fieldProps:e,isSmallWidthViewport:F,onChange:Se,readOnly:k,rtl:p,value:v},JSON.stringify({path:w,rerenderProviderKey:Me}))})}),N]}),D(Kt,{CustomComponent:P,Fallback:D(hn,{description:r,path:w})})]})]},A)};function kn({error:e}){return ce("div",{className:"errorBoundary",role:"alert",children:[D("p",{children:"Something went wrong:"}),D("pre",{style:{color:"red"},children:e instanceof Error?e.message:String(e)})]})}var Jl=vn;export{Jl as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-BPLEYPXV.js.map
|