@ai-stack/payloadcms 3.2.1-beta → 3.2.4-beta

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 (49) hide show
  1. package/LICENSE.md +2 -2
  2. package/README.md +20 -7
  3. package/dist/ai/models/openai/generateImage.d.ts.map +1 -1
  4. package/dist/ai/models/openai/generateImage.js +0 -1
  5. package/dist/ai/models/openai/generateImage.js.map +1 -1
  6. package/dist/ai/models/openai/generateRichText.d.ts +1 -1
  7. package/dist/ai/models/openai/generateRichText.d.ts.map +1 -1
  8. package/dist/ai/models/openai/generateRichText.js +14 -7
  9. package/dist/ai/models/openai/generateRichText.js.map +1 -1
  10. package/dist/ai/schemas/lexicalJsonSchema.d.ts +369 -0
  11. package/dist/ai/schemas/lexicalJsonSchema.d.ts.map +1 -1
  12. package/dist/ai/schemas/lexicalJsonSchema.js +547 -214
  13. package/dist/ai/schemas/lexicalJsonSchema.js.map +1 -1
  14. package/dist/collections/Instructions.js +3 -3
  15. package/dist/collections/Instructions.js.map +1 -1
  16. package/dist/endpoints/index.js.map +1 -1
  17. package/dist/exports/fields.d.ts +0 -1
  18. package/dist/exports/fields.d.ts.map +1 -1
  19. package/dist/exports/fields.js +0 -1
  20. package/dist/exports/fields.js.map +1 -1
  21. package/dist/fields/LexicalEditor/feature.client.d.ts.map +1 -1
  22. package/dist/fields/LexicalEditor/feature.client.js +4 -0
  23. package/dist/fields/LexicalEditor/feature.client.js.map +1 -1
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +3 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/plugin.d.ts.map +1 -1
  29. package/dist/plugin.js +26 -0
  30. package/dist/plugin.js.map +1 -1
  31. package/dist/types.d.ts +2 -0
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/types.js.map +1 -1
  34. package/dist/ui/Compose/Compose.js +4 -3
  35. package/dist/ui/Compose/Compose.js.map +1 -1
  36. package/dist/ui/Compose/{compose.module.scss → compose.module.css} +7 -7
  37. package/dist/ui/Compose/hooks/menu/useMenu.d.ts +2 -1
  38. package/dist/ui/Compose/hooks/menu/useMenu.d.ts.map +1 -1
  39. package/dist/ui/Compose/hooks/menu/useMenu.js +15 -4
  40. package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
  41. package/dist/ui/Compose/hooks/useGenerate.d.ts +1 -0
  42. package/dist/ui/Compose/hooks/useGenerate.d.ts.map +1 -1
  43. package/dist/ui/Compose/hooks/useGenerate.js +40 -11
  44. package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
  45. package/dist/utilities/editorSchemaValidator.d.ts +3 -0
  46. package/dist/utilities/editorSchemaValidator.d.ts.map +1 -0
  47. package/dist/utilities/editorSchemaValidator.js +31 -0
  48. package/dist/utilities/editorSchemaValidator.js.map +1 -0
  49. package/package.json +9 -11
@@ -1,294 +1,627 @@
1
- const CommonProperties = {
1
+ export const documentSchema = {
2
2
  type: 'object',
3
- properties: {
4
- children: {
5
- type: 'array',
6
- items: {
7
- $ref: '#/definitions/Node'
8
- }
9
- },
10
- direction: {
11
- type: [
12
- 'string',
13
- 'null'
14
- ],
15
- enum: [
16
- 'ltr',
17
- null
3
+ $schema: 'http://json-schema.org/draft-07/schema#',
4
+ additionalProperties: false,
5
+ definitions: {
6
+ // Text Node (Leaf Node)
7
+ TextNode: {
8
+ type: 'object',
9
+ additionalProperties: false,
10
+ properties: {
11
+ type: {
12
+ type: 'string',
13
+ enum: [
14
+ 'text'
15
+ ]
16
+ },
17
+ detail: {
18
+ type: 'number',
19
+ description: 'Text detail flags',
20
+ enum: [
21
+ 0,
22
+ 1,
23
+ 2,
24
+ 3
25
+ ],
26
+ examples: [
27
+ {
28
+ description: 'No special details',
29
+ value: 0
30
+ },
31
+ {
32
+ description: 'Directionless',
33
+ value: 1
34
+ },
35
+ {
36
+ description: 'Unmergeable',
37
+ value: 2
38
+ },
39
+ {
40
+ description: 'Directionless + Unmergeable',
41
+ value: 3
42
+ }
43
+ ]
44
+ },
45
+ direction: {
46
+ type: [
47
+ 'string',
48
+ 'null'
49
+ ],
50
+ enum: [
51
+ 'ltr',
52
+ null
53
+ ]
54
+ },
55
+ format: {
56
+ type: 'number',
57
+ description: `Format flags for text:
58
+ 0 = No format
59
+ 1 = Bold
60
+ 2 = Italic
61
+ 3 = Bold + Italic (1|2)
62
+ 4 = Strikethrough
63
+ 8 = Underline
64
+ 9 = Bold + Underline (1|8)
65
+ 16 = Code
66
+ 32 = Subscript
67
+ 64 = Superscript
68
+ 128 = Highlight
69
+
70
+ Formats can be combined using binary OR (|).
71
+ Example combinations:
72
+ - Bold + Italic = 1|2 = 3
73
+ - Bold + Underline = 1|8 = 9
74
+ - Italic + Underline = 2|8 = 10
75
+ - Bold + Italic + Underline = 1|2|8 = 11`
76
+ },
77
+ indent: {
78
+ type: 'number'
79
+ },
80
+ mode: {
81
+ type: 'number',
82
+ description: 'Text mode flags',
83
+ enum: [
84
+ 0,
85
+ 1,
86
+ 2
87
+ ],
88
+ examples: [
89
+ {
90
+ description: 'Normal text',
91
+ value: 0
92
+ },
93
+ {
94
+ description: 'Token text',
95
+ value: 1
96
+ },
97
+ {
98
+ description: 'Segmented text',
99
+ value: 2
100
+ }
101
+ ]
102
+ },
103
+ style: {
104
+ type: 'string',
105
+ description: 'CSS style string (e.g., "color: red; font-size: 12px;")'
106
+ },
107
+ text: {
108
+ type: 'string'
109
+ },
110
+ version: {
111
+ type: 'number'
112
+ }
113
+ },
114
+ required: [
115
+ 'type',
116
+ 'text',
117
+ 'format',
118
+ 'style',
119
+ 'mode',
120
+ 'detail',
121
+ 'direction',
122
+ 'indent',
123
+ 'version'
18
124
  ]
19
125
  },
20
- format: {
21
- type: 'string'
22
- },
23
- indent: {
24
- type: 'number'
126
+ // Styled Table Cell Node
127
+ TableCellNode: {
128
+ type: 'object',
129
+ additionalProperties: false,
130
+ properties: {
131
+ type: {
132
+ type: 'string',
133
+ enum: [
134
+ 'tablecell'
135
+ ]
136
+ },
137
+ children: {
138
+ type: 'array',
139
+ items: {
140
+ $ref: '#/definitions/TextNode'
141
+ }
142
+ },
143
+ colSpan: {
144
+ type: 'number'
145
+ },
146
+ direction: {
147
+ type: [
148
+ 'string',
149
+ 'null'
150
+ ],
151
+ enum: [
152
+ 'ltr',
153
+ null
154
+ ]
155
+ },
156
+ headerState: {
157
+ type: 'number'
158
+ },
159
+ indent: {
160
+ type: 'number'
161
+ },
162
+ version: {
163
+ type: 'number'
164
+ },
165
+ width: {
166
+ type: [
167
+ 'null'
168
+ ],
169
+ enum: [
170
+ null
171
+ ]
172
+ }
173
+ },
174
+ required: [
175
+ 'type',
176
+ 'children',
177
+ 'headerState',
178
+ 'colSpan',
179
+ 'width',
180
+ 'direction',
181
+ 'indent',
182
+ 'version'
183
+ ]
25
184
  },
26
- version: {
27
- type: 'number'
28
- }
29
- }
30
- };
31
- const BaseNode = {
32
- type: 'object',
33
- allOf: [
34
- {
35
- $ref: '#/definitions/CommonProperties'
36
- }
37
- ],
38
- properties: {
39
- type: {
40
- type: 'string'
41
- }
42
- },
43
- required: [
44
- 'type'
45
- ]
46
- };
47
- const CommonNodes = {
48
- allOf: [
49
- {
50
- $ref: '#/definitions/BaseNode'
185
+ // Styled Table Row Node
186
+ TableRowNode: {
187
+ type: 'object',
188
+ additionalProperties: false,
189
+ properties: {
190
+ type: {
191
+ type: 'string',
192
+ enum: [
193
+ 'tablerow'
194
+ ]
195
+ },
196
+ children: {
197
+ type: 'array',
198
+ items: {
199
+ $ref: '#/definitions/TableCellNode'
200
+ }
201
+ },
202
+ height: {
203
+ type: 'number'
204
+ }
205
+ },
206
+ required: [
207
+ 'type',
208
+ 'children',
209
+ 'height'
210
+ ]
51
211
  },
52
- {
212
+ // Styled Table Node
213
+ TableNode: {
214
+ type: 'object',
215
+ additionalProperties: false,
53
216
  properties: {
54
217
  type: {
55
218
  type: 'string',
56
219
  enum: [
57
- 'paragraph',
58
- 'quote',
59
- 'horizontalrule'
220
+ 'table'
60
221
  ]
222
+ },
223
+ children: {
224
+ type: 'array',
225
+ items: {
226
+ $ref: '#/definitions/TableRowNode'
227
+ }
61
228
  }
62
- }
63
- }
64
- ]
65
- };
66
- const HeadingNode = {
67
- allOf: [
68
- {
69
- $ref: '#/definitions/BaseNode'
229
+ },
230
+ required: [
231
+ 'type',
232
+ 'children'
233
+ ]
70
234
  },
71
- {
235
+ // Heading Node
236
+ HeadingNode: {
237
+ type: 'object',
238
+ additionalProperties: false,
72
239
  properties: {
73
240
  type: {
74
- const: 'heading'
241
+ type: 'string',
242
+ enum: [
243
+ 'heading'
244
+ ]
245
+ },
246
+ children: {
247
+ type: 'array',
248
+ items: {
249
+ anyOf: [
250
+ {
251
+ $ref: '#/definitions/TextNode'
252
+ },
253
+ {
254
+ $ref: '#/definitions/LinkNode'
255
+ }
256
+ ]
257
+ }
258
+ },
259
+ direction: {
260
+ type: [
261
+ 'string',
262
+ 'null'
263
+ ],
264
+ enum: [
265
+ 'ltr',
266
+ null
267
+ ]
268
+ },
269
+ indent: {
270
+ type: 'number'
75
271
  },
76
272
  tag: {
77
273
  type: 'string',
78
274
  enum: [
79
275
  'h1',
80
276
  'h2',
81
- 'h3',
82
- 'h4'
277
+ 'h3'
83
278
  ]
279
+ },
280
+ version: {
281
+ type: 'number'
84
282
  }
85
283
  },
86
284
  required: [
87
- 'tag'
285
+ 'type',
286
+ 'tag',
287
+ 'children',
288
+ 'direction',
289
+ 'indent',
290
+ 'version'
88
291
  ]
89
- }
90
- ]
91
- };
92
- const LinkNode = {
93
- allOf: [
94
- {
95
- $ref: '#/definitions/BaseNode'
96
292
  },
97
- {
293
+ // Paragraph Node
294
+ ParagraphNode: {
295
+ type: 'object',
296
+ additionalProperties: false,
98
297
  properties: {
99
- id: {
100
- type: 'string'
101
- },
102
298
  type: {
103
- const: 'link'
299
+ type: 'string',
300
+ enum: [
301
+ 'paragraph'
302
+ ]
104
303
  },
105
- fields: {
106
- type: 'object',
107
- properties: {
108
- linkType: {
109
- type: 'string'
110
- },
111
- newTab: {
112
- type: 'boolean'
113
- },
114
- url: {
115
- type: 'string'
116
- }
117
- },
118
- required: [
119
- 'linkType',
120
- 'newTab',
121
- 'url'
304
+ children: {
305
+ type: 'array',
306
+ items: {
307
+ anyOf: [
308
+ {
309
+ $ref: '#/definitions/TextNode'
310
+ },
311
+ {
312
+ $ref: '#/definitions/LinkNode'
313
+ },
314
+ {
315
+ $ref: '#/definitions/CodeNode'
316
+ }
317
+ ]
318
+ }
319
+ },
320
+ direction: {
321
+ type: [
322
+ 'string',
323
+ 'null'
324
+ ],
325
+ enum: [
326
+ 'ltr',
327
+ null
122
328
  ]
329
+ },
330
+ format: {
331
+ type: 'string',
332
+ enum: [
333
+ 'start',
334
+ 'center',
335
+ 'right'
336
+ ]
337
+ },
338
+ indent: {
339
+ type: 'number'
340
+ },
341
+ textFormat: {
342
+ type: 'number'
343
+ },
344
+ textStyle: {
345
+ type: 'string',
346
+ description: 'CSS style string (e.g., "color: red; font-size: 12px;")'
347
+ },
348
+ version: {
349
+ type: 'number'
123
350
  }
124
351
  },
125
352
  required: [
126
- 'id',
127
- 'fields'
353
+ 'type',
354
+ 'children',
355
+ 'direction',
356
+ 'format',
357
+ 'indent',
358
+ 'textFormat',
359
+ 'textStyle',
360
+ 'version'
128
361
  ]
129
- }
130
- ]
131
- };
132
- const ListItemNode = {
133
- allOf: [
134
- {
135
- $ref: '#/definitions/BaseNode'
136
362
  },
137
- {
363
+ // Link Node
364
+ LinkNode: {
365
+ type: 'object',
366
+ additionalProperties: false,
138
367
  properties: {
139
368
  type: {
140
- const: 'listitem'
369
+ type: 'string',
370
+ enum: [
371
+ 'link'
372
+ ]
141
373
  },
142
- checked: {
143
- type: 'boolean'
374
+ children: {
375
+ type: 'array',
376
+ items: {
377
+ $ref: '#/definitions/TextNode'
378
+ }
144
379
  },
145
- value: {
146
- type: 'number'
380
+ url: {
381
+ type: 'string'
147
382
  }
148
383
  },
149
384
  required: [
150
- 'value'
385
+ 'type',
386
+ 'url',
387
+ 'children'
151
388
  ]
152
- }
153
- ]
154
- };
155
- const ListNode = {
156
- allOf: [
157
- {
158
- $ref: '#/definitions/BaseNode'
159
389
  },
160
- {
390
+ // List Item Node
391
+ ListItemNode: {
392
+ type: 'object',
393
+ additionalProperties: false,
161
394
  properties: {
162
395
  type: {
163
- const: 'list'
396
+ type: 'string',
397
+ enum: [
398
+ 'listitem'
399
+ ]
164
400
  },
165
- listType: {
401
+ children: {
402
+ type: 'array',
403
+ items: {
404
+ anyOf: [
405
+ {
406
+ $ref: '#/definitions/ParagraphNode'
407
+ },
408
+ {
409
+ $ref: '#/definitions/ListNode'
410
+ }
411
+ ]
412
+ }
413
+ }
414
+ },
415
+ required: [
416
+ 'type',
417
+ 'children'
418
+ ]
419
+ },
420
+ // List Node
421
+ ListNode: {
422
+ type: 'object',
423
+ additionalProperties: false,
424
+ properties: {
425
+ type: {
166
426
  type: 'string',
167
427
  enum: [
168
- 'check',
169
- 'number',
170
- 'bullet'
428
+ 'list'
171
429
  ]
172
430
  },
173
- start: {
174
- type: 'number'
431
+ children: {
432
+ type: 'array',
433
+ items: {
434
+ $ref: '#/definitions/ListItemNode'
435
+ }
175
436
  },
176
- tag: {
437
+ listType: {
177
438
  type: 'string',
178
439
  enum: [
179
- 'ul',
180
- 'ol'
440
+ 'bullet',
441
+ 'number'
181
442
  ]
182
443
  }
183
444
  },
184
445
  required: [
446
+ 'type',
185
447
  'listType',
186
- 'start',
187
- 'tag'
448
+ 'children'
188
449
  ]
189
- }
190
- ]
191
- };
192
- // const MediaNode = {
193
- // allOf: [
194
- // { $ref: '#/definitions/BaseNode' },
195
- // {
196
- // properties: {
197
- // type: { const: 'block' },
198
- // fields: {
199
- // type: 'object',
200
- // properties: {
201
- // id: { type: 'string' },
202
- // blockName: { type: 'string' },
203
- // blockType: { const: 'mediaBlock' },
204
- // media: { type: 'string' },
205
- // position: {
206
- // type: 'string',
207
- // enum: ['fullscreen', 'default'],
208
- // },
209
- // },
210
- // required: ['id', 'media', 'position', 'blockName', 'blockType'],
211
- // },
212
- // version: { const: 2 },
213
- // },
214
- // required: ['version', 'fields'],
215
- // },
216
- // ],
217
- // }
218
- const Node = {
219
- oneOf: [
220
- {
221
- $ref: '#/definitions/TextNode'
222
- },
223
- {
224
- $ref: '#/definitions/LinkNode'
225
450
  },
226
- {
227
- $ref: '#/definitions/ListItemNode'
228
- },
229
- {
230
- $ref: '#/definitions/ListNode'
451
+ // Quote Node
452
+ QuoteNode: {
453
+ type: 'object',
454
+ additionalProperties: false,
455
+ properties: {
456
+ type: {
457
+ type: 'string',
458
+ enum: [
459
+ 'quote'
460
+ ]
461
+ },
462
+ children: {
463
+ type: 'array',
464
+ items: {
465
+ anyOf: [
466
+ {
467
+ $ref: '#/definitions/TextNode'
468
+ },
469
+ {
470
+ $ref: '#/definitions/ParagraphNode'
471
+ }
472
+ ]
473
+ }
474
+ }
475
+ },
476
+ required: [
477
+ 'type',
478
+ 'children'
479
+ ]
231
480
  },
232
- {
233
- $ref: '#/definitions/HeadingNode'
481
+ // Code Node
482
+ CodeNode: {
483
+ type: 'object',
484
+ additionalProperties: false,
485
+ properties: {
486
+ type: {
487
+ type: 'string',
488
+ enum: [
489
+ 'code'
490
+ ]
491
+ },
492
+ code: {
493
+ type: 'string'
494
+ },
495
+ language: {
496
+ type: 'string'
497
+ }
498
+ },
499
+ required: [
500
+ 'type',
501
+ 'code',
502
+ 'language'
503
+ ]
234
504
  },
235
- {
236
- $ref: '#/definitions/CommonNodes'
237
- }
238
- ]
239
- };
240
- const RootNode = {
241
- allOf: [
242
- {
243
- $ref: '#/definitions/BaseNode'
505
+ // Horizontal Rule Node
506
+ HorizontalRuleNode: {
507
+ type: 'object',
508
+ additionalProperties: false,
509
+ properties: {
510
+ type: {
511
+ type: 'string',
512
+ enum: [
513
+ 'horizontalrule'
514
+ ]
515
+ }
516
+ },
517
+ required: [
518
+ 'type'
519
+ ]
244
520
  },
245
- {
521
+ // Image Node
522
+ ImageNode: {
523
+ type: 'object',
524
+ additionalProperties: false,
246
525
  properties: {
247
526
  type: {
248
- const: 'root'
527
+ type: 'string',
528
+ enum: [
529
+ 'image'
530
+ ]
531
+ },
532
+ alt: {
533
+ type: 'string'
534
+ },
535
+ caption: {
536
+ type: 'array',
537
+ items: {
538
+ $ref: '#/definitions/TextNode'
539
+ }
540
+ },
541
+ src: {
542
+ type: 'string'
249
543
  }
250
- }
251
- }
252
- ]
253
- };
254
- const TextNode = {
255
- allOf: [
256
- {
257
- $ref: '#/definitions/BaseNode'
544
+ },
545
+ required: [
546
+ 'type',
547
+ 'src',
548
+ 'alt',
549
+ 'caption'
550
+ ]
258
551
  },
259
- {
552
+ // Root Node
553
+ RootNode: {
554
+ type: 'object',
555
+ additionalProperties: false,
260
556
  properties: {
261
557
  type: {
262
- const: 'text'
558
+ type: 'string',
559
+ enum: [
560
+ 'root'
561
+ ]
263
562
  },
264
- format: {
563
+ children: {
564
+ type: 'array',
565
+ items: {
566
+ anyOf: [
567
+ {
568
+ $ref: '#/definitions/TextNode'
569
+ },
570
+ {
571
+ $ref: '#/definitions/HeadingNode'
572
+ },
573
+ {
574
+ $ref: '#/definitions/ParagraphNode'
575
+ },
576
+ {
577
+ $ref: '#/definitions/LinkNode'
578
+ },
579
+ {
580
+ $ref: '#/definitions/ListNode'
581
+ },
582
+ {
583
+ $ref: '#/definitions/QuoteNode'
584
+ },
585
+ {
586
+ $ref: '#/definitions/CodeNode'
587
+ },
588
+ {
589
+ $ref: '#/definitions/HorizontalRuleNode'
590
+ },
591
+ {
592
+ $ref: '#/definitions/ImageNode'
593
+ },
594
+ {
595
+ $ref: '#/definitions/TableNode'
596
+ }
597
+ ]
598
+ }
599
+ },
600
+ direction: {
601
+ type: [
602
+ 'string',
603
+ 'null'
604
+ ],
605
+ enum: [
606
+ 'ltr',
607
+ null
608
+ ]
609
+ },
610
+ indent: {
265
611
  type: 'number'
266
612
  },
267
- text: {
268
- type: 'string'
613
+ version: {
614
+ type: 'number'
269
615
  }
270
616
  },
271
617
  required: [
272
- 'text'
618
+ 'type',
619
+ 'children',
620
+ 'direction',
621
+ 'indent',
622
+ 'version'
273
623
  ]
274
624
  }
275
- ]
276
- };
277
- const baseJsonSchema = {
278
- type: 'object',
279
- $schema: 'http://json-schema.org/draft-07/schema#',
280
- definitions: {
281
- BaseNode,
282
- CommonNodes,
283
- CommonProperties,
284
- HeadingNode,
285
- LinkNode,
286
- ListItemNode,
287
- ListNode,
288
- // MediaNode,
289
- Node,
290
- RootNode,
291
- TextNode
292
625
  },
293
626
  properties: {
294
627
  root: {
@@ -300,7 +633,7 @@ const baseJsonSchema = {
300
633
  ]
301
634
  };
302
635
  export const lexicalJsonSchema = (customNodes = [])=>{
303
- const schema = JSON.parse(JSON.stringify(baseJsonSchema));
636
+ const schema = JSON.parse(JSON.stringify(documentSchema));
304
637
  // Add custom nodes to the Node definition
305
638
  if (customNodes.length > 0) {
306
639
  customNodes.forEach((customNode, index)=>{