@payloadcms/richtext-lexical 3.26.0-canary.bbb3083 → 3.27.0-canary.ecc3f49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cell/rscEntry.js +1 -1
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-EE27FURT.js → chunk-QBDC3MVG.js} +2 -2
- package/dist/exports/client/{chunk-EE27FURT.js.map → chunk-QBDC3MVG.js.map} +2 -2
- package/dist/exports/client/componentInline-IBB73SHH.js +2 -0
- package/dist/exports/client/index.js +2 -2
- package/dist/exports/client/index.js.map +2 -2
- package/dist/exports/react/components/RichText/converter/converters/upload.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/upload.js +15 -15
- package/dist/exports/react/components/RichText/converter/converters/upload.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +1 -0
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +1 -0
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/converters/htmlToLexical/index.d.ts +13 -0
- package/dist/features/converters/htmlToLexical/index.d.ts.map +1 -0
- package/dist/features/converters/htmlToLexical/index.js +31 -0
- package/dist/features/converters/htmlToLexical/index.js.map +1 -0
- package/dist/features/upload/server/nodes/UploadNode.d.ts +17 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -35
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +28 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/editorConfigFactory.d.ts +57 -0
- package/dist/utilities/editorConfigFactory.d.ts.map +1 -0
- package/dist/utilities/editorConfigFactory.js +89 -0
- package/dist/utilities/editorConfigFactory.js.map +1 -0
- package/package.json +6 -6
- package/dist/exports/client/componentInline-XEH2GDVO.js +0 -2
- /package/dist/exports/client/{componentInline-XEH2GDVO.js.map → componentInline-IBB73SHH.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ie}from"./chunk-INBEEENE.js";import{b as se}from"./chunk-3LGFOM34.js";import{jsx as o,jsxs as p,Fragment as Ie}from"react/jsx-runtime";import T,{createContext as
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as ie}from"./chunk-INBEEENE.js";import{b as se}from"./chunk-3LGFOM34.js";import{jsx as o,jsxs as p,Fragment as Ie}from"react/jsx-runtime";import T,{createContext as ve,useCallback as j,useEffect as v,useMemo as N,useRef as x}from"react";import{useLexicalComposerContext as Ne}from"@lexical/react/LexicalComposerContext";import{getTranslation as ce}from"@payloadcms/translations";import{Button as ae,Drawer as Te,EditDepthProvider as $e,Form as Pe,formatDrawerSlug as Oe,FormSubmit as Re,RenderFields as Ee,ShimmerEffect as Le,useConfig as Me,useDocumentForm as je,useDocumentInfo as Ae,useEditDepth as Je,useServerFunctions as Ke,useTranslation as ze}from"@payloadcms/ui";import{abortAndIgnore as A}from"@payloadcms/ui/shared";import{$getNodeByKey as J}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as K,reduceFieldsToValues as He}from"payload/shared";import{v4 as Ve}from"uuid";import{jsx as Se}from"react/jsx-runtime";import ye from"bson-objectid";import Fe from"react";import xe from"bson-objectid";import{DecoratorNode as _e}from"lexical";var B=class extends _e{__cacheBuster;__fields;constructor({cacheBuster:e,fields:t,key:r}){super(r),this.__fields=t,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return Ce(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(){let e=document.createElement("span");return e.classList.add("inline-block-container"),e}decorate(e,t){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let t=document.createTextNode(this.getTextContent());return e.append(t),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e,t){let r=this.getWritable();r.__fields=e,t||r.__cacheBuster++}updateDOM(){return!1}};function Ce(l){return new B({fields:{...l,id:l?.id||new xe.default().toHexString()}})}var De=Fe.lazy(()=>import("./componentInline-IBB73SHH.js").then(l=>({default:l.InlineBlockComponent}))),I=class extends B{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return we(e.fields)}decorate(e,t){return Se(De,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function we(l){return new I({fields:{...l,id:l?.id||new ye.default().toHexString()}})}function M(l){return l instanceof I}var m="inline-block",ue=ve({initialState:!1}),ft=()=>T.useContext(ue),pt=l=>{let{cacheBuster:e,formData:t,nodeKey:r}=l,[a]=Ne(),{i18n:$,t:d}=ze(),{createdInlineBlock:z,fieldProps:{featureClientSchemaMap:de,initialLexicalFormState:me,permissions:fe,readOnly:_,schemaPath:H},setCreatedInlineBlock:V,uuid:pe}=se(),{fields:C}=je(),{getFormState:S}=Ke(),be=Je(),W=x(!1),[u,q]=T.useState(()=>me?.[t.id]?.formState),G=x(!1),Q=x(e);v(()=>{G.current?(Q.current!==e&&q(!1),Q.current=e):G.current=!0},[e]);let[P,U]=T.useState(u?._components?.customComponents?.BlockLabel),[X,Y]=T.useState(u?._components?.customComponents?.Block),Z=Oe({slug:`lexical-inlineBlocks-create-${pe}-${t.id}`,depth:be}),{toggleDrawer:b}=ie(Z,!0),ke=x(null),{id:y,collectionSlug:F,getDocPreferences:D,globalSlug:w}=Ae(),{config:he}=Me(),ge=`${H}.lexical_internal_feature.blocks.lexical_inline_blocks.${t.blockType}`,k=de.blocks?.[ge]?.[0],i=k.blockReferences?typeof k?.blockReferences?.[0]=="string"?he.blocksMap[k?.blockReferences?.[0]]:k?.blockReferences?.[0]:k?.blocks?.[0],ee=i?.fields??[];v(()=>{!W.current&&z?.getKey()===r&&(ee.length>2&&b(),V?.(void 0),W.current=!0)},[ee.length,z,r,V,b]);let te=j(()=>{a.update(()=>{J(r)?.remove()})},[a,r]),h=i?.labels?.singular?ce(i?.labels.singular,$):i?.slug,O=x(new AbortController),g=`${H}.lexical_internal_feature.blocks.lexical_inline_blocks.${i?.slug}.fields`;v(()=>{let n=new AbortController;return t&&!u&&(async()=>{let{state:s}=await S({id:y,collectionSlug:F,data:t,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:K(C),globalSlug:w,initialBlockData:t,initialBlockFormState:t,operation:"update",renderAllFields:!0,schemaPath:g,signal:n.signal});if(s){let f=He(K(s),!0);a.update(()=>{let L=J(r);if(L&&M(L)){let le=f;le.blockType=t.blockType,L.setFields(le,!0)}}),q(s),U(s._components?.customComponents?.BlockLabel),Y(s._components?.customComponents?.Block)}})(),()=>{A(n)}},[S,a,r,g,y,t,u,F,w,D,C]);let ne=j(async({formState:n,submit:c})=>{A(O.current);let s=new AbortController;O.current=s;let{state:f}=await S({id:y,collectionSlug:F,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:K(C),formState:n,globalSlug:w,initialBlockFormState:n,operation:"update",renderAllFields:!!c,schemaPath:g,signal:s.signal});return f?(c&&(U(f._components?.customComponents?.BlockLabel),Y(f._components?.customComponents?.Block)),f):n},[S,y,F,D,C,w,g]);v(()=>()=>{A(O.current)},[]);let Be=j((n,c)=>{c.blockType=t.blockType,a.update(()=>{let s=J(r);s&&M(s)&&s.setFields(c,!0)})},[a,r,t]),R=N(()=>()=>o(ae,{buttonStyle:"icon-label",className:`${m}__removeButton`,disabled:_,icon:"x",onClick:n=>{n.preventDefault(),te()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:remove",{label:h})}),[h,_,te,d]),oe=N(()=>()=>o(ae,{buttonStyle:"icon-label",className:`${m}__editButton`,disabled:_,el:"button",icon:"edit",onClick:()=>{b()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:edit",{label:h})}),[h,_,d,b]),E=N(()=>({children:n,className:c})=>o("div",{className:[m,m+"-"+t.blockType,c].filter(Boolean).join(" "),ref:ke,children:n}),[t.blockType]),re=N(()=>P?()=>P:()=>o("div",{children:i?.labels?ce(i?.labels.singular,$):""}),[P,i?.labels,$]);return i?p(Pe,{beforeSubmit:[async({formState:n})=>await ne({formState:n,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:i?.fields,initialState:u||{},onChange:[ne],onSubmit:(n,c)=>{Be(n,c),b()},uuid:Ve(),children:[o($e,{children:o(Te,{className:"",slug:Z,title:d(`lexical:blocks:inlineBlocks:${t?.id?"edit":"create"}`,{label:h??d("lexical:blocks:inlineBlocks:label")}),children:u?p(Ie,{children:[o(Ee,{fields:i?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:g,permissions:fe,readOnly:!1}),o(Re,{programmaticSubmit:!0,children:d("fields:saveChanges")})]}):null})}),X?o(ue.Provider,{value:{EditButton:oe,initialState:u,InlineBlockContainer:E,Label:re,nodeKey:r,RemoveButton:R},children:X}):p(E,{children:[u?o(re,{}):o(Le,{height:"15px",width:"40px"}),a.isEditable()?p("div",{className:`${m}__actions`,children:[o(oe,{}),o(R,{})]}):null]})]}):p(E,{className:`${m}-not-found`,children:[p("span",{children:["Error: Block '",t.blockType,"' not found"]}),a.isEditable()?o("div",{className:`${m}__actions`,children:o(R,{})}):null]})};export{ft as a,pt as b,I as c,we as d,M as e};
|
|
2
|
+
//# sourceMappingURL=chunk-QBDC3MVG.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\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 } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype 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.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\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\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n () => initialLexicalFormState?.[formData.id]?.formState,\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 [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\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.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\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 const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\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: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n 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 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\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\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\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\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 setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[baseClass, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, 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 {editor.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 fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\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 <>\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={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport type { EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.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 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(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\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 new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\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 SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields<TBlockFields>\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\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 override createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\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 type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\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 new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\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": "mJAEA,OAAOA,GAASC,iBAAAA,GAAeC,eAAAA,E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JC,EAACC,GAAA,CACCC,YAAY,aACZC,UAAW,GAAGrH,CAAA,eACdsH,SAAUhG,EACV0G,GAAG,SACHT,KAAK,OACLC,QAASA,IAAA,CACPhE,EAAA,CACF,EACAmE,MAAK,GACLC,KAAK,QACLC,QAAS9G,EAAE,mCAAoC,CAAE+G,MAAO7C,CAAiB,CAAA,IAG7E,CAACA,EAAkB3D,EAAUP,EAAGyC,CAAA,CAAa,EAGzCyE,EAAuBhB,EAC3B,IACE,CAAC,CAAEiB,SAAAA,EAAUb,UAAAA,CAAS,IACpBH,EAAC,MAAA,CACCG,UAAW,CAACrH,EAAWA,EAAY,IAAMU,EAASwD,UAAWmD,CAAA,EAC1Dc,OAAOC,OAAA,EACPC,KAAK,GAAA,EACRC,IAAK5E,YAEJwE,IAGP,CAACxH,EAASwD,SAAS,CAAC,EAGhBqE,GAAQtB,EAAQ,IAChBpE,EACK,IAAMA,EAEN,IACLqE,EAAC,MAAA,UAAK9C,GAAac,OAASE,GAAehB,GAAac,OAAOC,SAAUrE,CAAA,EAAQ,KAGpF,CAAC+B,EAAauB,GAAac,OAAQpE,CAAA,CAAK,EAE3C,OAAKsD,EAcHoE,EAACC,GAAA,CACCC,aAAc,CACZ,MAAO,CAAElG,UAAAA,CAAS,IAET,MAAMmE,GAAS,CAAEnE,UAAAA,EAAWqE,OAAQ,EAAK,CAAA,CAClD,EAEF8B,0BAAyB,
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\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 } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype 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.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\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\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n () => initialLexicalFormState?.[formData.id]?.formState,\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 [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\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.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\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 const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\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: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n 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 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\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\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\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\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 setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[baseClass, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, 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 {editor.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, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\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 <>\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={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport type { EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.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 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(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\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 new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\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 SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields<TBlockFields>\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\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 override createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\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 type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\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 new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\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": "mJAEA,OAAOA,GAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,MAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,mBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OAASC,iBAAAA,MAAqB,UAI9B,OAASC,8CAAAA,EAA4CC,wBAAAA,OAA4B,iBACjF,OAASC,MAAMC,OAAY,gDC5B3B,OAAO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CAAA,EAAWrB,EAACwC,GAAA,CAAcC,OAAO,OAAOC,MAAM,SAC9DhJ,EAAOiJ,WAAU,EAChBrB,EAAC,MAAA,CAAInB,UAAW,GAAGrH,CAAA,sBACjBkH,EAACa,GAAA,CAAA,CAAA,EACDb,EAACF,EAAA,CAAA,CAAA,CAAA,IAED,IAAA,OA3ERwB,EAACP,EAAA,CAAqBZ,UAAW,GAAGrH,CAAA,uBAClCwI,EAAC,OAAA,WAAK,iBAAe9H,EAASwD,UAAU,aAAA,IACvCtD,EAAOiJ,WAAU,EAChB3C,EAAC,MAAA,CAAIG,UAAW,GAAGrH,CAAA,qBACjBkH,EAACF,EAAA,CAAA,CAAA,IAED,IAAA,GA0EZ",
|
|
6
6
|
"names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useConfig", "useDocumentForm", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "deepCopyObjectSimpleWithoutReactComponents", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "React", "ObjectID", "DecoratorNode", "ServerInlineBlockNode", "__cacheBuster", "__fields", "constructor", "cacheBuster", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "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", "_jsx", "cacheBuster", "getCacheBuster", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "useContext", "InlineBlockComponent", "props", "cacheBuster", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "permissions", "readOnly", "schemaPath", "setCreatedInlineBlock", "uuid", "uuidFromContext", "useEditorConfigContext", "fields", "parentDocumentFields", "useDocumentForm", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "firstTimeDrawer", "useRef", "setInitialState", "useState", "id", "formState", "hasMounted", "prevCacheBuster", "useEffect", "current", "CustomLabel", "setCustomLabel", "customComponents", "BlockLabel", "CustomBlock", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "config", "useConfig", "componentMapRenderedBlockPath", "blockType", "blocksField", "clientBlock", "blockReferences", "blocksMap", "blocks", "clientBlockFields", "getKey", "length", "undefined", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "docPreferences", "documentFormState", "deepCopyObjectSimpleWithoutReactComponents", "initialBlockData", "initialBlockFormState", "operation", "renderAllFields", "signal", "newFormStateData", "reduceFieldsToValues", "node", "$isInlineBlockNode", "newData", "setFields", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "onFormSubmit", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "onClick", "e", "preventDefault", "round", "size", "tooltip", "label", "EditButton", "el", "InlineBlockContainer", "children", "filter", "Boolean", "join", "ref", "Label", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "title", "_Fragment", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "FormSubmit", "programmaticSubmit", "Provider", "value", "ShimmerEffect", "height", "width", "isEditable"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use client";import{a as ce,c as ho,d as go,e as Co}from"./chunk-
|
|
1
|
+
"use client";import{a as ce,c as ho,d as go,e as Co}from"./chunk-QBDC3MVG.js";import{a as Xe}from"./chunk-DBWINSQN.js";import{a as ze,b as It,c as Pe}from"./chunk-PUXDVIHC.js";import{a as ae}from"./chunk-INBEEENE.js";import{a as Ds}from"./chunk-F26IQ5RE.js";import{a as Ms,b as yr,d as vr,e as Mr,f as As,g as Os,h as $s,j as Fs,l as Ps,m as Bs}from"./chunk-OZ6Q4DWN.js";import{a as vs,b as P}from"./chunk-3LGFOM34.js";function z(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{$isElementNode as Ee,$isRangeSelection as vt,FORMAT_ELEMENT_COMMAND as Mt}from"lexical";import{jsx as xo,jsxs as Hs}from"react/jsx-runtime";import"react";var Dr=()=>Hs("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[xo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),xo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),xo("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as bo,jsxs as js}from"react/jsx-runtime";import"react";var Ar=()=>js("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[bo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),bo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),bo("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as _o,jsxs as Us}from"react/jsx-runtime";import"react";var yt=()=>Us("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[_o("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),_o("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),_o("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as To,jsxs as Gs}from"react/jsx-runtime";import"react";var Or=()=>Gs("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[To("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),To("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),To("path",{d:"M7.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});var y=t=>o=>{let r={clientFeatureProps:o};if(typeof t=="function")r.feature=({config:n,featureClientImportMap:i,featureClientSchemaMap:l,featureProviderMap:a,field:c,resolvedFeatures:u,schemaPath:p,unSanitizedEditorConfig:s})=>{let d=t({config:n,featureClientImportMap:i,featureClientSchemaMap:l,featureProviderMap:a,field:c,props:o,resolvedFeatures:u,schemaPath:p,unSanitizedEditorConfig:s});return d.sanitizedClientFeatureProps===null&&(d.sanitizedClientFeatureProps=o),d};else{let n={...t};n.sanitizedClientFeatureProps=o,r.feature=n}return r};var $r=t=>({type:"dropdown",ChildComponent:yt,items:t,key:"align",order:30});var Fr=[$r([{ChildComponent:yt,isActive:({selection:t})=>{if(!vt(t))return!1;for(let e of t.getNodes()){if(Ee(e)&&e.getFormatType()==="left")continue;let o=e.getParent();if(!(Ee(o)&&o.getFormatType()==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Mt,"left")},order:1},{ChildComponent:Dr,isActive:({selection:t})=>{if(!vt(t))return!1;for(let e of t.getNodes()){if(Ee(e)&&e.getFormatType()==="center")continue;let o=e.getParent();if(!(Ee(o)&&o.getFormatType()==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Mt,"center")},order:2},{ChildComponent:Or,isActive:({selection:t})=>{if(!vt(t))return!1;for(let e of t.getNodes()){if(Ee(e)&&e.getFormatType()==="right")continue;let o=e.getParent();if(!(Ee(o)&&o.getFormatType()==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Mt,"right")},order:3},{ChildComponent:Ar,isActive:({selection:t})=>{if(!vt(t))return!1;for(let e of t.getNodes()){if(Ee(e)&&e.getFormatType()==="justify")continue;let o=e.getParent();if(!(Ee(o)&&o.getFormatType()==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Mt,"justify")},order:4}])],Ws=y({toolbarFixed:{groups:Fr},toolbarInline:{groups:Fr}});import{$createQuoteNode as Wr,$isQuoteNode as Ur,QuoteNode as Ys}from"@lexical/rich-text";import{$setBlocksType as Vr}from"@lexical/selection";import{$getSelection as Kr,$isRangeSelection as zs}from"lexical";import{jsx as Pr}from"react/jsx-runtime";import"react";var Eo=()=>Pr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Pr("path",{d:"M13.5353 10.5725C13.5353 9.47709 11.0456 9.99991 11.0456 7.85883C11.0456 6.46464 12.1162 5.61816 13.361 5.61816C14.805 5.61816 16 6.86298 16 8.92937C16 11.2945 14.4564 13.7841 11.1203 14.3816L10.8216 13.1368C12.888 12.4895 13.5353 11.4937 13.5353 10.5725ZM6.71369 10.5725C6.71369 9.47709 4.22407 9.99991 4.22407 7.85883C4.22407 6.46464 5.29461 5.61816 6.53942 5.61816C7.9834 5.61816 9.17842 6.86298 9.17842 8.92937C9.17842 11.2945 7.63485 13.7841 4.29876 14.3816L4 13.1368C6.06639 12.4895 6.71369 11.4937 6.71369 10.5725Z",fill:"currentColor"})});import{jsx as Br}from"react/jsx-runtime";import"react";var Je=()=>Br("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Br("path",{d:"M11.708 14.5H7.79785V13.9414H8.01367C9.00391 13.9414 9.15625 13.9033 9.15625 13.6113V6.70508H8.07715C6.82031 6.70508 6.73145 7.08594 6.28711 8.67285H5.80469L5.91895 6.12109H13.5869L13.7012 8.67285H13.2188C12.7744 7.08594 12.6855 6.70508 11.4287 6.70508H10.3496V13.6113C10.3496 13.9033 10.502 13.9414 11.4922 13.9414H11.708V14.5Z",fill:"currentColor"})});var J=t=>({type:"dropdown",ChildComponent:Je,items:t,key:"text",order:25});import{$createQuoteNode as Vs,$isQuoteNode as Hr,QuoteNode as Ks}from"@lexical/rich-text";import{$createLineBreakNode as Zs}from"lexical";var jr={type:"element",dependencies:[Ks],export:(t,e)=>{if(!Hr(t))return null;let o=e(t).split(`
|
|
2
2
|
`),r=[];for(let n of o)r.push("> "+n);return r.join(`
|
|
3
|
-
`)},regExp:/^>\s/,replace:(t,e,o,r)=>{if(r){let i=t.getPreviousSibling();if(Hr(i)){i.splice(i.getChildrenSize(),0,[Zs(),...e]),i.select(0,0),t.remove();return}}let n=Vs();n.append(...e),t.replace(n),n.select(0,0)}};var Gr=[J([{ChildComponent:Eo,isActive:({selection:t})=>{if(!zs(t))return!1;for(let e of t.getNodes())if(!Ur(e)&&!Ur(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Kr();Vr(e,()=>Wr())})},order:20}])],Xs=y({markdownTransformers:[jr],nodes:[Ys],slashMenu:{groups:[z([{Icon:Eo,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Kr();Vr(e,()=>Wr())})}}])]},toolbarFixed:{groups:Gr},toolbarInline:{groups:Gr}});import{getTranslation as Ht}from"@payloadcms/translations";import{jsx as wo,jsxs as Js}from"react/jsx-runtime";import"react";var Dt=()=>Js("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[wo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),wo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),wo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as Zr}from"react/jsx-runtime";import"react";var At=()=>Zr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Zr("path",{clipRule:"evenodd",d:"M5.33333 6.5C5.11232 6.5 4.90036 6.5878 4.74408 6.74408C4.5878 6.90036 4.5 7.11232 4.5 7.33333V12.1667C4.5 12.3877 4.5878 12.5996 4.74408 12.7559C4.90036 12.9122 5.11232 13 5.33333 13H14.6667C14.8877 13 15.0996 12.9122 15.2559 12.7559C15.4122 12.5996 15.5 12.3877 15.5 12.1667V11.6667C15.5 11.3905 15.7239 11.1667 16 11.1667C16.2761 11.1667 16.5 11.3905 16.5 11.6667V12.1667C16.5 12.6529 16.3068 13.1192 15.963 13.463C15.6192 13.8068 15.1529 14 14.6667 14H5.33333C4.8471 14 4.38079 13.8068 4.03697 13.463C3.69315 13.1192 3.5 12.6529 3.5 12.1667V7.33333C3.5 6.8471 3.69315 6.38079 4.03697 6.03697C4.38079 5.69315 4.8471 5.5 5.33333 5.5H10.3333C10.6095 5.5 10.8333 5.72386 10.8333 6C10.8333 6.27614 10.6095 6.5 10.3333 6.5H5.33333ZM13 6.5C12.7239 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.7239 5.5 13 5.5H16C16.2761 5.5 16.5 5.72386 16.5 6V9C16.5 9.27614 16.2761 9.5 16 9.5C15.7239 9.5 15.5 9.27614 15.5 9V7.20711L13.3536 9.35355C13.1583 9.54882 12.8417 9.54882 12.6464 9.35355C12.4512 9.15829 12.4512 8.84171 12.6464 8.64645L14.7929 6.5H13ZM6.16699 8.33325C6.16699 8.05711 6.39085 7.83325 6.66699 7.83325H11.0003C11.2765 7.83325 11.5003 8.05711 11.5003 8.33325C11.5003 8.60939 11.2765 8.83325 11.0003 8.83325H6.66699C6.39085 8.83325 6.16699 8.60939 6.16699 8.33325ZM6.16699 10.9999C6.16699 10.7238 6.39085 10.4999 6.66699 10.4999H13.3337C13.6098 10.4999 13.8337 10.7238 13.8337 10.9999C13.8337 11.2761 13.6098 11.4999 13.3337 11.4999H6.66699C6.39085 11.4999 6.16699 11.2761 6.16699 10.9999Z",fill:"currentColor",fillRule:"evenodd"})});import{jsx as qs}from"react/jsx-runtime";import"react";function Ot(t,e){return t?()=>qs("img",{alt:e??"Block Image",className:"lexical-block-custom-image",src:t,style:{maxHeight:20,maxWidth:20}}):Dt}import{jsx as Sa}from"react/jsx-runtime";import Ia from"bson-objectid";import"react";import{DecoratorBlockNode as Qs}from"@lexical/react/LexicalDecoratorBlockNode.js";import ea from"bson-objectid";var qe=class extends Qs{__cacheBuster;__fields;constructor({cacheBuster:e,fields:o,format:r,key:n}){super(r,n),this.__fields=o,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,format:e.__format,key:e.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=ta(e.fields);return o.setFormat(e.format),o}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div"),o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e,o){let r=this.getWritable();r.__fields=e,o||r.__cacheBuster++}};function ta(t){return new qe({fields:{...t,id:t?.id||new ea.default().toHexString()}})}import{jsx as W,jsxs as Qe,Fragment as aa}from"react/jsx-runtime";import{Button as Jr,Collapsible as ca,Drawer as ua,EditDepthProvider as da,ErrorPill as ma,Form as pa,formatDrawerSlug as fa,FormSubmit as ha,Pill as ga,RenderFields as Ca,SectionTitle as xa,useConfig as ba,useDocumentForm as _a,useDocumentInfo as qr,useEditDepth as Ta,useFormSubmitted as Ea,useServerFunctions as wa,useTranslation as ka}from"@payloadcms/ui";import{abortAndIgnore as ko}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as Ft,reduceFieldsToValues as Qr}from"payload/shared";import et,{useCallback as Lo,useEffect as No,useMemo as tt,useRef as Ro}from"react";import{useLexicalComposerContext as La}from"@lexical/react/LexicalComposerContext";import{getTranslation as Na}from"@payloadcms/translations";import{$getNodeByKey as Pt}from"lexical";import{v4 as Ra}from"uuid";import{c as oa}from"react/compiler-runtime";import{jsx as $t,jsxs as ra}from"react/jsx-runtime";import{RenderFields as na,useFormSubmitted as ia}from"@payloadcms/ui";import la,{createContext as sa}from"react";var Yr=sa({initialState:!1}),Ne=()=>la.useContext(Yr),zr=t=>{let e=oa(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:a,initialState:c,nodeKey:u,RemoveButton:p}=t,d=ia()&&l>0,m,f;e[0]!==r||e[1]!==l||e[2]!==d?(f=x=>$t(r,{editButton:x.editButton,errorCount:l,fieldHasErrors:d,Label:x.Label,removeButton:x.removeButton,children:x.children}),e[0]=r,e[1]=l,e[2]=d,e[3]=f):f=e[3],m=f;let h=m,g;return e[4]!==o||e[5]!==h||e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==c||e[11]!==u?(g=n?ra(Yr.Provider,{value:{BlockCollapsible:h,EditButton:i,initialState:c,nodeKey:u,RemoveButton:p},children:[n,$t(o,{})]}):$t(h,{children:$t(na,{fields:a,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=o,e[5]=h,e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=c,e[11]=u,e[12]=g):g=e[12],g};function Xr({fields:t}){for(let e in t){let o=t[e];Array.isArray(o?.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var te="lexical-block",en=t=>{let{cacheBuster:e,formData:o,nodeKey:r}=t,n=Ea(),{id:i,collectionSlug:l,globalSlug:a}=qr(),{fieldProps:{featureClientSchemaMap:c,field:u,initialLexicalFormState:p,permissions:s,readOnly:d,schemaPath:m},uuid:f}=P(),{fields:h}=_a(),g=Ro(new AbortController),x=Ta(),[N,v]=et.useState(0),{config:b}=ba(),T=fa({slug:`lexical-blocks-create-${f}-${o.id}`,depth:x}),{toggleDrawer:C}=ae(T),{getDocPreferences:E,setDocFieldPreferences:M}=qr(),[k]=La(),{getFormState:S}=wa(),D=`${m}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}.fields`,[w,_]=et.useState(()=>p?.[o.id]?.formState?{...p?.[o.id]?.formState,blockName:{initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName}}:!1),L=Ro(!1),R=Ro(e);No(()=>{L.current?(R.current!==e&&_(!1),R.current=e):L.current=!0},[e]);let[I,O]=et.useState(w?._components?.customComponents?.BlockLabel),[A,H]=et.useState(w?._components?.customComponents?.Block);No(()=>{let B=new AbortController;return o&&!w&&(async()=>{let{state:U}=await S({id:i,collectionSlug:l,data:o,docPermissions:{fields:!0},docPreferences:await E(),documentFormState:Ft(h),globalSlug:a,initialBlockData:o,operation:"update",renderAllFields:!0,schemaPath:D,signal:B.signal});if(U){U.blockName={initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName};let Y=Qr(Ft(U),!0);k.update(()=>{let G=Pt(r);if(G&&ot(G)){let Q=Y;Q.blockType=o.blockType,G.setFields(Q,!0)}}),_(U),O(U._components?.customComponents?.BlockLabel),H(U._components?.customComponents?.Block)}})(),()=>{ko(B)}},[S,D,i,o,k,r,w,l,a,E,h]);let[j,ee]=et.useState(p?.[o.id]?.collapsed??!1),wt=`${m}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}`,K=c.blocks?.[wt]?.[0],Z=K.blockReferences?typeof K?.blockReferences?.[0]=="string"?b.blocksMap[K?.blockReferences?.[0]]:K?.blockReferences?.[0]:K?.blocks?.[0],{i18n:Oe,t:_e}=ka(),se=Lo(async({formState:B,submit:re})=>{ko(g.current);let U=new AbortController;g.current=U;let{state:Y}=await S({id:i,collectionSlug:l,docPermissions:{fields:!0},docPreferences:await E(),documentFormState:Ft(h),formState:B,globalSlug:a,initialBlockFormState:B,operation:"update",renderAllFields:!!re,schemaPath:D,signal:U.signal});if(!Y)return B;B.blockName&&(Y.blockName=B.blockName);let G=Qr(Xr({fields:Ft(Y)}),!0);if(setTimeout(()=>{k.update(()=>{let Q=Pt(r);if(Q&&ot(Q)){let Fe=G;Fe.blockType=o.blockType,Q.setFields(Fe,!0)}})},0),re){O(Y._components?.customComponents?.BlockLabel),H(Y._components?.customComponents?.Block);let Q=0;for(let Fe of Object.values(Y))Fe?.valid===!1&&Q++;v(Q)}return Y},[S,i,l,E,a,D,o.blockType,h,k,r]);No(()=>()=>{ko(g.current)},[]);let Lt=Lo(()=>{k.update(()=>{Pt(r)?.remove()})},[k,r]),Te=Z?.labels?.singular?Na(Z.labels.singular,Oe):Z?.slug,Nt=Lo(B=>{E().then(re=>{let Y=re?.fields?.[u.name]?.collapsed,G=Y&&Y?.length?Y:[];B?G.includes(o.id)||G.push(o.id):G.includes(o.id)&&G.splice(G.indexOf(o.id),1),M(u.name,{collapsed:G,hello:"hi"})})},[E,u.name,M,o.id]),$e=tt(()=>()=>W(Jr,{buttonStyle:"icon-label",className:`${te}__editButton`,disabled:d,el:"button",icon:"edit",onClick:B=>(B.preventDefault(),B.stopPropagation(),C(),!1),onMouseDown:B=>{B.preventDefault()},round:!0,size:"small",tooltip:_e("lexical:blocks:inlineBlocks:edit",{label:Te})}),[Te,d,_e,C]),Rt=tt(()=>()=>W(Jr,{buttonStyle:"icon-label",className:`${te}__removeButton`,disabled:u?.admin?.readOnly||!1,icon:"x",onClick:B=>{B.preventDefault(),Lt()},round:!0,tooltip:"Remove Block"}),[u?.admin?.readOnly,Lt]),fo=tt(()=>({children:B,disableBlockName:re,editButton:U,errorCount:Y,fieldHasErrors:G,Label:Q,removeButton:Fe})=>W("div",{className:te+" "+te+"-"+o.blockType,children:W(ca,{className:[`${te}__row`,G?`${te}__row--has-errors`:`${te}__row--no-errors`].join(" "),collapsibleStyle:G?"error":"default",header:Qe("div",{className:`${te}__block-header`,children:[Q??I?Q??I:Qe("div",{children:[W(ga,{className:`${te}__block-pill ${te}__block-pill-${o?.blockType}`,pillStyle:"white",children:Te??o?.blockType}),!re&&W(xa,{path:"blockName",readOnly:u?.admin?.readOnly||!1}),G&&W(ma,{count:Y??0,i18n:Oe,withMessage:!0})]}),Qe("div",{children:[A&&U!==!1||!A&&U?W($e,{}):null,Fe!==!1&&k.isEditable()?W(Rt,{}):null]})]}),isCollapsed:j,onToggle:Ir=>{Nt(Ir),ee(Ir)},children:B},0)}),[A,I,$e,Rt,Te,k,o.blockType,Oe,j,Nt,u?.admin?.readOnly]),St=Z?.fields??[],Sr=tt(()=>()=>W(da,{children:W(ua,{className:"",slug:T,title:_e(`lexical:blocks:inlineBlocks:${o?.id?"edit":"create"}`,{label:Te??_e("lexical:blocks:inlineBlocks:label")}),children:w?Qe(aa,{children:[W(Ca,{fields:St,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:D,permissions:s,readOnly:!1}),W(ha,{programmaticSubmit:!0,children:_e("fields:saveChanges")})]}):null})}),[w,T,Te,_e,Z?.fields,D,s]),ys=tt(()=>w?W(pa,{beforeSubmit:[async({formState:B})=>await se({formState:B,submit:!0})],fields:St,initialState:w,onChange:[se],onSubmit:(B,re)=>{re.blockType=o.blockType,k.update(()=>{let U=Pt(r);U&&ot(U)&&U.setFields(re,!0)}),C()},submitted:n,uuid:Ra(),children:W(zr,{baseClass:te,BlockDrawer:Sr,Collapsible:fo,CustomBlock:A,EditButton:$e,errorCount:N,formSchema:St,initialState:w,nodeKey:r,RemoveButton:Rt})}):null,[fo,Sr,A,St,Rt,$e,k,N,C,Z?.fields,w,r,se,n]);return Z?ys:W(fo,{disableBlockName:!0,fieldHasErrors:!0,children:Qe("div",{className:"lexical-block-not-found",children:["Error: Block '",o.blockType,"' not found in the config but exists in the lexical data"]})})};var ue=class extends qe{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=Bt(e.fields);return o.setFormat(e.format),o}decorate(e,o){return Sa(en,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Bt(t){return new ue({fields:{...t,id:t?.id||new Ia.default().toHexString()}})}function ot(t){return t instanceof ue}import{createCommand as tn}from"lexical";var Be=tn("INSERT_BLOCK_COMMAND"),He=tn("INSERT_INLINE_BLOCK_COMMAND");import{c as ya}from"react/compiler-runtime";import{useLexicalComposerContext as va}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Ma,$wrapNodeInElement as Da,mergeRegister as Aa}from"@lexical/utils";import{formatDrawerSlug as Oa,useEditDepth as $a}from"@payloadcms/ui";import{$createParagraphNode as Fa,$getNodeByKey as Pa,$getPreviousSelection as Ba,$getSelection as Ha,$insertNodes as ja,$isParagraphNode as rn,$isRangeSelection as Ua,$isRootOrShadowRoot as Ga,COMMAND_PRIORITY_EDITOR as on}from"lexical";import{useEffect as Wa,useState as Va}from"react";var nn=()=>{let t=ya(12),[e]=va(),[o,r]=Va(null),{setCreatedInlineBlock:n,uuid:i}=P(),l=$a(),a="lexical-inlineBlocks-create-"+i,c;t[0]!==l||t[1]!==a?(c=Oa({slug:a,depth:l}),t[0]=l,t[1]=a,t[2]=c):c=t[2];let u=c,{toggleDrawer:p}=ae(u,!0),s;t[3]!==e||t[4]!==n||t[5]!==o?(s=()=>{if(!e.hasNodes([ue]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return Aa(e.registerCommand(Be,m=>(e.update(()=>{let f=Ha()||Ba();if(Ua(f)){let h=Bt(m);Ma(h);let{focus:g}=f,x=g.getNode();rn(x)&&x.getTextContentSize()===0&&x.getParentOrThrow().getChildren().filter(Ka).length>1&&x.remove()}}),!0),on),e.registerCommand(He,m=>{if(o){let h=Pa(o);return!h||!Co(h)?!1:(h.setFields(m),r(null),!0)}let f=go(m);return n?.(f),ja([f]),Ga(f.getParentOrThrow())&&Da(f,Fa).selectEnd(),!0},on))},t[3]=e,t[4]=n,t[5]=o,t[6]=s):s=t[6];let d;return t[7]!==e||t[8]!==n||t[9]!==o||t[10]!==p?(d=[e,n,o,p],t[7]=e,t[8]=n,t[9]=o,t[10]=p,t[11]=d):d=t[11],Wa(s,d),null};function Ka(t){return rn(t)}var Za=y(({config:t,featureClientSchemaMap:e,props:o,schemaPath:r})=>{let n=`${r}.lexical_internal_feature.blocks.lexical_blocks`,i=`${r}.lexical_internal_feature.blocks.lexical_inline_blocks`,l=e.blocks;if(!l)return{};let a=Object.entries(l).filter(([s])=>s.startsWith(n+".")&&!s.replace(n+".","").includes(".")).map(([,s])=>s[0]),c=Object.entries(l).filter(([s])=>s.startsWith(i+".")&&!s.replace(i+".","").includes(".")).map(([,s])=>s[0]),u=a.map(s=>s.blockReferences?typeof s.blockReferences[0]=="string"?t.blocksMap[s.blockReferences[0]]:s.blockReferences[0]:s.blocks[0]).filter(s=>s!==void 0),p=c.map(s=>s.blockReferences?typeof s.blockReferences[0]=="string"?t.blocksMap[s.blockReferences[0]]:s.blockReferences[0]:s.blocks[0]).filter(s=>s!==void 0);return{nodes:[ue,ho],plugins:[{Component:nn,position:"normal"}],sanitizedClientFeatureProps:o,slashMenu:{groups:[u?.length?{items:u.map(s=>({Icon:Ot(s.imageURL,s.imageAltText),key:"block-"+s.slug,keywords:["block","blocks",s.slug],label:({i18n:d})=>s?.labels?.singular?Ht(s.labels.singular,d):s?.slug,onSelect:({editor:d})=>{d.dispatchCommand(Be,{blockName:"",blockType:s.slug})}})),key:"blocks",label:({i18n:s})=>s.t("lexical:blocks:label")}:null,p?.length?{items:p.map(s=>({Icon:At,key:"inlineBlocks-"+s.slug,keywords:["inlineBlock","inline block",s.slug],label:({i18n:d})=>s?.labels?.singular?Ht(s.labels.singular,d):s?.slug,onSelect:({editor:d})=>{d.dispatchCommand(He,{blockName:"",blockType:s.slug})}})),key:"inlineBlocks",label:({i18n:s})=>s.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[u.length?{type:"dropdown",ChildComponent:Dt,items:u.map((s,d)=>({ChildComponent:Ot(s.imageURL,s.imageAltText),isActive:void 0,key:"block-"+s.slug,label:({i18n:m})=>s?.labels?.singular?Ht(s.labels.singular,m):s?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Be,{blockName:"",blockType:s.slug})},order:d})),key:"blocks",order:20}:null,p?.length?{type:"dropdown",ChildComponent:At,items:p.map((s,d)=>({ChildComponent:s.imageURL?Ot(s.imageURL,s.imageAltText):At,isActive:void 0,key:"inlineBlock-"+s.slug,label:({i18n:m})=>s?.labels?.singular?Ht(s.labels.singular,m):s?.slug,onSelect:({editor:m})=>{m.dispatchCommand(He,{blockName:"",blockType:s.slug})},order:d})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as Ya}from"react/compiler-runtime";import{jsx as Se,jsxs as vo}from"react/jsx-runtime";import{useLexicalComposerContext as za}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Xa,$createTextNode as Ja,$getRoot as qa,getDOMSelection as So}from"lexical";import*as cn from"react";import{useCallback as Re,useEffect as Io,useLayoutEffect as ln,useRef as yo,useState as jt}from"react";var Qa=t=>{let e=document.createElement("textarea");e.value=t||"",e.style.position="absolute",e.style.opacity="0",document.body?.appendChild(e),e.focus(),e.select();try{let o=document.execCommand("copy");console.log(o)}catch(o){console.error(o)}document.body?.removeChild(e)},ec=(t,e)=>{let o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e||"")),o.setAttribute("download",t),o.style.display="none",document.body?.appendChild(o),o.click(),document.body?.removeChild(o)},tc=t=>{let o=((r,n)=>{switch(r){case"click":return` await page.mouse.click(${n.x}, ${n.y});`;case"keydown":return` await page.keyboard.keydown('${n}');`;case"keyup":return` await page.keyboard.keyup('${n}');`;case"press":return` await page.keyboard.press('${n}');`;case"selectAll":return" await selectAll(page);";case"snapshot":return` await assertHTMLSnapshot(page);
|
|
3
|
+
`)},regExp:/^>\s/,replace:(t,e,o,r)=>{if(r){let i=t.getPreviousSibling();if(Hr(i)){i.splice(i.getChildrenSize(),0,[Zs(),...e]),i.select(0,0),t.remove();return}}let n=Vs();n.append(...e),t.replace(n),n.select(0,0)}};var Gr=[J([{ChildComponent:Eo,isActive:({selection:t})=>{if(!zs(t))return!1;for(let e of t.getNodes())if(!Ur(e)&&!Ur(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Kr();Vr(e,()=>Wr())})},order:20}])],Xs=y({markdownTransformers:[jr],nodes:[Ys],slashMenu:{groups:[z([{Icon:Eo,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Kr();Vr(e,()=>Wr())})}}])]},toolbarFixed:{groups:Gr},toolbarInline:{groups:Gr}});import{getTranslation as Ht}from"@payloadcms/translations";import{jsx as wo,jsxs as Js}from"react/jsx-runtime";import"react";var Dt=()=>Js("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[wo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),wo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),wo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as Zr}from"react/jsx-runtime";import"react";var At=()=>Zr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Zr("path",{clipRule:"evenodd",d:"M5.33333 6.5C5.11232 6.5 4.90036 6.5878 4.74408 6.74408C4.5878 6.90036 4.5 7.11232 4.5 7.33333V12.1667C4.5 12.3877 4.5878 12.5996 4.74408 12.7559C4.90036 12.9122 5.11232 13 5.33333 13H14.6667C14.8877 13 15.0996 12.9122 15.2559 12.7559C15.4122 12.5996 15.5 12.3877 15.5 12.1667V11.6667C15.5 11.3905 15.7239 11.1667 16 11.1667C16.2761 11.1667 16.5 11.3905 16.5 11.6667V12.1667C16.5 12.6529 16.3068 13.1192 15.963 13.463C15.6192 13.8068 15.1529 14 14.6667 14H5.33333C4.8471 14 4.38079 13.8068 4.03697 13.463C3.69315 13.1192 3.5 12.6529 3.5 12.1667V7.33333C3.5 6.8471 3.69315 6.38079 4.03697 6.03697C4.38079 5.69315 4.8471 5.5 5.33333 5.5H10.3333C10.6095 5.5 10.8333 5.72386 10.8333 6C10.8333 6.27614 10.6095 6.5 10.3333 6.5H5.33333ZM13 6.5C12.7239 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.7239 5.5 13 5.5H16C16.2761 5.5 16.5 5.72386 16.5 6V9C16.5 9.27614 16.2761 9.5 16 9.5C15.7239 9.5 15.5 9.27614 15.5 9V7.20711L13.3536 9.35355C13.1583 9.54882 12.8417 9.54882 12.6464 9.35355C12.4512 9.15829 12.4512 8.84171 12.6464 8.64645L14.7929 6.5H13ZM6.16699 8.33325C6.16699 8.05711 6.39085 7.83325 6.66699 7.83325H11.0003C11.2765 7.83325 11.5003 8.05711 11.5003 8.33325C11.5003 8.60939 11.2765 8.83325 11.0003 8.83325H6.66699C6.39085 8.83325 6.16699 8.60939 6.16699 8.33325ZM6.16699 10.9999C6.16699 10.7238 6.39085 10.4999 6.66699 10.4999H13.3337C13.6098 10.4999 13.8337 10.7238 13.8337 10.9999C13.8337 11.2761 13.6098 11.4999 13.3337 11.4999H6.66699C6.39085 11.4999 6.16699 11.2761 6.16699 10.9999Z",fill:"currentColor",fillRule:"evenodd"})});import{jsx as qs}from"react/jsx-runtime";import"react";function Ot(t,e){return t?()=>qs("img",{alt:e??"Block Image",className:"lexical-block-custom-image",src:t,style:{maxHeight:20,maxWidth:20}}):Dt}import{jsx as Sa}from"react/jsx-runtime";import Ia from"bson-objectid";import"react";import{DecoratorBlockNode as Qs}from"@lexical/react/LexicalDecoratorBlockNode.js";import ea from"bson-objectid";var qe=class extends Qs{__cacheBuster;__fields;constructor({cacheBuster:e,fields:o,format:r,key:n}){super(r,n),this.__fields=o,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,format:e.__format,key:e.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=ta(e.fields);return o.setFormat(e.format),o}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div"),o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e,o){let r=this.getWritable();r.__fields=e,o||r.__cacheBuster++}};function ta(t){return new qe({fields:{...t,id:t?.id||new ea.default().toHexString()}})}import{jsx as W,jsxs as Qe,Fragment as aa}from"react/jsx-runtime";import{Button as Jr,Collapsible as ca,Drawer as ua,EditDepthProvider as da,ErrorPill as ma,Form as pa,formatDrawerSlug as fa,FormSubmit as ha,Pill as ga,RenderFields as Ca,SectionTitle as xa,useConfig as ba,useDocumentForm as _a,useDocumentInfo as qr,useEditDepth as Ta,useFormSubmitted as Ea,useServerFunctions as wa,useTranslation as ka}from"@payloadcms/ui";import{abortAndIgnore as ko}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as Ft,reduceFieldsToValues as Qr}from"payload/shared";import et,{useCallback as Lo,useEffect as No,useMemo as tt,useRef as Ro}from"react";import{useLexicalComposerContext as La}from"@lexical/react/LexicalComposerContext";import{getTranslation as Na}from"@payloadcms/translations";import{$getNodeByKey as Pt}from"lexical";import{v4 as Ra}from"uuid";import{c as oa}from"react/compiler-runtime";import{jsx as $t,jsxs as ra}from"react/jsx-runtime";import{RenderFields as na,useFormSubmitted as ia}from"@payloadcms/ui";import la,{createContext as sa}from"react";var Yr=sa({initialState:!1}),Ne=()=>la.useContext(Yr),zr=t=>{let e=oa(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:a,initialState:c,nodeKey:u,RemoveButton:p}=t,d=ia()&&l>0,m,f;e[0]!==r||e[1]!==l||e[2]!==d?(f=x=>$t(r,{editButton:x.editButton,errorCount:l,fieldHasErrors:d,Label:x.Label,removeButton:x.removeButton,children:x.children}),e[0]=r,e[1]=l,e[2]=d,e[3]=f):f=e[3],m=f;let h=m,g;return e[4]!==o||e[5]!==h||e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==c||e[11]!==u?(g=n?ra(Yr.Provider,{value:{BlockCollapsible:h,EditButton:i,initialState:c,nodeKey:u,RemoveButton:p},children:[n,$t(o,{})]}):$t(h,{children:$t(na,{fields:a,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=o,e[5]=h,e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=c,e[11]=u,e[12]=g):g=e[12],g};function Xr({fields:t}){for(let e in t){let o=t[e];Array.isArray(o?.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var te="lexical-block",en=t=>{let{cacheBuster:e,formData:o,nodeKey:r}=t,n=Ea(),{id:i,collectionSlug:l,globalSlug:a}=qr(),{fieldProps:{featureClientSchemaMap:c,field:u,initialLexicalFormState:p,permissions:s,readOnly:d,schemaPath:m},uuid:f}=P(),{fields:h}=_a(),g=Ro(new AbortController),x=Ta(),[N,v]=et.useState(0),{config:b}=ba(),T=fa({slug:`lexical-blocks-create-${f}-${o.id}`,depth:x}),{toggleDrawer:C}=ae(T),{getDocPreferences:E,setDocFieldPreferences:M}=qr(),[k]=La(),{getFormState:S}=wa(),D=`${m}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}.fields`,[w,_]=et.useState(()=>p?.[o.id]?.formState?{...p?.[o.id]?.formState,blockName:{initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName}}:!1),L=Ro(!1),R=Ro(e);No(()=>{L.current?(R.current!==e&&_(!1),R.current=e):L.current=!0},[e]);let[I,O]=et.useState(w?._components?.customComponents?.BlockLabel),[A,H]=et.useState(w?._components?.customComponents?.Block);No(()=>{let B=new AbortController;return o&&!w&&(async()=>{let{state:U}=await S({id:i,collectionSlug:l,data:o,docPermissions:{fields:!0},docPreferences:await E(),documentFormState:Ft(h),globalSlug:a,initialBlockData:o,operation:"update",renderAllFields:!0,schemaPath:D,signal:B.signal});if(U){U.blockName={initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName};let Y=Qr(Ft(U),!0);k.update(()=>{let G=Pt(r);if(G&&ot(G)){let Q=Y;Q.blockType=o.blockType,G.setFields(Q,!0)}}),_(U),O(U._components?.customComponents?.BlockLabel),H(U._components?.customComponents?.Block)}})(),()=>{ko(B)}},[S,D,i,o,k,r,w,l,a,E,h]);let[j,ee]=et.useState(p?.[o.id]?.collapsed??!1),wt=`${m}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}`,K=c.blocks?.[wt]?.[0],Z=K.blockReferences?typeof K?.blockReferences?.[0]=="string"?b.blocksMap[K?.blockReferences?.[0]]:K?.blockReferences?.[0]:K?.blocks?.[0],{i18n:Oe,t:_e}=ka(),se=Lo(async({formState:B,submit:re})=>{ko(g.current);let U=new AbortController;g.current=U;let{state:Y}=await S({id:i,collectionSlug:l,docPermissions:{fields:!0},docPreferences:await E(),documentFormState:Ft(h),formState:B,globalSlug:a,initialBlockFormState:B,operation:"update",renderAllFields:!!re,schemaPath:D,signal:U.signal});if(!Y)return B;B.blockName&&(Y.blockName=B.blockName);let G=Qr(Xr({fields:Ft(Y)}),!0);if(setTimeout(()=>{k.update(()=>{let Q=Pt(r);if(Q&&ot(Q)){let Fe=G;Fe.blockType=o.blockType,Q.setFields(Fe,!0)}})},0),re){O(Y._components?.customComponents?.BlockLabel),H(Y._components?.customComponents?.Block);let Q=0;for(let Fe of Object.values(Y))Fe?.valid===!1&&Q++;v(Q)}return Y},[S,i,l,E,a,D,o.blockType,h,k,r]);No(()=>()=>{ko(g.current)},[]);let Lt=Lo(()=>{k.update(()=>{Pt(r)?.remove()})},[k,r]),Te=Z?.labels?.singular?Na(Z.labels.singular,Oe):Z?.slug,Nt=Lo(B=>{E().then(re=>{let Y=re?.fields?.[u.name]?.collapsed,G=Y&&Y?.length?Y:[];B?G.includes(o.id)||G.push(o.id):G.includes(o.id)&&G.splice(G.indexOf(o.id),1),M(u.name,{collapsed:G,hello:"hi"})})},[E,u.name,M,o.id]),$e=tt(()=>()=>W(Jr,{buttonStyle:"icon-label",className:`${te}__editButton`,disabled:d,el:"button",icon:"edit",onClick:B=>(B.preventDefault(),B.stopPropagation(),C(),!1),onMouseDown:B=>{B.preventDefault()},round:!0,size:"small",tooltip:_e("lexical:blocks:inlineBlocks:edit",{label:Te})}),[Te,d,_e,C]),Rt=tt(()=>()=>W(Jr,{buttonStyle:"icon-label",className:`${te}__removeButton`,disabled:u?.admin?.readOnly||!1,icon:"x",onClick:B=>{B.preventDefault(),Lt()},round:!0,tooltip:"Remove Block"}),[u?.admin?.readOnly,Lt]),fo=tt(()=>({children:B,disableBlockName:re,editButton:U,errorCount:Y,fieldHasErrors:G,Label:Q,removeButton:Fe})=>W("div",{className:te+" "+te+"-"+o.blockType,children:W(ca,{className:[`${te}__row`,G?`${te}__row--has-errors`:`${te}__row--no-errors`].join(" "),collapsibleStyle:G?"error":"default",header:Qe("div",{className:`${te}__block-header`,children:[Q??I?Q??I:Qe("div",{children:[W(ga,{className:`${te}__block-pill ${te}__block-pill-${o?.blockType}`,pillStyle:"white",children:Te??o?.blockType}),!re&&W(xa,{path:"blockName",readOnly:u?.admin?.readOnly||!1}),G&&W(ma,{count:Y??0,i18n:Oe,withMessage:!0})]}),Qe("div",{children:[A&&U!==!1||!A&&U?W($e,{}):null,Fe!==!1&&k.isEditable()?W(Rt,{}):null]})]}),isCollapsed:j,onToggle:Ir=>{Nt(Ir),ee(Ir)},children:B},0)}),[A,I,$e,Rt,Te,k,o.blockType,Oe,j,Nt,u?.admin?.readOnly]),St=Z?.fields??[],Sr=tt(()=>()=>W(da,{children:W(ua,{className:"",slug:T,title:_e(`lexical:blocks:inlineBlocks:${o?.id?"edit":"create"}`,{label:Te??_e("lexical:blocks:inlineBlocks:label")}),children:w?Qe(aa,{children:[W(Ca,{fields:St,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:D,permissions:s,readOnly:!1}),W(ha,{programmaticSubmit:!0,children:_e("fields:saveChanges")})]}):null})}),[w,T,Te,_e,Z?.fields,D,s]),ys=tt(()=>w?W(pa,{beforeSubmit:[async({formState:B})=>await se({formState:B,submit:!0})],el:"div",fields:St,initialState:w,onChange:[se],onSubmit:(B,re)=>{re.blockType=o.blockType,k.update(()=>{let U=Pt(r);U&&ot(U)&&U.setFields(re,!0)}),C()},submitted:n,uuid:Ra(),children:W(zr,{baseClass:te,BlockDrawer:Sr,Collapsible:fo,CustomBlock:A,EditButton:$e,errorCount:N,formSchema:St,initialState:w,nodeKey:r,RemoveButton:Rt})}):null,[fo,Sr,A,St,Rt,$e,k,N,C,Z?.fields,w,r,se,n]);return Z?ys:W(fo,{disableBlockName:!0,fieldHasErrors:!0,children:Qe("div",{className:"lexical-block-not-found",children:["Error: Block '",o.blockType,"' not found in the config but exists in the lexical data"]})})};var ue=class extends qe{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=Bt(e.fields);return o.setFormat(e.format),o}decorate(e,o){return Sa(en,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Bt(t){return new ue({fields:{...t,id:t?.id||new Ia.default().toHexString()}})}function ot(t){return t instanceof ue}import{createCommand as tn}from"lexical";var Be=tn("INSERT_BLOCK_COMMAND"),He=tn("INSERT_INLINE_BLOCK_COMMAND");import{c as ya}from"react/compiler-runtime";import{useLexicalComposerContext as va}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Ma,$wrapNodeInElement as Da,mergeRegister as Aa}from"@lexical/utils";import{formatDrawerSlug as Oa,useEditDepth as $a}from"@payloadcms/ui";import{$createParagraphNode as Fa,$getNodeByKey as Pa,$getPreviousSelection as Ba,$getSelection as Ha,$insertNodes as ja,$isParagraphNode as rn,$isRangeSelection as Ua,$isRootOrShadowRoot as Ga,COMMAND_PRIORITY_EDITOR as on}from"lexical";import{useEffect as Wa,useState as Va}from"react";var nn=()=>{let t=ya(12),[e]=va(),[o,r]=Va(null),{setCreatedInlineBlock:n,uuid:i}=P(),l=$a(),a="lexical-inlineBlocks-create-"+i,c;t[0]!==l||t[1]!==a?(c=Oa({slug:a,depth:l}),t[0]=l,t[1]=a,t[2]=c):c=t[2];let u=c,{toggleDrawer:p}=ae(u,!0),s;t[3]!==e||t[4]!==n||t[5]!==o?(s=()=>{if(!e.hasNodes([ue]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return Aa(e.registerCommand(Be,m=>(e.update(()=>{let f=Ha()||Ba();if(Ua(f)){let h=Bt(m);Ma(h);let{focus:g}=f,x=g.getNode();rn(x)&&x.getTextContentSize()===0&&x.getParentOrThrow().getChildren().filter(Ka).length>1&&x.remove()}}),!0),on),e.registerCommand(He,m=>{if(o){let h=Pa(o);return!h||!Co(h)?!1:(h.setFields(m),r(null),!0)}let f=go(m);return n?.(f),ja([f]),Ga(f.getParentOrThrow())&&Da(f,Fa).selectEnd(),!0},on))},t[3]=e,t[4]=n,t[5]=o,t[6]=s):s=t[6];let d;return t[7]!==e||t[8]!==n||t[9]!==o||t[10]!==p?(d=[e,n,o,p],t[7]=e,t[8]=n,t[9]=o,t[10]=p,t[11]=d):d=t[11],Wa(s,d),null};function Ka(t){return rn(t)}var Za=y(({config:t,featureClientSchemaMap:e,props:o,schemaPath:r})=>{let n=`${r}.lexical_internal_feature.blocks.lexical_blocks`,i=`${r}.lexical_internal_feature.blocks.lexical_inline_blocks`,l=e.blocks;if(!l)return{};let a=Object.entries(l).filter(([s])=>s.startsWith(n+".")&&!s.replace(n+".","").includes(".")).map(([,s])=>s[0]),c=Object.entries(l).filter(([s])=>s.startsWith(i+".")&&!s.replace(i+".","").includes(".")).map(([,s])=>s[0]),u=a.map(s=>s.blockReferences?typeof s.blockReferences[0]=="string"?t.blocksMap[s.blockReferences[0]]:s.blockReferences[0]:s.blocks[0]).filter(s=>s!==void 0),p=c.map(s=>s.blockReferences?typeof s.blockReferences[0]=="string"?t.blocksMap[s.blockReferences[0]]:s.blockReferences[0]:s.blocks[0]).filter(s=>s!==void 0);return{nodes:[ue,ho],plugins:[{Component:nn,position:"normal"}],sanitizedClientFeatureProps:o,slashMenu:{groups:[u?.length?{items:u.map(s=>({Icon:Ot(s.imageURL,s.imageAltText),key:"block-"+s.slug,keywords:["block","blocks",s.slug],label:({i18n:d})=>s?.labels?.singular?Ht(s.labels.singular,d):s?.slug,onSelect:({editor:d})=>{d.dispatchCommand(Be,{blockName:"",blockType:s.slug})}})),key:"blocks",label:({i18n:s})=>s.t("lexical:blocks:label")}:null,p?.length?{items:p.map(s=>({Icon:At,key:"inlineBlocks-"+s.slug,keywords:["inlineBlock","inline block",s.slug],label:({i18n:d})=>s?.labels?.singular?Ht(s.labels.singular,d):s?.slug,onSelect:({editor:d})=>{d.dispatchCommand(He,{blockName:"",blockType:s.slug})}})),key:"inlineBlocks",label:({i18n:s})=>s.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[u.length?{type:"dropdown",ChildComponent:Dt,items:u.map((s,d)=>({ChildComponent:Ot(s.imageURL,s.imageAltText),isActive:void 0,key:"block-"+s.slug,label:({i18n:m})=>s?.labels?.singular?Ht(s.labels.singular,m):s?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Be,{blockName:"",blockType:s.slug})},order:d})),key:"blocks",order:20}:null,p?.length?{type:"dropdown",ChildComponent:At,items:p.map((s,d)=>({ChildComponent:s.imageURL?Ot(s.imageURL,s.imageAltText):At,isActive:void 0,key:"inlineBlock-"+s.slug,label:({i18n:m})=>s?.labels?.singular?Ht(s.labels.singular,m):s?.slug,onSelect:({editor:m})=>{m.dispatchCommand(He,{blockName:"",blockType:s.slug})},order:d})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as Ya}from"react/compiler-runtime";import{jsx as Se,jsxs as vo}from"react/jsx-runtime";import{useLexicalComposerContext as za}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Xa,$createTextNode as Ja,$getRoot as qa,getDOMSelection as So}from"lexical";import*as cn from"react";import{useCallback as Re,useEffect as Io,useLayoutEffect as ln,useRef as yo,useState as jt}from"react";var Qa=t=>{let e=document.createElement("textarea");e.value=t||"",e.style.position="absolute",e.style.opacity="0",document.body?.appendChild(e),e.focus(),e.select();try{let o=document.execCommand("copy");console.log(o)}catch(o){console.error(o)}document.body?.removeChild(e)},ec=(t,e)=>{let o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e||"")),o.setAttribute("download",t),o.style.display="none",document.body?.appendChild(o),o.click(),document.body?.removeChild(o)},tc=t=>{let o=((r,n)=>{switch(r){case"click":return` await page.mouse.click(${n.x}, ${n.y});`;case"keydown":return` await page.keyboard.keydown('${n}');`;case"keyup":return` await page.keyboard.keyup('${n}');`;case"press":return` await page.keyboard.press('${n}');`;case"selectAll":return" await selectAll(page);";case"snapshot":return` await assertHTMLSnapshot(page);
|
|
4
4
|
await assertSelection(page, {
|
|
5
5
|
anchorPath: [${n.anchorPath.toString()}],
|
|
6
6
|
anchorOffset: ${n.anchorOffset},
|