@payloadcms/richtext-lexical 3.0.0-beta.11 → 3.0.0-beta.12

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 (2) hide show
  1. package/package.json +9 -9
  2. package/src/index.ts +0 -423
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.0.0-beta.11",
3
+ "version": "3.0.0-beta.12",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,17 +40,17 @@
40
40
  "@types/node": "20.12.5",
41
41
  "@types/react": "18.2.74",
42
42
  "@types/react-dom": "18.2.24",
43
+ "payload": "3.0.0-beta.12",
44
+ "@payloadcms/ui": "3.0.0-beta.12",
43
45
  "@payloadcms/eslint-config": "1.1.1",
44
- "payload": "3.0.0-beta.11",
45
- "@payloadcms/translations": "3.0.0-beta.11",
46
- "@payloadcms/ui": "3.0.0-beta.11",
47
- "@payloadcms/next": "3.0.0-beta.11"
46
+ "@payloadcms/translations": "3.0.0-beta.12",
47
+ "@payloadcms/next": "3.0.0-beta.12"
48
48
  },
49
49
  "peerDependencies": {
50
- "@payloadcms/translations": "3.0.0-beta.11",
51
- "@payloadcms/ui": "3.0.0-beta.11",
52
- "@payloadcms/next": "3.0.0-beta.11",
53
- "payload": "3.0.0-beta.11"
50
+ "@payloadcms/translations": "3.0.0-beta.12",
51
+ "@payloadcms/ui": "3.0.0-beta.12",
52
+ "@payloadcms/next": "3.0.0-beta.12",
53
+ "payload": "3.0.0-beta.12"
54
54
  },
55
55
  "exports": {
56
56
  ".": {
package/src/index.ts DELETED
@@ -1,423 +0,0 @@
1
- import type { JSONSchema4 } from 'json-schema'
2
- import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'
3
-
4
- import { withMergedProps } from '@payloadcms/ui/elements/withMergedProps'
5
- import { withNullableJSONSchemaType } from 'payload/utilities'
6
-
7
- import type { FeatureProviderServer, ResolvedServerFeatureMap } from './field/features/types.js'
8
- import type { SanitizedServerEditorConfig } from './field/lexical/config/types.js'
9
- import type { AdapterProps, LexicalEditorProps, LexicalRichTextAdapter } from './types.js'
10
-
11
- import { RichTextCell } from './cell/index.js'
12
- import { RichTextField } from './field/index.js'
13
- import {
14
- defaultEditorConfig,
15
- defaultEditorFeatures,
16
- defaultSanitizedServerEditorConfig,
17
- } from './field/lexical/config/server/default.js'
18
- import { loadFeatures } from './field/lexical/config/server/loader.js'
19
- import { sanitizeServerFeatures } from './field/lexical/config/server/sanitize.js'
20
- import { cloneDeep } from './field/lexical/utils/cloneDeep.js'
21
- import { getGenerateComponentMap } from './generateComponentMap.js'
22
- import { getGenerateSchemaMap } from './generateSchemaMap.js'
23
- import { richTextRelationshipPromise } from './populate/richTextRelationshipPromise.js'
24
- import { richTextValidateHOC } from './validate/index.js'
25
-
26
- export function lexicalEditor(props?: LexicalEditorProps): LexicalRichTextAdapter {
27
- let resolvedFeatureMap: ResolvedServerFeatureMap = null
28
-
29
- let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only
30
- if (!props || (!props.features && !props.lexical)) {
31
- finalSanitizedEditorConfig = cloneDeep(defaultSanitizedServerEditorConfig)
32
- resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap
33
- } else {
34
- let features: FeatureProviderServer<unknown, unknown>[] =
35
- props.features && typeof props.features === 'function'
36
- ? props.features({ defaultFeatures: cloneDeep(defaultEditorFeatures) })
37
- : (props.features as FeatureProviderServer<unknown, unknown>[])
38
- if (!features) {
39
- features = cloneDeep(defaultEditorFeatures)
40
- }
41
-
42
- const lexical: LexicalEditorConfig = props.lexical
43
-
44
- resolvedFeatureMap = loadFeatures({
45
- unSanitizedEditorConfig: {
46
- features,
47
- lexical: lexical ? lexical : defaultEditorConfig.lexical,
48
- },
49
- })
50
-
51
- finalSanitizedEditorConfig = {
52
- features: sanitizeServerFeatures(resolvedFeatureMap),
53
- lexical: lexical ? lexical : defaultEditorConfig.lexical,
54
- resolvedFeatureMap,
55
- }
56
- }
57
-
58
- return {
59
- CellComponent: withMergedProps({
60
- Component: RichTextCell,
61
- toMergeIntoProps: { lexicalEditorConfig: finalSanitizedEditorConfig.lexical },
62
- }),
63
- FieldComponent: withMergedProps({
64
- Component: RichTextField,
65
- toMergeIntoProps: { lexicalEditorConfig: finalSanitizedEditorConfig.lexical },
66
- }),
67
- afterReadPromise: ({ field, incomingEditorState, siblingDoc }) => {
68
- return new Promise<void>((resolve, reject) => {
69
- const promises: Promise<void>[] = []
70
-
71
- if (finalSanitizedEditorConfig?.features?.hooks?.afterReadPromises?.length) {
72
- for (const afterReadPromise of finalSanitizedEditorConfig.features.hooks
73
- .afterReadPromises) {
74
- const promise = afterReadPromise({
75
- field,
76
- incomingEditorState,
77
- siblingDoc,
78
- })
79
- if (promise) {
80
- promises.push(promise)
81
- }
82
- }
83
- }
84
-
85
- Promise.all(promises)
86
- .then(() => resolve())
87
- .catch((error) => reject(error))
88
- })
89
- },
90
- editorConfig: finalSanitizedEditorConfig,
91
- generateComponentMap: getGenerateComponentMap({
92
- resolvedFeatureMap,
93
- }),
94
- generateSchemaMap: getGenerateSchemaMap({
95
- resolvedFeatureMap,
96
- }),
97
- outputSchema: ({
98
- collectionIDFieldTypes,
99
- config,
100
- field,
101
- interfaceNameDefinitions,
102
- isRequired,
103
- }) => {
104
- let outputSchema: JSONSchema4 = {
105
- // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.
106
- // In the future, we should
107
- // 1) allow recursive children
108
- // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.
109
- type: withNullableJSONSchemaType('object', isRequired),
110
- properties: {
111
- root: {
112
- type: 'object',
113
- additionalProperties: false,
114
- properties: {
115
- type: {
116
- type: 'string',
117
- },
118
- children: {
119
- type: 'array',
120
- items: {
121
- type: 'object',
122
- additionalProperties: true,
123
- properties: {
124
- type: {
125
- type: 'string',
126
- },
127
- version: {
128
- type: 'integer',
129
- },
130
- },
131
- required: ['type', 'version'],
132
- },
133
- },
134
- direction: {
135
- oneOf: [
136
- {
137
- enum: ['ltr', 'rtl'],
138
- },
139
- {
140
- type: 'null',
141
- },
142
- ],
143
- },
144
- format: {
145
- type: 'string',
146
- enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element
147
- },
148
- indent: {
149
- type: 'integer',
150
- },
151
- version: {
152
- type: 'integer',
153
- },
154
- },
155
- required: ['children', 'direction', 'format', 'indent', 'type', 'version'],
156
- },
157
- },
158
- required: ['root'],
159
- }
160
- for (const modifyOutputSchema of finalSanitizedEditorConfig.features.generatedTypes
161
- .modifyOutputSchemas) {
162
- outputSchema = modifyOutputSchema({
163
- collectionIDFieldTypes,
164
- config,
165
- currentSchema: outputSchema,
166
- field,
167
- interfaceNameDefinitions,
168
- isRequired,
169
- })
170
- }
171
-
172
- return outputSchema
173
- },
174
- populationPromise({
175
- context,
176
- currentDepth,
177
- depth,
178
- field,
179
- findMany,
180
- flattenLocales,
181
- overrideAccess,
182
- populationPromises,
183
- req,
184
- showHiddenFields,
185
- siblingDoc,
186
- }) {
187
- // check if there are any features with nodes which have populationPromises for this field
188
- if (finalSanitizedEditorConfig?.features?.populationPromises?.size) {
189
- return richTextRelationshipPromise({
190
- context,
191
- currentDepth,
192
- depth,
193
- editorPopulationPromises: finalSanitizedEditorConfig.features.populationPromises,
194
- field,
195
- findMany,
196
- flattenLocales,
197
- overrideAccess,
198
- populationPromises,
199
- req,
200
- showHiddenFields,
201
- siblingDoc,
202
- })
203
- }
204
-
205
- return null
206
- },
207
- validate: richTextValidateHOC({
208
- editorConfig: finalSanitizedEditorConfig,
209
- }),
210
- }
211
- }
212
-
213
- export { AlignFeature } from './field/features/align/feature.server.js'
214
- export { BlockQuoteFeature } from './field/features/blockquote/feature.server.js'
215
- export {
216
- BlocksFeature,
217
- type BlocksFeatureProps,
218
- type LexicalBlock,
219
- } from './field/features/blocks/feature.server.js'
220
- export {
221
- $createBlockNode,
222
- $isBlockNode,
223
- type BlockFields,
224
- BlockNode,
225
- type SerializedBlockNode,
226
- } from './field/features/blocks/nodes/BlocksNode.js'
227
-
228
- export { TextDropdownSectionWithEntries } from './field/features/common/floatingSelectToolbarTextDropdownSection/index.js'
229
- export { LinebreakHTMLConverter } from './field/features/converters/html/converter/converters/linebreak.js'
230
- export { ParagraphHTMLConverter } from './field/features/converters/html/converter/converters/paragraph.js'
231
-
232
- export { TextHTMLConverter } from './field/features/converters/html/converter/converters/text.js'
233
- export { defaultHTMLConverters } from './field/features/converters/html/converter/defaultConverters.js'
234
- export {
235
- convertLexicalNodesToHTML,
236
- convertLexicalToHTML,
237
- } from './field/features/converters/html/converter/index.js'
238
- export type { HTMLConverter } from './field/features/converters/html/converter/types.js'
239
- export {
240
- HTMLConverterFeature,
241
- type HTMLConverterFeatureProps,
242
- } from './field/features/converters/html/feature.server.js'
243
- export {
244
- consolidateHTMLConverters,
245
- lexicalHTML,
246
- } from './field/features/converters/html/field/index.js'
247
- export { createClientComponent } from './field/features/createClientComponent.js'
248
- export { TestRecorderFeature } from './field/features/debug/testrecorder/feature.server.js'
249
- export { TreeViewFeature } from './field/features/debug/treeview/feature.server.js'
250
- export { BoldFeature } from './field/features/format/bold/feature.server.js'
251
- export { SectionWithEntries as FormatSectionWithEntries } from './field/features/format/common/floatingSelectToolbarSection.js'
252
- export { InlineCodeFeature } from './field/features/format/inlinecode/feature.server.js'
253
- export { ItalicFeature } from './field/features/format/italic/feature.server.js'
254
- export { StrikethroughFeature } from './field/features/format/strikethrough/feature.server.js'
255
- export { SubscriptFeature } from './field/features/format/subscript/feature.server.js'
256
- export { SuperscriptFeature } from './field/features/format/superscript/feature.server.js'
257
- export { UnderlineFeature } from './field/features/format/underline/feature.server.js'
258
-
259
- export { HeadingFeature } from './field/features/heading/feature.server.js'
260
- export { IndentFeature } from './field/features/indent/feature.server.js'
261
-
262
- export { LinkFeature, type LinkFeatureServerProps } from './field/features/link/feature.server.js'
263
- export {
264
- $createAutoLinkNode,
265
- $isAutoLinkNode,
266
- AutoLinkNode,
267
- } from './field/features/link/nodes/AutoLinkNode.js'
268
- export {
269
- $createLinkNode,
270
- $isLinkNode,
271
- LinkNode,
272
- TOGGLE_LINK_COMMAND,
273
- } from './field/features/link/nodes/LinkNode.js'
274
- export type {
275
- LinkFields,
276
- SerializedAutoLinkNode,
277
- SerializedLinkNode,
278
- } from './field/features/link/nodes/types.js'
279
- export { CheckListFeature } from './field/features/lists/checklist/feature.server.js'
280
- export { OrderedListFeature } from './field/features/lists/orderedlist/feature.server.js'
281
- export { UnorderedListFeature } from './field/features/lists/unorderedlist/feature.server.js'
282
- export { LexicalPluginToLexicalFeature } from './field/features/migrations/lexicalPluginToLexical/feature.server.js'
283
- export { SlateBlockquoteConverter } from './field/features/migrations/slateToLexical/converter/converters/blockquote/index.js'
284
- export { SlateHeadingConverter } from './field/features/migrations/slateToLexical/converter/converters/heading/index.js'
285
- export { SlateIndentConverter } from './field/features/migrations/slateToLexical/converter/converters/indent/index.js'
286
- export { SlateLinkConverter } from './field/features/migrations/slateToLexical/converter/converters/link/index.js'
287
- export { SlateListItemConverter } from './field/features/migrations/slateToLexical/converter/converters/listItem/index.js'
288
- export { SlateOrderedListConverter } from './field/features/migrations/slateToLexical/converter/converters/orderedList/index.js'
289
- export { SlateRelationshipConverter } from './field/features/migrations/slateToLexical/converter/converters/relationship/index.js'
290
- export { SlateUnknownConverter } from './field/features/migrations/slateToLexical/converter/converters/unknown/index.js'
291
- export { SlateUnorderedListConverter } from './field/features/migrations/slateToLexical/converter/converters/unorderedList/index.js'
292
-
293
- export { SlateUploadConverter } from './field/features/migrations/slateToLexical/converter/converters/upload/index.js'
294
- export { defaultSlateConverters } from './field/features/migrations/slateToLexical/converter/defaultConverters.js'
295
- export {
296
- convertSlateNodesToLexical,
297
- convertSlateToLexical,
298
- } from './field/features/migrations/slateToLexical/converter/index.js'
299
-
300
- export type {
301
- SlateNode,
302
- SlateNodeConverter,
303
- } from './field/features/migrations/slateToLexical/converter/types.js'
304
- export { SlateToLexicalFeature } from './field/features/migrations/slateToLexical/feature.server.js'
305
- export { ParagraphFeature } from './field/features/paragraph/feature.server.js'
306
- export { RelationshipFeature } from './field/features/relationship/feature.server.js'
307
- export {
308
- $createRelationshipNode,
309
- $isRelationshipNode,
310
- type RelationshipData,
311
- RelationshipNode,
312
- type SerializedRelationshipNode,
313
- } from './field/features/relationship/nodes/RelationshipNode.js'
314
- export type {
315
- ClientFeature,
316
- ClientFeatureProviderMap,
317
- FeatureProviderClient,
318
- FeatureProviderProviderClient,
319
- FeatureProviderProviderServer,
320
- FeatureProviderServer,
321
- NodeValidation,
322
- PopulationPromise,
323
- ResolvedClientFeature,
324
- ResolvedClientFeatureMap,
325
- ResolvedServerFeature,
326
- ResolvedServerFeatureMap,
327
- SanitizedClientFeatures,
328
- SanitizedPlugin,
329
- SanitizedServerFeatures,
330
- ServerFeature,
331
- ServerFeatureProviderMap,
332
- } from './field/features/types.js'
333
- export { UploadFeature } from './field/features/upload/feature.server.js'
334
-
335
- export type { UploadFeatureProps } from './field/features/upload/feature.server.js'
336
-
337
- export type { RawUploadPayload } from './field/features/upload/nodes/UploadNode.js'
338
-
339
- export {
340
- $createUploadNode,
341
- $isUploadNode,
342
- type SerializedUploadNode,
343
- type UploadData,
344
- UploadNode,
345
- } from './field/features/upload/nodes/UploadNode.js'
346
- export {
347
- EditorConfigProvider,
348
- useEditorConfigContext,
349
- } from './field/lexical/config/client/EditorConfigProvider.js'
350
- export {
351
- sanitizeClientEditorConfig,
352
- sanitizeClientFeatures,
353
- } from './field/lexical/config/client/sanitize.js'
354
- export {
355
- defaultEditorConfig,
356
- defaultEditorFeatures,
357
- defaultEditorLexicalConfig,
358
- defaultSanitizedServerEditorConfig,
359
- } from './field/lexical/config/server/default.js'
360
- export {
361
- loadFeatures,
362
- sortFeaturesForOptimalLoading,
363
- } from './field/lexical/config/server/loader.js'
364
- export {
365
- sanitizeServerEditorConfig,
366
- sanitizeServerFeatures,
367
- } from './field/lexical/config/server/sanitize.js'
368
-
369
- export type {
370
- ClientEditorConfig,
371
- SanitizedClientEditorConfig,
372
- SanitizedServerEditorConfig,
373
- ServerEditorConfig,
374
- } from './field/lexical/config/types.js'
375
- export { getEnabledNodes } from './field/lexical/nodes/index.js'
376
-
377
- export {
378
- type FloatingToolbarSection,
379
- type FloatingToolbarSectionEntry,
380
- } from './field/lexical/plugins/FloatingSelectToolbar/types.js'
381
- export { ENABLE_SLASH_MENU_COMMAND } from './field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js'
382
- export type { AdapterProps }
383
-
384
- export {
385
- SlashMenuGroup,
386
- SlashMenuOption,
387
- } from './field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'
388
- export { CAN_USE_DOM } from './field/lexical/utils/canUseDOM.js'
389
- export { cloneDeep } from './field/lexical/utils/cloneDeep.js'
390
- export { getDOMRangeRect } from './field/lexical/utils/getDOMRangeRect.js'
391
- export { getSelectedNode } from './field/lexical/utils/getSelectedNode.js'
392
- export { isHTMLElement } from './field/lexical/utils/guard.js'
393
- export { invariant } from './field/lexical/utils/invariant.js'
394
- export { joinClasses } from './field/lexical/utils/joinClasses.js'
395
- export { createBlockNode } from './field/lexical/utils/markdown/createBlockNode.js'
396
- export {
397
- DETAIL_TYPE_TO_DETAIL,
398
- DOUBLE_LINE_BREAK,
399
- ELEMENT_FORMAT_TO_TYPE,
400
- ELEMENT_TYPE_TO_FORMAT,
401
- IS_ALL_FORMATTING,
402
- LTR_REGEX,
403
- NON_BREAKING_SPACE,
404
- NodeFormat,
405
- RTL_REGEX,
406
- TEXT_MODE_TO_TYPE,
407
- TEXT_TYPE_TO_FORMAT,
408
- TEXT_TYPE_TO_MODE,
409
- } from './field/lexical/utils/nodeFormat.js'
410
- export { Point, isPoint } from './field/lexical/utils/point.js'
411
- export { Rect } from './field/lexical/utils/rect.js'
412
- export { setFloatingElemPosition } from './field/lexical/utils/setFloatingElemPosition.js'
413
- export { setFloatingElemPositionForLinkEditor } from './field/lexical/utils/setFloatingElemPositionForLinkEditor.js'
414
- export {
415
- addSwipeDownListener,
416
- addSwipeLeftListener,
417
- addSwipeRightListener,
418
- addSwipeUpListener,
419
- } from './field/lexical/utils/swipe.js'
420
- export { sanitizeUrl, validateUrl } from './field/lexical/utils/url.js'
421
- export { defaultRichTextValue } from './populate/defaultValue.js'
422
-
423
- export type { LexicalEditorProps, LexicalRichTextAdapter } from './types.js'