@payloadcms/richtext-lexical 3.0.0-beta.63 → 3.0.0-beta.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/exports/client/chunk-XMCXIHWD.js +2 -0
  2. package/dist/exports/client/chunk-XMCXIHWD.js.map +7 -0
  3. package/dist/exports/client/{component-X4T7AVHY.js → component-VQ4OUM2Q.js} +2 -2
  4. package/dist/exports/client/index.js +3 -3
  5. package/dist/exports/client/index.js.map +2 -2
  6. package/dist/features/experimental_table/plugins/TablePlugin/index.d.ts.map +1 -1
  7. package/dist/features/experimental_table/plugins/TablePlugin/index.js +0 -1
  8. package/dist/features/experimental_table/plugins/TablePlugin/index.js.map +1 -1
  9. package/dist/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +2 -2
  10. package/dist/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  11. package/dist/field/index.js +3 -3
  12. package/dist/utilities/fieldsDrawer/Drawer.d.ts +2 -2
  13. package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
  14. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  15. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  16. package/dist/utilities/fieldsDrawer/DrawerContent.js +2 -4
  17. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  18. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts.map +1 -1
  19. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +15 -15
  20. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
  21. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
  22. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +15 -15
  23. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  24. package/package.json +9 -9
  25. package/dist/exports/client/chunk-M6Q5FGTK.js +0 -2
  26. package/dist/exports/client/chunk-M6Q5FGTK.js.map +0 -7
  27. /package/dist/exports/client/{component-X4T7AVHY.js.map → component-VQ4OUM2Q.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ import{b as g}from"./chunk-QZIAQPM7.js";import{Drawer as $}from"@payloadcms/ui";import{Form as R,FormSubmit as F,RenderFields as O,useConfig as E,useDocumentInfo as M,useFieldProps as T,useTranslation as A}from"@payloadcms/ui";import{getFormState as y}from"@payloadcms/ui/shared";import{useCallback as L,useEffect as k,useState as P}from"react";import{v4 as I}from"uuid";import{jsx as D,jsxs as N}from"react/jsx-runtime";var C=({data:e,featureKey:t,handleDrawerSubmit:o,schemaPathSuffix:a})=>{let{t:i}=A(),{id:n}=M(),{schemaPath:l}=T(),r=E(),[p,x]=P(!1),{field:{richTextComponentMap:_}}=g(),U=`lexical_internal_feature.${t}.fields${a?`.${a}`:""}`,s=`${l}.lexical_internal_feature.${t}${a?`.${a}`:""}`,d=_.get(U);k(()=>{(async()=>{let w=await y({apiRoute:r.routes.api,body:{id:n,data:e??{},operation:"update",schemaPath:s},serverURL:r.serverURL});x(w)})()},[r.routes.api,r.serverURL,s,n,e]);let m=L(async({formState:f})=>await y({apiRoute:r.routes.api,body:{id:n,formState:f,operation:"update",schemaPath:s},serverURL:r.serverURL}),[r.routes.api,r.serverURL,s,n]);return p===!1?null:N(R,{beforeSubmit:[m],disableValidationOnSubmit:!0,fields:Array.isArray(d)?d:[],initialState:p,onChange:[m],onSubmit:o,uuid:I(),children:[D(O,{fieldMap:Array.isArray(d)?d:[],forceRender:!0,path:"",readOnly:!1,schemaPath:s}),D(F,{children:i("fields:saveChanges")})]})};import{jsx as S}from"react/jsx-runtime";var lt=({className:e,data:t,drawerSlug:o,drawerTitle:a,featureKey:i,handleDrawerSubmit:n,schemaPathSuffix:l})=>S($,{className:e,slug:o,title:a??"",children:S(C,{data:t,featureKey:i,handleDrawerSubmit:n,schemaPathSuffix:l})});import{useAuth as H,useConfig as B,useEntityVisibility as K}from"@payloadcms/ui";import*as u from"react";var W=(e,t)=>e.filter(({slug:o,admin:{enableRichTextRelationship:a},upload:i})=>t.visibleEntities.collections.includes(o)?t?.uploads?a&&!!i:i?!1:a:!1),ut=e=>{let{children:t,uploads:o=!1,...a}=e,{collections:i}=B(),{user:n}=H(),{visibleEntities:l}=K(),[r]=u.useState(()=>W(i,{uploads:o,user:n,visibleEntities:l}).map(({slug:p})=>p));return r.length?u.cloneElement(t,{...a,enabledCollectionSlugs:r}):null};import{createCommand as J}from"lexical";var ft=J("INSERT_UPLOAD_WITH_DRAWER_COMMAND");import{DecoratorBlockNode as V}from"@lexical/react/LexicalDecoratorBlockNode.js";import h from"bson-objectid";import{$applyNodeReplacement as X}from"lexical";import*as b from"react";import{jsx as Q}from"react/jsx-runtime";var G=b.lazy(()=>import("./component-VQ4OUM2Q.js").then(e=>({default:e.UploadComponent})));function j(e){return e.parentElement!=null&&e.parentElement.tagName==="LI"&&e.previousSibling===null&&e.getAttribute("aria-roledescription")==="checkbox"}function q(e){if(e.hasAttribute("data-lexical-upload-relation-to")&&e.hasAttribute("data-lexical-upload-id")){let o=e.getAttribute("data-lexical-upload-id"),a=e.getAttribute("data-lexical-upload-relation-to");if(o!=null&&a!=null)return{node:v({data:{fields:{},relationTo:a,value:o}})}}let t=e;return t.src.startsWith("file:///")||j(t),null}var c=class e extends V{__data;constructor({data:t,format:o,key:a}){super(o,a),this.__data=t}static clone(t){return new e({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"upload"}static importDOM(){return{img:t=>({conversion:q,priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new h.default().toHexString(),t.version=3);let o={id:t.id,fields:t.fields,relationTo:t.relationTo,value:t.value},a=v({data:o});return a.setFormat(t.format),a}static isInline(){return!1}decorate(){return Q(G,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let t=document.createElement("img");return t.setAttribute("data-lexical-upload-id",String(this.__data?.value)),t.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(t){let o=this.getWritable();o.__data=t}updateDOM(){return!1}};function v({data:e}){return e?.id||(e.id=new h.default().toHexString()),X(new c({data:e}))}function St(e){return e instanceof c}export{lt as a,ut as b,ft as c,c as d,v as e,St as f};
2
+ //# sourceMappingURL=chunk-XMCXIHWD.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utilities/fieldsDrawer/Drawer.tsx", "../../../src/utilities/fieldsDrawer/DrawerContent.tsx", "../../../src/features/relationship/utils/EnabledRelationshipsCondition.tsx", "../../../src/features/upload/drawer/commands.ts", "../../../src/features/upload/nodes/UploadNode.tsx"],
4
+ "sourcesContent": ["'use client'\nimport type { Data, FormState } from 'payload'\n\nimport { Drawer } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { DrawerContent } from './DrawerContent.js'\n\nexport type FieldsDrawerProps = {\n className?: string\n data?: Data\n drawerSlug: string\n drawerTitle?: string\n featureKey: string\n handleDrawerSubmit: (fields: FormState, data: Record<string, unknown>) => void\n schemaPathSuffix?: string\n}\n\n/**\n * This FieldsDrawer component can be used to easily create a Drawer that contains a form with fields within your feature.\n * The fields are taken directly from the schema map based on your `featureKey` and `schemaPathSuffix`. Thus, this can only\n * be used if you provide your field schema inside the `generateSchemaMap` prop of your feature.server.ts.\n */\nexport const FieldsDrawer: React.FC<FieldsDrawerProps> = ({\n className,\n data,\n drawerSlug,\n drawerTitle,\n featureKey,\n handleDrawerSubmit,\n schemaPathSuffix,\n}) => {\n // The Drawer only renders its children (and itself) if it's open. Thus, by extracting the main content\n // to DrawerContent, this should be faster\n return (\n <Drawer className={className} slug={drawerSlug} title={drawerTitle ?? ''}>\n <DrawerContent\n data={data}\n featureKey={featureKey}\n handleDrawerSubmit={handleDrawerSubmit}\n schemaPathSuffix={schemaPathSuffix}\n />\n </Drawer>\n )\n}\n", "'use client'\nimport type { FormProps } from '@payloadcms/ui'\nimport type { FormState } from 'payload'\n\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useTranslation,\n} from '@payloadcms/ui'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n handleDrawerSubmit,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id } = useDocumentInfo()\n const { schemaPath } = useFieldProps()\n const config = useConfig()\n const [initialState, setInitialState] = useState<FormState | false>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedFieldsPath = `lexical_internal_feature.${featureKey}.fields${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fieldMap = richTextComponentMap.get(componentMapRenderedFieldsPath) // Field Schema\n\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: data ?? {},\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id, data])\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n return await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n },\n\n [config.routes.api, config.serverURL, schemaFieldsPath, id],\n )\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fieldMap) ? fieldMap : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fieldMap={Array.isArray(fieldMap) ? fieldMap : []}\n forceRender\n path=\"\" // See Blocks feature path for details as for why this is empty\n readOnly={false}\n schemaPath={schemaFieldsPath}\n />\n\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n", "import type { ClientCollectionConfig, ClientUser, VisibleEntities } from 'payload'\n\nimport { useAuth, useConfig, useEntityVisibility } from '@payloadcms/ui'\nimport * as React from 'react'\n\ntype Options = {\n uploads: boolean\n user: ClientUser\n visibleEntities: VisibleEntities\n}\n\ntype FilteredCollectionsT = (\n collections: ClientCollectionConfig[],\n options?: Options,\n) => ClientCollectionConfig[]\n\nconst filterRichTextCollections: FilteredCollectionsT = (collections, options) => {\n return collections.filter(({ slug, admin: { enableRichTextRelationship }, upload }) => {\n if (!options.visibleEntities.collections.includes(slug)) {\n return false\n }\n\n if (options?.uploads) {\n return enableRichTextRelationship && Boolean(upload) === true\n }\n\n return upload ? false : enableRichTextRelationship\n })\n}\n\nexport const EnabledRelationshipsCondition: React.FC<any> = (props) => {\n const { children, uploads = false, ...rest } = props\n const { collections } = useConfig()\n const { user } = useAuth()\n const { visibleEntities } = useEntityVisibility()\n\n const [enabledCollectionSlugs] = React.useState(() =>\n filterRichTextCollections(collections, { uploads, user, visibleEntities }).map(\n ({ slug }) => slug,\n ),\n )\n\n if (!enabledCollectionSlugs.length) {\n return null\n }\n\n return React.cloneElement(children, { ...rest, enabledCollectionSlugs })\n}\n", "'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nexport const INSERT_UPLOAD_WITH_DRAWER_COMMAND: LexicalCommand<{\n replace: { nodeKey: string } | false\n}> = createCommand('INSERT_UPLOAD_WITH_DRAWER_COMMAND')\n", "import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { CollectionSlug } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport type UploadData = {\n fields: {\n // unknown, custom fields:\n [key: string]: unknown\n }\n id: string\n relationTo: CollectionSlug\n value: number | string\n}\n\nfunction isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nfunction $convertUploadElement(domNode: HTMLImageElement): DOMConversionOutput | null {\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createUploadNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n const img = domNode\n if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {\n return null\n }\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n} & Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static clone(node: UploadNode): UploadNode {\n return new UploadNode({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'upload'\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n img: (node: HTMLImageElement) => ({\n conversion: $convertUploadElement,\n priority: 0,\n }),\n }\n }\n\n static importJSON(serializedNode: SerializedUploadNode): UploadNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n element.setAttribute('data-lexical-upload-id', String(this.__data?.value))\n element.setAttribute('data-lexical-upload-relation-to', this.__data?.relationTo)\n\n return { element }\n }\n\n exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadNode({ data: data as UploadData }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n"],
5
+ "mappings": "wCAGA,OAAS,UAAAA,MAAc,iBCCvB,OACE,QAAAC,EACA,cAAAC,EACA,gBAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,kBAAAC,MACK,iBACP,OAAS,gBAAAC,MAAoB,wBAC7B,OAAgB,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACxD,OAAS,MAAMC,MAAY,OAmEvB,OASE,OAAAC,EATF,QAAAC,MAAA,oBA7DG,IAAMC,EAAiF,CAAC,CAC7F,KAAAC,EACA,WAAAC,EACA,mBAAAC,EACA,iBAAAC,CACF,IAAM,CACJ,GAAM,CAAE,EAAAC,CAAE,EAAIC,EAAe,EACvB,CAAE,GAAAC,CAAG,EAAIC,EAAgB,EACzB,CAAE,WAAAC,CAAW,EAAIC,EAAc,EAC/BC,EAASC,EAAU,EACnB,CAACC,EAAcC,CAAe,EAAIC,EAA4B,EAAK,EACnE,CACJ,MAAO,CAAE,qBAAAC,CAAqB,CAChC,EAAIC,EAAuB,EAErBC,EAAiC,4BAA4BhB,CAAU,UAAUE,EAAmB,IAAIA,CAAgB,GAAK,EAAE,GAC/He,EAAmB,GAAGV,CAAU,6BAA6BP,CAAU,GAAGE,EAAmB,IAAIA,CAAgB,GAAK,EAAE,GAExHgB,EAAWJ,EAAqB,IAAIE,CAA8B,EAExEG,EAAU,IAAM,EACY,SAAY,CACpC,IAAMC,EAAQ,MAAMC,EAAa,CAC/B,SAAUZ,EAAO,OAAO,IACxB,KAAM,CACJ,GAAAJ,EACA,KAAMN,GAAQ,CAAC,EACf,UAAW,SACX,WAAYkB,CACd,EACA,UAAWR,EAAO,SACpB,CAAC,EAEDG,EAAgBQ,CAAK,CACvB,GAEuB,CACzB,EAAG,CAACX,EAAO,OAAO,IAAKA,EAAO,UAAWQ,EAAkBZ,EAAIN,CAAI,CAAC,EAEpE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KAAK,CAAC,EACzEA,EAAQ,aAAa,kCAAmC,KAAK,QAAQ,UAAU,EAExE,CAAE,QAAAA,CAAQ,CACnB,CAEA,YAAmC,CACjC,MAAO,CACL,GAAG,MAAM,WAAW,EACpB,GAAG,KAAK,QAAQ,EAChB,KAAM,SACN,QAAS,CACX,CACF,CAEA,SAAsB,CACpB,OAAO,KAAK,UAAU,EAAE,MAC1B,CAEA,QAAQN,EAAwB,CAC9B,IAAMO,EAAW,KAAK,YAAY,EAClCA,EAAS,OAASP,CACpB,CAEA,WAAmB,CACjB,MAAO,EACT,CACF,EAEO,SAASH,EAAkB,CAChC,KAAAG,CACF,EAEe,CACb,OAAKA,GAAM,KACTA,EAAK,GAAK,IAAIf,EAAS,QAAQ,EAAE,YAAY,GAExCC,EAAsB,IAAIY,EAAW,CAAE,KAAME,CAAmB,CAAC,CAAC,CAC3E,CAEO,SAASQ,GAAcL,EAA0D,CACtF,OAAOA,aAAgBL,CACzB",
6
+ "names": ["Drawer", "Form", "FormSubmit", "RenderFields", "useConfig", "useDocumentInfo", "useFieldProps", "useTranslation", "getFormState", "useCallback", "useEffect", "useState", "uuid", "jsx", "jsxs", "DrawerContent", "data", "featureKey", "handleDrawerSubmit", "schemaPathSuffix", "t", "useTranslation", "id", "useDocumentInfo", "schemaPath", "useFieldProps", "config", "useConfig", "initialState", "setInitialState", "useState", "richTextComponentMap", "useEditorConfigContext", "componentMapRenderedFieldsPath", "schemaFieldsPath", "fieldMap", "useEffect", "state", "getFormState", "onChange", "useCallback", "prevFormState", "Form", "uuid", "RenderFields", "FormSubmit", "jsx", "FieldsDrawer", "className", "data", "drawerSlug", "drawerTitle", "featureKey", "handleDrawerSubmit", "schemaPathSuffix", "Drawer", "DrawerContent", "useAuth", "useConfig", "useEntityVisibility", "React", "filterRichTextCollections", "collections", "options", "slug", "enableRichTextRelationship", "upload", "EnabledRelationshipsCondition", "props", "children", "uploads", "rest", "user", "visibleEntities", "enabledCollectionSlugs", "createCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "DecoratorBlockNode", "ObjectID", "$applyNodeReplacement", "React", "jsx", "RawUploadComponent", "module", "isGoogleDocCheckboxImg", "img", "$convertUploadElement", "domNode", "id", "relationTo", "$createUploadNode", "UploadNode", "_UploadNode", "data", "format", "key", "node", "serializedNode", "importedData", "element", "writable", "$isUploadNode"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use client";import{a as L,b as O,c as A,f as F}from"./chunk-M6Q5FGTK.js";import{b as T}from"./chunk-QZIAQPM7.js";import{useLexicalComposerContext as X}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as Z}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as ee}from"@lexical/utils";import{getTranslation as K}from"@payloadcms/translations";import{Button as N,DrawerToggler as oe,File as te,useConfig as ae,useDocumentDrawer as le,useDrawerSlug as re,useModal as ne,usePayloadAPI as ie,useTranslation as se}from"@payloadcms/ui";import{$getNodeByKey as E,$getSelection as de,$isNodeSelection as ce,CLICK_COMMAND as ue,COMMAND_PRIORITY_LOW as w,KEY_BACKSPACE_COMMAND as pe,KEY_DELETE_COMMAND as me}from"lexical";import{useCallback as i,useEffect as fe,useReducer as ge,useRef as Ce,useState as De}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";var t="lexical-upload",B={depth:0},ve=d=>{let{data:{fields:I,relationTo:R,value:c},nodeKey:l}=d,{collections:k,routes:{api:j},serverURL:W}=ae(),C=Ce(null),{closeModal:y}=ne(),[a]=X(),[r,u,D]=Z(l),{editorConfig:Y,field:v}=T(),{i18n:S,t:p}=se(),[$,H]=ge(e=>e+1,0),[n]=De(()=>k.find(e=>e.slug===R)),m=re("upload-drawer"),[z,q,{closeDrawer:h}]=le({id:c,collectionSlug:n.slug}),[{data:f},{setParams:P}]=ie(`${W}${j}/${n.slug}/${c}`,{initialParams:B}),U=f?.thumbnailURL||f?.url,G=i(()=>{a.update(()=>{E(l).remove()})},[a,l]),J=i(e=>{P({...B,cacheBust:$}),H(),h()},[P,$,h]),_=i(e=>{if(r&&ce(de())){e.preventDefault();let g=E(l);if(F(g))return g.remove(),!0}return!1},[r,l]),M=i(e=>e.target===C.current||C.current?.contains(e.target)?(e.shiftKey?u(!r):r||(D(),u(!0)),!0):!1,[r,u,D]);fe(()=>ee(a.registerCommand(ue,M,w),a.registerCommand(me,_,w),a.registerCommand(pe,_,w)),[D,a,r,l,_,u,M]);let x=(Y?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps).collections?.[n.slug]?.hasExtraFields,Q=i((e,g)=>{a.update(()=>{let b=E(l);if(b){let V={...b.getData(),fields:g};b.setData(V)}}),y(m)},[y,a,m,l]);return s("div",{className:[t,r&&`${t}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:C,children:[s("div",{className:`${t}__card`,children:[s("div",{className:`${t}__topRow`,children:[o("div",{className:`${t}__thumbnail`,children:U?o("img",{alt:f?.filename,"data-lexical-upload-id":c,"data-lexical-upload-relation-to":R,src:U}):o(te,{})}),s("div",{className:`${t}__topRowRightPanel`,children:[o("div",{className:`${t}__collectionLabel`,children:K(n.labels.singular,S)}),a.isEditable()&&s("div",{className:`${t}__actions`,children:[x?o(oe,{className:`${t}__upload-drawer-toggler`,disabled:v?.readOnly,slug:m,children:o(N,{buttonStyle:"icon-label",el:"div",icon:"edit",onClick:e=>{e.preventDefault()},round:!0,tooltip:p("fields:editRelationship")})}):null,o(N,{buttonStyle:"icon-label",disabled:v?.readOnly,el:"div",icon:"swap",onClick:()=>{a.dispatchCommand(A,{replace:{nodeKey:l}})},round:!0,tooltip:p("fields:swapUpload")}),o(N,{buttonStyle:"icon-label",className:`${t}__removeButton`,disabled:v?.readOnly,icon:"x",onClick:e=>{e.preventDefault(),G()},round:!0,tooltip:p("fields:removeUpload")})]})]})]}),o("div",{className:`${t}__bottomRow`,children:o(q,{className:`${t}__doc-drawer-toggler`,children:o("strong",{children:f?.filename})})})]}),c&&o(z,{onSave:J}),x?o(L,{data:I,drawerSlug:m,drawerTitle:p("general:editLabel",{label:K(n.labels.singular,S)}),featureKey:"upload",handleDrawerSubmit:Q,schemaPathSuffix:n.slug}):null]})},xe=d=>o(O,{...d,uploads:!0,children:o(ve,{...d})});export{xe as UploadComponent};
2
- //# sourceMappingURL=component-X4T7AVHY.js.map
1
+ "use client";import{a as L,b as O,c as A,f as F}from"./chunk-XMCXIHWD.js";import{b as T}from"./chunk-QZIAQPM7.js";import{useLexicalComposerContext as X}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as Z}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as ee}from"@lexical/utils";import{getTranslation as K}from"@payloadcms/translations";import{Button as N,DrawerToggler as oe,File as te,useConfig as ae,useDocumentDrawer as le,useDrawerSlug as re,useModal as ne,usePayloadAPI as ie,useTranslation as se}from"@payloadcms/ui";import{$getNodeByKey as E,$getSelection as de,$isNodeSelection as ce,CLICK_COMMAND as ue,COMMAND_PRIORITY_LOW as w,KEY_BACKSPACE_COMMAND as pe,KEY_DELETE_COMMAND as me}from"lexical";import{useCallback as i,useEffect as fe,useReducer as ge,useRef as Ce,useState as De}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";var t="lexical-upload",B={depth:0},ve=d=>{let{data:{fields:I,relationTo:R,value:c},nodeKey:l}=d,{collections:k,routes:{api:j},serverURL:W}=ae(),C=Ce(null),{closeModal:y}=ne(),[a]=X(),[r,u,D]=Z(l),{editorConfig:Y,field:v}=T(),{i18n:S,t:p}=se(),[$,H]=ge(e=>e+1,0),[n]=De(()=>k.find(e=>e.slug===R)),m=re("upload-drawer"),[z,q,{closeDrawer:h}]=le({id:c,collectionSlug:n.slug}),[{data:f},{setParams:P}]=ie(`${W}${j}/${n.slug}/${c}`,{initialParams:B}),U=f?.thumbnailURL||f?.url,G=i(()=>{a.update(()=>{E(l).remove()})},[a,l]),J=i(e=>{P({...B,cacheBust:$}),H(),h()},[P,$,h]),_=i(e=>{if(r&&ce(de())){e.preventDefault();let g=E(l);if(F(g))return g.remove(),!0}return!1},[r,l]),M=i(e=>e.target===C.current||C.current?.contains(e.target)?(e.shiftKey?u(!r):r||(D(),u(!0)),!0):!1,[r,u,D]);fe(()=>ee(a.registerCommand(ue,M,w),a.registerCommand(me,_,w),a.registerCommand(pe,_,w)),[D,a,r,l,_,u,M]);let x=(Y?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps).collections?.[n.slug]?.hasExtraFields,Q=i((e,g)=>{a.update(()=>{let b=E(l);if(b){let V={...b.getData(),fields:g};b.setData(V)}}),y(m)},[y,a,m,l]);return s("div",{className:[t,r&&`${t}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:C,children:[s("div",{className:`${t}__card`,children:[s("div",{className:`${t}__topRow`,children:[o("div",{className:`${t}__thumbnail`,children:U?o("img",{alt:f?.filename,"data-lexical-upload-id":c,"data-lexical-upload-relation-to":R,src:U}):o(te,{})}),s("div",{className:`${t}__topRowRightPanel`,children:[o("div",{className:`${t}__collectionLabel`,children:K(n.labels.singular,S)}),a.isEditable()&&s("div",{className:`${t}__actions`,children:[x?o(oe,{className:`${t}__upload-drawer-toggler`,disabled:v?.readOnly,slug:m,children:o(N,{buttonStyle:"icon-label",el:"div",icon:"edit",onClick:e=>{e.preventDefault()},round:!0,tooltip:p("fields:editRelationship")})}):null,o(N,{buttonStyle:"icon-label",disabled:v?.readOnly,el:"div",icon:"swap",onClick:()=>{a.dispatchCommand(A,{replace:{nodeKey:l}})},round:!0,tooltip:p("fields:swapUpload")}),o(N,{buttonStyle:"icon-label",className:`${t}__removeButton`,disabled:v?.readOnly,icon:"x",onClick:e=>{e.preventDefault(),G()},round:!0,tooltip:p("fields:removeUpload")})]})]})]}),o("div",{className:`${t}__bottomRow`,children:o(q,{className:`${t}__doc-drawer-toggler`,children:o("strong",{children:f?.filename})})})]}),c&&o(z,{onSave:J}),x?o(L,{data:I,drawerSlug:m,drawerTitle:p("general:editLabel",{label:K(n.labels.singular,S)}),featureKey:"upload",handleDrawerSubmit:Q,schemaPathSuffix:n.slug}):null]})},xe=d=>o(O,{...d,uploads:!0,children:o(ve,{...d})});export{xe as UploadComponent};
2
+ //# sourceMappingURL=component-VQ4OUM2Q.js.map