@payloadcms/richtext-lexical 3.0.2 → 3.0.3-canary.5a65a90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/Field-CO3ZH6ER.js +2 -0
- package/dist/exports/client/Field-CO3ZH6ER.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-XOQBVKA3.js +2 -0
- package/dist/exports/client/RelationshipComponent-XOQBVKA3.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-C7S3V4EB.js → chunk-DOK5S7LE.js} +2 -2
- package/dist/exports/client/chunk-DOK5S7LE.js.map +7 -0
- package/dist/exports/client/{chunk-U7O7EYCP.js → chunk-FBDJRK3A.js} +2 -2
- package/dist/exports/client/{chunk-U7O7EYCP.js.map → chunk-FBDJRK3A.js.map} +2 -2
- package/dist/exports/client/chunk-LMCV6WAN.js +12 -0
- package/dist/exports/client/chunk-LMCV6WAN.js.map +7 -0
- package/dist/exports/client/chunk-ZTAS32RX.js +2 -0
- package/dist/exports/client/{chunk-MI5HS4QX.js.map → chunk-ZTAS32RX.js.map} +3 -3
- package/dist/exports/client/{component-H3EYQ5KG.js → component-D6PKVJ2K.js} +2 -2
- package/dist/exports/client/component-D6PKVJ2K.js.map +7 -0
- package/dist/exports/client/componentInline-XC7SFQPN.js +2 -0
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/server/ast/mdx.d.ts.map +1 -1
- package/dist/exports/server/ast/mdx.js +6 -0
- package/dist/exports/server/ast/mdx.js.map +1 -1
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blockquote/server/index.js +2 -1
- package/dist/features/blockquote/server/index.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +2 -0
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +2 -0
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/converters/html/converter/converters/paragraph.d.ts.map +1 -1
- package/dist/features/converters/html/converter/converters/paragraph.js +2 -1
- package/dist/features/converters/html/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/html/converter/defaultConverters.d.ts +1 -1
- package/dist/features/converters/html/converter/defaultConverters.d.ts.map +1 -1
- package/dist/features/converters/html/converter/defaultConverters.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +23 -17
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +4 -2
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/utils/debounce.d.ts.map +1 -1
- package/dist/features/experimental_table/client/utils/debounce.js +3 -0
- package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
- package/dist/features/experimental_table/client/utils/useDebounce.d.ts +1 -5
- package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +1 -1
- package/dist/features/experimental_table/client/utils/useDebounce.js +40 -10
- package/dist/features/experimental_table/client/utils/useDebounce.js.map +1 -1
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js +2 -1
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/lists/checklist/server/index.js.map +1 -1
- package/dist/features/lists/orderedList/server/index.js.map +1 -1
- package/dist/features/lists/unorderedList/server/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +1 -3
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js +3 -3
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts +2 -2
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +51 -69
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +31 -51
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +152 -62
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +4 -2
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +8 -20
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/typesClient.d.ts +39 -36
- package/dist/features/typesClient.d.ts.map +1 -1
- package/dist/features/typesClient.js.map +1 -1
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.d.ts +2 -2
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/Field.d.ts +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +2 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/rscEntry.js +1 -1
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +1 -0
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +2 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +139 -88
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +2 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +4 -7
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +8 -14
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +1 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +4 -1
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/utilities/jsx/jsx.d.ts.map +1 -1
- package/dist/utilities/jsx/jsx.js +1 -0
- package/dist/utilities/jsx/jsx.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-IS3XMKMO.js +0 -2
- package/dist/exports/client/Field-IS3XMKMO.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-2RT3YXUT.js +0 -2
- package/dist/exports/client/RelationshipComponent-2RT3YXUT.js.map +0 -7
- package/dist/exports/client/chunk-C7S3V4EB.js.map +0 -7
- package/dist/exports/client/chunk-CBUZKU7S.js +0 -12
- package/dist/exports/client/chunk-CBUZKU7S.js.map +0 -7
- package/dist/exports/client/chunk-MI5HS4QX.js +0 -2
- package/dist/exports/client/component-H3EYQ5KG.js.map +0 -7
- package/dist/exports/client/componentInline-ZGO3K4TA.js +0 -2
- /package/dist/exports/client/{componentInline-ZGO3K4TA.js.map → componentInline-XC7SFQPN.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as P}from"./chunk-CUIBIFW2.js";import{c as Y}from"react/compiler-runtime";import{jsx as R}from"react/jsx-runtime";import{Drawer as Z,EditDepthProvider as N,useModal as z}from"@payloadcms/ui";import"react";import{jsx as T,jsxs as W}from"react/jsx-runtime";import{Form as H,FormSubmit as J,RenderFields as K,useDocumentInfo as L,useServerFunctions as B,useTranslation as G}from"@payloadcms/ui";import{abortAndIgnore as y}from"@payloadcms/ui/shared";import{useCallback as V,useEffect as I,useRef as q,useState as Q}from"react";import{v4 as X}from"uuid";var $=({data:e,featureKey:t,fieldMapOverride:n,handleDrawerSubmit:r,schemaFieldsPathOverride:a,schemaPath:d,schemaPathSuffix:p})=>{let{t:m}=G(),{id:s,collectionSlug:c,getDocPreferences:i,globalSlug:o}=L(),u=q(new AbortController),[l,f]=Q(!1),{fieldProps:{featureClientSchemaMap:h,permissions:w}}=P(),{getFormState:g}=B(),x=a??`${d}.lexical_internal_feature.${t}${p?`.${p}`:""}`,b=n??h[t]?.[x];I(()=>{let _=new AbortController;return(async()=>{let{state:v}=await g({id:s,collectionSlug:c,data:e??{},docPermissions:{fields:!0},docPreferences:await i(),globalSlug:o,operation:"update",renderAllFields:!0,schemaPath:x,signal:_.signal});f(v)})(),()=>{y(_)}},[x,s,e,g,c,o,i]);let E=V(async({formState:_})=>{y(u.current);let C=new AbortController;u.current=C;let{state:v}=await g({id:s,collectionSlug:c,docPermissions:{fields:!0},docPreferences:await i(),formState:_,globalSlug:o,operation:"update",schemaPath:x,signal:C.signal});return v||_},[g,s,c,i,o,x]);return I(()=>()=>{y(u.current)},[]),l===!1?null:W(H,{beforeSubmit:[E],disableValidationOnSubmit:!0,fields:Array.isArray(b)?b:[],initialState:l,onChange:[E],onSubmit:r,uuid:X(),children:[T(K,{fields:Array.isArray(b)?b:[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:x,permissions:w,readOnly:!1}),T(J,{children:m("fields:saveChanges")})]})};var Ot=e=>{let t=Y(15),{className:n,data:r,drawerSlug:a,drawerTitle:d,featureKey:p,fieldMapOverride:m,handleDrawerSubmit:s,schemaFieldsPathOverride:c,schemaPath:i,schemaPathSuffix:o}=e,{closeModal:u}=z(),l=d??"",f;t[0]!==u||t[1]!==a||t[2]!==s?(f=(w,g)=>{u(a),setTimeout(()=>{s(w,g)},1)},t[0]=u,t[1]=a,t[2]=s,t[3]=f):f=t[3];let h;return t[4]!==r||t[5]!==p||t[6]!==m||t[7]!==f||t[8]!==c||t[9]!==i||t[10]!==o||t[11]!==n||t[12]!==a||t[13]!==l?(h=R(N,{children:R(Z,{className:n,slug:a,title:l,children:R($,{data:r,featureKey:p,fieldMapOverride:m,handleDrawerSubmit:f,schemaFieldsPathOverride:c,schemaPath:i,schemaPathSuffix:o})})}),t[4]=r,t[5]=p,t[6]=m,t[7]=f,t[8]=c,t[9]=i,t[10]=o,t[11]=n,t[12]=a,t[13]=l,t[14]=h):h=t[14],h};import{c as tt}from"react/compiler-runtime";import{useAuth as et,useConfig as rt,useEntityVisibility as nt}from"@payloadcms/ui";import*as D from"react";var at=(e,t)=>e.filter(({slug:n,admin:{enableRichTextRelationship:r},upload:a})=>t?.visibleEntities.collections.includes(n)?t?.uploads?r&&!!a:a?!1:r:!1),It=e=>{let t=tt(16),n,r,a;t[0]!==e?({children:a,uploads:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a):(n=t[1],r=t[2],a=t[3]);let d=n===void 0?!1:n,{config:p}=rt(),{collections:m}=p,{user:s}=et(),{visibleEntities:c}=nt(),i;t[4]!==m||t[5]!==d||t[6]!==s||t[7]!==c?(i=()=>at(m,{uploads:d,user:s,visibleEntities:c}).map(l=>{let{slug:f}=l;return f}),t[4]=m,t[5]=d,t[6]=s,t[7]=c,t[8]=i):i=t[8];let[o]=D.useState(i);if(!o.length)return null;let u;if(t[9]!==r||t[10]!==o||t[11]!==a){let l;t[13]!==r||t[14]!==o?(l={...r,enabledCollectionSlugs:o},t[13]=r,t[14]=o,t[15]=l):l=t[15],u=D.cloneElement(a,l),t[9]=r,t[10]=o,t[11]=a,t[12]=u}else u=t[12];return u};import{createCommand as ot}from"lexical";var Mt=ot("INSERT_UPLOAD_WITH_DRAWER_COMMAND");import{jsx as ut}from"react/jsx-runtime";import F from"bson-objectid";import{$applyNodeReplacement as ft}from"lexical";import*as U from"react";import{jsx as it}from"react/jsx-runtime";import{DecoratorBlockNode as lt}from"@lexical/react/LexicalDecoratorBlockNode.js";import j from"bson-objectid";import{$applyNodeReplacement as st}from"lexical";import"react";function O(e){return e.parentElement!=null&&e.parentElement.tagName==="LI"&&e.previousSibling===null&&e.getAttribute("aria-roledescription")==="checkbox"}function ct(e){if(e.hasAttribute("data-lexical-upload-relation-to")&&e.hasAttribute("data-lexical-upload-id")){let n=e.getAttribute("data-lexical-upload-id"),r=e.getAttribute("data-lexical-upload-relation-to");if(n!=null&&r!=null)return{node:M({data:{fields:{},relationTo:r,value:n}})}}let t=e;return t.src.startsWith("file:///")||O(t),null}var S=class extends lt{__data;constructor({data:t,format:n,key:r}){super(n,r),this.__data=t}static clone(t){return new this({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"upload"}static importDOM(){return{img:t=>({conversion:ct,priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new j.default().toHexString(),t.version=3);let n={id:t.id,fields:t.fields,relationTo:t.relationTo,value:t.value},r=M({data:n});return r.setFormat(t.format),r}static isInline(){return!1}decorate(){return it(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let t=document.createElement("img");return t.setAttribute("data-lexical-upload-id",String(this.__data?.value)),t.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(t){let n=this.getWritable();n.__data=t}updateDOM(){return!1}};function M({data:e}){return e?.id||(e.id=new j.default().toHexString()),st(new S({data:e}))}var mt=U.lazy(()=>import("./component-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as P}from"./chunk-CUIBIFW2.js";import{c as Y}from"react/compiler-runtime";import{jsx as R}from"react/jsx-runtime";import{Drawer as Z,EditDepthProvider as N,useModal as z}from"@payloadcms/ui";import"react";import{jsx as T,jsxs as W}from"react/jsx-runtime";import{Form as H,FormSubmit as J,RenderFields as K,useDocumentInfo as L,useServerFunctions as B,useTranslation as G}from"@payloadcms/ui";import{abortAndIgnore as y}from"@payloadcms/ui/shared";import{useCallback as V,useEffect as I,useRef as q,useState as Q}from"react";import{v4 as X}from"uuid";var $=({data:e,featureKey:t,fieldMapOverride:n,handleDrawerSubmit:r,schemaFieldsPathOverride:a,schemaPath:d,schemaPathSuffix:p})=>{let{t:m}=G(),{id:s,collectionSlug:c,getDocPreferences:i,globalSlug:o}=L(),u=q(new AbortController),[l,f]=Q(!1),{fieldProps:{featureClientSchemaMap:h,permissions:w}}=P(),{getFormState:g}=B(),x=a??`${d}.lexical_internal_feature.${t}${p?`.${p}`:""}`,b=n??h[t]?.[x];I(()=>{let _=new AbortController;return(async()=>{let{state:v}=await g({id:s,collectionSlug:c,data:e??{},docPermissions:{fields:!0},docPreferences:await i(),globalSlug:o,operation:"update",renderAllFields:!0,schemaPath:x,signal:_.signal});f(v)})(),()=>{y(_)}},[x,s,e,g,c,o,i]);let E=V(async({formState:_})=>{y(u.current);let C=new AbortController;u.current=C;let{state:v}=await g({id:s,collectionSlug:c,docPermissions:{fields:!0},docPreferences:await i(),formState:_,globalSlug:o,operation:"update",schemaPath:x,signal:C.signal});return v||_},[g,s,c,i,o,x]);return I(()=>()=>{y(u.current)},[]),l===!1?null:W(H,{beforeSubmit:[E],disableValidationOnSubmit:!0,fields:Array.isArray(b)?b:[],initialState:l,onChange:[E],onSubmit:r,uuid:X(),children:[T(K,{fields:Array.isArray(b)?b:[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:x,permissions:w,readOnly:!1}),T(J,{children:m("fields:saveChanges")})]})};var Ot=e=>{let t=Y(15),{className:n,data:r,drawerSlug:a,drawerTitle:d,featureKey:p,fieldMapOverride:m,handleDrawerSubmit:s,schemaFieldsPathOverride:c,schemaPath:i,schemaPathSuffix:o}=e,{closeModal:u}=z(),l=d??"",f;t[0]!==u||t[1]!==a||t[2]!==s?(f=(w,g)=>{u(a),setTimeout(()=>{s(w,g)},1)},t[0]=u,t[1]=a,t[2]=s,t[3]=f):f=t[3];let h;return t[4]!==r||t[5]!==p||t[6]!==m||t[7]!==f||t[8]!==c||t[9]!==i||t[10]!==o||t[11]!==n||t[12]!==a||t[13]!==l?(h=R(N,{children:R(Z,{className:n,slug:a,title:l,children:R($,{data:r,featureKey:p,fieldMapOverride:m,handleDrawerSubmit:f,schemaFieldsPathOverride:c,schemaPath:i,schemaPathSuffix:o})})}),t[4]=r,t[5]=p,t[6]=m,t[7]=f,t[8]=c,t[9]=i,t[10]=o,t[11]=n,t[12]=a,t[13]=l,t[14]=h):h=t[14],h};import{c as tt}from"react/compiler-runtime";import{useAuth as et,useConfig as rt,useEntityVisibility as nt}from"@payloadcms/ui";import*as D from"react";var at=(e,t)=>e.filter(({slug:n,admin:{enableRichTextRelationship:r},upload:a})=>t?.visibleEntities.collections.includes(n)?t?.uploads?r&&!!a:a?!1:r:!1),It=e=>{let t=tt(16),n,r,a;t[0]!==e?({children:a,uploads:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a):(n=t[1],r=t[2],a=t[3]);let d=n===void 0?!1:n,{config:p}=rt(),{collections:m}=p,{user:s}=et(),{visibleEntities:c}=nt(),i;t[4]!==m||t[5]!==d||t[6]!==s||t[7]!==c?(i=()=>at(m,{uploads:d,user:s,visibleEntities:c}).map(l=>{let{slug:f}=l;return f}),t[4]=m,t[5]=d,t[6]=s,t[7]=c,t[8]=i):i=t[8];let[o]=D.useState(i);if(!o.length)return null;let u;if(t[9]!==r||t[10]!==o||t[11]!==a){let l;t[13]!==r||t[14]!==o?(l={...r,enabledCollectionSlugs:o},t[13]=r,t[14]=o,t[15]=l):l=t[15],u=D.cloneElement(a,l),t[9]=r,t[10]=o,t[11]=a,t[12]=u}else u=t[12];return u};import{createCommand as ot}from"lexical";var Mt=ot("INSERT_UPLOAD_WITH_DRAWER_COMMAND");import{jsx as ut}from"react/jsx-runtime";import F from"bson-objectid";import{$applyNodeReplacement as ft}from"lexical";import*as U from"react";import{jsx as it}from"react/jsx-runtime";import{DecoratorBlockNode as lt}from"@lexical/react/LexicalDecoratorBlockNode.js";import j from"bson-objectid";import{$applyNodeReplacement as st}from"lexical";import"react";function O(e){return e.parentElement!=null&&e.parentElement.tagName==="LI"&&e.previousSibling===null&&e.getAttribute("aria-roledescription")==="checkbox"}function ct(e){if(e.hasAttribute("data-lexical-upload-relation-to")&&e.hasAttribute("data-lexical-upload-id")){let n=e.getAttribute("data-lexical-upload-id"),r=e.getAttribute("data-lexical-upload-relation-to");if(n!=null&&r!=null)return{node:M({data:{fields:{},relationTo:r,value:n}})}}let t=e;return t.src.startsWith("file:///")||O(t),null}var S=class extends lt{__data;constructor({data:t,format:n,key:r}){super(n,r),this.__data=t}static clone(t){return new this({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"upload"}static importDOM(){return{img:t=>({conversion:ct,priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new j.default().toHexString(),t.version=3);let n={id:t.id,fields:t.fields,relationTo:t.relationTo,value:t.value},r=M({data:n});return r.setFormat(t.format),r}static isInline(){return!1}decorate(){return it(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let t=document.createElement("img");return t.setAttribute("data-lexical-upload-id",String(this.__data?.value)),t.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(t){let n=this.getWritable();n.__data=t}updateDOM(){return!1}};function M({data:e}){return e?.id||(e.id=new j.default().toHexString()),st(new S({data:e}))}var mt=U.lazy(()=>import("./component-D6PKVJ2K.js").then(e=>({default:e.UploadComponent})));function pt(e){if(e.hasAttribute("data-lexical-upload-relation-to")&&e.hasAttribute("data-lexical-upload-id")){let n=e.getAttribute("data-lexical-upload-id"),r=e.getAttribute("data-lexical-upload-relation-to");if(n!=null&&r!=null)return{node:k({data:{fields:{},relationTo:r,value:n}})}}let t=e;return t.src.startsWith("file:///")||O(t),null}var A=class extends S{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importDOM(){return{img:t=>({conversion:pt,priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new F.default().toHexString(),t.version=3);let n={id:t.id,fields:t.fields,relationTo:t.relationTo,value:t.value},r=k({data:n});return r.setFormat(t.format),r}decorate(){return ut(mt,{data:this.__data,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function k({data:e}){return e?.id||(e.id=new F.default().toHexString()),ft(new A({data:e}))}function qt(e){return e instanceof A}export{Ot as a,It as b,Mt as c,A as d,k as e,qt as f};
|
|
2
|
+
//# sourceMappingURL=chunk-DOK5S7LE.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utilities/fieldsDrawer/Drawer.tsx", "../../../src/utilities/fieldsDrawer/DrawerContent.tsx", "../../../src/features/relationship/client/utils/EnabledRelationshipsCondition.tsx", "../../../src/features/upload/client/drawer/commands.ts", "../../../src/features/upload/client/nodes/UploadNode.tsx", "../../../src/features/upload/server/nodes/UploadNode.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\nimport type { ClientField, Data, FormState, JsonObject } from 'payload'\n\nimport { Drawer, EditDepthProvider, useModal } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { DrawerContent } from './DrawerContent.js'\n\nexport type FieldsDrawerProps = {\n readonly className?: string\n readonly data?: Data\n readonly drawerSlug: string\n readonly drawerTitle?: string\n readonly featureKey: string\n readonly fieldMapOverride?: ClientField[]\n readonly handleDrawerSubmit: (fields: FormState, data: JsonObject) => void\n readonly schemaFieldsPathOverride?: string\n readonly schemaPath: string\n readonly schemaPathSuffix?: string\n}\n\n/**\n * This FieldsDrawer component can be used to easily create a Drawer that contains a form with fields within your feature.\n * The fields are taken directly from the schema map based on your `featureKey` and `schemaPathSuffix`. Thus, this can only\n * be used if you provide your field schema inside the `generateSchemaMap` prop of your feature.server.ts.\n */\nexport const FieldsDrawer: React.FC<FieldsDrawerProps> = ({\n className,\n data,\n drawerSlug,\n drawerTitle,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { closeModal } = useModal()\n // The Drawer only renders its children (and itself) if it's open. Thus, by extracting the main content\n // to DrawerContent, this should be faster\n return (\n <EditDepthProvider>\n <Drawer className={className} slug={drawerSlug} title={drawerTitle ?? ''}>\n <DrawerContent\n data={data}\n featureKey={featureKey}\n fieldMapOverride={fieldMapOverride}\n handleDrawerSubmit={(args, args2) => {\n // Simply close drawer - no need for useLexicalDrawer here as at this point,\n // we don't need to restore the cursor position. This is handled by the useEffect in useLexicalDrawer.\n closeModal(drawerSlug)\n\n // Actual drawer submit logic needs to be triggered after the drawer is closed.\n // That's because the lexical selection / cursor restore logic that is striggerer by\n // `useLexicalDrawer` neeeds to be triggered before any editor.update calls that may happen\n // in the `handleDrawerSubmit` function.\n setTimeout(() => {\n handleDrawerSubmit(args, args2)\n }, 1)\n }}\n schemaFieldsPathOverride={schemaFieldsPathOverride}\n schemaPath={schemaPath}\n schemaPathSuffix={schemaPathSuffix}\n />\n </Drawer>\n </EditDepthProvider>\n )\n}\n", "'use client'\nimport type { FormState } from 'payload'\n\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap, permissions },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [schemaFieldsPath, id, data, getFormState, collectionSlug, globalSlug, getDocPreferences])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n formState: prevFormState,\n globalSlug,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n", "'use client'\nimport type { ClientCollectionConfig, ClientUser, VisibleEntities } from 'payload'\n\nimport { useAuth, useConfig, useEntityVisibility } from '@payloadcms/ui'\nimport * as React from 'react'\n\ntype Options = {\n uploads: boolean\n user: ClientUser\n visibleEntities: VisibleEntities\n}\n\ntype FilteredCollectionsT = (\n collections: ClientCollectionConfig[],\n options?: Options,\n) => ClientCollectionConfig[]\n\nconst filterRichTextCollections: FilteredCollectionsT = (collections, options) => {\n return collections.filter(({ slug, admin: { enableRichTextRelationship }, upload }) => {\n if (!options?.visibleEntities.collections.includes(slug)) {\n return false\n }\n\n if (options?.uploads) {\n return enableRichTextRelationship && Boolean(upload) === true\n }\n\n return upload ? false : enableRichTextRelationship\n })\n}\n\nexport const EnabledRelationshipsCondition: React.FC<any> = (props) => {\n const { children, uploads = false, ...rest } = props\n const {\n config: { collections },\n } = useConfig()\n const { user } = useAuth()\n const { visibleEntities } = useEntityVisibility()\n\n const [enabledCollectionSlugs] = React.useState(() =>\n filterRichTextCollections(collections, { uploads, user: user!, visibleEntities }).map(\n ({ slug }) => slug,\n ),\n )\n\n if (!enabledCollectionSlugs.length) {\n return null\n }\n\n return React.cloneElement(children, { ...rest, enabledCollectionSlugs })\n}\n", "'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nexport const INSERT_UPLOAD_WITH_DRAWER_COMMAND: LexicalCommand<{\n replace: { nodeKey: string } | false\n}> = createCommand('INSERT_UPLOAD_WITH_DRAWER_COMMAND')\n", "'use client'\nimport type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type { DOMConversionMap, DOMConversionOutput, LexicalNode, Spread } from 'lexical'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\n\nimport { isGoogleDocCheckboxImg, UploadServerNode } from '../../server/nodes/UploadNode.js'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../../client/component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nfunction $convertUploadElement(domNode: HTMLImageElement): DOMConversionOutput | null {\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createUploadNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n const img = domNode\n if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {\n return null\n }\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n} & Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadNode extends UploadServerNode {\n static clone(node: UploadServerNode): UploadServerNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: $convertUploadElement,\n priority: 0,\n }),\n }\n }\n\n static importJSON(serializedNode: SerializedUploadNode): UploadNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n decorate(): JSX.Element {\n return <RawUploadComponent data={this.__data} nodeKey={this.getKey()} />\n }\n\n exportJSON(): SerializedUploadNode {\n return super.exportJSON()\n }\n}\n\nexport function $createUploadNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadNode({ data: data as UploadData }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n", "import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { CollectionSlug, DataFromCollectionSlug, JsonObject } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nexport type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in CollectionSlug]: {\n fields: TUploadExtraFieldsData\n // Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n id: string\n relationTo: TCollectionSlug\n // Value can be just the document ID, or the full, populated document\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\nexport function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nfunction $convertUploadServerElement(domNode: HTMLImageElement): DOMConversionOutput | null {\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createUploadServerNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n const img = domNode\n if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {\n return null\n }\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n} & Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'upload'\n }\n\n static importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: $convertUploadServerElement,\n priority: 0,\n }),\n }\n }\n\n static importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n element.setAttribute('data-lexical-upload-id', String(this.__data?.value))\n element.setAttribute('data-lexical-upload-relation-to', this.__data?.relationTo)\n\n return { element }\n }\n\n exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n"],
|
|
5
|
+
"mappings": "wCAAA,OAAAA,KAAAC,MAAA,iEAGA,OAASC,UAAAA,EAAQC,qBAAAA,EAAmBC,YAAAA,MAAgB,iBACpD,MAAkB,0DCDlB,OACEC,QAAAA,EACAC,cAAAA,EACAC,gBAAAA,EACAC,mBAAAA,EACAC,sBAAAA,EACAC,kBAAAA,MACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OAAgBC,eAAAA,EAAaC,aAAAA,EAAWC,UAAAA,EAAQC,YAAAA,MAAgB,QAChE,OAASC,MAAMC,MAAY,OAMpB,IAAMC,EAAiFA,CAAC,CAC7FC,KAAAA,EACAC,WAAAA,EACAC,iBAAAA,EACAC,mBAAAA,EACAC,yBAAAA,EACAC,WAAAA,EACAC,iBAAAA,CAAgB,IACjB,CACC,GAAM,CAAEC,EAAAA,CAAC,EAAKC,EAAA,EACR,CAAEC,GAAAA,EAAIC,eAAAA,EAAgBC,kBAAAA,EAAmBC,WAAAA,CAAU,EAAKC,EAAA,EAExDC,EAA6BC,EAAO,IAAIC,eAAA,EAExC,CAACC,EAAcC,CAAA,EAAmBC,EAAwC,EAAA,EAE1E,CACJC,WAAY,CAAEC,uBAAAA,EAAwBC,YAAAA,CAAW,CAAE,EACjDC,EAAA,EAEE,CAAEC,aAAAA,CAAY,EAAKC,EAAA,EAEnBC,EACJtB,GACA,GAAGC,CAAA,6BAAuCJ,CAAA,GAAaK,EAAmB,IAAIA,CAAA,GAAqB,EAAA,GAE/FqB,EAAczB,GAAoBmB,EAAuBpB,CAAA,IAAcyB,CAAA,EAE7EE,EAAU,IAAA,CACR,IAAMC,EAAa,IAAIb,gBAqBvB,OAnB0B,SAAA,CACxB,GAAM,CAAEc,MAAAA,CAAK,EAAK,MAAMN,EAAa,CACnCf,GAAAA,EACAC,eAAAA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,CAAA,CACzE,CAEO,SAAS6B,GAAc/B,EAAoC,CAChE,OAAOA,aAAgBS,CACzB",
|
|
6
|
+
"names": ["c", "_c", "Drawer", "EditDepthProvider", "useModal", "Form", "FormSubmit", "RenderFields", "useDocumentInfo", "useServerFunctions", "useTranslation", "abortAndIgnore", "useCallback", "useEffect", "useRef", "useState", "v4", "uuid", "DrawerContent", "data", "featureKey", "fieldMapOverride", "handleDrawerSubmit", "schemaFieldsPathOverride", "schemaPath", "schemaPathSuffix", "t", "useTranslation", "id", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "onChangeAbortControllerRef", "useRef", "AbortController", "initialState", "setInitialState", "useState", "fieldProps", "featureClientSchemaMap", "permissions", "useEditorConfigContext", "getFormState", "useServerFunctions", "schemaFieldsPath", "fields", "useEffect", "controller", "state", "docPermissions", "docPreferences", "operation", "renderAllFields", "signal", "abortAndIgnore", "onChange", "useCallback", "formState", "prevFormState", "current", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "Array", "isArray", "onSubmit", "uuid", "_jsx", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "readOnly", "FormSubmit", "FieldsDrawer", "t0", "$", "_c", "className", "data", "drawerSlug", "drawerTitle", "featureKey", "fieldMapOverride", "handleDrawerSubmit", "schemaFieldsPathOverride", "schemaPath", "schemaPathSuffix", "closeModal", "useModal", "t1", "t2", "args", "args2", "setTimeout", "t3", "_jsx", "EditDepthProvider", "children", "Drawer", "slug", "title", "DrawerContent", "c", "_c", "useAuth", "useConfig", "useEntityVisibility", "React", "filterRichTextCollections", "collections", "options", "filter", "slug", "admin", "enableRichTextRelationship", "upload", "visibleEntities", "includes", "uploads", "Boolean", "EnabledRelationshipsCondition", "props", "$", "t0", "rest", "children", "undefined", "config", "t1", "user", "t2", "map", "t3", "enabledCollectionSlugs", "useState", "length", "t4", "cloneElement", "createCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "ObjectID", "$applyNodeReplacement", "React", "DecoratorBlockNode", "ObjectID", "$applyNodeReplacement", "isGoogleDocCheckboxImg", "img", "parentElement", "tagName", "previousSibling", "getAttribute", "$convertUploadServerElement", "domNode", "hasAttribute", "id", "relationTo", "node", "$createUploadServerNode", "data", "fields", "value", "src", "startsWith", "UploadServerNode", "__data", "constructor", "format", "key", "clone", "__format", "__key", "getType", "importDOM", "conversion", "priority", "importJSON", "serializedNode", "version", "default", "toHexString", "importedData", "setFormat", "isInline", "decorate", "_jsx", "RawUploadComponent", "nodeKey", "getKey", "exportDOM", "element", "document", "createElement", "setAttribute", "String", "exportJSON", "getData", "type", "getLatest", "setData", "writable", "getWritable", "updateDOM", "RawUploadComponent", "lazy", "then", "module", "default", "UploadComponent", "$convertUploadElement", "domNode", "hasAttribute", "id", "getAttribute", "relationTo", "node", "$createUploadNode", "data", "fields", "value", "img", "src", "startsWith", "isGoogleDocCheckboxImg", "UploadNode", "UploadServerNode", "clone", "getType", "importDOM", "conversion", "priority", "importJSON", "serializedNode", "version", "ObjectID", "toHexString", "importedData", "setFormat", "format", "decorate", "_jsx", "__data", "nodeKey", "getKey", "exportJSON", "$applyNodeReplacement", "$isUploadNode"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as G}from"./chunk-2CYU43GM.js";import{b as q}from"./chunk-CUIBIFW2.js";import{jsx as l,jsxs as y,Fragment as he}from"react/jsx-runtime";import ee,{createContext as Ce,useCallback as g,useEffect as M,useMemo as I,useRef as Q}from"react";import{useLexicalComposerContext as Se}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as _e}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as Be}from"@lexical/utils";import{getTranslation as U}from"@payloadcms/translations";import{Button as X,Drawer as De,EditDepthProvider as ye,Form as Ie,formatDrawerSlug as Ne,FormSubmit as ve,RenderFields as we,ShimmerEffect as Oe,useDocumentInfo as Fe,useEditDepth as Ee,useServerFunctions as Pe,useTranslation as $e}from"@payloadcms/ui";import{abortAndIgnore as T}from"@payloadcms/ui/shared";import{$getNodeByKey as Z,$getSelection as Me,$isNodeSelection as Te,CLICK_COMMAND as Le,COMMAND_PRIORITY_LOW as L,KEY_BACKSPACE_COMMAND as Ae,KEY_DELETE_COMMAND as Re}from"lexical";import{reduceFieldsToValues as je}from"payload/shared";import{v4 as Ke}from"uuid";import{jsx as fe}from"react/jsx-runtime";import be from"bson-objectid";import ge from"react";import de from"bson-objectid";import{DecoratorNode as ue}from"lexical";import{deepCopyObjectSimple as me}from"payload/shared";var b=class extends ue{__fields;constructor({fields:e,key:t}){super(t),this.__fields=e}static clone(e){return new this({fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return pe(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}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e){let t=me(e),r=this.getWritable();r.__fields=t}updateDOM(){return!1}};function pe(o){return new b({fields:{...o,id:o?.id||new de.default().toHexString()}})}var ke=ge.lazy(()=>import("./componentInline-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as G}from"./chunk-2CYU43GM.js";import{b as q}from"./chunk-CUIBIFW2.js";import{jsx as l,jsxs as y,Fragment as he}from"react/jsx-runtime";import ee,{createContext as Ce,useCallback as g,useEffect as M,useMemo as I,useRef as Q}from"react";import{useLexicalComposerContext as Se}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as _e}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as Be}from"@lexical/utils";import{getTranslation as U}from"@payloadcms/translations";import{Button as X,Drawer as De,EditDepthProvider as ye,Form as Ie,formatDrawerSlug as Ne,FormSubmit as ve,RenderFields as we,ShimmerEffect as Oe,useDocumentInfo as Fe,useEditDepth as Ee,useServerFunctions as Pe,useTranslation as $e}from"@payloadcms/ui";import{abortAndIgnore as T}from"@payloadcms/ui/shared";import{$getNodeByKey as Z,$getSelection as Me,$isNodeSelection as Te,CLICK_COMMAND as Le,COMMAND_PRIORITY_LOW as L,KEY_BACKSPACE_COMMAND as Ae,KEY_DELETE_COMMAND as Re}from"lexical";import{reduceFieldsToValues as je}from"payload/shared";import{v4 as Ke}from"uuid";import{jsx as fe}from"react/jsx-runtime";import be from"bson-objectid";import ge from"react";import de from"bson-objectid";import{DecoratorNode as ue}from"lexical";import{deepCopyObjectSimple as me}from"payload/shared";var b=class extends ue{__fields;constructor({fields:e,key:t}){super(t),this.__fields=e}static clone(e){return new this({fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return pe(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}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e){let t=me(e),r=this.getWritable();r.__fields=t}updateDOM(){return!1}};function pe(o){return new b({fields:{...o,id:o?.id||new de.default().toHexString()}})}var ke=ge.lazy(()=>import("./componentInline-XC7SFQPN.js").then(o=>({default:o.InlineBlockComponent}))),D=class extends b{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return xe(e.fields)}decorate(e,t){return fe(ke,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function xe(o){return new D({fields:{...o,id:o?.id||new be.default().toHexString()}})}function $(o){return o instanceof D}var m="inline-block",te=Ce({initialState:!1}),pt=()=>ee.useContext(te),ft=o=>{let{formData:e,nodeKey:t}=o,[r]=Se(),{i18n:N,t:u}=$e(),{fieldProps:{featureClientSchemaMap:ne,initialLexicalFormState:oe,permissions:re,readOnly:k,schemaPath:A},uuid:ie}=q(),{getFormState:x}=Pe(),le=Ee(),[c,se]=ee.useState(oe?.[e.id]?.formState),R=Ne({slug:"lexical-inlineBlocks-create-"+ie,depth:le}),{toggleDrawer:v}=G(R,!0),w=Q(null),[a,h,O]=_e(t),{id:C,collectionSlug:S,getDocPreferences:_,globalSlug:B}=Fe(),ce=`${A}.lexical_internal_feature.blocks.lexical_inline_blocks.${e.blockType}`,d=ne.blocks[ce][0].blocks[0],j=g(()=>{r.update(()=>{Z(t)?.remove()})},[r,t]),F=g(n=>{let i=Me();return a&&Te(i)&&(n.preventDefault(),r.update(()=>{i.getNodes().forEach(s=>{$(s)&&s.remove()})})),!1},[r,a]),K=g(n=>{let i=n;return i.target===w.current||w.current?.contains(i.target)?(i.shiftKey?h(!a):a||(O(),h(!0)),!0):!1},[a,h,O]);M(()=>Be(r.registerCommand(Le,K,L),r.registerCommand(Re,F,L),r.registerCommand(Ae,F,L)),[O,r,a,t,F,h,K]);let p=d?.labels?.singular?U(d.labels.singular,N):d?.slug,E=Q(new AbortController),f=`${A}.lexical_internal_feature.blocks.lexical_inline_blocks.${d?.slug}.fields`;M(()=>{let n=new AbortController;return e&&!c&&(async()=>{let{state:s}=await x({id:C,collectionSlug:S,data:e,docPermissions:{fields:!0},docPreferences:await _(),globalSlug:B,operation:"update",renderAllFields:!0,schemaPath:f,signal:n.signal});s&&se(s)})(),()=>{T(n)}},[x,f,C,e,c,S,B,_]);let J=g(async({formState:n})=>{T(E.current);let i=new AbortController;E.current=i;let{state:s}=await x({id:C,collectionSlug:S,docPermissions:{fields:!0},docPreferences:await _(),formState:n,globalSlug:B,operation:"update",schemaPath:f,signal:i.signal});return s||n},[x,C,S,_,B,f]);M(()=>()=>{T(E.current)},[]);let ae=g(n=>{let i=je(n);i.blockType=e.blockType,r.update(()=>{let s=Z(t);s&&$(s)&&s.setFields(i)})},[r,t,e]),P=c?._components?.customComponents?.BlockLabel,z=c?._components?.customComponents?.Block,Y=I(()=>()=>l(X,{buttonStyle:"icon-label",className:`${m}__removeButton`,disabled:k,icon:"x",onClick:n=>{n.preventDefault(),j()},round:!0,size:"small",tooltip:u("lexical:blocks:inlineBlocks:remove",{label:p})}),[p,k,j,u]),H=I(()=>()=>l(X,{buttonStyle:"icon-label",className:`${m}__editButton`,disabled:k,el:"div",icon:"edit",onClick:()=>{v()},round:!0,size:"small",tooltip:u("lexical:blocks:inlineBlocks:edit",{label:p})}),[p,k,u,v]),V=I(()=>({children:n})=>l("div",{className:[m,m+"-"+e.blockType,a&&`${m}--selected`].filter(Boolean).join(" "),ref:w,children:n}),[e.blockType,a]),W=I(()=>P?()=>P:()=>l("div",{children:U(d.labels.singular,N)}),[P,d.labels,N]);return y(Ie,{beforeSubmit:[J],disableValidationOnSubmit:!0,fields:d.fields,initialState:c||{},onChange:[J],onSubmit:n=>{ae(n),v()},uuid:Ke(),children:[l(ye,{children:l(De,{className:"",slug:R,title:u(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:p??u("lexical:blocks:inlineBlocks:label")}),children:c?y(he,{children:[l(we,{fields:d.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:f,permissions:re,readOnly:!1}),l(ve,{children:u("fields:saveChanges")})]}):null})}),z?l(te.Provider,{value:{EditButton:H,initialState:c,InlineBlockContainer:V,Label:W,nodeKey:t,RemoveButton:Y},children:z}):y(V,{children:[c?l(W,{}):l(Oe,{height:"15px",width:"40px"}),r.isEditable()?y("div",{className:`${m}__actions`,children:[l(H,{}),l(Y,{})]}):null]})]})};export{pt as a,ft as b,D as c,xe as d,$ as e};
|
|
2
|
+
//# sourceMappingURL=chunk-FBDJRK3A.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-` + uuidFromContext,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[\n componentMapRenderedBlockPath\n ][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n setInitialState(state)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n formState: prevFormState,\n globalSlug,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const CustomLabel = initialState?.['_components']?.customComponents?.BlockLabel\n const CustomBlock = initialState?.['_components']?.customComponents?.Block\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=\"div\"\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 }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={clientBlock.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport type {\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type { SerializedServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type SerializedInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\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 React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\nimport { deepCopyObjectSimple } from 'payload/shared'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nexport type SerializedServerInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedServerInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const fieldsCopy = deepCopyObjectSimple(fields)\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n\n updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
|
|
5
|
-
"mappings": "iJAEA,OAAOA,IAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,MAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,2BAAAA,OAA+B,yCACxC,OAASC,iBAAAA,OAAqB,iBAC9B,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OACEC,iBAAAA,EACAC,iBAAAA,GACAC,oBAAAA,GACAC,iBAAAA,GACAC,wBAAAA,EACAC,yBAAAA,GACAC,sBAAAA,OACK,UACP,OAASC,wBAAAA,OAA4B,iBAIrC,OAASC,MAAMC,OAAY,gDC9B3B,OAAOC,OAAc,gBACrB,OAAOC,OAAyB,QCGhC,OAAOC,OAAc,gBACrB,OAASC,iBAAAA,OAAqB,UAC9B,OAASC,wBAAAA,OAA4B,iBAmB9B,IAAMC,EAAN,cAAoCF,EAAA,CACzCG,SAEAC,YAAY,CAAEC,OAAAA,EAAQC,IAAAA,CAAG,EAAkD,CACzE,MAAMA,CAAA,EACN,KAAKH,SAAWE,CAClB,CAEA,OAAOE,MAAMC,EAAoD,CAC/D,OAAO,IAAI,KAAK,CACdH,OAAQG,EAAKL,SACbG,IAAKE,EAAKC,KACZ,CAAA,CACF,CAEA,OAAOC,SAAkB,CACvB,MAAO,aACT,CAEA,OAAOC,WAAqD,CAC1D,MAAO,CAAC,CACV,CAEA,OAAOC,WAAWC,EAAwE,CAExF,OADaC,GAA6BD,EAAeR,M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tE,CAAA,EAC5CsC,GAAahB,KAEXkD,EAA6B7C,EAAO,IAAI8C,eAAA,EACxCC,EAAmB,GAAGlE,CAAA,0DAAoE8B,GAAahB,IAAA,UAG7GuC,EAAU,IAAA,CACR,IAAMc,EAAkB,IAAIF,gBA0B5B,OAAI7E,GAAY,CAACN,IAxBS,SAAA,CAMxB,GAAM,CAAEsF,MAAAA,CAAK,EAAK,MAAMhE,EAAa,CACnCM,GAAAA,EACAc,eAAAA,EACA6C,KAAMjF,EACNkF,eAAgB,CAAEC,OAAQ,EAAK,EAC/BC,eAAgB,MAAM/C,EAAA,EACtBC,WAAAA,EACA+C,UAAW,SACXC,gBAAiB,GACjB1E,WAAYkE,EACZS,OAAQR,EAAgBQ,MAC1B,CAAA,EAEIP,GACF5D,GAAgB4D,CAAA,CAEpB,GAGO,EAGA,IAAA,CACLQ,EAAeT,CAAA,CACjB,CACF,EAAG,CACD/D,EACA8D,EACAxD,EACAtB,EACAN,EACA0C,EACAE,EACAD,CAAA,CACD,EAKD,IAAMoD,EAAW5C,EACf,MAAO,CAAEtB,UAAWmE,CAAa,
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-` + uuidFromContext,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[\n componentMapRenderedBlockPath\n ][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n setInitialState(state)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n formState: prevFormState,\n globalSlug,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n const CustomLabel = initialState?.['_components']?.customComponents?.BlockLabel\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n const CustomBlock = initialState?.['_components']?.customComponents?.Block\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=\"div\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={clientBlock.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport type {\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type { SerializedServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type SerializedInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\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 React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\nimport { deepCopyObjectSimple } from 'payload/shared'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nexport type SerializedServerInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedServerInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const fieldsCopy = deepCopyObjectSimple(fields)\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n\n updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
|
|
5
|
+
"mappings": "iJAEA,OAAOA,IAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,MAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,2BAAAA,OAA+B,yCACxC,OAASC,iBAAAA,OAAqB,iBAC9B,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,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mCAAA,CAC/B,CAAA,WAECX,EACCiI,EAAAQ,GAAA,WACE5B,EAAC6B,GAAA,CACCjD,OAAQzC,EAAYyC,OACpBkD,YAAW,GACXC,gBAAgB,GAChBC,WAAW,GACXC,iBAAkB1D,EAClBpE,YAAaA,GACbC,SAAU,KAEZ4F,EAACkC,GAAA,UAAYpI,EAAE,oBAAA,OAEf,SAGP8F,EACCI,EAAC/G,GAA4BkJ,SAAQ,CACnCC,MAAO,CACLzB,WAAAA,EACAxH,aAAAA,EACA0H,qBAAAA,EACAM,MAAAA,EACAzH,QAAAA,EACAoG,aAAAA,CACF,WAECF,IAGHwB,EAACP,EAAA,WACE1H,EAAe6G,EAACmB,EAAA,CAAA,CAAA,EAAWnB,EAACqC,GAAA,CAAcC,OAAO,OAAOC,MAAM,SAC9D5I,EAAO6I,WAAU,EAChBpB,EAAC,MAAA,CAAIjB,UAAW,GAAGnH,CAAA,sBACjBgH,EAACW,EAAA,CAAA,CAAA,EACDX,EAACF,EAAA,CAAA,CAAA,CAAA,IAED,IAAA,MAKd",
|
|
6
6
|
"names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "useLexicalNodeSelection", "mergeRegister", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "$getSelection", "$isNodeSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "React", "ObjectID", "DecoratorNode", "deepCopyObjectSimple", "ServerInlineBlockNode", "__fields", "constructor", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getLatest", "setFields", "fieldsCopy", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "editor", "config", "_jsx", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "useContext", "InlineBlockComponent", "props", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "permissions", "readOnly", "schemaPath", "uuid", "uuidFromContext", "useEditorConfigContext", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "setInitialState", "useState", "id", "formState", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "useRef", "isSelected", "setSelected", "clearSelection", "useLexicalNodeSelection", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "componentMapRenderedBlockPath", "blockType", "clientBlock", "blocks", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "$onDelete", "event", "deleteSelection", "$getSelection", "$isNodeSelection", "preventDefault", "getNodes", "forEach", "node", "$isInlineBlockNode", "onClick", "payload", "target", "current", "contains", "shiftKey", "useEffect", "mergeRegister", "registerCommand", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_DELETE_COMMAND", "KEY_BACKSPACE_COMMAND", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "fields", "docPreferences", "operation", "renderAllFields", "signal", "abortAndIgnore", "onChange", "prevFormState", "controller", "onFormSubmit", "newData", "reduceFieldsToValues", "setFields", "CustomLabel", "customComponents", "BlockLabel", "CustomBlock", "Block", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "e", "round", "size", "tooltip", "label", "EditButton", "el", "InlineBlockContainer", "children", "filter", "Boolean", "join", "ref", "Label", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "title", "_Fragment", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "FormSubmit", "Provider", "value", "ShimmerEffect", "height", "width", "isEditable"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var R=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ln(o){return o instanceof HTMLElement}var Y=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 at(o){return o instanceof Y}import{c as _e}from"react/compiler-runtime";import{jsx as Te}from"react/jsx-runtime";import{useLexicalComposerContext as Se}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as we}from"@lexical/utils";import{$getSelection as q,$isRangeSelection as V,$isTextNode as Re,COMMAND_PRIORITY_LOW as Ce,createCommand as Ie}from"lexical";import{useEffect as Et,useState as Ne}from"react";import*as j from"react";import{c as gt}from"react/compiler-runtime";import{useLexicalComposerContext as pt}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ut}from"@lexical/utils";import{$getSelection as ne,$isRangeSelection as oe,COMMAND_PRIORITY_LOW as k,createCommand as re,KEY_ARROW_DOWN_COMMAND as ie,KEY_ARROW_UP_COMMAND as se,KEY_ENTER_COMMAND as ce,KEY_ESCAPE_COMMAND as le,KEY_TAB_COMMAND as ae}from"lexical";import{useCallback as Q,useEffect as M,useLayoutEffect as ue,useMemo as fe,useRef as me,useState as de}from"react";var ge="slash-menu-popup",ft=o=>{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"}),o.scrollIntoView({block:"nearest"})};function pe(o,t,e){let r=e;for(let n=r;n<=t.length;n++)o.substring(o.length-n)===t.substring(0,n)&&(r=n);return r}function he(o){let t=ne();if(!oe(t)||!t.isCollapsed())return null;let e=t.anchor;if(e.type!=="text")return null;let r=e.getNode();if(!r.isSimpleText())return null;let n=e.offset,s=r.getTextContent().slice(0,n),i=o.replaceableString.length,c=pe(s,o.matchingString,i),l=n-c;if(l<0)return null;let a;return l===0?[a]=r.splitText(n):[,a]=r.splitText(l,n),a}function xe(o,t){let e=getComputedStyle(o),r=e.position==="absolute",n=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let s=o;s=s.parentElement;)if(e=getComputedStyle(s),!(r&&e.position==="static")&&n.test(e.overflow+e.overflowY+e.overflowX))return s;return document.body}function mt(o,t){let e=o.getBoundingClientRect(),r=t.getBoundingClientRect();return e.top>r.top&&e.top<r.bottom}function Ee(o,t,e,r){let n=gt(12),[s]=pt(),i;n[0]!==t.current||n[1]!==o||n[2]!==s||n[3]!==e||n[4]!==r?(i=()=>{let l=t.current;if(l!=null&&o!=null){let a=s.getRootElement(),u=a!=null?xe(a,!1):document.body,d;d=!1;let g;g=mt(l,u);let h=function(){d||(window.requestAnimationFrame(function(){e(),d=!1}),d=!0);let f=mt(l,u);f!==g&&(g=f,r?.(f))},m=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",h,{capture:!0,passive:!0}),m.observe(l),()=>{m.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",h,!0)}}},n[0]=t.current,n[1]=o,n[2]=s,n[3]=e,n[4]=r,n[5]=i):i=n[5];let c;n[6]!==s||n[7]!==r||n[8]!==e||n[9]!==o||n[10]!==t?(c=[s,r,e,o,t],n[6]=s,n[7]=r,n[8]=e,n[9]=o,n[10]=t,n[11]=c):c=n[11],M(i,c)}var dt=re("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function ht({anchorElementRef:o,close:t,editor:e,groups:r,menuRenderFn:n,resolution:s,shouldSplitNodeWithQuery:i=!1}){let[c,l]=de(null),a=s.match&&s.match.matchingString||"",u=Q(m=>{let f=e.getRootElement();f!==null&&(f.setAttribute("aria-activedescendant",`${ge}__item-${m.key}`),l(m.key))},[e]),d=Q(()=>{if(r!==null&&a!=null){let m=r.flatMap(f=>f.items);if(m.length){let f=m[0];u(f)}}},[r,u,a]);M(()=>{d()},[a,d]);let g=Q(m=>{t(),e.update(()=>{let f=s.match!=null&&i?he(s.match):null;f&&f.remove()},{onUpdate(){m.onSelect({editor:e,queryString:s.match?s.match.matchingString:""})}})},[e,i,s.match,t]);M(()=>()=>{let m=e.getRootElement();m!==null&&m.removeAttribute("aria-activedescendant")},[e]),ue(()=>{r===null?l(null):c===null&&d()},[r,c,u,d]),M(()=>ut(e.registerCommand(dt,({item:m})=>m.ref&&m.ref.current!=null?(ft(m.ref.current),!0):!1,k)),[e,u]),M(()=>ut(e.registerCommand(ie,m=>{let f=m;if(r!==null&&r.length&&c!==null){let x=r.flatMap(_=>_.items),p=x.findIndex(_=>_.key===c),S=p!==x.length-1?p+1:0,E=x[S];u(E),E.ref!=null&&E.ref.current&&e.dispatchCommand(dt,{index:S,item:E}),f.preventDefault(),f.stopImmediatePropagation()}return!0},k),e.registerCommand(se,m=>{let f=m;if(r!==null&&r.length&&c!==null){let x=r.flatMap(_=>_.items),p=x.findIndex(_=>_.key===c),S=p!==0?p-1:x.length-1,E=x[S];u(E),E.ref!=null&&E.ref.current&&ft(E.ref.current),f.preventDefault(),f.stopImmediatePropagation()}return!0},k),e.registerCommand(le,m=>{let f=m;return f.preventDefault(),f.stopImmediatePropagation(),t(),!0},k),e.registerCommand(ae,m=>{let f=m;if(r===null||c===null)return!1;let p=r.flatMap(S=>S.items).find(S=>S.key===c);return p?(f.preventDefault(),f.stopImmediatePropagation(),g(p),!0):!1},k),e.registerCommand(ce,m=>{if(r===null||c===null)return!1;let x=r.flatMap(p=>p.items).find(p=>p.key===c);return x?(m!==null&&(m.preventDefault(),m.stopImmediatePropagation()),g(x),!0):!1},k)),[g,t,e,r,c,u]);let h=fe(()=>({groups:r,selectedItemKey:c,selectItemAndCleanUp:g,setSelectedItemKey:l}),[g,c,r]);return n(o,h,s.match?s.match.matchingString:"")}function xt(o,t,e,r){let n=gt(14),[s]=pt(),i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=R?document.createElement("div"):null,n[0]=i):i=n[0];let c=me(i),l;n[1]!==s||n[2]!==t||n[3]!==o||n[4]!==r?(l=()=>{if(c.current===null||parent===void 0)return;let m=s.getRootElement(),f=c.current,x=f.firstChild;if(m!==null&&t!==null){let{height:p,width:S}=t.getRect(),{left:E,top:_}=t.getRect(),F=_;if(_=_-(o.getBoundingClientRect().top+window.scrollY),E=E-(o.getBoundingClientRect().left+window.scrollX),f.style.left=`${E+window.scrollX}px`,f.style.height=`${p}px`,f.style.width=`${S}px`,x!==null){let T=x.getBoundingClientRect(),N=T.height,w=T.width,y=m.getBoundingClientRect();E+w>y.right&&(f.style.left=`${y.right-w+window.scrollX}px`);let b=F+N+32>window.innerHeight,O=F<0;b&&!O?f.style.top=`${_+32-N+window.scrollY-(p+24)}px`:f.style.top=`${_+window.scrollY+32}px`}f.isConnected||(r!=null&&(f.className=r),f.setAttribute("aria-label","Slash menu"),f.setAttribute("id","slash-menu"),f.setAttribute("role","listbox"),f.style.display="block",f.style.position="absolute",o.append(f)),c.current=f,m.setAttribute("aria-controls","slash-menu")}},n[1]=s,n[2]=t,n[3]=o,n[4]=r,n[5]=l):l=n[5];let a=l,u,d;n[6]!==s||n[7]!==t||n[8]!==a?(u=()=>{let m=s.getRootElement();if(t!==null)return a(),()=>{m!==null&&m.removeAttribute("aria-controls");let f=c.current;f!==null&&f.isConnected&&f.remove()}},d=[s,a,t],n[6]=s,n[7]=t,n[8]=a,n[9]=u,n[10]=d):(u=n[9],d=n[10]),M(u,d);let g;return n[11]!==t||n[12]!==e?(g=m=>{t!==null&&(m||e(null))},n[11]=t,n[12]=e,n[13]=g):g=n[13],Ee(t,c,a,g),c}var Zn=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Fe(o){let t=o.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let r=t.offset;return e.getTextContent().slice(0,r)}function _t(o,t,e){let r=e.getSelection();if(r===null||!r.isCollapsed)return!1;let n=r.anchorNode,s=o,i=r.anchorOffset;if(n==null||i==null)return!1;try{t.setStart(n,s),t.setEnd(n,i>1?i:1)}catch{return!1}return!0}function ye(o){let t;return o.getEditorState().read(()=>{let e=q();V(e)&&(t=Fe(e))}),t}function Tt(o,t){return t!==0?!1:o.getEditorState().read(()=>{let e=q();if(V(e)){let s=e.anchor.getNode().getPreviousSibling();return Re(s)&&s.isTextEntity()}return!1})}function St(o){j.startTransition?j.startTransition(o):o()}var be=Ie("ENABLE_SLASH_MENU_COMMAND");function Jn(o){let t=_e(30),{anchorClassName:e,anchorElem:r,groups:n,menuRenderFn:s,onClose:i,onOpen:c,onQueryChange:l,triggerFn:a}=o,[u]=Se(),[d,g]=Ne(null),h=xt(r,d,g,e),m;t[0]!==i||t[1]!==d?(m=()=>{g(null),i!=null&&d!==null&&i()},t[0]=i,t[1]=d,t[2]=m):m=t[2];let f=m,x;t[3]!==c||t[4]!==d?(x=N=>{g(N),c!=null&&d===null&&c(N)},t[3]=c,t[4]=d,t[5]=x):x=t[5];let p=x,S,E;t[6]!==u||t[7]!==p?(S=()=>we(u.registerCommand(be,N=>{let{node:w}=N;return u.getEditorState().read(()=>{let y={leadOffset:0,matchingString:"",replaceableString:""};if(!Tt(u,y.leadOffset)&&w!==null){let b=u._window??window,O=b.document.createRange();_t(y.leadOffset,O,b)!==null&&St(()=>p({getRect:()=>O.getBoundingClientRect(),match:y}));return}}),!0},Ce)),E=[u,p],t[6]=u,t[7]=p,t[8]=S,t[9]=E):(S=t[8],E=t[9]),Et(S,E);let _;t[10]!==u||t[11]!==f||t[12]!==a||t[13]!==l||t[14]!==p?(_=()=>{let N=()=>{u.getEditorState().read(()=>{let y=u._window??window,b=y.document.createRange(),O=q(),z=ye(u);if(!V(O)||!O.isCollapsed()||z===void 0||b===null){f();return}let A=a({editor:u,query:z});if(l(A?A.matchingString:null),A!==null&&!Tt(u,A.leadOffset)&&_t(A.leadOffset,b,y)!==null){St(()=>p({getRect:()=>b.getBoundingClientRect(),match:A}));return}f()})},w=u.registerUpdateListener(N);return()=>{w()}},t[10]=u,t[11]=f,t[12]=a,t[13]=l,t[14]=p,t[15]=_):_=t[15];let F;t[16]!==u||t[17]!==a||t[18]!==l||t[19]!==d||t[20]!==f||t[21]!==p?(F=[u,a,l,d,f,p],t[16]=u,t[17]=a,t[18]=l,t[19]=d,t[20]=f,t[21]=p,t[22]=F):F=t[22],Et(_,F);let T;return t[23]!==h||t[24]!==d||t[25]!==u||t[26]!==f||t[27]!==n||t[28]!==s?(T=h.current===null||d===null||u===null?null:Te(ht,{anchorElementRef:h,close:f,editor:u,groups:n,menuRenderFn:s,resolution:d,shouldSplitNodeWithQuery:!0}),t[23]=h,t[24]=d,t[25]=u,t[26]=f,t[27]=n,t[28]=s,t[29]=T):T=t[29],T}var wt=class o{_bottom;_left;_right;_top;constructor(t,e,r,n){let[s,i]=e<=n?[e,n]:[n,e],[c,l]=t<=r?[t,r]:[r,t];this._top=s,this._right=l,this._left=c,this._bottom=i}static fromDOM(t){let{height:e,left:r,top:n,width:s}=t.getBoundingClientRect();return o.fromLWTH(r,s,n,e)}static fromDOMRect(t){let{height:e,left:r,top:n,width:s}=t;return o.fromLWTH(r,s,n,e)}static fromLTRB(t,e,r,n){return new o(t,e,r,n)}static fromLWTH(t,e,r,n){return new o(t,r,t+e,r+n)}static fromPoints(t,e){let{x:r,y:n}=t,{x:s,y:i}=e;return o.fromLTRB(r,n,s,i)}contains(t){if(at(t)){let{x:i,y:c}=t,l=c<this._top,a=c>this._bottom,u=i<this._left,d=i>this._right;return{reason:{isOnBottomSide:a,isOnLeftSide:u,isOnRightSide:d,isOnTopSide:l},result:!l&&!a&&!u&&!d}}let{bottom:e,left:r,right:n,top:s}=t;return s>=this._top&&s<=this._bottom&&e>=this._top&&e<=this._bottom&&r>=this._left&&r<=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 r=0,n=0;return t.x<this._left?r=this._left-t.x:t.x>this._right&&(r=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(r*r+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:r,top:n}){return n===this._top&&t===this._bottom&&e===this._left&&r===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:r=this.right,top:n=this.top}){return new o(e,n,r,t)}intersectsWith(t){let{height:e,left:r,top:n,width:s}=t,{height:i,left:c,top:l,width:a}=this,u=r+s>=c+a?r+s:c+a,d=n+e>=l+i?n+e:l+i,g=r<=c?r:c,h=n<=l?n:l;return u-g<=s+a&&d-h<=e+i}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 oo({editorConfig:o}){return Oe({nodes:o.features.nodes})}function Oe({nodes:o}){return o.map(t=>"node"in t?t.node:t)}var Ae=R&&"documentMode"in document?document.documentMode:null,so=R&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),co=R&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),lo=R&&"InputEvent"in window&&!Ae?"getTargetRanges"in new window.InputEvent("input"):!1,Z=R&&/Version\/[\d.].*Safari/.test(navigator.userAgent),J=R&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ao=R&&/Android/.test(navigator.userAgent),uo=R&&/Win/.test(navigator.platform),ke=R&&/^(?=.*Chrome).*/i.test(navigator.userAgent),tt=R&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!ke;import{$getRoot as Ke,$isDecoratorNode as Ft,$isElementNode as H,$isLineBreakNode as Ue,$isTextNode as K}from"lexical";import{$isListItemNode as Me,$isListNode as Rt}from"@lexical/list";import{$isHeadingNode as Le,$isQuoteNode as $e}from"@lexical/rich-text";import{$isParagraphNode as De,$isTextNode as Pe}from"lexical";var C={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},I={...C,requiresParagraphStart:!0},ho={...I,export:L(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},xo={...I,export:L(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},Eo={...I,export:L(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},_o={...I,export:L(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},To={...I,export:L(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},So={...I,export:L(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},wo={...I,export:Be,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},Ro={...I,export:et,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},Co={...I,export:et,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},Io={...I,export:et,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},No={...I,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},Fo={...I,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},yo={...C,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},bo={...C,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},Oo={...C,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},Ao={...C,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},ko={...C,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Mo={...C,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Lo={...C,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},$o={...C,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},Do={...C,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},Po={...C,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},vo={...C,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},Bo={...C,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function L(o){return(t,e)=>Le(t)&&t.getTag()==="h"+o?"#".repeat(o)+" "+e(t):null}function et(o,t){return Rt(o)?Ct(o,t,0):null}var ve=4;function Ct(o,t,e){let r=[],n=o.getChildren(),s=0;for(let i of n)if(Me(i)){if(i.getChildrenSize()===1){let a=i.getFirstChild();if(Rt(a)){r.push(Ct(a,t,e+1));continue}}let c=" ".repeat(e*ve),l=o.getListType()==="bullet"?"- ":`${o.getStart()+s}. `;r.push(c+l+t(i)),s++}return r.join(`
|
|
2
|
+
`)}function Be(o,t){return $e(o)?"> "+t(o):null}function B(o,t){let e={};for(let r of o){let n=t(r);n&&(e[n]?e[n].push(r):e[n]=[r])}return e}function $(o){let t=B(o,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var D=/[!-/:-@[-`{-~\s]/,He=/^\s{0,3}$/;function v(o){if(!De(o))return!1;let t=o.getFirstChild();return t==null||o.getChildrenSize()===1&&Pe(t)&&He.test(t.getTextContent())}function yt(o,t=!1){let e=$(o),r=[...e.multilineElement,...e.element],n=!t,s=e.textFormat.filter(i=>i.format.length===1);return i=>{let c=[],l=(i||Ke()).getChildren();for(let a=0;a<l.length;a++){let u=l[a],d=We(u,r,s,e.textMatch);d!=null&&c.push(n&&a>0&&!v(u)&&!v(l[a-1])?`
|
|
3
|
+
`.concat(d):d)}return c.join(`
|
|
4
|
+
`)}}function We(o,t,e,r){for(let n of t){if(!n.export)continue;let s=n.export(o,i=>U(i,e,r));if(s!=null)return s}return H(o)?U(o,e,r):Ft(o)?o.getTextContent():null}function U(o,t,e){let r=[],n=o.getChildren();t:for(let s of n){for(let i of e){if(!i.export)continue;let c=i.export(s,l=>U(l,t,e),(l,a)=>It(l,a,t));if(c!=null){r.push(c);continue t}}Ue(s)?r.push(`
|
|
5
|
+
`):K(s)?r.push(It(s,s.getTextContent(),t)):H(s)?r.push(U(s,t,e)):Ft(s)&&r.push(s.getTextContent())}return r.join("")}function It(o,t,e){let r=t.trim(),n=r,s=new Set;for(let i of e){let c=i.format[0],l=i.tag;if(nt(o,c)&&!s.has(c)){s.add(c);let a=Nt(o,!0);nt(a,c)||(n=l+n);let u=Nt(o,!1);nt(u,c)||(n+=l)}}return t.replace(r,()=>n)}function Nt(o,t){let e=t?o.getPreviousSibling():o.getNextSibling();if(!e){let r=o.getParentOrThrow();r.isInline()&&(e=t?r.getPreviousSibling():r.getNextSibling())}for(;e;){if(H(e)){if(!e.isInline())break;let r=t?e.getLastDescendant():e.getFirstDescendant();if(K(r))return r;e=t?e.getPreviousSibling():e.getNextSibling()}if(K(e))return e;if(!H(e))return null}return null}function nt(o,t){return K(o)&&o.hasFormat(t)}import{$isListItemNode as Ge,$isListNode as bt}from"@lexical/list";import{$isQuoteNode as Xe}from"@lexical/rich-text";import{$findMatchingParent as ze}from"@lexical/utils";import{$createLineBreakNode as Ye,$createParagraphNode as Qe,$createTextNode as je,$getRoot as qe,$getSelection as Ve,$isParagraphNode as Ze}from"lexical";function Ot(o,t=!1){let e=$(o),r=nn(e.textFormat);return(n,s)=>{let i=n.split(`
|
|
6
|
+
`),c=i.length,l=s||qe();l.clear();for(let u=0;u<c;u++){let d=i[u],[g,h]=Je(i,u,e.multilineElement,l);if(g){u=h;continue}tn(d,l,e.element,r,e.textMatch)}let a=l.getChildren();for(let u of a)!t&&v(u)&&l.getChildrenSize()>1&&u.remove();Ve()!==null&&l.selectStart()}}function Je(o,t,e,r){for(let n of e){let{handleImportAfterStartMatch:s,regExpEnd:i,regExpStart:c,replace:l}=n,a=o[t].match(c);if(!a)continue;if(s){let m=s({lines:o,rootNode:r,startLineIndex:t,startMatch:a,transformer:n});if(m===null)continue;if(m)return m}let u=typeof i=="object"&&"regExp"in i?i.regExp:i,d=i&&typeof i=="object"&&"optional"in i?i.optional:!i,g=t,h=o.length;for(;g<h;){let m=u?o[g].match(u):null;if(!m&&(!d||d&&g<h-1)){g++;continue}if(m&&t===g&&m.index===a.index){g++;continue}let f=[];if(m&&t===g)f.push(o[t].slice(a[0].length,-m[0].length));else for(let x=t;x<=g;x++)if(x===t){let p=o[x].slice(a[0].length);f.push(p)}else if(x===g&&m){let p=o[x].slice(0,-m[0].length);f.push(p)}else f.push(o[x]);if(l(r,null,a,m,f,!0)!==!1)return[!0,g];break}}return[!1,t]}function tn(o,t,e,r,n){let s=je(o),i=Qe();i.append(s),t.append(i);for(let{regExp:c,replace:l}of e){let a=o.match(c);if(a&&(s.setTextContent(o.slice(a[0].length)),l(i,[s],a,!0)!==!1))break}if(W(s,r,n),i.isAttached()&&o.length>0){let c=i.getPreviousSibling();if(Ze(c)||Xe(c)||bt(c)){let l=c;if(bt(c)){let a=c.getLastDescendant();a==null?l=null:l=ze(a,Ge)}l!=null&&l.getTextContentSize()>0&&(l.splice(l.getChildrenSize(),0,[Ye(),...i.getChildren()]),i.remove())}}}function W(o,t,e){let r=o.getTextContent(),n=en(r,t);if(!n){At(o,e);return}let s,i,c;if(n[0]===r)s=o;else{let a=n.index||0,u=a+n[0].length;a===0?[s,c]=o.splitText(u):[i,s,c]=o.splitText(a,u)}s.setTextContent(n[2]);let l=t.transformersByTag[n[1]];if(l)for(let a of l.format)s.hasFormat(a)||s.toggleFormat(a);s.hasFormat("code")||W(s,t,e),i&&W(i,t,e),c&&W(c,t,e)}function At(o,t){let e=o;t:for(;e;){for(let r of t){if(!r.replace||!r.importRegExp)continue;let n=e.getTextContent().match(r.importRegExp);if(!n)continue;let s=n.index||0,i=r.getEndIndex?r.getEndIndex(e,n):s+n[0].length;if(i===!1)continue;let c,l;s===0?[l,e]=e.splitText(i):[,l,c]=e.splitText(s,i),c&&At(c,t),r.replace(l,n);continue t}break}}function en(o,t){let e=o.match(t.openTagsRegExp);if(e==null)return null;for(let r of e){let n=r.replace(/^\s/,""),s=t.fullMatchRegExpByTag[n];if(s==null)continue;let i=o.match(s),c=t.transformersByTag[n];if(i!=null&&c!=null){if(c.intraword!==!1)return i;let{index:l=0}=i,a=o[l-1],u=o[l+i[0].length];if((!a||D.test(a))&&(!u||D.test(u)))return i}}return null}function nn(o){let t={},e={},r=[],n="(?<![\\\\])";for(let s of o){let{tag:i}=s;t[i]=s;let c=i.replace(/([*^+])/g,"\\$1");r.push(c),Z||J||tt?e[i]=new RegExp(`(${c})(?![${c}\\s])(.*?[^${c}\\s])${c}(?!${c})`):e[i]=new RegExp(`(?<![\\\\${c}])(${c})((\\\\${c})?.*?[^${c}\\s](\\\\${c})?)((?<!\\\\)|(?<=\\\\\\\\))(${c})(?![\\\\${c}])`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp((Z||J||tt?"":`${n}`)+"("+r.join("|")+")","g"),transformersByTag:t}}import{$createRangeSelection as on,$getSelection as ot,$isLineBreakNode as rn,$isRangeSelection as rt,$isRootOrShadowRoot as Mt,$isTextNode as Lt,$setSelection as sn}from"lexical";function cn(o,t,e,r){let n=o.getParent();if(!Mt(n)||o.getFirstChild()!==t)return!1;let s=t.getTextContent();if(s[e-1]!==" ")return!1;for(let{regExp:i,replace:c}of r){let l=s.match(i);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let a=t.getNextSiblings(),[u,d]=t.splitText(e);u.remove();let g=d?[d,...a]:a;if(c(o,g,l,!1)!==!1)return!0}}return!1}function ln(o,t,e,r){let n=o.getParent();if(!Mt(n)||o.getFirstChild()!==t)return!1;let s=t.getTextContent();if(s[e-1]!==" ")return!1;for(let{regExpEnd:i,regExpStart:c,replace:l}of r){if(i&&!("optional"in i)||i&&"optional"in i&&!i.optional)continue;let a=s.match(c);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let u=t.getNextSiblings(),[d,g]=t.splitText(e);d.remove();let h=g?[g,...u]:u;if(l(o,h,a,null,null,!1)!==!1)return!0}}return!1}function an(o,t,e){let r=o.getTextContent(),n=r[t-1],s=e[n];if(s==null)return!1;t<r.length&&(r=r.slice(0,t));for(let i of s){if(!i.replace||!i.regExp)continue;let c=r.match(i.regExp);if(c===null)continue;let l=c.index||0,a=l+c[0].length,u;return l===0?[u]=o.splitText(a):[,u]=o.splitText(l,a),u.selectNext(0,0),i.replace(u,c),!0}return!1}function un(o,t,e){let r=o.getTextContent(),n=t-1,s=r[n],i=e[s];if(!i)return!1;for(let c of i){let{tag:l}=c,a=l.length,u=n-a+1;if(a>1&&!$t(r,u,l,0,a)||r[u-1]===" ")continue;let d=r[n+1];if(c.intraword===!1&&d&&!D.test(d))continue;let g=o,h=g,m=kt(r,u,l),f=h;for(;m<0&&(f=f.getPreviousSibling())&&!rn(f);)if(Lt(f)){let w=f.getTextContent();h=f,m=kt(w,w.length,l)}if(m<0||h===g&&m+a===u)continue;let x=h.getTextContent();if(m>0&&x[m-1]===s)continue;let p=x[m-1];if(c.intraword===!1&&p&&!D.test(p))continue;let S=g.getTextContent(),E=S.slice(0,u)+S.slice(n+1);g.setTextContent(E);let _=h===g?E:x;h.setTextContent(_.slice(0,m)+_.slice(m+a));let F=ot(),T=on();sn(T);let N=n-a*(h===g?2:1)+1;T.anchor.set(h.__key,m,"text"),T.focus.set(g.__key,N,"text");for(let w of c.format)T.hasFormat(w)||T.formatText(w);T.anchor.set(T.focus.key,T.focus.offset,T.focus.type);for(let w of c.format)T.hasFormat(w)&&T.toggleFormat(w);return rt(F)&&(T.format=F.format),!0}return!1}function kt(o,t,e){let r=e.length;for(let n=t;n>=r;n--){let s=n-r;if($t(o,s,e,0,r)&&o[s+r]!==" ")return s}return-1}function $t(o,t,e,r,n){for(let s=0;s<n;s++)if(o[t+s]!==e[r+s])return!1;return!0}function tr(o,t=G){let e=$(t),r=B(e.textFormat,({tag:i})=>i[i.length-1]),n=B(e.textMatch,({trigger:i})=>i);for(let i of t){let c=i.type;if(c==="element"||c==="text-match"||c==="multiline-element"){let l=i.dependencies;for(let a of l)if(!o.hasNode(a))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+a.getType())}}let s=(i,c,l)=>{cn(i,c,l,e.element)||ln(i,c,l,e.multilineElement)||an(c,l,n)||un(c,l,r)};return o.registerUpdateListener(({dirtyLeaves:i,editorState:c,prevEditorState:l,tags:a})=>{if(a.has("collaboration")||a.has("historic")||o.isComposing())return;let u=c.read(ot),d=l.read(ot);if(!rt(d)||!rt(u)||!u.isCollapsed()||u.is(d))return;let g=u.anchor.key,h=u.anchor.offset,m=c._nodeMap.get(g);!Lt(m)||!i.has(g)||h!==1&&h>d.anchor.offset+1||o.update(()=>{if(m.hasFormat("code"))return;let f=m.getParent();f!==null&&s(f,m,u.anchor.offset)})})}import{$createListItemNode as fn,$createListNode as mn,$isListItemNode as dn,$isListNode as P,ListItemNode as st,ListNode as ct}from"@lexical/list";import{$createHeadingNode as gn,$createQuoteNode as pn,$isHeadingNode as hn,$isQuoteNode as Dt,HeadingNode as xn,QuoteNode as En}from"@lexical/rich-text";import{$createLineBreakNode as _n}from"lexical";var Pt=/^(\s*)(\d+)\.\s/,vt=/^(\s*)[-*+]\s/,Bt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,it=/^(#{1,6})\s/,Ht=/^>\s/,Tn=/^[ \t]*```(\w+)?/,Sn=/[ \t]*```$/,wn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,Rn=/^\|(.+)\|\s?$/,Cn=/^(\| ?:?-*:? ?)+\|\s?$/,In=o=>(t,e,r)=>{let n=o(r);n.append(...e),t.replace(n),n.select(0,0)},Kt=4;function Nn(o){let t=o.match(/\t/g),e=o.match(/ /g),r=0;return t&&(r+=t.length),e&&(r+=Math.floor(e.length/Kt)),r}var lt=o=>(t,e,r)=>{let n=t.getPreviousSibling(),s=t.getNextSibling(),i=fn(o==="check"?r[3]==="x":void 0);if(P(s)&&s.getListType()===o){let l=s.getFirstChild();l!==null?l.insertBefore(i):s.append(i),t.remove()}else if(P(n)&&n.getListType()===o)n.append(i),t.remove();else{let l=mn(o,o==="number"?Number(r[2]):void 0);l.append(i),t.replace(l)}i.append(...e),i.select(0,0);let c=Nn(r[1]);c&&i.setIndent(c)},X=(o,t,e)=>{let r=[],n=o.getChildren(),s=0;for(let i of n)if(dn(i)){if(i.getChildrenSize()===1){let u=i.getFirstChild();if(P(u)){r.push(X(u,t,e+1));continue}}let c=" ".repeat(e*Kt),l=o.getListType(),a=l==="number"?`${o.getStart()+s}. `:l==="check"?`- [${i.getChecked()?"x":" "}] `:"- ";r.push(c+a+t(i)),s++}return r.join(`
|
|
7
|
+
`)},Ut={type:"element",dependencies:[xn],export:(o,t)=>{if(!hn(o))return null;let e=Number(o.getTag().slice(1));return"#".repeat(e)+" "+t(o)},regExp:it,replace:In(o=>{let t="h"+o[1].length;return gn(t)})},Wt={type:"element",dependencies:[En],export:(o,t)=>{if(!Dt(o))return null;let e=t(o).split(`
|
|
8
|
+
`),r=[];for(let n of e)r.push("> "+n);return r.join(`
|
|
9
|
+
`)},regExp:Ht,replace:(o,t,e,r)=>{if(r){let s=o.getPreviousSibling();if(Dt(s)){s.splice(s.getChildrenSize(),0,[_n(),...t]),s.select(0,0),o.remove();return}}let n=pn();n.append(...t),o.replace(n),n.select(0,0)}},Gt={type:"element",dependencies:[ct,st],export:(o,t)=>P(o)?X(o,t,0):null,regExp:vt,replace:lt("bullet")},Fn={type:"element",dependencies:[ct,st],export:(o,t)=>P(o)?X(o,t,0):null,regExp:Bt,replace:lt("check")},Xt={type:"element",dependencies:[ct,st],export:(o,t)=>P(o)?X(o,t,0):null,regExp:Pt,replace:lt("number")},zt={type:"text-format",format:["code"],tag:"`"},Yt={type:"text-format",format:["highlight"],tag:"=="},Qt={type:"text-format",format:["bold","italic"],tag:"***"},jt={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},qt={type:"text-format",format:["bold"],tag:"**"},Vt={type:"text-format",format:["bold"],intraword:!1,tag:"__"},Zt={type:"text-format",format:["strikethrough"],tag:"~~"},Jt={type:"text-format",format:["italic"],tag:"*"},te={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function ee(o,t=!1){let e=o.split(`
|
|
10
|
+
`),r=!1,n=[];for(let s=0;s<e.length;s++){let i=e[s],c=n[n.length-1];if(wn.test(i)){n.push(i);continue}if(Tn.test(i)||Sn.test(i)){r=!r,n.push(i);continue}if(r){n.push(i);continue}i===""||c===""||!c||it.test(c)||it.test(i)||Ht.test(i)||Pt.test(i)||vt.test(i)||Bt.test(i)||Rn.test(i)||Cn.test(i)||!t?n.push(i):n[n.length-1]=c+i}return n.join(`
|
|
11
|
+
`)}var yn=[Ut,Wt,Gt,Xt],bn=[],On=[zt,Qt,jt,qt,Vt,Yt,Jt,te,Zt],An=[],G=[...yn,...bn,...On,...An];function ar(o,t=G,e,r=!1,n=!1){let s=r?o:ee(o,n);return Ot(t,r)(s,e)}function ur(o=G,t,e=!1){return yt(o,e)(t)}export{R as a,so as b,tr as c,G as d,ar as e,ur as f,Ln as g,Y as h,at as i,Zn as j,be as k,Jn as l,wt as m,oo as n};
|
|
12
|
+
//# sourceMappingURL=chunk-LMCV6WAN.js.map
|