@payloadcms/richtext-lexical 3.59.0-canary.0 → 3.59.0-internal.56a1b3b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/exports/client/{Field-U4WLAHNW.js → Field-2MCIQXRP.js} +2 -2
  2. package/dist/exports/client/bundled.css +1 -1
  3. package/dist/exports/client/chunk-K47TNP5J.js +2 -0
  4. package/dist/exports/client/chunk-K47TNP5J.js.map +7 -0
  5. package/dist/exports/client/chunk-TLQLXR6Q.js +12 -0
  6. package/dist/exports/client/chunk-TLQLXR6Q.js.map +7 -0
  7. package/dist/exports/client/componentInline-AGFSKAY4.js +2 -0
  8. package/dist/exports/client/index.d.ts +3 -0
  9. package/dist/exports/client/index.d.ts.map +1 -1
  10. package/dist/exports/client/index.js +35 -10
  11. package/dist/exports/client/index.js.map +4 -4
  12. package/dist/features/blocks/client/component/BlockContent.d.ts +52 -27
  13. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  14. package/dist/features/blocks/client/component/BlockContent.js +45 -51
  15. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  16. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +2 -9
  17. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
  18. package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -25
  19. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  20. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  21. package/dist/features/blocks/client/component/index.js +62 -50
  22. package/dist/features/blocks/client/component/index.js.map +1 -1
  23. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  24. package/dist/features/blocks/client/componentInline/index.js +0 -1
  25. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  26. package/dist/features/blocks/client/index.d.ts.map +1 -1
  27. package/dist/features/blocks/client/index.js +5 -0
  28. package/dist/features/blocks/client/index.js.map +1 -1
  29. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +6 -0
  30. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -0
  31. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +24 -0
  32. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -0
  33. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +6 -0
  34. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -0
  35. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +20 -0
  36. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -0
  37. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +12 -0
  38. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -0
  39. package/dist/features/blocks/client/markdown/markdownTransformer.js +348 -0
  40. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -0
  41. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +5 -0
  42. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -0
  43. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +149 -0
  44. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -0
  45. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +53 -0
  46. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +1 -0
  47. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +84 -0
  48. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -0
  49. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +4 -0
  50. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +1 -0
  51. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +17 -0
  52. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -0
  53. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +4 -0
  54. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +1 -0
  55. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +26 -0
  56. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -0
  57. package/dist/features/blocks/premade/CodeBlock/converter.d.ts +7 -0
  58. package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +1 -0
  59. package/dist/features/blocks/premade/CodeBlock/converter.js +46 -0
  60. package/dist/features/blocks/premade/CodeBlock/converter.js.map +1 -0
  61. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +2 -0
  62. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +1 -0
  63. package/dist/features/blocks/premade/CodeBlock/converterClient.js +4 -0
  64. package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +1 -0
  65. package/dist/features/blocks/premade/CodeBlock/index.d.ts +7 -0
  66. package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -0
  67. package/dist/features/blocks/premade/CodeBlock/index.js +52 -0
  68. package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -0
  69. package/dist/features/blocks/server/index.js +1 -1
  70. package/dist/features/blocks/server/index.js.map +1 -1
  71. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +6 -0
  72. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +1 -0
  73. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +27 -0
  74. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +1 -0
  75. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +7 -0
  76. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +1 -0
  77. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +22 -0
  78. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +1 -0
  79. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
  80. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +1 -0
  81. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +15 -0
  82. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -0
  83. package/dist/features/blocks/server/{markdownTransformer.js → markdown/markdownTransformer.js} +6 -48
  84. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -0
  85. package/dist/field/bundled.css +1 -1
  86. package/dist/index.d.ts +1 -0
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +1 -0
  89. package/dist/index.js.map +1 -1
  90. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  91. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +5 -5
  92. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  93. package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
  94. package/dist/lexical/ui/icons/CodeBlock/index.js +10 -15
  95. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  96. package/dist/lexical/ui/icons/Collapse/index.d.ts +3 -0
  97. package/dist/lexical/ui/icons/Collapse/index.d.ts.map +1 -0
  98. package/dist/lexical/ui/icons/Collapse/index.js +18 -0
  99. package/dist/lexical/ui/icons/Collapse/index.js.map +1 -0
  100. package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
  101. package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
  102. package/package.json +7 -7
  103. package/dist/exports/client/chunk-3BY5IZJD.js +0 -2
  104. package/dist/exports/client/chunk-3BY5IZJD.js.map +0 -7
  105. package/dist/exports/client/chunk-YCH4JNUH.js +0 -12
  106. package/dist/exports/client/chunk-YCH4JNUH.js.map +0 -7
  107. package/dist/exports/client/componentInline-7TPI7ZBC.js +0 -2
  108. package/dist/features/blocks/client/markdownTransformer.d.ts +0 -17
  109. package/dist/features/blocks/client/markdownTransformer.d.ts.map +0 -1
  110. package/dist/features/blocks/client/markdownTransformer.js +0 -144
  111. package/dist/features/blocks/client/markdownTransformer.js.map +0 -1
  112. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
  113. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +0 -1
  114. package/dist/features/blocks/server/markdownTransformer.d.ts +0 -22
  115. package/dist/features/blocks/server/markdownTransformer.d.ts.map +0 -1
  116. package/dist/features/blocks/server/markdownTransformer.js.map +0 -1
  117. /package/dist/exports/client/{Field-U4WLAHNW.js.map → Field-2MCIQXRP.js.map} +0 -0
  118. /package/dist/exports/client/{componentInline-7TPI7ZBC.js.map → componentInline-AGFSKAY4.js.map} +0 -0
  119. /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.d.ts → markdown/linesFromMatchToContentAndPropsString.d.ts} +0 -0
  120. /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.js → markdown/linesFromMatchToContentAndPropsString.js} +0 -0
@@ -0,0 +1,2 @@
1
+ import{a as ie}from"./chunk-INBEEENE.js";import{b as se}from"./chunk-BZZVLW4U.js";import{jsx as r,jsxs as p,Fragment as we}from"react/jsx-runtime";import O,{createContext as Ie,useCallback as A,useEffect as v,useMemo as N,useRef as x}from"react";import{useLexicalComposerContext as ve}from"@lexical/react/LexicalComposerContext";import{getTranslation as ce}from"@payloadcms/translations";import{Button as ae,Drawer as Ne,EditDepthProvider as Oe,Form as Te,formatDrawerSlug as $e,FormSubmit as Pe,RenderFields as Re,ShimmerEffect as Ee,useConfig as Le,useDocumentForm as je,useDocumentInfo as Me,useEditDepth as Ae,useServerFunctions as Je,useTranslation as Ke}from"@payloadcms/ui";import{abortAndIgnore as J}from"@payloadcms/ui/shared";import{$getNodeByKey as K}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as z,reduceFieldsToValues as ze}from"payload/shared";import{v4 as He}from"uuid";import{jsx as Ce}from"react/jsx-runtime";import _e from"bson-objectid";import ye from"react";import Be from"bson-objectid";import{DecoratorNode as xe}from"lexical";var B=class extends xe{__cacheBuster;__fields;constructor({cacheBuster:e,fields:t,key:l}){super(l),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 Se(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(){let e=document.createElement("span");return e.classList.add("inline-block-container"),e}decorate(e,t){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let t=document.createTextNode(this.getTextContent());return e.append(t),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e,t){let l=this.getWritable();l.__fields=e,t||l.__cacheBuster++}updateDOM(){return!1}};function Se(s){return new B({fields:{...s,id:s?.id||new Be.default().toHexString()}})}var Fe=ye.lazy(()=>import("./componentInline-AGFSKAY4.js").then(s=>({default:s.InlineBlockComponent}))),I=class extends B{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return De(e.fields)}decorate(e,t){return Ce(Fe,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function De(s){return new I({fields:{...s,id:s?.id||new _e.default().toHexString()}})}function M(s){return s instanceof I}var f="inline-block",ue=Ie({initialState:!1}),mt=()=>O.use(ue),ft=s=>{let{cacheBuster:e,formData:t,nodeKey:l}=s,[d]=ve(),{i18n:T,t:m}=Ke(),{createdInlineBlock:H,fieldProps:{featureClientSchemaMap:de,initialLexicalFormState:me,readOnly:S,schemaPath:V},setCreatedInlineBlock:W,uuid:fe}=se(),{fields:C}=je(),{getFormState:_}=Je(),pe=Ae(),q=x(!1),[c,$]=O.useState(()=>me?.[t.id]?.formState),G=x(!1),Q=x(e);v(()=>{G.current?(Q.current!==e&&$(!1),Q.current=e):G.current=!0},[e]);let[P,U]=O.useState(c?._components?.customComponents?.BlockLabel),[X,Y]=O.useState(c?._components?.customComponents?.Block),Z=$e({slug:`lexical-inlineBlocks-create-${fe}-${t.id}`,depth:pe}),{toggleDrawer:b}=ie(Z,!0),be=x(null),{id:y,collectionSlug:F,getDocPreferences:D,globalSlug:w}=Me(),{config:ke}=Le(),he=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${t.blockType}`,k=de.blocks?.[he]?.[0],a=k.blockReferences?typeof k?.blockReferences?.[0]=="string"?ke.blocksMap[k?.blockReferences?.[0]]:k?.blockReferences?.[0]:k?.blocks?.[0],ee=a?.fields??[];v(()=>{!q.current&&H?.getKey()===l&&(ee.length>2&&b(),W?.(void 0),q.current=!0)},[ee.length,H,l,W,b]);let te=A(()=>{d.update(()=>{K(l)?.remove()})},[d,l]),h=a?.labels?.singular?ce(a?.labels.singular,T):a?.slug,R=x(new AbortController),g=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${a?.slug}.fields`;v(()=>{let n=new AbortController;return t&&!c&&(async()=>{let{state:o}=await _({id:y,collectionSlug:F,data:t,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:z(C),globalSlug:w,initialBlockData:t,initialBlockFormState:t,operation:"update",renderAllFields:!0,schemaPath:g,signal:n.signal});if(o){let u=ze(z(o),!0);d.update(()=>{let j=K(l);if(j&&M(j)){let le=u;le.blockType=t.blockType,j.setFields(le,!0)}}),$(o),U(o._components?.customComponents?.BlockLabel),Y(o._components?.customComponents?.Block)}})(),()=>{J(n)}},[_,d,l,g,y,t,c,F,w,D,C]);let ne=A(async({formState:n,submit:i})=>{J(R.current);let o=new AbortController;R.current=o;let{state:u}=await _({id:y,collectionSlug:F,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:z(C),formState:n,globalSlug:w,initialBlockFormState:n,operation:"update",renderAllFields:!!i,schemaPath:g,signal:o.signal});return u?(i&&(U(u._components?.customComponents?.BlockLabel),Y(u._components?.customComponents?.Block)),u):n},[_,y,F,D,C,w,g]);v(()=>{let n=(i,o)=>Object.keys(o).some(u=>o[u]&&i[u]!==o[u].value);return()=>{c&&n(t,c)&&$(!1),J(R.current)}},[t,c]);let ge=A((n,i)=>{i.blockType=t.blockType,d.update(()=>{let o=K(l);o&&M(o)&&o.setFields(i,!0)})},[d,l,t]),E=N(()=>()=>r(ae,{buttonStyle:"icon-label",className:`${f}__removeButton`,disabled:S,icon:"x",onClick:n=>{n.preventDefault(),te()},round:!0,size:"small",tooltip:m("lexical:blocks:inlineBlocks:remove",{label:h})}),[h,S,te,m]),oe=N(()=>()=>r(ae,{buttonStyle:"icon-label",className:`${f}__editButton`,disabled:S,el:"button",icon:"edit",onClick:()=>{b()},round:!0,size:"small",tooltip:m("lexical:blocks:inlineBlocks:edit",{label:h})}),[h,S,m,b]),L=N(()=>({children:n,className:i})=>r("div",{className:[f,f+"-"+t.blockType,i].filter(Boolean).join(" "),ref:be,children:n}),[t.blockType]),re=N(()=>P?()=>P:()=>r("div",{children:a?.labels?ce(a?.labels.singular,T):""}),[P,a?.labels,T]);return a?p(Te,{beforeSubmit:[async({formState:n})=>await ne({formState:n,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:a?.fields,initialState:c||{},onChange:[ne],onSubmit:(n,i)=>{ge(n,i),b()},uuid:He(),children:[r(Oe,{children:r(Ne,{className:"",slug:Z,title:m(`lexical:blocks:inlineBlocks:${t?.id?"edit":"create"}`,{label:h??m("lexical:blocks:inlineBlocks:label")}),children:c?p(we,{children:[r(Re,{fields:a?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:g,permissions:!0,readOnly:!1}),r(Pe,{programmaticSubmit:!0,children:m("fields:saveChanges")})]}):null})}),X?r(ue,{value:{EditButton:oe,initialState:c,InlineBlockContainer:L,Label:re,nodeKey:l,RemoveButton:E},children:X}):p(L,{children:[c?r(re,{}):r(Ee,{height:"15px",width:"40px"}),d.isEditable()?p("div",{className:`${f}__actions`,children:[r(oe,{}),r(E,{})]}):null]})]}):p(L,{className:`${f}-not-found`,children:[p("span",{children:["Error: Block '",t.blockType,"' not found"]}),d.isEditable()?r("div",{className:`${f}__actions`,children:r(E,{})}):null]})};export{mt as a,ft as b,I as c,De as d,M as e};
2
+ //# sourceMappingURL=chunk-K47TNP5J.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, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, readOnly, 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 () => initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n 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={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[baseClass, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={false}\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 {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport type { EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields<TBlockFields>\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n override createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
5
+ "mappings": "mJAEA,OAAOA,GAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,MAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,mBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OAASC,iBAAAA,MAAqB,UAI9B,OAASC,8CAAAA,EAA4CC,wBAAAA,OAA4B,iBACjF,OAASC,MAAMC,OAAY,gDC5B3B,OAAOC,OAAc,gBACrB,OAAOC,OAAyB,QCUhC,OAAOC,OAAc,gBACrB,OAASC,iBAAAA,OAAqB,UAgBvB,IAAMC,EAAN,cAAoCD,EAAA,CACzCE,cACAC,SAEAC,YAAY,CACVC,YAAAA,EACAC,OAAAA,EACAC,IAAAA,CAAG,EAKF,CACD,MAAMA,CAAA,EACN,KAAKJ,SAAWG,EAChB,KAAKJ,cAAgBG,GAAe,CACtC,CAEA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C,GAAA,CAAcC,OAAO,OAAOC,MAAM,SAC9DpJ,EAAOqJ,WAAU,EAChBpB,EAAC,MAAA,CAAInB,UAAW,GAAG1H,CAAA,sBACjBuH,EAACa,GAAA,CAAA,CAAA,EACDb,EAACF,EAAA,CAAA,CAAA,CAAA,IAED,IAAA,OA3ERwB,EAACP,EAAA,CAAqBZ,UAAW,GAAG1H,CAAA,uBAClC6I,EAAC,OAAA,WAAK,iBAAenI,EAASuD,UAAU,aAAA,IACvCrD,EAAOqJ,WAAU,EAChB1C,EAAC,MAAA,CAAIG,UAAW,GAAG1H,CAAA,qBACjBuH,EAACF,EAAA,CAAA,CAAA,IAED,IAAA,GA0EZ",
6
+ "names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useConfig", "useDocumentForm", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "deepCopyObjectSimpleWithoutReactComponents", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "React", "ObjectID", "DecoratorNode", "ServerInlineBlockNode", "__cacheBuster", "__fields", "constructor", "cacheBuster", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getCacheBuster", "getLatest", "setFields", "preventFormStateUpdate", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "editor", "config", "_jsx", "cacheBuster", "getCacheBuster", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "use", "InlineBlockComponent", "props", "cacheBuster", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "readOnly", "schemaPath", "setCreatedInlineBlock", "uuid", "uuidFromContext", "useEditorConfigContext", "fields", "parentDocumentFields", "useDocumentForm", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "firstTimeDrawer", "useRef", "setInitialState", "useState", "id", "formState", "hasMounted", "prevCacheBuster", "useEffect", "current", "CustomLabel", "setCustomLabel", "customComponents", "BlockLabel", "CustomBlock", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "config", "useConfig", "componentMapRenderedBlockPath", "blockType", "blocksField", "clientBlock", "blockReferences", "blocksMap", "blocks", "clientBlockFields", "getKey", "length", "undefined", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "docPreferences", "documentFormState", "deepCopyObjectSimpleWithoutReactComponents", "initialBlockData", "initialBlockFormState", "operation", "renderAllFields", "signal", "newFormStateData", "reduceFieldsToValues", "node", "$isInlineBlockNode", "newData", "setFields", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "isStateOutOfSync", "Object", "keys", "some", "key", "value", "onFormSubmit", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "onClick", "e", "preventDefault", "round", "size", "tooltip", "label", "EditButton", "el", "InlineBlockContainer", "children", "filter", "Boolean", "join", "ref", "Label", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "title", "_Fragment", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "permissions", "FormSubmit", "programmaticSubmit", "ShimmerEffect", "height", "width", "isEditable"]
7
+ }
@@ -0,0 +1,12 @@
1
+ var nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";import{c as ae}from"react/compiler-runtime";import{useRef as le}from"react";function Gn(n){let t=ae(2),e=n===void 0?500:n,o=le(void 0),r;return t[0]!==e?(r=s=>new Promise(i=>{let a=()=>{s(),i()};"requestIdleCallback"in window?("cancelIdleCallback"in window&&o.current!==void 0&&cancelIdleCallback(o.current),o.current=requestIdleCallback(a,{timeout:e})):fe().then(a)}),t[0]=e,t[1]=r):r=t[1],r}function fe(){return new Promise(n=>{setTimeout(n,100),requestAnimationFrame(()=>{setTimeout(n,0)})})}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 ot(n){return n instanceof G}import{jsx as be}from"react/jsx-runtime";import{useLexicalComposerContext as Ae}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Oe}from"@lexical/utils";import{$getSelection as Y,$isRangeSelection as W,$isTextNode as ke,COMMAND_PRIORITY_LOW as Me,createCommand as Le,getDOMSelection as $e}from"lexical";import{useCallback as gt,useEffect as pt,useState as De}from"react";import*as X from"react";import{c as lt}from"react/compiler-runtime";import{useLexicalComposerContext as ft}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as rt}from"@lexical/utils";import{$getSelection as ut,$isRangeSelection as ue,$setSelection as de,COMMAND_PRIORITY_LOW as it,COMMAND_PRIORITY_NORMAL as $,createCommand as me,KEY_ARROW_DOWN_COMMAND as ge,KEY_ARROW_UP_COMMAND as pe,KEY_ENTER_COMMAND as he,KEY_ESCAPE_COMMAND as xe,KEY_TAB_COMMAND as Ee}from"lexical";import{useCallback as z,useEffect as N,useLayoutEffect as _e,useMemo as Te,useRef as Se,useState as we}from"react";var Re="slash-menu-popup",st=n=>{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"}),n.scrollIntoView({block:"nearest"})};function Ce(n,t,e){let o=e;for(let r=o;r<=t.length;r++)n.substring(n.length-r)===t.substring(0,r)&&(o=r);return o}function Fe(n){let t=ut();if(!ue(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let o=e.getNode();if(!o.isSimpleText())return;let r=e.offset,c=o.getTextContent().slice(0,r),s=n.replaceableString.length,i=Ce(c,n.matchingString,s),a=r-i;if(a<0)return;let l;return a===0?[l]=o.splitText(r):[,l]=o.splitText(a,r),l}function Ie(n,t){let e=getComputedStyle(n),o=e.position==="absolute",r=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let c=n;c=c.parentElement;)if(e=getComputedStyle(c),!(o&&e.position==="static")&&r.test(e.overflow+e.overflowY+e.overflowX))return c;return document.body}function ct(n,t){let e=n.getBoundingClientRect(),o=t.getBoundingClientRect();return e.top>o.top&&e.top<o.bottom}function Ne(n,t,e,o){let r=lt(7),[c]=ft(),s,i;r[0]!==c||r[1]!==e||r[2]!==o||r[3]!==n||r[4]!==t?(s=()=>{let a=t.current;if(a!=null&&n!=null){let l=c.getRootElement(),u=l!=null?Ie(l,!1):document.body,g=!1,m=ct(a,u),p=function(){g||(window.requestAnimationFrame(function(){e(),g=!1}),g=!0);let d=ct(a,u);d!==m&&(m=d,o?.(d))},f=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",p,{capture:!0,passive:!0}),f.observe(a),()=>{f.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",p,!0)}}},i=[c,o,e,n,t],r[0]=c,r[1]=e,r[2]=o,r[3]=n,r[4]=t,r[5]=s,r[6]=i):(s=r[5],i=r[6]),N(s,i)}var at=me("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function dt({anchorElementRef:n,close:t,editor:e,groups:o,menuRenderFn:r,resolution:c,shouldSplitNodeWithQuery:s=!1}){let[i,a]=we(null),l=c.match&&c.match.matchingString||"",u=z(f=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${Re}__item-${f.key}`),a(f.key))},[e]),g=z(()=>{if(o!==null&&l!=null){let f=o.flatMap(d=>d.items);if(f.length){let d=f[0];u(d)}}},[o,u,l]);N(()=>{g()},[l,g]);let m=z(f=>{t(),e.update(()=>{let d=c.match!=null&&s?Fe(c.match):null;d&&d.remove()}),setTimeout(()=>{let d;e.read(()=>{d=ut()?.clone()}),e.update(()=>{d&&de(d)}),f.onSelect({editor:e,queryString:c.match?c.match.matchingString:""})},0)},[e,s,c.match,t]);N(()=>()=>{let f=e.getRootElement();f!==null&&f.removeAttribute("aria-activedescendant")},[e]),_e(()=>{o===null?a(null):i===null&&g()},[o,i,u,g]),N(()=>rt(e.registerCommand(at,({item:f})=>f.ref&&f.ref.current!=null?(st(f.ref.current),!0):!1,it)),[e,u]),N(()=>rt(e.registerCommand(ge,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(at,{index:E,item:_}),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(pe,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&&st(_.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(xe,f=>{let d=f;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},it),e.registerCommand(Ee,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(he,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 p=Te(()=>({groups:o,selectedItemKey:i,selectItemAndCleanUp:m,setSelectedItemKey:a}),[m,i,o]);return r(n,p,c.match?c.match.matchingString:"")}function ye(n,t){t!=null&&(n.className=t),n.setAttribute("aria-label","Slash menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function mt(n,t,e,o){let r=lt(14),[c]=ft(),s;r[0]===Symbol.for("react.memo_cache_sentinel")?(s=nt?document.createElement("div"):null,r[0]=s):s=r[0];let i=Se(s),a;r[1]!==n||r[2]!==o||r[3]!==c||r[4]!==t?(a=()=>{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(),I=T;if(T=T-(n.getBoundingClientRect().top+window.scrollY),_=_-(n.getBoundingClientRect().left+window.scrollX),d.style.left=`${_+window.scrollX}px`,d.style.height=`${x}px`,d.style.width=`${E}px`,h!==null){let S=h.getBoundingClientRect(),L=S.height,C=S.width,et=f.getBoundingClientRect();_+C>et.right&&(d.style.left=`${et.right-C+window.scrollX}px`);let se=I+L+32>window.innerHeight,ce=I<0;se&&!ce?d.style.top=`${T+32-L+window.scrollY-(x+24)}px`:d.style.top=`${T+window.scrollY+32}px`}d.isConnected||(ye(d,o),n.append(d)),d.setAttribute("id","slash-menu"),i.current=d,f.setAttribute("aria-controls","slash-menu")}},r[1]=n,r[2]=o,r[3]=c,r[4]=t,r[5]=a):a=r[5];let l=a,u,g;r[6]!==c||r[7]!==l||r[8]!==t?(u=()=>{let f=c.getRootElement();if(t!==null)return l(),()=>{f!==null&&f.removeAttribute("aria-controls");let d=i.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},g=[c,l,t],r[6]=c,r[7]=l,r[8]=t,r[9]=u,r[10]=g):(u=r[9],g=r[10]),N(u,g);let m;return r[11]!==t||r[12]!==e?(m=f=>{t!==null&&(f||e(null))},r[11]=t,r[12]=e,r[13]=m):m=r[13],Ne(t,i,l,m),i}var io=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Be(n){let t=n.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 ht(n,t,e){let o=$e(e);if(o===null||!o.isCollapsed)return!1;let r=o.anchorNode,c=n,s=o.anchorOffset;if(r==null||s==null)return!1;try{t.setStart(r,c),t.setEnd(r,s>1?s:1)}catch{return!1}return!0}function Pe(n){let t;return n.getEditorState().read(()=>{let e=Y();W(e)&&(t=Be(e))}),t}function xt(n,t){return t!==0?!1:n.getEditorState().read(()=>{let e=Y();if(W(e)){let c=e.anchor.getNode().getPreviousSibling();return ke(c)&&c.isTextEntity()}return!1})}function Et(n){X.startTransition?X.startTransition(n):n()}var ve=Le("ENABLE_SLASH_MENU_COMMAND");function so({anchorClassName:n,anchorElem:t,groups:e,menuRenderFn:o,onClose:r,onOpen:c,onQueryChange:s,triggerFn:i}){let[a]=Ae(),[l,u]=De(null),g=mt(t,l,u,n),m=gt(()=>{u(null),r!=null&&l!==null&&r()},[r,l]),p=gt(f=>{u(f),c!=null&&l===null&&c(f)},[c,l]);return pt(()=>Oe(a.registerCommand(ve,({node:f})=>(a.getEditorState().read(()=>{let d={leadOffset:0,matchingString:"",replaceableString:""};if(!xt(a,d.leadOffset)&&f!==null){let h=a._window??window,x=h.document.createRange();ht(d.leadOffset,x,h)!==null&&Et(()=>p({getRect:()=>x.getBoundingClientRect(),match:d}));return}}),!0),Me)),[a,p]),pt(()=>{let f=()=>{a.getEditorState().read(()=>{let h=a._window??window,x=h.document.createRange(),E=Y(),_=Pe(a);if(!W(E)||!E.isCollapsed()||_===void 0||x===null){m();return}let T=i({editor:a,query:_});if(s(T?T.matchingString:null),T!==null&&!xt(a,T.leadOffset)&&ht(T.leadOffset,x,h)!==null){Et(()=>p({getRect:()=>x.getBoundingClientRect(),match:T}));return}m()})},d=a.registerUpdateListener(f);return()=>{d()}},[a,i,s,l,m,p]),g.current===null||l===null||a===null?null:be(dt,{anchorElementRef:g,close:m,editor:a,groups:e,menuRenderFn:o,resolution:l,shouldSplitNodeWithQuery:!0})}var _t=class n{_bottom;_left;_right;_top;constructor(t,e,o,r){let[c,s]=e<=r?[e,r]:[r,e],[i,a]=t<=o?[t,o]:[o,t];this._top=c,this._right=a,this._left=i,this._bottom=s}static fromDOM(t){let{height:e,left:o,top:r,width:c}=t.getBoundingClientRect();return n.fromLWTH(o,c,r,e)}static fromDOMRect(t){let{height:e,left:o,top:r,width:c}=t;return n.fromLWTH(o,c,r,e)}static fromLTRB(t,e,o,r){return new n(t,e,o,r)}static fromLWTH(t,e,o,r){return new n(t,o,t+e,o+r)}static fromPoints(t,e){let{x:o,y:r}=t,{x:c,y:s}=e;return n.fromLTRB(o,r,c,s)}contains(t){if(ot(t)){let{x:s,y:i}=t,a=i<this._top,l=i>this._bottom,u=s<this._left,g=s>this._right;return{reason:{isOnBottomSide:l,isOnLeftSide:u,isOnRightSide:g,isOnTopSide:a},result:!a&&!l&&!u&&!g}}let{bottom:e,left:o,right:r,top:c}=t;return c>=this._top&&c<=this._bottom&&e>=this._top&&e<=this._bottom&&o>=this._left&&o<=this._right&&r>=this._left&&r<=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,r=0;return t.x<this._left?o=this._left-t.x:t.x>this._right&&(o=t.x-this._right),t.y<this._top?r=this._top-t.y:t.y>this._bottom&&(r=t.y-this._bottom),{distance:Math.sqrt(o*o+r*r),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:r}){return r===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:r=this.top}){return new n(e,r,o,t)}intersectsWith(t){let{height:e,left:o,top:r,width:c}=t,{height:s,left:i,top:a,width:l}=this,u=o+c>=i+l?o+c:i+l,g=r+e>=a+s?r+e:a+s,m=o<=i?o:i,p=r<=a?r:a;return u-m<=c+l&&g-p<=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)}};function fo({editorConfig:n}){return He({nodes:n.features.nodes})}function He({nodes:n}){return n.map(t=>"node"in t?t.node:t)}import{$getRoot as Qe,$isDecoratorNode as Ct,$isElementNode as P,$isLineBreakNode as je,$isTextNode as v}from"lexical";import{$isListItemNode as Ke,$isListNode as Tt}from"@lexical/list";import{$isHeadingNode as Ue,$isQuoteNode as Ge}from"@lexical/rich-text";import{$isParagraphNode as ze,$isTextNode as Xe}from"lexical";var w={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...w,requiresParagraphStart:!0},ho={...R,export:y(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},xo={...R,export:y(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},Eo={...R,export:y(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},_o={...R,export:y(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},To={...R,export:y(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},So={...R,export:y(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},wo={...R,export:We,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},Ro={...R,export:q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},Co={...R,export:q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},Fo={...R,export:q,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},Io={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},No={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},yo={...w,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},bo={...w,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},Ao={...w,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},Oo={...w,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},ko={...w,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Mo={...w,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Lo={...w,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},$o={...w,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},Do={...w,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},Bo={...w,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Po={...w,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},vo={...w,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function y(n){return(t,e)=>Ue(t)&&t.getTag()==="h"+n?"#".repeat(n)+" "+e(t):null}function q(n,t){return Tt(n)?St(n,t,0):null}var Ye=4;function St(n,t,e){let o=[],r=n.getChildren(),c=0;for(let s of r)if(Ke(s)){if(s.getChildrenSize()===1){let l=s.getFirstChild();if(Tt(l)){o.push(St(l,t,e+1));continue}}let i=" ".repeat(e*Ye),a=n.getListType()==="bullet"?"- ":`${n.getStart()+c}. `;o.push(i+a+t(s)),c++}return o.join(`
2
+ `)}function We(n,t){return Ge(n)?"> "+t(n):null}function D(n,t){let e={};for(let o of n){let r=t(o);r&&(e[r]?e[r].push(o):e[r]=[o])}return e}function b(n){let t=D(n,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var A=/[!-/:-@[-`{-~\s]/,qe=/^\s{0,3}$/;function M(n){if(!ze(n))return!1;let t=n.getFirstChild();return t==null||n.getChildrenSize()===1&&Xe(t)&&qe.test(t.getTextContent())}function Ft(n,t=!1){let e=b(n),o=[...e.multilineElement,...e.element],r=!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=[],a=(s||Qe()).getChildren();return a.forEach((l,u)=>{let g=Ve(l,o,c,e.textMatch);g!=null&&i.push(r&&u>0&&!M(l)&&!M(a[u-1])?`
3
+ `.concat(g):g)}),i.join(`
4
+ `)}}function Ve(n,t,e,o){for(let r of t){if(!r.export)continue;let c=r.export(n,s=>H(s,e,o));if(c!=null)return c}return P(n)?H(n,e,o):Ct(n)?n.getTextContent():null}function H(n,t,e,o,r){let c=[],s=n.getChildren();o||(o=[]),r||(r=[]);t:for(let i of s){for(let a of e){if(!a.export)continue;let l=a.export(i,u=>H(u,t,e,o,[...r,...o]),(u,g)=>wt(u,g,t,o,r));if(l!=null){c.push(l);continue t}}je(i)?c.push(`
5
+ `):v(i)?c.push(wt(i,i.getTextContent(),t,o,r)):P(i)?c.push(H(i,t,e,o,r)):Ct(i)&&c.push(i.getTextContent())}return c.join("")}function wt(n,t,e,o,r){let c=t.trim(),s=c;n.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",a="",l="",u=Rt(n,!0),g=Rt(n,!1),m=new Set;for(let p of e){let f=p.format[0],d=p.tag;B(n,f)&&!m.has(f)&&(m.add(f),(!B(u,f)||!o.find(h=>h.tag===d))&&(o.push({format:f,tag:d}),i+=d))}for(let p=0;p<o.length;p++){let f=o[p],d=B(n,f.format),h=B(g,f.format);if(d&&h)continue;let x=[...o];for(;x.length>p;){let E=x.pop();r&&E&&r.find(_=>_.tag===E.tag)||(E&&typeof E.tag=="string"&&(d?h||(l+=E.tag):a+=E.tag),o.pop())}break}return s=i+s+l,a+t.replace(c,()=>s)}function Rt(n,t){let e=t?n.getPreviousSibling():n.getNextSibling();if(!e){let o=n.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(v(o))return o;e=t?e.getPreviousSibling():e.getNextSibling()}if(v(e))return e;if(!P(e))return null}return null}function B(n,t){return v(n)&&n.hasFormat(t)}import{$isListItemNode as Je,$isListNode as At}from"@lexical/list";import{$isQuoteNode as tn}from"@lexical/rich-text";import{$findMatchingParent as en}from"@lexical/utils";import{$createLineBreakNode as nn,$createParagraphNode as on,$createTextNode as rn,$getRoot as sn,$getSelection as cn,$isParagraphNode as an}from"lexical";import{$isTextNode as O}from"lexical";function It(n,t){let e=n.getTextContent(),o=Ze(e,t);if(!o)return null;let r=o.index||0,c=r+o[0].length,s=t.transformersByTag[o[1]];return{endIndex:c,match:o,startIndex:r,transformer:s}}function Ze(n,t){let e=n.match(t.openTagsRegExp);if(e==null)return null;for(let o of e){let r=o.replace(/^\s/,""),c=t.fullMatchRegExpByTag[r];if(c==null)continue;let s=n.match(c),i=t.transformersByTag[r];if(s!=null&&i!=null){if(i.intraword!==!1)return s;let{index:a=0}=s,l=n[a-1],u=n[a+s[0].length];if((!l||A.test(l))&&(!u||A.test(u)))return s}}return null}function Nt(n,t,e,o,r){let c=n.getTextContent(),s,i,a;if(r[0]===c?a=n:t===0?[a,s]=n.splitText(e):[i,a,s]=n.splitText(t,e),a.setTextContent(r[2]),o)for(let l of o.format)a.hasFormat(l)||a.toggleFormat(l);return{nodeAfter:s,nodeBefore:i,transformedNode:a}}function yt(n,t){let e=n,o,r,c,s;for(let i of t){if(!i.replace||!i.importRegExp)continue;let a=e.getTextContent().match(i.importRegExp);if(!a)continue;let l=a.index||0,u=i.getEndIndex?i.getEndIndex(e,a):l+a[0].length;u!==!1&&(o===void 0||r===void 0||l<o&&u>r)&&(o=l,r=u,c=i,s=a)}return o===void 0||r===void 0||c===void 0||s===void 0?null:{endIndex:r,match:s,startIndex:o,transformer:c}}function bt(n,t,e,o,r){let c,s,i;if(t===0?[i,c]=n.splitText(e):[s,i,c]=n.splitText(t,e),!o.replace)return null;let a=i?o.replace(i,r):void 0;return{nodeAfter:c,nodeBefore:s,transformedNode:a||void 0}}function F(n,t,e){let o=It(n,t),r=yt(n,e);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){let i=Nt(n,o.startIndex,o.endIndex,o.transformer,o.match);i.nodeAfter&&O(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&F(i.nodeAfter,t,e),i.nodeBefore&&O(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&F(i.nodeBefore,t,e),i.transformedNode&&O(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&F(i.transformedNode,t,e)}else if(r){let i=bt(n,r.startIndex,r.endIndex,r.transformer,r.match);if(!i)return;i.nodeAfter&&O(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&F(i.nodeAfter,t,e),i.nodeBefore&&O(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&F(i.nodeBefore,t,e),i.transformedNode&&O(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&F(i.transformedNode,t,e)}let s=n.getTextContent().replace(/\\([*_`~])/g,"$1");n.setTextContent(s)}function Ot(n,t=!1){let e=b(n),o=un(e.textFormat);return(r,c)=>{let s=r.split(`
6
+ `),i=s.length,a=c||sn();a.clear();for(let u=0;u<i;u++){let g=s[u],[m,p]=ln(s,u,e.multilineElement,a);if(m){u=p;continue}fn(g,a,e.element,o,e.textMatch)}let l=a.getChildren();for(let u of l)!t&&M(u)&&a.getChildrenSize()>1&&u.remove();cn()!==null&&a.selectStart()}}function ln(n,t,e,o){for(let r of e){let{handleImportAfterStartMatch:c,regExpEnd:s,regExpStart:i,replace:a}=r,l=n[t]?.match(i);if(!l)continue;if(c){let f=c({lines:n,rootNode:o,startLineIndex:t,startMatch:l,transformer:r});if(f===null)continue;if(f)return f}let u=typeof s=="object"&&"regExp"in s?s.regExp:s,g=s&&typeof s=="object"&&"optional"in s?s.optional:!s,m=t,p=n.length;for(;m<p;){let f=u?n[m]?.match(u):null;if(!f&&(!g||g&&m<p-1)){m++;continue}if(f&&t===m&&f.index===l.index){m++;continue}let d=[];if(f&&t===m)d.push(n[t].slice(l[0].length,-f[0].length));else for(let h=t;h<=m;h++){let x=n[h];if(h===t){let E=x.slice(l[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(a(o,null,l,f,d,!0)!==!1)return[!0,m];break}}return[!1,t]}function fn(n,t,e,o,r){let c=rn(n),s=on();s.append(c),t.append(s);for(let{regExp:i,replace:a}of e){let l=n.match(i);if(l&&(c.setTextContent(n.slice(l[0].length)),a(s,[c],l,!0)!==!1))break}if(F(c,o,r),s.isAttached()&&n.length>0){let i=s.getPreviousSibling();if(an(i)||tn(i)||At(i)){let a=i;if(At(i)){let l=i.getLastDescendant();l==null?a=null:a=en(l,Je)}a!=null&&a.getTextContentSize()>0&&(a.splice(a.getChildrenSize(),0,[nn(),...s.getChildren()]),s.remove())}}}function un(n){let t={},e={},o=[],r="(?<![\\\\])";for(let c of n){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(`${r}(${o.join("|")})`,"g"),transformersByTag:t}}import{$createRangeSelection as dn,$getSelection as Q,$isLineBreakNode as mn,$isRangeSelection as j,$isRootOrShadowRoot as Mt,$isTextNode as Lt,$setSelection as gn}from"lexical";function pn(n,t,e,o){let r=n.getParent();if(!Mt(r)||n.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExp:s,replace:i}of o){let a=c.match(s);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let l=t.getNextSiblings(),[u,g]=t.splitText(e);u?.remove();let m=g?[g,...l]:l;if(i(n,m,a,!1)!==!1)return!0}}return!1}function hn(n,t,e,o){let r=n.getParent();if(!Mt(r)||n.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExpEnd:s,regExpStart:i,replace:a}of o){if(s&&!("optional"in s)||s&&"optional"in s&&!s.optional)continue;let l=c.match(i);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let u=t.getNextSiblings(),[g,m]=t.splitText(e);g?.remove();let p=m?[m,...u]:u;if(a(n,p,l,null,null,!1)!==!1)return!0}}return!1}function xn(n,t,e){let o=n.getTextContent(),r=o[t-1],c=e[r];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 a=i.index||0,l=a+i[0].length,u;return a===0?[u]=n.splitText(l):[,u]=n.splitText(a,l),u&&(u.selectNext(0,0),s.replace(u,i)),!0}return!1}function En(n,t,e){let o=n.getTextContent(),r=t-1,c=o[r],s=e[c];if(!s)return!1;for(let i of s){let{tag:a}=i,l=a.length,u=r-l+1;if(l>1&&!$t(o,u,a,0,l)||o[u-1]===" ")continue;let g=o[r+1];if(i.intraword===!1&&g&&!A.test(g))continue;let m=n,p=m,f=kt(o,u,a),d=p;for(;f<0&&(d=d.getPreviousSibling())&&!mn(d);)if(Lt(d)){let C=d.getTextContent();p=d,f=kt(C,C.length,a)}if(f<0||p===m&&f+l===u)continue;let h=p.getTextContent();if(f>0&&h[f-1]===c)continue;let x=h[f-1];if(i.intraword===!1&&x&&!A.test(x))continue;let E=m.getTextContent(),_=E.slice(0,u)+E.slice(r+1);m.setTextContent(_);let T=p===m?_:h;p.setTextContent(T.slice(0,f)+T.slice(f+l));let I=Q(),S=dn();gn(S);let L=r-l*(p===m?2:1)+1;S.anchor.set(p.__key,f,"text"),S.focus.set(m.__key,L,"text");for(let C of i.format)S.hasFormat(C)||S.formatText(C);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(let C of i.format)S.hasFormat(C)&&S.toggleFormat(C);return j(I)&&(S.format=I.format),!0}return!1}function kt(n,t,e){let o=e.length;for(let r=t;r>=o;r--){let c=r-o;if($t(n,c,e,0,o)&&n[c+o]!==" ")return c}return-1}function $t(n,t,e,o,r){for(let c=0;c<r;c++)if(n[t+c]!==e[o+c])return!1;return!0}function cr(n,t=K){let e=b(t),o=D(e.textFormat,({tag:s})=>s[s.length-1]),r=D(e.textMatch,({trigger:s})=>s);for(let s of t){let i=s.type;if(i==="element"||i==="text-match"||i==="multiline-element"){let a=s.dependencies;for(let l of a)if(!n.hasNode(l))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+l.getType())}}let c=(s,i,a)=>{pn(s,i,a,e.element)||hn(s,i,a,e.multilineElement)||xn(i,a,r)||En(i,a,o)};return n.registerUpdateListener(({dirtyLeaves:s,editorState:i,prevEditorState:a,tags:l})=>{if(l.has("collaboration")||l.has("historic")||n.isComposing())return;let u=i.read(Q),g=a.read(Q);if(!j(g)||!j(u)||!u.isCollapsed()||u.is(g))return;let m=u.anchor.key,p=u.anchor.offset,f=i._nodeMap.get(m);!Lt(f)||!s.has(m)||p!==1&&p>g.anchor.offset+1||n.update(()=>{if(f.hasFormat("code"))return;let d=f.getParent();d!==null&&c(d,f,u.anchor.offset)})})}import{$createListItemNode as _n,$createListNode as Tn,$isListItemNode as Sn,$isListNode as k,ListItemNode as Z,ListNode as J}from"@lexical/list";import{$createHeadingNode as wn,$createQuoteNode as Rn,$isHeadingNode as Cn,$isQuoteNode as Dt,HeadingNode as Fn,QuoteNode as In}from"@lexical/rich-text";import{$createLineBreakNode as Nn}from"lexical";var Bt=/^[\t ]*$/,Kt=/^(\s*)(\d+)\.\s/,Ut=/^(\s*)[-*+]\s/,Gt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,V=/^(#{1,6})\s/,zt=/^>\s/,yn=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,Pt=/[ \t]*(\\`\\`\\`|```)$/,bn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,An=/^\|(.+)\|\s?$/,On=/^(\| ?:?-*:? ?)+\|\s?$/,vt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,Ht=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,kn=n=>(t,e,o)=>{let r=n(o);r.append(...e),t.replace(r),r.select(0,0)},Xt=4;function Mn(n){let t=n.match(/\t/g),e=n.match(/ /g),o=0;return t&&(o+=t.length),e&&(o+=Math.floor(e.length/Xt)),o}var tt=n=>(t,e,o)=>{let r=t.getPreviousSibling(),c=t.getNextSibling(),s=_n(n==="check"?o[3]==="x":void 0);if(k(c)&&c.getListType()===n){let a=c.getFirstChild();a!==null?a.insertBefore(s):c.append(s),t.remove()}else if(k(r)&&r.getListType()===n)r.append(s),t.remove();else{let a=Tn(n,n==="number"?Number(o[2]):void 0);a.append(s),t.replace(a)}s.append(...e),s.select(0,0);let i=Mn(o[1]);i&&s.setIndent(i)},U=(n,t,e)=>{let o=[],r=n.getChildren(),c=0;for(let s of r)if(Sn(s)){if(s.getChildrenSize()===1){let u=s.getFirstChild();if(k(u)){o.push(U(u,t,e+1));continue}}let i=" ".repeat(e*Xt),a=n.getListType(),l=a==="number"?`${n.getStart()+c}. `:a==="check"?`- [${s.getChecked()?"x":" "}] `:"- ";o.push(i+l+t(s)),c++}return o.join(`
7
+ `)},Yt={type:"element",dependencies:[Fn],export:(n,t)=>{if(!Cn(n))return null;let e=Number(n.getTag().slice(1));return"#".repeat(e)+" "+t(n)},regExp:V,replace:kn(n=>{let t="h"+n[1].length;return wn(t)})},Wt={type:"element",dependencies:[In],export:(n,t)=>{if(!Dt(n))return null;let e=t(n).split(`
8
+ `),o=[];for(let r of e)o.push("> "+r);return o.join(`
9
+ `)},regExp:zt,replace:(n,t,e,o)=>{if(o){let c=n.getPreviousSibling();if(Dt(c)){c.splice(c.getChildrenSize(),0,[Nn(),...t]),c.select(0,0),n.remove();return}}let r=Rn();r.append(...t),n.replace(r),r.select(0,0)}},qt={type:"element",dependencies:[J,Z],export:(n,t)=>k(n)?U(n,t,0):null,regExp:Ut,replace:tt("bullet")},Ln={type:"element",dependencies:[J,Z],export:(n,t)=>k(n)?U(n,t,0):null,regExp:Gt,replace:tt("check")},Qt={type:"element",dependencies:[J,Z],export:(n,t)=>k(n)?U(n,t,0):null,regExp:Kt,replace:tt("number")},jt={type:"text-format",format:["code"],tag:"`"},Vt={type:"text-format",format:["highlight"],tag:"=="},Zt={type:"text-format",format:["bold","italic"],tag:"***"},Jt={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},te={type:"text-format",format:["bold"],tag:"**"},ee={type:"text-format",format:["bold"],intraword:!1,tag:"__"},ne={type:"text-format",format:["strikethrough"],tag:"~~"},oe={type:"text-format",format:["italic"],tag:"*"},re={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function ie(n,t){let e=n.split(`
10
+ `),o=!1,r=[],c=0;for(let s=0;s<e.length;s++){let i=e[s],a=r[r.length-1];if(bn.test(i)){r.push(i);continue}if(Pt.test(i)){c===0&&(o=!0),c===1&&(o=!1),c>0&&c--,r.push(i);continue}if(yn.test(i)){o=!0,c++,r.push(i);continue}if(o){r.push(i);continue}Bt.test(i)||Bt.test(a)||!a||V.test(a)||V.test(i)||zt.test(i)||Kt.test(i)||Ut.test(i)||Gt.test(i)||An.test(i)||On.test(i)||!t||vt.test(i)||Ht.test(i)||vt.test(a)||Ht.test(a)||Pt.test(a)?r.push(i):r[r.length-1]=a+" "+i.trim()}return r.join(`
11
+ `)}var $n=[Yt,Wt,qt,Qt],Dn=[],Bn=[jt,Zt,Jt,te,ee,Vt,oe,re,ne],Pn=[],K=[...$n,...Dn,...Bn,...Pn];function hr(n,t=K,e,o=!1,r=!0){let c=o?n:ie(n,r);return Ot(t,o)(c,e)}function xr(n=K,t,e=!1){return Ft(n,e)(t)}export{cr as a,hr as b,xr as c,nt as d,Gn as e,G as f,ot as g,io as h,ve as i,so as j,_t as k,fo as l};
12
+ //# sourceMappingURL=chunk-TLQLXR6Q.js.map