@payloadcms/richtext-lexical 3.0.0-alpha.48 → 3.0.0-alpha.49

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 (89) hide show
  1. package/dist/cell/index.d.ts.map +1 -1
  2. package/dist/cell/index.js +6 -5
  3. package/dist/cell/index.js.map +1 -1
  4. package/dist/field/Field.d.ts +2 -1
  5. package/dist/field/Field.d.ts.map +1 -1
  6. package/dist/field/Field.js +7 -4
  7. package/dist/field/Field.js.map +1 -1
  8. package/dist/field/features/blocks/component/BlockContent.d.ts +2 -2
  9. package/dist/field/features/blocks/component/BlockContent.d.ts.map +1 -1
  10. package/dist/field/features/blocks/component/BlockContent.js +34 -16
  11. package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
  12. package/dist/field/features/blocks/component/FormSavePlugin.d.ts.map +1 -1
  13. package/dist/field/features/blocks/component/FormSavePlugin.js +2 -1
  14. package/dist/field/features/blocks/component/FormSavePlugin.js.map +1 -1
  15. package/dist/field/features/blocks/component/index.d.ts.map +1 -1
  16. package/dist/field/features/blocks/component/index.js +10 -8
  17. package/dist/field/features/blocks/component/index.js.map +1 -1
  18. package/dist/field/features/blocks/drawer/index.d.ts.map +1 -1
  19. package/dist/field/features/blocks/drawer/index.js +4 -1
  20. package/dist/field/features/blocks/drawer/index.js.map +1 -1
  21. package/dist/field/features/blocks/feature.client.d.ts +1 -1
  22. package/dist/field/features/blocks/feature.client.d.ts.map +1 -1
  23. package/dist/field/features/blocks/feature.client.js.map +1 -1
  24. package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
  25. package/dist/field/features/blocks/feature.server.js +4 -11
  26. package/dist/field/features/blocks/feature.server.js.map +1 -1
  27. package/dist/field/features/createClientComponent.d.ts +1 -2
  28. package/dist/field/features/createClientComponent.d.ts.map +1 -1
  29. package/dist/field/features/createFeaturePropComponent.d.ts.map +1 -1
  30. package/dist/field/features/createFeaturePropComponent.js +3 -2
  31. package/dist/field/features/createFeaturePropComponent.js.map +1 -1
  32. package/dist/field/features/link/drawer/index.d.ts.map +1 -1
  33. package/dist/field/features/link/drawer/index.js +16 -10
  34. package/dist/field/features/link/drawer/index.js.map +1 -1
  35. package/dist/field/features/link/plugins/autoLink/index.js +1 -1
  36. package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
  37. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  38. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +4 -1
  39. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  40. package/dist/field/features/relationship/drawer/index.js +1 -1
  41. package/dist/field/features/relationship/drawer/index.js.map +1 -1
  42. package/dist/field/features/relationship/feature.client.js +1 -1
  43. package/dist/field/features/relationship/feature.client.js.map +1 -1
  44. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  45. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +5 -1
  46. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  47. package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
  48. package/dist/field/features/relationship/plugins/index.js +2 -2
  49. package/dist/field/features/relationship/plugins/index.js.map +1 -1
  50. package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.d.ts.map +1 -1
  51. package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.js +2 -1
  52. package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.js.map +1 -1
  53. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts +2 -2
  54. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
  55. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +17 -9
  56. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
  57. package/dist/field/features/upload/component/index.d.ts.map +1 -1
  58. package/dist/field/features/upload/component/index.js +10 -2
  59. package/dist/field/features/upload/component/index.js.map +1 -1
  60. package/dist/field/features/upload/drawer/index.js +1 -1
  61. package/dist/field/features/upload/drawer/index.js.map +1 -1
  62. package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
  63. package/dist/field/features/upload/plugin/index.js +1 -1
  64. package/dist/field/features/upload/plugin/index.js.map +1 -1
  65. package/dist/field/index.d.ts +1 -1
  66. package/dist/field/index.d.ts.map +1 -1
  67. package/dist/field/index.js +5 -5
  68. package/dist/field/index.js.map +1 -1
  69. package/dist/field/lexical/LexicalProvider.d.ts +1 -1
  70. package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
  71. package/dist/field/lexical/LexicalProvider.js.map +1 -1
  72. package/dist/field/lexical/config/client/EditorConfigProvider.d.ts +1 -1
  73. package/dist/field/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  74. package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
  75. package/dist/field/lexical/plugins/SlashMenu/index.js +1 -1
  76. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  77. package/dist/generateComponentMap.d.ts.map +1 -1
  78. package/dist/generateComponentMap.js +5 -3
  79. package/dist/generateComponentMap.js.map +1 -1
  80. package/dist/generateSchemaMap.d.ts.map +1 -1
  81. package/dist/generateSchemaMap.js +2 -1
  82. package/dist/generateSchemaMap.js.map +1 -1
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +15 -19
  85. package/dist/index.js.map +1 -1
  86. package/dist/useLexicalFeature.d.ts.map +1 -1
  87. package/dist/useLexicalFeature.js +3 -3
  88. package/dist/useLexicalFeature.js.map +1 -1
  89. package/package.json +10 -8
@@ -3,9 +3,13 @@ import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.
3
3
  const { useLexicalComposerContext } = lexicalComposerContextImport;
4
4
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js';
5
5
  import { getTranslation } from '@payloadcms/translations';
6
- import { Button, useConfig, useDocumentDrawer, usePayloadAPI, useTranslation } from '@payloadcms/ui';
7
6
  import lexicalImport from 'lexical';
8
7
  const { $getNodeByKey } = lexicalImport;
8
+ import { Button } from '@payloadcms/ui/elements/Button';
9
+ import { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer';
10
+ import usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI';
11
+ import { useConfig } from '@payloadcms/ui/providers/Config';
12
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
9
13
  import React, { useCallback, useReducer, useState } from 'react';
10
14
  import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
11
15
  import { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, useDocumentDrawer, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport type { ElementFormatType } from 'lexical'\n\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: {\n relationTo,\n value: { id },\n },\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":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","Button","useConfig","useDocumentDrawer","usePayloadAPI","useTranslation","lexicalImport","$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"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,EAAEC,SAAS,EAAEC,iBAAiB,EAAEC,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AACpG,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAI1B,OAAOE,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAIhE,SAASC,sBAAsB,QAAQ,4DAA2D;AAClG,SAASC,uCAAuC,QAAQ,2BAA0B;AAClF,OAAO,e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9D;IACpC,qBAAO,oBAACD,WAAcC;AACxB,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport type { ElementFormatType } from 'lexical'\n\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 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: {\n relationTo,\n value: { id },\n },\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":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","lexicalImport","$getNodeByKey","Button","useDocumentDrawer","usePayloadAPI","useConfig","useTranslation","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"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAI1B,SAASE,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,OAAOC,mBAAmB,qCAAoC;AAC9D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAIhE,SAASC,sBAAsB,QAAQ,4DAA2D;AAClG,SAASC,uCAAuC,QAAQ,2BAA0B;AAClF,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAUA,MAAMC,YAA6B,CAACC;IAClC,MAAM,EACJC,QAAQ,EACRC,MAAM,EACJC,UAAU,EACVC,OAAO,EAAEC,EA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AACC,SAASC,IAAI,CAAC;QACpFC,iBAAiB;qBAEjB,oBAACL;QAAIC,WAAW,CAAC,EAAEzC,UAAU,MAAM,CAAC;qBAClC,oBAAC8C;QAAEL,WAAW,CAAC,EAAEzC,UAAU,OAAO,CAAC;OAChC0B,EAAE,4BAA4B;QAC7BqB,OAAO7D,eAAekC,kBAAkB4B,MAAM,CAACC,QAAQ,EAAExB;IAC3D,mBAEF,oBAACO;QAAsBS,WAAW,CAAC,EAAEzC,UAAU,oBAAoB,CAAC;qBAClE,oBAAC8C;QAAEL,WAAW,CAAC,EAAEzC,UAAU,OAAO,CAAC;OAChCM,OAAOA,IAAI,CAACc,mBAAmB8B,OAAOC,cAAc,KAAK,GAAG1C,OAIlEE,OAAOyC,UAAU,oBAChB,oBAACZ;QAAIC,WAAW,CAAC,EAAEzC,UAAU,SAAS,CAAC;qBACrC,oBAACX;QACCgE,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,oBAACrC;QACCgE,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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAKpE,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,wBAAwB,GAAG,KAAK,CAAC,SAAS,CAqDpF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAKpE,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,wBAAwB,GAAG,KAAK,CAAC,SAAS,CAqDpF"}
@@ -3,9 +3,9 @@ import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.
3
3
  const { useLexicalComposerContext } = lexicalComposerContextImport;
4
4
  import lexicalUtilsImport from '@lexical/utils';
5
5
  const { $insertNodeToNearestRoot } = lexicalUtilsImport;
6
- import { useConfig } from '@payloadcms/ui';
7
6
  import lexicalImport from 'lexical';
8
7
  const { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } = lexicalImport;
8
+ import { useConfig } from '@payloadcms/ui/providers/Config';
9
9
  import { useEffect } from 'react';
10
10
  import React from 'react';
11
11
  import { RelationshipDrawer } from '../drawer/index.js';
@@ -18,7 +18,7 @@ export function RelationshipPlugin(props) {
18
18
  if (props?.enabledCollections) {
19
19
  enabledRelations = props?.enabledCollections;
20
20
  } else if (props?.disabledCollections) {
21
- enabledRelations = collections.filter(({ slug })=>!(props?.disabledCollections).includes(slug)).map(({ slug })=>slug);
21
+ enabledRelations = collections.filter(({ slug })=>!props?.disabledCollections?.includes(slug)).map(({ slug })=>slug);
22
22
  }
23
23
  useEffect(()=>{
24
24
  if (!editor.hasNodes([
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $insertNodeToNearestRoot } = lexicalUtilsImport\nimport { useConfig } from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} = lexicalImport\n\nimport type { LexicalCommand } from 'lexical'\n\nimport { useEffect } from 'react'\nimport React from 'react'\n\nimport type { RelationshipFeatureProps } from '../feature.server.js'\nimport type { RelationshipData } from '../nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport function RelationshipPlugin(props?: RelationshipFeatureProps): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n let enabledRelations: string[] = null\n\n if (props?.enabledCollections) {\n enabledRelations = props?.enabledCollections\n } else if (props?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !(props?.disabledCollections).includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const relationshipNode = $createRelationshipNode(payload)\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(relationshipNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$insertNodeToNearestRoot","useConfig","lexicalImport","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","React","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","props","editor","collections","enabledRelations","enabledCollections","disabledCollections","filter","slug","includes","map","hasNodes","Error","registerCommand","payload","relationshipNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","node","length","remove","enabledCollectionSlugs"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AACrC,SAASE,SAAS,QAAQ,iBAAgB;AAC1C,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EACJC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,E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AACU;KAAO;IAEX,qBAAO,oBAACN;QAAmB8B,wBAAwBtB;;AACrD"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $insertNodeToNearestRoot } = lexicalUtilsImport\nimport lexicalImport from 'lexical'\nconst {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} = lexicalImport\n\nimport type { LexicalCommand } from 'lexical'\n\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useEffect } from 'react'\nimport React from 'react'\n\nimport type { RelationshipFeatureProps } from '../feature.server.js'\nimport type { RelationshipData } from '../nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport function RelationshipPlugin(props?: RelationshipFeatureProps): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n let enabledRelations: string[] = null\n\n if (props?.enabledCollections) {\n enabledRelations = props?.enabledCollections\n } else if (props?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !props?.disabledCollections?.includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const relationshipNode = $createRelationshipNode(payload)\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(relationshipNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$insertNodeToNearestRoot","lexicalImport","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useConfig","useEffect","React","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","props","editor","collections","enabledRelations","enabledCollections","disabledCollections","filter","slug","includes","map","hasNodes","Error","registerCommand","payload","relationshipNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","node","length","remove","enabledCollectionSlugs"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AACrC,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EACJC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,EACd,GAAGN;AAIJ,SAASO,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,QAAO;AACjC,OAAOC,WAAW,QAAO;AAKzB,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,+BAA8B;AAExF,OAAO,MAAMC,8BAAgEP,cAC3E,+BACD;AAED,OAAO,SAASQ,mBAAmBC,KAAgC;IACjE,MAAM,CAACC,OAAO,GAAGnB;IACjB,MAAM,EAAEoB,WAAW,EAAE,GAAGV;IAExB,IAAIW,mBAA6B;IAEjC,IAAIH,OAAOI,oBAAoB;QAC7BD,mBAAmBH,OAAOI;IAC5B,OAAO,IAAIJ,OAAOK,qBAAqB;QACrCF,mBAAmBD,YAChBI,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAK,CAACP,OAAOK,qBAAqBG,SAASD,OAC3DE,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACvB;IAEAd,UAAU;QACR,IAAI,CAACQ,OAAOS,QAAQ,CAAC;YAACb;SAAiB,GAAG;YACxC,MAAM,IAAIc,MAAM;QAClB;QAEA,OAAOV,OAAOW,eAAe,CAC3Bd,6BACA,CAACe;YACC,MAAMC,mBAAmBlB,wBAAwBiB;YAEjD,MAAME,YAAY5B,mBAAmBD;YAErC,IAAIG,kBAAkB0B,YAAY;gBAChC,MAAM,EAAEC,KAAK,EAAE,GAAGD;gBAClB,MAAME,YAAYD,MAAME,OAAO;gBAE/B,+FAA+F;gBAC/F,0FAA0F;gBAC1F,IACE9B,iBAAiB6B,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXf,MAAM,CAAC,CAACgB,OAASlC,iBAAiBkC,OAAOC,MAAM,GAAG,GACrD;oBACAN,UAAUO,MAAM;gBAClB;gBAEAxC,yBAAyB8B;YAC3B;YAEA,OAAO;QACT,GACAxB;IAEJ,GAAG;QAACW;KAAO;IAEX,qBAAO,oBAACN;QAAmB8B,wBAAwBtB;;AACrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"EnabledRelationshipsCondition.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/utils/EnabledRelationshipsCondition.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAwB9B,eAAO,MAAM,6BAA6B,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAavD,CAAA"}
1
+ {"version":3,"file":"EnabledRelationshipsCondition.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/utils/EnabledRelationshipsCondition.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAwB9B,eAAO,MAAM,6BAA6B,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAavD,CAAA"}
@@ -1,4 +1,5 @@
1
- import { useAuth, useConfig } from '@payloadcms/ui';
1
+ import { useAuth } from '@payloadcms/ui/providers/Auth';
2
+ import { useConfig } from '@payloadcms/ui/providers/Config';
2
3
  import * as React from 'react';
3
4
  const filterRichTextCollections = (collections, options)=>{
4
5
  return collections.filter(({ admin: { enableRichTextRelationship, hidden }, upload })=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/utils/EnabledRelationshipsCondition.tsx"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport { useAuth, useConfig } from '@payloadcms/ui'\nimport * as React from 'react'\n\ntype options = {\n uploads: boolean\n user: User\n}\n\ntype FilteredCollectionsT = (\n collections: SanitizedCollectionConfig[],\n options?: options,\n) => SanitizedCollectionConfig[]\nconst filterRichTextCollections: FilteredCollectionsT = (collections, options) => {\n return collections.filter(({ admin: { enableRichTextRelationship, hidden }, upload }) => {\n if (hidden === true || (typeof hidden === 'function' && hidden({ user: options.user }))) {\n return false\n }\n if (options?.uploads) {\n return enableRichTextRelationship && Boolean(upload) === true\n }\n\n return upload ? false : enableRichTextRelationship\n })\n}\n\nexport const EnabledRelationshipsCondition: React.FC<any> = (props) => {\n const { children, uploads = false, ...rest } = props\n const { collections } = useConfig()\n const { user } = useAuth()\n const [enabledCollectionSlugs] = React.useState(() =>\n filterRichTextCollections(collections, { uploads, user }).map(({ slug }) => slug),\n )\n\n if (!enabledCollectionSlugs.length) {\n return null\n }\n\n return React.cloneElement(children, { ...rest, enabledCollectionSlugs })\n}\n"],"names":["useAuth","useConfig","React","filterRichTextCollections","collections","options","filter","admin","enableRichTextRelationship","hidden","upload","user","uploads","Boolean","EnabledRelationshipsCondition","props","children","rest","enabledCollectionSlugs","useState","map","slug","length","cloneElement"],"mappings":"AAGA,SAASA,OAAO,EAAEC,SAAS,QAAQ,iBAAgB;AACnD,YAAYC,WAAW,QAAO;AAW9B,MAAMC,4BAAkD,CAACC,aAAaC;IACpE,OAAOD,YAAYE,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAEC,0BAA0B,EAAEC,MAAM,EAAE,EAAEC,MAAM,EAAE;QAClF,IAAID,WAAW,QAAS,OAAOA,WAAW,cAAcA,OAAO;YAAEE,MAAMN,QAAQM,IAAI;QAAC,IAAK;YACvF,OAAO;QACT;QACA,IAAIN,SAASO,SAAS;YACpB,OAAOJ,8BAA8BK,QAAQH,YAAY;QAC3D;QAEA,OAAOA,SAAS,QAAQF;IAC1B;AACF;AAEA,OAAO,MAAMM,gCAA+C,CAACC;IAC3D,MAAM,EAAEC,QAAQ,EAAEJ,UAAU,KAAK,EAAE,GAAGK,MAAM,GAAGF;IAC/C,MAAM,EAAEX,WAAW,EAAE,GAAGH;IACxB,MAAM,EAAEU,IAAI,EAAE,GAAGX;IACjB,MAAM,CAACkB,uBAAuB,GAAGhB,MAAMiB,QAAQ,CAAC,IAC9ChB,0BAA0BC,aAAa;YAAEQ;YAASD;QAAK,GAAGS,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAG9E,IAAI,CAACH,uBAAuBI,MAAM,EAAE;QAClC,OAAO;IACT;IAEA,qBAAOpB,MAAMqB,YAAY,CAACP,UAAU;QAAE,GAAGC,IAAI;QAAEC;IAAuB;AACxE,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/utils/EnabledRelationshipsCondition.tsx"],"sourcesContent":["import type { ClientUser } from 'payload/auth'\nimport type { ClientCollectionConfig } from 'payload/types'\n\nimport { useAuth } from '@payloadcms/ui/providers/Auth'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport * as React from 'react'\n\ntype options = {\n uploads: boolean\n user: ClientUser\n}\n\ntype FilteredCollectionsT = (\n collections: ClientCollectionConfig[],\n options?: options,\n) => ClientCollectionConfig[]\nconst filterRichTextCollections: FilteredCollectionsT = (collections, options) => {\n return collections.filter(({ admin: { enableRichTextRelationship, hidden }, upload }) => {\n if (hidden === true || (typeof hidden === 'function' && hidden({ user: options.user }))) {\n return false\n }\n if (options?.uploads) {\n return enableRichTextRelationship && Boolean(upload) === true\n }\n\n return upload ? false : enableRichTextRelationship\n })\n}\n\nexport const EnabledRelationshipsCondition: React.FC<any> = (props) => {\n const { children, uploads = false, ...rest } = props\n const { collections } = useConfig()\n const { user } = useAuth()\n const [enabledCollectionSlugs] = React.useState(() =>\n filterRichTextCollections(collections, { uploads, user }).map(({ slug }) => slug),\n )\n\n if (!enabledCollectionSlugs.length) {\n return null\n }\n\n return React.cloneElement(children, { ...rest, enabledCollectionSlugs })\n}\n"],"names":["useAuth","useConfig","React","filterRichTextCollections","collections","options","filter","admin","enableRichTextRelationship","hidden","upload","user","uploads","Boolean","EnabledRelationshipsCondition","props","children","rest","enabledCollectionSlugs","useState","map","slug","length","cloneElement"],"mappings":"AAGA,SAASA,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,YAAYC,WAAW,QAAO;AAW9B,MAAMC,4BAAkD,CAACC,aAAaC;IACpE,OAAOD,YAAYE,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAEC,0BAA0B,EAAEC,MAAM,EAAE,EAAEC,MAAM,EAAE;QAClF,IAAID,WAAW,QAAS,OAAOA,WAAW,cAAcA,OAAO;YAAEE,MAAMN,QAAQM,IAAI;QAAC,IAAK;YACvF,OAAO;QACT;QACA,IAAIN,SAASO,SAAS;YACpB,OAAOJ,8BAA8BK,QAAQH,YAAY;QAC3D;QAEA,OAAOA,SAAS,QAAQF;IAC1B;AACF;AAEA,OAAO,MAAMM,gCAA+C,CAACC;IAC3D,MAAM,EAAEC,QAAQ,EAAEJ,UAAU,KAAK,EAAE,GAAGK,MAAM,GAAGF;IAC/C,MAAM,EAAEX,WAAW,EAAE,GAAGH;IACxB,MAAM,EAAEU,IAAI,EAAE,GAAGX;IACjB,MAAM,CAACkB,uBAAuB,GAAGhB,MAAMiB,QAAQ,CAAC,IAC9ChB,0BAA0BC,aAAa;YAAEQ;YAASD;QAAK,GAAGS,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAG9E,IAAI,CAACH,uBAAuBI,MAAM,EAAE;QAClC,OAAO;IACT;IAEA,qBAAOpB,MAAMqB,YAAY,CAACP,UAAU;QAAE,GAAGC,IAAI;QAAEC;IAAuB;AACxE,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { SanitizedCollectionConfig } from 'payload/types';
1
+ import type { ClientCollectionConfig } from 'payload/types';
2
2
  import React from 'react';
3
3
  import type { ElementProps } from '../index.js';
4
4
  /**
@@ -7,6 +7,6 @@ import type { ElementProps } from '../index.js';
7
7
  */
8
8
  export declare const ExtraFieldsUploadDrawer: React.FC<ElementProps & {
9
9
  drawerSlug: string;
10
- relatedCollection: SanitizedCollectionConfig;
10
+ relatedCollection: ClientCollectionConfig;
11
11
  }>;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/upload/component/ExtraFieldsDrawer/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,yBAAyB,EAAE,MAAM,eAAe,CAAA;AAuBzE,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAC5C,YAAY,GAAG;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,yBAAyB,CAAA;CAC7C,CA4GF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/upload/component/ExtraFieldsDrawer/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAa,MAAM,eAAe,CAAA;AAoBtE,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAC5C,YAAY,GAAG;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,sBAAsB,CAAA;CAC1C,CAgHF,CAAA"}
@@ -3,9 +3,17 @@ import * as facelessUIImport from '@faceless-ui/modal';
3
3
  import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
4
4
  const { useLexicalComposerContext } = lexicalComposerContextImport;
5
5
  import { getTranslation } from '@payloadcms/translations';
6
- import { Drawer, FieldPathProvider, Form, FormSubmit, RenderFields, getFormState, useConfig, useDocumentInfo, useFieldPath, useTranslation } from '@payloadcms/ui';
7
6
  import lexicalImport from 'lexical';
8
7
  const { $getNodeByKey } = lexicalImport;
8
+ import { Drawer } from '@payloadcms/ui/elements/Drawer';
9
+ import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
10
+ import { Form } from '@payloadcms/ui/forms/Form';
11
+ import { RenderFields } from '@payloadcms/ui/forms/RenderFields';
12
+ import { FormSubmit } from '@payloadcms/ui/forms/Submit';
13
+ import { useConfig } from '@payloadcms/ui/providers/Config';
14
+ import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
15
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
16
+ import { getFormState } from '@payloadcms/ui/utilities/getFormState';
9
17
  import { deepCopyObject } from 'payload/utilities';
10
18
  import React, { useCallback, useEffect, useState } from 'react';
11
19
  import { v4 as uuid } from 'uuid';
@@ -20,7 +28,7 @@ import { useEditorConfigContext } from '../../../../lexical/config/client/Editor
20
28
  const { closeModal } = useModal();
21
29
  const { i18n, t } = useTranslation();
22
30
  const { id } = useDocumentInfo();
23
- const { schemaPath } = useFieldPath();
31
+ const { schemaPath } = useFieldProps();
24
32
  const config = useConfig();
25
33
  const [initialState, setInitialState] = useState(false);
26
34
  const { field: { richTextComponentMap } } = useEditorConfigContext();
@@ -92,11 +100,8 @@ import { useEditorConfigContext } from '../../../../lexical/config/client/Editor
92
100
  title: t('general:editLabel', {
93
101
  label: getTranslation(relatedCollection.labels.singular, i18n)
94
102
  })
95
- }, initialState !== false && /*#__PURE__*/ React.createElement(FieldPathProvider, {
96
- path: "",
97
- schemaPath: ""
98
- }, /*#__PURE__*/ React.createElement(Form, {
99
- // @ts-expect-error // TODO: Fix this type. Is this correct?
103
+ }, initialState !== false && /*#__PURE__*/ React.createElement(Form, {
104
+ // @ts-expect-error TODO: Fix this
100
105
  fields: fieldMap,
101
106
  initialState: initialState,
102
107
  onChange: [
@@ -106,8 +111,11 @@ import { useEditorConfigContext } from '../../../../lexical/config/client/Editor
106
111
  uuid: uuid()
107
112
  }, /*#__PURE__*/ React.createElement(RenderFields, {
108
113
  fieldMap: Array.isArray(fieldMap) ? fieldMap : [],
109
- forceRender: true
110
- }), /*#__PURE__*/ React.createElement(FormSubmit, null, t('fields:saveChanges')))));
114
+ forceRender: true,
115
+ path: "",
116
+ readOnly: false,
117
+ schemaPath: ""
118
+ }), /*#__PURE__*/ React.createElement(FormSubmit, null, t('fields:saveChanges'))));
111
119
  };
112
120
 
113
121
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/upload/component/ExtraFieldsDrawer/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState, SanitizedCollectionConfig } from 'payload/types'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Drawer,\n FieldPathProvider,\n Form,\n type FormProps,\n FormSubmit,\n RenderFields,\n getFormState,\n useConfig,\n useDocumentInfo,\n useFieldPath,\n useTranslation,\n} from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport { deepCopyObject } from 'payload/utilities'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { UploadData, UploadNode } from '../../nodes/UploadNode.js'\nimport type { ElementProps } from '../index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\n\n/**\n * This handles the extra fields, e.g. captions or alt text, which are\n * potentially added to the upload feature.\n */\nexport const ExtraFieldsUploadDrawer: React.FC<\n ElementProps & {\n drawerSlug: string\n relatedCollection: SanitizedCollectionConfig\n }\n> = (props) => {\n const { useModal } = facelessUIImport\n\n const {\n data: { fields, relationTo, value },\n drawerSlug,\n nodeKey,\n relatedCollection,\n } = props\n\n const [editor] = useLexicalComposerContext()\n\n const { closeModal } = useModal()\n\n const { i18n, t } = useTranslation()\n const { id } = useDocumentInfo()\n const { schemaPath } = useFieldPath()\n const config = useConfig()\n const [initialState, setInitialState] = useState<FormState | false>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedFieldsPath = `feature.upload.fields.${relatedCollection.slug}`\n const schemaFieldsPath = `${schemaPath}.feature.upload.${relatedCollection.slug}`\n\n const fieldMap = richTextComponentMap.get(componentMapRenderedFieldsPath) // Field Schema\n\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: deepCopyObject(fields || {}),\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id, fields])\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n return await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n },\n\n [config.routes.api, config.serverURL, schemaFieldsPath, id],\n )\n\n const handleUpdateEditData = useCallback(\n (_, data) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: UploadNode | null = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n\n closeModal(drawerSlug)\n },\n [closeModal, editor, drawerSlug, nodeKey],\n )\n\n return (\n <Drawer\n slug={drawerSlug}\n title={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n >\n {initialState !== false && (\n <FieldPathProvider path=\"\" schemaPath=\"\">\n <Form\n // @ts-expect-error // TODO: Fix this type. Is this correct?\n fields={fieldMap}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleUpdateEditData}\n uuid={uuid()}\n >\n <RenderFields fieldMap={Array.isArray(fieldMap) ? fieldMap : []} forceRender />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n </FieldPathProvider>\n )}\n </Drawer>\n )\n}\n"],"names":["facelessUIImport","lexicalComposerContextImport","useLexicalComposerContext","getTranslation","Drawer","FieldPathProvider","Form","FormSubmit","RenderFields","getFormState","useConfig","useDocumentInfo","useFieldPath","useTranslation","lexicalImport","$getNodeByKey","deepCopyObject","React","useCallback","useEffect","useState","v4","uuid","useEditorConfigContext","ExtraFieldsUploadDrawer","props","useModal","data","fields","relationTo","value","drawerSlug","nodeKey","relatedCollection","editor","closeModal","i18n","t","id","schemaPath","config","initialState","setInitialState","field","richTextComponentMap","componentMapRenderedFieldsPath","slug","schemaFieldsPath","fieldMap","get","awaitInitialState","state","apiRoute","routes","api","body","operation","serverURL","onChange","formState","prevFormState","handleUpdateEditData","_","update","uploadNode","newData","getData","setData","title","label","labels","singular","path","onSubmit","Array","isArray","forceRender"],"mappings":"AAAA;AAGA,YAAYA,sBAAsB,qBAAoB;AACtD,OAAOC,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EAEJC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,YAAY,EACZC,cAAc,QACT,iBAAgB;AACvB,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAASE,cAAc,QAAQ,oBAAmB;AAClD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC/D,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAKjC,SAASC,sBAAsB,QAAQ,4DAA2D;AAElG;;;CAGC,GACD,OAAO,MAAMC,0BAKT,CAACC;IACH,MAAM,EAAEC,QAAQ,EAAE,GAAG1B;IAErB,MAAM,EACJ2B,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,KAAK,EAAE,EACnCC,UAAU,EACVC,OAAO,EACPC,iBAAiB,EAClB,GAAGR;IAEJ,MAAM,CAACS,OAAO,GAAGhC;IAEjB,MAAM,EAAEiC,UAAU,EAAE,GAAGT;IAEvB,MAAM,EAAEU,IAAI,EAAEC,CAAC,EAAE,GAAGxB;IACpB,MAAM,EAAEyB,EAAE,EAAE,GAAG3B;IACf,MAAM,EAAE4B,UAAU,EAAE,GAAG3B;IACvB,MAAM4B,SAAS9B;IACf,MAAM,CAAC+B,cAAcC,gBAAgB,GAAGtB,SAA4B;IACpE,MAAM,EACJuB,OAAO,EAAEC,oBAAoB,EAAE,EAChC,GAAGrB;IAEJ,MAAMsB,iCAAiC,CAAC,s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AG3C,qBACE,oBAAC5B;QACC0C,MAAMf;QACNqC,OAAO/B,EAAE,qBAAqB;YAC5BgC,OAAOlE,eAAe8B,kBAAkBqC,MAAM,CAACC,QAAQ,EAAEnC;QAC3D;OAECK,iBAAiB,uBAChB,oBAACpC;QAAkBmE,MAAK;QAAGjC,YAAW;qBACpC,oBAACjC;QACC,4DAA4D;QAC5DsB,QAAQoB;QACRP,cAAcA;QACdiB,UAAU;YAACA;SAAS;QACpBe,UAAUZ;QACVvC,MAAMA;qBAEN,oBAACd;QAAawC,UAAU0B,MAAMC,OAAO,CAAC3B,YAAYA,WAAW,EAAE;QAAE4B,aAAAA;sBACjE,oBAACrE,kBAAY8B,EAAE;AAM3B,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/upload/component/ExtraFieldsDrawer/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, FormState } from 'payload/types'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { getTranslation } from '@payloadcms/translations'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\nimport type { FormProps } from '@payloadcms/ui/forms/Form'\n\nimport { Drawer } from '@payloadcms/ui/elements/Drawer'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { Form } from '@payloadcms/ui/forms/Form'\nimport { RenderFields } from '@payloadcms/ui/forms/RenderFields'\nimport { FormSubmit } from '@payloadcms/ui/forms/Submit'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { getFormState } from '@payloadcms/ui/utilities/getFormState'\nimport { deepCopyObject } from 'payload/utilities'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { UploadData, UploadNode } from '../../nodes/UploadNode.js'\nimport type { ElementProps } from '../index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\n\n/**\n * This handles the extra fields, e.g. captions or alt text, which are\n * potentially added to the upload feature.\n */\nexport const ExtraFieldsUploadDrawer: React.FC<\n ElementProps & {\n drawerSlug: string\n relatedCollection: ClientCollectionConfig\n }\n> = (props) => {\n const { useModal } = facelessUIImport\n\n const {\n data: { fields, relationTo, value },\n drawerSlug,\n nodeKey,\n relatedCollection,\n } = props\n\n const [editor] = useLexicalComposerContext()\n\n const { closeModal } = useModal()\n\n const { i18n, t } = useTranslation()\n const { id } = useDocumentInfo()\n const { schemaPath } = useFieldProps()\n const config = useConfig()\n const [initialState, setInitialState] = useState<FormState | false>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedFieldsPath = `feature.upload.fields.${relatedCollection.slug}`\n const schemaFieldsPath = `${schemaPath}.feature.upload.${relatedCollection.slug}`\n\n const fieldMap = richTextComponentMap.get(componentMapRenderedFieldsPath) // Field Schema\n\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: deepCopyObject(fields || {}),\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id, fields])\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n return await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n },\n\n [config.routes.api, config.serverURL, schemaFieldsPath, id],\n )\n\n const handleUpdateEditData = useCallback(\n (_, data) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: UploadNode | null = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n\n closeModal(drawerSlug)\n },\n [closeModal, editor, drawerSlug, nodeKey],\n )\n\n return (\n <Drawer\n slug={drawerSlug}\n title={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n >\n {initialState !== false && (\n <Form\n // @ts-expect-error TODO: Fix this\n fields={fieldMap}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleUpdateEditData}\n uuid={uuid()}\n >\n <RenderFields\n fieldMap={Array.isArray(fieldMap) ? fieldMap : []}\n forceRender\n path=\"\"\n readOnly={false}\n schemaPath=\"\"\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )}\n </Drawer>\n )\n}\n"],"names":["facelessUIImport","lexicalComposerContextImport","useLexicalComposerContext","getTranslation","lexicalImport","$getNodeByKey","Drawer","useFieldProps","Form","RenderFields","FormSubmit","useConfig","useDocumentInfo","useTranslation","getFormState","deepCopyObject","React","useCallback","useEffect","useState","v4","uuid","useEditorConfigContext","ExtraFieldsUploadDrawer","props","useModal","data","fields","relationTo","value","drawerSlug","nodeKey","relatedCollection","editor","closeModal","i18n","t","id","schemaPath","config","initialState","setInitialState","field","richTextComponentMap","componentMapRenderedFieldsPath","slug","schemaFieldsPath","fieldMap","get","awaitInitialState","state","apiRoute","routes","api","body","operation","serverURL","onChange","formState","prevFormState","handleUpdateEditData","_","update","uploadNode","newData","getData","setData","title","label","labels","singular","onSubmit","Array","isArray","forceRender","path","readOnly"],"mappings":"AAAA;AAGA,YAAYA,sBAAsB,qBAAoB;AACtD,OAAOC,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAG1B,SAASE,MAAM,QAAQ,iCAAgC;AACvD,SAASC,aAAa,QA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UAAU;YAACA;SAAS;QACpBc,UAAUX;QACVvC,MAAMA;qBAEN,oBAACZ;QACCsC,UAAUyB,MAAMC,OAAO,CAAC1B,YAAYA,WAAW,EAAE;QACjD2B,aAAAA;QACAC,MAAK;QACLC,UAAU;QACVtC,YAAW;sBAEb,oBAAC5B,kBAAY0B,EAAE;AAKzB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/component/index.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAMxD,OAAO,cAAc,CAAA;AAQrB,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAEhB,CAAA;AA+ID,eAAO,MAAM,eAAe,UAAW,YAAY,KAAG,MAAM,SAM3D,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/component/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAMxD,OAAO,cAAc,CAAA;AAQrB,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAEhB,CAAA;AA+ID,eAAO,MAAM,eAAe,UAAW,YAAY,KAAG,MAAM,SAM3D,CAAA"}
@@ -3,9 +3,17 @@ import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.
3
3
  const { useLexicalComposerContext } = lexicalComposerContextImport;
4
4
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js';
5
5
  import { getTranslation } from '@payloadcms/translations';
6
- import { Button, DrawerToggler, FileGraphic, useConfig, useDocumentDrawer, useDrawerSlug, usePayloadAPI, useThumbnail, useTranslation } from '@payloadcms/ui';
7
6
  import lexicalImport from 'lexical';
8
7
  const { $getNodeByKey } = lexicalImport;
8
+ import { Button } from '@payloadcms/ui/elements/Button';
9
+ import { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer';
10
+ import { DrawerToggler } from '@payloadcms/ui/elements/Drawer';
11
+ import { useDrawerSlug } from '@payloadcms/ui/elements/Drawer';
12
+ import { File } from '@payloadcms/ui/graphics/File';
13
+ import usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI';
14
+ import { useThumbnail } from '@payloadcms/ui/hooks/useThumbnail';
15
+ import { useConfig } from '@payloadcms/ui/providers/Config';
16
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
9
17
  import React, { useCallback, useReducer, useState } from 'react';
10
18
  import { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js';
11
19
  import { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js';
@@ -71,7 +79,7 @@ const Component = (props)=>{
71
79
  }, thumbnailSRC ? /*#__PURE__*/ React.createElement("img", {
72
80
  alt: data?.filename,
73
81
  src: thumbnailSRC
74
- }) : /*#__PURE__*/ React.createElement(FileGraphic, null)), /*#__PURE__*/ React.createElement("div", {
82
+ }) : /*#__PURE__*/ React.createElement(File, null)), /*#__PURE__*/ React.createElement("div", {
75
83
  className: `${baseClass}__topRowRightPanel`
76
84
  }, /*#__PURE__*/ React.createElement("div", {
77
85
  className: `${baseClass}__collectionLabel`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/upload/component/index.tsx"],"sourcesContent":["'use client'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n DrawerToggler,\n FileGraphic,\n useConfig,\n useDocumentDrawer,\n useDrawerSlug,\n usePayloadAPI,\n useThumbnail,\n useTranslation,\n} from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport React, { useCallback, useReducer, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadData } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { ExtraFieldsUploadDrawer } from './ExtraFieldsDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n //uploadProps: UploadFeatureProps\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<SanitizedCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const thumbnailSRC = useThumbnail(relatedCollection.slug, relatedCollection.upload, data)\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (json) => {\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 dispatchCacheBust()\n closeDrawer()\n },\n [setParams, cacheBust, closeDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.clientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? <img alt={data?.filename} src={thumbnailSRC} /> : <FileGraphic />}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\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 removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","Button","DrawerToggler","FileGraphic","useConfig","useDocumentDrawer","useDrawerSlug","usePayloadAPI","useThumbnail","useTranslation","lexicalImport","$getNodeByKey","React","useCallback","useReducer","useState","useEditorConfigContext","EnabledRelationshipsCondition","INSERT_UPLOAD_WITH_DRAWER_COMMAND","ExtraFieldsUploadDrawer","baseClass","initialParams","depth","Component","props","data","fields","relationTo","value","nodeKey","collections","routes","api","serverURL","editor","isSelected","setSelected","clearSelection","editorConfig","field","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","find","coll","slug","drawerSlug","DocumentDrawer","DocumentDrawerToggler","closeDrawer","id","collectionSlug","setParams","thumbnailSRC","upload","removeUpload","update","remove","updateUpload","json","hasExtraFields","resolvedFeatureMap","get","clientFeatureProps","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","isEditable","disabled","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","dispatchCommand","replace","strong","onSave","UploadComponent","uploads"],"mappings":"AAAA;AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SACEC,M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../../../src/field/features/upload/component/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload/types'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport { DrawerToggler } from '@payloadcms/ui/elements/Drawer'\nimport { useDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { File } from '@payloadcms/ui/graphics/File'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useThumbnail } from '@payloadcms/ui/hooks/useThumbnail'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback, useReducer, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadData } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { ExtraFieldsUploadDrawer } from './ExtraFieldsDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n //uploadProps: UploadFeatureProps\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const thumbnailSRC = useThumbnail(relatedCollection.slug, relatedCollection.upload, data)\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (json) => {\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 dispatchCacheBust()\n closeDrawer()\n },\n [setParams, cacheBust, closeDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.clientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? <img alt={data?.filename} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\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 removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","lexicalImport","$getNodeByKey","Button","useDocumentDrawer","DrawerToggler","useDrawerSlug","File","usePayloadAPI","useThumbnail","useConfig","useTranslation","React","useCallback","useReducer","useState","useEditorConfigContext","EnabledRelationshipsCondition","INSERT_UPLOAD_WITH_DRAWER_COMMAND","ExtraFieldsUploadDrawer","baseClass","initialParams","depth","Component","props","data","fields","relationTo","value","nodeKey","collections","routes","api","serverURL","editor","isSelected","setSelected","clearSelection","editorConfig","field","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","find","coll","slug","drawerSlug","DocumentDrawer","DocumentDrawerToggler","closeDrawer","id","collectionSlug","setParams","thumbnailSRC","upload","removeUpload","update","remove","updateUpload","json","hasExtraFields","resolvedFeatureMap","get","clientFeatureProps","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","isEditable","disabled","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","dispatchCommand","replace","strong","onSave","UploadComponent","uploads"],"mappings":"AAAA;AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAASE,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,IAAI,QAAQ,+BAA8B;AACnD,OAAOC,mBAAmB,qCAAoC;AAC9D,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAMhE,SAASC,sBAAsB,QAAQ,yDAAwD;AAC/F,SAASC,6BAA6B,QAAQ,4DAA2D;AACzG,SAASC,iCAAiC,QAAQ,wBAAuB;AACzE,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAQA,MAAMC,YAAoC,CAACC;IACzC,MAAM,EACJC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,KAAK,EAAE,EAC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OAAAA;QACAC,SAASjD,EAAE;sBAEb,oBAACtC;QACCgF,aAAY;QACZd,WAAW,CAAC,EAAEjD,UAAU,cAAc,CAAC;QACvC6D,UAAU1C,OAAO2C;QACjBG,MAAK;QACLC,SAAS,CAACC;YACRA,EAAEC,cAAc;YAChB7B;QACF;QACA8B,OAAAA;QACAC,SAASjD,EAAE;yBAMrB,oBAAC2B;QAAIC,WAAW,CAAC,EAAEjD,UAAU,WAAW,CAAC;qBACvC,oBAACgC;QAAsBiB,WAAW,CAAC,EAAEjD,UAAU,oBAAoB,CAAC;qBAClE,oBAACyE,gBAAQpE,MAAMmD,cAIpBhD,OAAO0B,oBAAM,oBAACH;QAAe2C,QAAQhC;sBACtC,oBAAC3C;QACC+B,YAAYA;QACZL,mBAAmBA;QAClB,GAAGrB,KAAK;;AAIjB;AAEA,OAAO,MAAMuE,kBAAkB,CAACvE;IAC9B,qBACE,oBAACP;QAA+B,GAAGO,KAAK;QAAEwE,SAAAA;qBACxC,oBAACzE,WAAcC;AAGrB,EAAC"}
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
  import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
3
  const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import { useListDrawer } from '@payloadcms/ui';
5
4
  import lexicalImport from 'lexical';
6
5
  const { $getNodeByKey, COMMAND_PRIORITY_EDITOR } = lexicalImport;
6
+ import { useListDrawer } from '@payloadcms/ui/elements/ListDrawer';
7
7
  import React, { useCallback, useEffect, useState } from 'react';
8
8
  import { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js';
9
9
  import { $createUploadNode } from '../nodes/UploadNode.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/upload/drawer/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useListDrawer } from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey, COMMAND_PRIORITY_EDITOR } = lexicalImport\n\nimport type { LexicalEditor } from 'lexical'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { $createUploadNode } from '../nodes/UploadNode.js'\nimport { INSERT_UPLOAD_COMMAND } from '../plugin/index.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst baseClass = 'lexical-upload-drawer'\n\nconst insertUpload = ({\n id,\n editor,\n relationTo,\n replaceNodeKey,\n}: {\n editor: LexicalEditor\n id: string\n relationTo: string\n replaceNodeKey: null | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_UPLOAD_COMMAND, {\n id,\n fields: null,\n relationTo,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace(\n $createUploadNode({\n data: {\n fields: null,\n relationTo,\n value: {\n id,\n },\n },\n }),\n )\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: string[]\n}\n\nconst UploadDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer, openDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n uploads: true,\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_UPLOAD_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertUpload({\n id: docID,\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n })\n closeDrawer()\n },\n [editor, closeDrawer, replaceNodeKey],\n )\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const UploadDrawer = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useListDrawer","lexicalImport","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","EnabledRelationshipsCondition","$createUploadNode","INSERT_UPLOAD_COMMAND","INSERT_UPLOAD_WITH_DRAWER_COMMAND","baseClass","insertUpload","id","editor","relationTo","replaceNodeKey","dispatchCommand","fields","update","node","replace","data","value","UploadDrawerComponent","enabledCollectionSlugs","setReplaceNodeKey","ListDrawer","ListDrawerToggler","closeDrawer","openDrawer","collectionSlugs","uploads","registerCommand","payload","nodeKey","onSelect","collectionSlug","docID","UploadDrawer","props"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,aAAa,QAAQ,iBAAgB;AAC9C,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAEC,uBAAuB,EAAE,GAAGF;AAInD,OAAOG,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,6BAA6B,QAAQ,4DAA2D;AACzG,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,iCAAiC,QAAQ,gBAAe;AAEjE,MAAMC,YAAY;AAElB,MAAMC,eAAe,CAAC,EACpBC,EAAE,EACFC,MAAM,EACNC,UAAU,EACVC,cAAc,EAMf;IACC,IAAI,CAACA,gBAAgB;QACnBF,OAAOG,eAAe,CAACR,uBAAuB;YAC5CI;YACAK,QAAQ;YACRH;QACF;IACF,OAAO;QACLD,OAAOK,MAAM,CAAC;YACZ,MAAMC,OAAOnB,cAAce;YAC3B,IAAII,MAAM;gBACRA,KAAKC,OAAO,CACVb,kBAAkB;oBAChBc,MAAM;wBACJJ,QAAQ;wBACRH;wBACAQ,OAAO;4BACLV;wBACF;oBACF;gBACF;YAEJ;QACF;IACF;AACF;AAMA,MAAMW,wBAAyC,CAAC,EAAEC,sBAAsB,EAAE;IACxE,MAAM,CAACX,OAAO,GAAGhB;IAEjB,MAAM,CAACkB,gBAAgBU,kBAAkB,GAAGpB,SAAwB;IAEpE,MAAM,CAACqB,YAAYC,mBAAmB,EAAEC,WAAW,EAAEC,UAAU,EAAE,CAAC,GAAG/B,cAAc;QACjFgC,iBAAiBN;QACjBO,SAAS;IACX;IAEA3B,UAAU;QACR,OAAOS,OAAOmB,eAAe,CAG3BvB,mCACA,CAACwB;YACCR,kBAAkBQ,SAASb,UAAUa,SAASb,QAAQc,UAAU;YAChEL;YACA,OAAO;QACT,GACA5B;IAEJ,GAAG;QAACY;QAAQgB;KAAW;IAEvB,MAAMM,WAAWhC,YACf,CAAC,EAAEiC,cAAc,EAAEC,KAAK,EAAE;QACxB1B,aAAa;YACXC,IAAIyB;YACJxB;YACAC,YAAYsB;YACZrB;QACF;QACAa;IACF,GACA;QAACf;QAAQe;QAAab;KAAe;IAGvC,qBAAO,oBAACW;QAAWS,UAAUA;;AAC/B;AAEA,OAAO,MAAMG,eAAe,CAACC;IAC3B,qBACE,oBAACjC;QAA+B,GAAGiC,KAAK;QAAER,SAAAA;qBACxC,oBAACR,uBAA0BgB;AAGjC,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/features/upload/drawer/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey, COMMAND_PRIORITY_EDITOR } = lexicalImport\n\nimport type { LexicalEditor } from 'lexical'\n\nimport { useListDrawer } from '@payloadcms/ui/elements/ListDrawer'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { $createUploadNode } from '../nodes/UploadNode.js'\nimport { INSERT_UPLOAD_COMMAND } from '../plugin/index.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst baseClass = 'lexical-upload-drawer'\n\nconst insertUpload = ({\n id,\n editor,\n relationTo,\n replaceNodeKey,\n}: {\n editor: LexicalEditor\n id: string\n relationTo: string\n replaceNodeKey: null | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_UPLOAD_COMMAND, {\n id,\n fields: null,\n relationTo,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace(\n $createUploadNode({\n data: {\n fields: null,\n relationTo,\n value: {\n id,\n },\n },\n }),\n )\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: string[]\n}\n\nconst UploadDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer, openDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n uploads: true,\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_UPLOAD_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertUpload({\n id: docID,\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n })\n closeDrawer()\n },\n [editor, closeDrawer, replaceNodeKey],\n )\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const UploadDrawer = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalImport","$getNodeByKey","COMMAND_PRIORITY_EDITOR","useListDrawer","React","useCallback","useEffect","useState","EnabledRelationshipsCondition","$createUploadNode","INSERT_UPLOAD_COMMAND","INSERT_UPLOAD_WITH_DRAWER_COMMAND","baseClass","insertUpload","id","editor","relationTo","replaceNodeKey","dispatchCommand","fields","update","node","replace","data","value","UploadDrawerComponent","enabledCollectionSlugs","setReplaceNodeKey","ListDrawer","ListDrawerToggler","closeDrawer","openDrawer","collectionSlugs","uploads","registerCommand","payload","nodeKey","onSelect","collectionSlug","docID","UploadDrawer","props"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAEC,uBAAuB,EAAE,GAAGF;AAInD,SAASG,aAAa,QAAQ,qCAAoC;AAClE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,6BAA6B,QAAQ,4DAA2D;AACzG,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,iCAAiC,QAAQ,gBAAe;AAEjE,MAAMC,YAAY;AAElB,MAAMC,eAAe,CAAC,EACpBC,EAAE,EACFC,MAAM,EACNC,UAAU,EACVC,cAAc,EAMf;IACC,IAAI,CAACA,gBAAgB;QACnBF,OAAOG,eAAe,CAACR,uBAAuB;YAC5CI;YACAK,QAAQ;YACRH;QACF;IACF,OAAO;QACLD,OAAOK,MAAM,CAAC;YACZ,MAAMC,OAAOpB,cAAcgB;YAC3B,IAAII,MAAM;gBACRA,KAAKC,OAAO,CACVb,kBAAkB;oBAChBc,MAAM;wBACJJ,QAAQ;wBACRH;wBACAQ,OAAO;4BACLV;wBACF;oBACF;gBACF;YAEJ;QACF;IACF;AACF;AAMA,MAAMW,wBAAyC,CAAC,EAAEC,sBAAsB,EAAE;IACxE,MAAM,CAACX,OAAO,GAAGhB;IAEjB,MAAM,CAACkB,gBAAgBU,kBAAkB,GAAGpB,SAAwB;IAEpE,MAAM,CAACqB,YAAYC,mBAAmB,EAAEC,WAAW,EAAEC,UAAU,EAAE,CAAC,GAAG5B,cAAc;QACjF6B,iBAAiBN;QACjBO,SAAS;IACX;IAEA3B,UAAU;QACR,OAAOS,OAAOmB,eAAe,CAG3BvB,mCACA,CAACwB;YACCR,kBAAkBQ,SAASb,UAAUa,SAASb,QAAQc,UAAU;YAChEL;YACA,OAAO;QACT,GACA7B;IAEJ,GAAG;QAACa;QAAQgB;KAAW;IAEvB,MAAMM,WAAWhC,YACf,CAAC,EAAEiC,cAAc,EAAEC,KAAK,EAAE;QACxB1B,aAAa;YACXC,IAAIyB;YACJxB;YACAC,YAAYsB;YACZrB;QACF;QACAa;IACF,GACA;QAACf;QAAQe;QAAab;KAAe;IAGvC,qBAAO,oBAACW;QAAWS,UAAUA;;AAC/B;AAEA,OAAO,MAAMG,eAAe,CAACC;IAC3B,qBACE,oBAACjC;QAA+B,GAAGiC,KAAK;QAAER,SAAAA;qBACxC,oBAACR,uBAA0BgB;AAGjC,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/plugin/index.tsx"],"names":[],"mappings":";AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAK9D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAA;AAE5D,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAC9B,CAAA;AAExC,wBAAgB,YAAY,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAuDjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/plugin/index.tsx"],"names":[],"mappings":";AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAK9D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAA;AAE5D,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAC9B,CAAA;AAExC,wBAAgB,YAAY,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAuDjD"}
@@ -3,9 +3,9 @@ import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.
3
3
  const { useLexicalComposerContext } = lexicalComposerContextImport;
4
4
  import lexicalUtilsImport from '@lexical/utils';
5
5
  const { $insertNodeToNearestRoot, mergeRegister } = lexicalUtilsImport;
6
- import { useConfig } from '@payloadcms/ui';
7
6
  import lexicalImport from 'lexical';
8
7
  const { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } = lexicalImport;
8
+ import { useConfig } from '@payloadcms/ui/providers/Config';
9
9
  import React, { useEffect } from 'react';
10
10
  import { UploadDrawer } from '../drawer/index.js';
11
11
  import { $createUploadNode, UploadNode } from '../nodes/UploadNode.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/upload/plugin/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $insertNodeToNearestRoot, mergeRegister } = lexicalUtilsImport\nimport { useConfig } from '@payloadcms/ui'\nimport lexicalImport from 'lexical'\nconst {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} = lexicalImport\n\nimport type { LexicalCommand } from 'lexical'\n\nimport React, { useEffect } from 'react'\n\nimport type { RawUploadPayload } from '../nodes/UploadNode.js'\n\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<RawUploadPayload>\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\nexport function UploadPlugin(): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const uploadNode = $createUploadNode({\n data: {\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: {\n id: payload.id,\n },\n },\n })\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(uploadNode)\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={collections.map(({ slug }) => slug)} />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$insertNodeToNearestRoot","mergeRegister","useConfig","lexicalImport","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","React","useEffect","UploadDrawer","$createUploadNode","UploadNode","INSERT_UPLOAD_COMMAND","UploadPlugin","editor","collections","hasNodes","Error","registerCommand","payload","update","uploadNode","data","fields","relationTo","value","id","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove","enabledCollectionSlugs","map","slug"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,wBAAwB,EAAEC,aAAa,EAAE,GAAGF;AACpD,SAASG,SAAS,QAAQ,iBAAgB;AAC1C,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EACJC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,EACd,GAAGN;AAIJ,OAAOO,SAASC,SAAS,QAAQ,QAAO;AAIxC,SAASC,YAAY,QAAQ,qBAAoB;AACjD,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,yBAAwB;AAItE,OAAO,MAAMC,wBACXN,cAAc,yBAAwB;AAExC,OAAO,SAASO;IACd,MAAM,CAACC,OAAO,GAAGnB;IACjB,MAAM,EAAEoB,WAAW,EAAE,GAAGhB;IAExBS,UAAU;QACR,IAAI,CAACM,OAAOE,QAAQ,CAAC;YAACL;SAAW,GAAG;YAClC,MAAM,IAAIM,MAAM;QAClB;QAEA,OAAOnB,cACLgB,OAAOI,eAAe,CACpBN,uBACA,CAACO;YACCL,OAAOM,MAAM,CAAC;gBACZ,MAAMC,aAAaX,kBAAkB;oBACnCY,MAAM;wBACJC,QAAQJ,QAAQI,MAAM;wBACtBC,YAAYL,QAAQK,UAAU;wBAC9BC,OAAO;4BACLC,IAAIP,QAAQO,EAAE;wBAChB;oBACF;gBACF;gBAEA,MAAMC,YAAYzB,mBAAmBD;gBAErC,IAAIG,kBAAkBuB,YAAY;oBAChC,MAAM,EAAEC,KAAK,EAAE,GAAGD;oBAClB,MAAME,YAAYD,MAAME,OAAO;oBAE/B,+FAA+F;oBAC/F,0FAA0F;oBAC1F,IACE3B,iBAAiB0B,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXC,MAAM,CAAC,CAACC,OAAShC,iBAAiBgC,OAAOC,MAAM,GAAG,GACrD;wBACAP,UAAUQ,MAAM;oBAClB;oBAEAxC,yBAAyBwB;gBAC3B;YACF;YAEA,OAAO;QACT,GACAhB;IAGN,GAAG;QAACS;KAAO;IAEX,qBAAO,oBAACL;QAAa6B,wBAAwBvB,YAAYwB,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;;AAC7E"}
1
+ {"version":3,"sources":["../../../../../src/field/features/upload/plugin/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $insertNodeToNearestRoot, mergeRegister } = lexicalUtilsImport\nimport lexicalImport from 'lexical'\nconst {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} = lexicalImport\n\nimport type { LexicalCommand } from 'lexical'\n\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport React, { useEffect } from 'react'\n\nimport type { RawUploadPayload } from '../nodes/UploadNode.js'\n\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<RawUploadPayload>\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\nexport function UploadPlugin(): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const uploadNode = $createUploadNode({\n data: {\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: {\n id: payload.id,\n },\n },\n })\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(uploadNode)\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={collections.map(({ slug }) => slug)} />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$insertNodeToNearestRoot","mergeRegister","lexicalImport","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useConfig","React","useEffect","UploadDrawer","$createUploadNode","UploadNode","INSERT_UPLOAD_COMMAND","UploadPlugin","editor","collections","hasNodes","Error","registerCommand","payload","update","uploadNode","data","fields","relationTo","value","id","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove","enabledCollectionSlugs","map","slug"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,wBAAwB,EAAEC,aAAa,EAAE,GAAGF;AACpD,OAAOG,mBAAmB,UAAS;AACnC,MAAM,EACJC,qBAAqB,EACrBC,aAAa,EACb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C7E"}
@@ -1,5 +1,5 @@
1
+ import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
1
2
  import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js';
2
- import { type FormFieldBase } from '@payloadcms/ui';
3
3
  import React from 'react';
4
4
  export declare const RichTextField: React.FC<FormFieldBase & {
5
5
  lexicalEditorConfig: LexicalEditorConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/field/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,gBAAgB,CAAA;AAGlE,OAAO,KAA8C,MAAM,OAAO,CAAA;AAclE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,aAAa,GAAG;IACd,mBAAmB,EAAE,mBAAmB,CAAA;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;CACnD,CA4GF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/field/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAKnF,OAAO,KAA8C,MAAM,OAAO,CAAA;AAclE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,aAAa,GAAG;IACd,mBAAmB,EAAE,mBAAmB,CAAA;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;CACnD,CA4GF,CAAA"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
- import { ShimmerEffect } from '@payloadcms/ui';
3
- import { useFieldPath } from '@payloadcms/ui/forms';
4
- import { useClientFunctions } from '@payloadcms/ui/providers';
2
+ import { ShimmerEffect } from '@payloadcms/ui/elements/ShimmerEffect';
3
+ import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
4
+ import { useClientFunctions } from '@payloadcms/ui/providers/ClientFunction';
5
5
  import React, { Suspense, lazy, useEffect, useState } from 'react';
6
6
  import { defaultEditorLexicalConfig } from './lexical/config/client/default.js';
7
7
  import { loadClientFeatures } from './lexical/config/client/loader.js';
@@ -11,7 +11,7 @@ const RichTextEditor = /*#__PURE__*/ lazy(()=>import('./Field.js').then((module)
11
11
  })));
12
12
  export const RichTextField = (props)=>{
13
13
  const { lexicalEditorConfig, richTextComponentMap } = props;
14
- const { schemaPath } = useFieldPath();
14
+ const { schemaPath } = useFieldProps();
15
15
  const clientFunctions = useClientFunctions();
16
16
  const [hasLoadedFeatures, setHasLoadedFeatures] = useState(false);
17
17
  const [featureProviders, setFeatureProviders] = useState([]);
@@ -65,7 +65,7 @@ export const RichTextField = (props)=>{
65
65
  const featureComponentKeys = Array.from(richTextComponentMap.keys()).filter((key)=>key.startsWith(`feature.${featureProvider.key}.components.`));
66
66
  const featureComponents = featureComponentKeys.map((key)=>{
67
67
  return richTextComponentMap.get(key);
68
- })// TODO: Type better
68
+ }) // TODO: Type better
69
69
  ;
70
70
  return /*#__PURE__*/ React.createElement(React.Fragment, {
71
71
  key: featureProvider.key
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport { type FormFieldBase, ShimmerEffect } from '@payloadcms/ui'\nimport { useFieldPath } from '@payloadcms/ui/forms'\nimport { useClientFunctions } from '@payloadcms/ui/providers'\nimport React, { Suspense, lazy, useEffect, useState } from 'react'\n\nimport type { GeneratedFeatureProviderComponent } from '../types.js'\nimport type { FeatureProviderClient } from './features/types.js'\nimport type { SanitizedClientEditorConfig } from './lexical/config/types.js'\n\nimport { defaultEditorLexicalConfig } from './lexical/config/client/default.js'\nimport { loadClientFeatures } from './lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from './lexical/config/client/sanitize.js'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<\n FormFieldBase & {\n lexicalEditorConfig: LexicalEditorConfig\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n> = (props) => {\n const { lexicalEditorConfig, richTextComponentMap } = props\n const { schemaPath } = useFieldPath()\n const clientFunctions = useClientFunctions()\n const [hasLoadedFeatures, setHasLoadedFeatures] = useState(false)\n\n const [featureProviders, setFeatureProviders] = useState<FeatureProviderClient<unknown>[]>([])\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<SanitizedClientEditorConfig>(null)\n\n let featureProviderComponents: GeneratedFeatureProviderComponent[] = richTextComponentMap.get(\n 'features',\n ) as GeneratedFeatureProviderComponent[] // TODO: Type better\n // order by order\n featureProviderComponents = featureProviderComponents.sort((a, b) => a.order - b.order)\n\n const featureComponentsWithFeaturesLength =\n Array.from(richTextComponentMap.keys()).filter(\n (key) => key.startsWith(`feature.`) && !key.includes('.fields.'),\n ).length + featureProviderComponents.length\n\n useEffect(() => {\n if (!hasLoadedFeatures) {\n const featureProvidersLocal: FeatureProviderClient<unknown>[] = []\n let featureProvidersAndComponentsLoaded = 0\n\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (key.startsWith(`lexicalFeature.${schemaPath}.`)) {\n if (!key.includes('.components.')) {\n featureProvidersLocal.push(plugin)\n }\n featureProvidersAndComponentsLoaded++\n }\n })\n\n if (featureProvidersAndComponentsLoaded === featureComponentsWithFeaturesLength) {\n setFeatureProviders(featureProvidersLocal)\n setHasLoadedFeatures(true)\n\n /**\n * Loaded feature provided => create the final sanitized editor config\n */\n\n const resolvedClientFeatures = loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: lexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(\n lexicalEditorConfig ? lexicalEditorConfig : defaultEditorLexicalConfig,\n resolvedClientFeatures,\n ),\n )\n }\n }\n }, [\n hasLoadedFeatures,\n clientFunctions,\n schemaPath,\n featureProviderComponents.length,\n featureProviders,\n finalSanitizedEditorConfig,\n lexicalEditorConfig,\n featureComponentsWithFeaturesLength,\n ])\n\n if (!hasLoadedFeatures) {\n return (\n <React.Fragment>\n {Array.isArray(featureProviderComponents) &&\n featureProviderComponents.map((featureProvider) => {\n // get all components starting with key feature.${FeatureProvider.key}.components.{featureComponentKey}\n const featureComponentKeys = Array.from(richTextComponentMap.keys()).filter((key) =>\n key.startsWith(`feature.${featureProvider.key}.components.`),\n )\n const featureComponents: React.ReactNode[] = featureComponentKeys.map((key) => {\n return richTextComponentMap.get(key)\n }) as React.ReactNode[] // TODO: Type better\n\n return (\n <React.Fragment key={featureProvider.key}>\n {featureComponents?.length\n ? featureComponents.map((FeatureComponent) => {\n return FeatureComponent\n })\n : null}\n {featureProvider.ClientComponent}\n </React.Fragment>\n )\n })}\n </React.Fragment>\n )\n }\n\n return (\n <Suspense fallback={<ShimmerEffect height=\"35vh\" />}>\n {finalSanitizedEditorConfig && (\n <RichTextEditor {...props} editorConfig={finalSanitizedEditorConfig} />\n )}\n </Suspense>\n )\n}\n"],"names":["ShimmerEffect","useFieldPath","useClientFunctions","React","Suspense","lazy","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextEditor","then","module","default","RichText","RichTextField","props","lexicalEditorConfig","richTextComponentMap","schemaPath","clientFunctions","hasLoadedFeatures","setHasLoadedFeatures","featureProviders","setFeatureProviders","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","featureProviderComponents","get","sort","a","b","order","featureComponentsWithFeaturesLength","Array","from","keys","filter","key","startsWith","includes","length","featureProvidersLocal","featureProvidersAndComponentsLoaded","Object","entries","forEach","plugin","push","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","Fragment","isArray","map","featureProvider","featureComponentKeys","featureComponents","FeatureComponent","ClientComponent","fallback","height","editorConfig"],"mappings":"AAAA;AAGA,SAA6BA,aAAa,QAAQ,iBAAgB;AAClE,SAASC,YAAY,QAAQ,uBAAsB;AACnD,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,OAAOC,SAASC,QAAQ,EAAEC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAMlE,SAASC,0BAA0B,QAAQ,qCAAoC;AAC/E,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,0BAA0B,QAAQ,sCAAqC;AAEhF,MAAMC,+BAAiBN,KAAK,IAC1B,MAAM,CAAC,cAAcO,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,SAASD,OAAOE,QAAQ;QAAC,CAAA;AAGpE,OAAO,MAAMC,gBAMT,CAACC;IACH,MAAM,EAAEC,mBAAmB,EAAEC,oBAAoB,EAAE,GAAGF;IACtD,MAAM,EAAEG,UAAU,EAAE,GAAGnB;IACvB,MAAMoB,kBAAkBnB;IACxB,MAAM,CAACoB,mBAAmBC,qBAAqB,GAAGhB,SAAS;IAE3D,MAAM,CAACiB,kBAAkBC,oBAAoB,GAAGlB,SAA2C,EAAE;IAE7F,MAAM,CAACmB,4BAA4BC,8BAA8B,GAC/DpB,SAAsC;IAExC,IAAIqB,4BAAiET,qBAAqBU,GAAG,CAC3F,WACuC,oBAAoB;;IAC7D,iBAAiB;IACjBD,4BAA4BA,0BAA0BE,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEE,KAAK,GAAGD,EAAEC,KAAK;IAEtF,MAAMC,sCACJC,MAAMC,IAAI,CAACjB,qBAAqBkB,IAAI,IAAIC,MAAM,CAC5C,CAACC,MAAQA,IAAIC,UAAU,CAAC,CAAC,QAAQ,CA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AAQ;gBAACf,KAAKkB,gBAAgBlB,GAAG;eACrCoB,mBAAmBjB,SAChBiB,kBAAkBH,GAAG,CAAC,CAACI;gBACrB,OAAOA;YACT,KACA,MACHH,gBAAgBI,eAAe;QAGtC;IAGR;IAEA,qBACE,oBAACzD;QAAS0D,wBAAU,oBAAC9D;YAAc+D,QAAO;;OACvCrC,4CACC,oBAACf;QAAgB,GAAGM,KAAK;QAAE+C,cAActC;;AAIjD,EAAC"}
1
+ {"version":3,"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport { ShimmerEffect } from '@payloadcms/ui/elements/ShimmerEffect'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useClientFunctions } from '@payloadcms/ui/providers/ClientFunction'\nimport React, { Suspense, lazy, useEffect, useState } from 'react'\n\nimport type { GeneratedFeatureProviderComponent } from '../types.js'\nimport type { FeatureProviderClient } from './features/types.js'\nimport type { SanitizedClientEditorConfig } from './lexical/config/types.js'\n\nimport { defaultEditorLexicalConfig } from './lexical/config/client/default.js'\nimport { loadClientFeatures } from './lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from './lexical/config/client/sanitize.js'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<\n FormFieldBase & {\n lexicalEditorConfig: LexicalEditorConfig\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n> = (props) => {\n const { lexicalEditorConfig, richTextComponentMap } = props\n const { schemaPath } = useFieldProps()\n const clientFunctions = useClientFunctions()\n const [hasLoadedFeatures, setHasLoadedFeatures] = useState(false)\n\n const [featureProviders, setFeatureProviders] = useState<FeatureProviderClient<unknown>[]>([])\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<SanitizedClientEditorConfig>(null)\n\n let featureProviderComponents: GeneratedFeatureProviderComponent[] = richTextComponentMap.get(\n 'features',\n ) as GeneratedFeatureProviderComponent[] // TODO: Type better\n // order by order\n featureProviderComponents = featureProviderComponents.sort((a, b) => a.order - b.order)\n\n const featureComponentsWithFeaturesLength =\n Array.from(richTextComponentMap.keys()).filter(\n (key) => key.startsWith(`feature.`) && !key.includes('.fields.'),\n ).length + featureProviderComponents.length\n\n useEffect(() => {\n if (!hasLoadedFeatures) {\n const featureProvidersLocal: FeatureProviderClient<unknown>[] = []\n let featureProvidersAndComponentsLoaded = 0\n\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (key.startsWith(`lexicalFeature.${schemaPath}.`)) {\n if (!key.includes('.components.')) {\n featureProvidersLocal.push(plugin)\n }\n featureProvidersAndComponentsLoaded++\n }\n })\n\n if (featureProvidersAndComponentsLoaded === featureComponentsWithFeaturesLength) {\n setFeatureProviders(featureProvidersLocal)\n setHasLoadedFeatures(true)\n\n /**\n * Loaded feature provided => create the final sanitized editor config\n */\n\n const resolvedClientFeatures = loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: lexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(\n lexicalEditorConfig ? lexicalEditorConfig : defaultEditorLexicalConfig,\n resolvedClientFeatures,\n ),\n )\n }\n }\n }, [\n hasLoadedFeatures,\n clientFunctions,\n schemaPath,\n featureProviderComponents.length,\n featureProviders,\n finalSanitizedEditorConfig,\n lexicalEditorConfig,\n featureComponentsWithFeaturesLength,\n ])\n\n if (!hasLoadedFeatures) {\n return (\n <React.Fragment>\n {Array.isArray(featureProviderComponents) &&\n featureProviderComponents.map((featureProvider) => {\n // get all components starting with key feature.${FeatureProvider.key}.components.{featureComponentKey}\n const featureComponentKeys = Array.from(richTextComponentMap.keys()).filter((key) =>\n key.startsWith(`feature.${featureProvider.key}.components.`),\n )\n const featureComponents: React.ReactNode[] = featureComponentKeys.map((key) => {\n return richTextComponentMap.get(key)\n }) // TODO: Type better\n\n return (\n <React.Fragment key={featureProvider.key}>\n {featureComponents?.length\n ? featureComponents.map((FeatureComponent) => {\n return FeatureComponent\n })\n : null}\n {featureProvider.ClientComponent}\n </React.Fragment>\n )\n })}\n </React.Fragment>\n )\n }\n\n return (\n <Suspense fallback={<ShimmerEffect height=\"35vh\" />}>\n {finalSanitizedEditorConfig && (\n <RichTextEditor {...props} editorConfig={finalSanitizedEditorConfig} />\n )}\n </Suspense>\n )\n}\n"],"names":["ShimmerEffect","useFieldProps","useClientFunctions","React","Suspense","lazy","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextEditor","then","module","default","RichText","RichTextField","props","lexicalEditorConfig","richTextComponentMap","schemaPath","clientFunctions","hasLoadedFeatures","setHasLoadedFeatures","featureProviders","setFeatureProviders","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","featureProviderComponents","get","sort","a","b","order","featureComponentsWithFeaturesLength","Array","from","keys","filter","key","startsWith","includes","length","featureProvidersLocal","featureProvidersAndComponentsLoaded","Object","entries","forEach","plugin","push","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","Fragment","isArray","map","featureProvider","featureComponentKeys","featureComponents","FeatureComponent","ClientComponent","fallback","height","editorConfig"],"mappings":"AAAA;AAIA,SAASA,aAAa,QAAQ,wCAAuC;AACrE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,kBAAkB,QAAQ,0CAAyC;AAC5E,OAAOC,SAASC,QAAQ,EAAEC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAMlE,SAASC,0BAA0B,QAAQ,qCAAoC;AAC/E,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,0BAA0B,QAAQ,sCAAqC;AAEhF,MAAMC,+BAAiBN,KAAK,IAC1B,MAAM,CAAC,cAAcO,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,S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BC,UAAUT;wBACVU,SAASnC;oBACX;gBACF;gBAEAS,8BACEjB,2BACEQ,sBAAsBA,sBAAsBV,4BAC5C0C;YAGN;QACF;IACF,GAAG;QACD5B;QACAD;QACAD;QACAQ,0BAA0Bc,MAAM;QAChClB;QACAE;QACAR;QACAgB;KACD;IAED,IAAI,CAACZ,mBAAmB;QACtB,qBACE,oBAACnB,MAAMmD,QAAQ,QACZnB,MAAMoB,OAAO,CAAC3B,8BACbA,0BAA0B4B,GAAG,CAAC,CAACC;YAC7B,uGAAuG;YACvG,MAAMC,uBAAuBvB,MAAMC,IAAI,CAACjB,qBAAqBkB,IAAI,IAAIC,MAAM,CAAC,CAACC,MAC3EA,IAAIC,UAAU,CAAC,CAAC,QAAQ,EAAEiB,gBAAgBlB,GAAG,CAAC,YAAY,CAAC;YAE7D,MAAMoB,oBAAuCD,qBAAqBF,GAAG,CAAC,CAACjB;gBACrE,OAAOpB,qBAAqBU,GAAG,CAACU;YAClC,GAAG,oBAAoB;;YAEvB,qBACE,oBAACpC,MAAMmD,QAAQ;gBAACf,KAAKkB,gBAAgBlB,GAAG;eACrCoB,mBAAmBjB,SAChBiB,kBAAkBH,GAAG,CAAC,CAACI;gBACrB,OAAOA;YACT,KACA,MACHH,gBAAgBI,eAAe;QAGtC;IAGR;IAEA,qBACE,oBAACzD;QAAS0D,wBAAU,oBAAC9D;YAAc+D,QAAO;;OACvCrC,4CACC,oBAACf;QAAgB,GAAGM,KAAK;QAAE+C,cAActC;;AAIjD,EAAC"}
@@ -1,6 +1,6 @@
1
- import type { FormFieldBase } from '@payloadcms/ui';
2
1
  import type { EditorState, SerializedEditorState } from 'lexical';
3
2
  import type { LexicalEditor } from 'lexical';
3
+ import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
4
4
  import * as React from 'react';
5
5
  import type { SanitizedClientEditorConfig } from './config/types.js';
6
6
  export type LexicalProviderProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalProvider.d.ts","sourceRoot":"","sources":["../../../src/field/lexical/LexicalProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAO5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAMpE,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,2BAA2B,CAAA;IACzC,UAAU,EAAE,aAAa,GAAG;QAC1B,YAAY,EAAE,2BAA2B,CAAA;QACzC,IAAI,EAAE,MAAM,CAAA;QACZ,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;KACnD,CAAA;IACD,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;IACtF,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,qBAAqB,CAAA;CAC7B,CAAA;AACD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2D1D,CAAA"}
1
+ {"version":3,"file":"LexicalProvider.d.ts","sourceRoot":"","sources":["../../../src/field/lexical/LexicalProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,2BAA2B,EA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