@payloadcms/richtext-lexical 3.61.0-internal.c252d14 → 3.61.0-internal.dd40839
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cell/rscEntry.d.ts +2 -10
- package/dist/cell/rscEntry.d.ts.map +1 -1
- package/dist/cell/rscEntry.js +1 -2
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/exports/client/Field-5VLZM7KJ.js +2 -0
- package/dist/exports/client/Field-5VLZM7KJ.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-UCIWIEVD.js +2 -0
- package/dist/exports/client/RelationshipComponent-UCIWIEVD.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-52JG5GGJ.js +2 -0
- package/dist/exports/client/chunk-52JG5GGJ.js.map +7 -0
- package/dist/exports/client/chunk-U4AOQOHA.js +12 -0
- package/dist/exports/client/chunk-U4AOQOHA.js.map +7 -0
- package/dist/exports/client/component-5YLBQB5B.js +2 -0
- package/dist/exports/client/component-5YLBQB5B.js.map +7 -0
- package/dist/exports/client/componentInline-QEXUNJU4.js +2 -0
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/react/index.d.ts +1 -1
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +1 -1
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +1 -0
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +23 -20
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +2 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +6 -6
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +2 -2
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +5 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +2 -2
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +5 -3
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +2 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js +9 -2
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js +6 -5
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -14
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +4 -2
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +16 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +76 -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/features/link/nodes/AutoLinkNode.js +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +1 -1
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +4 -4
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +4 -4
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +2 -2
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js +3 -2
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +2 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js +9 -2
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/typesServer.d.ts +2 -2
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts +1 -0
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +2 -2
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts +2 -2
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +2 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +2 -2
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +2 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js +6 -0
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +50 -38
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RichTextViewProvider.d.ts +84 -0
- package/dist/field/RichTextViewProvider.d.ts.map +1 -0
- package/dist/field/RichTextViewProvider.js +92 -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.map +1 -1
- package/dist/field/index.js +63 -41
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +2 -3
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +15 -1
- 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 +9 -24
- 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/loader.d.ts.map +1 -1
- package/dist/lexical/config/client/loader.js +2 -4
- package/dist/lexical/config/client/loader.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 +195 -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/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
- package/dist/lexical/theme/EditorTheme.js +3 -39
- package/dist/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +16 -9
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/types.d.ts +138 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/editorConfigFactory.js +1 -1
- package/dist/utilities/editorConfigFactory.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts +2 -0
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +6 -13
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/{getDefaultSanitizedEditorConfig.d.ts → utilities/getDefaultSanitizedEditorConfig.d.ts} +1 -1
- package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -0
- package/dist/{getDefaultSanitizedEditorConfig.js → utilities/getDefaultSanitizedEditorConfig.js} +2 -2
- package/dist/utilities/getDefaultSanitizedEditorConfig.js.map +1 -0
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
- package/dist/utilities/initLexicalFeatures.js +12 -13
- package/dist/utilities/initLexicalFeatures.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 +7 -7
- package/dist/exports/client/Field-YYMTSGSP.js +0 -2
- package/dist/exports/client/Field-YYMTSGSP.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js +0 -2
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js.map +0 -7
- package/dist/exports/client/chunk-ADWHGDDR.js +0 -2
- package/dist/exports/client/chunk-ADWHGDDR.js.map +0 -7
- package/dist/exports/client/chunk-AFXLIYGL.js +0 -12
- package/dist/exports/client/chunk-AFXLIYGL.js.map +0 -7
- package/dist/exports/client/component-WT25HAJA.js +0 -2
- package/dist/exports/client/component-WT25HAJA.js.map +0 -7
- package/dist/exports/client/componentInline-MIPTDFRK.js +0 -2
- package/dist/getDefaultSanitizedEditorConfig.d.ts.map +0 -1
- package/dist/getDefaultSanitizedEditorConfig.js.map +0 -1
- /package/dist/exports/client/{componentInline-MIPTDFRK.js.map → componentInline-QEXUNJU4.js.map} +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 l,jsxs as b,Fragment as $e}from"react/jsx-runtime";import{useLexicalComposerContext as ve}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Te}from"@lexical/react/useLexicalEditable";import{getTranslation as ce}from"@payloadcms/translations";import{Button as ae,Drawer as Oe,EditDepthProvider as Re,Form as Ee,formatDrawerSlug as Pe,FormSubmit as Le,RenderFields as je,ShimmerEffect as Me,useConfig as Ae,useDocumentForm as Je,useDocumentInfo as Ke,useEditDepth as ze,useServerFunctions as He,useTranslation as Ve}from"@payloadcms/ui";import{abortAndIgnore as A}from"@payloadcms/ui/shared";import{$getNodeByKey as J}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as K,reduceFieldsToValues as We}from"payload/shared";import v,{createContext as qe,useCallback as z,useEffect as I,useMemo as $,useRef as x}from"react";import{v4 as Ge}from"uuid";import{jsx as ye}from"react/jsx-runtime";import Fe from"bson-objectid";import{$applyNodeReplacement as De}from"lexical";import Ne from"react";import{addClassNamesToElement as ge}from"@lexical/utils";import _e from"bson-objectid";import{$applyNodeReplacement as xe,DecoratorNode as Ce}from"lexical";var _=class extends Ce{__cacheBuster;__fields;constructor({cacheBuster:e,fields:t,key:n}){super(n),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(e){let t=document.createElement("span");return ge(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 n=this.getWritable();n.__fields=e,t||n.__cacheBuster++}updateDOM(){return!1}};function Se(s){return xe(new _({fields:{...s,id:s?.id||new _e.default().toHexString()}}))}var we=Ne.lazy(()=>import("./componentInline-QEXUNJU4.js").then(s=>({default:s.InlineBlockComponent}))),w=class extends _{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return Ie(e.fields)}decorate(e,t){return ye(we,{cacheBuster:this.getCacheBuster(),className:t.theme.inlineBlock??"LexicalEditorTheme__inlineBlock",formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ie(s){return De(new w({fields:{...s,id:s?.id||new Fe.default().toHexString()}}))}function M(s){return s instanceof w}var ue=qe({initialState:!1}),gt=()=>v.use(ue),_t=s=>{let{cacheBuster:e,className:t,formData:n,nodeKey:d}=s,[f]=ve(),c=Te(),{i18n:T,t:p}=Ve(),{createdInlineBlock:H,fieldProps:{featureClientSchemaMap:me,initialLexicalFormState:de,schemaPath:V},setCreatedInlineBlock:W,uuid:pe}=se(),{fields:C}=Je(),{getFormState:S}=He(),fe=ze(),q=x(!1),[a,O]=v.useState(()=>de?.[n.id]?.formState),G=x(!1),Q=x(e);I(()=>{G.current?(Q.current!==e&&O(!1),Q.current=e):G.current=!0},[e]);let[R,U]=v.useState(a?._components?.customComponents?.BlockLabel),[X,Y]=v.useState(a?._components?.customComponents?.Block),Z=Pe({slug:`lexical-inlineBlocks-create-${pe}-${n.id}`,depth:fe}),{toggleDrawer:h}=ie(Z,!0),be=x(null),{id:y,collectionSlug:F,getDocPreferences:D,globalSlug:N}=Ke(),{config:he}=Ae(),ke=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${n.blockType}`,k=me.blocks?.[ke]?.[0],u=k.blockReferences?typeof k?.blockReferences?.[0]=="string"?he.blocksMap[k?.blockReferences?.[0]]:k?.blockReferences?.[0]:k?.blocks?.[0],ee=u?.fields??[];I(()=>{!q.current&&H?.getKey()===d&&(ee.length>2&&h(),W?.(void 0),q.current=!0)},[ee.length,H,d,W,h]);let te=z(()=>{f.update(()=>{J(d)?.remove()})},[f,d]),B=u?.labels?.singular?ce(u?.labels.singular,T):u?.slug,E=x(new AbortController),g=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${u?.slug}.fields`;I(()=>{let o=new AbortController;return n&&!a&&(async()=>{let{state:r}=await S({id:y,collectionSlug:F,data:n,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:K(C),globalSlug:N,initialBlockData:n,initialBlockFormState:n,operation:"update",readOnly:!c,renderAllFields:!0,schemaPath:g,signal:o.signal});if(r){let m=We(K(r),!0);f.update(()=>{let j=J(d);if(j&&M(j)){let le=m;le.blockType=n.blockType,j.setFields(le,!0)}}),O(r),U(r._components?.customComponents?.BlockLabel),Y(r._components?.customComponents?.Block)}})(),()=>{A(o)}},[S,f,d,c,g,y,n,a,F,N,D,C]);let ne=z(async({formState:o,submit:i})=>{A(E.current);let r=new AbortController;E.current=r;let{state:m}=await S({id:y,collectionSlug:F,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:K(C),formState:o,globalSlug:N,initialBlockFormState:o,operation:"update",readOnly:!c,renderAllFields:!!i,schemaPath:g,signal:r.signal});return m?(i&&(U(m._components?.customComponents?.BlockLabel),Y(m._components?.customComponents?.Block)),m):o},[S,y,F,D,C,N,c,g]);I(()=>{let o=(i,r)=>Object.keys(r).some(m=>r[m]&&i[m]!==r[m].value);return()=>{a&&o(n,a)&&O(!1),A(E.current)}},[n,a]);let Be=z((o,i)=>{i.blockType=n.blockType,f.update(()=>{let r=J(d);r&&M(r)&&r.setFields(i,!0)})},[f,d,n]),P=$(()=>()=>l(ae,{buttonStyle:"icon-label",className:`${t}__removeButton`,disabled:!c,icon:"x",onClick:o=>{o.preventDefault(),te()},round:!0,size:"small",tooltip:p("lexical:blocks:inlineBlocks:remove",{label:B})}),[t,B,c,te,p]),oe=$(()=>()=>l(ae,{buttonStyle:"icon-label",className:`${t}__editButton`,disabled:!c,el:"button",icon:"edit",onClick:()=>{h()},round:!0,size:"small",tooltip:p("lexical:blocks:inlineBlocks:edit",{label:B})}),[t,B,c,p,h]),L=$(()=>({children:o,className:i})=>l("div",{className:[`${t}__container`,t+"-"+n.blockType,i].filter(Boolean).join(" "),ref:be,children:o}),[t,n.blockType]),re=$(()=>R?()=>R:()=>l("div",{children:u?.labels?ce(u?.labels.singular,T):""}),[R,u?.labels,T]);return u?b(Ee,{beforeSubmit:[async({formState:o})=>await ne({formState:o,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:u?.fields,initialState:a||{},onChange:[ne],onSubmit:(o,i)=>{Be(o,i),h()},uuid:Ge(),children:[l(Re,{children:l(Oe,{className:"",slug:Z,title:p(`lexical:blocks:inlineBlocks:${n?.id?"edit":"create"}`,{label:B??p("lexical:blocks:inlineBlocks:label")}),children:a?b($e,{children:[l(je,{fields:u?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:g,permissions:!0,readOnly:!c}),l(Le,{programmaticSubmit:!0,children:p("fields:saveChanges")})]}):null})}),X?l(ue,{value:{EditButton:oe,initialState:a,InlineBlockContainer:L,Label:re,nodeKey:d,RemoveButton:P},children:X}):b(L,{children:[a?l(re,{}):l(Me,{height:"15px",width:"40px"}),c?b("div",{className:`${t}__actions`,children:[l(oe,{}),l(P,{})]}):null]})]}):b(L,{className:`${t}-not-found`,children:[b("span",{children:["Error: Block '",n.blockType,"' not found"]}),c?l("div",{className:`${t}__actions`,children:l(P,{})}):null]})};export{gt as a,_t as b,w as c,Ie as d,M as e};
|
|
2
|
+
//# sourceMappingURL=chunk-52JG5GGJ.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 { 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 className: string\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, className: baseClass, formData, nodeKey } = 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 () => 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 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),\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 isEditable,\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 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 {\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 className={config.theme.inlineBlock ?? 'LexicalEditorTheme__inlineBlock'}\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,OAA0B,oCACnC,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAA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,UAAU,aAAA,IACvCpD,EACC2G,EAAC,MAAA,CAAIjH,UAAW,GAAGC,CAAA,qBACjBgH,EAACF,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", "_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", "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", "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", "readOnly", "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", "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 ge}from"react/compiler-runtime";import{useRef as he}from"react";function Qn(r){let t=ge(2),e=r===void 0?500:r,o=he(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})):xe().then(l)}),t[0]=e,t[1]=n):n=t[1],n}function xe(){return new Promise(r=>{setTimeout(r,100),requestAnimationFrame(()=>{setTimeout(r,0)})})}var z=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 ct(r){return r instanceof z}import{jsx as $e}from"react/jsx-runtime";import{useLexicalComposerContext as Be}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ve}from"@lexical/utils";import{$getSelection as j,$isRangeSelection as q,$isTextNode as Pe,COMMAND_PRIORITY_LOW as He,createCommand as Ke,getDOMSelection as Ue}from"lexical";import{useCallback as Et,useEffect as _t,useState as Xe}from"react";import*as W from"react";import{c as mt}from"react/compiler-runtime";import{useLexicalComposerContext as pt}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as lt}from"@lexical/utils";import{$getSelection as gt,$isRangeSelection as Ee,$setSelection as _e,COMMAND_PRIORITY_LOW as at,COMMAND_PRIORITY_NORMAL as $,createCommand as Te,KEY_ARROW_DOWN_COMMAND as Se,KEY_ARROW_UP_COMMAND as we,KEY_ENTER_COMMAND as Ce,KEY_ESCAPE_COMMAND as Re,KEY_TAB_COMMAND as ye}from"lexical";import{useCallback as Y,useEffect as b,useLayoutEffect as Oe,useMemo as be,useRef as ke,useState as Ne}from"react";var Fe="slash-menu-popup",ft=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 Ie(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 Me(r){let t=gt();if(!Ee(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=Ie(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 Ae(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 ut(r,t){let e=r.getBoundingClientRect(),o=t.getBoundingClientRect();return e.top>o.top&&e.top<o.bottom}function De(r,t,e,o){let n=mt(7),[c]=pt(),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?Ae(a,!1):document.body,p=!1,m=ut(l,u),g=function(){p||(window.requestAnimationFrame(function(){e(),p=!1}),p=!0);let d=ut(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]),b(s,i)}var dt=Te("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function ht({anchorElementRef:r,close:t,editor:e,groups:o,menuRenderFn:n,resolution:c,shouldSplitNodeWithQuery:s=!1}){let[i,l]=Ne(null),a=c.match&&c.match.matchingString||"",u=Y(f=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${Fe}__item-${f.key}`),l(f.key))},[e]),p=Y(()=>{if(o!==null&&a!=null){let f=o.flatMap(d=>d.items);if(f.length){let d=f[0];u(d)}}},[o,u,a]);b(()=>{p()},[a,p]);let m=Y(f=>{t(),e.update(()=>{let d=c.match!=null&&s?Me(c.match):null;d&&d.remove()}),setTimeout(()=>{let d;e.read(()=>{d=gt()?.clone()}),e.update(()=>{d&&_e(d)}),f.onSelect({editor:e,queryString:c.match?c.match.matchingString:""})},0)},[e,s,c.match,t]);b(()=>()=>{let f=e.getRootElement();f!==null&&f.removeAttribute("aria-activedescendant")},[e]),Oe(()=>{o===null?l(null):i===null&&p()},[o,i,u,p]),b(()=>lt(e.registerCommand(dt,({item:f})=>f.ref&&f.ref.current!=null?(ft(f.ref.current),!0):!1,at)),[e,u]),b(()=>lt(e.registerCommand(Se,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(dt,{index:E,item:_}),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(we,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&&ft(_.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(Re,f=>{let d=f;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},at),e.registerCommand(ye,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(Ce,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=be(()=>({groups:o,selectedItemKey:i,selectItemAndCleanUp:m,setSelectedItemKey:l}),[m,i,o]);return n(r,g,c.match?c.match.matchingString:"")}function Le(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 xt(r,t,e,o){let n=mt(14),[c]=pt(),s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=st?document.createElement("div"):null,n[0]=s):s=n[0];let i=ke(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(),O=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 S=h.getBoundingClientRect(),L=S.height,C=S.width,G=f.getBoundingClientRect(),rt=document.dir==="rtl"||document.documentElement.dir==="rtl",ue=r.getBoundingClientRect(),it=Math.max(0,G.left);if(!rt&&_+C>G.right)d.style.left=`${G.right-C+window.scrollX}px`;else if(rt&&S.left<it){let pe=it+C-ue.left;d.style.left=`${pe+window.scrollX}px`}let de=O+L+32>window.innerHeight,me=O<0;de&&!me?d.style.top=`${T+32-L+window.scrollY-(x+24)}px`:d.style.top=`${T+window.scrollY+32}px`}d.isConnected||(Le(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]),b(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],De(t,i,a,m),i}var po=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Ge(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 Tt(r,t,e){let o=Ue(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 ze(r){let t;return r.getEditorState().read(()=>{let e=j();q(e)&&(t=Ge(e))}),t}function St(r,t){return t!==0?!1:r.getEditorState().read(()=>{let e=j();if(q(e)){let c=e.anchor.getNode().getPreviousSibling();return Pe(c)&&c.isTextEntity()}return!1})}function wt(r){W.startTransition?W.startTransition(r):r()}var Ye=Ke("ENABLE_SLASH_MENU_COMMAND");function go({anchorClassName:r,anchorElem:t,groups:e,menuRenderFn:o,onClose:n,onOpen:c,onQueryChange:s,triggerFn:i}){let[l]=Be(),[a,u]=Xe(null),p=xt(t,a,u,r),m=Et(()=>{u(null),n!=null&&a!==null&&n()},[n,a]),g=Et(f=>{u(f),c!=null&&a===null&&c(f)},[c,a]);return _t(()=>ve(l.registerCommand(Ye,({node:f})=>(l.getEditorState().read(()=>{let d={leadOffset:0,matchingString:"",replaceableString:""};if(!St(l,d.leadOffset)&&f!==null){let h=l._window??window,x=h.document.createRange();Tt(d.leadOffset,x,h)!==null&&wt(()=>g({getRect:()=>x.getBoundingClientRect(),match:d}));return}}),!0),He)),[l,g]),_t(()=>{let f=()=>{l.getEditorState().read(()=>{let h=l._window??window,x=h.document.createRange(),E=j(),_=ze(l);if(!q(E)||!E.isCollapsed()||_===void 0||x===null){m();return}let T=i({editor:l,query:_});if(s(T?T.matchingString:null),T!==null&&!St(l,T.leadOffset)&&Tt(T.leadOffset,x,h)!==null){wt(()=>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:$e(ht,{anchorElementRef:p,close:m,editor:l,groups:e,menuRenderFn:o,resolution:a,shouldSplitNodeWithQuery:!0})}var Ct=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(ct(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 V from"react";var A=new WeakMap;function To(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 So(r){A.delete(r)}function Rt(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 We({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=Rt(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 i=typeof s.html=="function"?s.html({config:c,editor:n,isEditor:!0,isJSXConverter:!1,node:this}):s.html;return V.createElement("span",{dangerouslySetInnerHTML:{__html:i}})}if(s.html&&o&&!s.createDOM)return V.createElement(V.Fragment)}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=Rt(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 wo({editorConfig:r,nodeViews:t}){let e=je({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)&&We({node:n,nodeType:c})}}return e}function je({nodes:r}){return r.map(t=>"node"in t?t.node:t)}import{$getRoot as on,$isDecoratorNode as Nt,$isElementNode as P,$isLineBreakNode as rn,$isTextNode as H}from"lexical";import{$isListItemNode as qe,$isListNode as yt}from"@lexical/list";import{$isHeadingNode as Ve,$isQuoteNode as Qe}from"@lexical/rich-text";import{$isParagraphNode as Je,$isTextNode as Ze}from"lexical";var w={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...w,requiresParagraphStart:!0},bo={...R,export:k(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},ko={...R,export:k(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},No={...R,export:k(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Fo={...R,export:k(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},Io={...R,export:k(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},Mo={...R,export:k(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},Ao={...R,export:en,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},Do={...R,export:Q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},Lo={...R,export:Q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},$o={...R,export:Q,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},Bo={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},vo={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},Po={...w,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},Ho={...w,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},Ko={...w,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},Uo={...w,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},Xo={...w,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Go={...w,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},zo={...w,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},Yo={...w,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},Wo={...w,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},jo={...w,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},qo={...w,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},Vo={...w,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function k(r){return(t,e)=>Ve(t)&&t.getTag()==="h"+r?"#".repeat(r)+" "+e(t):null}function Q(r,t){return yt(r)?Ot(r,t,0):null}var tn=4;function Ot(r,t,e){let o=[],n=r.getChildren(),c=0;for(let s of n)if(qe(s)){if(s.getChildrenSize()===1){let a=s.getFirstChild();if(yt(a)){o.push(Ot(a,t,e+1));continue}}let i=" ".repeat(e*tn),l=r.getListType()==="bullet"?"- ":`${r.getStart()+c}. `;o.push(i+l+t(s)),c++}return o.join(`
|
|
2
|
+
`)}function en(r,t){return Qe(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]/,nn=/^\s{0,3}$/;function D(r){if(!Je(r))return!1;let t=r.getFirstChild();return t==null||r.getChildrenSize()===1&&Ze(t)&&nn.test(t.getTextContent())}function Ft(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||on()).getChildren();return l.forEach((a,u)=>{let p=sn(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 sn(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):Nt(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)=>bt(u,p,t,o,n));if(a!=null){c.push(a);continue t}}rn(i)?c.push(`
|
|
5
|
+
`):H(i)?c.push(bt(i,i.getTextContent(),t,o,n)):P(i)?c.push(K(i,t,e,o,n)):Nt(i)&&c.push(i.getTextContent())}return c.join("")}function bt(r,t,e,o,n){let c=t.trim(),s=c;r.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",l="",a="",u=kt(r,!0),p=kt(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 kt(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 ln,$isListNode as Lt}from"@lexical/list";import{$isQuoteNode as an}from"@lexical/rich-text";import{$findMatchingParent as fn}from"@lexical/utils";import{$createLineBreakNode as un,$createParagraphNode as dn,$createTextNode as mn,$getRoot as pn,$getSelection as gn,$isParagraphNode as hn}from"lexical";import{$isTextNode as I}from"lexical";function It(r,t){let e=r.getTextContent(),o=cn(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 cn(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 Mt(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 At(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 Dt(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=It(r,t),n=At(r,e);if(o&&n&&(o.startIndex<=n.startIndex&&o.endIndex>=n.endIndex?n=null:o=null),o){let i=Mt(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=Dt(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 $t(r,t=!1){let e=N(r),o=_n(e.textFormat);return(n,c)=>{let s=n.split(`
|
|
6
|
+
`),i=s.length,l=c||pn();l.clear();for(let u=0;u<i;u++){let p=s[u],[m,g]=xn(s,u,e.multilineElement,l);if(m){u=g;continue}En(p,l,e.element,o,e.textMatch)}let a=l.getChildren();for(let u of a)!t&&D(u)&&l.getChildrenSize()>1&&u.remove();gn()!==null&&l.selectStart()}}function xn(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 En(r,t,e,o,n){let c=mn(r),s=dn();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(hn(i)||an(i)||Lt(i)){let l=i;if(Lt(i)){let a=i.getLastDescendant();a==null?l=null:l=fn(a,ln)}l!=null&&l.getTextContentSize()>0&&(l.splice(l.getChildrenSize(),0,[un(),...s.getChildren()]),s.remove())}}}function _n(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 Tn,$getSelection as J,$isLineBreakNode as Sn,$isRangeSelection as Z,$isRootOrShadowRoot as vt,$isTextNode as Pt,$setSelection as wn}from"lexical";function Cn(r,t,e,o){let n=r.getParent();if(!vt(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 Rn(r,t,e,o){let n=r.getParent();if(!vt(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 yn(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 On(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&&!Ht(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=Bt(o,u,l),d=g;for(;f<0&&(d=d.getPreviousSibling())&&!Sn(d);)if(Pt(d)){let C=d.getTextContent();g=d,f=Bt(C,C.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 O=J(),S=Tn();wn(S);let L=n-a*(g===m?2:1)+1;S.anchor.set(g.__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 Z(O)&&(S.format=O.format),!0}return!1}function Bt(r,t,e){let o=e.length;for(let n=t;n>=o;n--){let c=n-o;if(Ht(r,c,e,0,o)&&r[c+o]!==" ")return c}return-1}function Ht(r,t,e,o,n){for(let c=0;c<n;c++)if(r[t+c]!==e[o+c])return!1;return!0}function Er(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)=>{Cn(s,i,l,e.element)||Rn(s,i,l,e.multilineElement)||yn(i,l,n)||On(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);!Pt(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 bn,$createListNode as kn,$isListItemNode as Nn,$isListNode as M,ListItemNode as et,ListNode as nt}from"@lexical/list";import{$createHeadingNode as Fn,$createQuoteNode as In,$isHeadingNode as Mn,$isQuoteNode as Kt,HeadingNode as An,QuoteNode as Dn}from"@lexical/rich-text";import{$createLineBreakNode as Ln}from"lexical";var Ut=/^[\t ]*$/,Yt=/^(\s*)(\d+)\.\s/,Wt=/^(\s*)[-*+]\s/,jt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,tt=/^(#{1,6})\s/,qt=/^>\s/,$n=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,Xt=/[ \t]*(\\`\\`\\`|```)$/,Bn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,vn=/^\|(.+)\|\s?$/,Pn=/^(\| ?:?-*:? ?)+\|\s?$/,Gt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,zt=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,Hn=r=>(t,e,o)=>{let n=r(o);n.append(...e),t.replace(n),n.select(0,0)},Vt=4;function Kn(r){let t=r.match(/\t/g),e=r.match(/ /g),o=0;return t&&(o+=t.length),e&&(o+=Math.floor(e.length/Vt)),o}var ot=r=>(t,e,o)=>{let n=t.getPreviousSibling(),c=t.getNextSibling(),s=bn(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=kn(r,r==="number"?Number(o[2]):void 0);l.append(s),t.replace(l)}s.append(...e),s.select(0,0);let i=Kn(o[1]);i&&s.setIndent(i)},X=(r,t,e)=>{let o=[],n=r.getChildren(),c=0;for(let s of n)if(Nn(s)){if(s.getChildrenSize()===1){let u=s.getFirstChild();if(M(u)){o.push(X(u,t,e+1));continue}}let i=" ".repeat(e*Vt),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
|
+
`)},Qt={type:"element",dependencies:[An],export:(r,t)=>{if(!Mn(r))return null;let e=Number(r.getTag().slice(1));return"#".repeat(e)+" "+t(r)},regExp:tt,replace:Hn(r=>{let t="h"+r[1].length;return Fn(t)})},Jt={type:"element",dependencies:[Dn],export:(r,t)=>{if(!Kt(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(Kt(c)){c.splice(c.getChildrenSize(),0,[Ln(),...t]),c.select(0,0),r.remove();return}}let n=In();n.append(...t),r.replace(n),n.select(0,0)}},Zt={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?X(r,t,0):null,regExp:Wt,replace:ot("bullet")},Un={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?X(r,t,0):null,regExp:jt,replace:ot("check")},te={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?X(r,t,0):null,regExp:Yt,replace:ot("number")},ee={type:"text-format",format:["code"],tag:"`"},ne={type:"text-format",format:["highlight"],tag:"=="},oe={type:"text-format",format:["bold","italic"],tag:"***"},re={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},ie={type:"text-format",format:["bold"],tag:"**"},se={type:"text-format",format:["bold"],intraword:!1,tag:"__"},ce={type:"text-format",format:["strikethrough"],tag:"~~"},le={type:"text-format",format:["italic"],tag:"*"},ae={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function fe(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(Bn.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($n.test(i)){o=!0,c++,n.push(i);continue}if(o){n.push(i);continue}Ut.test(i)||Ut.test(l)||!l||tt.test(l)||tt.test(i)||qt.test(i)||Yt.test(i)||Wt.test(i)||jt.test(i)||vn.test(i)||Pn.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 Xn=[Qt,Jt,Zt,te],Gn=[],zn=[ee,oe,re,ie,se,ne,le,ae,ce],Yn=[],U=[...Xn,...Gn,...zn,...Yn];function br(r,t=U,e,o=!1,n=!0){let c=o?r:fe(r,n);return $t(t,o)(c,e)}function kr(r=U,t,e=!1){return Ft(r,e)(t)}export{Er as a,br as b,kr as c,st as d,Qn as e,z as f,ct as g,po as h,Ye as i,go as j,Ct as k,To as l,So as m,wo as n};
|
|
12
|
+
//# sourceMappingURL=chunk-U4AOQOHA.js.map
|