@payloadcms/richtext-lexical 3.53.0-internal.2dadf5b → 3.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.53.0-internal.2dadf5b",
3
+ "version": "3.53.0",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -368,8 +368,8 @@
368
368
  "react-error-boundary": "4.1.2",
369
369
  "ts-essentials": "10.0.3",
370
370
  "uuid": "10.0.0",
371
- "@payloadcms/translations": "3.53.0-internal.2dadf5b",
372
- "@payloadcms/ui": "3.53.0-internal.2dadf5b"
371
+ "@payloadcms/translations": "3.53.0",
372
+ "@payloadcms/ui": "3.53.0"
373
373
  },
374
374
  "devDependencies": {
375
375
  "@babel/cli": "7.27.2",
@@ -389,15 +389,15 @@
389
389
  "esbuild-sass-plugin": "3.3.1",
390
390
  "swc-plugin-transform-remove-imports": "4.0.4",
391
391
  "@payloadcms/eslint-config": "3.28.0",
392
- "payload": "3.53.0-internal.2dadf5b"
392
+ "payload": "3.53.0"
393
393
  },
394
394
  "peerDependencies": {
395
395
  "@faceless-ui/modal": "3.0.0-beta.2",
396
396
  "@faceless-ui/scroll-info": "2.0.0",
397
397
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
398
398
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
399
- "@payloadcms/next": "3.53.0-internal.2dadf5b",
400
- "payload": "3.53.0-internal.2dadf5b"
399
+ "@payloadcms/next": "3.53.0",
400
+ "payload": "3.53.0"
401
401
  },
402
402
  "engines": {
403
403
  "node": "^18.20.2 || >=20.9.0"
@@ -1,2 +0,0 @@
1
- "use client";import{a as R,b as S,c as E}from"./chunk-FSKAVN4P.js";import{a as N}from"./chunk-INBEEENE.js";import{a as $}from"./chunk-F26IQ5RE.js";import{b as p}from"./chunk-BZZVLW4U.js";import{jsx as e,jsxs as i}from"react/jsx-runtime";import{useLexicalComposerContext as X}from"@lexical/react/LexicalComposerContext.js";import{getTranslation as y}from"@payloadcms/translations";import{Button as h,File as Y,formatDrawerSlug as Z,useConfig as ee,useEditDepth as te,usePayloadAPI as oe,useTranslation as ae}from"@payloadcms/ui";import{$getNodeByKey as P}from"lexical";import{useCallback as f,useId as le,useReducer as se,useRef as re,useState as ie}from"react";var t="lexical-upload",U={depth:0},ne=n=>{let{data:{fields:L,relationTo:g,value:l},nodeKey:s}=n;if(typeof l=="object")throw new Error("Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.");let{config:{routes:{api:F},serverURL:T},getEntityConfig:j}=ee(),B=re(null),{uuid:I}=p(),k=te(),[o]=X(),{editorConfig:A,fieldProps:{readOnly:u,schemaPath:K}}=p(),{i18n:b,t:d}=ae(),[_,M]=se(r=>r+1,0),[a]=ie(()=>j({collectionSlug:g})),O=le(),w=Z({slug:"lexical-upload-drawer-"+I+O,depth:k}),{toggleDrawer:W}=N(w,!0),{closeDocumentDrawer:D,DocumentDrawer:z,DocumentDrawerToggler:H}=$({id:l,collectionSlug:a.slug}),[{data:c},{setParams:x}]=oe(`${T}${F}/${a.slug}/${l}`,{initialParams:U}),C=c?.thumbnailURL||c?.url,q=f(()=>{o.update(()=>{P(s)?.remove()})},[o,s]),G=f(r=>{x({...U,cacheBust:_}),M(),D()},[x,_,D]),v=A?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[a.slug]?.hasExtraFields,J=f((r,Q)=>{o.update(()=>{let m=P(s);if(m){let V={...m.getData(),fields:Q};m.setData(V)}})},[o,s]);return i("div",{className:t,contentEditable:!1,ref:B,children:[i("div",{className:`${t}__card`,children:[i("div",{className:`${t}__topRow`,children:[e("div",{className:`${t}__thumbnail`,children:C?e("img",{alt:c?.filename,"data-lexical-upload-id":l,"data-lexical-upload-relation-to":g,src:C}):e(Y,{})}),i("div",{className:`${t}__topRowRightPanel`,children:[e("div",{className:`${t}__collectionLabel`,children:y(a.labels.singular,b)}),o.isEditable()&&i("div",{className:`${t}__actions`,children:[v?e(h,{buttonStyle:"icon-label",className:`${t}__upload-drawer-toggler`,disabled:u,el:"button",icon:"edit",onClick:()=>{W()},round:!0,tooltip:d("fields:editRelationship")}):null,e(h,{buttonStyle:"icon-label",className:`${t}__swap-drawer-toggler`,disabled:u,el:"button",icon:"swap",onClick:()=>{o.dispatchCommand(E,{replace:{nodeKey:s}})},round:!0,tooltip:d("fields:swapUpload")}),e(h,{buttonStyle:"icon-label",className:`${t}__removeButton`,disabled:u,icon:"x",onClick:r=>{r.preventDefault(),q()},round:!0,tooltip:d("fields:removeUpload")})]})]})]}),e("div",{className:`${t}__bottomRow`,children:e(H,{className:`${t}__doc-drawer-toggler`,children:e("strong",{children:c?.filename})})})]}),l?e(z,{onSave:G}):null,v?e(R,{data:L,drawerSlug:w,drawerTitle:d("general:editLabel",{label:y(a.labels.singular,b)}),featureKey:"upload",handleDrawerSubmit:J,schemaPath:K,schemaPathSuffix:a.slug}):null]})},Ce=n=>e(S,{...n,uploads:!0,children:e(ne,{...n})});export{Ce as UploadComponent};
2
- //# sourceMappingURL=component-NNKG7K3O.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/features/upload/client/component/index.tsx"],
4
- "sourcesContent": ["'use client'\nimport type { ClientCollectionConfig, Data, FormState, JsonObject } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n File,\n formatDrawerSlug,\n useConfig,\n useEditDepth,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useId, useReducer, useRef, useState } from 'react'\n\nimport type { BaseClientFeatureProps } from '../../../typesClient.js'\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\nimport type { UploadNode } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { EnabledRelationshipsCondition } from '../../../relationship/client/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.',\n )\n }\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n const [editor] = useLexicalComposerContext()\n\n const {\n editorConfig,\n fieldProps: { readOnly, schemaPath },\n } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection] = useState<ClientCollectionConfig>(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const componentID = useId()\n\n const extraFieldsDrawerSlug = formatDrawerSlug({\n slug: `lexical-upload-drawer-` + uuid + componentID, // There can be multiple upload components, each with their own drawer, in one single editor => separate them by componentID\n depth: editDepth,\n })\n\n // Need to use hook to initialize useEffect that restores cursor position\n const { toggleDrawer } = useLexicalDrawer(extraFieldsDrawerSlug, true)\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (data: Data) => {\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 closeDocumentDrawer()\n },\n [setParams, cacheBust, closeDocumentDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.sanitizedClientFeatureProps as BaseClientFeatureProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n const onExtraFieldsDrawerSubmit = useCallback(\n (_: FormState, data: JsonObject) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: null | UploadNode = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n },\n [editor, nodeKey],\n )\n\n return (\n <div className={baseClass} contentEditable={false} ref={uploadRef}>\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? (\n <img\n alt={data?.filename}\n data-lexical-upload-id={value}\n data-lexical-upload-relation-to={relationTo}\n src={thumbnailSRC}\n />\n ) : (\n <File />\n )}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swap-drawer-toggler`}\n disabled={readOnly}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value ? <DocumentDrawer onSave={updateUpload} /> : null}\n {hasExtraFields ? (\n <FieldsDrawer\n data={fields}\n drawerSlug={extraFieldsDrawerSlug}\n drawerTitle={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n featureKey=\"upload\"\n handleDrawerSubmit={onExtraFieldsDrawerSubmit}\n schemaPath={schemaPath}\n schemaPathSuffix={relatedCollection.slug}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],
5
- "mappings": "6OAGA,OAASA,6BAAAA,MAAiC,2CAC1C,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,QAAAA,EACAC,oBAAAA,EACAC,aAAAA,GACAC,gBAAAA,GACAC,i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,EAAkBO,OAEpC,IAAA,GAGV,EAEagE,GAAmBvG,GAE5ByE,EAAC+B,EAAA,CAA+B,GAAGxG,EAAOyG,QAAO,YAC/ChC,EAAC1E,GAAA,CAAW,GAAGC",
6
- "names": ["useLexicalComposerContext", "getTranslation", "Button", "File", "formatDrawerSlug", "useConfig", "useEditDepth", "usePayloadAPI", "useTranslation", "$getNodeByKey", "useCallback", "useId", "useReducer", "useRef", "useState", "baseClass", "initialParams", "depth", "Component", "props", "data", "fields", "relationTo", "value", "nodeKey", "Error", "config", "routes", "api", "serverURL", "getEntityConfig", "useConfig", "uploadRef", "useRef", "uuid", "useEditorConfigContext", "editDepth", "useEditDepth", "editor", "useLexicalComposerContext", "editorConfig", "fieldProps", "readOnly", "schemaPath", "i18n", "t", "useTranslation", "cacheBust", "dispatchCacheBust", "useReducer", "state", "relatedCollection", "useState", "collectionSlug", "componentID", "useId", "extraFieldsDrawerSlug", "formatDrawerSlug", "slug", "toggleDrawer", "useLexicalDrawer", "closeDocumentDrawer", "DocumentDrawer", "DocumentDrawerToggler", "useLexicalDocumentDrawer", "id", "setParams", "usePayloadAPI", "thumbnailSRC", "thumbnailURL", "url", "removeUpload", "useCallback", "update", "$getNodeByKey", "remove", "updateUpload", "hasExtraFields", "resolvedFeatureMap", "get", "sanitizedClientFeatureProps", "collections", "onExtraFieldsDrawerSubmit", "_", "uploadNode", "newData", "getData", "setData", "_jsxs", "className", "contentEditable", "ref", "_jsx", "alt", "filename", "src", "File", "getTranslation", "labels", "singular", "isEditable", "Button", "buttonStyle", "disabled", "el", "icon", "onClick", "round", "tooltip", "dispatchCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "replace", "e", "preventDefault", "onSave", "FieldsDrawer", "drawerSlug", "drawerTitle", "label", "featureKey", "handleDrawerSubmit", "schemaPathSuffix", "UploadComponent", "EnabledRelationshipsCondition", "uploads"]
7
- }