@payloadcms/richtext-lexical 3.60.0-canary.0 → 3.60.0-canary.10

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 (125) hide show
  1. package/dist/exports/client/Field-YHS7VMOE.js +2 -0
  2. package/dist/exports/client/Field-YHS7VMOE.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-JXQOFHXF.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-JXQOFHXF.js.map +7 -0
  5. package/dist/exports/client/{chunk-XNERFY6G.js → chunk-ADWHGDDR.js} +2 -2
  6. package/dist/exports/client/{chunk-XNERFY6G.js.map → chunk-ADWHGDDR.js.map} +2 -2
  7. package/dist/exports/client/chunk-O6XRT2H3.js +2 -0
  8. package/dist/exports/client/{chunk-BQCXN3B4.js.map → chunk-O6XRT2H3.js.map} +4 -4
  9. package/dist/exports/client/component-WT25HAJA.js +2 -0
  10. package/dist/exports/client/component-WT25HAJA.js.map +7 -0
  11. package/dist/exports/client/componentInline-MIPTDFRK.js +2 -0
  12. package/dist/exports/client/index.d.ts +1 -1
  13. package/dist/exports/client/index.d.ts.map +1 -1
  14. package/dist/exports/client/index.js +22 -22
  15. package/dist/exports/client/index.js.map +4 -4
  16. package/dist/features/blockquote/server/index.d.ts +3 -4
  17. package/dist/features/blockquote/server/index.d.ts.map +1 -1
  18. package/dist/features/blockquote/server/index.js.map +1 -1
  19. package/dist/features/blocks/premade/CodeBlock/index.d.ts +3 -1
  20. package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -1
  21. package/dist/features/blocks/premade/CodeBlock/index.js +7 -2
  22. package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -1
  23. package/dist/features/blocks/server/nodes/BlocksNode.d.ts +4 -5
  24. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  25. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  26. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +4 -5
  27. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  28. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  29. package/dist/features/converters/lexicalToHtml_deprecated/field/index.d.ts.map +1 -1
  30. package/dist/features/converters/lexicalToHtml_deprecated/field/index.js.map +1 -1
  31. package/dist/features/experimental_table/server/index.d.ts +5 -10
  32. package/dist/features/experimental_table/server/index.d.ts.map +1 -1
  33. package/dist/features/experimental_table/server/index.js.map +1 -1
  34. package/dist/features/heading/server/index.d.ts +3 -4
  35. package/dist/features/heading/server/index.d.ts.map +1 -1
  36. package/dist/features/heading/server/index.js.map +1 -1
  37. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +3 -5
  38. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  39. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  40. package/dist/features/link/nodes/types.d.ts +6 -6
  41. package/dist/features/link/nodes/types.d.ts.map +1 -1
  42. package/dist/features/link/nodes/types.js.map +1 -1
  43. package/dist/features/lists/plugin/index.d.ts +6 -7
  44. package/dist/features/lists/plugin/index.d.ts.map +1 -1
  45. package/dist/features/lists/plugin/index.js.map +1 -1
  46. package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
  47. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  48. package/dist/features/relationship/client/components/RelationshipComponent.js +1 -6
  49. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  50. package/dist/features/relationship/client/drawer/index.d.ts +3 -2
  51. package/dist/features/relationship/client/drawer/index.d.ts.map +1 -1
  52. package/dist/features/relationship/client/drawer/index.js +72 -59
  53. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  54. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  55. package/dist/features/relationship/client/plugins/index.js +41 -49
  56. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  57. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +13 -0
  58. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -0
  59. package/dist/features/relationship/client/utils/useEnabledRelationships.js +64 -0
  60. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -0
  61. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +3 -5
  62. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  63. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  64. package/dist/features/typesServer.d.ts +4 -4
  65. package/dist/features/typesServer.d.ts.map +1 -1
  66. package/dist/features/typesServer.js.map +1 -1
  67. package/dist/features/upload/client/component/index.d.ts +1 -1
  68. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  69. package/dist/features/upload/client/component/index.js +1 -11
  70. package/dist/features/upload/client/component/index.js.map +1 -1
  71. package/dist/features/upload/client/drawer/index.d.ts +3 -2
  72. package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
  73. package/dist/features/upload/client/drawer/index.js +8 -9
  74. package/dist/features/upload/client/drawer/index.js.map +1 -1
  75. package/dist/features/upload/client/index.d.ts +2 -1
  76. package/dist/features/upload/client/index.d.ts.map +1 -1
  77. package/dist/features/upload/client/index.js.map +1 -1
  78. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  79. package/dist/features/upload/client/plugin/index.js +72 -75
  80. package/dist/features/upload/client/plugin/index.js.map +1 -1
  81. package/dist/features/upload/server/index.d.ts +18 -3
  82. package/dist/features/upload/server/index.d.ts.map +1 -1
  83. package/dist/features/upload/server/index.js +6 -0
  84. package/dist/features/upload/server/index.js.map +1 -1
  85. package/dist/features/upload/server/nodes/UploadNode.d.ts +3 -5
  86. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  87. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  88. package/dist/field/RenderLexical/index.d.ts +2 -1
  89. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  90. package/dist/field/RenderLexical/index.js.map +1 -1
  91. package/dist/index.d.ts +1 -1
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +1 -1
  94. package/dist/index.js.map +1 -1
  95. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  96. package/dist/lexical/LexicalEditor.js +2 -1
  97. package/dist/lexical/LexicalEditor.js.map +1 -1
  98. package/dist/lexical/plugins/ClipboardPlugin/index.d.ts +2 -0
  99. package/dist/lexical/plugins/ClipboardPlugin/index.d.ts.map +1 -0
  100. package/dist/lexical/plugins/ClipboardPlugin/index.js +64 -0
  101. package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -0
  102. package/dist/nodeTypes.d.ts +46 -20
  103. package/dist/nodeTypes.d.ts.map +1 -1
  104. package/dist/nodeTypes.js.map +1 -1
  105. package/dist/types.d.ts +2 -1
  106. package/dist/types.d.ts.map +1 -1
  107. package/dist/types.js.map +1 -1
  108. package/dist/utilities/buildEditorState.d.ts +47 -6
  109. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  110. package/dist/utilities/buildEditorState.js +10 -1
  111. package/dist/utilities/buildEditorState.js.map +1 -1
  112. package/package.json +7 -6
  113. package/dist/exports/client/Field-CJFETHA3.js +0 -2
  114. package/dist/exports/client/Field-CJFETHA3.js.map +0 -7
  115. package/dist/exports/client/RelationshipComponent-TSIENULZ.js +0 -2
  116. package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +0 -7
  117. package/dist/exports/client/chunk-BQCXN3B4.js +0 -2
  118. package/dist/exports/client/component-CYFKY3IL.js +0 -2
  119. package/dist/exports/client/component-CYFKY3IL.js.map +0 -7
  120. package/dist/exports/client/componentInline-NGTRUSGB.js +0 -2
  121. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.d.ts +0 -7
  122. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.d.ts.map +0 -1
  123. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +0 -96
  124. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +0 -1
  125. /package/dist/exports/client/{componentInline-NGTRUSGB.js.map → componentInline-MIPTDFRK.js.map} +0 -0
@@ -4,10 +4,11 @@ import { c as _c } from "react/compiler-runtime";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
6
6
  import { $dfsIterator, $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils';
7
- import { useBulkUpload, useConfig, useEffectEvent, useModal } from '@payloadcms/ui';
7
+ import { useBulkUpload, useEffectEvent, useModal } from '@payloadcms/ui';
8
8
  import ObjectID from 'bson-objectid';
9
9
  import { $createRangeSelection, $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, $setSelection, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_LOW, createCommand, DROP_COMMAND, getDOMSelectionFromTarget, isHTMLElement, PASTE_COMMAND } from 'lexical';
10
10
  import React, { useEffect } from 'react';
11
+ import { useEnabledRelationships } from '../../../relationship/client/utils/useEnabledRelationships.js';
11
12
  import { UploadDrawer } from '../drawer/index.js';
12
13
  import { $createUploadNode, $isUploadNode, UploadNode } from '../nodes/UploadNode.js';
13
14
  function canDropImage(event) {
@@ -29,15 +30,30 @@ function getDragSelection(event) {
29
30
  return range;
30
31
  }
31
32
  export const INSERT_UPLOAD_COMMAND = createCommand('INSERT_UPLOAD_COMMAND');
32
- export const UploadPlugin = () => {
33
- const $ = _c(18);
34
- const [editor] = useLexicalComposerContext();
35
- const {
36
- config: t0
37
- } = useConfig();
33
+ export const UploadPlugin = t0 => {
34
+ const $ = _c(21);
38
35
  const {
39
- collections
36
+ clientProps
40
37
  } = t0;
38
+ const [editor] = useLexicalComposerContext();
39
+ const t1 = clientProps?.disabledCollections;
40
+ const t2 = clientProps?.enabledCollections;
41
+ let t3;
42
+ if ($[0] !== t1 || $[1] !== t2) {
43
+ t3 = {
44
+ collectionSlugsBlacklist: t1,
45
+ collectionSlugsWhitelist: t2,
46
+ uploads: true
47
+ };
48
+ $[0] = t1;
49
+ $[1] = t2;
50
+ $[2] = t3;
51
+ } else {
52
+ t3 = $[2];
53
+ }
54
+ const {
55
+ enabledCollectionSlugs
56
+ } = useEnabledRelationships(t3);
41
57
  const {
42
58
  drawerSlug: bulkUploadDrawerSlug,
43
59
  setCollectionSlug,
@@ -50,28 +66,27 @@ export const UploadPlugin = () => {
50
66
  isModalOpen,
51
67
  openModal
52
68
  } = useModal();
53
- let t1;
54
- if ($[0] !== bulkUploadDrawerSlug || $[1] !== collections || $[2] !== editor || $[3] !== isModalOpen || $[4] !== openModal || $[5] !== setCollectionSlug || $[6] !== setInitialForms || $[7] !== setOnCancel || $[8] !== setOnSuccess || $[9] !== setSelectableCollections) {
55
- t1 = t2 => {
69
+ let t4;
70
+ if ($[3] !== bulkUploadDrawerSlug || $[4] !== editor || $[5] !== enabledCollectionSlugs || $[6] !== isModalOpen || $[7] !== openModal || $[8] !== setCollectionSlug || $[9] !== setInitialForms || $[10] !== setOnCancel || $[11] !== setOnSuccess || $[12] !== setSelectableCollections) {
71
+ t4 = t5 => {
56
72
  const {
57
73
  files
58
- } = t2;
74
+ } = t5;
59
75
  if (files?.length === 0) {
60
76
  return;
61
77
  }
62
78
  setInitialForms(initialForms => [...(initialForms ?? []), ...files.map(_temp)]);
63
79
  if (!isModalOpen(bulkUploadDrawerSlug)) {
64
- const uploadCollections = collections.filter(_temp2).map(_temp3);
65
- if (!uploadCollections.length || !uploadCollections[0]) {
80
+ if (!enabledCollectionSlugs.length || !enabledCollectionSlugs[0]) {
66
81
  return;
67
82
  }
68
- setCollectionSlug(uploadCollections[0]);
69
- setSelectableCollections(uploadCollections);
83
+ setCollectionSlug(enabledCollectionSlugs[0]);
84
+ setSelectableCollections(enabledCollectionSlugs);
70
85
  setOnCancel(() => {
71
- editor.update(_temp4);
86
+ editor.update(_temp2);
72
87
  });
73
88
  setOnSuccess(newDocs => {
74
- const newDocsMap = new Map(newDocs.map(_temp5));
89
+ const newDocsMap = new Map(newDocs.map(_temp3));
75
90
  editor.update(() => {
76
91
  for (const dfsNode_0 of $dfsIterator()) {
77
92
  const node_0 = dfsNode_0.node;
@@ -97,24 +112,24 @@ export const UploadPlugin = () => {
97
112
  openModal(bulkUploadDrawerSlug);
98
113
  }
99
114
  };
100
- $[0] = bulkUploadDrawerSlug;
101
- $[1] = collections;
102
- $[2] = editor;
103
- $[3] = isModalOpen;
104
- $[4] = openModal;
105
- $[5] = setCollectionSlug;
106
- $[6] = setInitialForms;
107
- $[7] = setOnCancel;
108
- $[8] = setOnSuccess;
109
- $[9] = setSelectableCollections;
110
- $[10] = t1;
115
+ $[3] = bulkUploadDrawerSlug;
116
+ $[4] = editor;
117
+ $[5] = enabledCollectionSlugs;
118
+ $[6] = isModalOpen;
119
+ $[7] = openModal;
120
+ $[8] = setCollectionSlug;
121
+ $[9] = setInitialForms;
122
+ $[10] = setOnCancel;
123
+ $[11] = setOnSuccess;
124
+ $[12] = setSelectableCollections;
125
+ $[13] = t4;
111
126
  } else {
112
- t1 = $[10];
127
+ t4 = $[13];
113
128
  }
114
- const openBulkUpload = useEffectEvent(t1);
115
- let t2;
116
- if ($[11] !== editor || $[12] !== openBulkUpload) {
117
- t2 = () => {
129
+ const openBulkUpload = useEffectEvent(t4);
130
+ let t5;
131
+ if ($[14] !== editor || $[15] !== openBulkUpload) {
132
+ t5 = () => {
118
133
  if (!editor.hasNodes([UploadNode])) {
119
134
  throw new Error("UploadPlugin: UploadNode not registered on editor");
120
135
  }
@@ -123,7 +138,7 @@ export const UploadPlugin = () => {
123
138
  if (!nodeData_1?.pending) {
124
139
  return;
125
140
  }
126
- const upload_0 = async function upload() {
141
+ const upload = async function upload() {
127
142
  let transformedImage = null;
128
143
  const src = nodeData_1?.pending?.src;
129
144
  const formID = nodeData_1?.pending?.formID;
@@ -167,7 +182,7 @@ export const UploadPlugin = () => {
167
182
  files: [transformedImage]
168
183
  });
169
184
  };
170
- upload_0();
185
+ upload();
171
186
  }), editor.registerCommand(INSERT_UPLOAD_COMMAND, payload => {
172
187
  editor.update(() => {
173
188
  const selection = $getSelection() || $getPreviousSelection();
@@ -296,32 +311,32 @@ export const UploadPlugin = () => {
296
311
  return false;
297
312
  }, COMMAND_PRIORITY_LOW));
298
313
  };
299
- $[11] = editor;
300
- $[12] = openBulkUpload;
301
- $[13] = t2;
314
+ $[14] = editor;
315
+ $[15] = openBulkUpload;
316
+ $[16] = t5;
302
317
  } else {
303
- t2 = $[13];
318
+ t5 = $[16];
304
319
  }
305
- let t3;
306
- if ($[14] !== editor) {
307
- t3 = [editor];
308
- $[14] = editor;
309
- $[15] = t3;
320
+ let t6;
321
+ if ($[17] !== editor) {
322
+ t6 = [editor];
323
+ $[17] = editor;
324
+ $[18] = t6;
310
325
  } else {
311
- t3 = $[15];
326
+ t6 = $[18];
312
327
  }
313
- useEffect(t2, t3);
314
- let t4;
315
- if ($[16] !== collections) {
316
- t4 = _jsx(UploadDrawer, {
317
- enabledCollectionSlugs: collections.map(_temp6)
328
+ useEffect(t5, t6);
329
+ let t7;
330
+ if ($[19] !== enabledCollectionSlugs) {
331
+ t7 = _jsx(UploadDrawer, {
332
+ enabledCollectionSlugs
318
333
  });
319
- $[16] = collections;
320
- $[17] = t4;
334
+ $[19] = enabledCollectionSlugs;
335
+ $[20] = t7;
321
336
  } else {
322
- t4 = $[17];
337
+ t7 = $[20];
323
338
  }
324
- return t4;
339
+ return t7;
325
340
  };
326
341
  function _temp(file) {
327
342
  return {
@@ -329,19 +344,7 @@ function _temp(file) {
329
344
  formID: file.formID
330
345
  };
331
346
  }
332
- function _temp2(t0) {
333
- const {
334
- upload
335
- } = t0;
336
- return !!upload;
337
- }
338
- function _temp3(t0) {
339
- const {
340
- slug
341
- } = t0;
342
- return slug;
343
- }
344
- function _temp4() {
347
+ function _temp2() {
345
348
  for (const dfsNode of $dfsIterator()) {
346
349
  const node = dfsNode.node;
347
350
  if ($isUploadNode(node)) {
@@ -352,13 +355,7 @@ function _temp4() {
352
355
  }
353
356
  }
354
357
  }
355
- function _temp5(doc) {
358
+ function _temp3(doc) {
356
359
  return [doc.formID, doc];
357
360
  }
358
- function _temp6(t0) {
359
- const {
360
- slug: slug_0
361
- } = t0;
362
- return slug_0;
363
- }
364
361
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$dfsIterator","$insertNodeToNearestRoot","mergeRegister","useBulkUpload","useConfig","useEffectEvent","useModal","ObjectID","$createRangeSelection","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","$setSelection","COMMAND_PRIORITY_EDITOR","COMMAND_PRIORITY_LOW","createCommand","DROP_COMMAND","getDOMSelectionFromTarget","isHTMLElement","PASTE_COMMAND","React","useEffect","UploadDrawer","$createUploadNode","$isUploadNode","UploadNode","canDropImage","event","target","closest","parentElement","getDragSelection","range","domSelection","document","caretRangeFromPoint","clientX","clientY","rangeParent","collapse","rangeOffset","getRangeAt","Error","INSERT_UPLOAD_COMMAND","UploadPlugin","$","editor","config","t0","collections","drawerSlug","bulkUploadDrawerSlug","setCollectionSlug","setInitialForms","setOnCancel","setOnSuccess","setSelectableCollections","isModalOpen","openModal","t1","t2","files","length","initialForms","map","_temp","uploadCollections","filter","_temp2","_temp3","update","_temp4","newDocs","newDocsMap","Map","_temp5","dfsNode_0","node_0","dfsNode","node","nodeData_0","getData","nodeData","pending","newDoc","get","formID","replace","data","id","default","toHexString","fields","relationTo","collectionSlug","value","doc","openBulkUpload","hasNodes","registerNodeTransform","node_1","nodeData_1","upload_0","upload","transformedImage","src","startsWith","mimeMatch","match","mimeType","base64Data","byteCharacters","atob","byteNumbers","Array","i","charCodeAt","byteArray","Uint8Array","file_0","File","split","type","file","res","fetch","blob","inferredFileName","pop","file_1","registerCommand","payload","selection","uploadNode","focus","focusNode","getNode","__first","remove","ClipboardEvent","clipboardData","types","includes","files_0","from","forEach","file_2","push","alt","selection_0","file_3","pendingUploadNode","URL","createObjectURL","focus_0","focusNode_0","event_0","DragEvent","dt","dataTransfer","files_1","file_4","preventDefault","stopPropagation","selection_1","undefined","applyDOMRange","file_5","pendingUploadNode_0","focus_1","focusNode_1","t3","t4","_jsx","enabledCollectionSlugs","_temp6","slug","slug_0"],"sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $dfsIterator, $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport { useBulkUpload, useConfig, useEffectEvent, useModal } from '@payloadcms/ui'\nimport ObjectID from 'bson-objectid'\nimport {\n $createRangeSelection,\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n createCommand,\n DROP_COMMAND,\n getDOMSelectionFromTarget,\n isHTMLElement,\n PASTE_COMMAND,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { Internal_UploadData, UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\n\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, $isUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>>\n\ndeclare global {\n interface DragEvent {\n rangeOffset?: number\n rangeParent?: Node\n }\n}\n\nfunction canDropImage(event: DragEvent): boolean {\n const target = event.target\n return !!(\n isHTMLElement(target) &&\n !target.closest('code, span.editor-image') &&\n isHTMLElement(target.parentElement) &&\n target.parentElement.closest('div.ContentEditable__root')\n )\n}\n\nfunction getDragSelection(event: DragEvent): null | Range | undefined {\n // Source: https://github.com/AlessioGr/lexical/blob/main/packages/lexical-playground/src/plugins/ImagesPlugin/index.tsx\n let range\n const domSelection = getDOMSelectionFromTarget(event.target)\n if (document.caretRangeFromPoint) {\n range = document.caretRangeFromPoint(event.clientX, event.clientY)\n } else if (event.rangeParent && domSelection !== null) {\n domSelection.collapse(event.rangeParent, event.rangeOffset || 0)\n range = domSelection.getRangeAt(0)\n } else {\n throw Error(`Cannot get the selection when dragging`)\n }\n\n return range\n}\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\ntype FileToUpload = {\n alt?: string\n file: File\n /**\n * Bulk Upload Form ID that should be created, which can then be matched\n * against the node formID if the upload is successful\n */\n formID: string\n}\n\nexport const UploadPlugin: PluginComponent<UploadFeaturePropsClient> = () => {\n const [editor] = useLexicalComposerContext()\n const {\n config: { collections },\n } = useConfig()\n\n const {\n drawerSlug: bulkUploadDrawerSlug,\n setCollectionSlug,\n setInitialForms,\n setOnCancel,\n setOnSuccess,\n setSelectableCollections,\n } = useBulkUpload()\n\n const { isModalOpen, openModal } = useModal()\n\n const openBulkUpload = useEffectEvent(({ files }: { files: FileToUpload[] }) => {\n if (files?.length === 0) {\n return\n }\n\n setInitialForms((initialForms) => [\n ...(initialForms ?? []),\n ...files.map((file) => ({\n file: file.file,\n formID: file.formID,\n })),\n ])\n\n if (!isModalOpen(bulkUploadDrawerSlug)) {\n const uploadCollections = collections.filter(({ upload }) => !!upload).map(({ slug }) => slug)\n if (!uploadCollections.length || !uploadCollections[0]) {\n return\n }\n\n setCollectionSlug(uploadCollections[0])\n setSelectableCollections(uploadCollections)\n\n setOnCancel(() => {\n // Remove all the pending upload nodes that were added but not uploaded\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n\n if ($isUploadNode(node)) {\n const nodeData = node.getData()\n if ((nodeData as Internal_UploadData)?.pending) {\n node.remove()\n }\n }\n }\n })\n })\n\n setOnSuccess((newDocs) => {\n const newDocsMap = new Map(newDocs.map((doc) => [doc.formID, doc]))\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n if ($isUploadNode(node)) {\n const nodeData: Internal_UploadData = node.getData()\n\n if (nodeData?.pending) {\n const newDoc = newDocsMap.get(nodeData.pending?.formID)\n if (newDoc) {\n node.replace(\n $createUploadNode({\n data: {\n id: new ObjectID.default().toHexString(),\n fields: {},\n relationTo: newDoc.collectionSlug,\n value: newDoc.doc.id,\n } as UploadData,\n }),\n )\n }\n }\n }\n }\n })\n })\n\n openModal(bulkUploadDrawerSlug)\n }\n })\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n /**\n * Handle auto-uploading files if you copy & paste an image dom element from the clipboard\n */\n editor.registerNodeTransform(UploadNode, (node) => {\n const nodeData: Internal_UploadData = node.getData()\n if (!nodeData?.pending) {\n return\n }\n\n async function upload() {\n let transformedImage: FileToUpload | null = null\n\n const src = nodeData?.pending?.src\n const formID = nodeData?.pending?.formID as string\n\n if (src?.startsWith('data:')) {\n // It's a base64-encoded image\n const mimeMatch = src.match(/data:(image\\/[a-zA-Z]+);base64,/)\n const mimeType = mimeMatch ? mimeMatch[1] : 'image/png' // Default to PNG if MIME type not found\n const base64Data = src.replace(/^data:image\\/[a-zA-Z]+;base64,/, '')\n const byteCharacters = atob(base64Data)\n const byteNumbers = new Array(byteCharacters.length)\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i)\n }\n const byteArray = new Uint8Array(byteNumbers)\n const file = new File([byteArray], 'pasted-image.' + mimeType?.split('/')[1], {\n type: mimeType,\n })\n transformedImage = { alt: undefined, file, formID }\n } else if (src?.startsWith('http') || src?.startsWith('https')) {\n // It's an image URL\n const res = await fetch(src)\n const blob = await res.blob()\n const inferredFileName =\n src.split('/').pop() || 'pasted-image' + blob.type.split('/')[1]\n const file = new File([blob], inferredFileName, {\n type: blob.type,\n })\n\n transformedImage = { alt: undefined, file, formID }\n }\n\n if (!transformedImage) {\n return\n }\n\n openBulkUpload({ files: [transformedImage] })\n }\n void upload()\n }),\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const uploadNode = $createUploadNode({\n data: {\n id: payload.id,\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: payload.value,\n },\n })\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(uploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n PASTE_COMMAND,\n (event) => {\n // Pending UploadNodes are automatically created when importDOM is called. However, if you paste a file from your computer\n // directly, importDOM won't be called, as it's not a HTML dom element. So we need to handle that case here.\n\n if (!(event instanceof ClipboardEvent)) {\n return false\n }\n const clipboardData = event.clipboardData\n\n if (!clipboardData?.types?.length || clipboardData?.types?.includes('text/html')) {\n // HTML is handled through importDOM => registerNodeTransform for pending UploadNode\n return false\n }\n\n const files: FileToUpload[] = []\n if (clipboardData?.files?.length) {\n Array.from(clipboardData.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Insert a pending UploadNode for each image\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n for (const file of files) {\n const pendingUploadNode = new UploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n // Handle drag & drop of files from the desktop into the editor\n editor.registerCommand(\n DROP_COMMAND,\n (event) => {\n if (!(event instanceof DragEvent)) {\n return false\n }\n\n const dt = event.dataTransfer\n\n if (!dt?.types?.length) {\n return false\n }\n\n const files: FileToUpload[] = []\n if (dt?.files?.length) {\n Array.from(dt.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Prevent the default browser drop handling, which would open the file in the browser\n event.preventDefault()\n event.stopPropagation()\n\n // Insert a PendingUploadNode for each image\n editor.update(() => {\n if (canDropImage(event)) {\n const range = getDragSelection(event)\n const selection = $createRangeSelection()\n if (range !== null && range !== undefined) {\n selection.applyDOMRange(range)\n }\n $setSelection(selection)\n\n for (const file of files) {\n const pendingUploadNode = new UploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_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AA8B;IAAA,C;;;;;;SAApEH,E;CACT;AA/TuE,SAAA3G,MAAA0D,IAAA;EAAA;IAAAA,IAAA,EAyBzDA,IAAA,CAAAA,IAAA;IAAArC,MAAA,EACEqC,IAAA,CAAArC;EAAA;AAAA;AA1BuD,SAAAlB,OAAApB,EAAA;EA+BnB;IAAAuD;EAAA,IAAAvD,EAAU;EAAA,SAAOuD,MAAA;AAAA;AA/BE,SAAAlC,OAAArB,EAAA;EA+BW;IAAAgI;EAAA,IAAAhI,EAAQ;EAAA,OAAKgI,IAAA;AAAA;AA/BxB,SAAAzG,OAAA;EAAA,KA0CxD,MAAAO,OAAM,IAAW/E,YAAA;IACpB,MAAAgF,IAAA,GAAaD,OAAA,CAAAC,IAAA;IAAY,IAErBvD,aAAA,CAAcuD,IAAA;MAChB,MAAAG,QAAA,GAAiBH,IAAA,CAAAE,OAAA,CAAY;MAAA,IACxBC,QAAA,EAAAC,OAAA;QACHJ,IAAA,CAAA2D,MAAA,CAAW;MAAA;IAAA;EAAA;AAAA;AAhD4C,SAAA/D,OAAAqB,GAAA;EAAA,QAwDdA,GAAA,CAAAV,MAAA,EAAYU,GAAA;AAAA;AAxDE,SAAA+E,OAAA/H,EAAA;EA8TP;IAAAgI,IAAA,EAAAC;EAAA,IAAAjI,EAAQ;EAAA,OAAKgI,MAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$dfsIterator","$insertNodeToNearestRoot","mergeRegister","useBulkUpload","useEffectEvent","useModal","ObjectID","$createRangeSelection","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","$setSelection","COMMAND_PRIORITY_EDITOR","COMMAND_PRIORITY_LOW","createCommand","DROP_COMMAND","getDOMSelectionFromTarget","isHTMLElement","PASTE_COMMAND","React","useEffect","useEnabledRelationships","UploadDrawer","$createUploadNode","$isUploadNode","UploadNode","canDropImage","event","target","closest","parentElement","getDragSelection","range","domSelection","document","caretRangeFromPoint","clientX","clientY","rangeParent","collapse","rangeOffset","getRangeAt","Error","INSERT_UPLOAD_COMMAND","UploadPlugin","t0","$","clientProps","editor","t1","disabledCollections","t2","enabledCollections","t3","collectionSlugsBlacklist","collectionSlugsWhitelist","uploads","enabledCollectionSlugs","drawerSlug","bulkUploadDrawerSlug","setCollectionSlug","setInitialForms","setOnCancel","setOnSuccess","setSelectableCollections","isModalOpen","openModal","t4","t5","files","length","initialForms","map","_temp","update","_temp2","newDocs","newDocsMap","Map","_temp3","dfsNode_0","node_0","dfsNode","node","nodeData_0","getData","nodeData","pending","newDoc","get","formID","replace","data","id","default","toHexString","fields","relationTo","collectionSlug","value","doc","openBulkUpload","hasNodes","registerNodeTransform","node_1","nodeData_1","upload","transformedImage","src","startsWith","mimeMatch","match","mimeType","base64Data","byteCharacters","atob","byteNumbers","Array","i","charCodeAt","byteArray","Uint8Array","file_0","File","split","type","file","res","fetch","blob","inferredFileName","pop","file_1","registerCommand","payload","selection","uploadNode","focus","focusNode","getNode","__first","remove","ClipboardEvent","clipboardData","types","includes","files_0","from","forEach","file_2","push","alt","selection_0","file_3","pendingUploadNode","URL","createObjectURL","focus_0","focusNode_0","event_0","DragEvent","dt","dataTransfer","files_1","file_4","preventDefault","stopPropagation","selection_1","undefined","applyDOMRange","file_5","pendingUploadNode_0","focus_1","focusNode_1","t6","t7","_jsx"],"sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $dfsIterator, $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport { useBulkUpload, useEffectEvent, useModal } from '@payloadcms/ui'\nimport ObjectID from 'bson-objectid'\nimport {\n $createRangeSelection,\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n createCommand,\n DROP_COMMAND,\n getDOMSelectionFromTarget,\n isHTMLElement,\n PASTE_COMMAND,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { Internal_UploadData, UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\n\nimport { useEnabledRelationships } from '../../../relationship/client/utils/useEnabledRelationships.js'\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, $isUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>>\n\ndeclare global {\n interface DragEvent {\n rangeOffset?: number\n rangeParent?: Node\n }\n}\n\nfunction canDropImage(event: DragEvent): boolean {\n const target = event.target\n return !!(\n isHTMLElement(target) &&\n !target.closest('code, span.editor-image') &&\n isHTMLElement(target.parentElement) &&\n target.parentElement.closest('div.ContentEditable__root')\n )\n}\n\nfunction getDragSelection(event: DragEvent): null | Range | undefined {\n // Source: https://github.com/AlessioGr/lexical/blob/main/packages/lexical-playground/src/plugins/ImagesPlugin/index.tsx\n let range\n const domSelection = getDOMSelectionFromTarget(event.target)\n if (document.caretRangeFromPoint) {\n range = document.caretRangeFromPoint(event.clientX, event.clientY)\n } else if (event.rangeParent && domSelection !== null) {\n domSelection.collapse(event.rangeParent, event.rangeOffset || 0)\n range = domSelection.getRangeAt(0)\n } else {\n throw Error(`Cannot get the selection when dragging`)\n }\n\n return range\n}\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\ntype FileToUpload = {\n alt?: string\n file: File\n /**\n * Bulk Upload Form ID that should be created, which can then be matched\n * against the node formID if the upload is successful\n */\n formID: string\n}\n\nexport const UploadPlugin: PluginComponent<UploadFeaturePropsClient> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n\n const { enabledCollectionSlugs } = useEnabledRelationships({\n collectionSlugsBlacklist: clientProps?.disabledCollections,\n collectionSlugsWhitelist: clientProps?.enabledCollections,\n uploads: true,\n })\n\n const {\n drawerSlug: bulkUploadDrawerSlug,\n setCollectionSlug,\n setInitialForms,\n setOnCancel,\n setOnSuccess,\n setSelectableCollections,\n } = useBulkUpload()\n\n const { isModalOpen, openModal } = useModal()\n\n const openBulkUpload = useEffectEvent(({ files }: { files: FileToUpload[] }) => {\n if (files?.length === 0) {\n return\n }\n\n setInitialForms((initialForms) => [\n ...(initialForms ?? []),\n ...files.map((file) => ({\n file: file.file,\n formID: file.formID,\n })),\n ])\n\n if (!isModalOpen(bulkUploadDrawerSlug)) {\n if (!enabledCollectionSlugs.length || !enabledCollectionSlugs[0]) {\n return\n }\n\n setCollectionSlug(enabledCollectionSlugs[0])\n setSelectableCollections(enabledCollectionSlugs)\n\n setOnCancel(() => {\n // Remove all the pending upload nodes that were added but not uploaded\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n\n if ($isUploadNode(node)) {\n const nodeData = node.getData()\n if ((nodeData as Internal_UploadData)?.pending) {\n node.remove()\n }\n }\n }\n })\n })\n\n setOnSuccess((newDocs) => {\n const newDocsMap = new Map(newDocs.map((doc) => [doc.formID, doc]))\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n if ($isUploadNode(node)) {\n const nodeData: Internal_UploadData = node.getData()\n\n if (nodeData?.pending) {\n const newDoc = newDocsMap.get(nodeData.pending?.formID)\n if (newDoc) {\n node.replace(\n $createUploadNode({\n data: {\n id: new ObjectID.default().toHexString(),\n fields: {},\n relationTo: newDoc.collectionSlug,\n value: newDoc.doc.id,\n } as UploadData,\n }),\n )\n }\n }\n }\n }\n })\n })\n\n openModal(bulkUploadDrawerSlug)\n }\n })\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n /**\n * Handle auto-uploading files if you copy & paste an image dom element from the clipboard\n */\n editor.registerNodeTransform(UploadNode, (node) => {\n const nodeData: Internal_UploadData = node.getData()\n if (!nodeData?.pending) {\n return\n }\n\n async function upload() {\n let transformedImage: FileToUpload | null = null\n\n const src = nodeData?.pending?.src\n const formID = nodeData?.pending?.formID as string\n\n if (src?.startsWith('data:')) {\n // It's a base64-encoded image\n const mimeMatch = src.match(/data:(image\\/[a-zA-Z]+);base64,/)\n const mimeType = mimeMatch ? mimeMatch[1] : 'image/png' // Default to PNG if MIME type not found\n const base64Data = src.replace(/^data:image\\/[a-zA-Z]+;base64,/, '')\n const byteCharacters = atob(base64Data)\n const byteNumbers = new Array(byteCharacters.length)\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i)\n }\n const byteArray = new Uint8Array(byteNumbers)\n const file = new File([byteArray], 'pasted-image.' + mimeType?.split('/')[1], {\n type: mimeType,\n })\n transformedImage = { alt: undefined, file, formID }\n } else if (src?.startsWith('http') || src?.startsWith('https')) {\n // It's an image URL\n const res = await fetch(src)\n const blob = await res.blob()\n const inferredFileName =\n src.split('/').pop() || 'pasted-image' + blob.type.split('/')[1]\n const file = new File([blob], inferredFileName, {\n type: blob.type,\n })\n\n transformedImage = { alt: undefined, file, formID }\n }\n\n if (!transformedImage) {\n return\n }\n\n openBulkUpload({ files: [transformedImage] })\n }\n void upload()\n }),\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const uploadNode = $createUploadNode({\n data: {\n id: payload.id,\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: payload.value,\n },\n })\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(uploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n PASTE_COMMAND,\n (event) => {\n // Pending UploadNodes are automatically created when importDOM is called. However, if you paste a file from your computer\n // directly, importDOM won't be called, as it's not a HTML dom element. So we need to handle that case here.\n\n if (!(event instanceof ClipboardEvent)) {\n return false\n }\n const clipboardData = event.clipboardData\n\n if (!clipboardData?.types?.length || clipboardData?.types?.includes('text/html')) {\n // HTML is handled through importDOM => registerNodeTransform for pending UploadNode\n return false\n }\n\n const files: FileToUpload[] = []\n if (clipboardData?.files?.length) {\n Array.from(clipboardData.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Insert a pending UploadNode for each image\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n for (const file of files) {\n const pendingUploadNode = new UploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n // Handle drag & drop of files from the desktop into the editor\n editor.registerCommand(\n DROP_COMMAND,\n (event) => {\n if (!(event instanceof DragEvent)) {\n return false\n }\n\n const dt = event.dataTransfer\n\n if (!dt?.types?.length) {\n return false\n }\n\n const files: FileToUpload[] = []\n if (dt?.files?.length) {\n Array.from(dt.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Prevent the default browser drop handling, which would open the file in the browser\n event.preventDefault()\n event.stopPropagation()\n\n // Insert a PendingUploadNode for each image\n editor.update(() => {\n if (canDropImage(event)) {\n const range = getDragSelection(event)\n const selection = $createRangeSelection()\n if (range !== null && range !== undefined) {\n selection.applyDOMRange(range)\n }\n $setSelection(selection)\n\n for (const file of files) {\n const pendingUploadNode = new UploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,YAAY,EAAEC,wBAAwB,EAAEC,aAAa,QAAQ;AACtE,SAASC,aAAa,EAAEC,cAAc,EAAEC,QAAQ,QAAQ;AACxD,OAAOC,QAAA,MAAc;AACrB,SACEC,qBAAqB,EACrBC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,aAAa,EACbC,uBAAuB,EACvBC,oBAAoB,EACpBC,aAAa,EACbC,YAAY,EACZC,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A7BuD,SAAAf,OAAA;EAAA,KA4CxD,MAAAO,OAAM,IAAWnF,YAAA;IACpB,MAAAoF,IAAA,GAAaD,OAAA,CAAAC,IAAA;IAAY,IAErB3D,aAAA,CAAc2D,IAAA;MAChB,MAAAG,QAAA,GAAiBH,IAAA,CAAAE,OAAA,CAAY;MAAA,IACxBC,QAAA,EAAAC,OAAA;QACHJ,IAAA,CAAA0D,MAAA,CAAW;MAAA;IAAA;EAAA;AAAA;AAlD4C,SAAA9D,OAAAqB,GAAA;EAAA,QA0DdA,GAAA,CAAAV,MAAA,EAAYU,GAAA;AAAA","ignoreList":[]}
@@ -1,8 +1,23 @@
1
- import type { CollectionSlug, Field } from 'payload';
1
+ import type { Field, UploadCollectionSlug } from 'payload';
2
2
  import type { UploadFeaturePropsClient } from '../client/index.js';
3
+ export type ExclusiveUploadFeatureProps = {
4
+ /**
5
+ * The collections that should be disabled. Overrides the `enableRichTextRelationship` property in the collection config.
6
+ * When this property is set, `enabledCollections` will not be available.
7
+ **/
8
+ disabledCollections?: UploadCollectionSlug[];
9
+ enabledCollections?: never;
10
+ } | {
11
+ disabledCollections?: never;
12
+ /**
13
+ * The collections that should be enabled. Overrides the `enableRichTextRelationship` property in the collection config
14
+ * When this property is set, `disabledCollections` will not be available.
15
+ **/
16
+ enabledCollections?: UploadCollectionSlug[];
17
+ };
3
18
  export type UploadFeatureProps = {
4
19
  collections?: {
5
- [collection: CollectionSlug]: {
20
+ [collection: UploadCollectionSlug]: {
6
21
  fields: Field[];
7
22
  };
8
23
  };
@@ -13,6 +28,6 @@ export type UploadFeatureProps = {
13
28
  * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}
14
29
  */
15
30
  maxDepth?: number;
16
- };
31
+ } & ExclusiveUploadFeatureProps;
17
32
  export declare const UploadFeature: import("../../typesServer.js").FeatureProviderProviderServer<UploadFeatureProps, UploadFeatureProps, UploadFeaturePropsClient>;
18
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,KAAK,EAMN,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAUlE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,CAAC,EAAE;QACZ,CAAC,UAAU,EAAE,cAAc,GAAG;YAC5B,MAAM,EAAE,KAAK,EAAE,CAAA;SAChB,CAAA;KACF,CAAA;IACD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AASD,eAAO,MAAM,aAAa,gIAiPxB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,KAAK,EAML,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAUlE,MAAM,MAAM,2BAA2B,GACnC;IACE;;;QAGI;IACJ,mBAAmB,CAAC,EAAE,oBAAoB,EAAE,CAAA;IAG5C,kBAAkB,CAAC,EAAE,KAAK,CAAA;CAC3B,GACD;IAEE,mBAAmB,CAAC,EAAE,KAAK,CAAA;IAE3B;;;QAGI;IACJ,kBAAkB,CAAC,EAAE,oBAAoB,EAAE,CAAA;CAC5C,CAAA;AAEL,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,CAAC,EAAE;QACZ,CAAC,UAAU,EAAE,oBAAoB,GAAG;YAClC,MAAM,EAAE,KAAK,EAAE,CAAA;SAChB,CAAA;KACF,CAAA;IACD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,2BAA2B,CAAA;AAS/B,eAAO,MAAM,aAAa,gIAwPxB,CAAA"}
@@ -27,6 +27,12 @@ export const UploadFeature = createServerFeature({
27
27
  const clientProps = {
28
28
  collections: {}
29
29
  };
30
+ if (props.disabledCollections) {
31
+ clientProps.disabledCollections = props.disabledCollections;
32
+ }
33
+ if (props.enabledCollections) {
34
+ clientProps.enabledCollections = props.enabledCollections;
35
+ }
30
36
  if (props.collections) {
31
37
  for (const collection in props.collections) {
32
38
  clientProps.collections[collection] = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["sanitizeFields","populate","createServerFeature","createNode","uploadPopulationPromiseHOC","i18n","UploadServerNode","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","feature","_config","isRoot","parentIsLocalized","props","collections","clientProps","collection","hasExtraFields","fields","length","validRelationships","map","c","slug","collectionKey","requireFieldLevelRichTextEditor","ClientFeature","clientFeatureProps","generateSchemaMap","schemaMap","Map","set","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","req","showHiddenFields","id","value","uploadDocument","collectionSlug","relationTo","data","key","ignored","console","error","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","getSubFields","allSubFields","collectionFields","concat","collectionFieldSchema","Array","isArray","getSubFieldsData","graphQLPopulationPromises","hooks","afterRead","populateArg","populationPromises","populateDepth","maxDepth","undefined","push","select","defaultPopulate","validations","sanitizedServerFeatureProps"],"sources":["../../../../src/features/upload/server/index.ts"],"sourcesContent":["import type {\n CollectionSlug,\n Config,\n Field,\n FieldSchemaMap,\n FileData,\n FileSizeImproved,\n Payload,\n TypeWithID,\n} from 'payload'\n\nimport { sanitizeFields } from 'payload'\n\nimport type { UploadFeaturePropsClient } from '../client/index.js'\n\nimport { populate } from '../../../populateGraphQL/populate.js'\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { uploadPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { UploadServerNode } from './nodes/UploadNode.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections?: {\n [collection: CollectionSlug]: {\n fields: Field[]\n }\n }\n /**\n * Sets a maximum population depth for this upload (not the fields for this upload), regardless of the remaining depth when the respective field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n}\n\n/**\n * Get the absolute URL for an upload URL by potentially prepending the serverURL\n */\nfunction getAbsoluteURL(url: string, payload: Payload): string {\n return url?.startsWith('http') ? url : (payload?.config?.serverURL || '') + url\n}\n\nexport const UploadFeature = createServerFeature<\n UploadFeatureProps,\n UploadFeatureProps,\n UploadFeaturePropsClient\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = {\n collections: {},\n }\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection]!.fields.length >= 1,\n }\n }\n }\n\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n for (const collectionKey in props.collections) {\n const collection = props.collections[collectionKey]!\n if (collection.fields?.length) {\n collection.fields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: collection.fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n }\n }\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#UploadFeatureClient',\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ props }) => {\n if (!props?.collections) {\n return null\n }\n\n const schemaMap: FieldSchemaMap = new Map()\n\n for (const collectionKey in props.collections) {\n const collection = props.collections[collectionKey]!\n if (collection.fields?.length) {\n schemaMap.set(collectionKey, {\n fields: collection.fields,\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n req,\n showHiddenFields,\n }) => {\n // @ts-expect-error - for backwards-compatibility\n const id = node?.value?.id || node?.value\n\n if (req?.payload) {\n const uploadDocument: {\n value?: FileData & TypeWithID\n } = {}\n\n try {\n await populate({\n id,\n collectionSlug: node.relationTo,\n currentDepth,\n data: uploadDocument,\n depth,\n draft,\n key: 'value',\n overrideAccess,\n req,\n showHiddenFields,\n })\n } catch (ignored) {\n // eslint-disable-next-line no-console\n console.error(\n 'Lexical upload node HTML converter: error fetching upload file',\n ignored,\n 'Node:',\n node,\n )\n return `<img />`\n }\n\n const url = getAbsoluteURL(uploadDocument?.value?.url ?? '', req?.payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument?.value?.mimeType?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.value?.filename}</a>`\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (\n !uploadDocument?.value?.sizes ||\n !Object.keys(uploadDocument?.value?.sizes).length\n ) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.value?.filename}\" width=\"${uploadDocument?.value?.width}\" height=\"${uploadDocument?.value?.height}\"/>`\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n let pictureHTML = '<picture>'\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.value?.sizes) {\n const imageSize = uploadDocument.value.sizes[size] as FileSizeImproved\n\n // Skip if any property of the size object is null\n if (\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL = getAbsoluteURL(imageSize?.url, req?.payload)\n\n pictureHTML += `<source srcset=\"${imageSizeURL}\" media=\"(max-width: ${imageSize.width}px)\" type=\"${imageSize.mimeType}\">`\n }\n\n // Add the default img tag\n pictureHTML += `<img src=\"${url}\" alt=\"Image\" width=\"${uploadDocument.value?.width}\" height=\"${uploadDocument.value?.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${id}\" />`\n }\n },\n nodeTypes: [UploadServerNode.getType()],\n },\n },\n getSubFields: ({ node, req }) => {\n if (!node) {\n let allSubFields: Field[] = []\n for (const collection in props?.collections) {\n const collectionFields = props.collections[collection]!.fields\n allSubFields = allSubFields.concat(collectionFields)\n }\n return allSubFields\n }\n const collection = req ? req.payload.collections[node?.relationTo] : null\n\n if (collection) {\n const collectionFieldSchema = props?.collections?.[node?.relationTo]?.fields\n\n if (Array.isArray(collectionFieldSchema)) {\n if (!collectionFieldSchema?.length) {\n return null\n }\n return collectionFieldSchema\n }\n }\n return null\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [uploadPopulationPromiseHOC(props)],\n hooks: {\n afterRead: [\n ({\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n if (!node?.value) {\n return node\n }\n const collection = req.payload.collections[node?.relationTo]\n\n if (!collection) {\n return node\n }\n // @ts-expect-error - Fix in Payload v4\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n const populateDepth =\n props?.maxDepth !== undefined && props?.maxDepth < depth ? props?.maxDepth : depth\n\n populationPromises.push(\n populate({\n id,\n collectionSlug: collection.config.slug,\n currentDepth,\n data: node,\n depth: populateDepth,\n draft,\n key: 'value',\n overrideAccess,\n req,\n select:\n populateArg?.[collection.config.slug] ?? collection.config.defaultPopulate,\n showHiddenFields,\n }),\n )\n\n return node\n },\n ],\n },\n node: UploadServerNode,\n validations: [uploadValidation(props)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'upload',\n})\n"],"mappings":"AAWA,SAASA,cAAc,QAAQ;AAI/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,IAAI,QAAQ;AACrB,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,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ZC,KAAK;YACLC,KAAK;YACLC,IAAI;YACJC,cAAc;YACdsC,WAAW;YACXC,kBAAkB;YAClBtC,GAAG;YACHC;UAAgB,CACjB;YACC,IAAI,CAACH,IAAA,EAAMK,KAAA,EAAO;cAChB,OAAOL,IAAA;YACT;YACA,MAAMvB,UAAA,GAAayB,GAAA,CAAIrC,OAAO,CAACU,WAAW,CAACyB,IAAA,EAAMQ,UAAA,CAAW;YAE5D,IAAI,CAAC/B,UAAA,EAAY;cACf,OAAOuB,IAAA;YACT;YACA;YACA,MAAMI,EAAA,GAAKJ,IAAA,EAAMK,KAAA,EAAOD,EAAA,IAAMJ,IAAA,EAAMK,KAAA,CAAM;YAAA;YAE1C,MAAMoC,aAAA,GACJnE,KAAA,EAAOoE,QAAA,KAAaC,SAAA,IAAarE,KAAA,EAAOoE,QAAA,GAAW5C,KAAA,GAAQxB,KAAA,EAAOoE,QAAA,GAAW5C,KAAA;YAE/E0C,kBAAA,CAAmBI,IAAI,CACrBxF,QAAA,CAAS;cACPgD,EAAA;cACAG,cAAA,EAAgB9B,UAAA,CAAWV,MAAM,CAACiB,IAAI;cACtCa,YAAA;cACAY,IAAA,EAAMT,IAAA;cACNF,KAAA,EAAO2C,aAAA;cACP1C,KAAA;cACAW,GAAA,EAAK;cACLT,cAAA;cACAC,GAAA;cACA2C,MAAA,EACEN,WAAA,GAAc9D,UAAA,CAAWV,MAAM,CAACiB,IAAI,CAAC,IAAIP,UAAA,CAAWV,MAAM,CAAC+E,eAAe;cAC5E3C;YACF;YAGF,OAAOH,IAAA;UACT;QAEJ;QACAA,IAAA,EAAMvC,gBAAA;QACNsF,WAAA,EAAa,CAACrF,gBAAA,CAAiBY,KAAA;MACjC,GACD;MACD0E,2BAAA,EAA6B1E;IAC/B;EACF;EACAoC,GAAA,EAAK;AACP","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["sanitizeFields","populate","createServerFeature","createNode","uploadPopulationPromiseHOC","i18n","UploadServerNode","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","feature","_config","isRoot","parentIsLocalized","props","collections","clientProps","disabledCollections","enabledCollections","collection","hasExtraFields","fields","length","validRelationships","map","c","slug","collectionKey","requireFieldLevelRichTextEditor","ClientFeature","clientFeatureProps","generateSchemaMap","schemaMap","Map","set","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","req","showHiddenFields","id","value","uploadDocument","collectionSlug","relationTo","data","key","ignored","console","error","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","getSubFields","allSubFields","collectionFields","concat","collectionFieldSchema","Array","isArray","getSubFieldsData","graphQLPopulationPromises","hooks","afterRead","populateArg","populationPromises","populateDepth","maxDepth","undefined","push","select","defaultPopulate","validations","sanitizedServerFeatureProps"],"sources":["../../../../src/features/upload/server/index.ts"],"sourcesContent":["import type {\n Config,\n Field,\n FieldSchemaMap,\n FileData,\n FileSizeImproved,\n Payload,\n TypeWithID,\n UploadCollectionSlug,\n} from 'payload'\n\nimport { sanitizeFields } from 'payload'\n\nimport type { UploadFeaturePropsClient } from '../client/index.js'\n\nimport { populate } from '../../../populateGraphQL/populate.js'\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { uploadPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { UploadServerNode } from './nodes/UploadNode.js'\nimport { uploadValidation } from './validate.js'\n\nexport type ExclusiveUploadFeatureProps =\n | {\n /**\n * The collections that should be disabled. Overrides the `enableRichTextRelationship` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: UploadCollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled. Overrides the `enableRichTextRelationship` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: UploadCollectionSlug[]\n }\n\nexport type UploadFeatureProps = {\n collections?: {\n [collection: UploadCollectionSlug]: {\n fields: Field[]\n }\n }\n /**\n * Sets a maximum population depth for this upload (not the fields for this upload), regardless of the remaining depth when the respective field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveUploadFeatureProps\n\n/**\n * Get the absolute URL for an upload URL by potentially prepending the serverURL\n */\nfunction getAbsoluteURL(url: string, payload: Payload): string {\n return url?.startsWith('http') ? url : (payload?.config?.serverURL || '') + url\n}\n\nexport const UploadFeature = createServerFeature<\n UploadFeatureProps,\n UploadFeatureProps,\n UploadFeaturePropsClient\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = {\n collections: {},\n }\n if (props.disabledCollections) {\n clientProps.disabledCollections = props.disabledCollections\n }\n if (props.enabledCollections) {\n clientProps.enabledCollections = props.enabledCollections\n }\n\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection]!.fields.length >= 1,\n }\n }\n }\n\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n for (const collectionKey in props.collections) {\n const collection = props.collections[collectionKey]!\n if (collection.fields?.length) {\n collection.fields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: collection.fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n }\n }\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#UploadFeatureClient',\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ props }) => {\n if (!props?.collections) {\n return null\n }\n\n const schemaMap: FieldSchemaMap = new Map()\n\n for (const collectionKey in props.collections) {\n const collection = props.collections[collectionKey]!\n if (collection.fields?.length) {\n schemaMap.set(collectionKey, {\n fields: collection.fields,\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n req,\n showHiddenFields,\n }) => {\n // @ts-expect-error - for backwards-compatibility\n const id = node?.value?.id || node?.value\n\n if (req?.payload) {\n const uploadDocument: {\n value?: FileData & TypeWithID\n } = {}\n\n try {\n await populate({\n id,\n collectionSlug: node.relationTo,\n currentDepth,\n data: uploadDocument,\n depth,\n draft,\n key: 'value',\n overrideAccess,\n req,\n showHiddenFields,\n })\n } catch (ignored) {\n // eslint-disable-next-line no-console\n console.error(\n 'Lexical upload node HTML converter: error fetching upload file',\n ignored,\n 'Node:',\n node,\n )\n return `<img />`\n }\n\n const url = getAbsoluteURL(uploadDocument?.value?.url ?? '', req?.payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument?.value?.mimeType?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.value?.filename}</a>`\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (\n !uploadDocument?.value?.sizes ||\n !Object.keys(uploadDocument?.value?.sizes).length\n ) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.value?.filename}\" width=\"${uploadDocument?.value?.width}\" height=\"${uploadDocument?.value?.height}\"/>`\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n let pictureHTML = '<picture>'\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.value?.sizes) {\n const imageSize = uploadDocument.value.sizes[size] as FileSizeImproved\n\n // Skip if any property of the size object is null\n if (\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL = getAbsoluteURL(imageSize?.url, req?.payload)\n\n pictureHTML += `<source srcset=\"${imageSizeURL}\" media=\"(max-width: ${imageSize.width}px)\" type=\"${imageSize.mimeType}\">`\n }\n\n // Add the default img tag\n pictureHTML += `<img src=\"${url}\" alt=\"Image\" width=\"${uploadDocument.value?.width}\" height=\"${uploadDocument.value?.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${id}\" />`\n }\n },\n nodeTypes: [UploadServerNode.getType()],\n },\n },\n getSubFields: ({ node, req }) => {\n if (!node) {\n let allSubFields: Field[] = []\n for (const collection in props?.collections) {\n const collectionFields = props.collections[collection]!.fields\n allSubFields = allSubFields.concat(collectionFields)\n }\n return allSubFields\n }\n const collection = req ? req.payload.collections[node?.relationTo] : null\n\n if (collection) {\n const collectionFieldSchema = props?.collections?.[node?.relationTo]?.fields\n\n if (Array.isArray(collectionFieldSchema)) {\n if (!collectionFieldSchema?.length) {\n return null\n }\n return collectionFieldSchema\n }\n }\n return null\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [uploadPopulationPromiseHOC(props)],\n hooks: {\n afterRead: [\n ({\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n if (!node?.value) {\n return node\n }\n const collection = req.payload.collections[node?.relationTo]\n\n if (!collection) {\n return node\n }\n // @ts-expect-error - Fix in Payload v4\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n const populateDepth =\n props?.maxDepth !== undefined && props?.maxDepth < depth ? props?.maxDepth : depth\n\n populationPromises.push(\n populate({\n id,\n collectionSlug: collection.config.slug,\n currentDepth,\n data: node,\n depth: populateDepth,\n draft,\n key: 'value',\n overrideAccess,\n req,\n select:\n populateArg?.[collection.config.slug] ?? collection.config.defaultPopulate,\n showHiddenFields,\n }),\n )\n\n return node\n },\n ],\n },\n node: UploadServerNode,\n validations: [uploadValidation(props)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'upload',\n})\n"],"mappings":"AAWA,SAASA,cAAc,QAAQ;AAI/B,SAASC,QAAQ,QAAQ;AACz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,CAAWZ,MAAM,CAACmB,IAAI,CAAC,IAAIP,UAAA,CAAWZ,MAAM,CAACiF,eAAe;cAC5E3C;YACF;YAGF,OAAOH,IAAA;UACT;QAEJ;QACAA,IAAA,EAAMzC,gBAAA;QACNwF,WAAA,EAAa,CAACvF,gBAAA,CAAiBY,KAAA;MACjC,GACD;MACD4E,2BAAA,EAA6B5E;IAC/B;EACF;EACAsC,GAAA,EAAK;AACP","ignoreList":[]}
@@ -1,8 +1,9 @@
1
1
  import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
2
- import type { DOMConversionMap, DOMExportOutput, ElementFormatType, LexicalNode, NodeKey, Spread } from 'lexical';
2
+ import type { DOMConversionMap, DOMExportOutput, ElementFormatType, LexicalNode, NodeKey } from 'lexical';
3
3
  import type { CollectionSlug, DataFromCollectionSlug, JsonObject, TypedUploadCollection, UploadCollectionSlug } from 'payload';
4
4
  import type { JSX } from 'react';
5
5
  import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
6
+ import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js';
6
7
  export type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {
7
8
  [TCollectionSlug in CollectionSlug]: {
8
9
  fields: TUploadExtraFieldsData;
@@ -54,10 +55,7 @@ export type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonO
54
55
  value: number | string | TypedUploadCollection[TCollectionSlug];
55
56
  };
56
57
  }[UploadCollectionSlug];
57
- export type SerializedUploadNode = {
58
- children?: never;
59
- type: 'upload';
60
- } & Spread<UploadData, SerializedDecoratorBlockNode>;
58
+ export type SerializedUploadNode = StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'upload'> & UploadData;
61
59
  export declare class UploadServerNode extends DecoratorBlockNode {
62
60
  __data: UploadData;
63
61
  constructor({ data, format, key, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes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,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,OAAO,EACR,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAIhF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAIrE,MAAM,MAAM,UAAU,CAAC,sBAAsB,SAAS,UAAU,GAAG,UAAU,IAAI;KAC9E,eAAe,IAAI,cAAc,GAAG;QACnC,MAAM,EAAE,sBAAsB,CAAA;QAC9B;;WAEG;QACH,EAAE,EAAE,MAAM,CAAA;QACV,UAAU,EAAE,eAAe,CAAA;QAC3B;;WAEG;QACH,KAAK,EAAE,sBAAsB,CAAC,eAAe,CAAC,GAAG,MAAM,GAAG,MAAM,CAAA;KACjE;CACF,CAAC,cAAc,CAAC,CAAA;AAEjB;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,sBAAsB,SAAS,UAAU,GAAG,UAAU,IAAI;IACxF,OAAO,CAAC,EAAE;QACR;;WAEG;QACH,MAAM,EAAE,MAAM,CAAA;QACd;;WAEG;QACH,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;CACF,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAA;AAEtC;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,CAAC,sBAAsB,SAAS,UAAU,GAAG,UAAU,IAAI;KACtF,eAAe,IAAI,oBAAoB,GAAG;QACzC,MAAM,EAA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,IAAI,IAAI,gBAAgB,CAE1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"UploadNode.js","names":["DecoratorBlockNode","ObjectID","$applyNodeReplacement","$convertUploadElement","UploadServerNode","__data","constructor","data","format","key","clone","node","__format","__key","getType","importDOM","img","conversion","domNode","$createUploadServerNode","priority","importJSON","serializedNode","version","value","id","default","toHexString","importedData","fields","pending","relationTo","setFormat","isInline","decorate","exportDOM","element","document","createElement","setAttribute","String","formID","src","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type {\n CollectionSlug,\n DataFromCollectionSlug,\n JsonObject,\n TypedUploadCollection,\n UploadCollectionSlug,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\n\nimport { $convertUploadElement } from './conversions.js'\n\nexport type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in CollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\n/**\n * Internal use only - UploadData type that can contain a pending state\n * @internal\n */\nexport type Internal_UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n pending?: {\n /**\n * ID that corresponds to the bulk upload form ID\n */\n formID: string\n /**\n * src value of the image dom element\n */\n src: string\n }\n} & UploadData<TUploadExtraFieldsData>\n\n/**\n * UploadDataImproved is a more precise type, and will replace UploadData in Payload v4.\n * This type is for internal use only as it will be deprecated in the future.\n * @internal\n *\n * @todo Replace UploadData with UploadDataImproved in 4.0\n */\nexport type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: number | string | TypedUploadCollection[TCollectionSlug]\n }\n}[UploadCollectionSlug]\n\nexport type SerializedUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n} & Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n const data = this.__data as Internal_UploadData\n if (data.pending) {\n element.setAttribute('data-lexical-pending-upload-form-id', String(data?.pending?.formID))\n element.setAttribute('src', data?.pending?.src || '')\n } else {\n element.setAttribute('data-lexical-upload-id', String(data?.value))\n element.setAttribute('data-lexical-upload-relation-to', data?.relationTo)\n }\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n"],"mappings":"AAkBA,SAASA,kBAAkB,QAAQ;AACnC,OAAOC,QAAA,MAAc;AACrB,SAASC,qBAAqB,QAAQ;AAEtC,SAASC,qBAAqB,QAAQ;AA6DtC,OAAO,MAAMC,gBAAA,SAAyBJ,kBAAA;EACpCK,MAAA;EAEAC,YAAY;IACVC,IAAI;IACJC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACD,MAAA,EAAQC,GAAA;IACd,IAAI,CAACJ,MAAM,GAAGE,IAAA;EAChB;EAEA,OAAgBG,MAAMC,IAAsB,EAAoB;IAC9D,OAAO,IAAI,IAAI,CAAC;MACdJ,IAAA,EAAMI,IAAA,CAAKN,MAAM;MACjBG,MAAA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O,IAAI,CAACF,MAAM;IACxB,IAAIE,IAAA,CAAKuB,OAAO,EAAE;MAChBM,OAAA,CAAQG,YAAY,CAAC,uCAAuCC,MAAA,CAAOjC,IAAA,EAAMuB,OAAA,EAASW,MAAA;MAClFL,OAAA,CAAQG,YAAY,CAAC,OAAOhC,IAAA,EAAMuB,OAAA,EAASY,GAAA,IAAO;IACpD,OAAO;MACLN,OAAA,CAAQG,YAAY,CAAC,0BAA0BC,MAAA,CAAOjC,IAAA,EAAMiB,KAAA;MAC5DY,OAAA,CAAQG,YAAY,CAAC,mCAAmChC,IAAA,EAAMwB,UAAA;IAChE;IAEA,OAAO;MAAEK;IAAQ;EACnB;EAESO,WAAA,EAAmC;IAC1C,OAAO;MACL,GAAG,KAAK,CAACA,UAAA,EAAY;MACrB,GAAG,IAAI,CAACC,OAAO,EAAE;MACjBC,IAAA,EAAM;MACNtB,OAAA,EAAS;IACX;EACF;EAEAqB,QAAA,EAAsB;IACpB,OAAO,IAAI,CAACE,SAAS,GAAGzC,MAAM;EAChC;EAEA0C,QAAQxC,IAAgB,EAAQ;IAC9B,MAAMyC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAAS3C,MAAM,GAAGE,IAAA;EACpB;EAES2C,UAAA,EAAmB;IAC1B,OAAO;EACT;AACF;AAEA,OAAO,SAAS/B,wBAAwB;EACtCZ;AAAI,CAGL;EACC,IAAI,CAACA,IAAA,EAAMkB,EAAA,EAAI;IACblB,IAAA,CAAKkB,EAAE,GAAG,IAAIxB,QAAA,CAASyB,OAAO,GAAGC,WAAW;EAC9C;EACA,OAAOzB,qBAAA,CAAsB,IAAIE,gBAAA,CAAiB;IAAEG,IAAA,EAAMA;EAAmB;AAC/E;AAEA,OAAO,SAAS4C,oBACdxC,IAAoC;EAEpC,OAAOA,IAAA,YAAgBP,gBAAA;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"UploadNode.js","names":["DecoratorBlockNode","ObjectID","$applyNodeReplacement","$convertUploadElement","UploadServerNode","__data","constructor","data","format","key","clone","node","__format","__key","getType","importDOM","img","conversion","domNode","$createUploadServerNode","priority","importJSON","serializedNode","version","value","id","default","toHexString","importedData","fields","pending","relationTo","setFormat","isInline","decorate","exportDOM","element","document","createElement","setAttribute","String","formID","src","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type {\n CollectionSlug,\n DataFromCollectionSlug,\n JsonObject,\n TypedUploadCollection,\n UploadCollectionSlug,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\nimport { $convertUploadElement } from './conversions.js'\n\nexport type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in CollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\n/**\n * Internal use only - UploadData type that can contain a pending state\n * @internal\n */\nexport type Internal_UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n pending?: {\n /**\n * ID that corresponds to the bulk upload form ID\n */\n formID: string\n /**\n * src value of the image dom element\n */\n src: string\n }\n} & UploadData<TUploadExtraFieldsData>\n\n/**\n * UploadDataImproved is a more precise type, and will replace UploadData in Payload v4.\n * This type is for internal use only as it will be deprecated in the future.\n * @internal\n *\n * @todo Replace UploadData with UploadDataImproved in 4.0\n */\nexport type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: number | string | TypedUploadCollection[TCollectionSlug]\n }\n}[UploadCollectionSlug]\n\nexport type SerializedUploadNode = StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'upload'> &\n UploadData\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n const data = this.__data as Internal_UploadData\n if (data.pending) {\n element.setAttribute('data-lexical-pending-upload-form-id', String(data?.pending?.formID))\n element.setAttribute('src', data?.pending?.src || '')\n } else {\n element.setAttribute('data-lexical-upload-id', String(data?.value))\n element.setAttribute('data-lexical-upload-relation-to', data?.relationTo)\n }\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n"],"mappings":"AAiBA,SAASA,kBAAkB,QAAQ;AACnC,OAAOC,QAAA,MAAc;AACrB,SAASC,qBAAqB,QAAQ;AAItC,SAASC,qBAAqB,QAAQ;AA2DtC,OAAO,MAAMC,gBAAA,SAAyBJ,kBAAA;EACpCK,MAAA;EAEAC,YAAY;IACVC,IAAI;IACJC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACD,MAAA,EAAQC,GAAA;IACd,IAAI,CAACJ,MAAM,GAAGE,IAAA;EAChB;EAEA,OAAgBG,MAAMC,IAAsB,EAAoB;IAC9D,OAAO,IAAI,IAAI,CAAC;MACdJ,IAAA,EAAMI,IAAA,CAAKN,MAAM;MACjBG,MAAA,EAAQG,IAAA,CAAKC,QAAQ;MACrBH,GAAA,EAAKE,IAAA,CAAKE;IACZ;EACF;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAA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AOjC,IAAA,EAAMuB,OAAA,EAASW,MAAA;MAClFL,OAAA,CAAQG,YAAY,CAAC,OAAOhC,IAAA,EAAMuB,OAAA,EAASY,GAAA,IAAO;IACpD,OAAO;MACLN,OAAA,CAAQG,YAAY,CAAC,0BAA0BC,MAAA,CAAOjC,IAAA,EAAMiB,KAAA;MAC5DY,OAAA,CAAQG,YAAY,CAAC,mCAAmChC,IAAA,EAAMwB,UAAA;IAChE;IAEA,OAAO;MAAEK;IAAQ;EACnB;EAESO,WAAA,EAAmC;IAC1C,OAAO;MACL,GAAG,KAAK,CAACA,UAAA,EAAY;MACrB,GAAG,IAAI,CAACC,OAAO,EAAE;MACjBC,IAAA,EAAM;MACNtB,OAAA,EAAS;IACX;EACF;EAEAqB,QAAA,EAAsB;IACpB,OAAO,IAAI,CAACE,SAAS,GAAGzC,MAAM;EAChC;EAEA0C,QAAQxC,IAAgB,EAAQ;IAC9B,MAAMyC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAAS3C,MAAM,GAAGE,IAAA;EACpB;EAES2C,UAAA,EAAmB;IAC1B,OAAO;EACT;AACF;AAEA,OAAO,SAAS/B,wBAAwB;EACtCZ;AAAI,CAGL;EACC,IAAI,CAACA,IAAA,EAAMkB,EAAA,EAAI;IACblB,IAAA,CAAKkB,EAAE,GAAG,IAAIxB,QAAA,CAASyB,OAAO,GAAGC,WAAW;EAC9C;EACA,OAAOzB,qBAAA,CAAsB,IAAIE,gBAAA,CAAiB;IAAEG,IAAA,EAAMA;EAAmB;AAC/E;AAEA,OAAO,SAAS4C,oBACdxC,IAAoC;EAEpC,OAAOA,IAAA,YAAgBP,gBAAA;AACzB","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import { type FieldType, type RenderFieldServerFnArgs } from '@payloadcms/ui';
2
2
  import React from 'react';
3
3
  import type { DefaultTypedEditorState } from '../../nodeTypes.js';
4
+ import type { LexicalRichTextField } from '../../types.js';
4
5
  /**
5
6
  * Utility to render a lexical editor on the client.
6
7
  *
@@ -19,5 +20,5 @@ export declare const RenderLexical: React.FC<
19
20
  Loading?: React.ReactElement;
20
21
  setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue'];
21
22
  value?: FieldType<DefaultTypedEditorState | undefined>['value'];
22
- } & RenderFieldServerFnArgs>;
23
+ } & RenderFieldServerFnArgs<LexicalRichTextField>>;
23
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/field/RenderLexical/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,uBAAuB,EAK7B,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE;AAClC;;;GAGG;AACH;IACE;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,CAAA;IAE5B,QAAQ,CAAC,EAAE,SAAS,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC,UAAU,CAAC,CAAA;IACrE,KAAK,CAAC,EAAE,SAAS,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAA;CAChE,GAAG,uBAAuB,CA4F5B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/field/RenderLexical/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,uBAAuB,EAK7B,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,a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