@payloadcms/richtext-lexical 3.77.0-canary.3 → 3.77.0-internal.0b6b4e4
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/Field-4IVB5SEE.js +2 -0
- package/dist/exports/client/Field-4IVB5SEE.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-CRVQNLN7.js +2 -0
- package/dist/exports/client/chunk-CRVQNLN7.js.map +7 -0
- package/dist/exports/client/chunk-UOYS7JHZ.js +12 -0
- package/dist/exports/client/chunk-UOYS7JHZ.js.map +7 -0
- package/dist/exports/client/componentInline-22F6QL2B.js +2 -0
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +23 -23
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/client/internal-client.d.ts +3 -0
- package/dist/exports/client/internal-client.d.ts.map +1 -0
- package/dist/exports/react/index.d.ts +3 -1
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js +1 -0
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.d.ts +7 -4
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +9 -8
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +20 -4
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +40 -11
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +8 -14
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +38 -9
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +4 -2
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +3 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +4 -2
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +3 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +6 -20
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +7 -5
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +17 -2
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +124 -4
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +15 -6
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RichTextViewProvider.d.ts +85 -0
- package/dist/field/RichTextViewProvider.d.ts.map +1 -0
- package/dist/field/RichTextViewProvider.js +91 -0
- package/dist/field/RichTextViewProvider.js.map +1 -0
- package/dist/field/ViewSelector.d.ts +4 -0
- package/dist/field/ViewSelector.d.ts.map +1 -0
- package/dist/field/ViewSelector.js +89 -0
- package/dist/field/ViewSelector.js.map +1 -0
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts +1 -0
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +64 -35
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +12 -0
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +2 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +12 -3
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +3 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +4 -0
- package/dist/lexical/config/types.d.ts.map +1 -1
- package/dist/lexical/config/types.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +12 -2
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +213 -2
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +48 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +14 -1
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/types.d.ts +329 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +1 -0
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +6 -1
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +10 -4
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +11 -6
- package/dist/exports/client/Field-HJGV32KA.js +0 -2
- package/dist/exports/client/Field-HJGV32KA.js.map +0 -7
- package/dist/exports/client/chunk-2S5Q7QYO.js +0 -2
- package/dist/exports/client/chunk-2S5Q7QYO.js.map +0 -7
- package/dist/exports/client/chunk-EZX4YW7S.js +0 -12
- package/dist/exports/client/chunk-EZX4YW7S.js.map +0 -7
- package/dist/exports/client/componentInline-NL25DNZ5.js +0 -2
- /package/dist/exports/client/{componentInline-NL25DNZ5.js.map → componentInline-22F6QL2B.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as ae}from"./chunk-INBEEENE.js";import{b as ce}from"./chunk-BZZVLW4U.js";import{jsx as s,jsxs as h,Fragment as Te}from"react/jsx-runtime";import{useLexicalComposerContext as Ee}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Le}from"@lexical/react/useLexicalEditable";import{getTranslation as ue}from"@payloadcms/translations";import{Button as me,Drawer as Pe,EditDepthProvider as Re,Form as je,formatDrawerSlug as Me,FormSubmit as Ae,RenderFields as Je,ShimmerEffect as Ke,useConfig as ze,useDocumentForm as Ve,useDocumentInfo as He,useEditDepth as We,useServerFunctions as Xe,useTranslation as qe}from"@payloadcms/ui";import{abortAndIgnore as K}from"@payloadcms/ui/shared";import{$getNodeByKey as z}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as V,reduceFieldsToValues as Ge}from"payload/shared";import T,{createContext as Qe,useCallback as H,useEffect as O,useMemo as $,useRef as S}from"react";import{v4 as Ue}from"uuid";import{jsx as Ie}from"react/jsx-runtime";import we from"bson-objectid";import{$applyNodeReplacement as Ne}from"lexical";import ve from"react";import{addClassNamesToElement as _e}from"@lexical/utils";import Se from"bson-objectid";import{$applyNodeReplacement as ye,DecoratorNode as Fe}from"lexical";var _=class extends Fe{__cacheBuster;__fields;constructor({cacheBuster:e,fields:t,key:c}){super(c),this.__fields=t,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return De(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(e){let t=document.createElement("span");return _e(t,e?.theme?.inlineBlock),t}decorate(e,t){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let t=document.createTextNode(this.getTextContent());return e.append(t),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e,t){let c=this.getWritable();c.__fields=e,t||c.__cacheBuster++}updateDOM(){return!1}};function De(i){return ye(new _({fields:{...i,id:i?.id||new Se.default().toHexString()}}))}var Oe=ve.lazy(()=>import("./componentInline-22F6QL2B.js").then(i=>({default:i.InlineBlockComponent}))),v=class extends _{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return $e(e.fields)}decorate(...[e,t,c,b]){return Ie(Oe,{cacheBuster:this.getCacheBuster(),className:t.theme.inlineBlock??"LexicalEditorTheme__inlineBlock",CustomBlock:c,CustomLabel:b,formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function $e(i){return Ne(new v({fields:{...i,id:i?.id||new we.default().toHexString()}}))}function J(i){return i instanceof v}var fe=Qe({initialState:!1}),de=()=>T.use(fe),_t=i=>{let{cacheBuster:e,className:t,CustomBlock:c,CustomLabel:b,formData:n,nodeKey:a}=i,[k]=Ee(),u=Le(),{i18n:E,t:p}=qe(),{createdInlineBlock:W,fieldProps:{featureClientSchemaMap:pe,initialLexicalFormState:be,schemaPath:X},setCreatedInlineBlock:q,uuid:ke}=ce(),{fields:y}=Ve(),{getFormState:F}=Xe(),he=We(),G=S(!1),[m,L]=T.useState(()=>{let o=be?.[n.id]?.formState;return o?Object.fromEntries(Object.entries(o).map(([l,r])=>[l,l in n?{...r,initialValue:n[l],value:n[l]}:r])):!1}),Q=S(!1),U=S(e);O(()=>{Q.current?(U.current!==e&&L(!1),U.current=e):Q.current=!0},[e]);let[P,Y]=T.useState(()=>b?s(b,{className:t,formData:n,isEditor:!0,isJSXConverter:!1,nodeKey:a,useInlineBlockComponentContext:de}):m?._components?.customComponents?.BlockLabel??void 0),[Z,ee]=T.useState(()=>c?s(c,{className:t,formData:n,isEditor:!0,isJSXConverter:!1,nodeKey:a,useInlineBlockComponentContext:de}):m?._components?.customComponents?.Block??void 0),te=Me({slug:`lexical-inlineBlocks-create-${ke}-${n.id}`,depth:he}),{toggleDrawer:B}=ae(te,!0),Be=S(null),{id:D,collectionSlug:I,getDocPreferences:w,globalSlug:N}=He(),{config:Ce}=ze(),ge=`${X}.lexical_internal_feature.blocks.lexical_inline_blocks.${n.blockType}`,C=pe.blocks?.[ge]?.[0],d=C.blockReferences?typeof C?.blockReferences?.[0]=="string"?Ce.blocksMap[C?.blockReferences?.[0]]:C?.blockReferences?.[0]:C?.blocks?.[0],ne=d?.fields??[];O(()=>{!G.current&&W?.getKey()===a&&(ne.length>2&&B(),q?.(void 0),G.current=!0)},[ne.length,W,a,q,B]);let oe=H(()=>{k.update(()=>{z(a)?.remove()})},[k,a]),g=d?.labels?.singular?ue(d?.labels.singular,E):d?.slug,R=S(new AbortController),x=`${X}.lexical_internal_feature.blocks.lexical_inline_blocks.${d?.slug}.fields`;O(()=>{let o=new AbortController;return n&&!m&&(async()=>{let{state:r}=await F({id:D,collectionSlug:I,data:n,docPermissions:{fields:!0},docPreferences:await w(),documentFormState:V(y,{excludeFiles:!0}),globalSlug:N,initialBlockData:n,initialBlockFormState:n,operation:"update",readOnly:!u,renderAllFields:!0,schemaPath:x,signal:o.signal});if(r){let f=Ge(V(r,{excludeFiles:!0}),!0);k.update(()=>{let A=z(a);if(A&&J(A)){let ie=f;ie.blockType=n.blockType,A.setFields(ie,!0)}}),L(r),b||Y(r._components?.customComponents?.BlockLabel),c||ee(r._components?.customComponents?.Block)}})(),()=>{K(o)}},[F,k,a,u,b,c,x,D,n,m,I,N,w,y]);let re=H(async({formState:o,submit:l})=>{K(R.current);let r=new AbortController;R.current=r;let{state:f}=await F({id:D,collectionSlug:I,docPermissions:{fields:!0},docPreferences:await w(),documentFormState:V(y,{excludeFiles:!0}),formState:o,globalSlug:N,initialBlockFormState:o,operation:"update",readOnly:!u,renderAllFields:!!l,schemaPath:x,signal:r.signal});return f?(l&&(Y(f._components?.customComponents?.BlockLabel),ee(f._components?.customComponents?.Block)),f):o},[F,D,I,w,y,N,u,x]);O(()=>{let o=(l,r)=>Object.keys(r).some(f=>r[f]&&l[f]!==r[f].value);return()=>{m&&o(n,m)&&L(!1),K(R.current)}},[n,m]);let xe=H((o,l)=>{l.blockType=n.blockType,k.update(()=>{let r=z(a);r&&J(r)&&r.setFields(l,!0)})},[k,a,n]),j=$(()=>()=>s(me,{buttonStyle:"icon-label",className:`${t}__removeButton`,disabled:!u,icon:"x",onClick:o=>{o.preventDefault(),oe()},round:!0,size:"small",tooltip:p("lexical:blocks:inlineBlocks:remove",{label:g})}),[t,g,u,oe,p]),le=$(()=>()=>s(me,{buttonStyle:"icon-label",className:`${t}__editButton`,disabled:!u,el:"button",icon:"edit",onClick:()=>{B()},round:!0,size:"small",tooltip:p("lexical:blocks:inlineBlocks:edit",{label:g})}),[t,g,u,p,B]),M=$(()=>({children:o,className:l})=>s("div",{className:[`${t}__container`,t+"-"+n.blockType,l].filter(Boolean).join(" "),ref:Be,children:o}),[t,n.blockType]),se=$(()=>P?()=>P:()=>s("div",{children:d?.labels?ue(d?.labels.singular,E):""}),[P,d?.labels,E]);return d?h(je,{beforeSubmit:[async({formState:o})=>await re({formState:o,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:d?.fields,initialState:m||{},onChange:[re],onSubmit:(o,l)=>{xe(o,l),B()},uuid:Ue(),children:[s(Re,{children:s(Pe,{className:"",slug:te,title:p(`lexical:blocks:inlineBlocks:${n?.id?"edit":"create"}`,{label:g??p("lexical:blocks:inlineBlocks:label")}),children:m?h(Te,{children:[s(Je,{fields:d?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:x,permissions:!0,readOnly:!u}),s(Ae,{programmaticSubmit:!0,children:p("fields:saveChanges")})]}):null})}),Z?s(fe,{value:{EditButton:le,initialState:m,InlineBlockContainer:M,Label:se,nodeKey:a,RemoveButton:j},children:Z}):h(M,{children:[m?s(se,{}):s(Ke,{height:"15px",width:"40px"}),u?h("div",{className:`${t}__actions`,children:[s(le,{}),s(j,{})]}):null]})]}):h(M,{className:`${t}-not-found`,children:[h("span",{children:["Error: Block '",n.blockType,"' not found"]}),u?s("div",{className:`${t}__actions`,children:s(j,{})}):null]})};export{de as a,_t as b,v as c,$e as d,J as e};
|
|
2
|
+
//# sourceMappingURL=chunk-CRVQNLN7.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 type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types.js'\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\nimport type { BlockComponentProps } from '../component/index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\nexport type InlineBlockComponentProps<\n TFormData extends Record<string, unknown> = InlineBlockFields,\n> = {\n readonly CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>\n readonly CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>\n} & Pick<BlockComponentProps<TFormData>, 'cacheBuster' | 'className' | 'formData' | 'nodeKey'>\n\nexport type InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<InlineBlockComponentProps<InlineBlockFields>> = (\n props,\n) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n return Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n // Pass useInlineBlockComponentContext as useBlockComponentContext for inline blocks\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n CustomLabelFromProps,\n CustomBlockFromProps,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n isEditable,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\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 [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\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 [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {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 ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types.js'\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 type InlineBlockDecorateFunction = (\n editor: LexicalEditor,\n config: EditorConfig,\n CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>,\n CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>,\n) => JSX.Element\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n override decorate(\n ...[_editor, config, CustomBlock, CustomLabel]: Parameters<InlineBlockDecorateFunction>\n ): ReturnType<InlineBlockDecorateFunction> {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\n className={config.theme.inlineBlock ?? 'LexicalEditorTheme__inlineBlock'}\n CustomBlock={CustomBlock}\n CustomLabel={CustomLabel}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return $applyNodeReplacement(\n new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = {\n fields: InlineBlockFields<TBlockFields>\n} & StronglyTypedLeafNode<SerializedLexicalNode, 'inlineBlock'>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, config?.theme?.inlineBlock)\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return $applyNodeReplacement(\n new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
|
|
5
|
+
"mappings": "mJAIA,OAASA,6BAAAA,OAAiC,wCAC1C,OAASC,sBAAAA,OAA0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C1EoG,MAAOjD,GAAoB1E,EAAE,mCAAA,CAC/B,CAAA,WAECpB,EACCyJ,EAAAQ,GAAA,WACEvG,EAACwG,GAAA,CACCnI,OAAQmD,GAAanD,OACrBoI,YAAW,GACXC,gBAAgB,GAChBC,WAAW,GACXC,iBAAkBlE,EAClBmE,YAAa,GACbvD,SAAU,CAAC/F,IAEbyC,EAAC8G,GAAA,CAAWC,mBAAoB,YAAOrJ,EAAE,oBAAA,OAEzC,SAGPX,EACCiD,EAAC5D,GAAA,CACCsD,MAAO,CACL4F,WAAAA,GACAhJ,aAAAA,EACAkJ,qBAAAA,EACAM,MAAAA,GACA1I,QAAAA,EACAqH,aAAAA,CACF,WAEC1H,IAGHgJ,EAACP,EAAA,WACElJ,EAAe0D,EAAC8F,GAAA,CAAA,CAAA,EAAW9F,EAACgH,GAAA,CAAcC,OAAO,OAAOC,MAAM,SAC9D3J,EACCwI,EAAC,MAAA,CAAIlJ,UAAW,GAAGC,CAAA,sBACjBkD,EAACsF,GAAA,CAAA,CAAA,EACDtF,EAACyE,EAAA,CAAA,CAAA,CAAA,IAED,IAAA,OA3ERsB,EAACP,EAAA,CAAqB3I,UAAW,GAAGC,CAAA,uBAClCiJ,EAAC,OAAA,WAAK,iBAAe5I,EAASmE,UAAU,aAAA,IACvC/D,EACCyC,EAAC,MAAA,CAAInD,UAAW,GAAGC,CAAA,qBACjBkD,EAACyE,EAAA,CAAA,CAAA,IAED,IAAA,GA0EZ",
|
|
6
|
+
"names": ["useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useConfig", "useDocumentForm", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "deepCopyObjectSimpleWithoutReactComponents", "reduceFieldsToValues", "React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "v4", "uuid", "ObjectID", "$applyNodeReplacement", "React", "addClassNamesToElement", "ObjectID", "$applyNodeReplacement", "DecoratorNode", "ServerInlineBlockNode", "__cacheBuster", "__fields", "constructor", "cacheBuster", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "config", "element", "document", "createElement", "theme", "inlineBlock", "decorate", "editor", "exportDOM", "classList", "add", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getCacheBuster", "getLatest", "setFields", "preventFormStateUpdate", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "_editor", "config", "CustomBlock", "CustomLabel", "_jsx", "cacheBuster", "getCacheBuster", "className", "theme", "inlineBlock", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "$applyNodeReplacement", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "use", "InlineBlockComponent", "props", "cacheBuster", "className", "baseClass", "CustomBlock", "CustomBlockFromProps", "CustomLabel", "CustomLabelFromProps", "formData", "nodeKey", "editor", "useLexicalComposerContext", "isEditable", "useLexicalEditable", "i18n", "t", "useTranslation", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "schemaPath", "setCreatedInlineBlock", "uuid", "uuidFromContext", "useEditorConfigContext", "fields", "parentDocumentFields", "useDocumentForm", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "firstTimeDrawer", "useRef", "setInitialState", "useState", "cachedFormState", "id", "formState", "Object", "fromEntries", "entries", "map", "fieldName", "fieldState", "initialValue", "value", "hasMounted", "prevCacheBuster", "useEffect", "current", "setCustomLabel", "_jsx", "isEditor", "isJSXConverter", "customComponents", "BlockLabel", "undefined", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "config", "useConfig", "componentMapRenderedBlockPath", "blockType", "blocksField", "clientBlock", "blockReferences", "blocksMap", "blocks", "clientBlockFields", "getKey", "length", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "docPreferences", "documentFormState", "deepCopyObjectSimpleWithoutReactComponents", "excludeFiles", "initialBlockData", "initialBlockFormState", "operation", "readOnly", "renderAllFields", "signal", "newFormStateData", "reduceFieldsToValues", "node", "$isInlineBlockNode", "newData", "setFields", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "isStateOutOfSync", "keys", "some", "key", "onFormSubmit", "RemoveButton", "useMemo", "Button", "buttonStyle", "disabled", "icon", "onClick", "e", "preventDefault", "round", "size", "tooltip", "label", "EditButton", "el", "InlineBlockContainer", "children", "filter", "Boolean", "join", "ref", "Label", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "title", "_Fragment", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "permissions", "FormSubmit", "programmaticSubmit", "ShimmerEffect", "height", "width"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var st=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";import{c as he}from"react/compiler-runtime";import{useRef as xe}from"react";function ro(r){let t=he(2),e=r===void 0?500:r,o=xe(void 0),n;return t[0]!==e?(n=s=>new Promise(i=>{let l=()=>{s(),i()};"requestIdleCallback"in window?("cancelIdleCallback"in window&&o.current!==void 0&&cancelIdleCallback(o.current),o.current=requestIdleCallback(l,{timeout:e})):Ee().then(l)}),t[0]=e,t[1]=n):n=t[1],n}function Ee(){return new Promise(r=>{setTimeout(r,100),requestAnimationFrame(()=>{setTimeout(r,0)})})}import{jsx as _e}from"react/jsx-runtime";import{useControllableState as Te}from"@payloadcms/ui";import{createContext as we,use as Ce,useMemo as Se}from"react";var ct=we({currentView:"default",inheritable:!1,setCurrentView:()=>{}}),fo=r=>{let t=Re(),e=r.currentView!==void 0,o=t.inheritable&&!!t.hasExplicitCurrentView,n=e||t.inheritable&&!!t.hasExplicitCurrentView,{children:c,currentView:s,inheritable:i,views:l}={children:r.children,currentView:t.inheritable&&t.hasExplicitCurrentView?t.currentView:r.currentView,inheritable:t.inheritable||r.inheritable,views:t.inheritable&&t.views?t.views:r.views},[a,u]=Te(s,"default"),p=Se(()=>{let m=l?l[a]||l.default:void 0;return{currentView:a,currentViewMap:m,hasExplicitCurrentView:n,hasInheritedViews:o,inheritable:i,setCurrentView:u,views:l}},[a,i,n,o,u,l]);return _e(ct,{value:p,children:c})};function Re(){return Ce(ct)}var G=class{_x;_y;constructor(t,e){this._x=t,this._y=e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}equals({x:t,y:e}){return this.x===t&&this.y===e}get x(){return this._x}get y(){return this._y}};function lt(r){return r instanceof G}import{jsx as Ve}from"react/jsx-runtime";import{useLexicalComposerContext as Xe}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Ge}from"@lexical/utils";import{$getSelection as j,$isRangeSelection as W,$isTextNode as ze,COMMAND_PRIORITY_LOW as Ye,createCommand as je,getDOMSelection as We}from"lexical";import{useCallback as _t,useEffect as Tt,useState as qe}from"react";import*as Y from"react";import{c as pt}from"react/compiler-runtime";import{useLexicalComposerContext as gt}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as at}from"@lexical/utils";import{$getSelection as ht,$isRangeSelection as ye,$setSelection as be,COMMAND_PRIORITY_LOW as ft,COMMAND_PRIORITY_NORMAL as $,createCommand as ke,KEY_ARROW_DOWN_COMMAND as Oe,KEY_ARROW_UP_COMMAND as Ne,KEY_ENTER_COMMAND as Fe,KEY_ESCAPE_COMMAND as Ie,KEY_TAB_COMMAND as Me}from"lexical";import{useCallback as z,useEffect as k,useLayoutEffect as Ae,useMemo as De,useRef as Le,useState as $e}from"react";var Be="slash-menu-popup",ut=r=>{let t=document.getElementById("slash-menu");if(!t)return;let e=t.getBoundingClientRect();e.top+e.height>window.innerHeight&&t.scrollIntoView({block:"center"}),e.top<0&&t.scrollIntoView({block:"center"}),r.scrollIntoView({block:"nearest"})};function ve(r,t,e){let o=e;for(let n=o;n<=t.length;n++)r.substring(r.length-n)===t.substring(0,n)&&(o=n);return o}function Pe(r){let t=ht();if(!ye(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let o=e.getNode();if(!o.isSimpleText())return;let n=e.offset,c=o.getTextContent().slice(0,n),s=r.replaceableString.length,i=ve(c,r.matchingString,s),l=n-i;if(l<0)return;let a;return l===0?[a]=o.splitText(n):[,a]=o.splitText(l,n),a}function He(r,t){let e=getComputedStyle(r),o=e.position==="absolute",n=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let c=r;c=c.parentElement;)if(e=getComputedStyle(c),!(o&&e.position==="static")&&n.test(e.overflow+e.overflowY+e.overflowX))return c;return document.body}function dt(r,t){let e=r.getBoundingClientRect(),o=t.getBoundingClientRect();return e.top>o.top&&e.top<o.bottom}function Ke(r,t,e,o){let n=pt(7),[c]=gt(),s,i;n[0]!==c||n[1]!==e||n[2]!==o||n[3]!==r||n[4]!==t?(s=()=>{let l=t.current;if(l!=null&&r!=null){let a=c.getRootElement(),u=a!=null?He(a,!1):document.body,p=!1,m=dt(l,u),g=function(){p||(window.requestAnimationFrame(function(){e(),p=!1}),p=!0);let d=dt(l,u);d!==m&&(m=d,o?.(d))},f=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",g,{capture:!0,passive:!0}),f.observe(l),()=>{f.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",g,!0)}}},i=[c,o,e,r,t],n[0]=c,n[1]=e,n[2]=o,n[3]=r,n[4]=t,n[5]=s,n[6]=i):(s=n[5],i=n[6]),k(s,i)}var mt=ke("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function xt({anchorElementRef:r,close:t,editor:e,groups:o,menuRenderFn:n,resolution:c,shouldSplitNodeWithQuery:s=!1}){let[i,l]=$e(null),a=c.match&&c.match.matchingString||"",u=z(f=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${Be}__item-${f.key}`),l(f.key))},[e]),p=z(()=>{if(o!==null&&a!=null){let f=o.flatMap(d=>d.items);if(f.length){let d=f[0];u(d)}}},[o,u,a]);k(()=>{p()},[a,p]);let m=z(f=>{t(),e.update(()=>{let d=c.match!=null&&s?Pe(c.match):null;d&&d.remove()}),setTimeout(()=>{let d;e.read(()=>{d=ht()?.clone()}),e.update(()=>{d&&be(d)}),f.onSelect({editor:e,queryString:c.match?c.match.matchingString:""})},0)},[e,s,c.match,t]);k(()=>()=>{let f=e.getRootElement();f!==null&&f.removeAttribute("aria-activedescendant")},[e]),Ae(()=>{o===null?l(null):i===null&&p()},[o,i,u,p]),k(()=>at(e.registerCommand(mt,({item:f})=>f.ref&&f.ref.current!=null?(ut(f.ref.current),!0):!1,ft)),[e,u]),k(()=>at(e.registerCommand(Oe,f=>{let d=f;if(o!==null&&o.length&&i!==null){let h=o.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==h.length-1?x+1:0,_=h[E];if(!_)return!1;u(_),_.ref!=null&&_.ref.current&&e.dispatchCommand(mt,{index:E,item:_}),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(Ne,f=>{let d=f;if(o!==null&&o.length&&i!==null){let h=o.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==0?x-1:h.length-1,_=h[E];if(!_)return!1;u(_),_.ref!=null&&_.ref.current&&ut(_.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(Ie,f=>{let d=f;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},ft),e.registerCommand(Me,f=>{let d=f;if(o===null||i===null)return!1;let x=o.flatMap(E=>E.items).find(E=>E.key===i);return x?(d.preventDefault(),d.stopImmediatePropagation(),m(x),!0):!1},$),e.registerCommand(Fe,f=>{if(o===null||i===null)return!1;let h=o.flatMap(x=>x.items).find(x=>x.key===i);return h?(f!==null&&(f.preventDefault(),f.stopImmediatePropagation()),m(h),!0):!1},$)),[m,t,e,o,i,u]);let g=De(()=>({groups:o,selectedItemKey:i,selectItemAndCleanUp:m,setSelectedItemKey:l}),[m,i,o]);return n(r,g,c.match?c.match.matchingString:"")}function Ue(r,t){t!=null&&(r.className=t),r.setAttribute("aria-label","Slash menu"),r.setAttribute("role","listbox"),r.style.display="block",r.style.position="absolute"}function Et(r,t,e,o){let n=pt(14),[c]=gt(),s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=st?document.createElement("div"):null,n[0]=s):s=n[0];let i=Le(s),l;n[1]!==r||n[2]!==o||n[3]!==c||n[4]!==t?(l=()=>{if(i.current===null||parent===void 0)return;let f=c.getRootElement(),d=i.current,h=d.firstChild;if(f!==null&&t!==null){let{height:x,width:E}=t.getRect(),{left:_,top:T}=t.getRect(),b=T;if(T=T-(r.getBoundingClientRect().top+window.scrollY),_=_-(r.getBoundingClientRect().left+window.scrollX),d.style.left=`${_+window.scrollX}px`,d.style.height=`${x}px`,d.style.width=`${E}px`,h!==null){let w=h.getBoundingClientRect(),L=w.height,S=w.width,X=f.getBoundingClientRect(),rt=document.dir==="rtl"||document.documentElement.dir==="rtl",de=r.getBoundingClientRect(),it=Math.max(0,X.left);if(!rt&&_+S>X.right)d.style.left=`${X.right-S+window.scrollX}px`;else if(rt&&w.left<it){let ge=it+S-de.left;d.style.left=`${ge+window.scrollX}px`}let me=b+L+32>window.innerHeight,pe=b<0;me&&!pe?d.style.top=`${T+32-L+window.scrollY-(x+24)}px`:d.style.top=`${T+window.scrollY+32}px`}d.isConnected||(Ue(d,o),r.append(d)),d.setAttribute("id","slash-menu"),i.current=d,f.setAttribute("aria-controls","slash-menu")}},n[1]=r,n[2]=o,n[3]=c,n[4]=t,n[5]=l):l=n[5];let a=l,u,p;n[6]!==c||n[7]!==a||n[8]!==t?(u=()=>{let f=c.getRootElement();if(t!==null)return a(),()=>{f!==null&&f.removeAttribute("aria-controls");let d=i.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},p=[c,a,t],n[6]=c,n[7]=a,n[8]=t,n[9]=u,n[10]=p):(u=n[9],p=n[10]),k(u,p);let m;return n[11]!==t||n[12]!==e?(m=f=>{t!==null&&(f||e(null))},n[11]=t,n[12]=e,n[13]=m):m=n[13],Ke(t,i,a,m),i}var ko=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Qe(r){let t=r.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let o=t.offset;return e.getTextContent().slice(0,o)}function wt(r,t,e){let o=We(e);if(o===null||!o.isCollapsed)return!1;let n=o.anchorNode,c=r,s=o.anchorOffset;if(n==null||s==null)return!1;try{t.setStart(n,c),t.setEnd(n,s>1?s:1)}catch{return!1}return!0}function Je(r){let t;return r.getEditorState().read(()=>{let e=j();W(e)&&(t=Qe(e))}),t}function Ct(r,t){return t!==0?!1:r.getEditorState().read(()=>{let e=j();if(W(e)){let c=e.anchor.getNode().getPreviousSibling();return ze(c)&&c.isTextEntity()}return!1})}function St(r){Y.startTransition?Y.startTransition(r):r()}var Ze=je("ENABLE_SLASH_MENU_COMMAND");function Oo({anchorClassName:r,anchorElem:t,groups:e,menuRenderFn:o,onClose:n,onOpen:c,onQueryChange:s,triggerFn:i}){let[l]=Xe(),[a,u]=qe(null),p=Et(t,a,u,r),m=_t(()=>{u(null),n!=null&&a!==null&&n()},[n,a]),g=_t(f=>{u(f),c!=null&&a===null&&c(f)},[c,a]);return Tt(()=>Ge(l.registerCommand(Ze,({node:f})=>(l.getEditorState().read(()=>{let d={leadOffset:0,matchingString:"",replaceableString:""};if(!Ct(l,d.leadOffset)&&f!==null){let h=l._window??window,x=h.document.createRange();wt(d.leadOffset,x,h)!==null&&St(()=>g({getRect:()=>x.getBoundingClientRect(),match:d}));return}}),!0),Ye)),[l,g]),Tt(()=>{let f=()=>{l.getEditorState().read(()=>{let h=l._window??window,x=h.document.createRange(),E=j(),_=Je(l);if(!W(E)||!E.isCollapsed()||_===void 0||x===null){m();return}let T=i({editor:l,query:_});if(s(T?T.matchingString:null),T!==null&&!Ct(l,T.leadOffset)&&wt(T.leadOffset,x,h)!==null){St(()=>g({getRect:()=>x.getBoundingClientRect(),match:T}));return}m()})},d=l.registerUpdateListener(f);return()=>{d()}},[l,i,s,a,m,g]),p.current===null||a===null||l===null?null:Ve(xt,{anchorElementRef:p,close:m,editor:l,groups:e,menuRenderFn:o,resolution:a,shouldSplitNodeWithQuery:!0})}var Rt=class r{_bottom;_left;_right;_top;constructor(t,e,o,n){let[c,s]=e<=n?[e,n]:[n,e],[i,l]=t<=o?[t,o]:[o,t];this._top=c,this._right=l,this._left=i,this._bottom=s}static fromDOM(t){let{height:e,left:o,top:n,width:c}=t.getBoundingClientRect();return r.fromLWTH(o,c,n,e)}static fromDOMRect(t){let{height:e,left:o,top:n,width:c}=t;return r.fromLWTH(o,c,n,e)}static fromLTRB(t,e,o,n){return new r(t,e,o,n)}static fromLWTH(t,e,o,n){return new r(t,o,t+e,o+n)}static fromPoints(t,e){let{x:o,y:n}=t,{x:c,y:s}=e;return r.fromLTRB(o,n,c,s)}contains(t){if(lt(t)){let{x:s,y:i}=t,l=i<this._top,a=i>this._bottom,u=s<this._left,p=s>this._right;return{reason:{isOnBottomSide:a,isOnLeftSide:u,isOnRightSide:p,isOnTopSide:l},result:!l&&!a&&!u&&!p}}let{bottom:e,left:o,right:n,top:c}=t;return c>=this._top&&c<=this._bottom&&e>=this._top&&e<=this._bottom&&o>=this._left&&o<=this._right&&n>=this._left&&n<=this._right}distanceFromPoint(t){let e=this.contains(t);if(e.result)return{distance:0,isOnBottomSide:e.reason.isOnBottomSide,isOnLeftSide:e.reason.isOnLeftSide,isOnRightSide:e.reason.isOnRightSide,isOnTopSide:e.reason.isOnTopSide};let o=0,n=0;return t.x<this._left?o=this._left-t.x:t.x>this._right&&(o=t.x-this._right),t.y<this._top?n=this._top-t.y:t.y>this._bottom&&(n=t.y-this._bottom),{distance:Math.sqrt(o*o+n*n),isOnBottomSide:t.y>this._bottom,isOnLeftSide:t.x<this._left,isOnRightSide:t.x>this._right,isOnTopSide:t.y<this._top}}equals({bottom:t,left:e,right:o,top:n}){return n===this._top&&t===this._bottom&&e===this._left&&o===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:o=this.right,top:n=this.top}){return new r(e,n,o,t)}intersectsWith(t){let{height:e,left:o,top:n,width:c}=t,{height:s,left:i,top:l,width:a}=this,u=o+c>=i+a?o+c:i+a,p=n+e>=l+s?n+e:l+s,m=o<=i?o:i,g=n<=l?n:l;return u-m<=c+a&&p-g<=e+s}get bottom(){return this._bottom}get height(){return Math.abs(this._bottom-this._top)}get left(){return this._left}get right(){return this._right}get top(){return this._top}get width(){return Math.abs(this._left-this._right)}};import q from"react";var A=new WeakMap;function Ao(r,t){A.has(r)||A.set(r,new Map);let e=A.get(r);for(let[o,n]of Object.entries(t))if(!(!n||typeof n!="object")){if(o==="blocks"){for(let[c,s]of Object.entries(n))e.set(`block:${c}`,s);continue}if(o==="inlineBlocks"){for(let[c,s]of Object.entries(n))e.set(`inlineBlock:${c}`,s);continue}e.set(o,n)}}function Do(r){A.delete(r)}function yt(r,t,e){let o=A.get(r);if(t==="block"&&e?.__fields?.blockType){let n=e.__fields.blockType;return o?.get(`block:${n}`)}if(t==="inlineBlock"&&e?.__fields?.blockType){let n=e.__fields.blockType;return o?.get(`inlineBlock:${n}`)}return o?.get(t)}function tn({node:r,nodeType:t}){if(!("getType"in r)||r.getType()!==t)return;let e=r;if(e.prototype._originalDecorate||(e.prototype._originalDecorate=e.prototype.decorate),e.prototype._originalCreateDOM||(e.prototype._originalCreateDOM=e.prototype.createDOM),e.prototype.decorate&&!e.prototype._decorateOverridden){e.prototype._decorateOverridden=!0;let o=!!e.prototype.createDOM;e.prototype.decorate=function(n,c){let s=yt(n,t,this);if(s){if(s.Component)return s.Component({config:c,editor:n,isEditor:!0,isJSXConverter:!1,node:this});if(s.createDOM&&s.html){let l=typeof s.html=="function"?s.html({config:c,editor:n,isEditor:!0,isJSXConverter:!1,node:this}):s.html;return q.createElement("span",{dangerouslySetInnerHTML:{__html:l}})}if(s.html&&o&&!s.createDOM)return q.createElement(q.Fragment);if(t==="block"){let l=s;if(l.Block||l.Label)return e.prototype._originalDecorate.call(this,n,c,l.Block,l.Label)}else if(t==="inlineBlock"){let l=s;if(l.Block||l.Label)return e.prototype._originalDecorate.call(this,n,c,l.Block,l.Label)}}return e.prototype._originalDecorate.call(this,n,c)}}e.prototype.createDOM&&!e.prototype._createDOMOverridden&&(e.prototype._createDOMOverridden=!0,e.prototype.createDOM=function(o,n){let c=yt(n,t,this);if(c){if(c.createDOM)return c.createDOM({config:o,editor:n,node:this});if(c.html){let s=typeof c.html=="function"?c.html({config:o,editor:n,isEditor:!0,isJSXConverter:!1,node:this}):c.html,i=document.createElement("div");return i.innerHTML=s,i.firstElementChild||i}}return e.prototype._originalCreateDOM.call(this,o,n)})}function Lo({editorConfig:r,nodeViews:t}){let e=en({nodes:r.features.nodes});if(t){let o=new Set;for(let[n,c]of Object.entries(t))!c||typeof c!="object"||(n==="blocks"&&Object.keys(c).length>0?o.add("block"):n==="inlineBlocks"&&Object.keys(c).length>0?o.add("inlineBlock"):o.add(n));for(let n of e)if("getType"in n){let c=n.getType();o.has(c)&&tn({node:n,nodeType:c})}}return e}function en({nodes:r}){return r.map(t=>"node"in t?t.node:t)}import{$getRoot as un,$isDecoratorNode as Ft,$isElementNode as P,$isLineBreakNode as dn,$isTextNode as H}from"lexical";import{$isListItemNode as nn,$isListNode as bt}from"@lexical/list";import{$isHeadingNode as on,$isQuoteNode as rn}from"@lexical/rich-text";import{$isParagraphNode as sn,$isTextNode as cn}from"lexical";var C={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...C,requiresParagraphStart:!0},Ho={...R,export:O(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},Ko={...R,export:O(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},Uo={...R,export:O(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Vo={...R,export:O(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},Xo={...R,export:O(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},Go={...R,export:O(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},zo={...R,export:an,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},Yo={...R,export:Q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},jo={...R,export:Q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},Wo={...R,export:Q,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},qo={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},Qo={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},Jo={...C,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},Zo={...C,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},tr={...C,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},er={...C,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},nr={...C,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},or={...C,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},rr={...C,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},ir={...C,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},sr={...C,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},cr={...C,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},lr={...C,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},ar={...C,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function O(r){return(t,e)=>on(t)&&t.getTag()==="h"+r?"#".repeat(r)+" "+e(t):null}function Q(r,t){return bt(r)?kt(r,t,0):null}var ln=4;function kt(r,t,e){let o=[],n=r.getChildren(),c=0;for(let s of n)if(nn(s)){if(s.getChildrenSize()===1){let a=s.getFirstChild();if(bt(a)){o.push(kt(a,t,e+1));continue}}let i=" ".repeat(e*ln),l=r.getListType()==="bullet"?"- ":`${r.getStart()+c}. `;o.push(i+l+t(s)),c++}return o.join(`
|
|
2
|
+
`)}function an(r,t){return rn(r)?"> "+t(r):null}function B(r,t){let e={};for(let o of r){let n=t(o);n&&(e[n]?e[n].push(o):e[n]=[o])}return e}function N(r){let t=B(r,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var F=/[!-/:-@[-`{-~\s]/,fn=/^\s{0,3}$/;function D(r){if(!sn(r))return!1;let t=r.getFirstChild();return t==null||r.getChildrenSize()===1&&cn(t)&&fn.test(t.getTextContent())}function It(r,t=!1){let e=N(r),o=[...e.multilineElement,...e.element],n=!t,c=e.textFormat.filter(s=>s.format.length===1).sort((s,i)=>s.format.includes("code")&&!i.format.includes("code")?1:!s.format.includes("code")&&i.format.includes("code")?-1:0);return s=>{let i=[],l=(s||un()).getChildren();return l.forEach((a,u)=>{let p=mn(a,o,c,e.textMatch);p!=null&&i.push(n&&u>0&&!D(a)&&!D(l[u-1])?`
|
|
3
|
+
`.concat(p):p)}),i.join(`
|
|
4
|
+
`)}}function mn(r,t,e,o){for(let n of t){if(!n.export)continue;let c=n.export(r,s=>K(s,e,o));if(c!=null)return c}return P(r)?K(r,e,o):Ft(r)?r.getTextContent():null}function K(r,t,e,o,n){let c=[],s=r.getChildren();o||(o=[]),n||(n=[]);t:for(let i of s){for(let l of e){if(!l.export)continue;let a=l.export(i,u=>K(u,t,e,o,[...n,...o]),(u,p)=>Ot(u,p,t,o,n));if(a!=null){c.push(a);continue t}}dn(i)?c.push(`
|
|
5
|
+
`):H(i)?c.push(Ot(i,i.getTextContent(),t,o,n)):P(i)?c.push(K(i,t,e,o,n)):Ft(i)&&c.push(i.getTextContent())}return c.join("")}function Ot(r,t,e,o,n){let c=t.trim(),s=c;r.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",l="",a="",u=Nt(r,!0),p=Nt(r,!1),m=new Set;for(let g of e){let f=g.format[0],d=g.tag;v(r,f)&&!m.has(f)&&(m.add(f),(!v(u,f)||!o.find(h=>h.tag===d))&&(o.push({format:f,tag:d}),i+=d))}for(let g=0;g<o.length;g++){let f=o[g],d=v(r,f.format),h=v(p,f.format);if(d&&h)continue;let x=[...o];for(;x.length>g;){let E=x.pop();n&&E&&n.find(_=>_.tag===E.tag)||(E&&typeof E.tag=="string"&&(d?h||(a+=E.tag):l+=E.tag),o.pop())}break}return s=i+s+a,l+t.replace(c,()=>s)}function Nt(r,t){let e=t?r.getPreviousSibling():r.getNextSibling();if(!e){let o=r.getParentOrThrow();o.isInline()&&(e=t?o.getPreviousSibling():o.getNextSibling())}for(;e;){if(P(e)){if(!e.isInline())break;let o=t?e.getLastDescendant():e.getFirstDescendant();if(H(o))return o;e=t?e.getPreviousSibling():e.getNextSibling()}if(H(e))return e;if(!P(e))return null}return null}function v(r,t){return H(r)&&r.hasFormat(t)}import{$isListItemNode as gn,$isListNode as $t}from"@lexical/list";import{$isQuoteNode as hn}from"@lexical/rich-text";import{$findMatchingParent as xn}from"@lexical/utils";import{$createLineBreakNode as En,$createParagraphNode as _n,$createTextNode as Tn,$getRoot as wn,$getSelection as Cn,$isParagraphNode as Sn}from"lexical";import{$isTextNode as I}from"lexical";function Mt(r,t){let e=r.getTextContent(),o=pn(e,t);if(!o)return null;let n=o.index||0,c=n+o[0].length,s=t.transformersByTag[o[1]];return{endIndex:c,match:o,startIndex:n,transformer:s}}function pn(r,t){let e=r.match(t.openTagsRegExp);if(e==null)return null;for(let o of e){let n=o.replace(/^\s/,""),c=t.fullMatchRegExpByTag[n];if(c==null)continue;let s=r.match(c),i=t.transformersByTag[n];if(s!=null&&i!=null){if(i.intraword!==!1)return s;let{index:l=0}=s,a=r[l-1],u=r[l+s[0].length];if((!a||F.test(a))&&(!u||F.test(u)))return s}}return null}function At(r,t,e,o,n){let c=r.getTextContent(),s,i,l;if(n[0]===c?l=r:t===0?[l,s]=r.splitText(e):[i,l,s]=r.splitText(t,e),l.setTextContent(n[2]),o)for(let a of o.format)l.hasFormat(a)||l.toggleFormat(a);return{nodeAfter:s,nodeBefore:i,transformedNode:l}}function Dt(r,t){let e=r,o,n,c,s;for(let i of t){if(!i.replace||!i.importRegExp)continue;let l=e.getTextContent().match(i.importRegExp);if(!l)continue;let a=l.index||0,u=i.getEndIndex?i.getEndIndex(e,l):a+l[0].length;u!==!1&&(o===void 0||n===void 0||a<o&&u>n)&&(o=a,n=u,c=i,s=l)}return o===void 0||n===void 0||c===void 0||s===void 0?null:{endIndex:n,match:s,startIndex:o,transformer:c}}function Lt(r,t,e,o,n){let c,s,i;if(t===0?[i,c]=r.splitText(e):[s,i,c]=r.splitText(t,e),!o.replace)return null;let l=i?o.replace(i,n):void 0;return{nodeAfter:c,nodeBefore:s,transformedNode:l||void 0}}function y(r,t,e){let o=Mt(r,t),n=Dt(r,e);if(o&&n&&(o.startIndex<=n.startIndex&&o.endIndex>=n.endIndex?n=null:o=null),o){let i=At(r,o.startIndex,o.endIndex,o.transformer,o.match);i.nodeAfter&&I(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&y(i.nodeAfter,t,e),i.nodeBefore&&I(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&y(i.nodeBefore,t,e),i.transformedNode&&I(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&y(i.transformedNode,t,e)}else if(n){let i=Lt(r,n.startIndex,n.endIndex,n.transformer,n.match);if(!i)return;i.nodeAfter&&I(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&y(i.nodeAfter,t,e),i.nodeBefore&&I(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&y(i.nodeBefore,t,e),i.transformedNode&&I(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&y(i.transformedNode,t,e)}let s=r.getTextContent().replace(/\\([*_`~])/g,"$1");r.setTextContent(s)}function Bt(r,t=!1){let e=N(r),o=bn(e.textFormat);return(n,c)=>{let s=n.split(`
|
|
6
|
+
`),i=s.length,l=c||wn();l.clear();for(let u=0;u<i;u++){let p=s[u],[m,g]=Rn(s,u,e.multilineElement,l);if(m){u=g;continue}yn(p,l,e.element,o,e.textMatch)}let a=l.getChildren();for(let u of a)!t&&D(u)&&l.getChildrenSize()>1&&u.remove();Cn()!==null&&l.selectStart()}}function Rn(r,t,e,o){for(let n of e){let{handleImportAfterStartMatch:c,regExpEnd:s,regExpStart:i,replace:l}=n,a=r[t]?.match(i);if(!a)continue;if(c){let f=c({lines:r,rootNode:o,startLineIndex:t,startMatch:a,transformer:n});if(f===null)continue;if(f)return f}let u=typeof s=="object"&&"regExp"in s?s.regExp:s,p=s&&typeof s=="object"&&"optional"in s?s.optional:!s,m=t,g=r.length;for(;m<g;){let f=u?r[m]?.match(u):null;if(!f&&(!p||p&&m<g-1)){m++;continue}if(f&&t===m&&f.index===a.index){m++;continue}let d=[];if(f&&t===m)d.push(r[t].slice(a[0].length,-f[0].length));else for(let h=t;h<=m;h++){let x=r[h];if(h===t){let E=x.slice(a[0].length);d.push(E)}else if(h===m&&f){let E=x.slice(0,-f[0].length);d.push(E)}else d.push(x)}if(l(o,null,a,f,d,!0)!==!1)return[!0,m];break}}return[!1,t]}function yn(r,t,e,o,n){let c=Tn(r),s=_n();s.append(c),t.append(s);for(let{regExp:i,replace:l}of e){let a=r.match(i);if(a&&(c.setTextContent(r.slice(a[0].length)),l(s,[c],a,!0)!==!1))break}if(y(c,o,n),s.isAttached()&&r.length>0){let i=s.getPreviousSibling();if(Sn(i)||hn(i)||$t(i)){let l=i;if($t(i)){let a=i.getLastDescendant();a==null?l=null:l=xn(a,gn)}l!=null&&l.getTextContentSize()>0&&(l.splice(l.getChildrenSize(),0,[En(),...s.getChildren()]),s.remove())}}}function bn(r){let t={},e={},o=[],n="(?<![\\\\])";for(let c of r){let{tag:s}=c;t[s]=c;let i=s.replace(/([*^+])/g,"\\$1");o.push(i),s.length===1?e[s]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):e[s]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp(`${n}(${o.join("|")})`,"g"),transformersByTag:t}}import{$createRangeSelection as kn,$getSelection as J,$isLineBreakNode as On,$isRangeSelection as Z,$isRootOrShadowRoot as Pt,$isTextNode as Ht,$setSelection as Nn}from"lexical";function Fn(r,t,e,o){let n=r.getParent();if(!Pt(n)||r.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExp:s,replace:i}of o){let l=c.match(s);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let a=t.getNextSiblings(),[u,p]=t.splitText(e);u?.remove();let m=p?[p,...a]:a;if(i(r,m,l,!1)!==!1)return!0}}return!1}function In(r,t,e,o){let n=r.getParent();if(!Pt(n)||r.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExpEnd:s,regExpStart:i,replace:l}of o){if(s&&!("optional"in s)||s&&"optional"in s&&!s.optional)continue;let a=c.match(i);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let u=t.getNextSiblings(),[p,m]=t.splitText(e);p?.remove();let g=m?[m,...u]:u;if(l(r,g,a,null,null,!1)!==!1)return!0}}return!1}function Mn(r,t,e){let o=r.getTextContent(),n=o[t-1],c=e[n];if(c==null)return!1;t<o.length&&(o=o.slice(0,t));for(let s of c){if(!s.replace||!s.regExp)continue;let i=o.match(s.regExp);if(i===null)continue;let l=i.index||0,a=l+i[0].length,u;return l===0?[u]=r.splitText(a):[,u]=r.splitText(l,a),u&&(u.selectNext(0,0),s.replace(u,i)),!0}return!1}function An(r,t,e){let o=r.getTextContent(),n=t-1,c=o[n],s=e[c];if(!s)return!1;for(let i of s){let{tag:l}=i,a=l.length,u=n-a+1;if(a>1&&!Kt(o,u,l,0,a)||o[u-1]===" ")continue;let p=o[n+1];if(i.intraword===!1&&p&&!F.test(p))continue;let m=r,g=m,f=vt(o,u,l),d=g;for(;f<0&&(d=d.getPreviousSibling())&&!On(d);)if(Ht(d)){let S=d.getTextContent();g=d,f=vt(S,S.length,l)}if(f<0||g===m&&f+a===u)continue;let h=g.getTextContent();if(f>0&&h[f-1]===c)continue;let x=h[f-1];if(i.intraword===!1&&x&&!F.test(x))continue;let E=m.getTextContent(),_=E.slice(0,u)+E.slice(n+1);m.setTextContent(_);let T=g===m?_:h;g.setTextContent(T.slice(0,f)+T.slice(f+a));let b=J(),w=kn();Nn(w);let L=n-a*(g===m?2:1)+1;w.anchor.set(g.__key,f,"text"),w.focus.set(m.__key,L,"text");for(let S of i.format)w.hasFormat(S)||w.formatText(S);w.anchor.set(w.focus.key,w.focus.offset,w.focus.type);for(let S of i.format)w.hasFormat(S)&&w.toggleFormat(S);return Z(b)&&(w.format=b.format),!0}return!1}function vt(r,t,e){let o=e.length;for(let n=t;n>=o;n--){let c=n-o;if(Kt(r,c,e,0,o)&&r[c+o]!==" ")return c}return-1}function Kt(r,t,e,o,n){for(let c=0;c<n;c++)if(r[t+c]!==e[o+c])return!1;return!0}function Ir(r,t=U){let e=N(t),o=B(e.textFormat,({tag:s})=>s[s.length-1]),n=B(e.textMatch,({trigger:s})=>s);for(let s of t){let i=s.type;if(i==="element"||i==="text-match"||i==="multiline-element"){let l=s.dependencies;for(let a of l)if(!r.hasNode(a))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+a.getType())}}let c=(s,i,l)=>{Fn(s,i,l,e.element)||In(s,i,l,e.multilineElement)||Mn(i,l,n)||An(i,l,o)};return r.registerUpdateListener(({dirtyLeaves:s,editorState:i,prevEditorState:l,tags:a})=>{if(a.has("collaboration")||a.has("historic")||r.isComposing())return;let u=i.read(J),p=l.read(J);if(!Z(p)||!Z(u)||!u.isCollapsed()||u.is(p))return;let m=u.anchor.key,g=u.anchor.offset,f=i._nodeMap.get(m);!Ht(f)||!s.has(m)||g!==1&&g>p.anchor.offset+1||r.update(()=>{if(f.hasFormat("code"))return;let d=f.getParent();d!==null&&c(d,f,u.anchor.offset)})})}import{$createListItemNode as Dn,$createListNode as Ln,$isListItemNode as $n,$isListNode as M,ListItemNode as et,ListNode as nt}from"@lexical/list";import{$createHeadingNode as Bn,$createQuoteNode as vn,$isHeadingNode as Pn,$isQuoteNode as Ut,HeadingNode as Hn,QuoteNode as Kn}from"@lexical/rich-text";import{$createLineBreakNode as Un}from"lexical";var Vt=/^[\t ]*$/,Yt=/^(\s*)(\d+)\.\s/,jt=/^(\s*)[-*+]\s/,Wt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,tt=/^(#{1,6})\s/,qt=/^>\s/,Vn=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,Xt=/[ \t]*(\\`\\`\\`|```)$/,Xn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,Gn=/^\|(.+)\|\s?$/,zn=/^(\| ?:?-*:? ?)+\|\s?$/,Gt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,zt=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,Yn=r=>(t,e,o)=>{let n=r(o);n.append(...e),t.replace(n),n.select(0,0)},Qt=4;function jn(r){let t=r.match(/\t/g),e=r.match(/ /g),o=0;return t&&(o+=t.length),e&&(o+=Math.floor(e.length/Qt)),o}var ot=r=>(t,e,o)=>{let n=t.getPreviousSibling(),c=t.getNextSibling(),s=Dn(r==="check"?o[3]==="x":void 0);if(M(c)&&c.getListType()===r){let l=c.getFirstChild();l!==null?l.insertBefore(s):c.append(s),t.remove()}else if(M(n)&&n.getListType()===r)n.append(s),t.remove();else{let l=Ln(r,r==="number"?Number(o[2]):void 0);l.append(s),t.replace(l)}s.append(...e),s.select(0,0);let i=jn(o[1]);i&&s.setIndent(i)},V=(r,t,e)=>{let o=[],n=r.getChildren(),c=0;for(let s of n)if($n(s)){if(s.getChildrenSize()===1){let u=s.getFirstChild();if(M(u)){o.push(V(u,t,e+1));continue}}let i=" ".repeat(e*Qt),l=r.getListType(),a=l==="number"?`${r.getStart()+c}. `:l==="check"?`- [${s.getChecked()?"x":" "}] `:"- ";o.push(i+a+t(s)),c++}return o.join(`
|
|
7
|
+
`)},Jt={type:"element",dependencies:[Hn],export:(r,t)=>{if(!Pn(r))return null;let e=Number(r.getTag().slice(1));return"#".repeat(e)+" "+t(r)},regExp:tt,replace:Yn(r=>{let t="h"+r[1].length;return Bn(t)})},Zt={type:"element",dependencies:[Kn],export:(r,t)=>{if(!Ut(r))return null;let e=t(r).split(`
|
|
8
|
+
`),o=[];for(let n of e)o.push("> "+n);return o.join(`
|
|
9
|
+
`)},regExp:qt,replace:(r,t,e,o)=>{if(o){let c=r.getPreviousSibling();if(Ut(c)){c.splice(c.getChildrenSize(),0,[Un(),...t]),c.select(0,0),r.remove();return}}let n=vn();n.append(...t),r.replace(n),n.select(0,0)}},te={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?V(r,t,0):null,regExp:jt,replace:ot("bullet")},Wn={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?V(r,t,0):null,regExp:Wt,replace:ot("check")},ee={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?V(r,t,0):null,regExp:Yt,replace:ot("number")},ne={type:"text-format",format:["code"],tag:"`"},oe={type:"text-format",format:["highlight"],tag:"=="},re={type:"text-format",format:["bold","italic"],tag:"***"},ie={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},se={type:"text-format",format:["bold"],tag:"**"},ce={type:"text-format",format:["bold"],intraword:!1,tag:"__"},le={type:"text-format",format:["strikethrough"],tag:"~~"},ae={type:"text-format",format:["italic"],tag:"*"},fe={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function ue(r,t){let e=r.split(`
|
|
10
|
+
`),o=!1,n=[],c=0;for(let s=0;s<e.length;s++){let i=e[s],l=n[n.length-1];if(Xn.test(i)){n.push(i);continue}if(Xt.test(i)){c===0&&(o=!0),c===1&&(o=!1),c>0&&c--,n.push(i);continue}if(Vn.test(i)){o=!0,c++,n.push(i);continue}if(o){n.push(i);continue}Vt.test(i)||Vt.test(l)||!l||tt.test(l)||tt.test(i)||qt.test(i)||Yt.test(i)||jt.test(i)||Wt.test(i)||Gn.test(i)||zn.test(i)||!t||Gt.test(i)||zt.test(i)||Gt.test(l)||zt.test(l)||Xt.test(l)?n.push(i):n[n.length-1]=l+" "+i.trim()}return n.join(`
|
|
11
|
+
`)}var qn=[Jt,Zt,te,ee],Qn=[],Jn=[ne,re,ie,se,ce,oe,ae,fe,le],Zn=[],U=[...qn,...Qn,...Jn,...Zn];function Hr(r,t=U,e,o=!1,n=!0){let c=o?r:ue(r,n);return Bt(t,o)(c,e)}function Kr(r=U,t,e=!1){return It(r,e)(t)}export{Ir as a,Hr as b,Kr as c,st as d,ro as e,fo as f,Re as g,G as h,lt as i,ko as j,Ze as k,Oo as l,Rt as m,Ao as n,Do as o,Lo as p};
|
|
12
|
+
//# sourceMappingURL=chunk-UOYS7JHZ.js.map
|