@payloadcms/richtext-lexical 4.0.0-beta.2 → 4.0.0-beta.3

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 (37) hide show
  1. package/dist/exports/client/chunk-UH7ALTP6.js +2 -0
  2. package/dist/exports/client/chunk-UH7ALTP6.js.map +7 -0
  3. package/dist/exports/client/chunk-VHUGOQ3X.js +2 -0
  4. package/dist/exports/client/chunk-VHUGOQ3X.js.map +7 -0
  5. package/dist/exports/client/{component-6DQLENIE.js → component-ELXHSW52.js} +2 -2
  6. package/dist/exports/client/{componentInline-HNE5G4TE.js → componentInline-N7HK3HP3.js} +2 -2
  7. package/dist/exports/client/index.js +20 -20
  8. package/dist/exports/client/index.js.map +3 -3
  9. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  10. package/dist/features/blocks/client/component/index.js +35 -14
  11. package/dist/features/blocks/client/component/index.js.map +1 -1
  12. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  13. package/dist/features/blocks/client/componentInline/index.js +3 -9
  14. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  15. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  16. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  17. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  18. package/dist/features/indent/server/i18n.js.map +1 -1
  19. package/dist/features/lists/shared/schema.d.ts.map +1 -1
  20. package/dist/features/lists/shared/schema.js.map +1 -1
  21. package/dist/features/textState/defaultColors.js +1 -1
  22. package/dist/features/textState/defaultColors.js.map +1 -1
  23. package/dist/field/bundled.css +1 -1
  24. package/dist/types/index.d.ts.map +1 -1
  25. package/dist/types/index.js.map +1 -1
  26. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  27. package/dist/utilities/buildEditorState.js.map +1 -1
  28. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  29. package/dist/utilities/fieldsDrawer/DrawerContent.js +2 -7
  30. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  31. package/package.json +27 -27
  32. package/dist/exports/client/chunk-E6LSRRP2.js +0 -2
  33. package/dist/exports/client/chunk-E6LSRRP2.js.map +0 -7
  34. package/dist/exports/client/chunk-ZQX5HXUL.js +0 -2
  35. package/dist/exports/client/chunk-ZQX5HXUL.js.map +0 -7
  36. /package/dist/exports/client/{component-6DQLENIE.js.map → component-ELXHSW52.js.map} +0 -0
  37. /package/dist/exports/client/{componentInline-HNE5G4TE.js.map → componentInline-N7HK3HP3.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ import{a as P,b as T}from"./chunk-5VIL27GI.js";import{b as I}from"./chunk-RJ5MAOKZ.js";import{c as z}from"react/compiler-runtime";import{jsx as R}from"react/jsx-runtime";import{Drawer as tt,EditDepthProvider as et,useModal as rt}from"@payloadcms/ui";import"react";import{jsx as F,jsxs as W}from"react/jsx-runtime";import{useLexicalEditable as B}from"@lexical/react/useLexicalEditable";import{Form as N,RenderFields as K,useDocumentForm as G,useDocumentInfo as V,useServerFunctions as q}from"@payloadcms/ui";import{abortAndIgnore as v}from"@payloadcms/ui/shared";import{useCallback as Q,useEffect as j,useRef as X,useState as Y}from"react";import{v4 as Z}from"uuid";var M=({data:r,featureKey:t,fieldMapOverride:e,handleDrawerSubmit:o,schemaFieldsPathOverride:n,schemaPath:D,schemaPathSuffix:f,submitRef:b})=>{let{id:i,collectionSlug:s,getDocPreferences:l,globalSlug:c}=V(),{fields:u}=G(),a=B(),p=X(new AbortController),[g,d]=Y(!1),{fieldProps:{featureClientSchemaMap:x}}=I(),{getFormState:h}=q(),m=n??`${D}.lexical_internal_feature.${t}${f?`.${f}`:""}`,A=e??x[t]?.[m];j(()=>{let _=new AbortController;return(async()=>{let{state:w}=await h({id:i,collectionSlug:s,data:r??{},docPermissions:{fields:!0},docPreferences:await l(),documentFormState:u,globalSlug:c,initialBlockData:r,operation:"update",readOnly:!a,renderAllFields:!0,schemaPath:m,signal:_.signal});d(w)})(),()=>{v(_)}},[m,i,r,h,s,a,c,l,u]);let E=Q(async({formState:_})=>{v(p.current);let C=new AbortController;p.current=C;let{state:w}=await h({id:i,collectionSlug:s,docPermissions:{fields:!0},docPreferences:await l(),documentFormState:u,formState:_,globalSlug:c,initialBlockFormState:_,operation:"update",readOnly:!a,schemaPath:m,signal:C.signal});return w||_},[h,i,a,s,l,u,c,m]);return j(()=>()=>{v(p.current)},[]),g===!1?null:W(N,{beforeSubmit:[E],className:"fields-drawer",disableValidationOnSubmit:!0,fields:Array.isArray(A)?A:[],initialState:g,onChange:[E],onSubmit:o,uuid:Z(),children:[F(K,{fields:Array.isArray(A)?A:[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:m,permissions:!0,readOnly:!a}),F(T,{submitRef:b})]})};var It=r=>{let t=z(17),{className:e,data:o,drawerSlug:n,drawerTitle:D,featureKey:f,fieldMapOverride:b,handleDrawerSubmit:i,schemaFieldsPathOverride:s,schemaPath:l,schemaPathSuffix:c}=r,{closeModal:u}=rt(),{headerActions:a,submitRef:p}=P(),g=D??"",d;t[0]!==u||t[1]!==n||t[2]!==i?(d=(h,m)=>{u(n),setTimeout(()=>{i(h,m)},1)},t[0]=u,t[1]=n,t[2]=i,t[3]=d):d=t[3];let x;return t[4]!==e||t[5]!==o||t[6]!==n||t[7]!==f||t[8]!==b||t[9]!==a||t[10]!==s||t[11]!==l||t[12]!==c||t[13]!==p||t[14]!==g||t[15]!==d?(x=R(et,{children:R(tt,{className:e,headerActions:a,slug:n,title:g,children:R(M,{data:o,featureKey:f,fieldMapOverride:b,handleDrawerSubmit:d,schemaFieldsPathOverride:s,schemaPath:l,schemaPathSuffix:c,submitRef:p})})}),t[4]=e,t[5]=o,t[6]=n,t[7]=f,t[8]=b,t[9]=a,t[10]=s,t[11]=l,t[12]=c,t[13]=p,t[14]=g,t[15]=d,t[16]=x):x=t[16],x};import{createCommand as ot}from"lexical";var Ft=ot("INSERT_UPLOAD_WITH_DRAWER_COMMAND");import{jsx as J}from"react/jsx-runtime";import ut from"bson-objectid";import{$applyNodeReplacement as dt}from"lexical";import*as H from"react";import nt from"bson-objectid";function O(r,t){if(r.hasAttribute("data-lexical-pending-upload-form-id")){let o=r.getAttribute("data-lexical-pending-upload-form-id");if(o!=null)return{node:t({data:{pending:{formID:o,src:r.getAttribute("src")||""}}})}}if(r.hasAttribute("data-lexical-upload-relation-to")&&r.hasAttribute("data-lexical-upload-id")){let o=r.getAttribute("data-lexical-upload-id"),n=r.getAttribute("data-lexical-upload-relation-to");if(o!=null&&n!=null)return{node:t({data:{fields:{},relationTo:n,value:o}})}}return{node:t({data:{pending:{formID:new nt.default().toHexString(),src:r.getAttribute("src")||""}}})}}import{DecoratorBlockNode as at}from"@lexical/react/LexicalDecoratorBlockNode.js";import{addClassNamesToElement as it}from"@lexical/utils";import st from"bson-objectid";import{$applyNodeReplacement as lt}from"lexical";var S=class extends at{__data;constructor({data:t,format:e,key:o}){super(e,o),this.__data=t}static clone(t){return new this({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"upload"}static importDOM(){return{img:t=>({conversion:e=>O(e,U),priority:0})}}static importJSON(t){let e={id:t.id,fields:t.fields,pending:t.pending,relationTo:t.relationTo,value:t.value},o=U({data:e});return o.setFormat(t.format),o}static isInline(){return!1}createDOM(t){let e=document.createElement("div");return it(e,t?.theme?.upload),e}decorate(){return null}exportDOM(){let t=document.createElement("img"),e=this.__data;return e.pending?(t.setAttribute("data-lexical-pending-upload-form-id",String(e?.pending?.formID)),t.setAttribute("src",e?.pending?.src||"")):(t.setAttribute("data-lexical-upload-id",String(e?.value)),t.setAttribute("data-lexical-upload-relation-to",e?.relationTo)),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload"}}getData(){return this.getLatest().__data}setData(t){let e=this.getWritable();e.__data=t}updateDOM(){return!1}};function U({data:r}){return r?.id||(r.id=new st.default().toHexString()),lt(new S({data:r}))}import{jsx as $}from"react/jsx-runtime";import{ShimmerEffect as ct}from"@payloadcms/ui";var k=()=>$("div",{className:"lexical-upload",children:$(ct,{height:"95px",width:"203px"})});var mt=H.lazy(()=>import("./component-ELXHSW52.js").then(r=>({default:r.UploadComponent}))),y=class extends S{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importDOM(){return{img:t=>({conversion:e=>O(e,L),priority:0})}}static importJSON(t){let e={id:t.id,fields:t.fields,pending:t.pending,relationTo:t.relationTo,value:t.value},o=L({data:e});return o.setFormat(t.format),o}decorate(t,e){return this.__data.pending?J(k,{}):J(mt,{className:e?.theme?.upload??"LexicalEditorTheme__upload",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function L({data:r}){return r?.id||(r.id=new ut.default().toHexString()),dt(new y({data:r}))}function Zt(r){return r instanceof y}export{It as a,Ft as b,y as c,L as d,Zt as e};
2
+ //# sourceMappingURL=chunk-UH7ALTP6.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utilities/fieldsDrawer/Drawer.tsx", "../../../src/utilities/fieldsDrawer/DrawerContent.tsx", "../../../src/features/upload/client/drawer/commands.ts", "../../../src/features/upload/client/nodes/UploadNode.tsx", "../../../src/features/upload/server/nodes/conversions.ts", "../../../src/features/upload/server/nodes/UploadNode.tsx", "../../../src/features/upload/client/component/pending/index.tsx"],
4
+ "sourcesContent": ["'use client'\nimport type { ClientField, Data, FormState, JsonObject } from 'payload'\n\nimport { Drawer, EditDepthProvider, useModal } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { DrawerContent } from './DrawerContent.js'\nimport { useDrawerSubmit } from './useDrawerSubmit.js'\n\nexport type FieldsDrawerProps = {\n readonly className?: string\n readonly data?: Data\n readonly drawerSlug: string\n readonly drawerTitle?: string\n readonly featureKey: string\n readonly fieldMapOverride?: ClientField[]\n readonly handleDrawerSubmit: (fields: FormState, data: JsonObject) => void\n readonly schemaFieldsPathOverride?: string\n readonly schemaPath: string\n readonly 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 fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { closeModal } = useModal()\n const { headerActions, submitRef } = useDrawerSubmit()\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 <EditDepthProvider>\n <Drawer\n className={className}\n headerActions={headerActions}\n slug={drawerSlug}\n title={drawerTitle ?? ''}\n >\n <DrawerContent\n data={data}\n featureKey={featureKey}\n fieldMapOverride={fieldMapOverride}\n handleDrawerSubmit={(args, args2) => {\n // Simply close drawer - no need for useLexicalDrawer here as at this point,\n // we don't need to restore the cursor position. This is handled by the useEffect in useLexicalDrawer.\n closeModal(drawerSlug)\n\n // Actual drawer submit logic needs to be triggered after the drawer is closed.\n // That's because the lexical selection / cursor restore logic that is striggerer by\n // `useLexicalDrawer` neeeds to be triggered before any editor.update calls that may happen\n // in the `handleDrawerSubmit` function.\n setTimeout(() => {\n handleDrawerSubmit(args, args2)\n }, 1)\n }}\n schemaFieldsPathOverride={schemaFieldsPathOverride}\n schemaPath={schemaPath}\n schemaPathSuffix={schemaPathSuffix}\n submitRef={submitRef}\n />\n </Drawer>\n </EditDepthProvider>\n )\n}\n", "'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useRef, 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'\nimport { RegisterFormSubmit } from './useDrawerSubmit.js'\nimport './index.css'\n\nexport const DrawerContent: React.FC<\n {\n submitRef: React.RefObject<(() => void) | null>\n } & Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>\n> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n submitRef,\n}) => {\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: parentDocumentFields,\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: parentDocumentFields,\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n className=\"fields-drawer\"\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <RegisterFormSubmit submitRef={submitRef} />\n </Form>\n )\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", "'use client'\nimport type { DOMConversionMap, EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nimport type { Internal_UploadData, SerializedUploadNode, UploadData } from '../../server/schema.js'\n\nimport { $convertUploadElement } from '../../server/nodes/conversions.js'\nimport { UploadServerNode } from '../../server/nodes/UploadNode.js'\nimport { PendingUploadComponent } from '../component/pending/index.js'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../../client/component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport class UploadNode extends UploadServerNode {\n static override clone(node: UploadServerNode): UploadServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadNode {\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\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 override decorate(editor?: LexicalEditor, config?: EditorConfig): JSX.Element {\n if ((this.__data as Internal_UploadData).pending) {\n return <PendingUploadComponent />\n }\n return (\n <RawUploadComponent\n className={config?.theme?.upload ?? 'LexicalEditorTheme__upload'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedUploadNode {\n return super.exportJSON()\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\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", "// This file contains functions used to convert dom elements to upload or pending upload lexical nodes. It requires the actual node\n// creation functions to be passed in to stay compatible with both client and server code.\nimport type { DOMConversionOutput } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\n\nimport type { $createUploadNode } from '../../client/nodes/UploadNode.js'\nimport type { Internal_UploadData } from '../schema.js'\nimport type { $createUploadServerNode } from './UploadNode.js'\n\nexport function 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\nexport function $convertUploadElement(\n domNode: HTMLImageElement,\n $createNode: typeof $createUploadNode | typeof $createUploadServerNode,\n): DOMConversionOutput | null {\n if (domNode.hasAttribute('data-lexical-pending-upload-form-id')) {\n const formID = domNode.getAttribute('data-lexical-pending-upload-form-id')\n\n if (formID != null) {\n const node = $createNode({\n data: {\n pending: {\n formID,\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n return { node }\n }\n }\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 = $createNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n\n // Create pending UploadNode. Auto-Upload functionality will then be handled by the node transform\n const node = $createNode({\n data: {\n pending: {\n formID: new ObjectID.default().toHexString(),\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n\n return { node }\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\n\nimport type { Internal_UploadData, SerializedUploadNode, UploadData } from '../schema.js'\n\nimport { $convertUploadElement } from './conversions.js'\n\nexport class UploadServerNode 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 override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('div')\n addClassNamesToElement(element, config?.theme?.upload)\n return element\n }\n\n override decorate(): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n const data = this.__data as Internal_UploadData\n if (data.pending) {\n element.setAttribute('data-lexical-pending-upload-form-id', String(data?.pending?.formID))\n element.setAttribute('src', data?.pending?.src || '')\n } else {\n element.setAttribute('data-lexical-upload-id', String(data?.value))\n element.setAttribute('data-lexical-upload-relation-to', data?.relationTo)\n }\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\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 override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n", "'use client'\n\nimport { ShimmerEffect } from '@payloadcms/ui'\n\nexport const PendingUploadComponent = (): React.ReactNode => {\n return (\n <div className={'lexical-upload'}>\n <ShimmerEffect height={'95px'} width={'203px'} />\n </div>\n )\n}\n"],
5
+ "mappings": "uFAAA,OAAAA,KAAAC,MAAA,iEAGA,OAASC,UAAAA,GAAQC,qBAAAA,GAAmBC,YAAAA,OAAgB,iBACpD,MAAkB,0DCDlB,OAASC,sBAAAA,MAA0B,oCACnC,OACEC,QAAAA,EACAC,gBAAAA,EACAC,mBAAAA,EACAC,mBAAAA,EACAC,sBAAAA,MACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OAAgBC,eAAAA,EAAaC,aAAAA,EAAWC,UAAAA,EAAQC,YAAAA,MAAgB,QAChE,OAASC,MAAMC,MAAY,OAMpB,IAAAC,EAAA,CAAA,CAEP,KAAAC,EAKEA,WAAAA,EACAC,iBAAAA,EACAC,mBAAAA,EACAC,yBAAAA,EACAC,WAAAA,EACAC,iBAAAA,EACAC,UAAAA,KACAC,CACD,GAAA,CACC,GAAAC,EAAQA,eAAAA,EAAIC,kBAAAA,EAAgBC,WAAAA,GAAmBC,EAAAA,EAAeC,CAC9D,OAAMC,GAAEC,EAAQD,EAAyBE,EAAAC,EAAA,EACnCC,EAAaD,EAAA,IAAA,eAAA,EAEbE,CAAAA,EAAAA,CAA6BC,EAAAA,EAAWC,EAAAA,EAExC,CAEN,WAAM,CACJC,uBAAAA,IAAoCC,EAAA,EAClCA,CAEJ,aAAAC,GAAQA,EAAAA,EAAiBC,EAAApB,GAAA,GAAAC,CAAA,6BAAAJ,CAAA,GAAAK,EAAA,IAAAA,CAAA,GAAA,EAAA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AU,CACZ,EACF,CACF,CAEA,OAAgBC,WAAWC,EAAkD,CAC3E,IAAMC,EAAoC,CACxCC,GAAIF,EAAeE,GACnBC,OAAQH,EAAeG,OACvBC,QAASJ,EAAwCI,QACjDC,WAAYL,EAAeK,WAC3BC,MAAON,EAAeM,KACxB,EAEMhB,EAAOO,EAAkB,CAAEU,KAAMN,CAAa,CAAA,EACpDX,OAAAA,EAAKkB,UAAUR,EAAeS,MAAM,EAE7BnB,CACT,CAESoB,SAASC,EAAwBC,EAAoC,CAC5E,OAAI,KAAMC,OAA+BT,QAChCU,EAACC,EAAA,CAAA,CAAA,EAGRD,EAACjC,GAAA,CACCmC,UAAWJ,GAAQK,OAAOC,QAAU,6BACpCX,KAAM,KAAKM,OACXJ,OAAQ,KAAKU,SACbC,QAAS,KAAKC,OAAM,GAG1B,CAESC,YAAmC,CAC1C,OAAO,MAAMA,WAAA,CACf,CACF,EAEO,SAASzB,EAAkB,CAChCU,KAAAA,CAAI,EAGL,CACC,OAAKA,GAAML,KACTK,EAAKL,GAAK,IAAIqB,GAAStC,QAAO,EAAGuC,YAAW,GAGvCC,GAAsB,IAAItC,EAAW,CAAEoB,KAAMA,CAAmB,CAAA,CAAA,CACzE,CAEO,SAASmB,GAAcpC,EAAoC,CAChE,OAAOA,aAAgBH,CACzB",
6
+ "names": ["c", "_c", "Drawer", "EditDepthProvider", "useModal", "useLexicalEditable", "Form", "RenderFields", "useDocumentForm", "useDocumentInfo", "useServerFunctions", "abortAndIgnore", "useCallback", "useEffect", "useRef", "useState", "v4", "uuid", "DrawerContent", "data", "featureKey", "fieldMapOverride", "handleDrawerSubmit", "schemaFieldsPathOverride", "schemaPath", "schemaPathSuffix", "submitRef", "id", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "parentDocumentFields", "fields", "useDocumentForm", "useLexicalEditable", "isEditable", "onChangeAbortControllerRef", "useRef", "AbortController", "fieldProps", "useEditorConfigContext", "getFormState", "useServerFunctions", "schemaFieldsPath", "useEffect", "awaitInitialState", "state", "docPermissions", "docPreferences", "documentFormState", "initialBlockData", "operation", "readOnly", "renderAllFields", "setInitialState", "abortAndIgnore", "controller", "onChange", "formState", "state_0", "prevFormState", "initialBlockFormState", "initialState", "_jsxs", "Form", "beforeSubmit", "className", "disableValidationOnSubmit", "isArray", "onSubmit", "uuid", "_jsx", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "permissions", "FieldsDrawer", "t0", "$", "_c", "className", "data", "drawerSlug", "drawerTitle", "featureKey", "fieldMapOverride", "handleDrawerSubmit", "schemaFieldsPathOverride", "schemaPath", "schemaPathSuffix", "closeModal", "useModal", "headerActions", "submitRef", "useDrawerSubmit", "t1", "t2", "args", "args2", "setTimeout", "t3", "_jsx", "EditDepthProvider", "children", "Drawer", "slug", "title", "DrawerContent", "createCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "ObjectID", "$applyNodeReplacement", "React", "ObjectID", "$convertUploadElement", "domNode", "$createNode", "hasAttribute", "formID", "getAttribute", "node", "data", "pending", "src", "id", "relationTo", "fields", "value", "ObjectID", "default", "toHexString", "DecoratorBlockNode", "addClassNamesToElement", "ObjectID", "$applyNodeReplacement", "UploadServerNode", "DecoratorBlockNode", "__data", "constructor", "data", "format", "key", "clone", "node", "__format", "__key", "getType", "importDOM", "img", "conversion", "domNode", "$convertUploadElement", "$createUploadServerNode", "priority", "importJSON", "serializedNode", "importedData", "id", "fields", "pending", "relationTo", "value", "setFormat", "isInline", "createDOM", "config", "element", "document", "createElement", "addClassNamesToElement", "theme", "upload", "decorate", "exportDOM", "setAttribute", "String", "formID", "src", "exportJSON", "getData", "type", "getLatest", "setData", "writable", "getWritable", "updateDOM", "ObjectID", "default", "toHexString", "$applyNodeReplacement", "ShimmerEffect", "PendingUploadComponent", "_jsx", "className", "height", "width", "RawUploadComponent", "lazy", "then", "module", "default", "UploadComponent", "UploadNode", "UploadServerNode", "clone", "node", "getType", "importDOM", "img", "conversion", "domNode", "$convertUploadElement", "$createUploadNode", "priority", "importJSON", "serializedNode", "importedData", "id", "fields", "pending", "relationTo", "value", "data", "setFormat", "format", "decorate", "editor", "config", "__data", "_jsx", "PendingUploadComponent", "className", "theme", "upload", "__format", "nodeKey", "getKey", "exportJSON", "ObjectID", "toHexString", "$applyNodeReplacement", "$isUploadNode"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a as fe,b as pe,c as be}from"./chunk-5VIL27GI.js";import{b as me}from"./chunk-RJ5MAOKZ.js";import{jsx as c,jsxs as D}from"react/jsx-runtime";import{useLexicalComposerContext as Qe}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Ye}from"@lexical/react/useLexicalEditable";import{getTranslation as Be}from"@payloadcms/translations";import{Button as Ce,Drawer as Ze,EditDepthProvider as et,Form as tt,formatDrawerSlug as ot,RenderFields as nt,ShimmerEffect as rt,useConfig as st,useDocumentForm as it,useDocumentInfo as lt,useEditDepth as ct,useServerFunctions as at,useTranslation as ut}from"@payloadcms/ui";import{abortAndIgnore as H}from"@payloadcms/ui/shared";import{$getNodeByKey as X,SKIP_DOM_SELECTION_TAG as ge}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as dt}from"payload/shared";import w,{createContext as mt,useCallback as q,useEffect as j,useMemo as g,useRef as y}from"react";import{v4 as ft}from"uuid";import{dequal as Ee}from"dequal/lite";import{reduceFieldsToValues as je}from"payload/shared";var ke=({cachedFormState:n,cachedSchemaPath:t,currentSchemaPath:e,formData:o})=>{if(t!==e)return!1;let r=_(n),s=A({data:o,rowFieldPaths:Le(n)});return Ee(he(r),he(s))?n:!1},_=(n,t)=>{let e=Object.fromEntries(Object.entries(n).map(([o,r])=>!r||!Array.isArray(r.rows)?[o,r]:r.value===void 0||r.disableFormData!==!1&&r.isModified!==!0&&r.rows.length===0&&ve(t,o)===null?[o,{...r,value:null}]:[o,r.value===null?r:{...r,disableFormData:!0}]));return A({data:je(e,!0),rowFieldPaths:new Set})},ve=(n,t)=>t.split(".").reduce((e,o)=>{if(!(!e||typeof e!="object"))return e[o]},n),Le=n=>new Set(Object.entries(n).filter(([,t])=>Array.isArray(t?.rows)&&t.value!==null&&t.value!==void 0).map(([t])=>t)),A=({data:n,parentPath:t="",rowFieldPaths:e})=>{let o={};for(let[r,s]of Object.entries(n)){let a=t?`${t}.${r}`:r,p=Re({parentPath:a,rowFieldPaths:e,value:s});p!==void 0&&(o[r]=p)}return o},Re=({parentPath:n,rowFieldPaths:t,value:e})=>{if(!(e===void 0||Array.isArray(e)&&e.length===0&&t.has(n)))return Array.isArray(e)?e.map((o,r)=>o&&typeof o=="object"&&!Array.isArray(o)?A({data:o,parentPath:`${n}.${r}`,rowFieldPaths:t}):o):e&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype?A({data:e,parentPath:n,rowFieldPaths:t}):e},he=({blockName:n,blockType:t,...e})=>e;import{jsx as We}from"react/jsx-runtime";import He from"bson-objectid";import{$applyNodeReplacement as Xe}from"lexical";import qe from"react";import{addClassNamesToElement as Me}from"@lexical/utils";import Ke from"bson-objectid";import{$applyNodeReplacement as Je,DecoratorNode as ze}from"lexical";var S=class extends ze{__cacheBuster;__fields;constructor({cacheBuster:t,fields:e,key:o}){super(o),this.__fields=e,this.__cacheBuster=t||0}static clone(t){return new this({cacheBuster:t.__cacheBuster,fields:t.__fields,key:t.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(t){return Ve(t.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(t){let e=document.createElement("span");return Me(e,t?.theme?.inlineBlock),e}decorate(t,e){return null}exportDOM(){let t=document.createElement("span");t.classList.add("inline-block-container");let e=document.createTextNode(this.getTextContent());return t.append(e),{element:t}}exportJSON(){return{...super.exportJSON(),type:"inlineBlock",fields:this.getFields()}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(t,e){let o=this.getWritable();o.__fields=t,e||o.__cacheBuster++}updateDOM(){return!1}};function Ve(n){return Je(new S({fields:{...n,id:n?.id||new Ke.default().toHexString()}}))}var Ge=qe.lazy(()=>import("./componentInline-N7HK3HP3.js").then(n=>({default:n.InlineBlockComponent}))),E=class extends S{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importJSON(t){return Ue(t.fields)}decorate(...[t,e,o,r]){return We(Ge,{cacheBuster:this.getCacheBuster(),className:e.theme.inlineBlock??"LexicalEditorTheme__inlineBlock",CustomBlock:o,CustomLabel:r,formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ue(n){return Xe(new E({fields:{...n,id:n?.id||new He.default().toHexString()}}))}function W(n){return n instanceof E}var xe=mt({initialState:!1}),ye=()=>w.use(xe),Vt=n=>{let{cacheBuster:t,className:e,CustomBlock:o,CustomLabel:r,formData:s,nodeKey:a}=n,[p]=Qe(),u=Ye(),{i18n:v,t:B}=ut(),{createdInlineBlock:G,fieldProps:{featureClientSchemaMap:_e,initialLexicalFormState:Se,schemaPath:U},setCreatedInlineBlock:Q,uuid:De}=me(),{fields:F}=it(),{getFormState:N}=at(),we=ct(),Y=y(!1),I=s.blockType,L=y(s);L.current=s;let C=`${U}.lexical_internal_feature.blocks.lexical_inline_blocks.${I}.fields`,[f,R]=w.useState(()=>{let i=Se?.[s.id],d=i?.formState;return d?ke({cachedFormState:d,cachedSchemaPath:i.schemaPath,currentSchemaPath:C,formData:s}):!1}),Z=y(!1),ee=y(t);j(()=>{Z.current?(ee.current!==t&&R(!1),ee.current=t):Z.current=!0},[t]);let[Fe]=w.useState(()=>ft()),[te,oe]=w.useState(()=>{if(!r)return f?._components?.customComponents?.BlockLabel??void 0}),[ne,re]=w.useState(()=>{if(!o)return f?._components?.customComponents?.Block??void 0}),se=g(()=>o?c(o,{className:e,formData:s,isEditor:!0,isJSXConverter:!1,nodeKey:a,useInlineBlockComponentContext:ye}):ne,[o,e,s,a,ne]),M=g(()=>r?c(r,{className:e,formData:s,isEditor:!0,isJSXConverter:!1,nodeKey:a,useInlineBlockComponentContext:ye}):te,[r,e,s,a,te]),ie=ot({slug:`lexical-inlineBlocks-create-${De}-${s.id}`,depth:we}),{toggleDrawer:b}=be(ie,!0),Ne=y(null),{id:O,collectionSlug:T,getDocPreferences:$,globalSlug:P}=lt(),{config:Ie}=st(),Oe=`${U}.lexical_internal_feature.blocks.lexical_inline_blocks.${I}`,K=_e.blocks?.[Oe]?.[0]?.blocks?.[0],m=typeof K=="string"?Ie.blocksMap[K]:K,le=m?.fields??[];j(()=>{!Y.current&&G?.getKey()===a&&(le.length>2&&b(),Q?.(void 0),Y.current=!0)},[le.length,G,a,Q,b]);let ce=q(()=>{p.update(()=>{X(a)?.remove()})},[p,a]),x=m?.labels?.singular?Be(m?.labels.singular,v):m?.slug,J=y(new AbortController);j(()=>{let i=new AbortController;return m&&s&&!f&&(async()=>{let{state:l}=await N({id:O,collectionSlug:T,data:s,docPermissions:{fields:!0},docPreferences:await $(),documentFormState:F,globalSlug:P,initialBlockData:s,operation:"update",readOnly:!u,renderAllFields:!0,schemaPath:C,signal:i.signal});if(l){let h=_(dt(l,{excludeFiles:!0}));p.update(()=>{let k=X(a);if(k&&W(k)){let de=h;de.blockType=s.blockType,k.setFields(de,!0)}},{tag:ge}),R(l),r||oe(l._components?.customComponents?.BlockLabel),o||re(l._components?.customComponents?.Block)}})(),()=>{H(i)}},[N,p,a,u,r,o,C,O,s,f,T,P,$,F,m]);let ae=q(async({formState:i,submit:d})=>{H(J.current);let l=new AbortController;J.current=l;let h=_(i,L.current),{state:k}=await N({id:O,collectionSlug:T,data:h,docPermissions:{fields:!0},docPreferences:await $(),documentFormState:F,formState:i,globalSlug:P,initialBlockData:h,operation:"update",readOnly:!u,renderAllFields:!!d,schemaPath:C,signal:l.signal});return k?(d&&(r||oe(k._components?.customComponents?.BlockLabel),o||re(k._components?.customComponents?.Block)),k):i},[N,O,T,$,F,P,u,C,o,r]);j(()=>{let i=(d,l)=>Object.keys(l).some(h=>l[h]&&d[h]!==l[h].value);return()=>{f&&i(s,f)&&R(!1),H(J.current)}},[s,f]);let Te=q(i=>{let d=_(i,L.current);d.blockType=I,p.update(()=>{let l=X(a);l&&W(l)&&l.setFields(d,!0)},{tag:ge})},[I,p,a]),{headerActions:$e,submitRef:Pe}=fe(),z=g(()=>()=>c(Ce,{buttonStyle:"ghost",className:`${e}__removeButton`,disabled:!u,icon:"x",onClick:i=>{i.preventDefault(),i.stopPropagation(),ce()},round:!0,size:"medium",tooltip:B("lexical:blocks:inlineBlocks:remove",{label:x})}),[e,x,u,ce,B]),Ae=g(()=>()=>c(Ce,{buttonStyle:"ghost",className:`${e}__editButton`,disabled:!u,el:"button",icon:"edit",onClick:()=>{b()},round:!0,size:"medium",tooltip:B("lexical:blocks:inlineBlocks:edit",{label:x})}),[e,x,u,B,b]),V=g(()=>({children:i,className:d})=>c("div",{className:[`${e}__container`,e+"-"+s.blockType,d].filter(Boolean).join(" "),...u?{onClick:()=>b(),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),b())},role:"button",tabIndex:0}:{},ref:Ne,children:i}),[e,s.blockType,u,b]),ue=g(()=>M?()=>M:()=>c("div",{children:m?.labels?Be(m?.labels.singular,v):""}),[M,m?.labels,v]);return m?D(tt,{beforeSubmit:[async({formState:i})=>await ae({formState:i,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:m?.fields,initialState:f||{},onChange:[ae],onSubmit:i=>{Te(i),b()},uuid:Fe,children:[c(et,{children:c(Ze,{className:"",headerActions:$e,slug:ie,title:B(`lexical:blocks:inlineBlocks:${s?.id?"edit":"create"}`,{label:x??B("lexical:blocks:inlineBlocks:label")}),children:f?D("div",{className:"fields-drawer",children:[c(nt,{fields:m?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:C,permissions:!0,readOnly:!u}),c(pe,{submitRef:Pe})]}):null})}),se?c(xe,{value:{EditButton:Ae,initialState:f,InlineBlockContainer:V,Label:ue,nodeKey:a,RemoveButton:z},children:se}):D(V,{children:[f?c(ue,{}):c(rt,{height:"15px",width:"40px"}),u?c("div",{className:`${e}__actions`,children:c(z,{})}):null]})]}):D(V,{className:`${e}-not-found`,children:[D("span",{children:["Error: Block '",s.blockType,"' not found"]}),u?c("div",{className:`${e}__actions`,children:c(z,{})}):null]})};export{ke as a,_ as b,ye as c,Vt as d,E as e,Ue as f,W as g};
2
+ //# sourceMappingURL=chunk-VHUGOQ3X.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/getCachedFormStateIfDataMatches.ts", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
4
+ "sourcesContent": ["'use client'\n\nimport type { BlocksFieldClient, ClientBlock, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, SKIP_DOM_SELECTION_TAG } from 'lexical'\n\nimport './index.css'\nimport '../../../../utilities/fieldsDrawer/index.css'\n\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'\nimport type { InlineBlockFields } from '../../server/schema.js'\nimport type { BlockComponentProps } from '../component/index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport {\n RegisterFormSubmit,\n useDrawerSubmit,\n} from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport {\n getCachedFormStateIfDataMatches,\n reduceFormStateToBlockData,\n} from '../getCachedFormStateIfDataMatches.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\nexport type InlineBlockComponentProps<\n TFormData extends Record<string, unknown> = InlineBlockFields,\n> = {\n readonly CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>\n readonly CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>\n} & Pick<BlockComponentProps<TFormData>, 'cacheBuster' | 'className' | 'formData' | 'nodeKey'>\n\nexport type InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<InlineBlockComponentProps<InlineBlockFields>> = (\n props,\n) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n const blockType = formData.blockType\n const formDataRef = useRef(formData)\n formDataRef.current = formData\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedState = initialLexicalFormState?.[formData.id]\n const cachedFormState = cachedState?.formState\n if (!cachedFormState) {\n return false\n }\n\n return getCachedFormStateIfDataMatches({\n cachedFormState,\n cachedSchemaPath: cachedState.schemaPath,\n currentSchemaPath: schemaFieldsPath,\n formData,\n })\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist, we render them directly with formData instead.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient | undefined\n\n const blockOrSlug = blocksField?.blocks?.[0]\n const clientBlock: ClientBlock | undefined =\n typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: parentDocumentFields,\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData = reduceFormStateToBlockData(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n }\n\n if (clientBlock && formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n CustomLabelFromProps,\n CustomBlockFromProps,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n clientBlock,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n const blockData = reduceFormStateToBlockData(prevFormState, formDataRef.current)\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: blockData,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: parentDocumentFields,\n formState: prevFormState,\n globalSlug,\n initialBlockData: blockData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n isEditable,\n schemaFieldsPath,\n CustomBlockFromProps,\n CustomLabelFromProps,\n ],\n )\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState) => {\n const newData = reduceFormStateToBlockData(formState, formDataRef.current)\n newData.blockType = blockType\n\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n },\n [blockType, editor, nodeKey],\n )\n\n const { headerActions, submitRef } = useDrawerSubmit()\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n removeInlineBlock()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n {...(isEditable\n ? {\n onClick: () => toggleDrawer(),\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n toggleDrawer()\n }\n },\n role: 'button',\n tabIndex: 0,\n }\n : {})}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, formData.blockType, isEditable, toggleDrawer],\n )\n\n const Label = useMemo(() => {\n if (resolvedCustomLabel) {\n return () => resolvedCustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [resolvedCustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\n toggleDrawer()\n }}\n uuid={formUuid}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n headerActions={headerActions}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <div className=\"fields-drawer\">\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <RegisterFormSubmit submitRef={submitRef} />\n </div>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {resolvedCustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {resolvedCustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "import type { Data, FormState } from 'payload'\n\nimport { dequal } from 'dequal/lite'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nexport const getCachedFormStateIfDataMatches = ({\n cachedFormState,\n cachedSchemaPath,\n currentSchemaPath,\n formData,\n}: {\n cachedFormState: FormState\n cachedSchemaPath?: string\n currentSchemaPath?: string\n formData: Data\n}): false | FormState => {\n if (cachedSchemaPath !== currentSchemaPath) {\n return false\n }\n\n const cachedData = reduceFormStateToBlockData(cachedFormState)\n const currentData = normalizeData({\n data: formData,\n rowFieldPaths: getRowFieldPaths(cachedFormState),\n })\n\n return dequal(withoutSystemBlockFields(cachedData), withoutSystemBlockFields(currentData))\n ? cachedFormState\n : false\n}\n\nexport const reduceFormStateToBlockData = (formState: FormState, currentData?: Data): Data => {\n const formStateWithoutRowCounts = Object.fromEntries(\n Object.entries(formState).map(([path, fieldState]) => {\n if (!fieldState || !Array.isArray(fieldState.rows)) {\n return [path, fieldState]\n }\n\n if (\n fieldState.value === undefined ||\n (fieldState.disableFormData !== false &&\n fieldState.isModified !== true &&\n fieldState.rows.length === 0 &&\n getValueAtPath(currentData, path) === null)\n ) {\n return [path, { ...fieldState, value: null }]\n }\n\n return [\n path,\n fieldState.value === null ? fieldState : { ...fieldState, disableFormData: true },\n ]\n }),\n ) as FormState\n\n return normalizeData({\n data: reduceFieldsToValues(formStateWithoutRowCounts, true),\n rowFieldPaths: new Set(),\n })\n}\n\nconst getValueAtPath = (data: Data | undefined, path: string): unknown =>\n path.split('.').reduce<unknown>((value, pathSegment) => {\n if (!value || typeof value !== 'object') {\n return undefined\n }\n\n return (value as Record<string, unknown>)[pathSegment]\n }, data)\n\nconst getRowFieldPaths = (formState: FormState): Set<string> =>\n new Set(\n Object.entries(formState)\n .filter(\n ([, fieldState]) =>\n Array.isArray(fieldState?.rows) &&\n fieldState.value !== null &&\n fieldState.value !== undefined,\n )\n .map(([path]) => path),\n )\n\nconst normalizeData = ({\n data,\n parentPath = '',\n rowFieldPaths,\n}: {\n data: Data\n parentPath?: string\n rowFieldPaths: Set<string>\n}): Data => {\n const normalizedData: Data = {}\n\n for (const [key, value] of Object.entries(data)) {\n const path = parentPath ? `${parentPath}.${key}` : key\n const normalizedValue = normalizeValue({ parentPath: path, rowFieldPaths, value })\n\n if (normalizedValue !== undefined) {\n normalizedData[key] = normalizedValue\n }\n }\n\n return normalizedData\n}\n\nconst normalizeValue = ({\n parentPath,\n rowFieldPaths,\n value,\n}: {\n parentPath: string\n rowFieldPaths: Set<string>\n value: unknown\n}): unknown => {\n if (\n value === undefined ||\n (Array.isArray(value) && value.length === 0 && rowFieldPaths.has(parentPath))\n ) {\n return undefined\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) =>\n item && typeof item === 'object' && !Array.isArray(item)\n ? normalizeData({\n data: item as Data,\n parentPath: `${parentPath}.${index}`,\n rowFieldPaths,\n })\n : item,\n )\n }\n\n if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n return normalizeData({ data: value as Data, parentPath, rowFieldPaths })\n }\n\n return value\n}\n\nconst withoutSystemBlockFields = ({\n blockName: _blockName,\n blockType: _blockType,\n ...data\n}: Data): Data => data\n", "'use client'\nimport ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'\nimport type { InlineBlockFields, SerializedInlineBlockNode } from '../../server/schema.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type InlineBlockDecorateFunction = (\n editor: LexicalEditor,\n config: EditorConfig,\n CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>,\n CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>,\n) => JSX.Element\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n override decorate(\n ...[_editor, config, CustomBlock, CustomLabel]: Parameters<InlineBlockDecorateFunction>\n ): ReturnType<InlineBlockDecorateFunction> {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\n className={config.theme.inlineBlock ?? 'LexicalEditorTheme__inlineBlock'}\n CustomBlock={CustomBlock}\n CustomLabel={CustomLabel}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return $applyNodeReplacement(\n new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\n\nimport type { InlineBlockFields, SerializedInlineBlockNode } from '../schema.js'\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, config?.theme?.inlineBlock)\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n ...super.exportJSON(),\n type: 'inlineBlock',\n fields: this.getFields(),\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return $applyNodeReplacement(\n new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
5
+ "mappings": "oJAIA,OAASA,6BAAAA,OAAiC,wCAC1C,OAASC,sBAAAA,OAA0B,oCACnC,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,m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AAAA,EAAAA,GAAAA,8BAI0C4G,EAAO7B,EAAA,MAAA,CAAO8B,UAAM,GAAAxJ,CAAA,qBAC9D0H,EACCA,EAAC,CAAA,CAAA,IAAIxH,IAAAA,OA5EX6C,EAAqBsB,EAAqB,CAE1C,UAACA,GAAarE,CAAA,aAChB,SAAA,CACG6H,EAAAA,OAAAA,CAAqB3H,SAAW,CAAA,iBAAGG,EAAqB,UAAA,aAAA,MACtDqH,EAAA,MAAA,WAAK,GAAA1H,CAAA,qBACL0H,EACCA,EAAC,CAAA,CAAA,IAAIxH,IAAAA",
6
+ "names": ["useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "RenderFields", "ShimmerEffect", "useConfig", "useDocumentForm", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "SKIP_DOM_SELECTION_TAG", "deepCopyObjectSimpleWithoutReactComponents", "React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "dequal", "reduceFieldsToValues", "getCachedFormStateIfDataMatches", "cachedFormState", "cachedSchemaPath", "currentSchemaPath", "formData", "cachedData", "reduceFormStateToBlockData", "currentData", "normalizeData", "data", "rowFieldPaths", "getRowFieldPaths", "withoutSystemBlockFields", "formState", "formStateWithoutRowCounts", "Object", "fromEntries", "entries", "map", "path", "fieldState", "Array", "isArray", "rows", "value", "undefined", "disableFormData", "isModified", "length", "getValueAtPath", "Set", "split", "reduce", "pathSegment", "filter", "parentPath", "normalizedData", "key", "normalizedValue", "normalizeValue", "has", "item", "index", "getPrototypeOf", "prototype", "blockName", "_blockName", "blockType", "_blockType", "ObjectID", "$applyNodeReplacement", "React", "addClassNamesToElement", "ObjectID", "$applyNodeReplacement", "DecoratorNode", "ServerInlineBlockNode", "__cacheBuster", "__fields", "constructor", "cacheBuster", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "config", "element", "document", "createElement", "theme", "inlineBlock", "decorate", "editor", "exportDOM", "classList", "add", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "getCacheBuster", "getLatest", "setFields", "preventFormStateUpdate", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "_editor", "config", "CustomBlock", "CustomLabel", "_jsx", "cacheBuster", "getCacheBuster", "className", "theme", "inlineBlock", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "$applyNodeReplacement", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "InlineBlockComponentContext", "reduceFormStateToBlockData", "$isInlineBlockNode", "initialState", "React", "InlineBlockComponent", "props", "cacheBuster", "baseClass", "CustomBlockFromProps", "className", "CustomBlock", "CustomLabel", "formData", "nodeKey", "useLexicalEditable", "i18n", "t", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "uuidFromContext", "setCreatedInlineBlock", "useEditorConfigContext", "useDocumentForm", "fields", "getFormState", "useServerFunctions", "useRef", "editDepth", "useEditDepth", "firstTimeDrawer", "formDataRef", "blockType", "setInitialState", "useState", "cachedFormState", "cachedState", "getCachedFormStateIfDataMatches", "schemaFieldsPath", "cachedSchemaPath", "hasMounted", "prevCacheBuster", "useEffect", "current", "formUuid", "uuid", "setCustomLabel", "CustomLabelFromProps", "customComponents", "BlockLabel", "resolvedCustomBlock", "useMemo", "isEditor", "useInlineBlockComponentContext", "resolvedCustomLabel", "drawerSlug", "depth", "toggleDrawer", "useLexicalDrawer", "id", "collectionSlug", "getDocPreferences", "globalSlug", "config", "useConfig", "clientSchemaMap", "componentMapRenderedBlockPath", "blocksField", "blockOrSlug", "clientBlockFields", "removeInlineBlock", "useCallback", "editor", "length", "$getNodeByKey", "blockDisplayName", "clientBlock", "getTranslation", "onChangeAbortControllerRef", "abortController", "state", "data", "docPermissions", "parentDocumentFields", "docPreferences", "documentFormState", "initialBlockData", "operation", "readOnly", "isEditable", "renderAllFields", "signal", "newFormStateData", "deepCopyObjectSimpleWithoutReactComponents", "node", "newData", "SKIP_DOM_SELECTION_TAG", "setCustomBlock", "awaitInitialState", "abortAndIgnore", "submit", "formState", "controller", "prevFormState", "blockData", "state_0", "isStateOutOfSync", "formData_0", "initialState_0", "key", "Object", "newData_0", "onFormSubmit", "node_0", "tag", "headerActions", "submitRef", "useDrawerSubmit", "RemoveButton", "buttonStyle", "disabled", "e", "icon", "onClick", "round", "size", "tooltip", "label", "EditButton", "_jsx", "Button", "el", "InlineBlockContainer", "e_0", "onKeyDown", "role", "tabIndex", "children", "ref", "inlineBlockElemElemRef", "formState_0", "beforeSubmit", "onChange", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "slug", "title", "_jsxs", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "RegisterFormSubmit", "value", "Label", "height", "width"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use client";import{a as E,b as U,e as P}from"./chunk-ZQX5HXUL.js";import{c as y}from"./chunk-5VIL27GI.js";import{a as L}from"./chunk-WSAPGI3Z.js";import{b as f}from"./chunk-RJ5MAOKZ.js";import{jsx as o,jsxs as g}from"react/jsx-runtime";import{useLexicalComposerContext as ae}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as le}from"@lexical/react/useLexicalEditable";import{getTranslation as T}from"@payloadcms/translations";import{Button as h,formatDrawerSlug as se,Pill as ie,Thumbnail as re,useConfig as ne,useEditDepth as de,usePayloadAPI as ce,useTranslation as ue}from"@payloadcms/ui";import{$getNodeByKey as F,$getSelection as me,$isNodeSelection as pe,$isRangeSelection as fe}from"lexical";import{formatAdminURL as ge,isImage as he}from"payload/shared";import{useCallback as _,useEffect as I,useId as _e,useReducer as we,useRef as be,useState as j}from"react";var k={depth:0},Ie=z=>{let{className:e,data:{fields:A,relationTo:w,value:c},format:B,nodeKey:l}=z;if(typeof c=="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:K},serverURL:M},getEntityConfig:O}=ne(),b=be(null),{uuid:W}=f(),H=de(),[s]=ae(),{editorConfig:q,fieldProps:{schemaPath:G}}=f(),u=le(),{i18n:D,t:n}=ue(),[S,m]=j(!1),[$,J]=we(a=>a+1,0),[i]=j(()=>O({collectionSlug:w})),Q=_e(),x=se({slug:"lexical-upload-drawer-"+W+Q,depth:H}),{toggleDrawer:V}=y(x,!0),{closeDocumentDrawer:C,DocumentDrawer:X,DocumentDrawerToggler:Y}=L({id:c,collectionSlug:i.slug}),[{data:t},{setParams:N}]=ce(ge({apiRoute:K,path:`/${i.slug}/${c}`,serverURL:M}),{initialParams:k}),v=t?.thumbnailURL||t?.url;I(()=>s.registerUpdateListener(({editorState:a})=>{a.read(()=>{let r=me();if(pe(r))m(r.has(l));else if(fe(r)){let d=r.getNodes();m(d.some(p=>p.getKey()===l))}else m(!1)})}),[s,l]),I(()=>{let a=b.current?.closest(`.${e}`);a&&a.classList.toggle(`${e}--selected`,S)},[S,e]);let Z=_(()=>{s.update(()=>{F(l)?.remove()})},[s,l]),ee=_(a=>{N({...k,cacheBust:$}),J(),C()},[N,$,C]),R=q?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[i.slug]?.hasExtraFields,te=_((a,r)=>{s.update(()=>{let d=F(l);if(P(d)){let p={...d.getData(),fields:r};d.setData(p)}})},[s,l]),oe=v&&t?.width&&t?.height?t.width>t.height?"landscape":"portrait":"landscape";return g("div",{className:`${e}__contents ${e}__contents--${oe}`,"data-align":B||void 0,"data-filename":t?.filename,ref:b,children:[o("div",{className:`${e}__card`,children:g("div",{className:`${e}__media`,children:[o(re,{collectionSlug:w,fileSrc:he(t?.mimeType)?v:null,height:t?.height,size:"none",width:t?.width}),u&&g("div",{className:`${e}__floater`,"data-theme":"dark",children:[o(ie,{className:`${e}__collectionLabel`,pillStyle:"dark",size:"small",children:T(i.labels.singular,D)}),o(Y,{className:`${e}__doc-drawer-toggler`,children:o("span",{className:`${e}__filename`,children:t?.filename||n("general:untitled")})}),R?o(h,{buttonStyle:"ghost",className:`${e}__upload-drawer-toggler`,disabled:!u,el:"button",icon:"write",onClick:V,round:!0,size:"medium",tooltip:n("fields:editRelationship")}):null,o("div",{className:`${e}__divider`}),o(h,{buttonStyle:"ghost",className:`${e}__swap-drawer-toggler`,disabled:!u,el:"button",icon:"swap",onClick:()=>{s.dispatchCommand(U,{replace:{nodeKey:l}})},round:!0,size:"medium",tooltip:n("fields:swapUpload")}),o(h,{buttonStyle:"ghost",className:`${e}__removeButton`,disabled:!u,icon:"x",onClick:a=>{a.preventDefault(),Z()},round:!0,size:"medium",tooltip:n("fields:removeUpload")})]})]})}),c?o(X,{onSave:ee}):null,R?o(E,{data:A,drawerSlug:x,drawerTitle:n("general:editLabel",{label:T(i.labels.singular,D)}),featureKey:"upload",handleDrawerSubmit:te,schemaPath:G,schemaPathSuffix:i.slug}):null]})};export{Ie as UploadComponent};
2
- //# sourceMappingURL=component-6DQLENIE.js.map
1
+ "use client";import{a as E,b as U,e as P}from"./chunk-UH7ALTP6.js";import{c as y}from"./chunk-5VIL27GI.js";import{a as L}from"./chunk-WSAPGI3Z.js";import{b as f}from"./chunk-RJ5MAOKZ.js";import{jsx as o,jsxs as g}from"react/jsx-runtime";import{useLexicalComposerContext as ae}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as le}from"@lexical/react/useLexicalEditable";import{getTranslation as T}from"@payloadcms/translations";import{Button as h,formatDrawerSlug as se,Pill as ie,Thumbnail as re,useConfig as ne,useEditDepth as de,usePayloadAPI as ce,useTranslation as ue}from"@payloadcms/ui";import{$getNodeByKey as F,$getSelection as me,$isNodeSelection as pe,$isRangeSelection as fe}from"lexical";import{formatAdminURL as ge,isImage as he}from"payload/shared";import{useCallback as _,useEffect as I,useId as _e,useReducer as we,useRef as be,useState as j}from"react";var k={depth:0},Ie=z=>{let{className:e,data:{fields:A,relationTo:w,value:c},format:B,nodeKey:l}=z;if(typeof c=="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:K},serverURL:M},getEntityConfig:O}=ne(),b=be(null),{uuid:W}=f(),H=de(),[s]=ae(),{editorConfig:q,fieldProps:{schemaPath:G}}=f(),u=le(),{i18n:D,t:n}=ue(),[S,m]=j(!1),[$,J]=we(a=>a+1,0),[i]=j(()=>O({collectionSlug:w})),Q=_e(),x=se({slug:"lexical-upload-drawer-"+W+Q,depth:H}),{toggleDrawer:V}=y(x,!0),{closeDocumentDrawer:C,DocumentDrawer:X,DocumentDrawerToggler:Y}=L({id:c,collectionSlug:i.slug}),[{data:t},{setParams:N}]=ce(ge({apiRoute:K,path:`/${i.slug}/${c}`,serverURL:M}),{initialParams:k}),v=t?.thumbnailURL||t?.url;I(()=>s.registerUpdateListener(({editorState:a})=>{a.read(()=>{let r=me();if(pe(r))m(r.has(l));else if(fe(r)){let d=r.getNodes();m(d.some(p=>p.getKey()===l))}else m(!1)})}),[s,l]),I(()=>{let a=b.current?.closest(`.${e}`);a&&a.classList.toggle(`${e}--selected`,S)},[S,e]);let Z=_(()=>{s.update(()=>{F(l)?.remove()})},[s,l]),ee=_(a=>{N({...k,cacheBust:$}),J(),C()},[N,$,C]),R=q?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[i.slug]?.hasExtraFields,te=_((a,r)=>{s.update(()=>{let d=F(l);if(P(d)){let p={...d.getData(),fields:r};d.setData(p)}})},[s,l]),oe=v&&t?.width&&t?.height?t.width>t.height?"landscape":"portrait":"landscape";return g("div",{className:`${e}__contents ${e}__contents--${oe}`,"data-align":B||void 0,"data-filename":t?.filename,ref:b,children:[o("div",{className:`${e}__card`,children:g("div",{className:`${e}__media`,children:[o(re,{collectionSlug:w,fileSrc:he(t?.mimeType)?v:null,height:t?.height,size:"none",width:t?.width}),u&&g("div",{className:`${e}__floater`,"data-theme":"dark",children:[o(ie,{className:`${e}__collectionLabel`,pillStyle:"dark",size:"small",children:T(i.labels.singular,D)}),o(Y,{className:`${e}__doc-drawer-toggler`,children:o("span",{className:`${e}__filename`,children:t?.filename||n("general:untitled")})}),R?o(h,{buttonStyle:"ghost",className:`${e}__upload-drawer-toggler`,disabled:!u,el:"button",icon:"write",onClick:V,round:!0,size:"medium",tooltip:n("fields:editRelationship")}):null,o("div",{className:`${e}__divider`}),o(h,{buttonStyle:"ghost",className:`${e}__swap-drawer-toggler`,disabled:!u,el:"button",icon:"swap",onClick:()=>{s.dispatchCommand(U,{replace:{nodeKey:l}})},round:!0,size:"medium",tooltip:n("fields:swapUpload")}),o(h,{buttonStyle:"ghost",className:`${e}__removeButton`,disabled:!u,icon:"x",onClick:a=>{a.preventDefault(),Z()},round:!0,size:"medium",tooltip:n("fields:removeUpload")})]})]})}),c?o(X,{onSave:ee}):null,R?o(E,{data:A,drawerSlug:x,drawerTitle:n("general:editLabel",{label:T(i.labels.singular,D)}),featureKey:"upload",handleDrawerSubmit:te,schemaPath:G,schemaPathSuffix:i.slug}):null]})};export{Ie as UploadComponent};
2
+ //# sourceMappingURL=component-ELXHSW52.js.map
@@ -1,2 +1,2 @@
1
- "use client";import{c as a,d as b}from"./chunk-E6LSRRP2.js";import"./chunk-5VIL27GI.js";import"./chunk-RJ5MAOKZ.js";export{b as InlineBlockComponent,a as useInlineBlockComponentContext};
2
- //# sourceMappingURL=componentInline-HNE5G4TE.js.map
1
+ "use client";import{c as a,d as b}from"./chunk-VHUGOQ3X.js";import"./chunk-5VIL27GI.js";import"./chunk-RJ5MAOKZ.js";export{b as InlineBlockComponent,a as useInlineBlockComponentContext};
2
+ //# sourceMappingURL=componentInline-N7HK3HP3.js.map