@payloadcms/richtext-lexical 3.0.0-alpha.63 → 3.0.0-alpha.65
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.
- package/dist/field/features/blockquote/feature.server.d.ts.map +1 -1
- package/dist/field/features/blockquote/feature.server.js +3 -2
- package/dist/field/features/blockquote/feature.server.js.map +1 -1
- package/dist/field/features/blocks/component/index.d.ts.map +1 -1
- package/dist/field/features/blocks/component/index.js +31 -1
- package/dist/field/features/blocks/component/index.js.map +1 -1
- package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
- package/dist/field/features/blocks/feature.server.js +90 -3
- package/dist/field/features/blocks/feature.server.js.map +1 -1
- package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
- package/dist/field/features/blocks/populationPromise.js +3 -5
- package/dist/field/features/blocks/populationPromise.js.map +1 -1
- package/dist/field/features/blocks/validate.d.ts.map +1 -1
- package/dist/field/features/blocks/validate.js +21 -23
- package/dist/field/features/blocks/validate.js.map +1 -1
- package/dist/field/features/heading/feature.server.d.ts.map +1 -1
- package/dist/field/features/heading/feature.server.js +4 -3
- package/dist/field/features/heading/feature.server.js.map +1 -1
- package/dist/field/features/horizontalrule/feature.server.d.ts.map +1 -1
- package/dist/field/features/horizontalrule/feature.server.js +3 -2
- package/dist/field/features/horizontalrule/feature.server.js.map +1 -1
- package/dist/field/features/link/drawer/baseFields.js +1 -1
- package/dist/field/features/link/drawer/baseFields.js.map +1 -1
- package/dist/field/features/link/feature.server.d.ts.map +1 -1
- package/dist/field/features/link/feature.server.js +15 -6
- package/dist/field/features/link/feature.server.js.map +1 -1
- package/dist/field/features/link/populationPromise.d.ts.map +1 -1
- package/dist/field/features/link/populationPromise.js +28 -26
- package/dist/field/features/link/populationPromise.js.map +1 -1
- package/dist/field/features/lists/checklist/feature.server.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/feature.server.js +5 -4
- package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
- package/dist/field/features/lists/orderedlist/feature.server.d.ts.map +1 -1
- package/dist/field/features/lists/orderedlist/feature.server.js +5 -4
- package/dist/field/features/lists/orderedlist/feature.server.js.map +1 -1
- package/dist/field/features/lists/unorderedlist/feature.server.d.ts.map +1 -1
- package/dist/field/features/lists/unorderedlist/feature.server.js +5 -4
- package/dist/field/features/lists/unorderedlist/feature.server.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js +2 -4
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js +2 -4
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js +2 -4
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js.map +1 -1
- package/dist/field/features/relationship/drawer/index.d.ts.map +1 -1
- package/dist/field/features/relationship/drawer/index.js +5 -9
- package/dist/field/features/relationship/drawer/index.js.map +1 -1
- package/dist/field/features/relationship/feature.server.d.ts.map +1 -1
- package/dist/field/features/relationship/feature.server.js +3 -2
- package/dist/field/features/relationship/feature.server.js.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.d.ts +1 -4
- package/dist/field/features/relationship/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.js +7 -6
- package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
- package/dist/field/features/relationship/populationPromise.js +7 -6
- package/dist/field/features/relationship/populationPromise.js.map +1 -1
- package/dist/field/features/typeUtilities.d.ts +8 -0
- package/dist/field/features/typeUtilities.d.ts.map +1 -0
- package/dist/field/features/typeUtilities.js +8 -0
- package/dist/field/features/typeUtilities.js.map +1 -0
- package/dist/field/features/types.d.ts +51 -27
- package/dist/field/features/types.d.ts.map +1 -1
- package/dist/field/features/types.js.map +1 -1
- package/dist/field/features/upload/component/index.js +3 -3
- package/dist/field/features/upload/component/index.js.map +1 -1
- package/dist/field/features/upload/drawer/index.d.ts.map +1 -1
- package/dist/field/features/upload/drawer/index.js +6 -8
- package/dist/field/features/upload/drawer/index.js.map +1 -1
- package/dist/field/features/upload/feature.server.d.ts.map +1 -1
- package/dist/field/features/upload/feature.server.js +8 -4
- package/dist/field/features/upload/feature.server.js.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.d.ts +1 -11
- package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.js +4 -1
- package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
- package/dist/field/features/upload/plugin/index.d.ts +2 -2
- package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
- package/dist/field/features/upload/plugin/index.js +1 -3
- package/dist/field/features/upload/plugin/index.js.map +1 -1
- package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
- package/dist/field/features/upload/populationPromise.js +22 -9
- package/dist/field/features/upload/populationPromise.js.map +1 -1
- package/dist/field/features/upload/validate.js +5 -3
- package/dist/field/features/upload/validate.js.map +1 -1
- package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/server/sanitize.js +20 -6
- package/dist/field/lexical/config/server/sanitize.js.map +1 -1
- package/dist/field/lexical/utils/url.d.ts.map +1 -1
- package/dist/field/lexical/utils/url.js +1 -0
- package/dist/field/lexical/utils/url.js.map +1 -1
- package/dist/forEachNodeRecursively.d.ts +10 -0
- package/dist/forEachNodeRecursively.d.ts.map +1 -0
- package/dist/forEachNodeRecursively.js +24 -0
- package/dist/forEachNodeRecursively.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -23
- package/dist/index.js.map +1 -1
- package/dist/populate/populate.d.ts +3 -3
- package/dist/populate/populate.d.ts.map +1 -1
- package/dist/populate/populate.js.map +1 -1
- package/dist/populate/populateLexicalPopulationPromises.d.ts +12 -0
- package/dist/populate/populateLexicalPopulationPromises.d.ts.map +1 -0
- package/dist/populate/populateLexicalPopulationPromises.js +35 -0
- package/dist/populate/populateLexicalPopulationPromises.js.map +1 -0
- package/dist/populate/recurseNestedFields.d.ts +7 -4
- package/dist/populate/recurseNestedFields.d.ts.map +1 -1
- package/dist/populate/recurseNestedFields.js +3 -5
- package/dist/populate/recurseNestedFields.js.map +1 -1
- package/package.json +9 -9
- package/dist/populate/richTextRelationshipPromise.d.ts +0 -23
- package/dist/populate/richTextRelationshipPromise.d.ts.map +0 -1
- package/dist/populate/richTextRelationshipPromise.js +0 -68
- package/dist/populate/richTextRelationshipPromise.js.map +0 -1
- package/src/index.ts +0 -423
|
@@ -34,11 +34,11 @@ const Component = (props)=>{
|
|
|
34
34
|
const [relatedCollection, setRelatedCollection] = useState(()=>collections.find((coll)=>coll.slug === relationTo));
|
|
35
35
|
const drawerSlug = useDrawerSlug('upload-drawer');
|
|
36
36
|
const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({
|
|
37
|
-
id: value
|
|
37
|
+
id: value,
|
|
38
38
|
collectionSlug: relatedCollection.slug
|
|
39
39
|
});
|
|
40
40
|
// Get the referenced document
|
|
41
|
-
const [{ data }, { setParams }] = usePayloadAPI(`${serverURL}${api}/${relatedCollection.slug}/${value
|
|
41
|
+
const [{ data }, { setParams }] = usePayloadAPI(`${serverURL}${api}/${relatedCollection.slug}/${value}`, {
|
|
42
42
|
initialParams
|
|
43
43
|
});
|
|
44
44
|
const thumbnailSRC = data?.thumbnailURL || data?.url;
|
|
@@ -126,7 +126,7 @@ const Component = (props)=>{
|
|
|
126
126
|
className: `${baseClass}__bottomRow`
|
|
127
127
|
}, /*#__PURE__*/ React.createElement(DocumentDrawerToggler, {
|
|
128
128
|
className: `${baseClass}__doc-drawer-toggler`
|
|
129
|
-
}, /*#__PURE__*/ React.createElement("strong", null, data?.filename)))), value
|
|
129
|
+
}, /*#__PURE__*/ React.createElement("strong", null, data?.filename)))), value && /*#__PURE__*/ React.createElement(DocumentDrawer, {
|
|
130
130
|
onSave: updateUpload
|
|
131
131
|
}), hasExtraFields ? /*#__PURE__*/ React.createElement(ExtraFieldsUploadDrawer, {
|
|
132
132
|
drawerSlug: drawerSlug,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../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 { 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 = data?.thumbnailURL || data?.url\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 {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\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 {hasExtraFields ? (\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n ) : null}\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","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","thumbnailURL","url","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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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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SAAAA;qBACxC,oBAAC1E,WAAcC;AAGrB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../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 { 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,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\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 {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\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 && <DocumentDrawer onSave={updateUpload} />}\n {hasExtraFields ? (\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n ) : null}\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","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","thumbnailURL","url","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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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,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,wB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;QACCgF,aAAY;QACZF,UAAU3C,OAAO4C;QACjBE,IAAG;QACHC,MAAK;QACLC,SAAS;YACPrD,OAAO0D,eAAe,CAAC1E,mCAAmC;gBACxD2E,SAAS;oBAAEhE;gBAAQ;YACrB;QACF;QACA6D,OAAAA;QACAC,SAASlD,EAAE;sBAEb,oBAACrC;QACCgF,aAAY;QACZd,WAAW,CAAC,EAAElD,UAAU,cAAc,CAAC;QACvC8D,UAAU3C,OAAO4C;QACjBG,MAAK;QACLC,SAAS,CAACC;YACRA,EAAEC,cAAc;YAChB7B;QACF;QACA8B,OAAAA;QACAC,SAASlD,EAAE;yBAMrB,oBAAC4B;QAAIC,WAAW,CAAC,EAAElD,UAAU,WAAW,CAAC;qBACvC,oBAACgC;QAAsBkB,WAAW,CAAC,EAAElD,UAAU,oBAAoB,CAAC;qBAClE,oBAAC0E,gBAAQrE,MAAMoD,cAIpBjD,uBAAS,oBAACuB;QAAe4C,QAAQhC;QACjCE,+BACC,oBAAC9C;QACC+B,YAAYA;QACZL,mBAAmBA;QAClB,GAAGrB,KAAK;SAET;AAGV;AAEA,OAAO,MAAMwE,kBAAkB,CAACxE;IAC9B,qBACE,oBAACP;QAA+B,GAAGO,KAAK;QAAEyE,SAAAA;qBACxC,oBAAC1E,WAAcC;AAGrB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/drawer/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAA2C,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/drawer/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAA2C,MAAM,OAAO,CAAA;AA4C/D,KAAK,KAAK,GAAG;IACX,sBAAsB,EAAE,MAAM,EAAE,CAAA;CACjC,CAAA;AA0CD,eAAO,MAAM,YAAY,UAAW,KAAK,KAAG,MAAM,SAMjD,CAAA"}
|
|
@@ -10,12 +10,12 @@ import { $createUploadNode } from '../nodes/UploadNode.js';
|
|
|
10
10
|
import { INSERT_UPLOAD_COMMAND } from '../plugin/index.js';
|
|
11
11
|
import { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from './commands.js';
|
|
12
12
|
const baseClass = 'lexical-upload-drawer';
|
|
13
|
-
const insertUpload = ({
|
|
13
|
+
const insertUpload = ({ editor, relationTo, replaceNodeKey, value })=>{
|
|
14
14
|
if (!replaceNodeKey) {
|
|
15
15
|
editor.dispatchCommand(INSERT_UPLOAD_COMMAND, {
|
|
16
|
-
id,
|
|
17
16
|
fields: null,
|
|
18
|
-
relationTo
|
|
17
|
+
relationTo,
|
|
18
|
+
value
|
|
19
19
|
});
|
|
20
20
|
} else {
|
|
21
21
|
editor.update(()=>{
|
|
@@ -25,9 +25,7 @@ const insertUpload = ({ id, editor, relationTo, replaceNodeKey })=>{
|
|
|
25
25
|
data: {
|
|
26
26
|
fields: null,
|
|
27
27
|
relationTo,
|
|
28
|
-
value
|
|
29
|
-
id
|
|
30
|
-
}
|
|
28
|
+
value
|
|
31
29
|
}
|
|
32
30
|
}));
|
|
33
31
|
}
|
|
@@ -53,10 +51,10 @@ const UploadDrawerComponent = ({ enabledCollectionSlugs })=>{
|
|
|
53
51
|
]);
|
|
54
52
|
const onSelect = useCallback(({ collectionSlug, docID })=>{
|
|
55
53
|
insertUpload({
|
|
56
|
-
id: docID,
|
|
57
54
|
editor,
|
|
58
55
|
relationTo: collectionSlug,
|
|
59
|
-
replaceNodeKey
|
|
56
|
+
replaceNodeKey,
|
|
57
|
+
value: docID
|
|
60
58
|
});
|
|
61
59
|
closeDrawer();
|
|
62
60
|
}, [
|
|
@@ -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 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
|
|
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 editor,\n relationTo,\n replaceNodeKey,\n value,\n}: {\n editor: LexicalEditor\n relationTo: string\n replaceNodeKey: null | string\n value: number | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_UPLOAD_COMMAND, {\n fields: null,\n relationTo,\n value,\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 },\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 editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: docID,\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","editor","relationTo","replaceNodeKey","value","dispatchCommand","fields","update","node","replace","data","UploadDrawerComponent","enabledCollectionSlugs","setReplaceNodeKey","ListDrawer","ListDrawerToggler","closeDrawer","openDrawer","collectionSlugs","uploads","registerCommand","payload","nodeKey","onSelect","collectionSlug","docID","UploadDrawer","props"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;QAAQgB;KAAW;IAEvB,MAAMM,WAAW/B,YACf,CAAC,EAAEgC,cAAc,EAAEC,KAAK,EAAE;QACxBzB,aAAa;YACXC;YACAC,YAAYsB;YACZrB;YACAC,OAAOqB;QACT;QACAT;IACF,GACA;QAACf;QAAQe;QAAab;KAAe;IAGvC,qBAAO,oBAACW;QAAWS,UAAUA;;AAC/B;AAEA,OAAO,MAAMG,eAAe,CAACC;IAC3B,qBACE,oBAAChC;QAA+B,GAAGgC,KAAK;QAAER,SAAAA;qBACxC,oBAACR,uBAA0BgB;AAGjC,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,+BAA+B,EAKhC,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAQnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE;QACX,CAAC,UAAU,EAAE,MAAM,GAAG;YACpB,MAAM,EAAE,+BAA+B,EAAE,CAAA;SAC1C,CAAA;KACF,CAAA;CACF,CAAA;AASD,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CAsIzB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { traverseFields } from '@payloadcms/next/utilities';
|
|
2
|
+
import { createNode } from '../typeUtilities.js';
|
|
2
3
|
import { UploadFeatureClientComponent } from './feature.client.js';
|
|
3
4
|
import { UploadNode } from './nodes/UploadNode.js';
|
|
4
5
|
import { uploadPopulationPromiseHOC } from './populationPromise.js';
|
|
@@ -49,15 +50,18 @@ export const UploadFeature = (props)=>{
|
|
|
49
50
|
return schemaMap;
|
|
50
51
|
},
|
|
51
52
|
nodes: [
|
|
52
|
-
{
|
|
53
|
+
createNode({
|
|
53
54
|
converters: {
|
|
54
55
|
html: {
|
|
55
56
|
converter: async ({ node, payload })=>{
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
const id = node?.value?.id || node?.value // for backwards-compatibility
|
|
59
|
+
;
|
|
56
60
|
if (payload) {
|
|
57
61
|
let uploadDocument;
|
|
58
62
|
try {
|
|
59
63
|
uploadDocument = await payload.findByID({
|
|
60
|
-
id
|
|
64
|
+
id,
|
|
61
65
|
collection: node.relationTo
|
|
62
66
|
});
|
|
63
67
|
} catch (ignored) {
|
|
@@ -94,7 +98,7 @@ export const UploadFeature = (props)=>{
|
|
|
94
98
|
pictureHTML += '</picture>';
|
|
95
99
|
return pictureHTML;
|
|
96
100
|
} else {
|
|
97
|
-
return `<img src="${
|
|
101
|
+
return `<img src="${id}" />`;
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
104
|
nodeTypes: [
|
|
@@ -109,7 +113,7 @@ export const UploadFeature = (props)=>{
|
|
|
109
113
|
validations: [
|
|
110
114
|
uploadValidation()
|
|
111
115
|
]
|
|
112
|
-
}
|
|
116
|
+
})
|
|
113
117
|
],
|
|
114
118
|
serverFeatureProps: props
|
|
115
119
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/upload/feature.server.ts"],"sourcesContent":["import type { Field, FieldWithRichTextRequiredEditor, Payload } from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { UploadFeaturePropsClient } from './feature.client.js'\n\nimport { UploadFeatureClientComponent } from './feature.client.js'\nimport { type SerializedUploadNode, UploadNode } from './nodes/UploadNode.js'\nimport { uploadPopulationPromiseHOC } from './populationPromise.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections: {\n [collection: string]: {\n fields: FieldWithRichTextRequiredEditor[]\n }\n }\n}\n\n/**\n * Get the absolute URL for an upload URL by potentially prepending the serverURL\n */\nfunction getAbsoluteURL(url: string, payload: Payload): string {\n return url?.startsWith('http') ? url : (payload?.config?.serverURL || '') + url\n}\n\nexport const UploadFeature: FeatureProviderProviderServer<\n UploadFeatureProps,\n UploadFeaturePropsClient\n> = (props) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = { collections: {} }\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection].fields.length >= 1,\n }\n }\n }\n\n return {\n feature: () => {\n return {\n ClientComponent: UploadFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n if (!props?.collections) return null\n\n const schemaMap = new Map<string, Field[]>()\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const collection in props.collections) {\n if (props.collections[collection].fields?.length) {\n schemaMap.set(collection, props.collections[collection].fields)\n traverseFields({\n config,\n fields: props.collections[collection].fields,\n i18n,\n schemaMap,\n schemaPath: collection,\n validRelationships,\n })\n }\n }\n\n return schemaMap\n },\n nodes: [\n {\n converters: {\n html: {\n converter: async ({ node, payload }) => {\n if (payload) {\n let uploadDocument: any\n try {\n uploadDocument = await payload.findByID({\n id: node.value.id,\n collection: node.relationTo,\n })\n } catch (ignored) {\n // eslint-disable-next-line no-console\n console.error(\n 'Lexical upload node HTML converter: error fetching upload file',\n ignored,\n 'Node:',\n node,\n )\n return `<img />`\n }\n\n const url: string = getAbsoluteURL(uploadDocument?.url as string, payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!(uploadDocument?.mimeType as string)?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.filename}</a>`\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDocument?.sizes || !Object.keys(uploadDocument?.sizes).length) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.filename}\" width=\"${uploadDocument?.width}\" height=\"${uploadDocument?.height}\"/>`\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n let pictureHTML = '<picture>'\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.sizes) {\n const imageSize = uploadDocument.sizes[size]\n\n // Skip if any property of the size object is null\n if (\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL: string = getAbsoluteURL(imageSize?.url as string, payload)\n\n pictureHTML += `<source srcset=\"${imageSizeURL}\" media=\"(max-width: ${imageSize.width}px)\" type=\"${imageSize.mimeType}\">`\n }\n\n // Add the default img tag\n pictureHTML += `<img src=\"${url}\" alt=\"Image\" width=\"${uploadDocument.width}\" height=\"${uploadDocument.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${node.value.id}\" />`\n }\n },\n nodeTypes: [UploadNode.getType()],\n } as HTMLConverter<SerializedUploadNode>,\n },\n node: UploadNode,\n populationPromises: [uploadPopulationPromiseHOC(props)],\n validations: [uploadValidation()],\n },\n ],\n serverFeatureProps: props,\n }\n },\n key: 'upload',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","UploadFeatureClientComponent","UploadNode","uploadPopulationPromiseHOC","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","props","collections","clientProps","collection","hasExtraFields","fields","length","feature","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","schemaMap","Map","validRelationships","map","c","slug","set","schemaPath","nodes","converters","html","converter","node","uploadDocument","findByID","id","value","relationTo","ignored","console","error","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","populationPromises","validations","serverFeatureProps","key"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B,eAAeU,KAAK,CAACM,KAAK;4CAE5C,kDAAkD;4CAClD,IACE,CAACC,UAAUJ,KAAK,IAChB,CAACI,UAAUH,MAAM,IACjB,CAACG,UAAUT,QAAQ,IACnB,CAACS,UAAUC,QAAQ,IACnB,CAACD,UAAUR,QAAQ,IACnB,CAACQ,UAAUhD,GAAG,EACd;gDACA;4CACF;4CACA,MAAMkD,eAAuBnD,eAAeiD,WAAWhD,KAAeC;4CAEtE6C,eAAe,CAAC,gBAAgB,EAAEI,aAAa,qBAAqB,EAAEF,UAAUJ,KAAK,CAAC,WAAW,EAAEI,UAAUT,QAAQ,CAAC,EAAE,CAAC;wCAC3H;wCAEA,0BAA0B;wCAC1BO,eAAe,CAAC,UAAU,EAAE9C,IAAI,qBAAqB,EAAE+B,eAAea,KAAK,CAAC,UAAU,EAAEb,eAAec,MAAM,CAAC,EAAE,CAAC;wCACjHC,eAAe;wCACf,OAAOA;oCACT,OAAO;wCACL,OAAO,CAAC,UAAU,EAAEhB,KAAKI,KAAK,CAACD,EAAE,CAAC,IAAI,CAAC;oCACzC;gCACF;gCACAkB,WAAW;oCAACvD,WAAWwD,OAAO;iCAAG;4BACnC;wBACF;wBACAtB,MAAMlC;wBACNyD,oBAAoB;4BAACxD,2BAA2BS;yBAAO;wBACvDgD,aAAa;4BAACxD;yBAAmB;oBACnC;iBACD;gBACDyD,oBAAoBjD;YACtB;QACF;QACAkD,KAAK;QACLD,oBAAoBjD;IACtB;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/upload/feature.server.ts"],"sourcesContent":["import type {\n Field,\n FieldWithRichTextRequiredEditor,\n FileData,\n FileSize,\n Payload,\n TypeWithID,\n} from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { UploadFeaturePropsClient } from './feature.client.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { UploadFeatureClientComponent } from './feature.client.js'\nimport { UploadNode } from './nodes/UploadNode.js'\nimport { uploadPopulationPromiseHOC } from './populationPromise.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections: {\n [collection: string]: {\n fields: FieldWithRichTextRequiredEditor[]\n }\n }\n}\n\n/**\n * Get the absolute URL for an upload URL by potentially prepending the serverURL\n */\nfunction getAbsoluteURL(url: string, payload: Payload): string {\n return url?.startsWith('http') ? url : (payload?.config?.serverURL || '') + url\n}\n\nexport const UploadFeature: FeatureProviderProviderServer<\n UploadFeatureProps,\n UploadFeaturePropsClient\n> = (props) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = { collections: {} }\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection].fields.length >= 1,\n }\n }\n }\n\n return {\n feature: () => {\n return {\n ClientComponent: UploadFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n if (!props?.collections) return null\n\n const schemaMap = new Map<string, Field[]>()\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const collection in props.collections) {\n if (props.collections[collection].fields?.length) {\n schemaMap.set(collection, props.collections[collection].fields)\n traverseFields({\n config,\n fields: props.collections[collection].fields,\n i18n,\n schemaMap,\n schemaPath: collection,\n validRelationships,\n })\n }\n }\n\n return schemaMap\n },\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ node, payload }) => {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n if (payload) {\n let uploadDocument: TypeWithID & FileData\n\n try {\n uploadDocument = (await payload.findByID({\n id,\n collection: node.relationTo,\n })) as TypeWithID & FileData\n } catch (ignored) {\n // eslint-disable-next-line no-console\n console.error(\n 'Lexical upload node HTML converter: error fetching upload file',\n ignored,\n 'Node:',\n node,\n )\n return `<img />`\n }\n\n const url = getAbsoluteURL(uploadDocument?.url, payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument?.mimeType?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.filename}</a>`\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDocument?.sizes || !Object.keys(uploadDocument?.sizes).length) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.filename}\" width=\"${uploadDocument?.width}\" height=\"${uploadDocument?.height}\"/>`\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n let pictureHTML = '<picture>'\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.sizes) {\n const imageSize: FileSize & {\n url?: string\n } = uploadDocument.sizes[size]\n\n // Skip if any property of the size object is null\n if (\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL = getAbsoluteURL(imageSize?.url, payload)\n\n pictureHTML += `<source srcset=\"${imageSizeURL}\" media=\"(max-width: ${imageSize.width}px)\" type=\"${imageSize.mimeType}\">`\n }\n\n // Add the default img tag\n pictureHTML += `<img src=\"${url}\" alt=\"Image\" width=\"${uploadDocument.width}\" height=\"${uploadDocument.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${id}\" />`\n }\n },\n nodeTypes: [UploadNode.getType()],\n },\n },\n node: UploadNode,\n populationPromises: [uploadPopulationPromiseHOC(props)],\n validations: [uploadValidation()],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'upload',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","createNode","UploadFeatureClientComponent","UploadNode","uploadPopulationPromiseHOC","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","props","collections","clientProps","collection","hasExtraFields","fields","length","feature","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","schemaMap","Map","validRelationships","map","c","slug","set","schemaPath","nodes","converters","html","converter","node","id","value","uploadDocument","findByID","relationTo","ignored","console","error","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","populationPromises","validations","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AASA,SAASA,cAAc,QAAQ,6BAA4B;AAK3D,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,4BAA4B,QAAQ,sBAAqB;AAClE,SAASC,UAAU,QAAQ,wBAAuB;AAClD,SAASC,0BAA0B,QAAQ,yBAAwB;AACnE,SAASC,gBAAgB,QAAQ,gBAAe;AAUhD;;CAEC,GACD,SAASC,eAAeC,GAAW,EAAEC,OAAgB;IACnD,OAAOD,KAAKE,WAAW,UAAUF,MAAM,AAACC,CAAAA,SAASE,QAAQC,aAAa,EAAC,IAAKJ;AAC9E;AAEA,OAAO,MAAMK,gBAGT,CAACC;IACH,IAAI,CAACA,OAAO;QACVA,QAAQ;YAAEC,aAAa,CAAC;QAAE;IAC5B;IAEA,MAAMC,cAAwC;QAAED,aAAa,CAAC;IAAE;IAChE,IAAID,MAAMC,WAAW,EAAE;QACrB,IAAK,MAAME,cAAcH,MAAMC,WAAW,CAAE;YAC1CC,YAAYD,WAAW,CAACE,WAAW,GAAG;gBACpCC,gBAAgBJ,MAAMC,WAAW,CAACE,WAAW,CAACE,MAAM,CAACC,MAAM,IAAI;YACjE;QACF;IACF;IAEA,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBnB;gBACjBoB,oBAAoBP;gBACpBQ,mBAAmB,CAAC,EAAEb,MAAM,EAAEc,IAAI,EAAEX,KAAK,EAAE;oBACzC,IAAI,CAACA,OAAOC,aAAa,OAAO;oBAEhC,MAAMW,YAAY,IAAIC;oBACtB,MAAMC,qBAAqBjB,OAAOI,WAAW,CAACc,GAA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AS,EAAEP,gBAAgBW,MAAM,WAAW,EAAEX,gBAAgBY,OAAO,GAAG,CAAC;wCACrI;wCAEA;;qBAEC,GACD,IAAIC,cAAc;wCAElB,qDAAqD;wCACrD,IAAK,MAAMC,QAAQd,eAAeQ,KAAK,CAAE;4CACvC,MAAMO,YAEFf,eAAeQ,KAAK,CAACM,KAAK;4CAE9B,kDAAkD;4CAClD,IACE,CAACC,UAAUJ,KAAK,IAChB,CAACI,UAAUH,MAAM,IACjB,CAACG,UAAUT,QAAQ,IACnB,CAACS,UAAUC,QAAQ,IACnB,CAACD,UAAUR,QAAQ,IACnB,CAACQ,UAAUhD,GAAG,EACd;gDACA;4CACF;4CACA,MAAMkD,eAAenD,eAAeiD,WAAWhD,KAAKC;4CAEpD6C,eAAe,CAAC,gBAAgB,EAAEI,aAAa,qBAAqB,EAAEF,UAAUJ,KAAK,CAAC,WAAW,EAAEI,UAAUT,QAAQ,CAAC,EAAE,CAAC;wCAC3H;wCAEA,0BAA0B;wCAC1BO,eAAe,CAAC,UAAU,EAAE9C,IAAI,qBAAqB,EAAEiC,eAAeW,KAAK,CAAC,UAAU,EAAEX,eAAeY,MAAM,CAAC,EAAE,CAAC;wCACjHC,eAAe;wCACf,OAAOA;oCACT,OAAO;wCACL,OAAO,CAAC,UAAU,EAAEf,GAAG,IAAI,CAAC;oCAC9B;gCACF;gCACAoB,WAAW;oCAACvD,WAAWwD,OAAO;iCAAG;4BACnC;wBACF;wBACAtB,MAAMlC;wBACNyD,oBAAoB;4BAACxD,2BAA2BS;yBAAO;wBACvDgD,aAAa;4BAACxD;yBAAmB;oBACnC;iBACD;gBACDyD,oBAAoBjD;YACtB;QACF;QACAkD,KAAK;QACLD,oBAAoBjD;IACtB;AACF,EAAC"}
|
|
@@ -4,22 +4,12 @@ import type { ElementFormatType, NodeKey } from 'lexical';
|
|
|
4
4
|
import lexicalDecoratorBlockNodeImport from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
5
5
|
declare const DecoratorBlockNode: typeof lexicalDecoratorBlockNodeImport.DecoratorBlockNode;
|
|
6
6
|
import type { DOMConversionMap, DOMExportOutput, LexicalNode, Spread } from 'lexical';
|
|
7
|
-
export type RawUploadPayload = {
|
|
8
|
-
fields: {
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
};
|
|
11
|
-
id: string;
|
|
12
|
-
relationTo: string;
|
|
13
|
-
};
|
|
14
7
|
export type UploadData = {
|
|
15
8
|
fields: {
|
|
16
9
|
[key: string]: unknown;
|
|
17
10
|
};
|
|
18
11
|
relationTo: string;
|
|
19
|
-
value:
|
|
20
|
-
[key: string]: unknown;
|
|
21
|
-
id: string;
|
|
22
|
-
};
|
|
12
|
+
value: number | string;
|
|
23
13
|
};
|
|
24
14
|
export type SerializedUploadNode = Spread<UploadData, SerializedDecoratorBlockNode>;
|
|
25
15
|
export declare class UploadNode extends DecoratorBlockNode {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/nodes/UploadNode.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEzD,OAAO,+BAA+B,MAAM,6CAA6C,CAAA;AACzF,QAAA,MAAQ,kBAAkB,2DAAoC,CAAA;AAK9D,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,WAAW,EACX,MAAM,EACP,MAAM,SAAS,CAAA;AAQhB,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/nodes/UploadNode.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEzD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AAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,UAAU,CAEtF"}
|
|
@@ -40,6 +40,9 @@ export class UploadNode extends DecoratorBlockNode {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
static importJSON(serializedNode) {
|
|
43
|
+
if (serializedNode.version === 1 && serializedNode?.value?.id) {
|
|
44
|
+
serializedNode.value = serializedNode.value.id;
|
|
45
|
+
}
|
|
43
46
|
const importedData = {
|
|
44
47
|
fields: serializedNode.fields,
|
|
45
48
|
relationTo: serializedNode.relationTo,
|
|
@@ -75,7 +78,7 @@ export class UploadNode extends DecoratorBlockNode {
|
|
|
75
78
|
...super.exportJSON(),
|
|
76
79
|
...this.getData(),
|
|
77
80
|
type: this.getType(),
|
|
78
|
-
version:
|
|
81
|
+
version: 2
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
84
|
getData() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/upload/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type { ElementFormatType, NodeKey } from 'lexical'\n\nimport lexicalDecoratorBlockNodeImport from '@lexical/react/LexicalDecoratorBlockNode.js'\nconst { DecoratorBlockNode } = lexicalDecoratorBlockNodeImport\n\nimport lexicalImport from 'lexical'\nconst { $applyNodeReplacement } = lexicalImport\n\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n Spread,\n} from 'lexical'\n\nimport * as React from 'react'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/upload/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type { ElementFormatType, NodeKey } from 'lexical'\n\nimport lexicalDecoratorBlockNodeImport from '@lexical/react/LexicalDecoratorBlockNode.js'\nconst { DecoratorBlockNode } = lexicalDecoratorBlockNodeImport\n\nimport lexicalImport from 'lexical'\nconst { $applyNodeReplacement } = lexicalImport\n\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n Spread,\n} from 'lexical'\n\nimport * as React from 'react'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport type UploadData = {\n fields: {\n // unknown, custom fields:\n [key: string]: unknown\n }\n relationTo: string\n value: number | string\n}\n\nfunction convertUploadElement(domNode: Node): DOMConversionOutput | null {\n //if (domNode instanceof HTMLImageElement) {\n // const { alt: altText, src } = domNode;\n // const node = $createImageNode({ altText, src });\n // return { node };\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static clone(node: UploadNode): UploadNode {\n return new UploadNode({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'upload'\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n img: (node: Node) => ({\n conversion: convertUploadElement,\n priority: 0,\n }),\n }\n }\n\n static importJSON(serializedNode: SerializedUploadNode): UploadNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: UploadData = {\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n // element.setAttribute('src', this.__src);\n // element.setAttribute('alt', this.__altText); //TODO\n return { element }\n }\n\n exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: this.getType(),\n version: 2,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n // eslint-disable-next-line class-methods-use-this\n updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadNode({ data }: { data: UploadData }): UploadNode {\n return $applyNodeReplacement(new UploadNode({ data }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n"],"names":["lexicalDecoratorBlockNodeImport","DecoratorBlockNode","lexicalImport","$applyNodeReplacement","React","RawUploadComponent","lazy","then","module","default","UploadComponent","convertUploadElement","domNode","UploadNode","__data","constructor","data","format","key","clone","node","__format","__key","getType","importDOM","img","conversion","priority","importJSON","serializedNode","version","value","id","importedData","fields","relationTo","$createUploadNode","setFormat","isInline","decorate","nodeKey","getKey","exportDOM","element","document","createElement","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,qCAAqC,8CAA6C;AACzF,MAAM,EAAEC,kBAAkB,EAAE,GAAGD;AAE/B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,qBAAqB,EAAE,GAAGD;AAUlC,YAAYE,WAAW,QAAO;AAE9B,MAAMC,mCAAqBD,MAAME,IAAI,CAAC,IACpC,MAAM,CAAC,yBAAyBC,IAAI,CAAC,CA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I,CAACC,MAAM;;IAC3F;IAEAC,YAA6B;QAC3B,MAAMC,UAAUC,SAASC,aAAa,CAAC;QACvC,2CAA2C;QAC3C,sDAAsD;QACtD,OAAO;YAAEF;QAAQ;IACnB;IAEAG,aAAmC;QACjC,OAAO;YACL,GAAG,KAAK,CAACA,YAAY;YACrB,GAAG,IAAI,CAACC,OAAO,EAAE;YACjBC,MAAM,IAAI,CAACzB,OAAO;YAClBO,SAAS;QACX;IACF;IAEAiB,UAAsB;QACpB,OAAO,IAAI,CAACE,SAAS,GAAGnC,MAAM;IAChC;IAEAoC,QAAQlC,IAAgB,EAAQ;QAC9B,MAAMmC,WAAW,IAAI,CAACC,WAAW;QACjCD,SAASrC,MAAM,GAAGE;IACpB;IAEA,kDAAkD;IAClDqC,YAAmB;QACjB,OAAO;IACT;AACF;AAEA,OAAO,SAASjB,kBAAkB,EAAEpB,IAAI,EAAwB;IAC9D,OAAOb,sBAAsB,IAAIU,WAAW;QAAEG;IAAK;AACrD;AAEA,OAAO,SAASsC,cAAclC,IAAoC;IAChE,OAAOA,gBAAgBP;AACzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import type { LexicalCommand } from 'lexical';
|
|
3
|
-
import type {
|
|
4
|
-
export type InsertUploadPayload = Readonly<
|
|
3
|
+
import type { UploadData } from '../nodes/UploadNode.js';
|
|
4
|
+
export type InsertUploadPayload = Readonly<UploadData>;
|
|
5
5
|
export declare const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload>;
|
|
6
6
|
export declare function UploadPlugin(): JSX.Element | null;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAKxD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;AAEtD,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAC9B,CAAA;AAExC,wBAAgB,YAAY,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAqDjD"}
|
|
@@ -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 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 {
|
|
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 { UploadData } from '../nodes/UploadNode.js'\n\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<UploadData>\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: payload.value,\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","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove","enabledCollectionSlugs","map","slug"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,EACd,GAAGN;AAIJ,SAASO,SAAS,QAAQ,kCAAiC;AAC3D,OAAOC,SAASC,SAAS,QAAQ,QAAO;AAIxC,SAASC,YAAY,QAAQ,qBAAoB;AACjD,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,yBAAwB;AAItE,OAAO,MAAMC,wBACXP,cAAc,yBAAwB;AAExC,OAAO,SAASQ;IACd,MAAM,CAACC,OAAO,GAAGnB;IACjB,MAAM,EAAEoB,WAAW,EAAE,GAAGT;IAExBE,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,OAAON,QAAQM,KAAK;oBACtB;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;oBAEAvC,yBAAyBwB;gBAC3B;YACF;YAEA,OAAO;QACT,GACAjB;IAGN,GAAG;QAACU;KAAO;IAEX,qBAAO,oBAACL;QAAa4B,wBAAwBtB,YAAYuB,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;;AAC7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/populationPromise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/populationPromise.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAKjE,eAAO,MAAM,0BAA0B,WAC7B,kBAAkB,KACzB,kBAAkB,oBAAoB,CAyExC,CAAA"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { sanitizeFields } from 'payload/config';
|
|
1
2
|
import { populate } from '../../../populate/populate.js';
|
|
2
3
|
import { recurseNestedFields } from '../../../populate/recurseNestedFields.js';
|
|
3
4
|
export const uploadPopulationPromiseHOC = (props)=>{
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
if (node?.value
|
|
5
|
+
return ({ context, currentDepth, depth, editorPopulationPromises, field, fieldPromises, findMany, flattenLocales, node, overrideAccess, populationPromises, req, showHiddenFields })=>{
|
|
6
|
+
const payloadConfig = req.payload.config;
|
|
7
|
+
if (node?.value) {
|
|
7
8
|
const collection = req.payload.collections[node?.relationTo];
|
|
8
9
|
if (collection) {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
// @ts-expect-error
|
|
11
|
+
const id = node?.value?.id || node?.value // for backwards-compatibility
|
|
12
|
+
;
|
|
13
|
+
populationPromises.push(populate({
|
|
14
|
+
id,
|
|
11
15
|
collection,
|
|
12
16
|
currentDepth,
|
|
13
17
|
data: node,
|
|
@@ -20,27 +24,36 @@ export const uploadPopulationPromiseHOC = (props)=>{
|
|
|
20
24
|
}));
|
|
21
25
|
}
|
|
22
26
|
if (Array.isArray(props?.collections?.[node?.relationTo]?.fields)) {
|
|
27
|
+
const validRelationships = payloadConfig.collections.map((c)=>c.slug) || [];
|
|
28
|
+
// TODO: Sanitize & transform ahead of time! On startup!
|
|
29
|
+
const sanitizedFields = sanitizeFields({
|
|
30
|
+
config: payloadConfig,
|
|
31
|
+
fields: props?.collections?.[node?.relationTo]?.fields,
|
|
32
|
+
requireFieldLevelRichTextEditor: true,
|
|
33
|
+
validRelationships
|
|
34
|
+
});
|
|
35
|
+
if (!sanitizedFields?.length) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
23
38
|
recurseNestedFields({
|
|
24
39
|
context,
|
|
25
40
|
currentDepth,
|
|
26
41
|
data: node.fields || {},
|
|
27
42
|
depth,
|
|
28
43
|
editorPopulationPromises,
|
|
29
|
-
|
|
44
|
+
fieldPromises,
|
|
45
|
+
fields: sanitizedFields,
|
|
30
46
|
findMany,
|
|
31
47
|
flattenLocales,
|
|
32
48
|
overrideAccess,
|
|
33
49
|
populationPromises,
|
|
34
|
-
promises,
|
|
35
50
|
req,
|
|
36
51
|
showHiddenFields,
|
|
37
52
|
siblingDoc: node.fields || {}
|
|
38
53
|
});
|
|
39
54
|
}
|
|
40
55
|
}
|
|
41
|
-
return promises;
|
|
42
56
|
};
|
|
43
|
-
return uploadPopulationPromise;
|
|
44
57
|
};
|
|
45
58
|
|
|
46
59
|
//# sourceMappingURL=populationPromise.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/upload/populationPromise.ts"],"sourcesContent":["import type { PopulationPromise } from '../types.js'\nimport type { UploadFeatureProps } from './feature.server.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { populate } from '../../../populate/populate.js'\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const uploadPopulationPromiseHOC = (\n props?: UploadFeatureProps,\n): PopulationPromise<SerializedUploadNode> => {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/upload/populationPromise.ts"],"sourcesContent":["import { sanitizeFields } from 'payload/config'\n\nimport type { PopulationPromise } from '../types.js'\nimport type { UploadFeatureProps } from './feature.server.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { populate } from '../../../populate/populate.js'\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const uploadPopulationPromiseHOC = (\n props?: UploadFeatureProps,\n): PopulationPromise<SerializedUploadNode> => {\n return ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n const payloadConfig = req.payload.config\n\n if (node?.value) {\n const collection = req.payload.collections[node?.relationTo]\n\n if (collection) {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n populationPromises.push(\n populate({\n id,\n collection,\n currentDepth,\n data: node,\n depth,\n field,\n key: 'value',\n overrideAccess,\n req,\n showHiddenFields,\n }),\n )\n }\n if (Array.isArray(props?.collections?.[node?.relationTo]?.fields)) {\n const validRelationships = payloadConfig.collections.map((c) => c.slug) || []\n\n // TODO: Sanitize & transform ahead of time! On startup!\n const sanitizedFields = sanitizeFields({\n config: payloadConfig,\n fields: props?.collections?.[node?.relationTo]?.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })\n\n if (!sanitizedFields?.length) {\n return\n }\n recurseNestedFields({\n context,\n currentDepth,\n data: node.fields || {},\n depth,\n editorPopulationPromises,\n fieldPromises,\n fields: sanitizedFields,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: node.fields || {},\n })\n }\n }\n }\n}\n"],"names":["sanitizeFields","populate","recurseNestedFields","uploadPopulationPromiseHOC","props","context","currentDepth","depth","editorPopulationPromises","field","fieldPromises","findMany","flattenLocales","node","overrideAccess","populationPromises","req","showHiddenFields","payloadConfig","payload","config","value","collection","collections","relationTo","id","push","data","key","Array","isArray","fields","validRelationships","map","c","slug","sanitizedFields","requireFieldLevelRichTextEditor","length","siblingDoc"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,QAAQ,iBAAgB;AAM/C,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,mBAAmB,QAAQ,2CAA0C;AAE9E,OAAO,MAAMC,6BAA6B,CACxCC;IAEA,OAAO,CAAC,EACNC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,wBAAwB,EACxBC,KAAK,EACLC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EACjB;QACC,MAAMC,gBAAgBF,IAAIG,OAAO,CAACC,MAAM;QAExC,IAAIP,MAAMQ,OAAO;YACf,MAAMC,aAAaN,IAAIG,OAAO,CAACI,WAAW,CAACV,MAAMW,WAAW;YAE5D,IAAIF,YAAY;gBACd,mBAAmB;gBACnB,MAAMG,KAAKZ,MAAMQ,OAAOI,MAAMZ,MAAMQ,MAAM,8BAA8B;;gBAExEN,mBAAmBW,IAAI,CACrBzB,SAAS;oBACPwB;oBACAH;oBACAhB;oBACAqB,MAAMd;oBACNN;oBACAE;oBACAmB,KAAK;oBACLd;oBACAE;oBACAC;gBACF;YAEJ;YACA,IAAIY,MAAMC,OAAO,CAAC1B,OAAOmB,aAAa,CAACV,MAAMW,WAAW,EAAEO,SAAS;gBACjE,MAAMC,qBAAqBd,cAAcK,WAAW,CAACU,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;gBAE7E,wDAAwD;gBACxD,MAAMC,kBAAkBpC,eAAe;oBACrCoB,QAAQF;oBACRa,QAAQ3B,OAAOmB,aAAa,CAACV,MAAMW,WAAW,EAAEO;oBAChDM,iCAAiC;oBACjCL;gBACF;gBAEA,IAAI,CAACI,iBAAiBE,QAAQ;oBAC5B;gBACF;gBACApC,oBAAoB;oBAClBG;oBACAC;oBACAqB,MAAMd,KAAKkB,MAAM,IAAI,CAAC;oBACtBxB;oBACAC;oBACAE;oBACAqB,QAAQK;oBACRzB;oBACAC;oBACAE;oBACAC;oBACAC;oBACAC;oBACAsB,YAAY1B,KAAKkB,MAAM,IAAI,CAAC;gBAC9B;YACF;QACF;IACF;AACF,EAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { isValidID } from 'payload/utilities';
|
|
2
2
|
import { CAN_USE_DOM } from '../../lexical/utils/canUseDOM.js';
|
|
3
3
|
export const uploadValidation = ()=>{
|
|
4
|
-
|
|
4
|
+
return ({ node, validation: { options: { req: { payload, t } } } })=>{
|
|
5
5
|
if (!CAN_USE_DOM) {
|
|
6
6
|
const idType = payload.collections[node.relationTo].customIDType || payload.db.defaultIDType;
|
|
7
|
-
|
|
7
|
+
// @ts-expect-error
|
|
8
|
+
const id = node?.value?.id || node?.value // for backwards-compatibility
|
|
9
|
+
;
|
|
10
|
+
if (!isValidID(id, idType)) {
|
|
8
11
|
return t('validation:validUploadID');
|
|
9
12
|
}
|
|
10
13
|
}
|
|
11
14
|
// TODO: validate upload collection fields
|
|
12
15
|
return true;
|
|
13
16
|
};
|
|
14
|
-
return uploadValidation;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/upload/validate.ts"],"sourcesContent":["import { isValidID } from 'payload/utilities'\n\nimport type { NodeValidation } from '../types.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { CAN_USE_DOM } from '../../lexical/utils/canUseDOM.js'\n\nexport const uploadValidation = (): NodeValidation<SerializedUploadNode> => {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/upload/validate.ts"],"sourcesContent":["import { isValidID } from 'payload/utilities'\n\nimport type { NodeValidation } from '../types.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { CAN_USE_DOM } from '../../lexical/utils/canUseDOM.js'\n\nexport const uploadValidation = (): NodeValidation<SerializedUploadNode> => {\n return ({\n node,\n validation: {\n options: {\n req: { payload, t },\n },\n },\n }) => {\n if (!CAN_USE_DOM) {\n const idType = payload.collections[node.relationTo].customIDType || payload.db.defaultIDType\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n if (!isValidID(id, idType)) {\n return t('validation:validUploadID')\n }\n }\n\n // TODO: validate upload collection fields\n\n return true\n }\n}\n"],"names":["isValidID","CAN_USE_DOM","uploadValidation","node","validation","options","req","payload","t","idType","collections","relationTo","customIDType","db","defaultIDType","id","value"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAK7C,SAASC,WAAW,QAAQ,mCAAkC;AAE9D,OAAO,MAAMC,mBAAmB;IAC9B,OAAO,CAAC,EACNC,IAAI,EACJC,YAAY,EACVC,SAAS,EACPC,KAAK,EAAEC,OAAO,EAAEC,CAAC,EAAE,EACpB,EACF,EACF;QACC,IAAI,CAACP,aAAa;YAChB,MAAMQ,SAASF,QAAQG,WAAW,CAACP,KAAKQ,UAAU,CAAC,CAACC,YAAY,IAAIL,QAAQM,EAAE,CAACC,aAAa;YAC5F,mBAAmB;YACnB,MAAMC,KAAKZ,MAAMa,OAAOD,MAAMZ,MAAMa,MAAM,8BAA8B;;YAExE,IAAI,CAAChB,UAAUe,IAAIN,SAAS;gBAC1B,OAAOD,EAAE;YACX;QACF;QAEA,0CAA0C;QAE1C,OAAO;IACT;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIlF,eAAO,MAAM,sBAAsB,0CAEhC,
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIlF,eAAO,MAAM,sBAAsB,0CAEhC,uBA0EF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,kBAAkB,GAC/B,2BAA2B,CAU7B"}
|