@payloadcms/richtext-lexical 3.2.2 → 3.2.3-canary.519752f
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/exports/client/chunk-YSJURFKK.js +2 -0
- package/dist/exports/client/chunk-YSJURFKK.js.map +7 -0
- package/dist/exports/client/componentInline-OK3ZQ6YQ.js +2 -0
- package/dist/exports/client/index.js +1 -1
- package/dist/features/blocks/client/componentInline/index.js +1 -1
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/getDefaultSanitizedEditorConfig.d.ts.map +1 -1
- package/dist/getDefaultSanitizedEditorConfig.js +2 -3
- package/dist/getDefaultSanitizedEditorConfig.js.map +1 -1
- package/package.json +7 -7
- package/dist/exports/client/chunk-WHL7AV5U.js +0 -2
- package/dist/exports/client/chunk-WHL7AV5U.js.map +0 -7
- package/dist/exports/client/componentInline-GXYBWVCR.js +0 -2
- /package/dist/exports/client/{componentInline-GXYBWVCR.js.map → componentInline-OK3ZQ6YQ.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as Z}from"./chunk-2CYU43GM.js";import{b as X}from"./chunk-CUIBIFW2.js";import{jsx as i,jsxs as I,Fragment as he}from"react/jsx-runtime";import w,{createContext as _e,useCallback as k,useEffect as T,useMemo as N,useRef as ee}from"react";import{useLexicalComposerContext as Be}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as De}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as ye}from"@lexical/utils";import{getTranslation as te}from"@payloadcms/translations";import{Button as ne,Drawer as Ie,EditDepthProvider as Ne,Form as we,formatDrawerSlug as ve,FormSubmit as Fe,RenderFields as Oe,ShimmerEffect as $e,useDocumentInfo as Ee,useEditDepth as Pe,useServerFunctions as Me,useTranslation as Le}from"@payloadcms/ui";import{abortAndIgnore as A}from"@payloadcms/ui/shared";import{$getNodeByKey as oe,$getSelection as Te,$isNodeSelection as Ae,CLICK_COMMAND as Re,COMMAND_PRIORITY_LOW as R,KEY_BACKSPACE_COMMAND as je,KEY_DELETE_COMMAND as Ke}from"lexical";import{reduceFieldsToValues as Je}from"payload/shared";import{v4 as ze}from"uuid";import{jsx as ke}from"react/jsx-runtime";import ge from"bson-objectid";import Ce from"react";import pe from"bson-objectid";import{DecoratorNode as fe}from"lexical";var b=class extends fe{__fields;constructor({fields:e,key:n}){super(n),this.__fields=e}static clone(e){return new this({fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return be(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,n){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let n=document.createTextNode(this.getTextContent());return e.append(n),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e){let n=this.getWritable();n.__fields=e}updateDOM(){return!1}};function be(r){return new b({fields:{...r,id:r?.id||new pe.default().toHexString()}})}var xe=Ce.lazy(()=>import("./componentInline-OK3ZQ6YQ.js").then(r=>({default:r.InlineBlockComponent}))),y=class extends b{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return Se(e.fields)}decorate(e,n){return ke(xe,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Se(r){return new y({fields:{...r,id:r?.id||new ge.default().toHexString()}})}function L(r){return r instanceof y}var m="inline-block",re=_e({initialState:!1}),ft=()=>w.useContext(re),bt=r=>{let{formData:e,nodeKey:n}=r,[s]=Be(),{i18n:v,t:d}=Le(),{fieldProps:{featureClientSchemaMap:le,initialLexicalFormState:ie,permissions:se,readOnly:g,schemaPath:j},uuid:ce}=X(),{getFormState:C}=Me(),ae=Pe(),[c,ue]=w.useState(ie?.[e.id]?.formState),[F,K]=w.useState(c?._components?.customComponents?.BlockLabel),[J,z]=w.useState(c?._components?.customComponents?.Block),Y=ve({slug:`lexical-inlineBlocks-create-${ce}-${e.id}`,depth:ae}),{toggleDrawer:O}=Z(Y,!0),$=ee(null),[a,x,E]=De(n),{id:S,collectionSlug:h,getDocPreferences:_,globalSlug:B}=Ee(),de=`${j}.lexical_internal_feature.blocks.lexical_inline_blocks.${e.blockType}`,u=le.blocks[de][0].blocks[0],H=k(()=>{s.update(()=>{oe(n)?.remove()})},[s,n]),P=k(t=>{let l=Te();return a&&Ae(l)&&(t.preventDefault(),s.update(()=>{l.getNodes().forEach(o=>{L(o)&&o.remove()})})),!1},[s,a]),V=k(t=>{let l=t;return l.target===$.current||$.current?.contains(l.target)?(l.shiftKey?x(!a):a||(E(),x(!0)),!0):!1},[a,x,E]);T(()=>ye(s.registerCommand(Re,V,R),s.registerCommand(Ke,P,R),s.registerCommand(je,P,R)),[E,s,a,n,P,x,V]);let p=u?.labels?.singular?te(u.labels.singular,v):u?.slug,M=ee(new AbortController),f=`${j}.lexical_internal_feature.blocks.lexical_inline_blocks.${u?.slug}.fields`;T(()=>{let t=new AbortController;return e&&!c&&(async()=>{let{state:o}=await C({id:S,collectionSlug:h,data:e,docPermissions:{fields:!0},docPreferences:await _(),globalSlug:B,operation:"update",renderAllFields:!0,schemaPath:f,signal:t.signal});o&&(ue(o),K(o._components?.customComponents?.BlockLabel),z(o._components?.customComponents?.Block))})(),()=>{A(t)}},[C,f,S,e,c,h,B,_]);let W=k(async({formState:t,submit:l})=>{A(M.current);let o=new AbortController;M.current=o;let{state:D}=await C({id:S,collectionSlug:h,docPermissions:{fields:!0},docPreferences:await _(),formState:t,globalSlug:B,operation:"update",renderAllFields:!!l,schemaPath:f,signal:o.signal});return D?(l&&(K(D._components?.customComponents?.BlockLabel),z(D._components?.customComponents?.Block)),D):t},[C,S,h,_,B,f]);T(()=>()=>{A(M.current)},[]);let me=k(t=>{let l=Je(t);l.blockType=e.blockType,s.update(()=>{let o=oe(n);o&&L(o)&&o.setFields(l)})},[s,n,e]),q=N(()=>()=>i(ne,{buttonStyle:"icon-label",className:`${m}__removeButton`,disabled:g,icon:"x",onClick:t=>{t.preventDefault(),H()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:remove",{label:p})}),[p,g,H,d]),G=N(()=>()=>i(ne,{buttonStyle:"icon-label",className:`${m}__editButton`,disabled:g,el:"button",icon:"edit",onClick:()=>{O()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:edit",{label:p})}),[p,g,d,O]),Q=N(()=>({children:t})=>i("div",{className:[m,m+"-"+e.blockType,a&&`${m}--selected`].filter(Boolean).join(" "),ref:$,children:t}),[e.blockType,a]),U=N(()=>F?()=>F:()=>i("div",{children:te(u.labels.singular,v)}),[F,u.labels,v]);return I(we,{beforeSubmit:[async({formState:t})=>await W({formState:t,submit:!0})],disableValidationOnSubmit:!0,fields:u.fields,initialState:c||{},onChange:[W],onSubmit:t=>{me(t),O()},uuid:ze(),children:[i(Ne,{children:i(Ie,{className:"",slug:Y,title:d(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:p??d("lexical:blocks:inlineBlocks:label")}),children:c?I(he,{children:[i(Oe,{fields:u.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:f,permissions:se,readOnly:!1}),i(Fe,{programmaticSubmit:!0,children:d("fields:saveChanges")})]}):null})}),J?i(re.Provider,{value:{EditButton:G,initialState:c,InlineBlockContainer:Q,Label:U,nodeKey:n,RemoveButton:q},children:J}):I(Q,{children:[c?i(U,{}):i($e,{height:"15px",width:"40px"}),s.isEditable()?I("div",{className:`${m}__actions`,children:[i(G,{}),i(q,{})]}):null]})]})};export{ft as a,bt as b,y as c,Se as d,L as e};
|
|
2
|
+
//# sourceMappingURL=chunk-YSJURFKK.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\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 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 { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\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 [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\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 = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\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 globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\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 schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\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 formState: prevFormState,\n globalSlug,\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 [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\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) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\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 }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\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) => {\n onFormSubmit(formState)\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 clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n 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 __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static 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 createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n 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 exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const writable = this.getWritable()\n writable.__fields = fields\n }\n\n 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": "iJAEA,OAAOA,GAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,OAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,2BAAAA,OAA+B,yCACxC,OAASC,iBAAAA,OAAqB,iBAC9B,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OACEC,iBAAAA,GACAC,iBAAAA,GACAC,oBAAAA,GACAC,iBAAAA,GACAC,wBAAAA,EACAC,yBAAAA,GACAC,sBAAAA,OACK,UACP,OAASC,wBAAAA,OAA4B,iBAIrC,OAASC,MAAMC,OAAY,gDCpC3B,OAAOC,OAAc,gBACrB,OAAOC,OAAyB,QCUhC,OAAOC,OAAc,gBACrB,OAASC,iBAAAA,OAAqB,UAgBvB,IAAMC,EAAN,cAAoCD,EAAA,CACzCE,SAEAC,YAAY,CAAEC,OAAAA,EAAQC,IAAAA,CAAG,EAAkD,CACzE,MAAMA,CAAA,EACN,KAAKH,SAAWE,CAClB,CAEA,OAAOE,MAAMC,EAAoD,CAC/D,OAAO,IAAI,KAAK,CACdH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AW,GACXC,gBAAgB,GAChBC,WAAW,GACXC,iBAAkBtD,EAClB3E,YAAaA,GACbC,SAAU,KAEZ+F,EAACkC,GAAA,CAAWC,mBAAoB,YAAOxI,EAAE,oBAAA,OAEzC,SAGPuB,EACC8E,EAAClH,GAA4BsJ,SAAQ,CACnCC,MAAO,CACL1B,WAAAA,EACA3H,aAAAA,EACA6H,qBAAAA,EACAM,MAAAA,EACA5H,QAAAA,EACAuG,aAAAA,CACF,WAEC5E,IAGHkG,EAACP,EAAA,WACE7H,EAAegH,EAACmB,EAAA,CAAA,CAAA,EAAWnB,EAACsC,GAAA,CAAcC,OAAO,OAAOC,MAAM,SAC9DhJ,EAAOiJ,WAAU,EAChBrB,EAAC,MAAA,CAAIjB,UAAW,GAAGtH,CAAA,sBACjBmH,EAACW,EAAA,CAAA,CAAA,EACDX,EAACF,EAAA,CAAA,CAAA,CAAA,IAED,IAAA,MAKd",
|
|
6
|
+
"names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "useLexicalNodeSelection", "mergeRegister", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "$getSelection", "$isNodeSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "React", "ObjectID", "DecoratorNode", "ServerInlineBlockNode", "__fields", "constructor", "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", "getLatest", "setFields", "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", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "useContext", "InlineBlockComponent", "props", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "permissions", "readOnly", "schemaPath", "uuid", "uuidFromContext", "useEditorConfigContext", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "setInitialState", "useState", "id", "formState", "CustomLabel", "setCustomLabel", "customComponents", "BlockLabel", "CustomBlock", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "useRef", "isSelected", "setSelected", "clearSelection", "useLexicalNodeSelection", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "componentMapRenderedBlockPath", "blockType", "clientBlock", "blocks", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "$onDelete", "event", "deleteSelection", "$getSelection", "$isNodeSelection", "preventDefault", "getNodes", "forEach", "node", "$isInlineBlockNode", "onClick", "payload", "target", "current", "contains", "shiftKey", "useEffect", "mergeRegister", "registerCommand", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_DELETE_COMMAND", "KEY_BACKSPACE_COMMAND", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "fields", "docPreferences", "operation", "renderAllFields", "signal", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "onFormSubmit", "newData", "reduceFieldsToValues", "setFields", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "e", "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
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{a as be,c as ro,d as no,e as io}from"./chunk-
|
|
1
|
+
"use client";import{a as be,c as ro,d as no,e as io}from"./chunk-YSJURFKK.js";import{a as Be,b as gt,c as Ct,d as xt}from"./chunk-XCEM47RI.js";import{a as je,b as Ge,c as Ue,d as lo}from"./chunk-ZTAS32RX.js";import{a as He,b as bt,c as We,d as Ve,e as Ke,f as so}from"./chunk-DOK5S7LE.js";import{a as ce}from"./chunk-2CYU43GM.js";import{a as fs}from"./chunk-5PBXL4HT.js";import{a as ps,b as mr,d as pr,e as fr,f as hr,g as hs,h as gs,i as Cs,k as xs,m as bs,n as _s}from"./chunk-2L2Z4JHF.js";import{a as ms,b as B}from"./chunk-CUIBIFW2.js";function Z(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{$isElementNode as _e,$isRangeSelection as Tt,FORMAT_ELEMENT_COMMAND as Et}from"lexical";import{jsx as ao,jsxs as Ts}from"react/jsx-runtime";import"react";var gr=()=>Ts("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:[ao("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),ao("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),ao("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as co,jsxs as Es}from"react/jsx-runtime";import"react";var Cr=()=>Es("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:[co("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),co("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),co("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as uo,jsxs as ws}from"react/jsx-runtime";import"react";var _t=()=>ws("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:[uo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),uo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),uo("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as mo,jsxs as ks}from"react/jsx-runtime";import"react";var xr=()=>ks("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:[mo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),mo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),mo("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=({featureClientSchemaMap:n,featureProviderMap:i,field:l,resolvedFeatures:s,schemaPath:a,unSanitizedEditorConfig:d})=>{let c=t({featureClientSchemaMap:n,featureProviderMap:i,field:l,props:o,resolvedFeatures:s,schemaPath:a,unSanitizedEditorConfig:d});return c.sanitizedClientFeatureProps===null&&(c.sanitizedClientFeatureProps=o),c};else{let n={...t};n.sanitizedClientFeatureProps=o,r.feature=n}return r};var br=t=>({type:"dropdown",ChildComponent:_t,items:t,key:"align",order:30});var _r=[br([{ChildComponent:_t,isActive:({selection:t})=>{if(!Tt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="left")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Et,"left")},order:1},{ChildComponent:gr,isActive:({selection:t})=>{if(!Tt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="center")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Et,"center")},order:2},{ChildComponent:xr,isActive:({selection:t})=>{if(!Tt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="right")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Et,"right")},order:3},{ChildComponent:Cr,isActive:({selection:t})=>{if(!Tt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="justify")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Et,"justify")},order:4}])],Ns=y({toolbarFixed:{groups:_r},toolbarInline:{groups:_r}});import{$createQuoteNode as Rr,$isQuoteNode as Nr,QuoteNode as Is}from"@lexical/rich-text";import{$setBlocksType as Sr}from"@lexical/selection";import{$getSelection as Ir,$isRangeSelection as ys}from"lexical";import{jsx as Tr}from"react/jsx-runtime";import"react";var po=()=>Tr("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:Tr("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 Er}from"react/jsx-runtime";import"react";var ze=()=>Er("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:Er("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 q=t=>({type:"dropdown",ChildComponent:ze,items:t,key:"text",order:25});import{$createQuoteNode as Ls,$isQuoteNode as wr,QuoteNode as Rs}from"@lexical/rich-text";import{$createLineBreakNode as Ss}from"lexical";var kr={type:"element",dependencies:[Rs],export:(t,e)=>{if(!wr(t))return null;let o=e(t).split(`
|
|
2
2
|
`),r=[];for(let n of o)r.push("> "+n);return r.join(`
|
|
3
3
|
`)},regExp:/^>\s/,replace:(t,e,o,r)=>{if(r){let i=t.getPreviousSibling();if(wr(i)){i.splice(i.getChildrenSize(),0,[Ss(),...e]),i.select(0,0),t.remove();return}}let n=Ls();n.append(...e),t.replace(n),n.select(0,0)}};var Lr=[q([{ChildComponent:po,isActive:({selection:t})=>{if(!ys(t))return!1;for(let e of t.getNodes())if(!Nr(e)&&!Nr(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Ir();Sr(e,()=>Rr())})},order:20}])],vs=y({markdownTransformers:[kr],nodes:[Is],slashMenu:{groups:[Z([{Icon:po,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Ir();Sr(e,()=>Rr())})}}])]},toolbarFixed:{groups:Lr},toolbarInline:{groups:Lr}});import{getTranslation as It}from"@payloadcms/translations";import{jsx as fo,jsxs as Ms}from"react/jsx-runtime";import"react";var wt=()=>Ms("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:[fo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),fo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),fo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as yr}from"react/jsx-runtime";import"react";var kt=()=>yr("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:yr("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 aa}from"react/jsx-runtime";import ca from"bson-objectid";import"react";import{DecoratorBlockNode as Ds}from"@lexical/react/LexicalDecoratorBlockNode.js";import As from"bson-objectid";var Ze=class extends Ds{__fields;constructor({fields:e,format:o,key:r}){super(o,r),this.__fields=e}static clone(e){return new this({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=Fs(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}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e){let o=this.getWritable();o.__fields=e}};function Fs(t){return new Ze({fields:{...t,id:t?.id||new As.default().toHexString()}})}import{jsx as X,jsxs as Lt,Fragment as Gs}from"react/jsx-runtime";import{Button as Ar,Collapsible as Us,Drawer as Ws,EditDepthProvider as Vs,ErrorPill as Ks,Form as zs,formatDrawerSlug as Zs,FormSubmit as Xs,Pill as Ys,RenderFields as Js,SectionTitle as qs,useDocumentInfo as Fr,useEditDepth as Qs,useFormSubmitted as ea,useServerFunctions as ta,useTranslation as oa}from"@payloadcms/ui";import{abortAndIgnore as ho}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as ra,reduceFieldsToValues as Or}from"payload/shared";import Xe,{useCallback as go,useEffect as $r,useMemo as Ye,useRef as na}from"react";import{useLexicalComposerContext as ia}from"@lexical/react/LexicalComposerContext";import{getTranslation as la}from"@payloadcms/translations";import{$getNodeByKey as Co}from"lexical";import{v4 as sa}from"uuid";import{c as Os}from"react/compiler-runtime";import{jsx as Nt,jsxs as $s}from"react/jsx-runtime";import{RenderFields as Ps,useFormSubmitted as Bs}from"@payloadcms/ui";import Hs,{createContext as js}from"react";var vr=js({initialState:!1}),ve=()=>Hs.useContext(vr),Mr=t=>{let e=Os(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:s,initialState:a,nodeKey:d,RemoveButton:c}=t,m=Bs()&&l>0,p,f;e[0]!==r||e[1]!==l||e[2]!==m?(f=w=>Nt(r,{editButton:w.editButton,errorCount:l,fieldHasErrors:m,Label:w.Label,removeButton:w.removeButton,children:w.children}),e[0]=r,e[1]=l,e[2]=m,e[3]=f):f=e[3],p=f;let h=p,C;return e[4]!==n||e[5]!==h||e[6]!==i||e[7]!==a||e[8]!==d||e[9]!==c||e[10]!==o||e[11]!==s?(C=n?$s(vr.Provider,{value:{BlockCollapsible:h,EditButton:i,initialState:a,nodeKey:d,RemoveButton:c},children:[n,Nt(o,{})]}):Nt(h,{children:Nt(Ps,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=n,e[5]=h,e[6]=i,e[7]=a,e[8]=d,e[9]=c,e[10]=o,e[11]=s,e[12]=C):C=e[12],C};function Dr({fields:t}){for(let e in t){let o=t[e];Array.isArray(o.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var re="lexical-block",Pr=t=>{let{formData:e,nodeKey:o}=t,r=ea(),{id:n,collectionSlug:i,globalSlug:l}=Fr(),{fieldProps:{featureClientSchemaMap:s,field:a,initialLexicalFormState:d,permissions:c,readOnly:u,schemaPath:m},uuid:p}=B(),f=na(new AbortController),h=Qs(),[C,w]=Xe.useState(0),v=Zs({slug:`lexical-blocks-create-${p}-${e.id}`,depth:h}),{toggleDrawer:D}=ce(v),{getDocPreferences:x,setDocFieldPreferences:E}=Fr(),[g]=ia(),{getFormState:_}=ta(),N=`${m}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}.fields`,[k,R]=Xe.useState(d?.[e.id]?.formState?{...d?.[e.id]?.formState,blockName:{initialValue:e.blockName,passesCondition:!0,valid:!0,value:e.blockName}}:!1),[S,b]=Xe.useState(k?._components?.customComponents?.BlockLabel),[T,I]=Xe.useState(k?._components?.customComponents?.Block);$r(()=>{let j=new AbortController;return e&&!k&&(async()=>{let{state:K}=await _({id:n,collectionSlug:i,data:e,docPermissions:{fields:!0},docPreferences:await x(),globalSlug:l,operation:"update",renderAllFields:!0,schemaPath:N,signal:j.signal});K&&(K.blockName={initialValue:e.blockName,passesCondition:!0,valid:!0,value:e.blockName},R(K),b(K._components?.customComponents?.BlockLabel),I(K._components?.customComponents?.Block))})(),()=>{ho(j)}},[_,N,n,e,k,i,l,x]);let[L,A]=Xe.useState(d?.[e.id]?.collapsed??!1),M=`${m}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}`,$=s.blocks[M][0].blocks[0],{i18n:W,t:J}=oa(),U=go(async({formState:j,submit:te})=>{ho(f.current);let K=new AbortController;f.current=K;let{state:z}=await _({id:n,collectionSlug:i,docPermissions:{fields:!0},docPreferences:await x(),formState:j,globalSlug:l,operation:"update",renderAllFields:!!te,schemaPath:N,signal:K.signal});if(!z)return j;z.blockName=j.blockName;let oe=Or(Dr({fields:ra(z)}),!0);if(setTimeout(()=>{g.update(()=>{let xe=Co(o);if(xe&&Rt(xe)){let we=oe;we.blockType=e.blockType,xe.setFields(we)}})},0),te){b(z._components?.customComponents?.BlockLabel),I(z._components?.customComponents?.Block);let xe=0;for(let we of Object.values(z))we?.valid===!1&&xe++;w(xe)}return z},[_,n,i,x,l,N,e.blockType,g,o]);$r(()=>()=>{ho(f.current)},[]);let H=go(()=>{g.update(()=>{Co(o)?.remove()})},[g,o]),ee=$?.labels?.singular?la($.labels.singular,W):$?.slug,pt=go(j=>{x().then(te=>{let z=te?.fields?.[a.name]?.collapsed,oe=z&&z?.length?z:[];j?oe.includes(e.id)||oe.push(e.id):oe.includes(e.id)&&oe.splice(oe.indexOf(e.id),1),E(a.name,{collapsed:oe,hello:"hi"})})},[x,a.name,E,e.id]),ie=Ye(()=>()=>X(Ar,{buttonStyle:"icon-label",className:`${re}__editButton`,disabled:u,el:"button",icon:"edit",onClick:j=>(j.preventDefault(),j.stopPropagation(),D(),!1),onMouseDown:j=>{j.preventDefault()},round:!0,size:"small",tooltip:J("lexical:blocks:inlineBlocks:edit",{label:ee})}),[ee,u,J,D]),ye=Ye(()=>()=>X(Ar,{buttonStyle:"icon-label",className:`${re}__removeButton`,disabled:a?.admin?.readOnly||!1,icon:"x",onClick:j=>{j.preventDefault(),H()},round:!0,tooltip:"Remove Block"}),[a?.admin?.readOnly,H]),ft=Ye(()=>({children:j,editButton:te,errorCount:K,fieldHasErrors:z,Label:oe,removeButton:xe})=>X("div",{className:re+" "+re+"-"+e.blockType,children:X(Us,{className:[`${re}__row`,z?`${re}__row--has-errors`:`${re}__row--no-errors`].join(" "),collapsibleStyle:z?"error":"default",header:Lt("div",{className:`${re}__block-header`,children:[oe??S?oe??S:Lt("div",{children:[X(Ys,{className:`${re}__block-pill ${re}__block-pill-${e?.blockType}`,pillStyle:"white",children:ee}),X(qs,{path:"blockName",readOnly:a?.admin?.readOnly||!1}),z&&X(Ks,{count:K??0,i18n:W,withMessage:!0})]}),Lt("div",{children:[T&&te!==!1||!T&&te?X(ie,{}):null,xe!==!1&&g.isEditable()?X(ye,{}):null]})]}),isCollapsed:L,onToggle:we=>{pt(we),A(we)},children:j},0)}),[T,S,ie,ye,ee,g,e.blockType,W,L,pt,a?.admin?.readOnly]),ht=Ye(()=>()=>X(Vs,{children:X(Ws,{className:"",slug:v,title:J(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:ee??J("lexical:blocks:inlineBlocks:label")}),children:k?Lt(Gs,{children:[X(Js,{fields:$.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:N,permissions:c,readOnly:!1}),X(Xs,{programmaticSubmit:!0,children:J("fields:saveChanges")})]}):null})}),[k,v,ee,J,$.fields,N,c]);return Ye(()=>k?X(zs,{beforeSubmit:[async({formState:j})=>await U({formState:j,submit:!0})],fields:$.fields,initialState:k,onChange:[U],onSubmit:j=>{let te=Or(j);te.blockType=e.blockType,g.update(()=>{let K=Co(o);K&&Rt(K)&&K.setFields(te)}),D()},submitted:r,uuid:sa(),children:X(Mr,{baseClass:re,BlockDrawer:ht,Collapsible:ft,CustomBlock:T,EditButton:ie,errorCount:C,formSchema:$.fields,initialState:k,nodeKey:o,RemoveButton:ye})}):null,[ft,ht,T,ye,ie,g,C,D,$.fields,k,o,U,r])};var ue=class extends Ze{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=St(e.fields);return o.setFormat(e.format),o}decorate(e,o){return aa(Pr,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function St(t){return new ue({fields:{...t,id:t?.id||new ca.default().toHexString()}})}function Rt(t){return t instanceof ue}import{createCommand as Br}from"lexical";var Je=Br("INSERT_BLOCK_COMMAND"),qe=Br("INSERT_INLINE_BLOCK_COMMAND");import{c as ua}from"react/compiler-runtime";import{useLexicalComposerContext as da}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as ma,$wrapNodeInElement as pa,mergeRegister as fa}from"@lexical/utils";import{formatDrawerSlug as ha,useEditDepth as ga}from"@payloadcms/ui";import{$createParagraphNode as Ca,$getNodeByKey as xa,$getPreviousSelection as ba,$getSelection as _a,$insertNodes as Ta,$isParagraphNode as Hr,$isRangeSelection as Ea,$isRootOrShadowRoot as wa,COMMAND_PRIORITY_EDITOR as jr}from"lexical";import{useEffect as ka,useState as Na}from"react";var Gr=()=>{let t=ua(10),[e]=da(),[o,r]=Na(null),{uuid:n}=B(),i=ga(),l="lexical-inlineBlocks-create-"+n,s;t[0]!==l||t[1]!==i?(s=ha({slug:l,depth:i}),t[0]=l,t[1]=i,t[2]=s):s=t[2];let a=s,{toggleDrawer:d}=ce(a,!0),c;t[3]!==e||t[4]!==o?(c=()=>{if(!e.hasNodes([ue]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return fa(e.registerCommand(Je,m=>(e.update(()=>{let p=_a()||ba();if(Ea(p)){let f=St(m);ma(f);let{focus:h}=p,C=h.getNode();Hr(C)&&C.getTextContentSize()===0&&C.getParentOrThrow().getChildren().filter(w=>Hr(w)).length>1&&C.remove()}}),!0),jr),e.registerCommand(qe,m=>{if(o){let f=xa(o);return!f||!io(f)?!1:(f.setFields(m),r(null),!0)}let p=no(m);return Ta([p]),wa(p.getParentOrThrow())&&pa(p,Ca).selectEnd(),!0},jr))},t[3]=e,t[4]=o,t[5]=c):c=t[5];let u;return t[6]!==e||t[7]!==o||t[8]!==d?(u=[e,o,d],t[6]=e,t[7]=o,t[8]=d,t[9]=u):u=t[9],ka(c,u),null};var La=y(({featureClientSchemaMap:t,props:e,schemaPath:o})=>{let r=`${o}.lexical_internal_feature.blocks.lexical_blocks`,n=`${o}.lexical_internal_feature.blocks.lexical_inline_blocks`,i=t.blocks,l=Object.entries(i).filter(([c])=>c.startsWith(r+".")&&!c.replace(r+".","").includes(".")).map(([c,u])=>u[0]),s=Object.entries(i).filter(([c])=>c.startsWith(n+".")&&!c.replace(n+".","").includes(".")).map(([c,u])=>u[0]),a=l.map(c=>c.blocks[0]),d=s.map(c=>c.blocks[0]);return{nodes:[ue,ro],plugins:[{Component:Gr,position:"normal"}],sanitizedClientFeatureProps:e,slashMenu:{groups:[a?.length?{items:a.map(c=>({Icon:wt,key:"block-"+c.slug,keywords:["block","blocks",c.slug],label:({i18n:u})=>c?.labels?.singular?It(c.labels.singular,u):c?.slug,onSelect:({editor:u})=>{u.dispatchCommand(Je,{blockName:"",blockType:c.slug})}})),key:"blocks",label:({i18n:c})=>c.t("lexical:blocks:label")}:null,d?.length?{items:d.map(c=>({Icon:kt,key:"inlineBlocks-"+c.slug,keywords:["inlineBlock","inline block",c.slug],label:({i18n:u})=>c?.labels?.singular?It(c.labels.singular,u):c?.slug,onSelect:({editor:u})=>{u.dispatchCommand(qe,{blockName:"",blockType:c.slug})}})),key:"inlineBlocks",label:({i18n:c})=>c.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[a.length?{type:"dropdown",ChildComponent:wt,items:a.map((c,u)=>({ChildComponent:wt,isActive:void 0,key:"block-"+c.slug,label:({i18n:m})=>c?.labels?.singular?It(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Je,{blockName:"",blockType:c.slug})},order:u})),key:"blocks",order:20}:null,d?.length?{type:"dropdown",ChildComponent:kt,items:d.map((c,u)=>({ChildComponent:kt,isActive:void 0,key:"inlineBlock-"+c.slug,label:({i18n:m})=>c?.labels?.singular?It(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(qe,{blockName:"",blockType:c.slug})},order:u})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as Ra}from"react/compiler-runtime";import{jsx as Ne,jsxs as _o}from"react/jsx-runtime";import{useLexicalComposerContext as Sa}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Ia,$createTextNode as ya,$getRoot as va}from"lexical";import*as Kr from"react";import{useCallback as ke,useEffect as xo,useLayoutEffect as Ur,useRef as bo,useState as yt}from"react";var Ma=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)},Da=(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)},Aa=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, {
|
|
@@ -53,7 +53,7 @@ export const InlineBlockComponent = props => {
|
|
|
53
53
|
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
54
54
|
initialState?.['_components']?.customComponents?.Block);
|
|
55
55
|
const drawerSlug = formatDrawerSlug({
|
|
56
|
-
slug: `lexical-inlineBlocks-create
|
|
56
|
+
slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,
|
|
57
57
|
depth: editDepth
|
|
58
58
|
});
|
|
59
59
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","createContext","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","reduceFieldsToValues","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","useContext","InlineBlockComponent","props","formData","nodeKey","editor","i18n","t","fieldProps","featureClientSchemaMap","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","getFormState","editDepth","setInitialState","useState","id","formState","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","isSelected","setSelected","clearSelection","collectionSlug","getDocPreferences","globalSlug","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blocks","removeInlineBlock","update","remove","$onDelete","event","deleteSelection","preventDefault","getNodes","forEach","node","onClick","payload","target","current","contains","shiftKey","registerCommand","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","fields","docPreferences","operation","renderAllFields","signal","onChange","prevFormState","submit","controller","onFormSubmit","newData","setFields","RemoveButton","_jsx","buttonStyle","className","disabled","icon","e","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","ref","Label","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","programmaticSubmit","Provider","value","height","width","isEditable"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\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 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 { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\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,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\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 = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\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 globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\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 schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\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 formState: prevFormState,\n globalSlug,\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 [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\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) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\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 }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\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) => {\n onFormSubmit(formState)\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"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC9E,MAAMC,SAAA,GAAY;AAIlB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,uBAAuB,QAAQ;AACxC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SACEC,aAAa,EACbC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb;AACP,SAASC,oBAAoB,QAAQ;AAIrC,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAgBnC,MAAMC,2BAAA,gBAA8BpC,aAAA,CAA+C;EACjFqC,YAAA,EAAc;AAChB;AAEA,OAAO,MAAMC,8BAAA,GAAiCA,CAAA;EAAA,OAAMvC,KAAA,CAAAwC,UAAA,CAAAH,2BAAiB;AAAA;AAErE,OAAO,MAAMI,oBAAA,GAAyCC,KAAA;EACpD,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGF,KAAA;EAC9B,MAAM,CAACG,MAAA,CAAO,GAAGtC,yBAAA;EACjB,MAAM;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AA;QACCoH,SAAA,EAAW;QACX3D,IAAA,EAAMD,UAAA;QACNiF,KAAA,EAAOtG,CAAA,CAAE,+BAA+BJ,QAAA,EAAUgB,EAAA,GAAK,SAAS,UAAU,EAAE;UAC1E4E,KAAA,EAAOjC,gBAAA,IAAoBvD,CAAA,CAAE;QAC/B;kBAECT,YAAA,gBACC2G,KAAA,CAAAK,SAAA;kCACExB,IAAA,CAAC7G,YAAA;YACCgG,MAAA,EAAQ9B,WAAA,CAAY8B,MAAM;YAC1BsC,WAAW;YACXC,eAAA,EAAgB;YAChBC,UAAA,EAAW,GAAG;YAAA;;YACdC,gBAAA,EAAkB/C,gBAAA;YAClBxD,WAAA,EAAaA,WAAA;YACbC,QAAA,EAAU;2BAEZ0E,IAAA,CAAC9G,UAAA;YAAW2I,kBAAA,EAAoB;sBAAO5G,CAAA,CAAE;;aAEzC;;QAGPkB,WAAA,gBACC6D,IAAA,CAACzF,2BAAA,CAA4BuH,QAAQ;MACnCC,KAAA,EAAO;QACLrB,UAAA;QACAlG,YAAA;QACAoG,oBAAA;QACAM,KAAA;QACApG,OAAA;QACAiF;MACF;gBAEC5D;sBAGHgF,KAAA,CAACP,oBAAA;iBACEpG,YAAA,gBAAewF,IAAA,CAACkB,KAAA,qBAAWlB,IAAA,CAAC5G,aAAA;QAAc4I,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DlH,MAAA,CAAOmH,UAAU,kBAChBf,KAAA,CAAC;QAAIjB,SAAA,EAAW,GAAG1H,SAAA,WAAoB;gCACrCwH,IAAA,CAACU,UAAA,O,aACDV,IAAA,CAACD,YAAA;WAED;;;AAKd","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","createContext","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","reduceFieldsToValues","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","useContext","InlineBlockComponent","props","formData","nodeKey","editor","i18n","t","fieldProps","featureClientSchemaMap","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","getFormState","editDepth","setInitialState","useState","id","formState","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","isSelected","setSelected","clearSelection","collectionSlug","getDocPreferences","globalSlug","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blocks","removeInlineBlock","update","remove","$onDelete","event","deleteSelection","preventDefault","getNodes","forEach","node","onClick","payload","target","current","contains","shiftKey","registerCommand","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","fields","docPreferences","operation","renderAllFields","signal","onChange","prevFormState","submit","controller","onFormSubmit","newData","setFields","RemoveButton","_jsx","buttonStyle","className","disabled","icon","e","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","ref","Label","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","programmaticSubmit","Provider","value","height","width","isEditable"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\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 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 { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\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 [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\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 = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\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 globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\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 schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\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 formState: prevFormState,\n globalSlug,\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 [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\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) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\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 }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\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) => {\n onFormSubmit(formState)\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>\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OjC,gBAAA,IAAoBvD,CAAA,CAAE;QAC/B;kBAECT,YAAA,gBACC2G,KAAA,CAAAK,SAAA;kCACExB,IAAA,CAAC7G,YAAA;YACCgG,MAAA,EAAQ9B,WAAA,CAAY8B,MAAM;YAC1BsC,WAAW;YACXC,eAAA,EAAgB;YAChBC,UAAA,EAAW,GAAG;YAAA;;YACdC,gBAAA,EAAkB/C,gBAAA;YAClBxD,WAAA,EAAaA,WAAA;YACbC,QAAA,EAAU;2BAEZ0E,IAAA,CAAC9G,UAAA;YAAW2I,kBAAA,EAAoB;sBAAO5G,CAAA,CAAE;;aAEzC;;QAGPkB,WAAA,gBACC6D,IAAA,CAACzF,2BAAA,CAA4BuH,QAAQ;MACnCC,KAAA,EAAO;QACLrB,UAAA;QACAlG,YAAA;QACAoG,oBAAA;QACAM,KAAA;QACApG,OAAA;QACAiF;MACF;gBAEC5D;sBAGHgF,KAAA,CAACP,oBAAA;iBACEpG,YAAA,gBAAewF,IAAA,CAACkB,KAAA,qBAAWlB,IAAA,CAAC5G,aAAA;QAAc4I,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DlH,MAAA,CAAOmH,UAAU,kBAChBf,KAAA,CAAC;QAAIjB,SAAA,EAAW,GAAG1H,SAAA,WAAoB;gCACrCwH,IAAA,CAACU,UAAA,O,aACDV,IAAA,CAACD,YAAA;WAED;;;AAKd","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultSanitizedEditorConfig.d.ts","sourceRoot":"","sources":["../src/getDefaultSanitizedEditorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getDefaultSanitizedEditorConfig.d.ts","sourceRoot":"","sources":["../src/getDefaultSanitizedEditorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAgB7D,eAAO,MAAM,+BAA+B,SAAgB;IAC1D,MAAM,EAAE,eAAe,CAAA;IACvB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,KAAG,OAAO,CAAC,2BAA2B,CAoBtC,CAAA"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { cache } from 'react';
|
|
2
1
|
import { defaultEditorConfig } from './lexical/config/server/default.js';
|
|
3
2
|
import { sanitizeServerEditorConfig } from './lexical/config/server/sanitize.js';
|
|
4
3
|
let cachedDefaultSanitizedServerEditorConfig = global._payload_lexical_defaultSanitizedServerEditorConfig;
|
|
5
4
|
if (!cachedDefaultSanitizedServerEditorConfig) {
|
|
6
5
|
cachedDefaultSanitizedServerEditorConfig = global._payload_lexical_defaultSanitizedServerEditorConfig = null;
|
|
7
6
|
}
|
|
8
|
-
export const getDefaultSanitizedEditorConfig =
|
|
7
|
+
export const getDefaultSanitizedEditorConfig = async args => {
|
|
9
8
|
const {
|
|
10
9
|
config,
|
|
11
10
|
parentIsLocalized
|
|
@@ -18,5 +17,5 @@ export const getDefaultSanitizedEditorConfig = cache(async args => {
|
|
|
18
17
|
cachedDefaultSanitizedServerEditorConfig = await cachedDefaultSanitizedServerEditorConfig;
|
|
19
18
|
global.payload_lexical_defaultSanitizedServerEditorConfig = cachedDefaultSanitizedServerEditorConfig;
|
|
20
19
|
return cachedDefaultSanitizedServerEditorConfig;
|
|
21
|
-
}
|
|
20
|
+
};
|
|
22
21
|
//# sourceMappingURL=getDefaultSanitizedEditorConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultSanitizedEditorConfig.js","names":["
|
|
1
|
+
{"version":3,"file":"getDefaultSanitizedEditorConfig.js","names":["defaultEditorConfig","sanitizeServerEditorConfig","cachedDefaultSanitizedServerEditorConfig","global","_payload_lexical_defaultSanitizedServerEditorConfig","getDefaultSanitizedEditorConfig","args","config","parentIsLocalized","payload_lexical_defaultSanitizedServerEditorConfig"],"sources":["../src/getDefaultSanitizedEditorConfig.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { type SanitizedServerEditorConfig } from './index.js'\nimport { defaultEditorConfig } from './lexical/config/server/default.js'\nimport { sanitizeServerEditorConfig } from './lexical/config/server/sanitize.js'\n\nlet cachedDefaultSanitizedServerEditorConfig:\n | null\n | Promise<SanitizedServerEditorConfig>\n | SanitizedServerEditorConfig = (global as any)\n ._payload_lexical_defaultSanitizedServerEditorConfig\n\nif (!cachedDefaultSanitizedServerEditorConfig) {\n cachedDefaultSanitizedServerEditorConfig = (\n global as any\n )._payload_lexical_defaultSanitizedServerEditorConfig = null\n}\n\nexport const getDefaultSanitizedEditorConfig = async (args: {\n config: SanitizedConfig\n parentIsLocalized: boolean\n}): Promise<SanitizedServerEditorConfig> => {\n const { config, parentIsLocalized } = args\n\n if (cachedDefaultSanitizedServerEditorConfig) {\n return await cachedDefaultSanitizedServerEditorConfig\n }\n\n cachedDefaultSanitizedServerEditorConfig = sanitizeServerEditorConfig(\n defaultEditorConfig,\n config,\n parentIsLocalized,\n )\n ;(global as any).payload_lexical_defaultSanitizedServerEditorConfig =\n cachedDefaultSanitizedServerEditorConfig\n\n cachedDefaultSanitizedServerEditorConfig = await cachedDefaultSanitizedServerEditorConfig\n ;(global as any).payload_lexical_defaultSanitizedServerEditorConfig =\n cachedDefaultSanitizedServerEditorConfig\n\n return cachedDefaultSanitizedServerEditorConfig\n}\n"],"mappings":"AAGA,SAASA,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAE3C,IAAIC,wCAAA,GAG8BC,MAAC,CAChCC,mDAAmD;AAEtD,IAAI,CAACF,wCAAA,EAA0C;EAC7CA,wCAAA,GAA2CC,MACzC,CACAC,mDAAmD,GAAG;AAC1D;AAEA,OAAO,MAAMC,+BAAA,GAAkC,MAAOC,IAAA;EAIpD,MAAM;IAAEC,MAAM;IAAEC;EAAiB,CAAE,GAAGF,IAAA;EAEtC,IAAIJ,wCAAA,EAA0C;IAC5C,OAAO,MAAMA,wCAAA;EACf;EAEAA,wCAAA,GAA2CD,0BAAA,CACzCD,mBAAA,EACAO,MAAA,EACAC,iBAAA;EAEAL,MAAA,CAAeM,kDAAkD,GACjEP,wCAAA;EAEFA,wCAAA,GAA2C,MAAMA,wCAAA;EAC/CC,MAAA,CAAeM,kDAAkD,GACjEP,wCAAA;EAEF,OAAOA,wCAAA;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3-canary.519752f",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -345,8 +345,8 @@
|
|
|
345
345
|
"react-error-boundary": "4.1.2",
|
|
346
346
|
"ts-essentials": "10.0.3",
|
|
347
347
|
"uuid": "10.0.0",
|
|
348
|
-
"@payloadcms/
|
|
349
|
-
"@payloadcms/
|
|
348
|
+
"@payloadcms/ui": "3.2.3-canary.519752f",
|
|
349
|
+
"@payloadcms/translations": "3.2.3-canary.519752f"
|
|
350
350
|
},
|
|
351
351
|
"devDependencies": {
|
|
352
352
|
"@babel/cli": "^7.24.5",
|
|
@@ -366,8 +366,8 @@
|
|
|
366
366
|
"esbuild-sass-plugin": "3.3.1",
|
|
367
367
|
"eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
368
368
|
"swc-plugin-transform-remove-imports": "1.15.0",
|
|
369
|
-
"
|
|
370
|
-
"
|
|
369
|
+
"payload": "3.2.3-canary.519752f",
|
|
370
|
+
"@payloadcms/eslint-config": "3.0.0"
|
|
371
371
|
},
|
|
372
372
|
"peerDependencies": {
|
|
373
373
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
@@ -384,8 +384,8 @@
|
|
|
384
384
|
"lexical": "0.20.0",
|
|
385
385
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
386
386
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
387
|
-
"@payloadcms/next": "3.2.
|
|
388
|
-
"payload": "3.2.
|
|
387
|
+
"@payloadcms/next": "3.2.3-canary.519752f",
|
|
388
|
+
"payload": "3.2.3-canary.519752f"
|
|
389
389
|
},
|
|
390
390
|
"engines": {
|
|
391
391
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as Z}from"./chunk-2CYU43GM.js";import{b as X}from"./chunk-CUIBIFW2.js";import{jsx as i,jsxs as I,Fragment as he}from"react/jsx-runtime";import w,{createContext as _e,useCallback as k,useEffect as T,useMemo as N,useRef as ee}from"react";import{useLexicalComposerContext as Be}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as De}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as ye}from"@lexical/utils";import{getTranslation as te}from"@payloadcms/translations";import{Button as ne,Drawer as Ie,EditDepthProvider as Ne,Form as we,formatDrawerSlug as ve,FormSubmit as Fe,RenderFields as Oe,ShimmerEffect as Ee,useDocumentInfo as Pe,useEditDepth as $e,useServerFunctions as Me,useTranslation as Le}from"@payloadcms/ui";import{abortAndIgnore as A}from"@payloadcms/ui/shared";import{$getNodeByKey as oe,$getSelection as Te,$isNodeSelection as Ae,CLICK_COMMAND as Re,COMMAND_PRIORITY_LOW as R,KEY_BACKSPACE_COMMAND as je,KEY_DELETE_COMMAND as Ke}from"lexical";import{reduceFieldsToValues as Je}from"payload/shared";import{v4 as ze}from"uuid";import{jsx as ke}from"react/jsx-runtime";import ge from"bson-objectid";import Ce from"react";import pe from"bson-objectid";import{DecoratorNode as fe}from"lexical";var b=class extends fe{__fields;constructor({fields:e,key:n}){super(n),this.__fields=e}static clone(e){return new this({fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return be(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,n){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let n=document.createTextNode(this.getTextContent());return e.append(n),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e){let n=this.getWritable();n.__fields=e}updateDOM(){return!1}};function be(r){return new b({fields:{...r,id:r?.id||new pe.default().toHexString()}})}var xe=Ce.lazy(()=>import("./componentInline-GXYBWVCR.js").then(r=>({default:r.InlineBlockComponent}))),y=class extends b{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return Se(e.fields)}decorate(e,n){return ke(xe,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Se(r){return new y({fields:{...r,id:r?.id||new ge.default().toHexString()}})}function L(r){return r instanceof y}var m="inline-block",re=_e({initialState:!1}),ft=()=>w.useContext(re),bt=r=>{let{formData:e,nodeKey:n}=r,[s]=Be(),{i18n:v,t:d}=Le(),{fieldProps:{featureClientSchemaMap:le,initialLexicalFormState:ie,permissions:se,readOnly:g,schemaPath:j},uuid:ce}=X(),{getFormState:C}=Me(),ae=$e(),[c,ue]=w.useState(ie?.[e.id]?.formState),[F,K]=w.useState(c?._components?.customComponents?.BlockLabel),[J,z]=w.useState(c?._components?.customComponents?.Block),Y=ve({slug:"lexical-inlineBlocks-create-"+ce,depth:ae}),{toggleDrawer:O}=Z(Y,!0),E=ee(null),[a,x,P]=De(n),{id:S,collectionSlug:h,getDocPreferences:_,globalSlug:B}=Pe(),de=`${j}.lexical_internal_feature.blocks.lexical_inline_blocks.${e.blockType}`,u=le.blocks[de][0].blocks[0],H=k(()=>{s.update(()=>{oe(n)?.remove()})},[s,n]),$=k(t=>{let l=Te();return a&&Ae(l)&&(t.preventDefault(),s.update(()=>{l.getNodes().forEach(o=>{L(o)&&o.remove()})})),!1},[s,a]),V=k(t=>{let l=t;return l.target===E.current||E.current?.contains(l.target)?(l.shiftKey?x(!a):a||(P(),x(!0)),!0):!1},[a,x,P]);T(()=>ye(s.registerCommand(Re,V,R),s.registerCommand(Ke,$,R),s.registerCommand(je,$,R)),[P,s,a,n,$,x,V]);let p=u?.labels?.singular?te(u.labels.singular,v):u?.slug,M=ee(new AbortController),f=`${j}.lexical_internal_feature.blocks.lexical_inline_blocks.${u?.slug}.fields`;T(()=>{let t=new AbortController;return e&&!c&&(async()=>{let{state:o}=await C({id:S,collectionSlug:h,data:e,docPermissions:{fields:!0},docPreferences:await _(),globalSlug:B,operation:"update",renderAllFields:!0,schemaPath:f,signal:t.signal});o&&(ue(o),K(o._components?.customComponents?.BlockLabel),z(o._components?.customComponents?.Block))})(),()=>{A(t)}},[C,f,S,e,c,h,B,_]);let W=k(async({formState:t,submit:l})=>{A(M.current);let o=new AbortController;M.current=o;let{state:D}=await C({id:S,collectionSlug:h,docPermissions:{fields:!0},docPreferences:await _(),formState:t,globalSlug:B,operation:"update",renderAllFields:!!l,schemaPath:f,signal:o.signal});return D?(l&&(K(D._components?.customComponents?.BlockLabel),z(D._components?.customComponents?.Block)),D):t},[C,S,h,_,B,f]);T(()=>()=>{A(M.current)},[]);let me=k(t=>{let l=Je(t);l.blockType=e.blockType,s.update(()=>{let o=oe(n);o&&L(o)&&o.setFields(l)})},[s,n,e]),q=N(()=>()=>i(ne,{buttonStyle:"icon-label",className:`${m}__removeButton`,disabled:g,icon:"x",onClick:t=>{t.preventDefault(),H()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:remove",{label:p})}),[p,g,H,d]),G=N(()=>()=>i(ne,{buttonStyle:"icon-label",className:`${m}__editButton`,disabled:g,el:"button",icon:"edit",onClick:()=>{O()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:edit",{label:p})}),[p,g,d,O]),Q=N(()=>({children:t})=>i("div",{className:[m,m+"-"+e.blockType,a&&`${m}--selected`].filter(Boolean).join(" "),ref:E,children:t}),[e.blockType,a]),U=N(()=>F?()=>F:()=>i("div",{children:te(u.labels.singular,v)}),[F,u.labels,v]);return I(we,{beforeSubmit:[async({formState:t})=>await W({formState:t,submit:!0})],disableValidationOnSubmit:!0,fields:u.fields,initialState:c||{},onChange:[W],onSubmit:t=>{me(t),O()},uuid:ze(),children:[i(Ne,{children:i(Ie,{className:"",slug:Y,title:d(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:p??d("lexical:blocks:inlineBlocks:label")}),children:c?I(he,{children:[i(Oe,{fields:u.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:f,permissions:se,readOnly:!1}),i(Fe,{programmaticSubmit:!0,children:d("fields:saveChanges")})]}):null})}),J?i(re.Provider,{value:{EditButton:G,initialState:c,InlineBlockContainer:Q,Label:U,nodeKey:n,RemoveButton:q},children:J}):I(Q,{children:[c?i(U,{}):i(Ee,{height:"15px",width:"40px"}),s.isEditable()?I("div",{className:`${m}__actions`,children:[i(G,{}),i(q,{})]}):null]})]})};export{ft as a,bt as b,y as c,Se as d,L as e};
|
|
2
|
-
//# sourceMappingURL=chunk-WHL7AV5U.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\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 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 { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\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,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\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 = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\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 globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\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 schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\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 formState: prevFormState,\n globalSlug,\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 [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\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) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\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 }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\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) => {\n onFormSubmit(formState)\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 clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n 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 __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static 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 createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n 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 exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const writable = this.getWritable()\n writable.__fields = fields\n }\n\n 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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AA,EAAWnB,EAACsC,GAAA,CAAcC,OAAO,OAAOC,MAAM,SAC9DhJ,EAAOiJ,WAAU,EAChBrB,EAAC,MAAA,CAAIjB,UAAW,GAAGtH,CAAA,sBACjBmH,EAACW,EAAA,CAAA,CAAA,EACDX,EAACF,EAAA,CAAA,CAAA,CAAA,IAED,IAAA,MAKd",
|
|
6
|
-
"names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "useLexicalNodeSelection", "mergeRegister", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "$getSelection", "$isNodeSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "React", "ObjectID", "DecoratorNode", "ServerInlineBlockNode", "__fields", "constructor", "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", "getLatest", "setFields", "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", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "useContext", "InlineBlockComponent", "props", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "permissions", "readOnly", "schemaPath", "uuid", "uuidFromContext", "useEditorConfigContext", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "setInitialState", "useState", "id", "formState", "CustomLabel", "setCustomLabel", "customComponents", "BlockLabel", "CustomBlock", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "useRef", "isSelected", "setSelected", "clearSelection", "useLexicalNodeSelection", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "componentMapRenderedBlockPath", "blockType", "clientBlock", "blocks", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "$onDelete", "event", "deleteSelection", "$getSelection", "$isNodeSelection", "preventDefault", "getNodes", "forEach", "node", "$isInlineBlockNode", "onClick", "payload", "target", "current", "contains", "shiftKey", "useEffect", "mergeRegister", "registerCommand", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_DELETE_COMMAND", "KEY_BACKSPACE_COMMAND", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "fields", "docPreferences", "operation", "renderAllFields", "signal", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "onFormSubmit", "newData", "reduceFieldsToValues", "setFields", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "e", "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
|
-
}
|
/package/dist/exports/client/{componentInline-GXYBWVCR.js.map → componentInline-OK3ZQ6YQ.js.map}
RENAMED
|
File without changes
|