@payloadcms/richtext-slate 3.69.0-internal.2883df2 → 3.69.0
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/cell/rscEntry.d.ts.map +1 -1
- package/dist/cell/rscEntry.js +3 -1
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/field/elements/relationship/Element/index.d.ts.map +1 -1
- package/dist/field/elements/relationship/Element/index.js +7 -2
- package/dist/field/elements/relationship/Element/index.js.map +1 -1
- package/dist/field/elements/upload/Element/index.d.ts.map +1 -1
- package/dist/field/elements/upload/Element/index.js +7 -2
- package/dist/field/elements/upload/Element/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/cell/rscEntry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEvE,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG1E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CACtC;IACE,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,+BAA+B,
|
|
1
|
+
{"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/cell/rscEntry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEvE,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG1E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CACtC;IACE,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,+BAA+B,CA2EpC,CAAA"}
|
package/dist/cell/rscEntry.js
CHANGED
|
@@ -10,6 +10,7 @@ import React from 'react';
|
|
|
10
10
|
const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined;
|
|
11
11
|
const className = classNameFromProps || (field.admin && 'className' in field.admin ? field.admin.className : null) || classNameFromConfigContext;
|
|
12
12
|
const adminRoute = payload.config.routes.admin;
|
|
13
|
+
const serverURL = payload.config.serverURL;
|
|
13
14
|
const onClick = onClickFromProps;
|
|
14
15
|
let WrapElement = 'span';
|
|
15
16
|
const wrapElementProps = {
|
|
@@ -20,7 +21,8 @@ import React from 'react';
|
|
|
20
21
|
WrapElement = Link;
|
|
21
22
|
wrapElementProps.href = collectionConfig?.slug ? formatAdminURL({
|
|
22
23
|
adminRoute,
|
|
23
|
-
path: `/collections/${collectionConfig?.slug}/${rowData.id}
|
|
24
|
+
path: `/collections/${collectionConfig?.slug}/${rowData.id}`,
|
|
25
|
+
serverURL
|
|
24
26
|
}) : '';
|
|
25
27
|
}
|
|
26
28
|
if (typeof onClick === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cell/rscEntry.tsx"],"sourcesContent":["import type { DefaultServerCellComponentProps, Payload } from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\nimport { Link } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\n/**\n * @deprecated - slate will be removed in 4.0. Please [migrate our new, lexical-based rich text editor](https://payloadcms.com/docs/rich-text/migration#migrating-from-slate).\n */\nexport const RscEntrySlateCell: React.FC<\n {\n i18n: I18nClient\n payload: Payload\n } & DefaultServerCellComponentProps\n> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionConfig,\n field: { admin },\n field,\n i18n,\n link,\n onClick: onClickFromProps,\n payload,\n rowData,\n } = props\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n const adminRoute = payload.config.routes.admin\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}/${rowData.id}`,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n let textContent = ''\n\n if (cellData) {\n textContent = cellData?.map((i) => i?.children?.map((c) => c.text)).join(' ')\n }\n\n if (!cellData || !textContent?.length) {\n textContent = i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n })\n }\n\n return <WrapElement {...wrapElementProps}>{textContent}</WrapElement>\n}\n"],"names":["getTranslation","Link","formatAdminURL","React","RscEntrySlateCell","props","cellData","className","classNameFromProps","collectionConfig","field","admin","i18n","link","onClick","onClickFromProps","payload","rowData","classNameFromConfigContext","undefined","adminRoute","config","routes","WrapElement","wrapElementProps","prefetch","href","slug","path","id","type","collectionSlug","textContent","map","i","children","c","text","join","length","t","label"],"mappings":";AAEA,SAASA,cAAc,QAAyB,2BAA0B;AAC1E,SAASC,IAAI,QAAQ,iBAAgB;AACrC,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAEzB;;CAEC,GACD,OAAO,MAAMC,oBAKT,CAACC;IACH,MAAM,EACJC,QAAQ,EACRC,WAAWC,kBAAkB,EAC7BC,gBAAgB,EAChBC,OAAO,EAAEC,KAAK,EAAE,EAChBD,KAAK,EACLE,IAAI,EACJC,IAAI,EACJC,SAASC,gBAAgB,EACzBC,OAAO,EACPC,OAAO,EACR,GAAGZ;IAEJ,MAAMa,6BAA6BP,SAAS,eAAeA,QAAQA,MAAMJ,SAAS,GAAGY;IAErF,MAAMZ,YACJC,sBACCE,CAAAA,MAAMC,KAAK,IAAI,eAAeD,MAAMC,KAAK,GAAGD,MAAMC,KAAK,CAACJ,SAAS,GAAG,IAAG,KACxEW;IACF,MAAME,aAAaJ,QAAQK,MAAM,CAACC,MAAM,CAACX,KAAK;
|
|
1
|
+
{"version":3,"sources":["../../src/cell/rscEntry.tsx"],"sourcesContent":["import type { DefaultServerCellComponentProps, Payload } from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\nimport { Link } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\n/**\n * @deprecated - slate will be removed in 4.0. Please [migrate our new, lexical-based rich text editor](https://payloadcms.com/docs/rich-text/migration#migrating-from-slate).\n */\nexport const RscEntrySlateCell: React.FC<\n {\n i18n: I18nClient\n payload: Payload\n } & DefaultServerCellComponentProps\n> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionConfig,\n field: { admin },\n field,\n i18n,\n link,\n onClick: onClickFromProps,\n payload,\n rowData,\n } = props\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n const adminRoute = payload.config.routes.admin\n const serverURL = payload.config.serverURL\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}/${rowData.id}`,\n serverURL,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n let textContent = ''\n\n if (cellData) {\n textContent = cellData?.map((i) => i?.children?.map((c) => c.text)).join(' ')\n }\n\n if (!cellData || !textContent?.length) {\n textContent = i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n })\n }\n\n return <WrapElement {...wrapElementProps}>{textContent}</WrapElement>\n}\n"],"names":["getTranslation","Link","formatAdminURL","React","RscEntrySlateCell","props","cellData","className","classNameFromProps","collectionConfig","field","admin","i18n","link","onClick","onClickFromProps","payload","rowData","classNameFromConfigContext","undefined","adminRoute","config","routes","serverURL","WrapElement","wrapElementProps","prefetch","href","slug","path","id","type","collectionSlug","textContent","map","i","children","c","text","join","length","t","label"],"mappings":";AAEA,SAASA,cAAc,QAAyB,2BAA0B;AAC1E,SAASC,IAAI,QAAQ,iBAAgB;AACrC,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAEzB;;CAEC,GACD,OAAO,MAAMC,oBAKT,CAACC;IACH,MAAM,EACJC,QAAQ,EACRC,WAAWC,kBAAkB,EAC7BC,gBAAgB,EAChBC,OAAO,EAAEC,KAAK,EAAE,EAChBD,KAAK,EACLE,IAAI,EACJC,IAAI,EACJC,SAASC,gBAAgB,EACzBC,OAAO,EACPC,OAAO,EACR,GAAGZ;IAEJ,MAAMa,6BAA6BP,SAAS,eAAeA,QAAQA,MAAMJ,SAAS,GAAGY;IAErF,MAAMZ,YACJC,sBACCE,CAAAA,MAAMC,KAAK,IAAI,eAAeD,MAAMC,KAAK,GAAGD,MAAMC,KAAK,CAACJ,SAAS,GAAG,IAAG,KACxEW;IACF,MAAME,aAAaJ,QAAQK,MAAM,CAACC,MAAM,CAACX,KAAK;IAC9C,MAAMY,YAAYP,QAAQK,MAAM,CAACE,SAAS;IAE1C,MAAMT,UAAUC;IAEhB,IAAIS,cAAiD;IAErD,MAAMC,mBAMF;QACFlB;IACF;IAEA,IAAIM,MAAM;QACRY,iBAAiBC,QAAQ,GAAG;QAC5BF,cAAcvB;QACdwB,iBAAiBE,IAAI,GAAGlB,kBAAkBmB,OACtC1B,eAAe;YACbkB;YACAS,MAAM,CAAC,aAAa,EAAEpB,kBAAkBmB,KAAK,CAAC,EAAEX,QAAQa,EAAE,EAAE;YAC5DP;QACF,KACA;IACN;IAEA,IAAI,OAAOT,YAAY,YAAY;QACjCU,cAAc;QACdC,iBAAiBM,IAAI,GAAG;QACxBN,iBAAiBX,OAAO,GAAG;YACzBA,QAAQ;gBACNR;gBACA0B,gBAAgBvB,kBAAkBmB;gBAClCX;YACF;QACF;IACF;IAEA,IAAIgB,cAAc;IAElB,IAAI3B,UAAU;QACZ2B,cAAc3B,UAAU4B,IAAI,CAACC,IAAMA,GAAGC,UAAUF,IAAI,CAACG,IAAMA,EAAEC,IAAI,GAAGC,KAAK;IAC3E;IAEA,IAAI,CAACjC,YAAY,CAAC2B,aAAaO,QAAQ;QACrCP,cAAcrB,KAAK6B,CAAC,CAAC,mBAAmB;YACtCC,OAAO1C,eAAe,AAAC,CAAA,WAAWU,QAAQA,MAAMgC,KAAK,GAAG,IAAG,KAAM,QAAQ9B;QAC3E;IACF;IAEA,qBAAO,KAACY;QAAa,GAAGC,gBAAgB;kBAAGQ;;AAC7C,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAOhE,OAAO,cAAc,CAAA;AA4KrB,eAAO,MAAM,mBAAmB,UAAW,GAAG,KAAG,KAAK,CAAC,SAMtD,CAAA"}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { getTranslation } from '@payloadcms/translations';
|
|
4
4
|
import { Button, useConfig, useDocumentDrawer, useListDrawer, usePayloadAPI, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import { formatAdminURL } from 'payload/shared';
|
|
5
6
|
import React, { useCallback, useReducer, useState } from 'react';
|
|
6
7
|
import { Transforms } from 'slate';
|
|
7
8
|
import { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react';
|
|
8
9
|
import { useElement } from '../../../providers/ElementProvider.js';
|
|
9
|
-
import { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js';
|
|
10
10
|
import './index.scss';
|
|
11
|
+
import { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js';
|
|
11
12
|
const baseClass = 'rich-text-relationship';
|
|
12
13
|
const initialParams = {
|
|
13
14
|
depth: 0
|
|
@@ -24,7 +25,11 @@ const RelationshipElementComponent = ()=>{
|
|
|
24
25
|
const { i18n, t } = useTranslation();
|
|
25
26
|
const editor = useSlateStatic();
|
|
26
27
|
const [cacheBust, dispatchCacheBust] = useReducer((state)=>state + 1, 0);
|
|
27
|
-
const [{ data }, { setParams }] = usePayloadAPI(
|
|
28
|
+
const [{ data }, { setParams }] = usePayloadAPI(formatAdminURL({
|
|
29
|
+
apiRoute: api,
|
|
30
|
+
path: `/${relatedCollection.slug}/${value?.id}`,
|
|
31
|
+
serverURL
|
|
32
|
+
}), {
|
|
28
33
|
initialParams
|
|
29
34
|
});
|
|
30
35
|
const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ListDrawerProps } from '@payloadcms/ui'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n useConfig,\n useDocumentDrawer,\n useListDrawer,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { RelationshipElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\nconst RelationshipElementComponent: React.FC = () => {\n const {\n attributes,\n children,\n element,\n element: { relationTo, value },\n fieldProps,\n } = useElement<RelationshipElementType>()\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const [enabledCollectionSlugs] = useState(() =>\n collections\n .filter(({ admin: { enableRichTextRelationship } }) => enableRichTextRelationship)\n .map(({ slug }) => slug),\n )\n const [relatedCollection, setRelatedCollection] = useState(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const selected = useSelected()\n const focused = useFocused()\n const { i18n, t } = useTranslation()\n const editor = useSlateStatic()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: relatedCollection.slug,\n value: { id: doc.id },\n },\n { at: elementPath },\n )\n\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 [editor, element, relatedCollection, cacheBust, setParams, closeDrawer],\n )\n\n const swapRelationship = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, doc }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: doc.id },\n },\n { at: elementPath },\n )\n\n setRelatedCollection(getEntityConfig({ collectionSlug }))\n\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 closeListDrawer()\n dispatchCacheBust()\n },\n [closeListDrawer, editor, element, cacheBust, setParams, getEntityConfig],\n )\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\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[relatedCollection?.admin?.useAsTitle || 'id']}\n </p>\n </DocumentDrawerToggler>\n </div>\n <div className={`${baseClass}__actions`}>\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n {value?.id && <DocumentDrawer onSave={updateRelationship} />}\n <ListDrawer onSelect={swapRelationship} />\n {children}\n </div>\n )\n}\n\nexport const RelationshipElement = (props: any): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipElementComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","useConfig","useDocumentDrawer","useListDrawer","usePayloadAPI","useTranslation","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","baseClass","initialParams","depth","RelationshipElementComponent","attributes","children","element","relationTo","value","fieldProps","config","collections","routes","api","serverURL","getEntityConfig","enabledCollectionSlugs","filter","admin","enableRichTextRelationship","map","slug","relatedCollection","setRelatedCollection","collectionSlug","selected","focused","i18n","t","editor","cacheBust","dispatchCacheBust","state","data","setParams","id","DocumentDrawer","DocumentDrawerToggler","closeDrawer","ListDrawer","ListDrawerToggler","closeListDrawer","collectionSlugs","selectedCollection","removeRelationship","elementPath","findPath","removeNodes","at","updateRelationship","doc","setNodes","type","text","swapRelationship","div","className","Boolean","join","contentEditable","p","label","labels","singular","useAsTitle","disabled","field","readOnly","buttonStyle","el","icon","onClick","round","tooltip","e","preventDefault","onSave","onSelect","RelationshipElement","props"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,SAAS,EACTC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,WAAW,EA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ACV;gBAAWsC,UAAUvB;;YACrBjD;;;AAGP;AAEA,OAAO,MAAMyE,sBAAsB,CAACC;IAClC,qBACE,KAAChF;QAA+B,GAAGgF,KAAK;kBACtC,cAAA,KAAC5E;YAA8B,GAAG4E,KAAK;;;AAG7C,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ListDrawerProps } from '@payloadcms/ui'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n useConfig,\n useDocumentDrawer,\n useListDrawer,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { RelationshipElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport './index.scss'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\n\nconst baseClass = 'rich-text-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\nconst RelationshipElementComponent: React.FC = () => {\n const {\n attributes,\n children,\n element,\n element: { relationTo, value },\n fieldProps,\n } = useElement<RelationshipElementType>()\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const [enabledCollectionSlugs] = useState(() =>\n collections\n .filter(({ admin: { enableRichTextRelationship } }) => enableRichTextRelationship)\n .map(({ slug }) => slug),\n )\n const [relatedCollection, setRelatedCollection] = useState(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const selected = useSelected()\n const focused = useFocused()\n const { i18n, t } = useTranslation()\n const editor = useSlateStatic()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n formatAdminURL({ apiRoute: api, path: `/${relatedCollection.slug}/${value?.id}`, serverURL }),\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: relatedCollection.slug,\n value: { id: doc.id },\n },\n { at: elementPath },\n )\n\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 [editor, element, relatedCollection, cacheBust, setParams, closeDrawer],\n )\n\n const swapRelationship = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, doc }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: doc.id },\n },\n { at: elementPath },\n )\n\n setRelatedCollection(getEntityConfig({ collectionSlug }))\n\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 closeListDrawer()\n dispatchCacheBust()\n },\n [closeListDrawer, editor, element, cacheBust, setParams, getEntityConfig],\n )\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\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[relatedCollection?.admin?.useAsTitle || 'id']}\n </p>\n </DocumentDrawerToggler>\n </div>\n <div className={`${baseClass}__actions`}>\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n {value?.id && <DocumentDrawer onSave={updateRelationship} />}\n <ListDrawer onSelect={swapRelationship} />\n {children}\n </div>\n )\n}\n\nexport const RelationshipElement = (props: any): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipElementComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","useConfig","useDocumentDrawer","useListDrawer","usePayloadAPI","useTranslation","formatAdminURL","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","baseClass","initialParams","depth","RelationshipElementComponent","attributes","children","element","relationTo","value","fieldProps","config","collections","routes","api","serverURL","getEntityConfig","enabledCollectionSlugs","filter","admin","enableRichTextRelationship","map","slug","relatedCollection","setRelatedCollection","collectionSlug","selected","focused","i18n","t","editor","cacheBust","dispatchCacheBust","state","data","setParams","apiRoute","path","id","DocumentDrawer","DocumentDrawerToggler","closeDrawer","ListDrawer","ListDrawerToggler","closeListDrawer","collectionSlugs","selectedCollection","removeRelationship","elementPath","findPath","removeNodes","at","updateRelationship","doc","setNodes","type","text","swapRelationship","div","className","Boolean","join","contentEditable","p","label","labels","singular","useAsTitle","disabled","field","readOnly","buttonStyle","el","icon","onClick","round","tooltip","e","preventDefault","onSave","onSelect","RelationshipElement","props"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,SAAS,EACTC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,WAAW,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,OAAO,eAAc;AACrB,SAASC,6BAA6B,QAAQ,yCAAwC;AAEtF,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAEA,MAAMC,+BAAyC;IAC7C,MAAM,EACJC,UAAU,EACVC,QAAQ,EACRC,OAAO,EACPA,SAAS,EAAEC,UAAU,EAAEC,KAAK,EAAE,EAC9BC,UAAU,EACX,GAAGX;IAEJ,MAAM,EACJY,QAAQ,EACNC,WAAW,EACXC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACDC,eAAe,EAChB,GAAGhC;IACJ,MAAM,CAACiC,uBAAuB,GAAGxB,SAAS,IACxCmB,YACGM,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAEC,0BAA0B,EAAE,EAAE,GAAKA,4BACtDC,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAEvB,MAAM,CAACC,mBAAmBC,qBAAqB,GAAG/B,SAAS,IACzDuB,gBAAgB;YAAES,gBAAgBjB;QAAW;IAG/C,MAAMkB,WAAW7B;IACjB,MAAM8B,UAAU/B;IAChB,MAAM,EAAEgC,IAAI,EAAEC,CAAC,E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OAAOmD;kCAEpC,cAAA,KAACvF;4BACCwF,aAAY;4BACZH,UAAU1D,YAAY2D,OAAOlD,OAAOmD;4BACpCE,IAAG;4BACHC,MAAK;4BACLC,SAAS;4BACP,aAAa;4BACf;4BACAC,KAAK;4BACLC,SAAS/C,EAAE;;;kCAGf,KAAC9C;wBACCwF,aAAY;wBACZZ,WAAW,GAAG1D,UAAU,cAAc,CAAC;wBACvCmE,UAAU1D,YAAY2D,OAAOlD,OAAOmD;wBACpCG,MAAK;wBACLC,SAAS,CAACG;4BACRA,EAAEC,cAAc;4BAChB/B;wBACF;wBACA4B,KAAK;wBACLC,SAAS/C,EAAE;;;;YAGdpB,OAAO6B,oBAAM,KAACC;gBAAewC,QAAQ3B;;0BACtC,KAACV;gBAAWsC,UAAUvB;;YACrBnD;;;AAGP;AAEA,OAAO,MAAM2E,sBAAsB,CAACC;IAClC,qBACE,KAAClF;QAA+B,GAAGkF,KAAK;kBACtC,cAAA,KAAC9E;YAA8B,GAAG8E,KAAK;;;AAG7C,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAShE,OAAO,cAAc,CAAA;AAqMrB,eAAO,MAAM,aAAa,UAAW,GAAG,KAAG,KAAK,CAAC,SAMhD,CAAA"}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { getTranslation } from '@payloadcms/translations';
|
|
4
4
|
import { Button, DrawerToggler, File, useConfig, useDocumentDrawer, useDrawerSlug, useListDrawer, usePayloadAPI, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import { formatAdminURL } from 'payload/shared';
|
|
5
6
|
import React, { useCallback, useReducer, useState } from 'react';
|
|
6
7
|
import { Transforms } from 'slate';
|
|
7
8
|
import { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react';
|
|
8
9
|
import { useElement } from '../../../providers/ElementProvider.js';
|
|
9
10
|
import { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js';
|
|
10
11
|
import { uploadFieldsSchemaPath, uploadName } from '../shared.js';
|
|
11
|
-
import { UploadDrawer } from './UploadDrawer/index.js';
|
|
12
12
|
import './index.scss';
|
|
13
|
+
import { UploadDrawer } from './UploadDrawer/index.js';
|
|
13
14
|
const baseClass = 'rich-text-upload';
|
|
14
15
|
const initialParams = {
|
|
15
16
|
depth: 0
|
|
@@ -35,7 +36,11 @@ const UploadElementComponent = ({ enabledCollectionSlugs })=>{
|
|
|
35
36
|
const selected = useSelected();
|
|
36
37
|
const focused = useFocused();
|
|
37
38
|
// Get the referenced document
|
|
38
|
-
const [{ data }, { setParams }] = usePayloadAPI(
|
|
39
|
+
const [{ data }, { setParams }] = usePayloadAPI(formatAdminURL({
|
|
40
|
+
apiRoute: api,
|
|
41
|
+
path: `/${relatedCollection.slug}/${value?.id}`,
|
|
42
|
+
serverURL
|
|
43
|
+
}), {
|
|
39
44
|
initialParams
|
|
40
45
|
});
|
|
41
46
|
const thumbnailSRC = data?.thumbnailURL || data?.url;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ListDrawerProps } from '@payloadcms/ui'\nimport type { ClientCollectionConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n DrawerToggler,\n File,\n useConfig,\n useDocumentDrawer,\n useDrawerSlug,\n useListDrawer,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { UploadElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { uploadFieldsSchemaPath, uploadName } from '../shared.js'\nimport { UploadDrawer } from './UploadDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nconst UploadElementComponent: React.FC<{ enabledCollectionSlugs?: string[] }> = ({\n enabledCollectionSlugs,\n}) => {\n const {\n attributes,\n children,\n element: { relationTo, value },\n element,\n fieldProps,\n schemaPath,\n } = useElement<UploadElementType>()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const editor = useSlateStatic()\n const selected = useSelected()\n const focused = useFocused()\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 const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateUpload = useCallback(\n (json) => {\n const { doc } = json\n\n const newNode = {\n fields: doc,\n }\n\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(editor, newNode, { at: elementPath })\n\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 [editor, element, setParams, cacheBust, closeDrawer],\n )\n\n const swapUpload = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, doc }) => {\n const newNode = {\n type: uploadName,\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: doc.id },\n }\n\n const elementPath = ReactEditor.findPath(editor, element)\n\n setRelatedCollection(getEntityConfig({ collectionSlug }))\n\n Transforms.setNodes(editor, newNode, { at: elementPath })\n\n dispatchCacheBust()\n closeListDrawer()\n },\n [closeListDrawer, editor, element, getEntityConfig],\n )\n\n const relatedFieldSchemaPath = `${uploadFieldsSchemaPath}.${relatedCollection.slug}`\n const customFieldsMap = fieldProps.componentMap[relatedFieldSchemaPath]\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use 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 <div className={`${baseClass}__actions`}>\n {Boolean(customFieldsMap) && (\n <>\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.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 <UploadDrawer\n {...{ drawerSlug, element, fieldProps, relatedCollection, schemaPath }}\n />\n </>\n )}\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\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 {children}\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n <ListDrawer onSelect={swapUpload} />\n </div>\n )\n}\n\nexport const UploadElement = (props: any): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadElementComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","DrawerToggler","File","useConfig","useDocumentDrawer","useDrawerSlug","useListDrawer","usePayloadAPI","useTranslation","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","uploadFieldsSchemaPath","uploadName","UploadDrawer","baseClass","initialParams","depth","UploadElementComponent","enabledCollectionSlugs","attributes","children","element","relationTo","value","fieldProps","schemaPath","config","routes","api","serverURL","getEntityConfig","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","collectionSlug","drawerSlug","ListDrawer","ListDrawerToggler","closeDrawer","closeListDrawer","collectionSlugs","selectedCollection","slug","DocumentDrawer","DocumentDrawerToggler","id","editor","selected","focused","data","setParams","thumbnailSRC","thumbnailURL","url","removeUpload","elementPath","findPath","removeNodes","at","updateUpload","json","doc","newNode","fields","setNodes","swapUpload","type","text","relatedFieldSchemaPath","customFieldsMap","componentMap","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","disabled","field","admin","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","strong","onSave","onSelect","UploadElement","props","uploads"],"mappings":"AAAA;;AAKA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,aAAa,EACbC,IAAI,EACJC,SAAS,EACTC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,WAAW,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,SAASC,sBAAsB,EAAEC,UAAU,QAAQ,eAAc;AACjE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAEA,MAAMC,yBAA0E,CAAC,EAC/EC,sBAAsB,EACvB;IACC,MAAM,EACJC,UAAU,EACVC,QAAQ,EACRC,SAAS,EAAEC,UAAU,EAAEC,KAAK,EAAE,EAC9BF,OAAO,EACPG,UAAU,EACVC,UAAU,EACX,GAAGhB;IAEJ,MAAM,EACJiB,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACDC,eAAe,EAChB,GAAGpC;IACJ,MAAM,EAAEqC,IAAI,EAAEC,CAAC,EAAE,GAAGjC;IACpB,MAAM,CAACkC,WAAWC,kBAAkB,GAAGhC,WAAW,CAACiC,QAAUA,QAAQ,GAAG;IACxE,MA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cAAA,KAACvF;YAAwB,GAAGsF,KAAK;;;AAGvC,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ListDrawerProps } from '@payloadcms/ui'\nimport type { ClientCollectionConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n DrawerToggler,\n File,\n useConfig,\n useDocumentDrawer,\n useDrawerSlug,\n useListDrawer,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { UploadElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { uploadFieldsSchemaPath, uploadName } from '../shared.js'\nimport './index.scss'\nimport { UploadDrawer } from './UploadDrawer/index.js'\n\nconst baseClass = 'rich-text-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nconst UploadElementComponent: React.FC<{ enabledCollectionSlugs?: string[] }> = ({\n enabledCollectionSlugs,\n}) => {\n const {\n attributes,\n children,\n element: { relationTo, value },\n element,\n fieldProps,\n schemaPath,\n } = useElement<UploadElementType>()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const editor = useSlateStatic()\n const selected = useSelected()\n const focused = useFocused()\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n formatAdminURL({ apiRoute: api, path: `/${relatedCollection.slug}/${value?.id}`, serverURL }),\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateUpload = useCallback(\n (json) => {\n const { doc } = json\n\n const newNode = {\n fields: doc,\n }\n\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(editor, newNode, { at: elementPath })\n\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 [editor, element, setParams, cacheBust, closeDrawer],\n )\n\n const swapUpload = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, doc }) => {\n const newNode = {\n type: uploadName,\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: doc.id },\n }\n\n const elementPath = ReactEditor.findPath(editor, element)\n\n setRelatedCollection(getEntityConfig({ collectionSlug }))\n\n Transforms.setNodes(editor, newNode, { at: elementPath })\n\n dispatchCacheBust()\n closeListDrawer()\n },\n [closeListDrawer, editor, element, getEntityConfig],\n )\n\n const relatedFieldSchemaPath = `${uploadFieldsSchemaPath}.${relatedCollection.slug}`\n const customFieldsMap = fieldProps.componentMap[relatedFieldSchemaPath]\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use 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 <div className={`${baseClass}__actions`}>\n {Boolean(customFieldsMap) && (\n <>\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.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 <UploadDrawer\n {...{ drawerSlug, element, fieldProps, relatedCollection, schemaPath }}\n />\n </>\n )}\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\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 {children}\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n <ListDrawer onSelect={swapUpload} />\n </div>\n )\n}\n\nexport const UploadElement = (props: any): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadElementComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","DrawerToggler","File","useConfig","useDocumentDrawer","useDrawerSlug","useListDrawer","usePayloadAPI","useTranslation","formatAdminURL","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","uploadFieldsSchemaPath","uploadName","UploadDrawer","baseClass","initialParams","depth","UploadElementComponent","enabledCollectionSlugs","attributes","children","element","relationTo","value","fieldProps","schemaPath","config","routes","api","serverURL","getEntityConfig","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","collectionSlug","drawerSlug","ListDrawer","ListDrawerToggler","closeDrawer","closeListDrawer","collectionSlugs","selectedCollection","slug","DocumentDrawer","DocumentDrawerToggler","id","editor","selected","focused","data","setParams","apiRoute","path","thumbnailSRC","thumbnailURL","url","removeUpload","elementPath","findPath","removeNodes","at","updateUpload","json","doc","newNode","fields","setNodes","swapUpload","type","text","relatedFieldSchemaPath","customFieldsMap","componentMap","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","disabled","field","admin","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","strong","onSave","onSelect","UploadElement","props","uploads"],"mappings":"AAAA;;AAKA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,aAAa,EACbC,IAAI,EACJC,SAAS,EACTC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,WAAW,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,SAASC,sBAAsB,EAAEC,UAAU,QAAQ,eAAc;AACjE,OAAO,eAAc;AACrB,SAASC,YAAY,QAAQ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hE,UAAU,cAAc,CAAC;gDACvC2E,UAAUjE,YAAYkE,OAAOC,OAAOC;gDACpCG,MAAK;gDACLC,SAAS,CAACC;oDACRA,EAAEC,cAAc;oDAChBtC;gDACF;gDACAuC,KAAK;gDACLC,SAASpE,EAAE;;;;;;;;kCAKnB,KAAC6C;wBAAIC,WAAW,GAAGhE,UAAU,WAAW,CAAC;kCACvC,cAAA,KAACkC;4BAAsB8B,WAAW,GAAGhE,UAAU,oBAAoB,CAAC;sCAClE,cAAA,KAACuF;0CAAQhD,MAAMgC;;;;;;YAIpBjE;YACAG,OAAO0B,oBAAM,KAACF;gBAAeuD,QAAQrC;;0BACtC,KAACzB;gBAAW+D,UAAUhC;;;;AAG5B;AAEA,OAAO,MAAMiC,gBAAgB,CAACC;IAC5B,qBACE,KAAC/F;QAA+B,GAAG+F,KAAK;QAAEC,OAAO;kBAC/C,cAAA,KAACzF;YAAwB,GAAGwF,KAAK;;;AAGvC,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-slate",
|
|
3
|
-
"version": "3.69.0
|
|
3
|
+
"version": "3.69.0",
|
|
4
4
|
"description": "The officially supported Slate richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -50,21 +50,21 @@
|
|
|
50
50
|
"slate-history": "0.86.0",
|
|
51
51
|
"slate-hyperscript": "0.81.3",
|
|
52
52
|
"slate-react": "0.92.0",
|
|
53
|
-
"@payloadcms/translations": "3.69.0
|
|
54
|
-
"@payloadcms/ui": "3.69.0
|
|
53
|
+
"@payloadcms/translations": "3.69.0",
|
|
54
|
+
"@payloadcms/ui": "3.69.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/is-hotkey": "^0.1.10",
|
|
58
58
|
"@types/node": "22.15.30",
|
|
59
59
|
"@types/react": "19.2.1",
|
|
60
60
|
"@types/react-dom": "19.2.1",
|
|
61
|
-
"payload": "3.69.0
|
|
61
|
+
"payload": "3.69.0",
|
|
62
62
|
"@payloadcms/eslint-config": "3.28.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
66
66
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
67
|
-
"payload": "3.69.0
|
|
67
|
+
"payload": "3.69.0"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": "^18.20.2 || >=20.9.0"
|