@payloadcms/richtext-slate 3.24.0-canary.f229d8d → 3.25.0-canary.36940b2

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.
@@ -14,6 +14,6 @@ type RecurseRichTextArgs = {
14
14
  showHiddenFields: boolean;
15
15
  };
16
16
  export declare const recurseRichText: ({ children, currentDepth, depth, draft, field, overrideAccess, populateArg, populationPromises, req, showHiddenFields, }: RecurseRichTextArgs) => void;
17
- export declare const richTextRelationshipPromise: ({ currentDepth, depth, draft, field, overrideAccess, populateArg, populationPromises, req, showHiddenFields, siblingDoc, }: Args) => void;
17
+ export declare const richTextRelationshipPromise: ({ currentDepth, depth, draft, field, overrideAccess, parentIsLocalized, populateArg, populationPromises, req, showHiddenFields, siblingDoc, }: Args) => void;
18
18
  export {};
19
19
  //# sourceMappingURL=richTextRelationshipPromise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"richTextRelationshipPromise.d.ts","sourceRoot":"","sources":["../../src/data/richTextRelationshipPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACd,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,MAAM,MAAM,IAAI,GAAG,UAAU,CAC3B,eAAe,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC,2BAA2B,CAAC,CACtE,CAAC,CAAC,CAAC,CAAA;AAEJ,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,aAAa,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACrC,cAAc,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,YAAY,CAAA;IAC1B,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,eAAe,6HAWzB,mBAAmB,KAAG,IA6GxB,CAAA;AAED,eAAO,MAAM,2BAA2B,+HAWrC,IAAI,SAaN,CAAA"}
1
+ {"version":3,"file":"richTextRelationshipPromise.d.ts","sourceRoot":"","sources":["../../src/data/richTextRelationshipPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACd,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,MAAM,MAAM,IAAI,GAAG,UAAU,CAC3B,eAAe,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC,2BAA2B,CAAC,CACtE,CAAC,CAAC,CAAC,CAAA;AAEJ,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,aAAa,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACrC,cAAc,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,YAAY,CAAA;IAC1B,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,eAAe,6HAWzB,mBAAmB,KAAG,IA6GxB,CAAA;AAED,eAAO,MAAM,2BAA2B,kJAYrC,IAAI,SAaN,CAAA"}
@@ -92,7 +92,7 @@ export const recurseRichText = ({ children, currentDepth = 0, depth, draft, fiel
92
92
  });
93
93
  }
94
94
  };
95
- export const richTextRelationshipPromise = ({ currentDepth, depth, draft, field, overrideAccess, populateArg, populationPromises, req, showHiddenFields, siblingDoc })=>{
95
+ export const richTextRelationshipPromise = ({ currentDepth, depth, draft, field, overrideAccess, parentIsLocalized, populateArg, populationPromises, req, showHiddenFields, siblingDoc })=>{
96
96
  recurseRichText({
97
97
  children: siblingDoc[field.name],
98
98
  currentDepth,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/data/richTextRelationshipPromise.ts"],"sourcesContent":["import type {\n CollectionConfig,\n PayloadRequest,\n PopulateType,\n RichTextAdapter,\n RichTextField,\n} from 'payload'\n\nimport type { AdapterArguments } from '../types.js'\n\nimport { populate } from './populate.js'\nimport { recurseNestedFields } from './recurseNestedFields.js'\n\nexport type Args = Parameters<\n RichTextAdapter<any[], AdapterArguments>['graphQLPopulationPromises']\n>[0]\n\ntype RecurseRichTextArgs = {\n children: unknown[]\n currentDepth: number\n depth: number\n draft: boolean\n field: RichTextField<any[], any, any>\n overrideAccess: boolean\n populateArg?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n}\n\nexport const recurseRichText = ({\n children,\n currentDepth = 0,\n depth,\n draft,\n field,\n overrideAccess = false,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n}: RecurseRichTextArgs): void => {\n if (depth <= 0 || currentDepth > depth) {\n return\n }\n\n if (Array.isArray(children)) {\n ;(children as any[]).forEach((element) => {\n if ((element.type === 'relationship' || element.type === 'upload') && element?.value?.id) {\n const collection = req.payload.collections[element?.relationTo]\n\n if (collection) {\n populationPromises.push(\n populate({\n id: element.value.id,\n collection,\n currentDepth,\n data: element,\n depth,\n draft,\n field,\n key: 'value',\n overrideAccess,\n req,\n select:\n req.payloadAPI !== 'GraphQL'\n ? (populateArg?.[collection.config.slug] ?? collection.config.defaultPopulate)\n : undefined,\n showHiddenFields,\n }),\n )\n }\n if (\n element.type === 'upload' &&\n Array.isArray(field.admin?.upload?.collections?.[element?.relationTo]?.fields)\n ) {\n recurseNestedFields({\n currentDepth,\n data: element.fields || {},\n depth,\n draft,\n fields: field.admin.upload.collections[element.relationTo].fields,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n })\n }\n }\n\n if (element.type === 'link') {\n if (element?.doc?.value && element?.doc?.relationTo) {\n const collection = req.payload.collections[element?.doc?.relationTo]\n\n if (collection) {\n populationPromises.push(\n populate({\n id: element.doc.value,\n collection,\n currentDepth,\n data: element.doc,\n depth,\n draft,\n field,\n key: 'value',\n overrideAccess,\n req,\n select:\n req.payloadAPI !== 'GraphQL'\n ? (populateArg?.[collection.config.slug] ?? collection.config.defaultPopulate)\n : undefined,\n showHiddenFields,\n }),\n )\n }\n }\n\n if (Array.isArray(field.admin?.link?.fields)) {\n recurseNestedFields({\n currentDepth,\n data: element.fields || {},\n depth,\n draft,\n fields: field.admin?.link?.fields,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n })\n }\n }\n\n if (element?.children) {\n recurseRichText({\n children: element.children,\n currentDepth,\n depth,\n draft,\n field,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n })\n }\n })\n }\n}\n\nexport const richTextRelationshipPromise = ({\n currentDepth,\n depth,\n draft,\n field,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n}: Args) => {\n recurseRichText({\n children: siblingDoc[field.name] as unknown[],\n currentDepth,\n depth,\n draft,\n field,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n })\n}\n"],"names":["populate","recurseNestedFields","recurseRichText","children","currentDepth","depth","draft","field","overrideAccess","populateArg","populationPromises","req","showHiddenFields","Array","isArray","forEach","element","type","value","id","collection","payload","collections","relationTo","push","data","key","select","payloadAPI","config","slug","defaultPopulate","undefined","admin","upload","fields","doc","link","richTextRelationshipPromise","siblingDoc","name"],"mappings":"AAUA,SAASA,QAA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ACAC;QACAC;QACAC;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/data/richTextRelationshipPromise.ts"],"sourcesContent":["import type {\n CollectionConfig,\n PayloadRequest,\n PopulateType,\n RichTextAdapter,\n RichTextField,\n} from 'payload'\n\nimport type { AdapterArguments } from '../types.js'\n\nimport { populate } from './populate.js'\nimport { recurseNestedFields } from './recurseNestedFields.js'\n\nexport type Args = Parameters<\n RichTextAdapter<any[], AdapterArguments>['graphQLPopulationPromises']\n>[0]\n\ntype RecurseRichTextArgs = {\n children: unknown[]\n currentDepth: number\n depth: number\n draft: boolean\n field: RichTextField<any[], any, any>\n overrideAccess: boolean\n populateArg?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n}\n\nexport const recurseRichText = ({\n children,\n currentDepth = 0,\n depth,\n draft,\n field,\n overrideAccess = false,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n}: RecurseRichTextArgs): void => {\n if (depth <= 0 || currentDepth > depth) {\n return\n }\n\n if (Array.isArray(children)) {\n ;(children as any[]).forEach((element) => {\n if ((element.type === 'relationship' || element.type === 'upload') && element?.value?.id) {\n const collection = req.payload.collections[element?.relationTo]\n\n if (collection) {\n populationPromises.push(\n populate({\n id: element.value.id,\n collection,\n currentDepth,\n data: element,\n depth,\n draft,\n field,\n key: 'value',\n overrideAccess,\n req,\n select:\n req.payloadAPI !== 'GraphQL'\n ? (populateArg?.[collection.config.slug] ?? collection.config.defaultPopulate)\n : undefined,\n showHiddenFields,\n }),\n )\n }\n if (\n element.type === 'upload' &&\n Array.isArray(field.admin?.upload?.collections?.[element?.relationTo]?.fields)\n ) {\n recurseNestedFields({\n currentDepth,\n data: element.fields || {},\n depth,\n draft,\n fields: field.admin.upload.collections[element.relationTo].fields,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n })\n }\n }\n\n if (element.type === 'link') {\n if (element?.doc?.value && element?.doc?.relationTo) {\n const collection = req.payload.collections[element?.doc?.relationTo]\n\n if (collection) {\n populationPromises.push(\n populate({\n id: element.doc.value,\n collection,\n currentDepth,\n data: element.doc,\n depth,\n draft,\n field,\n key: 'value',\n overrideAccess,\n req,\n select:\n req.payloadAPI !== 'GraphQL'\n ? (populateArg?.[collection.config.slug] ?? collection.config.defaultPopulate)\n : undefined,\n showHiddenFields,\n }),\n )\n }\n }\n\n if (Array.isArray(field.admin?.link?.fields)) {\n recurseNestedFields({\n currentDepth,\n data: element.fields || {},\n depth,\n draft,\n fields: field.admin?.link?.fields,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n })\n }\n }\n\n if (element?.children) {\n recurseRichText({\n children: element.children,\n currentDepth,\n depth,\n draft,\n field,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n })\n }\n })\n }\n}\n\nexport const richTextRelationshipPromise = ({\n currentDepth,\n depth,\n draft,\n field,\n overrideAccess,\n parentIsLocalized,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n}: Args) => {\n recurseRichText({\n children: siblingDoc[field.name] as unknown[],\n currentDepth,\n depth,\n draft,\n field,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n })\n}\n"],"names":["populate","recurseNestedFields","recurseRichText","children","currentDepth","depth","draft","field","overrideAccess","populateArg","populationPromises","req","showHiddenFields","Array","isArray","forEach","element","type","value","id","collection","payload","collections","relationTo","push","data","key","select","payloadAPI","config","slug","defaultPopulate","undefined","admin","upload","fields","doc","link","richTextRelationshipPromise","parentIsLocalized","siblingDoc","name"],"mappings":"AAUA,SAASA,QAAQ,QAAQ,gBAAe;AACxC,SAASC,mBAAmB,QAAQ,2BAA0B;AAmB9D,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,QAAQ,EACRC,eAAe,CAAC,EAChBC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,iBAAiB,KAAK,EACtBC,WAAW,EACXC,kBAAkB,EAClBC,GAAG,EACHC,g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4BACPmB,IAAIH,QAAQoB,GAAG,CAAClB,KAAK;4BACrBE;4BACAhB;4BACAqB,MAAMT,QAAQoB,GAAG;4BACjB/B;4BACAC;4BACAC;4BACAmB,KAAK;4BACLlB;4BACAG;4BACAgB,QACEhB,IAAIiB,UAAU,KAAK,YACdnB,aAAa,CAACW,WAAWS,MAAM,CAACC,IAAI,CAAC,IAAIV,WAAWS,MAAM,CAACE,eAAe,GAC3EC;4BACNpB;wBACF;oBAEJ;gBACF;gBAEA,IAAIC,MAAMC,OAAO,CAACP,MAAM0B,KAAK,EAAEI,MAAMF,SAAS;oBAC5ClC,oBAAoB;wBAClBG;wBACAqB,MAAMT,QAAQmB,MAAM,IAAI,CAAC;wBACzB9B;wBACAC;wBACA6B,QAAQ5B,MAAM0B,KAAK,EAAEI,MAAMF;wBAC3B3B;wBACAC;wBACAC;wBACAC;wBACAC;oBACF;gBACF;YACF;YAEA,IAAII,SAASb,UAAU;gBACrBD,gBAAgB;oBACdC,UAAUa,QAAQb,QAAQ;oBAC1BC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;YACF;QACF;IACF;AACF,EAAC;AAED,OAAO,MAAM0B,8BAA8B,CAAC,EAC1ClC,YAAY,EACZC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,cAAc,EACd+B,iBAAiB,EACjB9B,WAAW,EACXC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EAChB4B,UAAU,EACL;IACLtC,gBAAgB;QACdC,UAAUqC,UAAU,CAACjC,MAAMkC,IAAI,CAAC;QAChCrC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Button/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqD,MAAM,OAAO,CAAA;AAOzE,OAAO,cAAc,CAAA;AAmBrB,KAAK,KAAK,GAAG;IACX,sBAAsB,EAAE,MAAM,EAAE,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AA6CD,eAAO,MAAM,kBAAkB,UAAW,KAAK,KAAG,KAAK,CAAC,SAMvD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Button/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAO9D,OAAO,cAAc,CAAA;AAmBrB,KAAK,KAAK,GAAG;IACX,sBAAsB,EAAE,MAAM,EAAE,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AA2CD,eAAO,MAAM,kBAAkB,UAAW,KAAK,KAAG,KAAK,CAAC,SAMvD,CAAA"}
@@ -27,8 +27,8 @@ const insertRelationship = (editor, { relationTo, value })=>{
27
27
  const RelationshipButtonComponent = ({ enabledCollectionSlugs })=>{
28
28
  const { t } = useTranslation();
29
29
  const editor = useSlate();
30
- const [selectedCollectionSlug, setSelectedCollectionSlug] = useState(()=>enabledCollectionSlugs[0]);
31
- const [ListDrawer, ListDrawerToggler, { closeDrawer, isDrawerOpen }] = useListDrawer({
30
+ const [selectedCollectionSlug] = useState(()=>enabledCollectionSlugs[0]);
31
+ const [ListDrawer, ListDrawerToggler, { closeDrawer }] = useListDrawer({
32
32
  collectionSlugs: enabledCollectionSlugs,
33
33
  selectedCollection: selectedCollectionSlug
34
34
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/elements/relationship/Button/index.tsx"],"sourcesContent":["'use client'\n\nimport { useListDrawer, useTranslation } from '@payloadcms/ui'\nimport React, { Fragment, useCallback, useEffect, useState } from 'react'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport { RelationshipIcon } from '../../../icons/Relationship/index.js'\nimport { ElementButton } from '../../Button.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { injectVoidElement } from '../../injectVoid.js'\nimport './index.scss'\n\nconst baseClass = 'relationship-rich-text-button'\n\nconst insertRelationship = (editor, { relationTo, value }) => {\n const text = { text: ' ' }\n\n const relationship = {\n type: 'relationship',\n children: [text],\n relationTo,\n value,\n }\n\n injectVoidElement(editor, relationship)\n\n ReactEditor.focus(editor)\n}\n\ntype Props = {\n enabledCollectionSlugs: string[]\n path: string\n}\nconst RelationshipButtonComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const { t } = useTranslation()\n const editor = useSlate()\n const [selectedCollectionSlug, setSelectedCollectionSlug] = useState(\n () => enabledCollectionSlugs[0],\n )\n const [ListDrawer, ListDrawerToggler, { closeDrawer, isDrawerOpen }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: selectedCollectionSlug,\n })\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertRelationship(editor, {\n relationTo: collectionSlug,\n value: {\n id: docID,\n },\n })\n closeDrawer()\n },\n [editor, closeDrawer],\n )\n\n return (\n <Fragment>\n <ListDrawerToggler>\n <ElementButton\n className={baseClass}\n el=\"div\"\n format=\"relationship\"\n onClick={() => {\n // do nothing\n }}\n tooltip={t('fields:addRelationship')}\n >\n <RelationshipIcon />\n </ElementButton>\n </ListDrawerToggler>\n <ListDrawer onSelect={onSelect} />\n </Fragment>\n )\n}\n\nexport const RelationshipButton = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipButtonComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useListDrawer","useTranslation","React","Fragment","useCallback","useState","ReactEditor","useSlate","RelationshipIcon","ElementButton","EnabledRelationshipsCondition","injectVoidElement","baseClass","insertRelationship","editor","relationTo","value","text","relationship","type","children","focus","RelationshipButtonComponent","enabledCollectionSlugs","t","selectedCollectionSlug","setSelectedCollectionSlug","ListDrawer","ListDrawerToggler","closeDrawer","isDrawerOpen","collectionSlugs","selectedCollection","onSelect","collectionSlug","docID","id","className","el","format","onClick","too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,aAAa;oBACf;oBACAC,SAASjB,EAAE;8BAEX,cAAA,KAAChB;;;0BAGL,KAACmB;gBAAWM,UAAUA;;;;AAG5B;AAEA,OAAO,MAAMS,qBAAqB,CAACC;IACjC,qBACE,KAACjC;QAA+B,GAAGiC,KAAK;kBACtC,cAAA,KAACrB;YAA6B,GAAGqB,KAAK;;;AAG5C,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/elements/relationship/Button/index.tsx"],"sourcesContent":["'use client'\nimport type { ListDrawerProps } from '@payloadcms/ui'\n\nimport { useListDrawer, useTranslation } from '@payloadcms/ui'\nimport React, { Fragment, useCallback, useState } from 'react'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport { RelationshipIcon } from '../../../icons/Relationship/index.js'\nimport { ElementButton } from '../../Button.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { injectVoidElement } from '../../injectVoid.js'\nimport './index.scss'\n\nconst baseClass = 'relationship-rich-text-button'\n\nconst insertRelationship = (editor, { relationTo, value }) => {\n const text = { text: ' ' }\n\n const relationship = {\n type: 'relationship',\n children: [text],\n relationTo,\n value,\n }\n\n injectVoidElement(editor, relationship)\n\n ReactEditor.focus(editor)\n}\n\ntype Props = {\n enabledCollectionSlugs: string[]\n path: string\n}\nconst RelationshipButtonComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const { t } = useTranslation()\n const editor = useSlate()\n const [selectedCollectionSlug] = useState(() => enabledCollectionSlugs[0])\n const [ListDrawer, ListDrawerToggler, { closeDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: selectedCollectionSlug,\n })\n\n const onSelect = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, docID }) => {\n insertRelationship(editor, {\n relationTo: collectionSlug,\n value: {\n id: docID,\n },\n })\n closeDrawer()\n },\n [editor, closeDrawer],\n )\n\n return (\n <Fragment>\n <ListDrawerToggler>\n <ElementButton\n className={baseClass}\n el=\"div\"\n format=\"relationship\"\n onClick={() => {\n // do nothing\n }}\n tooltip={t('fields:addRelationship')}\n >\n <RelationshipIcon />\n </ElementButton>\n </ListDrawerToggler>\n <ListDrawer onSelect={onSelect} />\n </Fragment>\n )\n}\n\nexport const RelationshipButton = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipButtonComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useListDrawer","useTranslation","React","Fragment","useCallback","useState","ReactEditor","useSlate","RelationshipIcon","ElementButton","EnabledRelationshipsCondition","injectVoidElement","baseClass","insertRelationship","editor","relationTo","value","text","relationship","type","children","focus","RelationshipButtonComponent","enabledCollectionSlugs","t","selectedCollectionSlug","ListDrawer","ListDrawerToggler","closeDrawer","collectionSlugs","selectedCollection","onSelect","collectionSlug","docID","id","className","el","format","onClick","tooltip","RelationshipButton","props"],"mappings":"AAAA;;AAGA,SAASA,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AAC9D,OAAOC,SAASC,QAAQ,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AAC9D,SAASC,WAAW,EAAEC,QAAQ,QAAQ,cAAa;AAEnD,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,aAAa,QAAQ,kBAAiB;AAC/C,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,qBAAqB,CAACC,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAE;IACvD,MAAMC,OAAO;QAAEA,MAAM;IAAI;IAEzB,MAAMC,eAAe;QACnBC,MAAM;QACNC,UAAU;YAACH;SAAK;QAChBF;QACAC;IACF;IAEAL,kBAAkBG,QAAQI;IAE1BZ,YAAYe,KAAK,CAACP;AACpB;AAMA,MAAMQ,8BAA+C,CAAC,EAAEC,sBAAsB,EAAE;IAC9E,MAAM,EAAEC,CAAC,EAAE,GAAGvB;IACd,MAAMa,SAASP;IACf,MAAM,CAACkB,uBAAuB,GAAGpB,SAAS,IAAMkB,sBAAsB,CAAC,EAAE;IACzE,MAAM,CAACG,YAAYC,mBAAmB,EAAEC,WAAW,EAAE,CAAC,GAAG5B,cAAc;QACrE6B,iBAAiBN;QACjBO,oBAAoBL;IACtB;IAEA,MAAMM,WAAW3B,YACf,CAAC,EAAE4B,cAAc,EAAEC,KAAK,EAAE;QACxBpB,mBAAmBC,QAAQ;YACzBC,YAAYiB;YACZhB,OAAO;gBACLkB,IAAID;YACN;QACF;QACAL;IACF,GACA;QAACd;QAAQc;KAAY;IAGvB,qBACE,MAACzB;;0BACC,KAACwB;0BACC,cAAA,KAAClB;oBACC0B,WAAWvB;oBACXwB,IAAG;oBACHC,QAAO;oBACPC,SAAS;oBACP,aAAa;oBACf;oBACAC,SAASf,EAAE;8BAEX,cAAA,KAAChB;;;0BAGL,KAACkB;gBAAWK,UAAUA;;;;AAG5B;AAEA,OAAO,MAAMS,qBAAqB,CAACC;IACjC,qBACE,KAAC/B;QAA+B,GAAG+B,KAAK;kBACtC,cAAA,KAACnB;YAA6B,GAAGmB,KAAK;;;AAG5C,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAQhE,OAAO,cAAc,CAAA;AA2KrB,eAAO,MAAM,mBAAmB,UAAW,GAAG,KAAG,KAAK,CAAC,SAMtD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAQhE,OAAO,cAAc,CAAA;AA2KrB,eAAO,MAAM,mBAAmB,UAAW,GAAG,KAAG,KAAK,CAAC,SAMtD,CAAA"}
@@ -74,7 +74,7 @@ const RelationshipElementComponent = ()=>{
74
74
  setParams,
75
75
  closeDrawer
76
76
  ]);
77
- const swapRelationship = React.useCallback(({ collectionSlug, docID })=>{
77
+ const swapRelationship = useCallback(({ collectionSlug, doc })=>{
78
78
  const elementPath = ReactEditor.findPath(editor, element);
79
79
  Transforms.setNodes(editor, {
80
80
  type: 'relationship',
@@ -85,7 +85,7 @@ const RelationshipElementComponent = ()=>{
85
85
  ],
86
86
  relationTo: collectionSlug,
87
87
  value: {
88
- id: docID
88
+ id: doc.id
89
89
  }
90
90
  }, {
91
91
  at: elementPath
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"sourcesContent":["'use client'\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 = React.useCallback(\n ({ collectionSlug, docID }) => {\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: docID },\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","docID","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;;AAEA,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,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,OAAO,eAAc;AAErB,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,GAAG/B;IACJ,MAAM,CAACgC,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,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;4BACCsF,aAAY;4BACZH,UAAUzD,YAAY0D,OAAOjD,OAAOkD;4BACpCE,IAAG;4BACHC,MAAK;4BACLC,SAAS;4BACP,aAAa;4BACf;4BACAC,KAAK;4BACLC,SAAS9C,EAAE;;;kCAGf,KAAC7C;wBACCsF,aAAY;wBACZZ,WAAW,GAAGzD,UAAU,cAAc,CAAC;wBACvCkE,UAAUzD,YAAY0D,OAAOjD,OAAOkD;wBACpCG,MAAK;wBACLC,SAAS,CAACG;4BACRA,EAAEC,cAAc;4BAChBhC;wBACF;wBACA6B,KAAK;wBACLC,SAAS9C,EAAE;;;;YAGdpB,OAAO2B,oBAAM,KAACC;gBAAeyC,QAAQ5B;;0BACtC,KAACV;gBAAWuC,UAAUxB;;YACrBjD;;;AAGP;AAEA,OAAO,MAAM0E,sBAAsB,CAACC;IAClC,qBACE,KAACjF;QAA+B,GAAGiF,KAAK;kBACtC,cAAA,KAAC7E;YAA8B,GAAG6E,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 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,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,OAAO,eAAc;AAErB,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,GAAG/B;IACJ,MAAM,CAACgC,uBAAuB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BAAoB,CAAC;kCAClE,cAAA,KAAC4D;4BAAEJ,WAAW,GAAGxD,UAAU,OAAO,CAAC;sCAChCiC,IAAI,CAACX,mBAAmBJ,OAAO8C,cAAc,KAAK;;;;;0BAIzD,MAACT;gBAAIC,WAAW,GAAGxD,UAAU,SAAS,CAAC;;kCACrC,KAACwC;wBACCgB,WAAW,GAAGxD,UAAU,qBAAqB,CAAC;wBAC9CiE,UAAUxD,YAAYyD,OAAOhD,OAAOiD;kCAEpC,cAAA,KAACpF;4BACCqF,aAAY;4BACZH,UAAUxD,YAAYyD,OAAOhD,OAAOiD;4BACpCE,IAAG;4BACHC,MAAK;4BACLC,SAAS;4BACP,aAAa;4BACf;4BACAC,KAAK;4BACLC,SAAS7C,EAAE;;;kCAGf,KAAC7C;wBACCqF,aAAY;wBACZZ,WAAW,GAAGxD,UAAU,cAAc,CAAC;wBACvCiE,UAAUxD,YAAYyD,OAAOhD,OAAOiD;wBACpCG,MAAK;wBACLC,SAAS,CAACG;4BACRA,EAAEC,cAAc;4BAChB/B;wBACF;wBACA4B,KAAK;wBACLC,SAAS7C,EAAE;;;;YAGdpB,OAAO2B,oBAAM,KAACC;gBAAewC,QAAQ3B;;0BACtC,KAACV;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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/upload/Button/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgC,MAAM,OAAO,CAAA;AAOpD,OAAO,cAAc,CAAA;AAmBrB,KAAK,WAAW,GAAG;IACjB,sBAAsB,EAAE,MAAM,EAAE,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AA4CD,eAAO,MAAM,mBAAmB,UAAW,WAAW,KAAG,KAAK,CAAC,SAM9D,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/upload/Button/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAgC,MAAM,OAAO,CAAA;AAOpD,OAAO,cAAc,CAAA;AAmBrB,KAAK,WAAW,GAAG;IACjB,sBAAsB,EAAE,MAAM,EAAE,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AA4CD,eAAO,MAAM,mBAAmB,UAAW,WAAW,KAAG,KAAK,CAAC,SAM9D,CAAA"}
@@ -31,11 +31,11 @@ const UploadButton = ({ enabledCollectionSlugs })=>{
31
31
  collectionSlugs: enabledCollectionSlugs,
32
32
  uploads: true
33
33
  });
34
- const onSelect = useCallback(({ collectionSlug, docID })=>{
34
+ const onSelect = useCallback(({ collectionSlug, doc })=>{
35
35
  insertUpload(editor, {
36
36
  relationTo: collectionSlug,
37
37
  value: {
38
- id: docID
38
+ id: doc.id
39
39
  }
40
40
  });
41
41
  closeDrawer();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/elements/upload/Button/index.tsx"],"sourcesContent":["'use client'\n\nimport { useListDrawer, useTranslation } from '@payloadcms/ui'\nimport React, { Fragment, useCallback } from 'react'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport { UploadIcon } from '../../../icons/Upload/index.js'\nimport { ElementButton } from '../../Button.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { injectVoidElement } from '../../injectVoid.js'\nimport './index.scss'\n\nconst baseClass = 'upload-rich-text-button'\n\nconst insertUpload = (editor, { relationTo, value }) => {\n const text = { text: ' ' }\n\n const upload = {\n type: 'upload',\n children: [text],\n relationTo,\n value,\n }\n\n injectVoidElement(editor, upload)\n\n ReactEditor.focus(editor)\n}\n\ntype ButtonProps = {\n enabledCollectionSlugs: string[]\n path: string\n}\n\nconst UploadButton: React.FC<ButtonProps> = ({ enabledCollectionSlugs }) => {\n const { t } = useTranslation()\n const editor = useSlate()\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n uploads: true,\n })\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertUpload(editor, {\n relationTo: collectionSlug,\n value: {\n id: docID,\n },\n })\n closeDrawer()\n },\n [editor, closeDrawer],\n )\n\n return (\n <Fragment>\n <ListDrawerToggler>\n <ElementButton\n className={baseClass}\n el=\"div\"\n format=\"upload\"\n onClick={() => {\n // do nothing\n }}\n tooltip={t('fields:addUpload')}\n >\n <UploadIcon />\n </ElementButton>\n </ListDrawerToggler>\n <ListDrawer onSelect={onSelect} />\n </Fragment>\n )\n}\n\nexport const UploadElementButton = (props: ButtonProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadButton {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useListDrawer","useTranslation","React","Fragment","useCallback","ReactEditor","useSlate","UploadIcon","ElementButton","EnabledRelationshipsCondition","injectVoidElement","baseClass","insertUpload","editor","relationTo","value","text","upload","type","children","focus","UploadButton","enabledCollectionSlugs","t","ListDrawer","ListDrawerToggler","closeDrawer","collectionSlugs","uploads","onSelect","collectionSlug","docID","id","className","el","format","onClick","tooltip","UploadElementButton","props"],"mappings":"AAAA;;AAEA,SAASA,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AAC9D,OAAOC,SAASC,QAAQ,EAAEC,WAAW,QAAQ,QAAO;AACpD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,cAAa;AAEnD,SAASC,UAAU,QAAQ,iCAAgC;AAC3D,SAASC,aAAa,QAAQ,kBAAiB;AAC/C,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,eAAe,CAACC,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAE;IACjD,MAAMC,OAAO;QAAEA,MAAM;IAAI;IAEzB,MAAMC,SAAS;QACbC,MAAM;QACNC,UAAU;YAACH;SAAK;QAChBF;QACAC;IACF;IAEAL,kBAAkBG,QAAQI;IAE1BZ,YAAYe,KAAK,CAACP;AACpB;AAOA,MAAMQ,eAAsC,CAAC,EAAEC,sBAAsB,EAAE;IACrE,MAAM,EAAEC,CAAC,EAAE,GAAGtB;IACd,MAAMY,SAASP;IAEf,MAAM,CAACkB,YAAYC,mBAAmB,EAAEC,WAAW,EAAE,CAAC,GAAG1B,cAAc;QACrE2B,iBAAiBL;QACjBM,SAAS;IACX;IAEA,MAAMC,WAAWzB,YACf,CAAC,EAAE0B,cAAc,EAAEC,KAAK,EAAE;QACxBnB,aAAaC,QAAQ;YACnBC,YAAYgB;YACZf,OAAO;gBACLiB,IAAID;YACN;QACF;QACAL;IACF,GACA;QAACb;QAAQa;KAAY;IAGvB,qBACE,MAACvB;;0BACC,KAACsB;0BACC,cAAA,KAACjB;oBACCyB,WAAWtB;oBACXuB,IAAG;oBACHC,QAAO;oBACPC,SAAS;oBACP,aAAa;oBACf;oBACAC,SAASd,EAAE;8BAEX,cAAA,KAAChB;;;0BAGL,KAACiB;gBAAWK,UAAUA;;;;AAG5B;AAEA,OAAO,MAAMS,sBAAsB,CAACC;IAClC,qBACE,KAAC9B;QAA+B,GAAG8B,KAAK;QAAEX,OAAO;kBAC/C,cAAA,KAACP;YAAc,GAAGkB,KAAK;;;AAG7B,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/elements/upload/Button/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ListDrawerProps } from '@payloadcms/ui'\n\nimport { useListDrawer, useTranslation } from '@payloadcms/ui'\nimport React, { Fragment, useCallback } from 'react'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport { UploadIcon } from '../../../icons/Upload/index.js'\nimport { ElementButton } from '../../Button.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { injectVoidElement } from '../../injectVoid.js'\nimport './index.scss'\n\nconst baseClass = 'upload-rich-text-button'\n\nconst insertUpload = (editor, { relationTo, value }) => {\n const text = { text: ' ' }\n\n const upload = {\n type: 'upload',\n children: [text],\n relationTo,\n value,\n }\n\n injectVoidElement(editor, upload)\n\n ReactEditor.focus(editor)\n}\n\ntype ButtonProps = {\n enabledCollectionSlugs: string[]\n path: string\n}\n\nconst UploadButton: React.FC<ButtonProps> = ({ enabledCollectionSlugs }) => {\n const { t } = useTranslation()\n const editor = useSlate()\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n uploads: true,\n })\n\n const onSelect = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, doc }) => {\n insertUpload(editor, {\n relationTo: collectionSlug,\n value: {\n id: doc.id,\n },\n })\n closeDrawer()\n },\n [editor, closeDrawer],\n )\n\n return (\n <Fragment>\n <ListDrawerToggler>\n <ElementButton\n className={baseClass}\n el=\"div\"\n format=\"upload\"\n onClick={() => {\n // do nothing\n }}\n tooltip={t('fields:addUpload')}\n >\n <UploadIcon />\n </ElementButton>\n </ListDrawerToggler>\n <ListDrawer onSelect={onSelect} />\n </Fragment>\n )\n}\n\nexport const UploadElementButton = (props: ButtonProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadButton {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useListDrawer","useTranslation","React","Fragment","useCallback","ReactEditor","useSlate","UploadIcon","ElementButton","EnabledRelationshipsCondition","injectVoidElement","baseClass","insertUpload","editor","relationTo","value","text","upload","type","children","focus","UploadButton","enabledCollectionSlugs","t","ListDrawer","ListDrawerToggler","closeDrawer","collectionSlugs","uploads","onSelect","collectionSlug","doc","id","className","el","format","onClick","tooltip","UploadElementButton","props"],"mappings":"AAAA;;AAIA,SAASA,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AAC9D,OAAOC,SAASC,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,GAAGkB,KAAK;;;AAG7B,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAShE,OAAO,cAAc,CAAA;AAqMrB,eAAO,MAAM,aAAa,UAAW,GAAG,KAAG,KAAK,CAAC,SAMhD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAUhE,OAAO,cAAc,CAAA;AAoMrB,eAAO,MAAM,aAAa,UAAW,GAAG,KAAG,KAAK,CAAC,SAMhD,CAAA"}
@@ -8,8 +8,8 @@ import { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-reac
8
8
  import { useElement } from '../../../providers/ElementProvider.js';
9
9
  import { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js';
10
10
  import { uploadFieldsSchemaPath, uploadName } from '../shared.js';
11
- import './index.scss';
12
11
  import { UploadDrawer } from './UploadDrawer/index.js';
12
+ import './index.scss';
13
13
  const baseClass = 'rich-text-upload';
14
14
  const initialParams = {
15
15
  depth: 0
@@ -70,7 +70,7 @@ const UploadElementComponent = ({ enabledCollectionSlugs })=>{
70
70
  cacheBust,
71
71
  closeDrawer
72
72
  ]);
73
- const swapUpload = React.useCallback(({ collectionSlug, docID })=>{
73
+ const swapUpload = useCallback(({ collectionSlug, doc })=>{
74
74
  const newNode = {
75
75
  type: uploadName,
76
76
  children: [
@@ -80,7 +80,7 @@ const UploadElementComponent = ({ enabledCollectionSlugs })=>{
80
80
  ],
81
81
  relationTo: collectionSlug,
82
82
  value: {
83
- id: docID
83
+ id: doc.id
84
84
  }
85
85
  };
86
86
  const elementPath = ReactEditor.findPath(editor, element);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/elements/upload/Element/index.tsx"],"sourcesContent":["'use client'\n\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 './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 `${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 = React.useCallback(\n ({ collectionSlug, docID }) => {\n const newNode = {\n type: uploadName,\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: docID },\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","docID","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;;AAIA,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,OAAO,eAAc;AACrB,SAASC,YAAY,QAAQ,0BAAyB;AAEtD,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;IAE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cAAA,KAACsF;0CAAQ/C,MAAM+B;;;;;;YAIpBhE;YACAG,OAAO0B,oBAAM,KAACF;gBAAesD,QAAQtC;;0BACtC,KAACvB;gBAAW8D,UAAUjC;;;;AAG5B;AAEA,OAAO,MAAMkC,gBAAgB,CAACC;IAC5B,qBACE,KAAC9F;QAA+B,GAAG8F,KAAK;QAAEC,OAAO;kBAC/C,cAAA,KAACxF;YAAwB,GAAGuF,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 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,wC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ACAG,KAAK;oDACLC,SAASlE,EAAE;;;0DAGf,KAACzC;gDACCoG,aAAY;gDACZf,WAAW,GAAG9D,UAAU,cAAc,CAAC;gDACvCyE,UAAU/D,YAAYgE,OAAOC,OAAOC;gDACpCG,MAAK;gDACLC,SAAS,CAACC;oDACRA,EAAEC,cAAc;oDAChBtC;gDACF;gDACAuC,KAAK;gDACLC,SAASlE,EAAE;;;;;;;;kCAKnB,KAAC2C;wBAAIC,WAAW,GAAG9D,UAAU,WAAW,CAAC;kCACvC,cAAA,KAACkC;4BAAsB4B,WAAW,GAAG9D,UAAU,oBAAoB,CAAC;sCAClE,cAAA,KAACqF;0CAAQ9C,MAAM8B;;;;;;YAIpB/D;YACAG,OAAO0B,oBAAM,KAACF;gBAAeqD,QAAQrC;;0BACtC,KAACvB;gBAAW6D,UAAUhC;;;;AAG5B;AAEA,OAAO,MAAMiC,gBAAgB,CAACC;IAC5B,qBACE,KAAC7F;QAA+B,GAAG6F,KAAK;QAAEC,OAAO;kBAC/C,cAAA,KAACvF;YAAwB,GAAGsF,KAAK;;;AAGvC,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAI9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AASlD,wBAAgB,WAAW,CACzB,IAAI,EAAE,gBAAgB,GACrB,uBAAuB,CAAC,GAAG,EAAE,EAAE,gBAAgB,EAAE,GAAG,CAAC,CA+LvD;AAED,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,QAAQ,GACT,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAI9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AASlD,wBAAgB,WAAW,CACzB,IAAI,EAAE,gBAAgB,GACrB,uBAAuB,CAAC,GAAG,EAAE,EAAE,gBAAgB,EAAE,GAAG,CAAC,CAmMvD;AAED,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,QAAQ,GACT,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -96,7 +96,7 @@ export function slateEditor(args) {
96
96
  });
97
97
  },
98
98
  generateSchemaMap: getGenerateSchemaMap(args),
99
- graphQLPopulationPromises ({ context, currentDepth, depth, draft, field, fieldPromises, findMany, flattenLocales, overrideAccess, populationPromises, req, showHiddenFields, siblingDoc }) {
99
+ graphQLPopulationPromises ({ context, currentDepth, depth, draft, field, fieldPromises, findMany, flattenLocales, overrideAccess, parentIsLocalized, populationPromises, req, showHiddenFields, siblingDoc }) {
100
100
  if (field.admin?.elements?.includes('relationship') || field.admin?.elements?.includes('upload') || field.admin?.elements?.includes('link') || !field?.admin?.elements) {
101
101
  richTextRelationshipPromise({
102
102
  context,
@@ -108,6 +108,7 @@ export function slateEditor(args) {
108
108
  findMany,
109
109
  flattenLocales,
110
110
  overrideAccess,
111
+ parentIsLocalized,
111
112
  populationPromises,
112
113
  req,
113
114
  showHiddenFields,
@@ -117,7 +118,7 @@ export function slateEditor(args) {
117
118
  },
118
119
  hooks: {
119
120
  afterRead: [
120
- ({ context: _context, currentDepth, depth, draft, field: _field, fieldPromises, findMany, flattenLocales, overrideAccess, populate, populationPromises, req, showHiddenFields, siblingData })=>{
121
+ ({ context: _context, currentDepth, depth, draft, field: _field, fieldPromises, findMany, flattenLocales, overrideAccess, parentIsLocalized, populate, populationPromises, req, showHiddenFields, siblingData })=>{
121
122
  const context = _context;
122
123
  const field = _field;
123
124
  if (field.admin?.elements?.includes('relationship') || field.admin?.elements?.includes('upload') || field.admin?.elements?.includes('link') || !field?.admin?.elements) {
@@ -131,6 +132,7 @@ export function slateEditor(args) {
131
132
  findMany,
132
133
  flattenLocales,
133
134
  overrideAccess,
135
+ parentIsLocalized,
134
136
  populateArg: populate,
135
137
  populationPromises,
136
138
  req,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { Config, RichTextAdapterProvider } from 'payload'\n\nimport { sanitizeFields, withNullableJSONSchemaType } from 'payload'\n\nimport type { AdapterArguments } from './types.js'\n\nimport { richTextRelationshipPromise } from './data/richTextRelationshipPromise.js'\nimport { richTextValidate } from './data/validation.js'\nimport { elements as elementTypes } from './field/elements/index.js'\nimport { transformExtraFields } from './field/elements/link/utilities.js'\nimport { defaultLeaves as leafTypes } from './field/leaves/index.js'\nimport { getGenerateSchemaMap } from './generateSchemaMap.js'\n\nexport function slateEditor(\n args: AdapterArguments,\n): RichTextAdapterProvider<any[], AdapterArguments, any> {\n return async ({ config }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n if (!args.admin) {\n args.admin = {}\n }\n if (!args.admin.link) {\n args.admin.link = {}\n }\n if (!args.admin.link.fields) {\n args.admin.link.fields = []\n }\n args.admin.link.fields = await sanitizeFields({\n config: config as unknown as Config,\n fields: transformExtraFields(args.admin?.link?.fields, config),\n parentIsLocalized: false,\n validRelationships,\n })\n\n if (args?.admin?.upload?.collections) {\n for (const collection of Object.keys(args.admin.upload.collections)) {\n if (args?.admin?.upload?.collections[collection]?.fields) {\n args.admin.upload.collections[collection].fields = await sanitizeFields({\n config: config as unknown as Config,\n fields: args.admin?.upload?.collections[collection]?.fields,\n parentIsLocalized: false,\n validRelationships,\n })\n }\n }\n }\n\n return {\n CellComponent: '@payloadcms/richtext-slate/rsc#RscEntrySlateCell',\n FieldComponent: {\n path: '@payloadcms/richtext-slate/rsc#RscEntrySlateField',\n serverProps: {\n args,\n },\n },\n generateImportMap: ({ addToImportMap }) => {\n addToImportMap('@payloadcms/richtext-slate/rsc#RscEntrySlateCell')\n addToImportMap('@payloadcms/richtext-slate/rsc#RscEntrySlateField')\n Object.values(leafTypes).forEach((leaf) => {\n if (leaf.Button) {\n addToImportMap(leaf.Button)\n }\n if (leaf.Leaf) {\n addToImportMap(leaf.Leaf)\n }\n if (Array.isArray(leaf.plugins) && leaf.plugins?.length) {\n addToImportMap(leaf.plugins)\n }\n })\n args?.admin?.leaves?.forEach((leaf) => {\n if (typeof leaf === 'object') {\n if (leaf.Button) {\n addToImportMap(leaf.Button)\n }\n if (leaf.Leaf) {\n addToImportMap(leaf.Leaf)\n }\n if (Array.isArray(leaf.plugins) && leaf.plugins?.length) {\n addToImportMap(leaf.plugins)\n }\n }\n })\n\n Object.values(elementTypes).forEach((element) => {\n if (element.Button) {\n addToImportMap(element.Button)\n }\n if (element.Element) {\n addToImportMap(element.Element)\n }\n if (Array.isArray(element.plugins) && element.plugins?.length) {\n addToImportMap(element.plugins)\n }\n })\n\n args?.admin?.elements?.forEach((element) => {\n if (typeof element === 'object') {\n if (element.Button) {\n addToImportMap(element.Button)\n }\n if (element.Element) {\n addToImportMap(element.Element)\n }\n if (Array.isArray(element.plugins) && element.plugins?.length) {\n addToImportMap(element.plugins)\n }\n }\n })\n },\n generateSchemaMap: getGenerateSchemaMap(args),\n graphQLPopulationPromises({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n if (\n field.admin?.elements?.includes('relationship') ||\n field.admin?.elements?.includes('upload') ||\n field.admin?.elements?.includes('link') ||\n !field?.admin?.elements\n ) {\n richTextRelationshipPromise({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n },\n hooks: {\n afterRead: [\n ({\n context: _context,\n currentDepth,\n depth,\n draft,\n field: _field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n populate,\n populationPromises,\n req,\n showHiddenFields,\n siblingData,\n }) => {\n const context: any = _context\n const field = _field as any\n if (\n field.admin?.elements?.includes('relationship') ||\n field.admin?.elements?.includes('upload') ||\n field.admin?.elements?.includes('link') ||\n !field?.admin?.elements\n ) {\n richTextRelationshipPromise({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n populateArg: populate,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: siblingData,\n })\n }\n },\n ],\n },\n outputSchema: ({ isRequired }) => {\n return {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n },\n validate: richTextValidate,\n }\n }\n}\n\nexport type {\n AdapterArguments,\n ElementNode,\n RichTextCustomElement,\n RichTextCustomLeaf,\n RichTextElement,\n RichTextLeaf,\n RichTextPlugin,\n RichTextPluginComponent,\n SlateFieldProps,\n TextNode,\n} from './types.js'\n\nexport { nodeIsTextNode } from './types.js'\n"],"names":["sanitizeFields","withNullableJSONSchemaType","richTextRelationshipPromise","richTextValidate","elements","elementTypes","transformExtraFields","defaultLeaves","leafTypes","getGenerateSchemaMap","slateEditor","args","config","validRelationships","collections","map","c","slug","admin","link","fields","parentIsLocalized","upload","collection","Object","keys","CellComponent","FieldComponent","path","serverProps","generateImportMap","addToImportMap","values","forEach","leaf","Button","Leaf","Array","isArray","plugins","length","leaves","element","Element","generateSchemaMap","graphQLPopulationPromises","context","currentDepth","depth","draft","field","fieldPromises","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","includes","hooks","afterRead","_context","_field","populate","siblingData","populate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EAAEd,UAAUuD,SAAS,mBAChCT,MAAMhC,KAAK,EAAEd,UAAUuD,SAAS,aAChCT,MAAMhC,KAAK,EAAEd,UAAUuD,SAAS,WAChC,CAACT,OAAOhC,OAAOd,UACf;4BACAF,4BAA4B;gCAC1B4C;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAY,aAAaF;gCACbT;gCACAC;gCACAC;gCACAC,YAAYO;4BACd;wBACF;oBACF;iBACD;YACH;YACAE,cAAc,CAAC,EAAEC,UAAU,EAAE;gBAC3B,OAAO;oBACLC,MAAMpE,2BAA2B,SAASmE;oBAC1CE,OAAO;wBACLD,MAAM;oBACR;gBACF;YACF;YACAE,UAAUpE;QACZ;IACF;AACF;AAeA,SAASqE,cAAc,QAAQ,aAAY"}
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { Config, RichTextAdapterProvider } from 'payload'\n\nimport { sanitizeFields, withNullableJSONSchemaType } from 'payload'\n\nimport type { AdapterArguments } from './types.js'\n\nimport { richTextRelationshipPromise } from './data/richTextRelationshipPromise.js'\nimport { richTextValidate } from './data/validation.js'\nimport { elements as elementTypes } from './field/elements/index.js'\nimport { transformExtraFields } from './field/elements/link/utilities.js'\nimport { defaultLeaves as leafTypes } from './field/leaves/index.js'\nimport { getGenerateSchemaMap } from './generateSchemaMap.js'\n\nexport function slateEditor(\n args: AdapterArguments,\n): RichTextAdapterProvider<any[], AdapterArguments, any> {\n return async ({ config }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n if (!args.admin) {\n args.admin = {}\n }\n if (!args.admin.link) {\n args.admin.link = {}\n }\n if (!args.admin.link.fields) {\n args.admin.link.fields = []\n }\n args.admin.link.fields = await sanitizeFields({\n config: config as unknown as Config,\n fields: transformExtraFields(args.admin?.link?.fields, config),\n parentIsLocalized: false,\n validRelationships,\n })\n\n if (args?.admin?.upload?.collections) {\n for (const collection of Object.keys(args.admin.upload.collections)) {\n if (args?.admin?.upload?.collections[collection]?.fields) {\n args.admin.upload.collections[collection].fields = await sanitizeFields({\n config: config as unknown as Config,\n fields: args.admin?.upload?.collections[collection]?.fields,\n parentIsLocalized: false,\n validRelationships,\n })\n }\n }\n }\n\n return {\n CellComponent: '@payloadcms/richtext-slate/rsc#RscEntrySlateCell',\n FieldComponent: {\n path: '@payloadcms/richtext-slate/rsc#RscEntrySlateField',\n serverProps: {\n args,\n },\n },\n generateImportMap: ({ addToImportMap }) => {\n addToImportMap('@payloadcms/richtext-slate/rsc#RscEntrySlateCell')\n addToImportMap('@payloadcms/richtext-slate/rsc#RscEntrySlateField')\n Object.values(leafTypes).forEach((leaf) => {\n if (leaf.Button) {\n addToImportMap(leaf.Button)\n }\n if (leaf.Leaf) {\n addToImportMap(leaf.Leaf)\n }\n if (Array.isArray(leaf.plugins) && leaf.plugins?.length) {\n addToImportMap(leaf.plugins)\n }\n })\n args?.admin?.leaves?.forEach((leaf) => {\n if (typeof leaf === 'object') {\n if (leaf.Button) {\n addToImportMap(leaf.Button)\n }\n if (leaf.Leaf) {\n addToImportMap(leaf.Leaf)\n }\n if (Array.isArray(leaf.plugins) && leaf.plugins?.length) {\n addToImportMap(leaf.plugins)\n }\n }\n })\n\n Object.values(elementTypes).forEach((element) => {\n if (element.Button) {\n addToImportMap(element.Button)\n }\n if (element.Element) {\n addToImportMap(element.Element)\n }\n if (Array.isArray(element.plugins) && element.plugins?.length) {\n addToImportMap(element.plugins)\n }\n })\n\n args?.admin?.elements?.forEach((element) => {\n if (typeof element === 'object') {\n if (element.Button) {\n addToImportMap(element.Button)\n }\n if (element.Element) {\n addToImportMap(element.Element)\n }\n if (Array.isArray(element.plugins) && element.plugins?.length) {\n addToImportMap(element.plugins)\n }\n }\n })\n },\n generateSchemaMap: getGenerateSchemaMap(args),\n graphQLPopulationPromises({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n if (\n field.admin?.elements?.includes('relationship') ||\n field.admin?.elements?.includes('upload') ||\n field.admin?.elements?.includes('link') ||\n !field?.admin?.elements\n ) {\n richTextRelationshipPromise({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n },\n hooks: {\n afterRead: [\n ({\n context: _context,\n currentDepth,\n depth,\n draft,\n field: _field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populate,\n populationPromises,\n req,\n showHiddenFields,\n siblingData,\n }) => {\n const context: any = _context\n const field = _field as any\n if (\n field.admin?.elements?.includes('relationship') ||\n field.admin?.elements?.includes('upload') ||\n field.admin?.elements?.includes('link') ||\n !field?.admin?.elements\n ) {\n richTextRelationshipPromise({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populateArg: populate,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: siblingData,\n })\n }\n },\n ],\n },\n outputSchema: ({ isRequired }) => {\n return {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n },\n validate: richTextValidate,\n }\n }\n}\n\nexport type {\n AdapterArguments,\n ElementNode,\n RichTextCustomElement,\n RichTextCustomLeaf,\n RichTextElement,\n RichTextLeaf,\n RichTextPlugin,\n RichTextPluginComponent,\n SlateFieldProps,\n TextNode,\n} from './types.js'\n\nexport { nodeIsTextNode } from './types.js'\n"],"names":["sanitizeFields","withNullableJSONSchemaType","richTextRelationshipPromise","richTextValidate","elements","elementTypes","transformExtraFields","defaultLeaves","leafTypes","getGenerateSchemaMap","slateEditor","args","config","validRelationships","collections","map","c","slug","admin","link","fields","parentIsLocalized","upload","collection","Object","keys","CellComponent","FieldComponent","path","serverProps","generateImportMap","addToImportMap","values","forEach","leaf","Button","Leaf","Array","isArray","plugins","length","leaves","element","Element","generateSchemaMap","graphQLPopulationPromises","context","currentDepth","depth","draft","field","fieldPromises","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","includes","hooks","afterRead","_context","_field","populate","siblingData","populateArg","outputSchema","isRequired","type","items","validate","nodeIsTextNode"],"mappings":"AAEA,SAASA,cAAc,EAAEC,0BAA0B,QAAQ,UAAS;AAIpE,SAASC,2BAA2B,QAAQ,wCAAuC;AACnF,SAASC,gBAAgB,QAAQ,uBAAsB;AACvD,SAASC,YAAYC,YAAY,QAAQ,4BAA2B;AACpE,SAASC,oBAAoB,QAAQ,qCAAoC;AACzE,SAASC,iBAAiBC,SAAS,QAAQ,0BAAyB;AACpE,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7D,OAAO,SAASC,YACdC,IAAsB;IAEtB,OAAO,OAAO,EAAEC,MAAM,EAAE;QACtB,MAAMC,qBAAqBD,OAAOE,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEtE,IAAI,CAACN,KAAKO,KAAK,EAAE;YACfP,KAAKO,KAAK,GAAG,CAAC;QAChB;QACA,IAAI,CAACP,KAAKO,KAAK,CAACC,IAAI,EAAE;YACpBR,KAAKO,KAAK,CAACC,IAAI,GAAG,CAAC;QACrB;QACA,IAAI,CAACR,KAAKO,KAAK,CAACC,IAAI,CAACC,MAAM,EAAE;YAC3BT,KAAKO,KAAK,CAACC,IAAI,CAACC,MAAM,GAAG,EAAE;QAC7B;QACAT,KAAKO,KAAK,CAACC,IAAI,CAACC,MAAM,GAAG,MAAMpB,eAAe;YAC5CY,QAAQA;YACRQ,QAAQd,qBAAqBK,KAAKO,KAAK,EAAEC,MAAMC,QAAQR;YACvDS,mBAAmB;YACnBR;QACF;QAEA,IAAIF,MAAMO,OAAOI,QAAQR,aAAa;YACpC,KAAK,MAAMS,cAAcC,OAAOC,IAAI,CAACd,KAAKO,KAAK,CAACI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MAAM,EACbZ,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,cAAc,EACdjC,iBAAiB,EACjB2C,QAAQ,EACRT,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EAChBQ,WAAW,EACZ;wBACC,MAAMnB,UAAegB;wBACrB,MAAMZ,QAAQa;wBACd,IACEb,MAAMhC,KAAK,EAAEd,UAAUuD,SAAS,mBAChCT,MAAMhC,KAAK,EAAEd,UAAUuD,SAAS,aAChCT,MAAMhC,KAAK,EAAEd,UAAUuD,SAAS,WAChC,CAACT,OAAOhC,OAAOd,UACf;4BACAF,4BAA4B;gCAC1B4C;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAjC;gCACA6C,aAAaF;gCACbT;gCACAC;gCACAC;gCACAC,YAAYO;4BACd;wBACF;oBACF;iBACD;YACH;YACAE,cAAc,CAAC,EAAEC,UAAU,EAAE;gBAC3B,OAAO;oBACLC,MAAMpE,2BAA2B,SAASmE;oBAC1CE,OAAO;wBACLD,MAAM;oBACR;gBACF;YACF;YACAE,UAAUpE;QACZ;IACF;AACF;AAeA,SAASqE,cAAc,QAAQ,aAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-slate",
3
- "version": "3.24.0-canary.f229d8d",
3
+ "version": "3.25.0-canary.36940b2",
4
4
  "description": "The officially supported Slate richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -46,20 +46,20 @@
46
46
  "slate-history": "0.86.0",
47
47
  "slate-hyperscript": "0.81.3",
48
48
  "slate-react": "0.92.0",
49
- "@payloadcms/translations": "3.24.0-canary.f229d8d",
50
- "@payloadcms/ui": "3.24.0-canary.f229d8d"
49
+ "@payloadcms/translations": "3.25.0-canary.36940b2",
50
+ "@payloadcms/ui": "3.25.0-canary.36940b2"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/is-hotkey": "^0.1.10",
54
54
  "@types/node": "22.5.4",
55
55
  "@types/react": "19.0.1",
56
56
  "@types/react-dom": "19.0.1",
57
- "@payloadcms/eslint-config": "3.9.0",
58
- "payload": "3.24.0-canary.f229d8d"
57
+ "payload": "3.25.0-canary.36940b2",
58
+ "@payloadcms/eslint-config": "3.9.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
62
- "payload": "3.24.0-canary.f229d8d"
62
+ "payload": "3.25.0-canary.36940b2"
63
63
  },
64
64
  "engines": {
65
65
  "node": "^18.20.2 || >=20.9.0"