@payloadcms/richtext-lexical 3.67.0-internal.87c53da → 3.68.0-canary.0

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.
Files changed (111) hide show
  1. package/dist/exports/client/Field-2A2VQXKP.js +2 -0
  2. package/dist/exports/client/Field-2A2VQXKP.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-AFXLIYGL.js +12 -0
  5. package/dist/exports/client/chunk-AFXLIYGL.js.map +7 -0
  6. package/dist/exports/client/index.d.ts +0 -1
  7. package/dist/exports/client/index.d.ts.map +1 -1
  8. package/dist/exports/client/index.js +20 -20
  9. package/dist/exports/client/index.js.map +3 -3
  10. package/dist/exports/react/index.d.ts +1 -1
  11. package/dist/exports/react/index.d.ts.map +1 -1
  12. package/dist/exports/react/index.js.map +1 -1
  13. package/dist/features/blocks/client/component/index.js +1 -3
  14. package/dist/features/blocks/client/component/index.js.map +1 -1
  15. package/dist/features/blocks/client/componentInline/index.js +1 -3
  16. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  17. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -2
  18. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  19. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js +3 -6
  20. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +1 -1
  21. package/dist/features/converters/lexicalToHtml/async/converters/link.js +1 -2
  22. package/dist/features/converters/lexicalToHtml/async/converters/link.js.map +1 -1
  23. package/dist/features/converters/lexicalToHtml/sync/converters/link.js +1 -2
  24. package/dist/features/converters/lexicalToHtml/sync/converters/link.js.map +1 -1
  25. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +14 -2
  26. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  27. package/dist/features/converters/lexicalToJSX/Component/index.js +2 -4
  28. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  29. package/dist/features/converters/lexicalToJSX/converter/converters/link.js +1 -2
  30. package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
  31. package/dist/features/converters/lexicalToJSX/converter/index.d.ts +1 -16
  32. package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
  33. package/dist/features/converters/lexicalToJSX/converter/index.js +4 -76
  34. package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
  35. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +10 -14
  36. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  37. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  38. package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
  39. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  40. package/dist/field/Diff/converters/link.js +1 -2
  41. package/dist/field/Diff/converters/link.js.map +1 -1
  42. package/dist/field/Field.d.ts.map +1 -1
  43. package/dist/field/Field.js +6 -11
  44. package/dist/field/Field.js.map +1 -1
  45. package/dist/field/bundled.css +1 -1
  46. package/dist/field/index.d.ts +0 -1
  47. package/dist/field/index.d.ts.map +1 -1
  48. package/dist/field/index.js +29 -47
  49. package/dist/field/index.js.map +1 -1
  50. package/dist/field/rscEntry.d.ts +1 -1
  51. package/dist/field/rscEntry.d.ts.map +1 -1
  52. package/dist/field/rscEntry.js +0 -12
  53. package/dist/field/rscEntry.js.map +1 -1
  54. package/dist/index.d.ts +1 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +1 -3
  57. package/dist/index.js.map +1 -1
  58. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  59. package/dist/lexical/LexicalEditor.js +1 -2
  60. package/dist/lexical/LexicalEditor.js.map +1 -1
  61. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  62. package/dist/lexical/LexicalProvider.js +3 -12
  63. package/dist/lexical/LexicalProvider.js.map +1 -1
  64. package/dist/lexical/config/client/EditorConfigProvider.js +1 -2
  65. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  66. package/dist/lexical/config/client/sanitize.d.ts +1 -1
  67. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  68. package/dist/lexical/config/client/sanitize.js +2 -3
  69. package/dist/lexical/config/client/sanitize.js.map +1 -1
  70. package/dist/lexical/config/types.d.ts +0 -4
  71. package/dist/lexical/config/types.d.ts.map +1 -1
  72. package/dist/lexical/config/types.js.map +1 -1
  73. package/dist/lexical/nodes/index.d.ts +2 -12
  74. package/dist/lexical/nodes/index.d.ts.map +1 -1
  75. package/dist/lexical/nodes/index.js +2 -195
  76. package/dist/lexical/nodes/index.js.map +1 -1
  77. package/dist/packages/@lexical/markdown/MarkdownImport.js +3 -6
  78. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -1
  79. package/dist/types.d.ts +2 -152
  80. package/dist/types.d.ts.map +1 -1
  81. package/dist/types.js.map +1 -1
  82. package/dist/utilities/fieldsDrawer/DrawerContent.js +1 -3
  83. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  84. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  85. package/dist/utilities/generateImportMap.js +0 -1
  86. package/dist/utilities/generateImportMap.js.map +1 -1
  87. package/dist/utilities/useRunDeprioritized.js +1 -2
  88. package/dist/utilities/useRunDeprioritized.js.map +1 -1
  89. package/dist/validate/hasText.d.ts +1 -6
  90. package/dist/validate/hasText.d.ts.map +1 -1
  91. package/dist/validate/hasText.js +4 -10
  92. package/dist/validate/hasText.js.map +1 -1
  93. package/package.json +9 -12
  94. package/dist/exports/client/Field-YM44WOON.js +0 -2
  95. package/dist/exports/client/Field-YM44WOON.js.map +0 -7
  96. package/dist/exports/client/chunk-6NIGQP6A.js +0 -12
  97. package/dist/exports/client/chunk-6NIGQP6A.js.map +0 -7
  98. package/dist/exports/client/internal-client.d.ts +0 -3
  99. package/dist/exports/client/internal-client.d.ts.map +0 -1
  100. package/dist/field/RichTextViewProvider.d.ts +0 -83
  101. package/dist/field/RichTextViewProvider.d.ts.map +0 -1
  102. package/dist/field/RichTextViewProvider.js +0 -87
  103. package/dist/field/RichTextViewProvider.js.map +0 -1
  104. package/dist/field/ViewSelector.d.ts +0 -4
  105. package/dist/field/ViewSelector.d.ts.map +0 -1
  106. package/dist/field/ViewSelector.js +0 -89
  107. package/dist/field/ViewSelector.js.map +0 -1
  108. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +0 -2
  109. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +0 -1
  110. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +0 -48
  111. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +0 -1
package/dist/types.d.ts CHANGED
@@ -1,10 +1,8 @@
1
- import type { DecoratorNode, EditorConfig, LexicalEditor, EditorConfig as LexicalEditorConfig, LexicalNode, SerializedEditorState, SerializedLexicalNode } from 'lexical';
2
- import type { ClientField, DefaultServerCellComponentProps, LabelFunction, PayloadComponent, RichTextAdapter, RichTextField, RichTextFieldClient, RichTextFieldClientProps, SanitizedConfig, ServerFieldBase, StaticLabel } from 'payload';
3
- import type { JSXConverterArgs } from './features/converters/lexicalToJSX/converter/types.js';
1
+ import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical';
2
+ import type { ClientField, DefaultServerCellComponentProps, LabelFunction, RichTextAdapter, RichTextField, RichTextFieldClient, RichTextFieldClientProps, SanitizedConfig, ServerFieldBase, StaticLabel } from 'payload';
4
3
  import type { BaseClientFeatureProps, FeatureProviderProviderClient } from './features/typesClient.js';
5
4
  import type { FeatureProviderServer } from './features/typesServer.js';
6
5
  import type { SanitizedServerEditorConfig } from './lexical/config/types.js';
7
- import type { DefaultNodeTypes, SerializedBlockNode, SerializedInlineBlockNode } from './nodeTypes.js';
8
6
  import type { InitialLexicalFormState } from './utilities/buildInitialState.js';
9
7
  export type LexicalFieldAdminProps = {
10
8
  /**
@@ -58,156 +56,10 @@ export type FeaturesInput = (({ defaultFeatures, rootFeatures, }: {
58
56
  */
59
57
  rootFeatures: FeatureProviderServer<any, any, any>[];
60
58
  }) => FeatureProviderServer<any, any, any>[]) | FeatureProviderServer<any, any, any>[];
61
- type WithinEditorArgs = {
62
- config: EditorConfig;
63
- editor: LexicalEditor;
64
- node: LexicalNode;
65
- };
66
- /**
67
- *
68
- * @experimental - This API is experimental and may change in a minor release.
69
- * @internal
70
- */
71
- export type NodeMapValue<TNode extends {
72
- [key: string]: any;
73
- type?: string;
74
- } = SerializedLexicalNode> = {
75
- /**
76
- * Provide a react component to render the node.
77
- *
78
- * **JSX Converter:** Always works. Takes priority over `html`.
79
- *
80
- * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.
81
- */
82
- Component?: (args: ({
83
- isEditor: false;
84
- isJSXConverter: true;
85
- } & JSXConverterArgs<TNode>) | ({
86
- isEditor: true;
87
- isJSXConverter: false;
88
- node: {
89
- _originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode;
90
- } & DecoratorNode<React.ReactNode>;
91
- } & Omit<WithinEditorArgs, 'node'>)) => React.ReactNode;
92
- /**
93
- * Provide a function to create the DOM element for the node.
94
- *
95
- * **JSX Converter:** Not used (only `Component` and `html` work).
96
- *
97
- * **Lexical Editor:** Always works (renders in `createDOM` method).
98
- * - For ElementNodes: This is the standard way to customize rendering.
99
- * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.
100
- */
101
- createDOM?: (args: WithinEditorArgs) => HTMLElement;
102
- /**
103
- * Provide HTML string or function to render the node.
104
- *
105
- * **JSX Converter:** Always works (ignored if `Component` is provided).
106
- *
107
- * **Lexical Editor behavior depends on node type:**
108
- *
109
- * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.
110
- *
111
- * - **DecoratorNodes (have both `createDOM` and `decorate`):**
112
- * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`
113
- * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`
114
- * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content
115
- * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)
116
- */
117
- html?: (args: ({
118
- isEditor: false;
119
- isJSXConverter: true;
120
- } & JSXConverterArgs<TNode>) | ({
121
- isEditor: true;
122
- isJSXConverter: false;
123
- } & WithinEditorArgs)) => string;
124
- };
125
- /**
126
- * @experimental - This API is experimental and may change in a minor release.
127
- * @internal
128
- */
129
- export type LexicalEditorNodeMap<TNodes extends {
130
- [key: string]: any;
131
- type?: string;
132
- } = DefaultNodeTypes | SerializedBlockNode<{
133
- blockName?: null | string;
134
- blockType: string;
135
- }> | SerializedInlineBlockNode<{
136
- blockName?: null | string;
137
- blockType: string;
138
- }>> = {
139
- [key: string]: {
140
- [blockSlug: string]: NodeMapValue<any>;
141
- } | NodeMapValue<any> | undefined;
142
- } & {
143
- [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<Extract<TNodes, {
144
- type: nodeType;
145
- }>>;
146
- } & {
147
- blocks?: {
148
- [K in Extract<Extract<TNodes, {
149
- type: 'block';
150
- }> extends SerializedBlockNode<infer B> ? B extends {
151
- blockType: string;
152
- } ? B['blockType'] : never : never, string>]?: NodeMapValue<Extract<TNodes, {
153
- type: 'block';
154
- }> extends SerializedBlockNode<infer B> ? SerializedBlockNode<Extract<B, {
155
- blockType: K;
156
- }>> : SerializedBlockNode>;
157
- };
158
- inlineBlocks?: {
159
- [K in Extract<Extract<TNodes, {
160
- type: 'inlineBlock';
161
- }> extends SerializedInlineBlockNode<infer B> ? B extends {
162
- blockType: string;
163
- } ? B['blockType'] : never : never, string>]?: NodeMapValue<Extract<TNodes, {
164
- type: 'inlineBlock';
165
- }> extends SerializedInlineBlockNode<infer B> ? SerializedInlineBlockNode<Extract<B, {
166
- blockType: K;
167
- }>> : SerializedInlineBlockNode>;
168
- };
169
- unknown?: NodeMapValue<SerializedLexicalNode>;
170
- };
171
- /**
172
- * A map of views, which can be used to render the editor in different ways.
173
- *
174
- * In order to override the default view, you can add a `default` key to the map.
175
- *
176
- * @experimental - This API is experimental and may change in a minor release.
177
- * @internal
178
- */
179
- export type LexicalEditorViewMap<TNodes extends {
180
- [key: string]: any;
181
- type?: string;
182
- } = DefaultNodeTypes | SerializedBlockNode<{
183
- blockName?: null | string;
184
- blockType: string;
185
- }> | SerializedInlineBlockNode<{
186
- blockName?: null | string;
187
- blockType: string;
188
- }>> = {
189
- [viewKey: string]: {
190
- admin?: LexicalFieldAdminClientProps;
191
- lexical?: LexicalEditorConfig;
192
- nodes: LexicalEditorNodeMap<TNodes>;
193
- };
194
- };
195
- /**
196
- * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function
197
- */
198
59
  export type LexicalEditorProps = {
199
60
  admin?: LexicalFieldAdminProps;
200
61
  features?: FeaturesInput;
201
62
  lexical?: LexicalEditorConfig;
202
- /**
203
- * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.
204
- *
205
- * In order to override the default view, you can add a `default` key to the map.
206
- *
207
- * @experimental - This API is experimental and may change in a minor release.
208
- * @internal
209
- */
210
- views?: PayloadComponent;
211
63
  };
212
64
  export type LexicalRichTextAdapter = {
213
65
  editorConfig: SanitizedServerEditorConfig;
@@ -244,7 +96,6 @@ export type LexicalRichTextFieldProps = {
244
96
  featureClientSchemaMap: FeatureClientSchemaMap;
245
97
  initialLexicalFormState: InitialLexicalFormState;
246
98
  lexicalEditorConfig: LexicalEditorConfig | undefined;
247
- views?: LexicalEditorViewMap;
248
99
  } & Pick<ServerFieldBase, 'permissions'> & RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>;
249
100
  export type LexicalRichTextCellProps = DefaultServerCellComponentProps<RichTextFieldClient<SerializedEditorState, AdapterProps, object>, SerializedEditorState>;
250
101
  export type AdapterProps = {
@@ -255,5 +106,4 @@ export type GeneratedFeatureProviderComponent = {
255
106
  clientFeatureProps: BaseClientFeatureProps<object>;
256
107
  };
257
108
  export type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>;
258
- export {};
259
109
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,IAAI,mBAAmB,EACnC,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,WAAW,EACX,+BAA+B,EAC/B,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACZ,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uDAAuD,CAAA;AAC7F,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAC5E,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAE/E,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;OAEG;IACH,WAAW,CAAC,EAAE,aAAa,GAAG,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MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;YAChE,qBAAqB,CAAC,EAAE,6BAA6B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SAChE,CAAA;KACF,CAAA;IACD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,uBAAuB,EAAE,uBAAuB,CAAA;IAChD,mBAAmB,EAAE,mBAAmB,GAAG,SAAS,CAAA;CACrD,GAAG,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,GACtC,wBAAwB,CAAC,qBAAqB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA;AAEvE,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,CACpE,mBAAmB,CAAC,qBAAqB,EAAE,YAAY,EAAE,MAAM,CAAC,EAChE,qBAAqB,CACtB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,2BAA2B,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,aAAa,EAAE,6BAA6B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACtD,kBAAkB,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n DecoratorNode,\n EditorConfig,\n LexicalEditor,\n EditorConfig as LexicalEditorConfig,\n LexicalNode,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n PayloadComponent,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport type { JSXConverterArgs } from './features/converters/lexicalToJSX/converter/types.js'\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from './nodeTypes.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\ntype WithinEditorArgs = {\n config: EditorConfig\n editor: LexicalEditor\n node: LexicalNode\n}\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapValue<\n TNode extends { [key: string]: any; type?: string } = SerializedLexicalNode,\n> = {\n /**\n * Provide a react component to render the node.\n *\n * **JSX Converter:** Always works. Takes priority over `html`.\n *\n * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.\n */\n Component?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n node: {\n _originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode\n } & DecoratorNode<React.ReactNode>\n } & Omit<WithinEditorArgs, 'node'>),\n ) => React.ReactNode\n /**\n * Provide a function to create the DOM element for the node.\n *\n * **JSX Converter:** Not used (only `Component` and `html` work).\n *\n * **Lexical Editor:** Always works (renders in `createDOM` method).\n * - For ElementNodes: This is the standard way to customize rendering.\n * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.\n */\n createDOM?: (args: WithinEditorArgs) => HTMLElement\n /**\n * Provide HTML string or function to render the node.\n *\n * **JSX Converter:** Always works (ignored if `Component` is provided).\n *\n * **Lexical Editor behavior depends on node type:**\n *\n * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.\n *\n * - **DecoratorNodes (have both `createDOM` and `decorate`):**\n * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`\n * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`\n * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content\n * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)\n */\n html?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n } & WithinEditorArgs),\n ) => string\n}\n\n/**\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorNodeMap<\n TNodes extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: NodeMapValue<any>\n }\n | NodeMapValue<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<\n Extract<TNodes, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapValue<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? SerializedBlockNode<Extract<B, { blockType: K }>>\n : SerializedBlockNode\n >\n }\n inlineBlocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapValue<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? SerializedInlineBlockNode<Extract<B, { blockType: K }>>\n : SerializedInlineBlockNode\n >\n }\n unknown?: NodeMapValue<SerializedLexicalNode>\n}\n\n/**\n * A map of views, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorViewMap<\n TNodes extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [viewKey: string]: {\n admin?: LexicalFieldAdminClientProps\n lexical?: LexicalEditorConfig\n nodes: LexicalEditorNodeMap<TNodes>\n }\n}\n\n/**\n * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function\n */\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n /**\n * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\n views?: PayloadComponent\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n views?: LexicalEditorViewMap\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"mappings":"AAmUA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"mappings":"AAoJA","ignoreList":[]}
@@ -122,9 +122,7 @@ export const DrawerContent = ({
122
122
  fields: Array.isArray(fields) ? fields : [],
123
123
  forceRender: true,
124
124
  parentIndexPath: "",
125
- parentPath: "" // See Blocks feature path for details as for why this is empty
126
- ,
127
-
125
+ parentPath: "",
128
126
  parentSchemaPath: schemaFieldsPath,
129
127
  permissions: true,
130
128
  readOnly: !isEditable
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerContent.js","names":["useLexicalEditable","Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","isEditable","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","_jsxs","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","_jsx","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,kBAAkB,QAAQ;AACnC,SACEC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,e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W,MAAA,EAAQV,YAAA,CAAWU;IACrB;IAEA,IAAI,CAACR,OAAA,EAAO;MACV,OAAOW,aAAA;IACT;IAEA,OAAOX,OAAA;EACT,GACA,CACEJ,YAAA,EACAb,EAAA,EACAM,UAAA,EACAL,cAAA,EACAC,iBAAA,EACAG,oBAAA,EACAF,UAAA,EACAW,gBAAA,CACD;EAGH;EACA7B,SAAA,CAAU;IACR,OAAO;MACLJ,cAAA,CAAe0B,0BAAA,CAA2BsB,OAAO;IACnD;EACF,GAAG,EAAE;EAEL,IAAIpB,YAAA,KAAiB,OAAO;IAC1B,OAAO;EACT;EAEA,oBACEsB,KAAA,CAACzD,IAAA;IACC0D,YAAA,EAAc,CAACN,QAAA,CAAS;IACxBO,yBAAyB;IACzB7B,MAAA,EAAQ8B,KAAA,CAAMC,OAAO,CAAC/B,MAAA,IAAUA,MAAA,GAAS,EAAE;IAC3CK,YAAA,EAAcA,YAAA;IACdiB,QAAA,EAAU,CAACA,QAAA,CAAS;IACpBU,QAAA,EAAUzC,kBAAA;IACVN,IAAA,EAAMA,IAAA;4BAENgD,IAAA,CAAC7D,YAAA;MACC4B,MAAA,EAAQ8B,KAAA,CAAMC,OAAO,CAAC/B,MAAA,IAAUA,MAAA,GAAS,EAAE;MAC3CkC,WAAW;MACXC,eAAA,EAAgB;MAChBC,UAAA,EAAW,GAAG;MAAA;;MACdC,gBAAA,EAAkB3B,gBAAA;MAClB4B,WAAA,EAAa;MACbnB,QAAA,EAAU,CAACjB;qBAEb+B,IAAA,CAAC9D,UAAA;gBAAYwB,CAAA,CAAE;;;AAGrB","ignoreList":[]}
1
+ {"version":3,"file":"DrawerContent.js","names":["useLexicalEditable","Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","isEditable","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","_jsxs","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","_jsx","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,kBAAkB,QAAQ;AACnC,SACEC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,0CAA0C,QAAQ;AAC3D,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAChE,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,aAAA,GAAiFA,CAAC;EAC7FC,IAAI;EACJC,UAAU;EACVC,gBAAgB;EAChBC,kBAAkB;EAClBC,wBAAwB;EACxBC,UAAU;EACVC;AAAgB,CACjB;EACC,MAAM;IAAEC;EAAC,CAAE,GAAGnB,cAAA;EACd,MAAM;IAAEoB,EAAE;IAAEC,cAAc;IAAEC,iBAAiB;IAAEC;EAAU,CAAE,GAAGzB,eAAA;EAC9D,MAAM;IAAE0B,MAAA,EAAQC;EAAoB,CAAE,GAAG5B,eAAA;EACzC,MAAM6B,UAAA,GAAajC,kBAAA;EAEnB,MAAMkC,0BAAA,GAA6BrB,MAAA,CAAO,IAAIsB,eAAA;EAE9C,MAAM,CAACC,YAAA,EAAcC,eAAA,CAAgB,GAAGvB,QAAA,CAAwC;EAEhF,MAAM;IACJwB,UAAA,EAAY;MAAEC;IAAsB;EAAE,CACvC,GAAGtB,sBAAA;EAEJ,MAAM;IAAEuB;EAAY,CAAE,GAAGlC,kBA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AA,EAAa;MACbnB,QAAA,EAAU,CAACjB;qBAEb+B,IAAA,CAAC9D,UAAA;gBAAYwB,CAAA,CAAE;;;AAGrB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CAiDtC,CAAA"}
1
+ {"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CA+CtC,CAAA"}
@@ -9,7 +9,6 @@ export const getGenerateImportMap = args => ({
9
9
  addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell');
10
10
  addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField');
11
11
  addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent');
12
- addToImportMap(args.lexicalEditorArgs?.views);
13
12
  for (const resolvedFeature of args.resolvedFeatureMap.values()) {
14
13
  if ('componentImports' in resolvedFeature) {
15
14
  if (typeof resolvedFeature.componentImports === 'function') {
@@ -1 +1 @@
1
- {"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","lexicalEditorArgs","views","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n addToImportMap(args.lexicalEditorArgs?.views)\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields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AAA,EAAQD,SAAA;YACRhB,SAAA;YACAC;UACF;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\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7 @@ export function useRunDeprioritized(t0) {
59
59
  function interactionResponse() {
60
60
  // Taken from https://github.com/vercel-labs/await-interaction-response/tree/main/packages/await-interaction-response/src
61
61
  return new Promise(resolve => {
62
- setTimeout(resolve, 100) // Fallback for the case where the animation frame never fires.
63
- ;
62
+ setTimeout(resolve, 100); // Fallback for the case where the animation frame never fires.
64
63
  requestAnimationFrame(() => {
65
64
  setTimeout(resolve, 0);
66
65
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useRunDeprioritized.js","names":["c","_c","useCallback","useRef","useRunDeprioritized","t0","$","timeout","undefined","idleHandleRef","t1","fn","Promise","resolve","exec","window","current","cancelIdleCallback","requestIdleCallback","interactionResponse","then","runDeprioritized","setTimeout","requestAnimationFrame"],"sources":["../../src/utilities/useRunDeprioritized.ts"],"sourcesContent":["'use client'\nimport { useCallback, useRef } from 'react'\n\n/**\n * Simple hook that lets you run any callback once the main thread is idle\n * (via `requestIdleCallback`) or when that API is missing (Safari) - after the\n * next animation frame (`interactionResponse`).\n *\n * This will help you to avoid blocking the main thread with heavy work.\n *\n * The latest invocation wins: if a new run is queued before the previous one\n * executes, the previous task is cancelled.\n *\n * Usage:\n * ```ts\n * const runDeprioritized = useRunDeprioritized();\n *\n * const onEditorChange = (state: EditorState) => {\n * runDeprioritized(() => {\n * // heavy work here …\n * });\n * };\n * ```\n *\n * @param timeout Optional timeout (ms) for `requestIdleCallback`; defaults to 500 ms.\n * @returns A `runDeprioritized(fn)` helper.\n */\n\nexport function useRunDeprioritized(timeout = 500) {\n const idleHandleRef = useRef<number>(undefined)\n\n /**\n * Schedule `fn` and resolve when it has executed.\n */\n const runDeprioritized = useCallback(\n (fn: () => void): Promise<void> => {\n return new Promise<void>((resolve) => {\n const exec = () => {\n fn()\n resolve()\n }\n\n if ('requestIdleCallback' in window) {\n // Cancel any previously queued task so only the latest runs.\n if ('cancelIdleCallback' in window && idleHandleRef.current !== undefined) {\n // Cancel earlier scheduled value updates,\n // so that a CPU-limited event loop isn't flooded with n callbacks for n keystrokes into the rich text field,\n // but that there's only ever the latest one state update\n // dispatch task, to be executed with the next idle time,\n // or the deadline of 500ms.\n cancelIdleCallback(idleHandleRef.current)\n }\n // Schedule the state update to happen the next time the browser has sufficient resources,\n // or the latest after 500ms.\n idleHandleRef.current = requestIdleCallback(exec, { timeout })\n } else {\n // Safari fallback: rAF + setTimeout shim.\n void interactionResponse().then(exec)\n }\n })\n },\n [timeout],\n )\n\n return runDeprioritized\n}\n\nfunction interactionResponse(): Promise<unknown> {\n // Taken from https://github.com/vercel-labs/await-interaction-response/tree/main/packages/await-interaction-response/src\n\n return new Promise((resolve) => {\n setTimeout(resolve, 100) // Fallback for the case where the animation frame never fires.\n requestAnimationFrame(() => {\n setTimeout(resolve, 0)\n })\n })\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,WAAW,EAAEC,MAAM,QAAQ;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,SAAAC,oBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAA6B,MAAAM,OAAA,GAAAF,EAAa,KAAAG,SAAA,SAAbH,EAAa;EAC/C,MAAAI,aAAA,GAAsBN,MAAA,CAAAK,SAAe;EAAA,IAAAE,EAAA;EAAA,IAAAJ,CAAA,QAAAC,OAAA;IAMnCG,EAAA,GAAAC,EAAA,QAAAC,OAAA,CAAAC,OAAA;MAEI,MAAAC,IAAA,GAAAA,CAAA;QACEH,EAAA;QACAE,OAAA;MAAA;MACF,IAEI,yBAAAE,MAAyB;QAAA,IAEvB,wBAAAA,MAAwB,IAAUN,aAAA,CAAAO,OAAA,KAAAR,SAA0B;UAM9DS,kBAAA,CAAmBR,aAAA,CAAAO,OAAqB;QAAA;QAI1CP,aAAA,CAAAO,OAAA,GAAwBE,mBAAA,CAAoBJ,IAAA;UAAAP;QAAA,CAAgB;MAAA;QAGvDY,mBAAA,GAAAC,IAAA,CAA2BN,IAAA;MAAA;IAAA;IAGtCR,CAAA,MAAAC,OAAA;IAAAD,CAAA,MAAAI,EAAA;EAAA;IAAAA,EAAA,GAAAJ,CAAA;EAAA;EA1BF,MAAAe,gBAAA,GAAyBX,EA2Bd;EAAA,OAGJW,gBAAA;AAAA;AAGT,SAASF,oBAAA;EACP;EAEA,OAAO,IAAIP,OAAA,CAASC,OAAA;IAClBS,UAAA,CAAWT,OAAA,EAAS,KAAK;IAAA;IACzBU,qBAAA,CAAsB;MACpBD,UAAA,CAAWT,OAAA,EAAS;IACtB;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"useRunDeprioritized.js","names":["c","_c","useCallback","useRef","useRunDeprioritized","t0","$","timeout","undefined","idleHandleRef","t1","fn","Promise","resolve","exec","window","current","cancelIdleCallback","requestIdleCallback","interactionResponse","then","runDeprioritized","setTimeout","requestAnimationFrame"],"sources":["../../src/utilities/useRunDeprioritized.ts"],"sourcesContent":["'use client'\nimport { useCallback, useRef } from 'react'\n\n/**\n * Simple hook that lets you run any callback once the main thread is idle\n * (via `requestIdleCallback`) or when that API is missing (Safari) - after the\n * next animation frame (`interactionResponse`).\n *\n * This will help you to avoid blocking the main thread with heavy work.\n *\n * The latest invocation wins: if a new run is queued before the previous one\n * executes, the previous task is cancelled.\n *\n * Usage:\n * ```ts\n * const runDeprioritized = useRunDeprioritized();\n *\n * const onEditorChange = (state: EditorState) => {\n * runDeprioritized(() => {\n * // heavy work here …\n * });\n * };\n * ```\n *\n * @param timeout Optional timeout (ms) for `requestIdleCallback`; defaults to 500 ms.\n * @returns A `runDeprioritized(fn)` helper.\n */\n\nexport function useRunDeprioritized(timeout = 500) {\n const idleHandleRef = useRef<number>(undefined)\n\n /**\n * Schedule `fn` and resolve when it has executed.\n */\n const runDeprioritized = useCallback(\n (fn: () => void): Promise<void> => {\n return new Promise<void>((resolve) => {\n const exec = () => {\n fn()\n resolve()\n }\n\n if ('requestIdleCallback' in window) {\n // Cancel any previously queued task so only the latest runs.\n if ('cancelIdleCallback' in window && idleHandleRef.current !== undefined) {\n // Cancel earlier scheduled value updates,\n // so that a CPU-limited event loop isn't flooded with n callbacks for n keystrokes into the rich text field,\n // but that there's only ever the latest one state update\n // dispatch task, to be executed with the next idle time,\n // or the deadline of 500ms.\n cancelIdleCallback(idleHandleRef.current)\n }\n // Schedule the state update to happen the next time the browser has sufficient resources,\n // or the latest after 500ms.\n idleHandleRef.current = requestIdleCallback(exec, { timeout })\n } else {\n // Safari fallback: rAF + setTimeout shim.\n void interactionResponse().then(exec)\n }\n })\n },\n [timeout],\n )\n\n return runDeprioritized\n}\n\nfunction interactionResponse(): Promise<unknown> {\n // Taken from https://github.com/vercel-labs/await-interaction-response/tree/main/packages/await-interaction-response/src\n\n return new Promise((resolve) => {\n setTimeout(resolve, 100) // Fallback for the case where the animation frame never fires.\n requestAnimationFrame(() => {\n setTimeout(resolve, 0)\n })\n })\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,WAAW,EAAEC,MAAM,QAAQ;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,SAAAC,oBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAA6B,MAAAM,OAAA,GAAAF,EAAa,KAAAG,SAAA,SAAbH,EAAa;EAC/C,MAAAI,aAAA,GAAsBN,MAAA,CAAAK,SAAe;EAAA,IAAAE,EAAA;EAAA,IAAAJ,CAAA,QAAAC,OAAA;IAMnCG,EAAA,GAAAC,EAAA,QAAAC,OAAA,CAAAC,OAAA;MAEI,MAAAC,IAAA,GAAAA,CAAA;QACEH,EAAA;QACAE,OAAA;MAAA;MACF,IAEI,yBAAAE,MAAyB;QAAA,IAEvB,wBAAAA,MAAwB,IAAUN,aAAA,CAAAO,OAAA,KAAAR,SAA0B;UAM9DS,kBAAA,CAAmBR,aAAA,CAAAO,OAAqB;QAAA;QAI1CP,aAAA,CAAAO,OAAA,GAAwBE,mBAAA,CAAoBJ,IAAA;UAAAP;QAAA,CAAgB;MAAA;QAGvDY,mBAAA,GAAAC,IAAA,CAA2BN,IAAA;MAAA;IAAA;IAGtCR,CAAA,MAAAC,OAAA;IAAAD,CAAA,MAAAI,EAAA;EAAA;IAAAA,EAAA,GAAAJ,CAAA;EAAA;EA1BF,MAAAe,gBAAA,GAAyBX,EA2Bd;EAAA,OAGJW,gBAAA;AAAA;AAGT,SAASF,oBAAA;EACP;EAEA,OAAO,IAAIP,OAAA,CAASC,OAAA;IAClBS,UAAA,CAAWT,OAAA,EAAS,MAAK;IACzBU,qBAAA,CAAsB;MACpBD,UAAA,CAAWT,OAAA,EAAS;IACtB;EACF;AACF","ignoreList":[]}
@@ -1,8 +1,3 @@
1
1
  import type { SerializedEditorState, SerializedLexicalNode } from 'lexical';
2
- /**
3
- * This function checks if the editor state is empty (has any text). If the editor state has no nodes,
4
- * or only an empty paragraph node (no TextNode with length > 0), it returns false.
5
- * Otherwise, it returns true.
6
- */
7
- export declare function hasText(value: null | SerializedEditorState<SerializedLexicalNode> | undefined): value is SerializedEditorState<SerializedLexicalNode>;
2
+ export declare function hasText(value: null | SerializedEditorState<SerializedLexicalNode> | undefined): boolean;
8
3
  //# sourceMappingURL=hasText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,SAAS,GACrE,KAAK,IAAI,qBAAqB,CAAC,qBAAqB,CAAC,CA6BvD"}
1
+ {"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,SAAS,GACrE,OAAO,CA0BT"}
@@ -1,12 +1,5 @@
1
- /**
2
- * This function checks if the editor state is empty (has any text). If the editor state has no nodes,
3
- * or only an empty paragraph node (no TextNode with length > 0), it returns false.
4
- * Otherwise, it returns true.
5
- */export function hasText(value) {
1
+ export function hasText(value) {
6
2
  const hasChildren = !!value?.root?.children?.length;
7
- if (!hasChildren) {
8
- return false;
9
- }
10
3
  let hasOnlyEmptyParagraph = false;
11
4
  if (value?.root?.children?.length === 1) {
12
5
  if (value?.root?.children[0]?.type === 'paragraph') {
@@ -23,9 +16,10 @@
23
16
  }
24
17
  }
25
18
  }
26
- if (hasOnlyEmptyParagraph) {
19
+ if (!hasChildren || hasOnlyEmptyParagraph) {
27
20
  return false;
21
+ } else {
22
+ return true;
28
23
  }
29
- return true;
30
24
  }
31
25
  //# sourceMappingURL=hasText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hasText.js","names":["hasText","value","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild"],"sources":["../../src/validate/hasText.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\n/**\n * This function checks if the editor state is empty (has any text). If the editor state has no nodes,\n * or only an empty paragraph node (no TextNode with length > 0), it returns false.\n * Otherwise, it returns true.\n */\nexport function hasText(\n value: null | SerializedEditorState<SerializedLexicalNode> | undefined,\n): value is SerializedEditorState<SerializedLexicalNode> {\n const hasChildren = !!value?.root?.children?.length\n if (!hasChildren) {\n return false\n }\n\n let hasOnlyEmptyParagraph = false\n if (value?.root?.children?.length === 1) {\n if (value?.root?.children[0]?.type === 'paragraph') {\n const paragraphNode = value?.root?.children[0] as SerializedParagraphNode\n\n if (!paragraphNode?.children || paragraphNode?.children?.length === 0) {\n hasOnlyEmptyParagraph = true\n } else if (paragraphNode?.children?.length === 1) {\n const paragraphNodeChild = paragraphNode?.children[0]\n if (paragraphNodeChild?.type === 'text') {\n if (!(paragraphNodeChild as SerializedTextNode | undefined)?.['text']?.length) {\n hasOnlyEmptyParagraph = true\n }\n }\n }\n }\n }\n\n if (hasOnlyEmptyParagraph) {\n return false\n }\n\n return true\n}\n"],"mappings":"AAOA;;;;GAKA,OAAO,SAASA,QACdC,KAAsE;EAEtE,MAAMC,WAAA,GAAc,CAAC,CAACD,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA;EAC7C,IAAI,CAACH,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAII,qBAAA,GAAwB;EAC5B,IAAIL,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA,KAAW,GAAG;IACvC,IAAIJ,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE,EAAEG,IAAA,KAAS,aAAa;MAClD,MAAMC,aAAA,GAAgBP,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE;MAE9C,IAAI,CAACI,aAAA,EAAeJ,QAAA,IAAYI,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QACrEC,qBAAA,GAAwB;MAC1B,OAAO,IAAIE,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QAChD,MAAMI,kBAAA,GAAqBD,aAAA,EAAeJ,QAAQ,CAAC,EAAE;QACrD,IAAIK,kBAAA,EAAoBF,IAAA,KAAS,QAAQ;UACvC,IAAI,CAAEE,kBAAA,GAAwD,OAAO,EAAEJ,MAAA,EAAQ;YAC7EC,qBAAA,GAAwB;UAC1B;QACF;MACF;IACF;EACF;EAEA,IAAIA,qBAAA,EAAuB;IACzB,OAAO;EACT;EAEA,OAAO;AACT","ignoreList":[]}
1
+ {"version":3,"file":"hasText.js","names":["hasText","value","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild"],"sources":["../../src/validate/hasText.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\nexport function hasText(\n value: null | SerializedEditorState<SerializedLexicalNode> | undefined,\n): boolean {\n const hasChildren = !!value?.root?.children?.length\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 (!hasChildren || hasOnlyEmptyParagraph) {\n return false\n } else {\n return true\n }\n}\n"],"mappings":"AAOA,OAAO,SAASA,QACdC,KAAsE;EAEtE,MAAMC,WAAA,GAAc,CAAC,CAACD,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA;EAE7C,IAAIC,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,IAAI,CAACJ,WAAA,IAAeI,qBAAA,EAAuB;IACzC,OAAO;EACT,OAAO;IACL,OAAO;EACT;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.67.0-internal.87c53da",
3
+ "version": "3.68.0-canary.0",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -33,11 +33,6 @@
33
33
  "types": "./dist/exports/client/index.d.ts",
34
34
  "default": "./dist/exports/client/index.js"
35
35
  },
36
- "./internal-client": {
37
- "import": "./dist/exports/client/internal-client.js",
38
- "types": "./dist/exports/client/internal-client.d.ts",
39
- "default": "./dist/exports/client/internal-client.js"
40
- },
41
36
  "./react": {
42
37
  "import": "./dist/exports/react/index.js",
43
38
  "types": "./dist/exports/react/index.d.ts",
@@ -379,8 +374,8 @@
379
374
  "react-error-boundary": "4.1.2",
380
375
  "ts-essentials": "10.0.3",
381
376
  "uuid": "10.0.0",
382
- "@payloadcms/translations": "3.67.0-internal.87c53da",
383
- "@payloadcms/ui": "3.67.0-internal.87c53da"
377
+ "@payloadcms/translations": "3.68.0-canary.0",
378
+ "@payloadcms/ui": "3.68.0-canary.0"
384
379
  },
385
380
  "devDependencies": {
386
381
  "@babel/cli": "7.27.2",
@@ -398,17 +393,17 @@
398
393
  "babel-plugin-transform-remove-imports": "^1.8.0",
399
394
  "esbuild": "0.25.5",
400
395
  "esbuild-sass-plugin": "3.3.1",
401
- "swc-plugin-transform-remove-imports": "4.0.4",
396
+ "swc-plugin-transform-remove-imports": "8.3.0",
402
397
  "@payloadcms/eslint-config": "3.28.0",
403
- "payload": "3.67.0-internal.87c53da"
398
+ "payload": "3.68.0-canary.0"
404
399
  },
405
400
  "peerDependencies": {
406
401
  "@faceless-ui/modal": "3.0.0",
407
402
  "@faceless-ui/scroll-info": "2.0.0",
408
403
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
409
404
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
410
- "@payloadcms/next": "3.67.0-internal.87c53da",
411
- "payload": "3.67.0-internal.87c53da"
405
+ "@payloadcms/next": "3.68.0-canary.0",
406
+ "payload": "3.68.0-canary.0"
412
407
  },
413
408
  "engines": {
414
409
  "node": "^18.20.2 || >=20.9.0"
@@ -421,10 +416,12 @@
421
416
  "build:babel": "rm -rf dist_optimized && babel dist --out-dir dist_optimized --source-maps --extensions .ts,.js,.tsx,.jsx,.cjs,.mjs && rm -rf dist && mv dist_optimized dist",
422
417
  "build:bundle-for-analysis": "rm -rf dist esbuild && rm -rf tsconfig.tsbuildinfo && pnpm build:swc && pnpm build:babel && pnpm copyfiles && pnpm build:esbuild esbuild --no-split",
423
418
  "build:clean": "find . \\( -type d \\( -name build -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} + && pnpm build",
419
+ "build:debug": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm build:swc:debug && pnpm copyfiles && pnpm build:types",
424
420
  "build:esbuild": "node bundle.js",
425
421
  "build:esbuild:postprocess": "rm -rf dist/exports/client && mv dist/exports/client_optimized dist/exports/client",
426
422
  "build:reactcompiler": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm build:swc && pnpm build:babel && pnpm copyfiles && pnpm build:esbuild && pnpm build:esbuild:postprocess && pnpm build:types",
427
423
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
424
+ "build:swc:debug": "swc ./src -d ./dist --config-file .swcrc-debug --strip-leading-paths",
428
425
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
429
426
  "build:without_reactcompiler": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm copyfiles && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm build:esbuild:postproces && rm -rf dist/exports/client && mv dist/exports/client_unoptimized dist/exports/client",
430
427
  "clean": "rimraf -g {dist,*.tsbuildinfo,esbuild}",
@@ -1,2 +0,0 @@
1
- "use client";import{a as De,e as Le,g as z,h as F,j as Me,k as Ae,l as Oe,m as Be,n as Ee,o as Ce,p as Ie}from"./chunk-6NIGQP6A.js";import{a as _e,b as P}from"./chunk-BZZVLW4U.js";import{jsx as D,jsxs as ie}from"react/jsx-runtime";import{BulkUploadProvider as Jn,FieldDescription as qn,FieldError as Qn,FieldLabel as Xn,RenderCustomComponent as _t,useEditDepth as Zn,useEffectEvent as er,useField as tr}from"@payloadcms/ui";import{mergeFieldStyles as or}from"@payloadcms/ui/shared";import{dequal as nr}from"dequal/lite";import Dt,{useCallback as Lt,useEffect as Mt,useMemo as rr,useState as At}from"react";import{ErrorBoundary as ir}from"react-error-boundary";import"./bundled.css";import{jsx as $}from"react/jsx-runtime";import{LexicalComposer as Kn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as jn}from"@payloadcms/ui";import*as Pt from"react";import{useMemo as Hn}from"react";import{c as Sn}from"react/compiler-runtime";import{jsx as b,jsxs as ne}from"react/jsx-runtime";import{useLexicalComposerContext as Pn}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Rn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as kn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as vn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Tn}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as _n}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as Dn,COMMAND_PRIORITY_LOW as wt,FOCUS_COMMAND as Ln}from"lexical";import*as q from"react";import{useEffect as Mn,useState as An}from"react";import{jsx as Fe}from"react/jsx-runtime";import"react";var K=({anchorElem:e,clientProps:t,plugin:o})=>o.position==="floatingAnchorElem"&&e?o.Component&&Fe(o.Component,{anchorElem:e,clientProps:t}):o.Component&&Fe(o.Component,{clientProps:t});import{c as It}from"react/compiler-runtime";import{copyToClipboard as $e}from"@lexical/clipboard";import{useLexicalComposerContext as Ft}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as $t}from"@lexical/utils";import Ke from"bson-objectid";import{$getSelection as Kt,$isNodeSelection as jt,COMMAND_PRIORITY_LOW as Ht,COPY_COMMAND as Vt}from"lexical";import{useEffect as zt}from"react";var Ne=e=>{if("fields"in e&&typeof e.fields=="object"&&e.fields!==null&&"id"in e.fields?e.fields.id=new Ke.default().toHexString():"id"in e&&(e.id=new Ke.default().toHexString()),e.children)for(let t of e.children)Ne(t)};function je(){let e=It(3),[t]=Ft(),o,n;return e[0]!==t?(o=()=>t.registerCommand(Vt,r=>{let c=Kt();if(jt(c)){let s=c.getNodes()[0]?.exportJSON(),u=JSON.parse(JSON.stringify(s));Ne(u);let d={namespace:t._config.namespace,nodes:[u]},y=JSON.stringify(d);return $e(t,null,{"application/x-lexical-editor":y,"text/plain":""}).catch(Wt),!0}return $e(t,$t(r,ClipboardEvent)?r:null).then(()=>{if(!(r instanceof ClipboardEvent)||!r.clipboardData)throw new Error("No clipboard event");let i=r.clipboardData.getData("application/x-lexical-editor");if(!i)return!0;let s=JSON.parse(i);for(let d of s.nodes)Ne(d);let u=JSON.stringify(s);r.clipboardData.setData("application/x-lexical-editor",u)}).catch(i=>{throw r instanceof ClipboardEvent&&r.clipboardData?.setData("application/x-lexical-editor",""),i}),!0},Ht),n=[t],e[0]=t,e[1]=o,e[2]=n):(o=e[1],n=e[2]),zt(o,n),null}function Wt(e){throw e}import{c as Yt}from"react/compiler-runtime";import{useLexicalComposerContext as Gt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as le,mergeRegister as Ut}from"@lexical/utils";import{$createNodeSelection as Jt,$getEditor as ee,$getNearestNodeFromDOMNode as qt,$getSelection as ae,$isDecoratorNode as j,$isElementNode as we,$isLineBreakNode as Qt,$isNodeSelection as ce,$isRangeSelection as He,$isRootOrShadowRoot as Xt,$isTextNode as Zt,$setSelection as Ve,CLICK_COMMAND as eo,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as to,KEY_ARROW_UP_COMMAND as oo,KEY_BACKSPACE_COMMAND as no,KEY_DELETE_COMMAND as ro,SELECTION_CHANGE_COMMAND as io}from"lexical";import{useEffect as so}from"react";function ze(){let e=Yt(3),[t]=Gt(),o=po,n,r;return e[0]!==t?(n=()=>Ut(t.registerCommand(eo,fo,W),t.registerCommand(ro,o,W),t.registerCommand(no,o,W),t.registerCommand(io,mo,W),t.registerCommand(oo,co,W),t.registerCommand(to,lo,W)),r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),so(n,r),null}function lo(e){let t=ae();if(ce(t)){e.preventDefault();let i=t.getNodes()[0]?.getNextSibling();if(j(i)){let d=ee().getElementByKey(i.getKey());return d&&te({element:d,node:i}),!0}if(!we(i))return!0;let s=i.getFirstDescendant()??i;return s&&(le(s,ue)?.selectEnd(),e.preventDefault()),!0}if(!He(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=le(n,ao),c=r?.getNextSibling();if(!r||c!==We(r))return!1;if(j(c)){let i=ee().getElementByKey(c.getKey());if(i)return te({element:i,node:c}),e.preventDefault(),!0}return!1}function ao(e){return We(e)!==null}function co(e){let t=ae();if(ce(t)){let i=t.getNodes()[0]?.getPreviousSibling();if(j(i)){let d=ee().getElementByKey(i.getKey());return d?(te({element:d,node:i}),e.preventDefault(),!0):!1}if(!we(i))return!1;let s=i.getLastDescendant()??i;return s?(le(s,ue)?.selectStart(),e.preventDefault(),!0):!1}if(!He(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=le(n,uo),c=r?.getPreviousSibling();if(!r||c!==Ye(r))return!1;if(j(c)){let i=ee().getElementByKey(c.getKey());if(i)return te({element:i,node:c}),e.preventDefault(),!0}return!1}function uo(e){return Ye(e)!==null}function mo(){let e=yo();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),e?(e.element?.classList.add("decorator-selected"),!0):!1}function fo(e){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let t=ho(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"]')?Ve(null):te(t),!0}function po(e){let t=ae();return ce(t)?(e.preventDefault(),t.getNodes().forEach(go),!0):!1}function go(e){e.remove()}function ho(e){if(!(e.target instanceof HTMLElement))return;let t=e.target.closest('[data-lexical-decorator="true"]');if(!(t instanceof HTMLElement))return;let o=qt(t);return j(o)?{element:t,node:o}:void 0}function yo(){let e=ae();if(!ce(e))return;let t=e.getNodes();if(t.length!==1)return;let o=t[0];return j(o)?{decorator:o,element:ee().getElementByKey(o.getKey())}:void 0}function te({element:e,node:t}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Jt();o.add(t.getKey()),Ve(o),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.classList.add("decorator-selected")}function ue(e){if(j(e)&&!e.isInline())return!0;if(!we(e)||Xt(e))return!1;let t=e.getFirstChild(),o=t===null||Qt(t)||Zt(t)||t.isInline();return!e.isInline()&&e.canBeEmpty()!==!1&&o}function We(e){let t=e.getNextSibling();for(;t!==null;){if(ue(t))return t;t=t.getNextSibling()}return null}function Ye(e){let t=e.getPreviousSibling();for(;t!==null;){if(ue(t))return t;t=t.getPreviousSibling()}return null}import{jsx as Se}from"react/jsx-runtime";import{useLexicalComposerContext as wo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as So,isHTMLElement as Po}from"lexical";import*as qe from"react";import{useCallback as Ro,useEffect as Je,useRef as ko,useState as vo}from"react";import{createPortal as To}from"react-dom";var Y=(e,t,o,n,r=50,c=25)=>{let i=0;if(e&&!e.contains(n)){let{bottom:s,left:u,right:d,top:y}=e.getBoundingClientRect(),a=y+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||t<u-r||t>d+r)return-1;(t<u||t>d)&&(i=t<u?t-u:t-d)}return i};import{$getNodeByKey as me}from"lexical";function G(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 de(e){let t=(u,d)=>u?parseFloat(window.getComputedStyle(u)[d]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(e),r=t(e.previousElementSibling,"marginBottom"),c=t(e.nextElementSibling,"marginTop"),i=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as xo}from"lexical";function H(e){return e.getEditorState().read(()=>xo().getChildrenKeys())}var bo=1,Eo=-1,Ge=0,A={props:null,result:null};function Co(e,t,o=20){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=o*o}function U(e){let{anchorElem:t,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:c=0,point:{x:i,y:s},startIndex:u=0,useEdgeAsDefault:d=!1}=e;if(o>0&&A.props&&A.result&&A.props.fuzzy===e.fuzzy&&A.props.horizontalOffset===e.horizontalOffset&&A.props.useEdgeAsDefault===e.useEdgeAsDefault&&Co(A.props.point,e.point,o))return A.result;let y=t.getBoundingClientRect(),a=H(n),l={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(d){let g=n.getElementByKey(a[0]),f=n.getElementByKey(a[a.length-1]);if(g&&f){let[h,p]=[G(g),G(f)];if(s<h.top?(l.blockElem=g,l.distance=h.top-s,l.blockNode=me(a[0]),l.foundAtIndex=0):s>p.bottom&&(l.distance=s-p.bottom,l.blockNode=me(a[a.length-1]),l.blockElem=f,l.foundAtIndex=a.length-1),l?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let m=u,x=Ge;for(;m>=0&&m<a.length;){let g=a[m],f=n.getElementByKey(g);if(f===null)break;let h=new F(i+c,s),p=Be.fromDOMRect(G(f)),{marginBottom:E,marginTop:k}=de(f),S=p.generateNewRect({bottom:p.bottom+E,left:y.left,right:y.right,top:p.top-k}),{distance:C,isOnBottomSide:R,isOnTopSide:N}=S.distanceFromPoint(h);if(C===0){l.blockElem=f,l.blockNode=me(g),l.foundAtIndex=m,l.distance=C,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!r&&!e.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else r&&C<l.distance&&(l.blockElem=f,l.blockNode=me(g),l.distance=C,l.foundAtIndex=m);x===Ge&&(N?x=Eo:R?x=bo:x=1/0),m+=x}}),A.props=e,A.result={blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph},{blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph}}function fe(e,t){return!!e.closest(`.${t}`)}var No=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ue(e){if(!e||No.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 pe(e,t,o,n=0){if(!e){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}let r=e.getBoundingClientRect(),c=window.getComputedStyle(e),i=t.getBoundingClientRect(),s=o.getBoundingClientRect(),u;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(a=>e.classList.contains(a)||e.firstElementChild?.classList.contains(a)))u=r.top+8-s.top;else{let a=Ue(e)?parseInt(c.lineHeight,10):0;u=r.top+(a-i.height)/2-s.top}let y=n;t.style.opacity="1",t.style.transform=`translate(${y}px, ${u}px)`}var _o="add-block-menu",ge=1/0;function Do(e){return e===0?1/0:ge>=0&&ge<e?ge:Math.floor(e/2)}function Lo(e,t,o){let n=t.parentElement,{editorConfig:r}=P(),c=r?.admin?.hideGutter?-24:12,i=ko(null),[s,u]=vo(null);Je(()=>{function y(a){let l=a.target;if(!Po(l))return;let m=Y(n,a.pageX,a.pageY,l);if(m===-1){u(null);return}if(fe(l,_o))return;let x=H(e),{blockElem:g,blockNode:f,foundAtIndex:h}=U({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-m,point:new F(a.x,a.y),returnEmptyParagraphs:!0,startIndex:Do(x.length),useEdgeAsDefault:!1});ge=h,g&&f&&(s?.node!==f||s?.elem!==g)&&u({elem:g,node:f})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[n,t,e,s]),Je(()=>{i.current&&s?.node&&pe(s?.elem,i.current,t,c)},[t,s,c]);let d=Ro(y=>{let a=s;a?.node&&(e.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let m=So();a?.node.insertAfter(m),setTimeout(()=>{a={elem:e.getElementByKey(m.getKey()),node:m},u(a)},0)}}),setTimeout(()=>{e.update(()=>{e.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{e.dispatchCommand(Ae,{node:a?.node})},2),y.stopPropagation(),y.preventDefault())},[e,s]);return To(Se(qe.Fragment,{children:Se("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{d(y)},ref:i,type:"button",children:Se("div",{className:o?"icon":""})})}),t)}function Qe(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=wo();return Lo(n,o,n._editable)}import{jsx as he,jsxs as Ao}from"react/jsx-runtime";import{useLexicalComposerContext as Oo}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as et}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as tt,$getNodeByKey as Bo,isHTMLElement as Pe}from"lexical";import*as st from"react";import{useEffect as Re,useRef as ye,useState as ot}from"react";import{createPortal as Io}from"react-dom";var Xe=0,Mo=-24;var V=0;function Ze(e,t,o,n,r,c,i,s,u,d=!1){let{height:y,top:a}=n.getBoundingClientRect(),{top:l,width:m}=i.getBoundingClientRect(),{marginBottom:x,marginTop:g}=de(n),f=a,h=c>=a+y/2+window.scrollY,p=!1;if(r?.elem)if(n!==r?.elem)(h&&r?.elem&&r?.elem===n.nextElementSibling||!h&&r?.elem&&r?.elem===n.previousElementSibling)&&(V++,V<200&&(p=!0));else{V++;let C=r?.boundingBox?.y,R=n.getBoundingClientRect().y;(h===r?.isBelow&&C===R||V<200)&&(p=!1)}if(p)return{isBelow:h,willStayInSamePosition:p};d?f+=y/2:h?f+=y+x/2:f-=g/2;let E=0;d||(h?E=-Xe:E=Xe);let k=f-l+E,S=Mo-t;return o.style.width=`calc(${m}px - ${e})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${k}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?h?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),V=0,{isBelow:h,willStayInSamePosition:p}}var Fo="draggable-block-menu",nt="application/x-lexical-drag-block",oe=1/0;function rt(e){return e===0?1/0:oe>=0&&oe<e?oe:Math.floor(e/2)}function $o(e,t){let{transform:o}=t.style;e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function it(e,t){e&&(e.style.opacity="0"),t&&(t.style.opacity="",t.style.marginBottom="",t.style.marginTop="")}function Ko(e,t,o){let n=t.parentElement,r=ye(null),c=ye(null),i=ye(null),s=ye(!1),[u,d]=ot(null),[y,a]=ot(null),{editorConfig:l}=P(),m=l?.admin?.hideGutter?-44:-8;Re(()=>{function f(h){let p=h.target;if(!Pe(p))return;let E=Y(n,h.pageX,h.pageY,p);if(E===-1){d(null);return}if(fe(p,Fo))return;let k=H(e),{blockElem:S,foundAtIndex:C,isFoundNodeEmptyParagraph:R}=U({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-E,point:new F(h.x,h.y),startIndex:rt(k.length),useEdgeAsDefault:!1,verbose:!1});oe=C,!(!S&&!R)&&u!==S&&d(S)}return document?.addEventListener("mousemove",f),()=>{document?.removeEventListener("mousemove",f)}},[n,t,e,u]),Re(()=>{r.current&&pe(u,r.current,t,m)},[t,u,m]),Re(()=>{function f(p){if(!s.current)return!1;let[E]=et(p);if(E)return!1;let{pageY:k,target:S}=p;if(!Pe(S))return!1;let C=Y(n,p.pageX,p.pageY,S,100,50),R=H(e),{blockElem:N,foundAtIndex:L,isFoundNodeEmptyParagraph:B}=U({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-C,point:new F(p.x,p.y),startIndex:rt(R.length),useEdgeAsDefault:!0,verbose:!0});oe=L;let v=c.current;if(N===null||v===null)return!1;if(u!==N){let{isBelow:T,willStayInSamePosition:X}=Ze(l?.admin?.hideGutter?"0px":"3rem",m+(l?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),v,N,y,k,t,p,i,B);p.preventDefault(),X||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:T})}else y?.elem&&(it(v,y.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function h(p){if(!s.current)return!1;let[E]=et(p);if(E)return!1;let{dataTransfer:k,pageY:S,target:C}=p,R=k?.getData(nt)||"";return e.update(()=>{let N=Bo(R);if(!N||!Pe(C))return!1;let L=Y(n,p.pageX,p.pageY,C,100,50),{blockElem:B,isFoundNodeEmptyParagraph:v}=U({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-L,point:new F(p.x,p.y),useEdgeAsDefault:!0});if(!B)return!1;let T=tt(B);if(!T)return!1;if(T===N)return!0;let{height:X,top:xe}=G(B),I=S>=xe+X/2+window.scrollY;v?(T.insertBefore(N),T.remove()):I?T.insertAfter(N):T.insertBefore(N),u!==null&&d(null),document.querySelectorAll(".lexical-block-highlighter").forEach(_=>{_.remove()});let se=e.getElementByKey(N.getKey());setTimeout(()=>{let _=se?.getBoundingClientRect();if(!_)return;let w=document.createElement("div");w.className="lexical-block-highlighter",w.style.backgroundColor="var(--theme-elevation-1000",w.style.transition="opacity 0.5s ease-in-out",w.style.zIndex="1",w.style.pointerEvents="none",w.style.boxSizing="border-box",w.style.borderRadius="4px",w.style.position="absolute",document.body.appendChild(w),w.style.opacity="0.1",w.style.height=`${_.height+8}px`,w.style.width=`${_.width+8}px`,w.style.top=`${_.top+window.scrollY-4}px`,w.style.left=`${_.left-4}px`,setTimeout(()=>{w.style.opacity="0",setTimeout(()=>{w.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",f),document.addEventListener("drop",h),()=>{document.removeEventListener("dragover",f),document.removeEventListener("drop",h)}},[n,m,t,e,y,u,l?.admin?.hideGutter]);function x(f){let h=f.dataTransfer;if(!h||!u)return;$o(h,u);let p="";e.update(()=>{let E=tt(u);E&&(p=E.getKey())}),s.current=!0,h.setData(nt,p)}function g(){s.current=!1,y?.elem&&it(c.current,y?.elem)}return Io(Ao(st.Fragment,{children:[he("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:g,onDragStart:x,ref:r,type:"button",children:he("div",{className:o?"icon":""})}),he("div",{className:"draggable-block-target-line",ref:c}),he("div",{className:"debug-highlight",ref:i})]}),t)}function lt(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=Oo();return Ko(n,o,n._editable)}import{c as jo}from"react/compiler-runtime";import{jsx as ke}from"react/jsx-runtime";import{useLexicalComposerContext as Ho}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Vo,$getRoot as zo}from"lexical";import"react";var at="insert-paragraph-at-end",ct=()=>{let e=jo(2),[t]=Ho(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let n;return e[0]!==t?(n=ke("div",{"aria-label":"Insert Paragraph",className:at,onClick:()=>{t.update(Wo)},role:"button",tabIndex:0,children:ke("div",{className:`${at}-inside`,children:ke("span",{children:"+"})})}),e[0]=t,e[1]=n):n=e[1],n};function Wo(){let e=Vo();zo().append(e),e.select()}import{c as Yo}from"react/compiler-runtime";import{useLexicalComposerContext as Go}from"@lexical/react/LexicalComposerContext";import*as ut from"react";var dt=()=>{let e=Yo(4),{editorConfig:t}=P(),[o]=Go(),n,r;return e[0]!==o||e[1]!==t.features.markdownTransformers?(n=()=>De(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]),ut.useEffect(n,r),null};import{c as Uo}from"react/compiler-runtime";import{useLexicalComposerContext as Jo}from"@lexical/react/LexicalComposerContext.js";import{useEffect as qo}from"react";function mt(){let e=Uo(5),[t]=Jo(),{currentView:o,views:n}=z(),r,c;return e[0]!==o||e[1]!==t||e[2]!==n?(r=()=>{n&&(o==="default"?n.default?Ee(t,n.default?.nodes):Ce(t):n[o]&&(Ce(t),Ee(t,n[o]?.nodes)))},c=[t,n,o],e[0]=o,e[1]=t,e[2]=n,e[3]=r,e[4]=c):(r=e[3],c=e[4]),qo(r,c),null}import{useLexicalComposerContext as Qo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Xo,$isRangeSelection as Zo,RootNode as en}from"lexical";import{useEffect as tn}from"react";function ft(){let[e]=Qo();return tn(()=>e.registerNodeTransform(en,t=>{let o=Xo();if(Zo(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 on}from"@lexical/react/LexicalComposerContext";import{$getSelection as nn,COMMAND_PRIORITY_LOW as rn,SELECT_ALL_COMMAND as sn}from"lexical";import{useEffect as ln}from"react";function pt(){let[e]=on();return ln(()=>e.registerCommand(sn,()=>{if(nn())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},rn),[e]),null}import{jsx as J,jsxs as ht}from"react/jsx-runtime";import{useLexicalComposerContext as cn}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as yt}from"@payloadcms/ui";import{useCallback as un,useMemo as dn,useState as mn}from"react";import"react";import*as xt from"react-dom";import{c as an}from"react/compiler-runtime";import"react";function gt(e,t){let o=an(4),{maxLength:n,minLength:r}=t,c=n===void 0?75:n,i=r===void 0?1:r,s;return o[0]!==c||o[1]!==i||o[2]!==e?(s=u=>{let{query:d}=u,y="[^"+e+Me+"\\s]",l=new RegExp("(^|\\s|\\()(["+e+"]((?:"+y+"){0,"+c+"}))$").exec(d);if(l!==null){let m=l[1],x=l[3];if(x.length>=i)return{leadOffset:l.index+m.length,matchingString:x,replaceableString:l[2]}}return null},o[0]=c,o[1]=i,o[2]=e,o[3]=s):s=o[3],s}var O="slash-menu-popup";function fn({isSelected:e,item:t,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=P(),{i18n:s}=yt(),u=`${O}__item ${O}__item-${t.key}`;e&&(u+=` ${O}__item--selected`);let d=t.key;return t.label&&(d=typeof t.label=="function"?t.label({featureClientSchemaMap:c,i18n:s,schemaPath:i}):t.label),d.length>25&&(d=d.substring(0,25)+"..."),ht("button",{"aria-selected":e,className:u,id:O+"__item-"+t.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[t?.Icon&&J(t.Icon,{}),J("span",{className:`${O}__item-text`,children:d})]},t.key)}function bt({anchorElem:e=document.body}){let[t]=cn(),[o,n]=mn(null),{editorConfig:r}=P(),{i18n:c}=yt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=P(),u=gt("/",{minLength:0}),d=un(()=>{let a=[];for(let l of r.features.slashMenu.dynamicGroups)if(o){let m=l({editor:t,queryString:o});a=a.concat(m)}return a},[t,o,r?.features]),y=dn(()=>{let a=[];for(let l of r?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(m=>{let x=m.items.filter(g=>{let f=g.key;return g.label&&(f=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):g.label),new RegExp(o,"gi").exec(f)?!0:g.keywords!=null?g.keywords.some(h=>new RegExp(o,"gi").exec(h)):!1});return x.length?{...m,items:x}:null}),a=a.filter(m=>m!=null);let l=d();for(let m of l){let x=a.find(g=>g.key===m.key);x?a=a.filter(g=>g.key!==m.key):x={...m,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,r?.features.slashMenu.groups,d,i,c,s]);return J(Oe,{anchorElem:e,groups:y,menuRenderFn:(a,{selectedItemKey:l,selectItemAndCleanUp:m,setSelectedItemKey:x})=>a.current&&y.length?xt.createPortal(J("div",{className:O,children:y.map(g=>{let f=g.key;return g.label&&i&&(f=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):g.label),ht("div",{className:`${O}__group ${O}__group-${g.key}`,children:[J("div",{className:`${O}__group-title`,children:f}),g.items.map((h,p)=>J(fn,{index:p,isSelected:l===h.key,item:h,onClick:()=>{x(h.key),m(h)},onMouseEnter:()=>{x(h.key)},ref:E=>{h.ref={current:E}}},h.key))]},g.key)})}),a.current):null,onQueryChange:n,triggerFn:u})}import{c as pn}from"react/compiler-runtime";import{useLexicalComposerContext as gn}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as hn,TextNode as yn}from"lexical";import{useEffect as xn}from"react";function Et(e){let t=pn(6),{features:o}=e,[n]=gn(),r;t[0]!==n||t[1]!==o.enabledFormats?(r=()=>{let i=bn(o.enabledFormats);if(i.length!==0)return n.registerNodeTransform(yn,s=>{i.forEach(u=>{s.hasFormat(u)&&s.toggleFormat(u)})})},t[0]=n,t[1]=o.enabledFormats,t[2]=r):r=t[2];let c;return t[3]!==n||t[4]!==o?(c=[n,o],t[3]=n,t[4]=o,t[5]=c):c=t[5],xn(r,c),null}function bn(e){let t=Object.keys(hn),o=new Set(e);return t.filter(n=>!o.has(n))}import{c as En}from"react/compiler-runtime";import{jsx as Ct}from"react/jsx-runtime";import{useLexicalComposerContext as Cn}from"@lexical/react/LexicalComposerContext";import{ContentEditable as Nn}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as wn}from"@payloadcms/ui";import"react";function Nt(e){let t=En(5),{className:o,editorConfig:n}=e,{t:r}=wn(),[,c]=Cn(),{getTheme:i}=c,s;if(t[0]!==o||t[1]!==n?.admin?.placeholder||t[2]!==i||t[3]!==r){let u=i();s=Ct(Nn,{"aria-placeholder":r("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ct("p",{className:u?.placeholder,children:n?.admin?.placeholder??r("lexical:general:placeholder")})}),t[0]=o,t[1]=n?.admin?.placeholder,t[2]=i,t[3]=r,t[4]=s}else s=t[4];return s}var St=e=>{let t=Sn(12),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:c}=e,i=P(),[s]=Pn(),u=_n(),[d,y]=An(null),a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=f=>{f!==null&&y(f)},t[0]=a):a=t[0];let l=a,m,x;t[1]!==s||t[2]!==i?(m=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let f=()=>{i.focusEditor(i)},h=()=>{i.blurEditor(i)},p=s.registerCommand(Ln,()=>(f(),!0),wt),E=s.registerCommand(Dn,()=>(h(),!0),wt);return()=>{p(),E(),i.parentEditor?.unregisterChild?.(i.uuid)}},x=[s,i],t[1]=s,t[2]=i,t[3]=m,t[4]=x):(m=t[3],x=t[4]),Mn(m,x);let g;return t[5]!==o||t[6]!==n||t[7]!==d||t[8]!==u||t[9]!==r||t[10]!==c?(g=ne(q.Fragment,{children:[o.features.plugins?.map(On),ne("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(Bn),b(Tn,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:l,children:b(Nt,{editorConfig:o})})}),ErrorBoundary:Rn}),b(ft,{}),u&&b(ct,{}),b(ze,{}),b(je,{}),b(Et,{features:o.features}),b(pt,{}),b(mt,{}),u&&b(vn,{ignoreSelectionChange:!0,onChange:(f,h,p)=>{(!p.has("focus")||p.size>1)&&c?.(f,h,p)}}),d&&ne(q.Fragment,{children:[!r&&u&&ne(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:b(lt,{anchorElem:d}),o.admin?.hideAddBlockButton?null:b(Qe,{anchorElem:d})]}),o.features.plugins?.map(f=>{if(f.position==="floatingAnchorElem"&&!(f.desktopOnly===!0&&r))return b(K,{anchorElem:d,clientProps:f.clientProps,plugin:f},f.key)}),u&&b(q.Fragment,{children:b(bt,{anchorElem:d})})]}),u&&ne(q.Fragment,{children:[b(kn,{}),o?.features?.markdownTransformers?.length>0&&b(dt,{})]}),o.features.plugins?.map(In),o.features.plugins?.map(Fn)]}),o.features.plugins?.map($n)]}),t[5]=o,t[6]=n,t[7]=d,t[8]=u,t[9]=r,t[10]=c,t[11]=g):g=t[11],g};function On(e){if(e.position==="aboveContainer")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function Bn(e){if(e.position==="top")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function In(e){if(e.position==="normal")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function Fn(e){if(e.position==="bottom")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function $n(e){if(e.position==="belowContainer")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}var Rt=({children:e,providers:t})=>{if(!t?.length)return e;let o=t[0];return t.length>1?$(o,{children:$(Rt,{providers:t.slice(1),children:e})}):$(o,{children:e})},kt=e=>{let{composerKey:t,editorConfig:o,fieldProps:n,isSmallWidthViewport:r,onChange:c,readOnly:i,value:s}=e,{currentView:u,views:d}=z(),y=P(),a=jn(),l=Pt.useRef(null),m=Hn(()=>{if(s&&typeof s!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(s));if(s&&Array.isArray(s)&&!("root"in s))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(s&&"jsonContent"in s)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");let x=d?.[u]?.nodes;return{editable:i!==!0,editorState:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Ie({editorConfig:o,nodeViews:x}),onError:g=>{throw g},theme:o.lexical.theme}},[o,d,u]);return m?$(Kn,{initialConfig:m,children:$(_e,{editorConfig:o,editorContainerRef:l,fieldProps:n,parentContext:y?.editDepth===a?y:void 0,children:$(Rt,{providers:o.features.providers,children:$(St,{editorConfig:o,editorContainerRef:l,isSmallWidthViewport:r,onChange:c})})})},t+m.editable+u):$("p",{children:"Loading..."})};import{c as Vn}from"react/compiler-runtime";import{jsx as Q,jsxs as zn}from"react/jsx-runtime";import{ChevronIcon as Wn,Popup as Yn,PopupList as vt}from"@payloadcms/ui";import"react";function Tt(){let e=Vn(5),{currentView:t,setCurrentView:o,views:n}=z();if(!n||Object.keys(n).length===0)return null;let r,c;if(e[0]!==t||e[1]!==o||e[2]!==n){c=Symbol.for("react.early_return_sentinel");e:{let i=Object.keys(n);if(!i.some(Un)){c=null;break e}let u=["default",...i.filter(Gn)],d=t.charAt(0).toUpperCase()+t.slice(1);r=Q("div",{className:"lexical-view-selector",children:Q(Yn,{button:zn("button",{className:"lexical-view-selector__button",type:"button",children:[Q("span",{className:"lexical-view-selector__label",children:d}),Q(Wn,{className:"lexical-view-selector__icon"})]}),buttonType:"custom",horizontalAlign:"left",render:y=>{let{close:a}=y;return Q(vt.ButtonGroup,{children:u.map(l=>{let m=l.charAt(0).toUpperCase()+l.slice(1);return Q(vt.Button,{active:l===t,disabled:l===t,onClick:()=>{o?.(l),a()},children:m},l)})})},size:"large"})})}e[0]=t,e[1]=o,e[2]=n,e[3]=r,e[4]=c}else r=e[3],c=e[4];return c!==Symbol.for("react.early_return_sentinel")?c:r}function Gn(e){return e!=="default"}function Un(e){return e!=="default"}var re="rich-text-lexical",sr=e=>{let{editorConfig:t,field:o,field:{admin:{className:n,description:r,readOnly:c}={},label:i,localized:s,required:u},path:d,readOnly:y,validate:a}=e,l=y||c,m=Zn(),x=Lt((M,Z)=>typeof a=="function"?a(M,{...Z,required:u}):!0,[a,u]),{customComponents:{AfterInput:g,BeforeInput:f,Description:h,Error:p,Label:E}={},disabled:k,initialValue:S,path:C,setValue:R,showError:N,value:L}=tr({potentiallyStalePath:d,validate:x}),B=l||k,[v,T]=At(!1),[X,xe]=At(),be=Dt.useRef(S),I=Dt.useRef(L);Mt(()=>{let M=()=>{let Z=window.matchMedia("(max-width: 768px)").matches;Z!==v&&T(Z)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[v]);let ve=["field-type",re,n,N&&"error",B&&`${re}--read-only`,t?.admin?.hideGutter!==!0&&!v?`${re}--show-gutter`:null].filter(Boolean).join(" "),se=`${C}.${m}`,_=Le(),w=Lt(M=>{_(()=>{let Te=M.toJSON();I.current=Te,R(Te)})},[R,_]),Ot=rr(()=>or(o),[o]),Bt=er(M=>{I.current!==L&&!nr(I.current!=null?JSON.parse(JSON.stringify(I.current)):I.current,L)&&(be.current=M,I.current=L,xe(new Date))});return Mt(()=>{Object.is(S,be.current)||Bt(S)},[S]),ie("div",{className:ve,"data-lexical-view":t?.view,style:Ot,children:[D(_t,{CustomComponent:p,Fallback:D(Qn,{path:C,showError:N})}),ie("div",{className:`${re}__label-row`,children:[E||D(Xn,{label:i,localized:s,path:C,required:u}),D(Tt,{})]}),ie("div",{className:`${re}__wrap`,children:[ie(ir,{fallbackRender:lr,onReset:()=>{},children:[f,D(Jn,{drawerSlugPrefix:C,children:D(kt,{composerKey:se,editorConfig:t,fieldProps:e,isSmallWidthViewport:v,onChange:w,readOnly:B,value:L},JSON.stringify({path:C,rerenderProviderKey:X}))}),g]}),D(_t,{CustomComponent:h,Fallback:D(qn,{description:r,path:C})})]})]},se)};function lr({error:e}){return ie("div",{className:"errorBoundary",role:"alert",children:[D("p",{children:"Something went wrong:"}),D("pre",{style:{color:"red"},children:e.message})]})}var hl=sr;export{hl as RichText};
2
- //# sourceMappingURL=Field-YM44WOON.js.map