@payloadcms/richtext-lexical 3.0.0-beta.20 → 3.0.0-beta.21

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 (92) hide show
  1. package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
  2. package/dist/field/features/blocks/feature.server.js +28 -68
  3. package/dist/field/features/blocks/feature.server.js.map +1 -1
  4. package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
  5. package/dist/field/features/blocks/populationPromise.js +0 -13
  6. package/dist/field/features/blocks/populationPromise.js.map +1 -1
  7. package/dist/field/features/blocks/validate.d.ts.map +1 -1
  8. package/dist/field/features/blocks/validate.js +2 -14
  9. package/dist/field/features/blocks/validate.js.map +1 -1
  10. package/dist/field/features/link/drawer/baseFields.d.ts +3 -3
  11. package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
  12. package/dist/field/features/link/drawer/baseFields.js +28 -42
  13. package/dist/field/features/link/drawer/baseFields.js.map +1 -1
  14. package/dist/field/features/link/drawer/types.d.ts +4 -2
  15. package/dist/field/features/link/drawer/types.d.ts.map +1 -1
  16. package/dist/field/features/link/drawer/types.js.map +1 -1
  17. package/dist/field/features/link/feature.server.d.ts +0 -2
  18. package/dist/field/features/link/feature.server.d.ts.map +1 -1
  19. package/dist/field/features/link/feature.server.js +22 -6
  20. package/dist/field/features/link/feature.server.js.map +1 -1
  21. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  22. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +38 -24
  23. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  24. package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +9 -1
  25. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +3 -5
  26. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
  27. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +11 -29
  28. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
  29. package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
  30. package/dist/field/features/link/plugins/link/index.js +0 -6
  31. package/dist/field/features/link/plugins/link/index.js.map +1 -1
  32. package/dist/field/features/link/populationPromise.d.ts.map +1 -1
  33. package/dist/field/features/link/populationPromise.js +5 -23
  34. package/dist/field/features/link/populationPromise.js.map +1 -1
  35. package/dist/field/features/link/validate.d.ts +5 -0
  36. package/dist/field/features/link/validate.d.ts.map +1 -0
  37. package/dist/field/features/link/validate.js +32 -0
  38. package/dist/field/features/link/validate.js.map +1 -0
  39. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  40. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +51 -2
  41. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  42. package/dist/field/features/types.d.ts +5 -1
  43. package/dist/field/features/types.d.ts.map +1 -1
  44. package/dist/field/features/types.js.map +1 -1
  45. package/dist/field/features/upload/feature.server.d.ts.map +1 -1
  46. package/dist/field/features/upload/feature.server.js +14 -2
  47. package/dist/field/features/upload/feature.server.js.map +1 -1
  48. package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
  49. package/dist/field/features/upload/populationPromise.js +2 -12
  50. package/dist/field/features/upload/populationPromise.js.map +1 -1
  51. package/dist/field/features/upload/validate.d.ts +2 -1
  52. package/dist/field/features/upload/validate.d.ts.map +1 -1
  53. package/dist/field/features/upload/validate.js +33 -11
  54. package/dist/field/features/upload/validate.js.map +1 -1
  55. package/dist/field/lexical/LexicalEditor.js +1 -1
  56. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  57. package/dist/field/lexical/config/server/default.d.ts +1 -2
  58. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  59. package/dist/field/lexical/config/server/default.js +0 -2
  60. package/dist/field/lexical/config/server/default.js.map +1 -1
  61. package/dist/field/lexical/config/server/loader.d.ts +4 -2
  62. package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
  63. package/dist/field/lexical/config/server/loader.js +3 -2
  64. package/dist/field/lexical/config/server/loader.js.map +1 -1
  65. package/dist/field/lexical/config/server/sanitize.d.ts +2 -1
  66. package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
  67. package/dist/field/lexical/config/server/sanitize.js +3 -2
  68. package/dist/field/lexical/config/server/sanitize.js.map +1 -1
  69. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +1 -1
  70. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js +24 -23
  71. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +1 -1
  72. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +1 -1
  73. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
  74. package/dist/field/lexical/utils/setFloatingElemPosition.js +15 -13
  75. package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
  76. package/dist/field/lexical/utils/url.d.ts.map +1 -1
  77. package/dist/field/lexical/utils/url.js +2 -0
  78. package/dist/field/lexical/utils/url.js.map +1 -1
  79. package/dist/generateComponentMap.d.ts.map +1 -1
  80. package/dist/generateComponentMap.js +1 -10
  81. package/dist/generateComponentMap.js.map +1 -1
  82. package/dist/generateSchemaMap.d.ts.map +1 -1
  83. package/dist/generateSchemaMap.js +1 -10
  84. package/dist/generateSchemaMap.js.map +1 -1
  85. package/dist/index.d.ts +3 -3
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +241 -234
  88. package/dist/index.js.map +1 -1
  89. package/dist/types.d.ts +8 -1
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/types.js.map +1 -1
  92. package/package.json +9 -9
@@ -1,16 +1,19 @@
1
1
  'use client';
2
2
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
3
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js';
4
+ import { mergeRegister } from '@lexical/utils';
4
5
  import { getTranslation } from '@payloadcms/translations';
5
6
  import { Button } from '@payloadcms/ui/elements/Button';
6
7
  import { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer';
7
8
  import usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI';
8
9
  import { useConfig } from '@payloadcms/ui/providers/Config';
9
10
  import { useTranslation } from '@payloadcms/ui/providers/Translation';
11
+ import { $getSelection, $isNodeSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND } from 'lexical';
10
12
  import { $getNodeByKey } from 'lexical';
11
- import React, { useCallback, useReducer, useState } from 'react';
13
+ import React, { useCallback, useEffect, useReducer, useRef, useState } from 'react';
12
14
  import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
13
15
  import { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js';
16
+ import { $isRelationshipNode } from '../RelationshipNode.js';
14
17
  import './index.scss';
15
18
  const baseClass = 'lexical-relationship';
16
19
  const initialParams = {
@@ -18,6 +21,7 @@ const initialParams = {
18
21
  };
19
22
  const Component = (props)=>{
20
23
  const { children, data: { relationTo, value: id }, nodeKey } = props;
24
+ const relationshipElemRef = useRef(null);
21
25
  const [editor] = useLexicalComposerContext();
22
26
  const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
23
27
  const { field } = useEditorConfigContext();
@@ -52,12 +56,57 @@ const Component = (props)=>{
52
56
  setParams,
53
57
  closeDrawer
54
58
  ]);
59
+ const onDelete = useCallback((payload)=>{
60
+ if (isSelected && $isNodeSelection($getSelection())) {
61
+ const event = payload;
62
+ event.preventDefault();
63
+ const node = $getNodeByKey(nodeKey);
64
+ if ($isRelationshipNode(node)) {
65
+ node.remove();
66
+ return true;
67
+ }
68
+ }
69
+ return false;
70
+ }, [
71
+ isSelected,
72
+ nodeKey
73
+ ]);
74
+ const onClick = useCallback((payload)=>{
75
+ const event = payload;
76
+ // Check if relationshipElemRef.target or anything WITHIN relationshipElemRef.target was clicked
77
+ if (event.target === relationshipElemRef.current || relationshipElemRef.current?.contains(event.target)) {
78
+ if (event.shiftKey) {
79
+ setSelected(!isSelected);
80
+ } else {
81
+ clearSelection();
82
+ setSelected(true);
83
+ }
84
+ return true;
85
+ }
86
+ return false;
87
+ }, [
88
+ isSelected,
89
+ setSelected,
90
+ clearSelection
91
+ ]);
92
+ useEffect(()=>{
93
+ return mergeRegister(editor.registerCommand(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW));
94
+ }, [
95
+ clearSelection,
96
+ editor,
97
+ isSelected,
98
+ nodeKey,
99
+ onDelete,
100
+ setSelected,
101
+ onClick
102
+ ]);
55
103
  return /*#__PURE__*/ React.createElement("div", {
56
104
  className: [
57
105
  baseClass,
58
106
  isSelected && `${baseClass}--selected`
59
107
  ].filter(Boolean).join(' '),
60
- contentEditable: false
108
+ contentEditable: false,
109
+ ref: relationshipElemRef
61
110
  }, /*#__PURE__*/ React.createElement("div", {
62
111
  className: `${baseClass}__wrap`
63
112
  }, /*#__PURE__*/ React.createElement("p", {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useState } from 'react'\n\nimport type { RelationshipData } from '../RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n children?: React.ReactNode\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n children,\n data: { relationTo, value: id },\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { field } = useEditorConfigContext()\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDrawer],\n )\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id}\n </p>\n </DocumentDrawerToggler>\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {id && <DocumentDrawer onSave={updateRelationship} />}\n {children}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"names":["useLexicalComposerContext","useLexicalNodeSelection","getTranslation","Button","useDocumentDrawer","usePayloadAPI","useConfig","useTranslation","$getNodeByKey","React","useCallback","useReducer","useState","useEditorConfigContext","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","baseClass","initialParams","depth","Component","props","children","data","relationTo","value","id","nodeKey","editor","isSelected","setSelected","clearSelection","field","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","div","className","filter","Boolean","join","contentEditable","p","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","readOnly","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave","RelationshipComponent"],"rangeMappings":";;;;;;;;;;;;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C,WAAW,CAAC,EAAEzC,UAAU,SAAS,CAAC;qBACrC,oBAACZ;QACCiE,aAAY;QACZZ,WAAW,CAAC,EAAEzC,UAAU,YAAY,CAAC;QACrCsD,UAAUvC,OAAOwC;QACjBC,IAAG;QACHC,MAAK;QACLC,SAAS;YACP/C,OAAOgD,eAAe,CAAC5D,yCAAyC;gBAC9D6D,SAAS;oBAAElD;gBAAQ;YACrB;QACF;QACAmD,OAAAA;QACAC,SAASpC,EAAE;sBAEb,oBAACtC;QACCiE,aAAY;QACZZ,WAAW,CAAC,EAAEzC,UAAU,cAAc,CAAC;QACvCsD,UAAUvC,OAAOwC;QACjBE,MAAK;QACLC,SAAS,CAACK;YACRA,EAAEC,cAAc;YAChB7B;QACF;QACA0B,OAAAA;QACAC,SAASpC,EAAE;SAKhBjB,oBAAM,oBAACsB;QAAekC,QAAQ3B;QAC9BjC;AAGP;AAEA,OAAO,MAAM6D,wBAAwB,CAAC9D;IACpC,qBAAO,oBAACD,WAAcC;AACxB,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport {\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js'\nimport { $isRelationshipNode } from '../RelationshipNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n children?: React.ReactNode\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n children,\n data: { relationTo, value: id },\n nodeKey,\n } = props\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { field } = useEditorConfigContext()\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDrawer],\n )\n\n const onDelete = useCallback(\n (payload: KeyboardEvent) => {\n if (isSelected && $isNodeSelection($getSelection())) {\n const event: KeyboardEvent = payload\n event.preventDefault()\n const node = $getNodeByKey(nodeKey)\n if ($isRelationshipNode(node)) {\n node.remove()\n return true\n }\n }\n return false\n },\n [isSelected, nodeKey],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if relationshipElemRef.target or anything WITHIN relationshipElemRef.target was clicked\n if (\n event.target === relationshipElemRef.current ||\n relationshipElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n clearSelection()\n setSelected(true)\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected, onClick])\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={relationshipElemRef}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id}\n </p>\n </DocumentDrawerToggler>\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {id && <DocumentDrawer onSave={updateRelationship} />}\n {children}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"names":["useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useDocumentDrawer","usePayloadAPI","useConfig","useTranslation","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","$getNodeByKey","React","useCallback","useEffect","useReducer","useRef","useState","useEditorConfigContext","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","baseClass","initialParams","depth","Component","props","children","data","relationTo","value","id","nodeKey","relationshipElemRef","editor","isSelected","setSelected","clearSelection","field","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","onDelete","payload","event","preventDefault","node","onClick","target","current","contains","shiftKey","registerCommand","div","className","filter","Boolean","join","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","readOnly","el","icon","dispatchCommand","replace","round","tooltip","e","onSave","RelationshipComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,aAAa,QAAQ,iB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c,CAAC;QACvCmE,UAAUnD,OAAOoD;QACjBE,MAAK;QACLxB,SAAS,CAAC6B;YACRA,EAAE/B,cAAc;YAChBR;QACF;QACAqC,OAAAA;QACAC,SAAS/C,EAAE;SAKhBlB,oBAAM,oBAACuB;QAAe4C,QAAQrC;QAC9BlC;AAGP;AAEA,OAAO,MAAMwE,wBAAwB,CAACzE;IACpC,qBAAO,oBAACD,WAAcC;AACxB,EAAC"}
@@ -51,12 +51,16 @@ export type FeatureProviderServer<ServerFeatureProps, ClientFeatureProps> = {
51
51
  dependenciesPriority?: string[];
52
52
  /** Keys of soft-dependencies needed for this feature. The FeatureProviders dependencies are optional, but are considered as last-priority in the loading process */
53
53
  dependenciesSoft?: string[];
54
+ /**
55
+ * This is being called during the payload sanitization process
56
+ */
54
57
  feature: (props: {
58
+ config: SanitizedConfig;
55
59
  /** unSanitizedEditorConfig.features, but mapped */
56
60
  featureProviderMap: ServerFeatureProviderMap;
57
61
  resolvedFeatures: ResolvedServerFeatureMap;
58
62
  unSanitizedEditorConfig: ServerEditorConfig;
59
- }) => ServerFeature<ServerFeatureProps, ClientFeatureProps>;
63
+ }) => Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>> | ServerFeature<ServerFeatureProps, ClientFeatureProps>;
60
64
  key: string;
61
65
  /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */
62
66
  serverFeatureProps: ServerFeatureProps;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/field/features/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAA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Ae,EAAE,MAAM,EAAE,CAAA;IACzB,qBAAqB,EAAE;QACrB,QAAQ,EAAE,sBAAsB,EAAE,CAAA;KACnC,CAAA;IACD,KAAK,EAAE;QACL,IAAI,EAAE,KAAK,CACT,CAAC,EACC,mBAAmB,GACpB,EAAE;YACD,mBAAmB,EAAE,qBAAqB,CAAA;SAC3C,KAAK,qBAAqB,CAC5B,CAAA;QACD,IAAI,EAAE,KAAK,CACT,CAAC,EACC,mBAAmB,GACpB,EAAE;YACD,mBAAmB,EAAE,qBAAqB,CAAA;SAC3C,KAAK,qBAAqB,CAC5B,CAAA;KACF,CAAA;IACD,OAAO,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;IAChC,SAAS,EAAE;QACT,cAAc,EAAE,KAAK,CACnB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;YAAE,MAAM,EAAE,aAAa,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,KAAK,cAAc,EAAE,CAC9F,CAAA;QACD,iBAAiB,EAAE,cAAc,EAAE,CAAA;KACpC,CAAA;CACF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/field/features/types.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { Klass, LexicalEditor, LexicalNode, SerializedEditorState } from 'lexical'\nimport type { SerializedLexicalNode } from 'lexical'\nimport type { LexicalNodeReplacement } from 'lexical'\nimport type { RequestContext } from 'payload'\nimport type { SanitizedConfig } from 'payload/config'\nimport type {\n Field,\n PayloadRequestWithData,\n ReplaceAny,\n RichTextField,\n ValidateOptions,\n} from 'payload/types'\nimport type React from 'react'\n\nimport type { AdapterProps } from '../../types.js'\nimport type { ClientEditorConfig, ServerEditorConfig } from '../lexical/config/types.js'\nimport type { FloatingToolbarSection } from '../lexical/plugins/FloatingSelectToolbar/types.js'\nimport type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport type { HTMLConverter } from './converters/html/converter/types.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n}: {\n context: RequestContext\n currentDepth: number\n depth: number\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<ServerFeatureProps, ClientFeatureProps> = (\n props?: ServerFeatureProps,\n) => FeatureProviderServer<ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<ServerFeatureProps, ClientFeatureProps> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first and are available in the `feature` property*/\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. The FeatureProviders dependencies are optional, but are considered as last-priority in the loading process */\n dependenciesSoft?: string[]\n\n feature: (props: {\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) => ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: ServerFeatureProps\n}\n\nexport type FeatureProviderProviderClient<ClientFeatureProps> = (\n props?: ClientComponentProps<ClientFeatureProps>,\n) => FeatureProviderClient<ClientFeatureProps>\n\n/**\n * No dependencies => Features need to be sorted on the server first, then sent to client in right order\n */\nexport type FeatureProviderClient<ClientFeatureProps> = {\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n clientFeatureProps: ClientComponentProps<ClientFeatureProps>\n feature: (props: {\n clientFunctions: Record<string, any>\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ClientFeatureProviderMap\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedClientFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ClientEditorConfig\n }) => ClientFeature<ClientFeatureProps>\n}\n\nexport type ClientFeature<ClientFeatureProps> = {\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n clientFeatureProps: ClientComponentProps<ClientFeatureProps>\n\n floatingSelectToolbar?: {\n sections: FloatingToolbarSection[]\n }\n hooks?: {\n load?: ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n save?: ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n }\n markdownTransformers?: Transformer[]\n nodes?: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n plugins?: Array<\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC<{ anchorElem: HTMLElement }>\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n >\n slashMenu?: {\n dynamicOptions?: ({\n editor,\n queryString,\n }: {\n editor: LexicalEditor\n queryString: string\n }) => SlashMenuGroup[]\n options?: SlashMenuGroup[]\n }\n}\n\nexport type ClientComponentProps<ClientFeatureProps> = ClientFeatureProps & {\n featureKey: string\n order: number\n}\n\nexport type FieldNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n /** The value of the field. */\n node?: T\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n overrideAccess?: boolean\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequestWithData\n}\n\nexport type FieldNodeHook<T extends SerializedLexicalNode> = (\n args: FieldNodeHookArgs<T>,\n) => Promise<T> | T\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n converters?: {\n html?: HTMLConverter<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n }\n hooks?: {\n afterChange?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n /**\n * Runs before a document is duplicated to prevent errors in unique fields or return null to use defaultValue.\n */\n beforeDuplicate?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n }\n node: Klass<T> | LexicalNodeReplacement\n populationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientComponent?: React.FC<ClientComponentProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n generateComponentMap?: (args: {\n config: SanitizedConfig\n i18n: I18n\n props: ServerProps\n schemaPath: string\n }) => {\n [key: string]: React.FC<{ componentKey: string; featureKey: string }>\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18n\n props: ServerProps\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]> | null\n generatedTypes?: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n }\n markdownTransformers?: Transformer[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = ServerFeature<\n ServerProps,\n ClientFeatureProps\n> &\n Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n > & {\n order: number\n }\n\nexport type ResolvedClientFeature<ClientFeatureProps> = ClientFeature<ClientFeatureProps> & {\n key: string\n order: number\n}\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<unknown, unknown>>\nexport type ResolvedClientFeatureMap = Map<string, ResolvedClientFeature<unknown>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<unknown, unknown>>\nexport type ClientFeatureProviderMap = Map<string, FeatureProviderClient<unknown>>\n\nexport type SanitizedPlugin =\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n key: string\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n key: string\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n key: string\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC<{ anchorElem: HTMLElement }>\n desktopOnly?: boolean\n key: string\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n\nexport type SanitizedServerFeatures = Required<\n Pick<ResolvedServerFeature<unknown, unknown>, 'markdownTransformers' | 'nodes'>\n> & {\n /** The node types mapped to their converters */\n converters: {\n html: HTMLConverter[]\n }\n /** The keys of all enabled features */\n enabledFeatures: string[]\n generatedTypes: {\n modifyOutputSchemas: Array<\n ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n >\n }\n /** The node types mapped to their hooks */\n\n hooks?: {\n afterChange?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n /**\n * Runs before a document is duplicated to prevent errors in unique fields or return null to use defaultValue.\n */\n beforeDuplicate?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n populationPromises: Map<string, Array<PopulationPromise>>\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n}\n\nexport type SanitizedClientFeatures = Required<\n Pick<ResolvedClientFeature<unknown>, 'markdownTransformers' | 'nodes'>\n> & {\n /** The keys of all enabled features */\n enabledFeatures: string[]\n floatingSelectToolbar: {\n sections: FloatingToolbarSection[]\n }\n hooks: {\n load: Array<\n ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n >\n save: Array<\n ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n >\n }\n plugins?: Array<SanitizedPlugin>\n slashMenu: {\n dynamicOptions: Array<\n ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => SlashMenuGroup[]\n >\n groupsWithOptions: SlashMenuGroup[]\n }\n}\n"],"names":[],"rangeMappings":"","mappings":"AAwXA,WA+BC"}
1
+ {"version":3,"sources":["../../../src/field/features/types.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { Klass, LexicalEditor, LexicalNode, SerializedEditorState } from 'lexical'\nimport type { SerializedLexicalNode } from 'lexical'\nimport type { LexicalNodeReplacement } from 'lexical'\nimport type { RequestContext } from 'payload'\nimport type { SanitizedConfig } from 'payload/config'\nimport type {\n Field,\n PayloadRequestWithData,\n ReplaceAny,\n RichTextField,\n ValidateOptions,\n} from 'payload/types'\nimport type React from 'react'\n\nimport type { AdapterProps } from '../../types.js'\nimport type { ClientEditorConfig, ServerEditorConfig } from '../lexical/config/types.js'\nimport type { FloatingToolbarSection } from '../lexical/plugins/FloatingSelectToolbar/types.js'\nimport type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport type { HTMLConverter } from './converters/html/converter/types.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n}: {\n context: RequestContext\n currentDepth: number\n depth: number\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<ServerFeatureProps, ClientFeatureProps> = (\n props?: ServerFeatureProps,\n) => FeatureProviderServer<ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<ServerFeatureProps, ClientFeatureProps> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first and are available in the `feature` property*/\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. The FeatureProviders dependencies are optional, but are considered as last-priority in the loading process */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature: (props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: ServerFeatureProps\n}\n\nexport type FeatureProviderProviderClient<ClientFeatureProps> = (\n props?: ClientComponentProps<ClientFeatureProps>,\n) => FeatureProviderClient<ClientFeatureProps>\n\n/**\n * No dependencies => Features need to be sorted on the server first, then sent to client in right order\n */\nexport type FeatureProviderClient<ClientFeatureProps> = {\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n clientFeatureProps: ClientComponentProps<ClientFeatureProps>\n feature: (props: {\n clientFunctions: Record<string, any>\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ClientFeatureProviderMap\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedClientFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ClientEditorConfig\n }) => ClientFeature<ClientFeatureProps>\n}\n\nexport type ClientFeature<ClientFeatureProps> = {\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n clientFeatureProps: ClientComponentProps<ClientFeatureProps>\n\n floatingSelectToolbar?: {\n sections: FloatingToolbarSection[]\n }\n hooks?: {\n load?: ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n save?: ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n }\n markdownTransformers?: Transformer[]\n nodes?: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n plugins?: Array<\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC<{ anchorElem: HTMLElement }>\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n >\n slashMenu?: {\n dynamicOptions?: ({\n editor,\n queryString,\n }: {\n editor: LexicalEditor\n queryString: string\n }) => SlashMenuGroup[]\n options?: SlashMenuGroup[]\n }\n}\n\nexport type ClientComponentProps<ClientFeatureProps> = ClientFeatureProps & {\n featureKey: string\n order: number\n}\n\nexport type FieldNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n /** The value of the field. */\n node?: T\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n overrideAccess?: boolean\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequestWithData\n}\n\nexport type FieldNodeHook<T extends SerializedLexicalNode> = (\n args: FieldNodeHookArgs<T>,\n) => Promise<T> | T\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n converters?: {\n html?: HTMLConverter<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n }\n hooks?: {\n afterChange?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n /**\n * Runs before a document is duplicated to prevent errors in unique fields or return null to use defaultValue.\n */\n beforeDuplicate?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<FieldNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n }\n node: Klass<T> | LexicalNodeReplacement\n populationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientComponent?: React.FC<ClientComponentProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n generateComponentMap?: (args: {\n config: SanitizedConfig\n i18n: I18n\n props: ServerProps\n schemaPath: string\n }) => {\n [key: string]: React.FC<{ componentKey: string; featureKey: string }>\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18n\n props: ServerProps\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]> | null\n generatedTypes?: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n }\n markdownTransformers?: Transformer[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = ServerFeature<\n ServerProps,\n ClientFeatureProps\n> &\n Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n > & {\n order: number\n }\n\nexport type ResolvedClientFeature<ClientFeatureProps> = ClientFeature<ClientFeatureProps> & {\n key: string\n order: number\n}\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<unknown, unknown>>\nexport type ResolvedClientFeatureMap = Map<string, ResolvedClientFeature<unknown>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<unknown, unknown>>\nexport type ClientFeatureProviderMap = Map<string, FeatureProviderClient<unknown>>\n\nexport type SanitizedPlugin =\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n key: string\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n key: string\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC\n key: string\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: React.FC<{ anchorElem: HTMLElement }>\n desktopOnly?: boolean\n key: string\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n\nexport type SanitizedServerFeatures = Required<\n Pick<ResolvedServerFeature<unknown, unknown>, 'markdownTransformers' | 'nodes'>\n> & {\n /** The node types mapped to their converters */\n converters: {\n html: HTMLConverter[]\n }\n /** The keys of all enabled features */\n enabledFeatures: string[]\n generatedTypes: {\n modifyOutputSchemas: Array<\n ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n >\n }\n /** The node types mapped to their hooks */\n\n hooks?: {\n afterChange?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n /**\n * Runs before a document is duplicated to prevent errors in unique fields or return null to use defaultValue.\n */\n beforeDuplicate?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<FieldNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n populationPromises: Map<string, Array<PopulationPromise>>\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n}\n\nexport type SanitizedClientFeatures = Required<\n Pick<ResolvedClientFeature<unknown>, 'markdownTransformers' | 'nodes'>\n> & {\n /** The keys of all enabled features */\n enabledFeatures: string[]\n floatingSelectToolbar: {\n sections: FloatingToolbarSection[]\n }\n hooks: {\n load: Array<\n ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n >\n save: Array<\n ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n >\n }\n plugins?: Array<SanitizedPlugin>\n slashMenu: {\n dynamicOptions: Array<\n ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => SlashMenuGroup[]\n >\n groupsWithOptions: SlashMenuGroup[]\n }\n}\n"],"names":[],"rangeMappings":"","mappings":"AA8XA,WA+BC"}
@@ -1 +1 @@
1
- {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,+BAA+B,EAKhC,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAQnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE;QACX,CAAC,UAAU,EAAE,MAAM,GAAG;YACpB,MAAM,EAAE,+BAA+B,EAAE,CAAA;SAC1C,CAAA;KACF,CAAA;CACF,CAAA;AASD,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CAsIzB,CAAA"}
1
+ {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/feature.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,+BAA+B,EAKhC,MAAM,eAAe,CAAA;AAKtB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAQnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE;QACX,CAAC,UAAU,EAAE,MAAM,GAAG;YACpB,MAAM,EAAE,+BAA+B,EAAE,CAAA;SAC1C,CAAA;KACF,CAAA;CACF,CAAA;AASD,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CAmJzB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { traverseFields } from '@payloadcms/next/utilities';
2
+ import { sanitizeFields } from 'payload/config';
2
3
  import { createNode } from '../typeUtilities.js';
3
4
  import { UploadFeatureClientComponent } from './feature.client.js';
4
5
  import { UploadNode } from './nodes/UploadNode.js';
@@ -26,7 +27,18 @@ export const UploadFeature = (props)=>{
26
27
  }
27
28
  }
28
29
  return {
29
- feature: ()=>{
30
+ feature: async ({ config: _config })=>{
31
+ const validRelationships = _config.collections.map((c)=>c.slug) || [];
32
+ for(const collection in props.collections){
33
+ if (props.collections[collection].fields?.length) {
34
+ props.collections[collection].fields = await sanitizeFields({
35
+ config: _config,
36
+ fields: props.collections[collection].fields,
37
+ requireFieldLevelRichTextEditor: true,
38
+ validRelationships
39
+ });
40
+ }
41
+ }
30
42
  return {
31
43
  ClientComponent: UploadFeatureClientComponent,
32
44
  clientFeatureProps: clientProps,
@@ -111,7 +123,7 @@ export const UploadFeature = (props)=>{
111
123
  uploadPopulationPromiseHOC(props)
112
124
  ],
113
125
  validations: [
114
- uploadValidation()
126
+ uploadValidation(props)
115
127
  ]
116
128
  })
117
129
  ],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/upload/feature.server.ts"],"sourcesContent":["import type {\n Field,\n FieldWithRichTextRequiredEditor,\n FileData,\n FileSize,\n Payload,\n TypeWithID,\n} from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { UploadFeaturePropsClient } from './feature.client.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { UploadFeatureClientComponent } from './feature.client.js'\nimport { UploadNode } from './nodes/UploadNode.js'\nimport { uploadPopulationPromiseHOC } from './populationPromise.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections: {\n [collection: string]: {\n fields: FieldWithRichTextRequiredEditor[]\n }\n }\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: FeatureProviderProviderServer<\n UploadFeatureProps,\n UploadFeaturePropsClient\n> = (props) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = { collections: {} }\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 return {\n feature: () => {\n return {\n ClientComponent: UploadFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n if (!props?.collections) return null\n\n const schemaMap = new Map<string, Field[]>()\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const collection in props.collections) {\n if (props.collections[collection].fields?.length) {\n schemaMap.set(collection, props.collections[collection].fields)\n traverseFields({\n config,\n fields: props.collections[collection].fields,\n i18n,\n schemaMap,\n schemaPath: collection,\n validRelationships,\n })\n }\n }\n\n return schemaMap\n },\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ node, payload }) => {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n if (payload) {\n let uploadDocument: TypeWithID & FileData\n\n try {\n uploadDocument = (await payload.findByID({\n id,\n collection: node.relationTo,\n })) as TypeWithID & FileData\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?.url, payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument?.mimeType?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.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 (!uploadDocument?.sizes || !Object.keys(uploadDocument?.sizes).length) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.filename}\" width=\"${uploadDocument?.width}\" height=\"${uploadDocument?.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.sizes) {\n const imageSize: FileSize & {\n url?: string\n } = uploadDocument.sizes[size]\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, 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.width}\" height=\"${uploadDocument.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${id}\" />`\n }\n },\n nodeTypes: [UploadNode.getType()],\n },\n },\n node: UploadNode,\n populationPromises: [uploadPopulationPromiseHOC(props)],\n validations: [uploadValidation()],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'upload',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","createNode","UploadFeatureClientComponent","UploadNode","uploadPopulationPromiseHOC","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","props","collections","clientProps","collection","hasExtraFields","fields","length","feature","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","schemaMap","Map","validRelationships","map","c","slug","set","schemaPath","nodes","converters","html","converter","node","id","value","uploadDocument","findByID","relationTo","ignored","console","error","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","populationPromises","validations","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AASA,SAASA,cAAc,QAAQ,6BAA4B;AAK3D,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,4BAA4B,QAAQ,sBAAqB;AAClE,SAASC,UAAU,QAAQ,wBAAuB;AAClD,SAASC,0BAA0B,QAAQ,yBAAwB;AACnE,SAASC,gBAAgB,QAAQ,gBAAe;AAUhD;;CAEC,GACD,SAASC,eAAeC,GAAW,EAAEC,OAAgB;IACnD,OAAOD,KAAKE,WAAW,UAAUF,MAAM,AAACC,CAAAA,SAASE,QAAQC,aAAa,EAAC,IAAKJ;AAC9E;AAEA,OAAO,MAAMK,gBAGT,CAACC;IACH,IAAI,CAACA,OAAO;QACVA,QAAQ;YAAEC,aAAa,CAAC;QAAE;IAC5B;IAEA,MAAMC,cAAwC;QAAED,aAAa,CAAC;IAAE;IAChE,IAAID,MAAMC,WAAW,EAAE;QACrB,IAAK,MAAME,cAAcH,MAAMC,WAAW,CAAE;YAC1CC,YAAYD,WAAW,CAACE,WAAW,GAAG;gBACpCC,gBAAgBJ,MAAMC,WAAW,CAACE,WAAW,CAACE,MAAM,CAACC,MAAM,IAAI;YACjE;QACF;IACF;IAEA,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBnB;gBACjBoB,oBAAoBP;gBACpBQ,mBAAmB,CAAC,EAAEb,MAAM,EAAEc,IAAI,EAAEX,KAAK,EAAE;oBACzC,IAAI,CAACA,OAAOC,aAAa,OAAO;oBAEhC,MAAMW,YAAY,IAAIC;oBACtB,MAAMC,qBAAqBjB,OAAOI,WAAW,CAACc,GAAG,CAAC,CAACC,IAAMA,EAA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,WAAW,EAAEX,gBAAgBY,OAAO,GAAG,CAAC;wCACrI;wCAEA;;qBAEC,GACD,IAAIC,cAAc;wCAElB,qDAAqD;wCACrD,IAAK,MAAMC,QAAQd,eAAeQ,KAAK,CAAE;4CACvC,MAAMO,YAEFf,eAAeQ,KAAK,CAACM,KAAK;4CAE9B,kDAAkD;4CAClD,IACE,CAACC,UAAUJ,KAAK,IAChB,CAACI,UAAUH,MAAM,IACjB,CAACG,UAAUT,QAAQ,IACnB,CAACS,UAAUC,QAAQ,IACnB,CAACD,UAAUR,QAAQ,IACnB,CAACQ,UAAUhD,GAAG,EACd;gDACA;4CACF;4CACA,MAAMkD,eAAenD,eAAeiD,WAAWhD,KAAKC;4CAEpD6C,eAAe,CAAC,gBAAgB,EAAEI,aAAa,qBAAqB,EAAEF,UAAUJ,KAAK,CAAC,WAAW,EAAEI,UAAUT,QAAQ,CAAC,EAAE,CAAC;wCAC3H;wCAEA,0BAA0B;wCAC1BO,eAAe,CAAC,UAAU,EAAE9C,IAAI,qBAAqB,EAAEiC,eAAeW,KAAK,CAAC,UAAU,EAAEX,eAAeY,MAAM,CAAC,EAAE,CAAC;wCACjHC,eAAe;wCACf,OAAOA;oCACT,OAAO;wCACL,OAAO,CAAC,UAAU,EAAEf,GAAG,IAAI,CAAC;oCAC9B;gCACF;gCACAoB,WAAW;oCAACvD,WAAWwD,OAAO;iCAAG;4BACnC;wBACF;wBACAtB,MAAMlC;wBACNyD,oBAAoB;4BAACxD,2BAA2BS;yBAAO;wBACvDgD,aAAa;4BAACxD;yBAAmB;oBACnC;iBACD;gBACDyD,oBAAoBjD;YACtB;QACF;QACAkD,KAAK;QACLD,oBAAoBjD;IACtB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/upload/feature.server.ts"],"sourcesContent":["import type { Config } from 'payload/config'\nimport type {\n Field,\n FieldWithRichTextRequiredEditor,\n FileData,\n FileSize,\n Payload,\n TypeWithID,\n} from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\nimport { sanitizeFields } from 'payload/config'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { UploadFeaturePropsClient } from './feature.client.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { UploadFeatureClientComponent } from './feature.client.js'\nimport { UploadNode } from './nodes/UploadNode.js'\nimport { uploadPopulationPromiseHOC } from './populationPromise.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections: {\n [collection: string]: {\n fields: FieldWithRichTextRequiredEditor[]\n }\n }\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: FeatureProviderProviderServer<\n UploadFeatureProps,\n UploadFeaturePropsClient\n> = (props) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = { collections: {} }\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 return {\n feature: async ({ config: _config }) => {\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n for (const collection in props.collections) {\n if (props.collections[collection].fields?.length) {\n props.collections[collection].fields = (await sanitizeFields({\n config: _config as unknown as Config,\n fields: props.collections[collection].fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })) as FieldWithRichTextRequiredEditor[]\n }\n }\n\n return {\n ClientComponent: UploadFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n if (!props?.collections) return null\n\n const schemaMap = new Map<string, Field[]>()\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const collection in props.collections) {\n if (props.collections[collection].fields?.length) {\n schemaMap.set(collection, props.collections[collection].fields)\n traverseFields({\n config,\n fields: props.collections[collection].fields,\n i18n,\n schemaMap,\n schemaPath: collection,\n validRelationships,\n })\n }\n }\n\n return schemaMap\n },\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ node, payload }) => {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n if (payload) {\n let uploadDocument: TypeWithID & FileData\n\n try {\n uploadDocument = (await payload.findByID({\n id,\n collection: node.relationTo,\n })) as TypeWithID & FileData\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?.url, payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument?.mimeType?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.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 (!uploadDocument?.sizes || !Object.keys(uploadDocument?.sizes).length) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.filename}\" width=\"${uploadDocument?.width}\" height=\"${uploadDocument?.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.sizes) {\n const imageSize: FileSize & {\n url?: string\n } = uploadDocument.sizes[size]\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, 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.width}\" height=\"${uploadDocument.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${id}\" />`\n }\n },\n nodeTypes: [UploadNode.getType()],\n },\n },\n node: UploadNode,\n populationPromises: [uploadPopulationPromiseHOC(props)],\n validations: [uploadValidation(props)],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'upload',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","sanitizeFields","createNode","UploadFeatureClientComponent","UploadNode","uploadPopulationPromiseHOC","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","props","collections","clientProps","collection","hasExtraFields","fields","length","feature","_config","validRelationships","map","c","slug","requireFieldLevelRichTextEditor","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","schemaMap","Map","set","schemaPath","nodes","converters","html","converter","node","id","value","uploadDocument","findByID","relationTo","ignored","console","error","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","populationPromises","validations","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAUA,SAASA,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,cAAc,QAAQ,iBAAgB;AAK/C,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,4BAA4B,QAAQ,sBAAqB;AAClE,SAASC,UAAU,QAAQ,wBAAuB;AAClD,SAASC,0BAA0B,QAAQ,yBAAwB;AACnE,SAASC,gBAAgB,QAAQ,gBAAe;AAUhD;;CAEC,GACD,SAASC,eAAeC,GAAW,EAAEC,OAAgB;IACnD,OAAOD,KAAKE,WAAW,UAAUF,MAAM,AAACC,CAAAA,SAASE,QAAQC,aAAa,EAAC,IAAKJ;AAC9E;AAEA,OAAO,MAAMK,gBAGT,CAACC;IACH,IAAI,CAACA,OAAO;QACVA,QAAQ;YAAEC,aAAa,CAAC;QAAE;IAC5B;IAEA,MAAMC,cAAwC;Q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IACnB,CAACS,UAAUC,QAAQ,IACnB,CAACD,UAAUR,QAAQ,IACnB,CAACQ,UAAUlD,GAAG,EACd;gDACA;4CACF;4CACA,MAAMoD,eAAerD,eAAemD,WAAWlD,KAAKC;4CAEpD+C,eAAe,CAAC,gBAAgB,EAAEI,aAAa,qBAAqB,EAAEF,UAAUJ,KAAK,CAAC,WAAW,EAAEI,UAAUT,QAAQ,CAAC,EAAE,CAAC;wCAC3H;wCAEA,0BAA0B;wCAC1BO,eAAe,CAAC,UAAU,EAAEhD,IAAI,qBAAqB,EAAEmC,eAAeW,KAAK,CAAC,UAAU,EAAEX,eAAeY,MAAM,CAAC,EAAE,CAAC;wCACjHC,eAAe;wCACf,OAAOA;oCACT,OAAO;wCACL,OAAO,CAAC,UAAU,EAAEf,GAAG,IAAI,CAAC;oCAC9B;gCACF;gCACAoB,WAAW;oCAACzD,WAAW0D,OAAO;iCAAG;4BACnC;wBACF;wBACAtB,MAAMpC;wBACN2D,oBAAoB;4BAAC1D,2BAA2BS;yBAAO;wBACvDkD,aAAa;4BAAC1D,iBAAiBQ;yBAAO;oBACxC;iBACD;gBACDmD,oBAAoBnD;YACtB;QACF;QACAoD,KAAK;QACLD,oBAAoBnD;IACtB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/populationPromise.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAKjE,eAAO,MAAM,0BAA0B,WAC7B,kBAAkB,KACzB,kBAAkB,oBAAoB,CAyExC,CAAA"}
1
+ {"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/populationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAKjE,eAAO,MAAM,0BAA0B,WAC7B,kBAAkB,KACzB,kBAAkB,oBAAoB,CA6DxC,CAAA"}
@@ -1,9 +1,7 @@
1
- import { sanitizeFields } from 'payload/config';
2
1
  import { populate } from '../../../populate/populate.js';
3
2
  import { recurseNestedFields } from '../../../populate/recurseNestedFields.js';
4
3
  export const uploadPopulationPromiseHOC = (props)=>{
5
4
  return ({ context, currentDepth, depth, editorPopulationPromises, field, fieldPromises, findMany, flattenLocales, node, overrideAccess, populationPromises, req, showHiddenFields })=>{
6
- const payloadConfig = req.payload.config;
7
5
  if (node?.value) {
8
6
  const collection = req.payload.collections[node?.relationTo];
9
7
  if (collection) {
@@ -24,15 +22,7 @@ export const uploadPopulationPromiseHOC = (props)=>{
24
22
  }));
25
23
  }
26
24
  if (Array.isArray(props?.collections?.[node?.relationTo]?.fields)) {
27
- const validRelationships = payloadConfig.collections.map((c)=>c.slug) || [];
28
- // TODO: Sanitize & transform ahead of time! On startup!
29
- const sanitizedFields = sanitizeFields({
30
- config: payloadConfig,
31
- fields: props?.collections?.[node?.relationTo]?.fields,
32
- requireFieldLevelRichTextEditor: true,
33
- validRelationships
34
- });
35
- if (!sanitizedFields?.length) {
25
+ if (!props?.collections?.[node?.relationTo]?.fields?.length) {
36
26
  return;
37
27
  }
38
28
  recurseNestedFields({
@@ -42,7 +32,7 @@ export const uploadPopulationPromiseHOC = (props)=>{
42
32
  depth,
43
33
  editorPopulationPromises,
44
34
  fieldPromises,
45
- fields: sanitizedFields,
35
+ fields: props?.collections?.[node?.relationTo]?.fields,
46
36
  findMany,
47
37
  flattenLocales,
48
38
  overrideAccess,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/upload/populationPromise.ts"],"sourcesContent":["import { sanitizeFields } from 'payload/config'\n\nimport type { PopulationPromise } from '../types.js'\nimport type { UploadFeatureProps } from './feature.server.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { populate } from '../../../populate/populate.js'\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const uploadPopulationPromiseHOC = (\n props?: UploadFeatureProps,\n): PopulationPromise<SerializedUploadNode> => {\n return ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n const payloadConfig = req.payload.config\n\n if (node?.value) {\n const collection = req.payload.collections[node?.relationTo]\n\n if (collection) {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n populationPromises.push(\n populate({\n id,\n collection,\n currentDepth,\n data: node,\n depth,\n field,\n key: 'value',\n overrideAccess,\n req,\n showHiddenFields,\n }),\n )\n }\n if (Array.isArray(props?.collections?.[node?.relationTo]?.fields)) {\n const validRelationships = payloadConfig.collections.map((c) => c.slug) || []\n\n // TODO: Sanitize & transform ahead of time! On startup!\n const sanitizedFields = sanitizeFields({\n config: payloadConfig,\n fields: props?.collections?.[node?.relationTo]?.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })\n\n if (!sanitizedFields?.length) {\n return\n }\n recurseNestedFields({\n context,\n currentDepth,\n data: node.fields || {},\n depth,\n editorPopulationPromises,\n fieldPromises,\n fields: sanitizedFields,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: node.fields || {},\n })\n }\n }\n }\n}\n"],"names":["sanitizeFields","populate","recurseNestedFields","uploadPopulationPromiseHOC","props","context","currentDepth","depth","editorPopulationPromises","field","fieldPromises","findMany","flattenLocales","node","overrideAccess","populationPromises","req","showHiddenFields","payloadConfig","payload","config","value","collection","collections","relationTo","id","push","data","key","Array","isArray","fields","validRelationships","map","c","slug","sanitizedFields","requireFieldLevelRichTextEditor","length","siblingDoc"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,QAAQ,iBAAgB;AAM/C,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,mBAAmB,QAAQ,2CAA0C;AAE9E,OAAO,MAAMC,6BAA6B,CACxCC;IAEA,OAAO,CAAC,EACNC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,wBAAwB,EACxBC,KAAK,EACLC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EACjB;QACC,MAAMC,gBAAgBF,IAAIG,OAAO,CAACC,MAAM;QAExC,IAAIP,MAAMQ,OAAO;YACf,MAAMC,aAAaN,IAAIG,OAAO,CAACI,WAAW,CAACV,MAAMW,WAAW;YAE5D,IAAIF,YAAY;gBACd,mBAAmB;gBACnB,MAAMG,KAAKZ,MAAMQ,OAAOI,MAAMZ,MAAMQ,MAAM,8BAA8B;;gBAExEN,mBAAmBW,IAAI,CACrBzB,SAAS;oBACPwB;oBACAH;oBACAhB;oBACAqB,MAAMd;oBACNN;oBACAE;oBACAmB,KAAK;oBACLd;oBACAE;oBACAC;gBACF;YAEJ;YACA,IAAIY,MAAMC,OAAO,CAAC1B,OAAOmB,aAAa,CAACV,MAAMW,WAAW,EAAEO,SAAS;gBACjE,MAAMC,qBAAqBd,cAAcK,WAAW,CAACU,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;gBAE7E,wDAAwD;gBACxD,MAAMC,kBAAkBpC,eAAe;oBACrCoB,QAAQF;oBACRa,QAAQ3B,OAAOmB,aAAa,CAACV,MAAMW,WAAW,EAAEO;oBAChDM,iCAAiC;oBACjCL;gBACF;gBAEA,IAAI,CAACI,iBAAiBE,QAAQ;oBAC5B;gBACF;gBACApC,oBAAoB;oBAClBG;oBACAC;oBACAqB,MAAMd,KAAKkB,MAAM,IAAI,CAAC;oBACtBxB;oBACAC;oBACAE;oBACAqB,QAAQK;oBACRzB;oBACAC;oBACAE;oBACAC;oBACAC;oBACAC;oBACAsB,YAAY1B,KAAKkB,MAAM,IAAI,CAAC;gBAC9B;YACF;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/upload/populationPromise.ts"],"sourcesContent":["import type { PopulationPromise } from '../types.js'\nimport type { UploadFeatureProps } from './feature.server.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { populate } from '../../../populate/populate.js'\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const uploadPopulationPromiseHOC = (\n props?: UploadFeatureProps,\n): PopulationPromise<SerializedUploadNode> => {\n return ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n if (node?.value) {\n const collection = req.payload.collections[node?.relationTo]\n\n if (collection) {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n populationPromises.push(\n populate({\n id,\n collection,\n currentDepth,\n data: node,\n depth,\n field,\n key: 'value',\n overrideAccess,\n req,\n showHiddenFields,\n }),\n )\n }\n if (Array.isArray(props?.collections?.[node?.relationTo]?.fields)) {\n if (!props?.collections?.[node?.relationTo]?.fields?.length) {\n return\n }\n recurseNestedFields({\n context,\n currentDepth,\n data: node.fields || {},\n depth,\n editorPopulationPromises,\n fieldPromises,\n fields: props?.collections?.[node?.relationTo]?.fields,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: node.fields || {},\n })\n }\n }\n }\n}\n"],"names":["populate","recurseNestedFields","uploadPopulationPromiseHOC","props","context","currentDepth","depth","editorPopulationPromises","field","fieldPromises","findMany","flattenLocales","node","overrideAccess","populationPromises","req","showHiddenFields","value","collection","payload","collections","relationTo","id","push","data","key","Array","isArray","fields","length","siblingDoc"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,mBAAmB,QAAQ,2CAA0C;AAE9E,OAAO,MAAMC,6BAA6B,CACxCC;IAEA,OAAO,CAAC,EACNC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,wBAAwB,EACxBC,KAAK,EACLC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EACjB;QACC,IAAIJ,MAAMK,OAAO;YACf,MAAMC,aAAaH,IAAII,OAAO,CAACC,WAAW,CAACR,MAAMS,WAAW;YAE5D,IAAIH,YAAY;gBACd,mBAAmB;gBACnB,MAAMI,KAAKV,MAAMK,OAAOK,MAAMV,MAAMK,MAAM,8BAA8B;;gBAExEH,mBAAmBS,IAAI,CACrBvB,SAAS;oBACPsB;oBACAJ;oBACAb;oBACAmB,MAAMZ;oBACNN;oBACAE;oBACAiB,KAAK;oBACLZ;oBACAE;oBACAC;gBACF;YAEJ;YACA,IAAIU,MAAMC,OAAO,CAACxB,OAAOiB,aAAa,CAACR,MAAMS,WAAW,EAAEO,SAAS;gBACjE,IAAI,CAACzB,OAAOiB,aAAa,CAACR,MAAMS,WAAW,EAAEO,QAAQC,QAAQ;oBAC3D;gBACF;gBACA5B,oBAAoB;oBAClBG;oBACAC;oBACAmB,MAAMZ,KAAKgB,MAAM,IAAI,CAAC;oBACtBtB;oBACAC;oBACAE;oBACAmB,QAAQzB,OAAOiB,aAAa,CAACR,MAAMS,WAAW,EAAEO;oBAChDlB;oBACAC;oBACAE;oBACAC;oBACAC;oBACAC;oBACAc,YAAYlB,KAAKgB,MAAM,IAAI,CAAC;gBAC9B;YACF;QACF;IACF;AACF,EAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { NodeValidation } from '../types.js';
2
+ import type { UploadFeatureProps } from './feature.server.js';
2
3
  import type { SerializedUploadNode } from './nodes/UploadNode.js';
3
- export declare const uploadValidation: () => NodeValidation<SerializedUploadNode>;
4
+ export declare const uploadValidation: (props: UploadFeatureProps) => NodeValidation<SerializedUploadNode>;
4
5
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAIjE,eAAO,MAAM,gBAAgB,QAAO,eAAe,oBAAoB,CAuBtE,CAAA"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,eAAO,MAAM,gBAAgB,UACpB,kBAAkB,KACxB,eAAe,oBAAoB,CAsDrC,CAAA"}
@@ -1,17 +1,39 @@
1
+ import { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema';
1
2
  import { isValidID } from 'payload/utilities';
2
- import { CAN_USE_DOM } from '../../lexical/utils/canUseDOM.js';
3
- export const uploadValidation = ()=>{
4
- return ({ node, validation: { options: { req: { payload, t } } } })=>{
5
- if (!CAN_USE_DOM) {
6
- const idType = payload.collections[node.relationTo].customIDType || payload.db.defaultIDType;
7
- // @ts-expect-error
8
- const id = node?.value?.id || node?.value // for backwards-compatibility
9
- ;
10
- if (!isValidID(id, idType)) {
11
- return t('validation:validUploadID');
3
+ export const uploadValidation = (props)=>{
4
+ return async ({ node, validation: { options: { id, operation, preferences, req, req: { payload, t } } } })=>{
5
+ const idType = payload.collections[node.relationTo].customIDType || payload.db.defaultIDType;
6
+ // @ts-expect-error
7
+ const nodeID = node?.value?.id || node?.value // for backwards-compatibility
8
+ ;
9
+ if (!isValidID(nodeID, idType)) {
10
+ return t('validation:validUploadID');
11
+ }
12
+ if (Object.keys(props?.collections).length === 0) {
13
+ return true;
14
+ }
15
+ const collection = props?.collections[node.relationTo];
16
+ if (!collection.fields?.length) {
17
+ return true;
18
+ }
19
+ const result = await buildStateFromSchema({
20
+ id,
21
+ data: node?.fields ?? {},
22
+ fieldSchema: collection.fields,
23
+ operation: operation === 'create' || operation === 'update' ? operation : 'update',
24
+ preferences,
25
+ req,
26
+ siblingData: node?.fields ?? {}
27
+ });
28
+ let errorPaths = [];
29
+ for(const fieldKey in result){
30
+ if (result[fieldKey].errorPaths) {
31
+ errorPaths = errorPaths.concat(result[fieldKey].errorPaths);
12
32
  }
13
33
  }
14
- // TODO: validate upload collection fields
34
+ if (errorPaths.length) {
35
+ return 'Upload fields validation failed: ' + errorPaths.join(', ');
36
+ }
15
37
  return true;
16
38
  };
17
39
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/upload/validate.ts"],"sourcesContent":["import { isValidID } from 'payload/utilities'\n\nimport type { NodeValidation } from '../types.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { CAN_USE_DOM } from '../../lexical/utils/canUseDOM.js'\n\nexport const uploadValidation = (): NodeValidation<SerializedUploadNode> => {\n return ({\n node,\n validation: {\n options: {\n req: { payload, t },\n },\n },\n }) => {\n if (!CAN_USE_DOM) {\n const idType = payload.collections[node.relationTo].customIDType || payload.db.defaultIDType\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n if (!isValidID(id, idType)) {\n return t('validation:validUploadID')\n }\n }\n\n // TODO: validate upload collection fields\n\n return true\n }\n}\n"],"names":["isValidID","CAN_USE_DOM","uploadValidation","node","validation","options","req","payload","t","idType","collections","relationTo","customIDType","db","defaultIDType","id","value"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAK7C,SAASC,WAAW,QAAQ,mCAAkC;AAE9D,OAAO,MAAMC,mBAAmB;IAC9B,OAAO,CAAC,EACNC,IAAI,EACJC,YAAY,EACVC,SAAS,EACPC,KAAK,EAAEC,OAAO,EAAEC,CAAC,EAAE,EACpB,EACF,EACF;QACC,IAAI,CAACP,aAAa;YAChB,MAAMQ,SAASF,QAAQG,WAAW,CAACP,KAAKQ,UAAU,CAAC,CAACC,YAAY,IAAIL,QAAQM,EAAE,CAACC,aAAa;YAC5F,mBAAmB;YACnB,MAAMC,KAAKZ,MAAMa,OAAOD,MAAMZ,MAAMa,MAAM,8BAA8B;;YAExE,IAAI,CAAChB,UAAUe,IAAIN,SAAS;gBAC1B,OAAOD,EAAE;YACX;QACF;QAEA,0CAA0C;QAE1C,OAAO;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/upload/validate.ts"],"sourcesContent":["import { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport { isValidID } from 'payload/utilities'\n\nimport type { NodeValidation } from '../types.js'\nimport type { UploadFeatureProps } from './feature.server.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nexport const uploadValidation = (\n props: UploadFeatureProps,\n): NodeValidation<SerializedUploadNode> => {\n return async ({\n node,\n validation: {\n options: {\n id,\n operation,\n preferences,\n req,\n req: { payload, t },\n },\n },\n }) => {\n const idType = payload.collections[node.relationTo].customIDType || payload.db.defaultIDType\n // @ts-expect-error\n const nodeID = node?.value?.id || node?.value // for backwards-compatibility\n\n if (!isValidID(nodeID, idType)) {\n return t('validation:validUploadID')\n }\n\n if (Object.keys(props?.collections).length === 0) {\n return true\n }\n\n const collection = props?.collections[node.relationTo]\n\n if (!collection.fields?.length) {\n return true\n }\n\n const result = await buildStateFromSchema({\n id,\n data: node?.fields ?? {},\n fieldSchema: collection.fields,\n operation: operation === 'create' || operation === 'update' ? operation : 'update',\n preferences,\n req,\n siblingData: node?.fields ?? {},\n })\n\n let errorPaths = []\n for (const fieldKey in result) {\n if (result[fieldKey].errorPaths) {\n errorPaths = errorPaths.concat(result[fieldKey].errorPaths)\n }\n }\n\n if (errorPaths.length) {\n return 'Upload fields validation failed: ' + errorPaths.join(', ')\n }\n\n return true\n }\n}\n"],"names":["buildStateFromSchema","isValidID","uploadValidation","props","node","validation","options","id","operation","preferences","req","payload","t","idType","collections","relationTo","customIDType","db","defaultIDType","nodeID","value","Object","keys","length","collection","fields","result","data","fieldSchema","siblingData","errorPaths","fieldKey","concat","join"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,SAAS,QAAQ,oBAAmB;AAM7C,OAAO,MAAMC,mBAAmB,CAC9BC;IAEA,OAAO,OAAO,EACZC,IAAI,EACJC,YAAY,EACVC,SAAS,EACPC,EAAE,EACFC,SAAS,EACTC,WAAW,EACXC,GAAG,EACHA,KAAK,EAAEC,OAAO,EAAEC,CAAC,EAAE,EACpB,EACF,EACF;QACC,MAAMC,SAASF,QAAQG,WAAW,CAACV,KAAKW,UAAU,CAAC,CAACC,YAAY,IAAIL,QAAQM,EAAE,CAACC,aAAa;QAC5F,mBAAmB;QACnB,MAAMC,SAASf,MAAMgB,OAAOb,MAAMH,MAAMgB,MAAM,8BAA8B;;QAE5E,IAAI,CAACnB,UAAUkB,QAAQN,SAAS;YAC9B,OAAOD,EAAE;QACX;QAEA,IAAIS,OAAOC,IAAI,CAACnB,OAAOW,aAAaS,MAAM,KAAK,GAAG;YAChD,OAAO;QACT;QAEA,MAAMC,aAAarB,OAAOW,WAAW,CAACV,KAAKW,UAAU,CAAC;QAEtD,IAAI,CAACS,WAAWC,MAAM,EAAEF,QAAQ;YAC9B,OAAO;QACT;QAEA,MAAMG,SAAS,MAAM1B,qBAAqB;YACxCO;YACAoB,MAAMvB,MAAMqB,UAAU,CAAC;YACvBG,aAAaJ,WAAWC,MAAM;YAC9BjB,WAAWA,cAAc,YAAYA,cAAc,WAAWA,YAAY;YAC1EC;YACAC;YACAmB,aAAazB,MAAMqB,UAAU,CAAC;QAChC;QAEA,IAAIK,aAAa,EAAE;QACnB,IAAK,MAAMC,YAAYL,OAAQ;YAC7B,IAAIA,MAAM,CAACK,SAAS,CAACD,UAAU,EAAE;gBAC/BA,aAAaA,WAAWE,MAAM,CAACN,MAAM,CAACK,SAAS,CAACD,UAAU;YAC5D;QACF;QAEA,IAAIA,WAAWP,MAAM,EAAE;YACrB,OAAO,sCAAsCO,WAAWG,IAAI,CAAC;QAC/D;QAEA,OAAO;IACT;AACF,EAAC"}
@@ -27,7 +27,7 @@ export const LexicalEditor = (props)=>{
27
27
  const [isSmallWidthViewport, setIsSmallWidthViewport] = useState(false);
28
28
  useEffect(()=>{
29
29
  const updateViewPortWidth = ()=>{
30
- const isNextSmallWidthViewport = window.matchMedia('(max-width: 1025px)').matches;
30
+ const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches;
31
31
  if (isNextSmallWidthViewport !== isSmallWidthViewport) {
32
32
  setIsSmallWidthViewport(isNextSmallWidthViewport);
33
33
  }