@payloadcms/richtext-lexical 3.40.0-internal.9cc3927 → 3.40.0-internal.c3af32e
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/bundled.css +1 -1
- package/dist/exports/client/index.js +1 -1
- package/dist/exports/client/index.js.map +2 -2
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +1 -0
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/package.json +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";import{a as Ce,c as To,d as ko,e as Eo}from"./chunk-3BY5IZJD.js";import{a as st}from"./chunk-DBWINSQN.js";import{a as lt,b as Ot,c as Ve}from"./chunk-FSKAVN4P.js";import{a as xe}from"./chunk-INBEEENE.js";import{a as xa}from"./chunk-F26IQ5RE.js";import{a as ae,c as Ur,d as Gr,e as Ca,f as ba,h as _a,j as Ta,k as ka}from"./chunk-DOZWITPU.js";import{a as ga,b as j}from"./chunk-BZZVLW4U.js";function Q(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{$isElementNode as Re,$isRangeSelection as $t,FORMAT_ELEMENT_COMMAND as Pt}from"lexical";import{jsx as wo,jsxs as Ea}from"react/jsx-runtime";import"react";var Wr=()=>Ea("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[wo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),wo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),wo("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as No,jsxs as wa}from"react/jsx-runtime";import"react";var Vr=()=>wa("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[No("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),No("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),No("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as So,jsxs as Na}from"react/jsx-runtime";import"react";var Ft=()=>Na("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[So("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),So("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),So("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Lo,jsxs as Sa}from"react/jsx-runtime";import"react";var Kr=()=>Sa("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Lo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Lo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Lo("path",{d:"M7.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});var y=t=>o=>{let r={clientFeatureProps:o};if(typeof t=="function")r.feature=({config:n,featureClientImportMap:i,featureClientSchemaMap:l,featureProviderMap:s,field:u,resolvedFeatures:c,schemaPath:d,unSanitizedEditorConfig:a})=>{let p=t({config:n,featureClientImportMap:i,featureClientSchemaMap:l,featureProviderMap:s,field:u,props:o,resolvedFeatures:c,schemaPath:d,unSanitizedEditorConfig:a});return p.sanitizedClientFeatureProps===null&&(p.sanitizedClientFeatureProps=o),p};else{let n={...t};n.sanitizedClientFeatureProps=o,r.feature=n}return r};var Jr=t=>({type:"dropdown",ChildComponent:Ft,items:t,key:"align",order:30});var Xr=[Jr([{ChildComponent:Ft,isActive:({selection:t})=>{if(!$t(t))return!1;for(let e of t.getNodes()){if(Re(e)&&e.getFormatType()==="left")continue;let o=e.getParent();if(!(Re(o)&&o.getFormatType()==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Pt,"left")},order:1},{ChildComponent:Wr,isActive:({selection:t})=>{if(!$t(t))return!1;for(let e of t.getNodes()){if(Re(e)&&e.getFormatType()==="center")continue;let o=e.getParent();if(!(Re(o)&&o.getFormatType()==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Pt,"center")},order:2},{ChildComponent:Kr,isActive:({selection:t})=>{if(!$t(t))return!1;for(let e of t.getNodes()){if(Re(e)&&e.getFormatType()==="right")continue;let o=e.getParent();if(!(Re(o)&&o.getFormatType()==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Pt,"right")},order:3},{ChildComponent:Vr,isActive:({selection:t})=>{if(!$t(t))return!1;for(let e of t.getNodes()){if(Re(e)&&e.getFormatType()==="justify")continue;let o=e.getParent();if(!(Re(o)&&o.getFormatType()==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Pt,"justify")},order:4}])],La=y({toolbarFixed:{groups:Xr},toolbarInline:{groups:Xr}});import{$createQuoteNode as tn,$isQuoteNode as Qr,QuoteNode as Ra}from"@lexical/rich-text";import{$setBlocksType as on}from"@lexical/selection";import{$getSelection as rn,$isRangeSelection as va}from"lexical";import{jsx as zr}from"react/jsx-runtime";import"react";var yo=()=>zr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:zr("path",{d:"M13.5353 10.5725C13.5353 9.47709 11.0456 9.99991 11.0456 7.85883C11.0456 6.46464 12.1162 5.61816 13.361 5.61816C14.805 5.61816 16 6.86298 16 8.92937C16 11.2945 14.4564 13.7841 11.1203 14.3816L10.8216 13.1368C12.888 12.4895 13.5353 11.4937 13.5353 10.5725ZM6.71369 10.5725C6.71369 9.47709 4.22407 9.99991 4.22407 7.85883C4.22407 6.46464 5.29461 5.61816 6.53942 5.61816C7.9834 5.61816 9.17842 6.86298 9.17842 8.92937C9.17842 11.2945 7.63485 13.7841 4.29876 14.3816L4 13.1368C6.06639 12.4895 6.71369 11.4937 6.71369 10.5725Z",fill:"currentColor"})});import{jsx as Zr}from"react/jsx-runtime";import"react";var at=()=>Zr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Zr("path",{d:"M11.708 14.5H7.79785V13.9414H8.01367C9.00391 13.9414 9.15625 13.9033 9.15625 13.6113V6.70508H8.07715C6.82031 6.70508 6.73145 7.08594 6.28711 8.67285H5.80469L5.91895 6.12109H13.5869L13.7012 8.67285H13.2188C12.7744 7.08594 12.6855 6.70508 11.4287 6.70508H10.3496V13.6113C10.3496 13.9033 10.502 13.9414 11.4922 13.9414H11.708V14.5Z",fill:"currentColor"})});var ne=t=>({type:"dropdown",ChildComponent:at,items:t,key:"text",order:25});import{$createQuoteNode as ya,$isQuoteNode as Yr,QuoteNode as Ia}from"@lexical/rich-text";var qr={type:"element",dependencies:[Ia],export:(t,e)=>{if(!Yr(t))return null;let o=e(t).split(`
|
|
2
2
|
`),r=[];for(let n of o)r.push("> "+n);return r.join(`
|
|
3
|
-
`)},regExp:/^>\s/,replace:(t,e,o,r)=>{if(r){let i=t.getPreviousSibling();if(Yr(i)){i.splice(i.getChildrenSize(),0,[...e]),i.select(0,0),t.remove();return}}let n=ya();n.append(...e),t.replace(n),n.select(0,0)}};var en=[ne([{ChildComponent:yo,isActive:({selection:t})=>{if(!va(t))return!1;for(let e of t.getNodes())if(!Qr(e)&&!Qr(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=rn();on(e,()=>tn())})},order:20}])],Ma=y({markdownTransformers:[qr],nodes:[Ra],slashMenu:{groups:[Q([{Icon:yo,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=rn();on(e,()=>tn())})}}])]},toolbarFixed:{groups:en},toolbarInline:{groups:en}});import{getTranslation as Kt}from"@payloadcms/translations";import{jsx as Io,jsxs as Aa}from"react/jsx-runtime";import"react";var Bt=()=>Aa("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Io("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),Io("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),Io("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as nn}from"react/jsx-runtime";import"react";var Ht=()=>nn("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:nn("path",{clipRule:"evenodd",d:"M5.33333 6.5C5.11232 6.5 4.90036 6.5878 4.74408 6.74408C4.5878 6.90036 4.5 7.11232 4.5 7.33333V12.1667C4.5 12.3877 4.5878 12.5996 4.74408 12.7559C4.90036 12.9122 5.11232 13 5.33333 13H14.6667C14.8877 13 15.0996 12.9122 15.2559 12.7559C15.4122 12.5996 15.5 12.3877 15.5 12.1667V11.6667C15.5 11.3905 15.7239 11.1667 16 11.1667C16.2761 11.1667 16.5 11.3905 16.5 11.6667V12.1667C16.5 12.6529 16.3068 13.1192 15.963 13.463C15.6192 13.8068 15.1529 14 14.6667 14H5.33333C4.8471 14 4.38079 13.8068 4.03697 13.463C3.69315 13.1192 3.5 12.6529 3.5 12.1667V7.33333C3.5 6.8471 3.69315 6.38079 4.03697 6.03697C4.38079 5.69315 4.8471 5.5 5.33333 5.5H10.3333C10.6095 5.5 10.8333 5.72386 10.8333 6C10.8333 6.27614 10.6095 6.5 10.3333 6.5H5.33333ZM13 6.5C12.7239 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.7239 5.5 13 5.5H16C16.2761 5.5 16.5 5.72386 16.5 6V9C16.5 9.27614 16.2761 9.5 16 9.5C15.7239 9.5 15.5 9.27614 15.5 9V7.20711L13.3536 9.35355C13.1583 9.54882 12.8417 9.54882 12.6464 9.35355C12.4512 9.15829 12.4512 8.84171 12.6464 8.64645L14.7929 6.5H13ZM6.16699 8.33325C6.16699 8.05711 6.39085 7.83325 6.66699 7.83325H11.0003C11.2765 7.83325 11.5003 8.05711 11.5003 8.33325C11.5003 8.60939 11.2765 8.83325 11.0003 8.83325H6.66699C6.39085 8.83325 6.16699 8.60939 6.16699 8.33325ZM6.16699 10.9999C6.16699 10.7238 6.39085 10.4999 6.66699 10.4999H13.3337C13.6098 10.4999 13.8337 10.7238 13.8337 10.9999C13.8337 11.2761 13.6098 11.4999 13.3337 11.4999H6.66699C6.39085 11.4999 6.16699 11.2761 6.16699 10.9999Z",fill:"currentColor",fillRule:"evenodd"})});import{jsx as Da}from"react/jsx-runtime";import"react";function jt(t,e){return t?()=>Da("img",{alt:e??"Block Image",className:"lexical-block-custom-image",src:t,style:{maxHeight:20,maxWidth:20}}):Bt}import{jsx as uc}from"react/jsx-runtime";import dc from"bson-objectid";import"react";import{DecoratorBlockNode as Oa}from"@lexical/react/LexicalDecoratorBlockNode.js";import Fa from"bson-objectid";var ct=class extends Oa{__cacheBuster;__fields;constructor({cacheBuster:e,fields:o,format:r,key:n}){super(r,n),this.__fields=o,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,format:e.__format,key:e.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=$a(e.fields);return o.setFormat(e.format),o}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div"),o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e,o){let r=this.getWritable();r.__fields=e,o||r.__cacheBuster++}};function $a(t){return new ct({fields:{...t,id:t?.id||new Fa.default().toHexString()}})}import{jsx as z,jsxs as ut,Fragment as Wa}from"react/jsx-runtime";import{Button as cn,Collapsible as Va,Drawer as Ka,EditDepthProvider as Ja,ErrorPill as Xa,Form as za,formatDrawerSlug as Za,FormSubmit as Ya,Pill as qa,RenderFields as Qa,SectionTitle as ec,useConfig as tc,useDocumentForm as oc,useDocumentInfo as un,useEditDepth as rc,useFormSubmitted as nc,useServerFunctions as ic,useTranslation as lc}from"@payloadcms/ui";import{abortAndIgnore as Ro}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as Gt,reduceFieldsToValues as dn}from"payload/shared";import dt,{useCallback as vo,useEffect as Mo,useMemo as mt,useRef as Ao}from"react";import{useLexicalComposerContext as sc}from"@lexical/react/LexicalComposerContext";import{getTranslation as ac}from"@payloadcms/translations";import{$getNodeByKey as Wt}from"lexical";import{v4 as cc}from"uuid";import{c as Pa}from"react/compiler-runtime";import{jsx as Ut,jsxs as Ba}from"react/jsx-runtime";import{RenderFields as Ha,useFormSubmitted as ja}from"@payloadcms/ui";import Ua,{createContext as Ga}from"react";var ln=Ga({initialState:!1}),Oe=()=>Ua.use(ln),sn=t=>{let e=Pa(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:s,initialState:u,nodeKey:c,RemoveButton:d}=t,p=ja()&&l>0,m,f;e[0]!==r||e[1]!==l||e[2]!==p?(f=_=>Ut(r,{editButton:_.editButton,errorCount:l,fieldHasErrors:p,Label:_.Label,removeButton:_.removeButton,children:_.children}),e[0]=r,e[1]=l,e[2]=p,e[3]=f):f=e[3],m=f;let h=m,x;return e[4]!==o||e[5]!==h||e[6]!==n||e[7]!==i||e[8]!==d||e[9]!==s||e[10]!==u||e[11]!==c?(x=n?Ba(ln,{value:{BlockCollapsible:h,EditButton:i,initialState:u,nodeKey:c,RemoveButton:d},children:[n,Ut(o,{})]}):Ut(h,{children:Ut(Ha,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=o,e[5]=h,e[6]=n,e[7]=i,e[8]=d,e[9]=s,e[10]=u,e[11]=c,e[12]=x):x=e[12],x};function an({fields:t}){for(let e in t){let o=t[e];Array.isArray(o?.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var ue="lexical-block",mn=t=>{let{cacheBuster:e,formData:o,nodeKey:r}=t,n=nc(),{id:i,collectionSlug:l,globalSlug:s}=un(),{fieldProps:{featureClientSchemaMap:u,field:c,initialLexicalFormState:d,permissions:a,readOnly:p,schemaPath:m},uuid:f}=j(),{fields:h}=oc(),x=Ao(new AbortController),_=rc(),[I,A]=dt.useState(0),{config:b}=tc(),T=Za({slug:`lexical-blocks-create-${f}-${o.id}`,depth:_}),{toggleDrawer:g}=xe(T),{getDocPreferences:E,setDocFieldPreferences:M}=un(),[D]=sc(),{getFormState:P}=ic(),v=`${m}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}.fields`,[N,C]=dt.useState(()=>d?.[o.id]?.formState?{...d?.[o.id]?.formState,blockName:{initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName}}:!1),w=Ao(!1),L=Ao(e);Mo(()=>{w.current?(L.current!==e&&C(!1),L.current=e):w.current=!0},[e]);let[S,R]=dt.useState(N?._components?.customComponents?.BlockLabel),[k,F]=dt.useState(N?._components?.customComponents?.Block);Mo(()=>{let G=new AbortController;return o&&!N&&(async()=>{let{state:J}=await P({id:i,collectionSlug:l,data:o,docPermissions:{fields:!0},docPreferences:await E(),documentFormState:Gt(h),globalSlug:s,initialBlockData:o,operation:"update",renderAllFields:!0,schemaPath:v,signal:G.signal});if(J){J.blockName={initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName};let q=dn(Gt(J),!0);D.update(()=>{let X=Wt(r);if(X&&pt(X)){let se=q;se.blockType=o.blockType,X.setFields(se,!0)}}),C(J),R(J._components?.customComponents?.BlockLabel),F(J._components?.customComponents?.Block)}})(),()=>{Ro(G)}},[P,v,i,o,D,r,N,l,s,E,h]);let[$,U]=dt.useState(d?.[o.id]?.collapsed??!1),V=`${m}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}`,H=u.blocks?.[V]?.[0],W=H.blockReferences?typeof H?.blockReferences?.[0]=="string"?b.blocksMap[H?.blockReferences?.[0]]:H?.blockReferences?.[0]:H?.blocks?.[0],{i18n:te,t:ce}=lc(),Y=vo(async({formState:G,submit:fe})=>{Ro(x.current);let J=new AbortController;x.current=J;let{state:q}=await P({id:i,collectionSlug:l,docPermissions:{fields:!0},docPreferences:await E(),documentFormState:Gt(h),formState:G,globalSlug:s,initialBlockFormState:G,operation:"update",renderAllFields:!!fe,schemaPath:v,signal:J.signal});if(!q)return G;G.blockName&&(q.blockName=G.blockName);let X=dn(an({fields:Gt(q)}),!0);if(setTimeout(()=>{D.update(()=>{let se=Wt(r);if(se&&pt(se)){let We=X;We.blockType=o.blockType,se.setFields(We,!0)}})},0),fe){R(q._components?.customComponents?.BlockLabel),F(q._components?.customComponents?.Block);let se=0;for(let We of Object.values(q))We?.valid===!1&&se++;A(se)}return q},[P,i,l,E,s,v,o.blockType,h,D,r]);Mo(()=>()=>{Ro(x.current)},[]);let K=vo(()=>{D.update(()=>{Wt(r)?.remove()})},[D,r]),oe=W?.labels?.singular?ac(W.labels.singular,te):W?.slug,re=vo(G=>{E().then(fe=>{let q=fe?.fields?.[c.name]?.collapsed,X=q&&q?.length?q:[];G?X.includes(o.id)||X.push(o.id):X.includes(o.id)&&X.splice(X.indexOf(o.id),1),M(c.name,{collapsed:X,hello:"hi"})})},[E,c.name,M,o.id]),le=mt(()=>()=>z(cn,{buttonStyle:"icon-label",className:`${ue}__editButton`,disabled:p,el:"button",icon:"edit",onClick:G=>(G.preventDefault(),G.stopPropagation(),g(),!1),onMouseDown:G=>{G.preventDefault()},round:!0,size:"small",tooltip:ce("lexical:blocks:inlineBlocks:edit",{label:oe})}),[oe,p,ce,g]),De=mt(()=>()=>z(cn,{buttonStyle:"icon-label",className:`${ue}__removeButton`,disabled:c?.admin?.readOnly||!1,icon:"x",onClick:G=>{G.preventDefault(),K()},round:!0,tooltip:"Remove Block"}),[c?.admin?.readOnly,K]),it=mt(()=>({children:G,disableBlockName:fe,editButton:J,errorCount:q,fieldHasErrors:X,Label:se,removeButton:We})=>z("div",{className:ue+" "+ue+"-"+o.blockType,children:z(Va,{className:[`${ue}__row`,X?`${ue}__row--has-errors`:`${ue}__row--no-errors`].join(" "),collapsibleStyle:X?"error":"default",header:ut("div",{className:`${ue}__block-header`,children:[se??S?se??S:ut("div",{children:[z(qa,{className:`${ue}__block-pill ${ue}__block-pill-${o?.blockType}`,pillStyle:"white",children:oe??o?.blockType}),!fe&&z(ec,{path:"blockName",readOnly:c?.admin?.readOnly||!1}),X&&z(Xa,{count:q??0,i18n:te,withMessage:!0})]}),ut("div",{children:[k&&J!==!1||!k&&J?z(le,{}):null,We!==!1&&D.isEditable()?z(De,{}):null]})]}),isCollapsed:$,onToggle:jr=>{re(jr),U(jr)},children:G},0)}),[k,S,le,De,oe,D,o.blockType,te,$,re,c?.admin?.readOnly]),Dt=W?.fields??[],Hr=mt(()=>()=>z(Ja,{children:z(Ka,{className:"",slug:T,title:ce(`lexical:blocks:inlineBlocks:${o?.id?"edit":"create"}`,{label:oe??ce("lexical:blocks:inlineBlocks:label")}),children:N?ut(Wa,{children:[z(Qa,{fields:Dt,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:v,permissions:!0,readOnly:!1}),z(Ya,{programmaticSubmit:!0,children:ce("fields:saveChanges")})]}):null})}),[N,T,oe,ce,W?.fields,v,a]),ha=mt(()=>N?z(za,{beforeSubmit:[async({formState:G})=>await Y({formState:G,submit:!0})],el:"div",fields:Dt,initialState:N,onChange:[Y],onSubmit:(G,fe)=>{fe.blockType=o.blockType,D.update(()=>{let J=Wt(r);J&&pt(J)&&J.setFields(fe,!0)}),g()},submitted:n,uuid:cc(),children:z(sn,{baseClass:ue,BlockDrawer:Hr,Collapsible:it,CustomBlock:k,EditButton:le,errorCount:I,formSchema:Dt,initialState:N,nodeKey:r,RemoveButton:De})}):null,[it,Hr,k,Dt,De,le,D,I,g,W?.fields,N,r,Y,n]);return W?ha:z(it,{disableBlockName:!0,fieldHasErrors:!0,children:ut("div",{className:"lexical-block-not-found",children:["Error: Block '",o.blockType,"' not found in the config but exists in the lexical data"]})})};var be=class extends ct{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=Vt(e.fields);return o.setFormat(e.format),o}decorate(e,o){return uc(mn,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Vt(t){return new be({fields:{...t,id:t?.id||new dc.default().toHexString()}})}function pt(t){return t instanceof be}import{createCommand as pn}from"lexical";var Ke=pn("INSERT_BLOCK_COMMAND"),Je=pn("INSERT_INLINE_BLOCK_COMMAND");import{c as mc}from"react/compiler-runtime";import{useLexicalComposerContext as pc}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as fc,$wrapNodeInElement as hc,mergeRegister as gc}from"@lexical/utils";import{formatDrawerSlug as xc,useEditDepth as Cc}from"@payloadcms/ui";import{$createParagraphNode as bc,$getNodeByKey as _c,$getPreviousSelection as Tc,$getSelection as kc,$insertNodes as Ec,$isParagraphNode as wc,$isRangeSelection as Nc,$isRootOrShadowRoot as Sc,COMMAND_PRIORITY_EDITOR as fn}from"lexical";import{useEffect as Lc,useState as yc}from"react";var hn=()=>{let t=mc(12),[e]=pc(),[o,r]=yc(null),{setCreatedInlineBlock:n,uuid:i}=j(),l=Cc(),s="lexical-inlineBlocks-create-"+i,u;t[0]!==l||t[1]!==s?(u=xc({slug:s,depth:l}),t[0]=l,t[1]=s,t[2]=u):u=t[2];let c=u,{toggleDrawer:d}=xe(c,!0),a;t[3]!==e||t[4]!==n||t[5]!==o?(a=()=>{if(!e.hasNodes([be]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return gc(e.registerCommand(Ke,m=>(e.update(()=>{let f=kc()||Tc();if(Nc(f)){let h=Vt(m),{focus:x}=f,_=x.getNode();fc(h),wc(_)&&!_.__first&&_.remove()}}),!0),fn),e.registerCommand(Je,m=>{if(o){let h=_c(o);return!h||!Eo(h)?!1:(h.setFields(m),r(null),!0)}let f=ko(m);return n?.(f),Ec([f]),Sc(f.getParentOrThrow())&&hc(f,bc).selectEnd(),!0},fn))},t[3]=e,t[4]=n,t[5]=o,t[6]=a):a=t[6];let p;return t[7]!==e||t[8]!==n||t[9]!==o||t[10]!==d?(p=[e,n,o,d],t[7]=e,t[8]=n,t[9]=o,t[10]=d,t[11]=p):p=t[11],Lc(a,p),null};var Ic=y(({config:t,featureClientSchemaMap:e,props:o,schemaPath:r})=>{let n=`${r}.lexical_internal_feature.blocks.lexical_blocks`,i=`${r}.lexical_internal_feature.blocks.lexical_inline_blocks`,l=e.blocks;if(!l)return{};let s=Object.entries(l).filter(([a])=>a.startsWith(n+".")&&!a.replace(n+".","").includes(".")).map(([,a])=>a[0]),u=Object.entries(l).filter(([a])=>a.startsWith(i+".")&&!a.replace(i+".","").includes(".")).map(([,a])=>a[0]),c=s.map(a=>a.blockReferences?typeof a.blockReferences[0]=="string"?t.blocksMap[a.blockReferences[0]]:a.blockReferences[0]:a.blocks[0]).filter(a=>a!==void 0),d=u.map(a=>a.blockReferences?typeof a.blockReferences[0]=="string"?t.blocksMap[a.blockReferences[0]]:a.blockReferences[0]:a.blocks[0]).filter(a=>a!==void 0);return{nodes:[be,To],plugins:[{Component:hn,position:"normal"}],sanitizedClientFeatureProps:o,slashMenu:{groups:[c?.length?{items:c.map(a=>({Icon:jt(a.imageURL,a.imageAltText),key:"block-"+a.slug,keywords:["block","blocks",a.slug],label:({i18n:p})=>a?.labels?.singular?Kt(a.labels.singular,p):a?.slug,onSelect:({editor:p})=>{p.dispatchCommand(Ke,{blockName:"",blockType:a.slug})}})),key:"blocks",label:({i18n:a})=>a.t("lexical:blocks:label")}:null,d?.length?{items:d.map(a=>({Icon:Ht,key:"inlineBlocks-"+a.slug,keywords:["inlineBlock","inline block",a.slug],label:({i18n:p})=>a?.labels?.singular?Kt(a.labels.singular,p):a?.slug,onSelect:({editor:p})=>{p.dispatchCommand(Je,{blockName:"",blockType:a.slug})}})),key:"inlineBlocks",label:({i18n:a})=>a.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[c.length?{type:"dropdown",ChildComponent:Bt,items:c.map((a,p)=>({ChildComponent:jt(a.imageURL,a.imageAltText),isActive:void 0,key:"block-"+a.slug,label:({i18n:m})=>a?.labels?.singular?Kt(a.labels.singular,m):a?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Ke,{blockName:"",blockType:a.slug})},order:p})),key:"blocks",order:20}:null,d?.length?{type:"dropdown",ChildComponent:Ht,items:d.map((a,p)=>({ChildComponent:a.imageURL?jt(a.imageURL,a.imageAltText):Ht,isActive:void 0,key:"inlineBlock-"+a.slug,label:({i18n:m})=>a?.labels?.singular?Kt(a.labels.singular,m):a?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Je,{blockName:"",blockType:a.slug})},order:p})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as Mc}from"react/compiler-runtime";import{jsx as $e,jsxs as $o}from"react/jsx-runtime";import{useLexicalComposerContext as Ac}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Dc,$createTextNode as Oc,$getRoot as Fc,getDOMSelection as Do}from"lexical";import*as _n from"react";import{useCallback as Fe,useEffect as Oo,useLayoutEffect as xn,useRef as Fo,useState as Jt}from"react";var Rc=ae&&"documentMode"in document?document.documentMode:null,gn=ae&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Xb=ae&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),zb=ae&&"InputEvent"in window&&!Rc?"getTargetRanges"in new window.InputEvent("input"):!1,Zb=ae&&/Version\/[\d.].*Safari/.test(navigator.userAgent),Yb=ae&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,qb=ae&&/Android/.test(navigator.userAgent),Qb=ae&&/Win/.test(navigator.platform),vc=ae&&/^(?=.*Chrome).*/i.test(navigator.userAgent),e0=ae&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!vc;var $c=t=>{let e=document.createElement("textarea");e.value=t||"",e.style.position="absolute",e.style.opacity="0",document.body?.appendChild(e),e.focus(),e.select();try{let o=document.execCommand("copy");console.log(o)}catch(o){console.error(o)}document.body?.removeChild(e)},Pc=(t,e)=>{let o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e||"")),o.setAttribute("download",t),o.style.display="none",document.body?.appendChild(o),o.click(),document.body?.removeChild(o)},Bc=t=>{let o=((r,n)=>{switch(r){case"click":return` await page.mouse.click(${n.x}, ${n.y});`;case"keydown":return` await page.keyboard.keydown('${n}');`;case"keyup":return` await page.keyboard.keyup('${n}');`;case"press":return` await page.keyboard.press('${n}');`;case"selectAll":return" await selectAll(page);";case"snapshot":return` await assertHTMLSnapshot(page);
|
|
3
|
+
`)},regExp:/^>\s/,replace:(t,e,o,r)=>{if(r){let i=t.getPreviousSibling();if(Yr(i)){i.splice(i.getChildrenSize(),0,[...e]),i.select(0,0),t.remove();return}}let n=ya();n.append(...e),t.replace(n),n.select(0,0)}};var en=[ne([{ChildComponent:yo,isActive:({selection:t})=>{if(!va(t))return!1;for(let e of t.getNodes())if(!Qr(e)&&!Qr(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=rn();on(e,()=>tn())})},order:20}])],Ma=y({markdownTransformers:[qr],nodes:[Ra],slashMenu:{groups:[Q([{Icon:yo,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=rn();on(e,()=>tn())})}}])]},toolbarFixed:{groups:en},toolbarInline:{groups:en}});import{getTranslation as Kt}from"@payloadcms/translations";import{jsx as Io,jsxs as Aa}from"react/jsx-runtime";import"react";var Bt=()=>Aa("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Io("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),Io("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),Io("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as nn}from"react/jsx-runtime";import"react";var Ht=()=>nn("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:nn("path",{clipRule:"evenodd",d:"M5.33333 6.5C5.11232 6.5 4.90036 6.5878 4.74408 6.74408C4.5878 6.90036 4.5 7.11232 4.5 7.33333V12.1667C4.5 12.3877 4.5878 12.5996 4.74408 12.7559C4.90036 12.9122 5.11232 13 5.33333 13H14.6667C14.8877 13 15.0996 12.9122 15.2559 12.7559C15.4122 12.5996 15.5 12.3877 15.5 12.1667V11.6667C15.5 11.3905 15.7239 11.1667 16 11.1667C16.2761 11.1667 16.5 11.3905 16.5 11.6667V12.1667C16.5 12.6529 16.3068 13.1192 15.963 13.463C15.6192 13.8068 15.1529 14 14.6667 14H5.33333C4.8471 14 4.38079 13.8068 4.03697 13.463C3.69315 13.1192 3.5 12.6529 3.5 12.1667V7.33333C3.5 6.8471 3.69315 6.38079 4.03697 6.03697C4.38079 5.69315 4.8471 5.5 5.33333 5.5H10.3333C10.6095 5.5 10.8333 5.72386 10.8333 6C10.8333 6.27614 10.6095 6.5 10.3333 6.5H5.33333ZM13 6.5C12.7239 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.7239 5.5 13 5.5H16C16.2761 5.5 16.5 5.72386 16.5 6V9C16.5 9.27614 16.2761 9.5 16 9.5C15.7239 9.5 15.5 9.27614 15.5 9V7.20711L13.3536 9.35355C13.1583 9.54882 12.8417 9.54882 12.6464 9.35355C12.4512 9.15829 12.4512 8.84171 12.6464 8.64645L14.7929 6.5H13ZM6.16699 8.33325C6.16699 8.05711 6.39085 7.83325 6.66699 7.83325H11.0003C11.2765 7.83325 11.5003 8.05711 11.5003 8.33325C11.5003 8.60939 11.2765 8.83325 11.0003 8.83325H6.66699C6.39085 8.83325 6.16699 8.60939 6.16699 8.33325ZM6.16699 10.9999C6.16699 10.7238 6.39085 10.4999 6.66699 10.4999H13.3337C13.6098 10.4999 13.8337 10.7238 13.8337 10.9999C13.8337 11.2761 13.6098 11.4999 13.3337 11.4999H6.66699C6.39085 11.4999 6.16699 11.2761 6.16699 10.9999Z",fill:"currentColor",fillRule:"evenodd"})});import{jsx as Da}from"react/jsx-runtime";import"react";function jt(t,e){return t?()=>Da("img",{alt:e??"Block Image",className:"lexical-block-custom-image",src:t,style:{maxHeight:20,maxWidth:20}}):Bt}import{jsx as uc}from"react/jsx-runtime";import dc from"bson-objectid";import"react";import{DecoratorBlockNode as Oa}from"@lexical/react/LexicalDecoratorBlockNode.js";import Fa from"bson-objectid";var ct=class extends Oa{__cacheBuster;__fields;constructor({cacheBuster:e,fields:o,format:r,key:n}){super(r,n),this.__fields=o,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,format:e.__format,key:e.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=$a(e.fields);return o.setFormat(e.format),o}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div"),o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e,o){let r=this.getWritable();r.__fields=e,o||r.__cacheBuster++}};function $a(t){return new ct({fields:{...t,id:t?.id||new Fa.default().toHexString()}})}import{jsx as z,jsxs as ut,Fragment as Wa}from"react/jsx-runtime";import{Button as cn,Collapsible as Va,Drawer as Ka,EditDepthProvider as Ja,ErrorPill as Xa,Form as za,formatDrawerSlug as Za,FormSubmit as Ya,Pill as qa,RenderFields as Qa,SectionTitle as ec,useConfig as tc,useDocumentForm as oc,useDocumentInfo as un,useEditDepth as rc,useFormSubmitted as nc,useServerFunctions as ic,useTranslation as lc}from"@payloadcms/ui";import{abortAndIgnore as Ro}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as Gt,reduceFieldsToValues as dn}from"payload/shared";import dt,{useCallback as vo,useEffect as Mo,useMemo as mt,useRef as Ao}from"react";import{useLexicalComposerContext as sc}from"@lexical/react/LexicalComposerContext";import{getTranslation as ac}from"@payloadcms/translations";import{$getNodeByKey as Wt}from"lexical";import{v4 as cc}from"uuid";import{c as Pa}from"react/compiler-runtime";import{jsx as Ut,jsxs as Ba}from"react/jsx-runtime";import{RenderFields as Ha,useFormSubmitted as ja}from"@payloadcms/ui";import Ua,{createContext as Ga}from"react";var ln=Ga({initialState:!1}),Oe=()=>Ua.use(ln),sn=t=>{let e=Pa(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:s,initialState:u,nodeKey:c,RemoveButton:d}=t,p=ja()&&l>0,m,f;e[0]!==r||e[1]!==l||e[2]!==p?(f=_=>Ut(r,{editButton:_.editButton,errorCount:l,fieldHasErrors:p,Label:_.Label,removeButton:_.removeButton,children:_.children}),e[0]=r,e[1]=l,e[2]=p,e[3]=f):f=e[3],m=f;let h=m,x;return e[4]!==o||e[5]!==h||e[6]!==n||e[7]!==i||e[8]!==d||e[9]!==s||e[10]!==u||e[11]!==c?(x=n?Ba(ln,{value:{BlockCollapsible:h,EditButton:i,initialState:u,nodeKey:c,RemoveButton:d},children:[n,Ut(o,{})]}):Ut(h,{children:Ut(Ha,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=o,e[5]=h,e[6]=n,e[7]=i,e[8]=d,e[9]=s,e[10]=u,e[11]=c,e[12]=x):x=e[12],x};function an({fields:t}){for(let e in t){let o=t[e];Array.isArray(o?.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var ue="lexical-block",mn=t=>{let{cacheBuster:e,formData:o,nodeKey:r}=t,n=nc(),{id:i,collectionSlug:l,globalSlug:s}=un(),{fieldProps:{featureClientSchemaMap:u,field:c,initialLexicalFormState:d,permissions:a,readOnly:p,schemaPath:m},uuid:f}=j(),{fields:h}=oc(),x=Ao(new AbortController),_=rc(),[I,A]=dt.useState(0),{config:b}=tc(),T=Za({slug:`lexical-blocks-create-${f}-${o.id}`,depth:_}),{toggleDrawer:g}=xe(T),{getDocPreferences:E,setDocFieldPreferences:M}=un(),[D]=sc(),{getFormState:P}=ic(),v=`${m}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}.fields`,[N,C]=dt.useState(()=>d?.[o.id]?.formState?{...d?.[o.id]?.formState,blockName:{initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName}}:!1),w=Ao(!1),L=Ao(e);Mo(()=>{w.current?(L.current!==e&&C(!1),L.current=e):w.current=!0},[e]);let[S,R]=dt.useState(N?._components?.customComponents?.BlockLabel),[k,F]=dt.useState(N?._components?.customComponents?.Block);Mo(()=>{let G=new AbortController;return o&&!N&&(async()=>{let{state:J}=await P({id:i,collectionSlug:l,data:o,docPermissions:{fields:!0},docPreferences:await E(),documentFormState:Gt(h),globalSlug:s,initialBlockData:o,operation:"update",renderAllFields:!0,schemaPath:v,signal:G.signal});if(J){J.blockName={initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName};let q=dn(Gt(J),!0);D.update(()=>{let X=Wt(r);if(X&&pt(X)){let se=q;se.blockType=o.blockType,X.setFields(se,!0)}}),C(J),R(J._components?.customComponents?.BlockLabel),F(J._components?.customComponents?.Block)}})(),()=>{Ro(G)}},[P,v,i,o,D,r,N,l,s,E,h]);let[$,U]=dt.useState(d?.[o.id]?.collapsed??!1),V=`${m}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}`,H=u.blocks?.[V]?.[0],W=H.blockReferences?typeof H?.blockReferences?.[0]=="string"?b.blocksMap[H?.blockReferences?.[0]]:H?.blockReferences?.[0]:H?.blocks?.[0],{i18n:te,t:ce}=lc(),Y=vo(async({formState:G,submit:fe})=>{Ro(x.current);let J=new AbortController;x.current=J;let{state:q}=await P({id:i,collectionSlug:l,docPermissions:{fields:!0},docPreferences:await E(),documentFormState:Gt(h),formState:G,globalSlug:s,initialBlockFormState:G,operation:"update",renderAllFields:!!fe,schemaPath:v,signal:J.signal});if(!q)return G;G.blockName&&(q.blockName=G.blockName);let X=dn(an({fields:Gt(q)}),!0);if(setTimeout(()=>{D.update(()=>{let se=Wt(r);if(se&&pt(se)){let We=X;We.blockType=o.blockType,se.setFields(We,!0)}})},0),fe){R(q._components?.customComponents?.BlockLabel),F(q._components?.customComponents?.Block);let se=0;for(let We of Object.values(q))We?.valid===!1&&se++;A(se)}return q},[P,i,l,E,s,v,o.blockType,h,D,r]);Mo(()=>()=>{Ro(x.current)},[]);let K=vo(()=>{D.update(()=>{Wt(r)?.remove()})},[D,r]),oe=W?.labels?.singular?ac(W.labels.singular,te):W?.slug,re=vo(G=>{E().then(fe=>{let q=fe?.fields?.[c.name]?.collapsed,X=q&&q?.length?q:[];G?X.includes(o.id)||X.push(o.id):X.includes(o.id)&&X.splice(X.indexOf(o.id),1),M(c.name,{collapsed:X,hello:"hi"})})},[E,c.name,M,o.id]),le=mt(()=>()=>z(cn,{buttonStyle:"icon-label",className:`${ue}__editButton`,disabled:p,el:"button",icon:"edit",onClick:G=>(G.preventDefault(),G.stopPropagation(),g(),!1),onMouseDown:G=>{G.preventDefault()},round:!0,size:"small",tooltip:ce("lexical:blocks:inlineBlocks:edit",{label:oe})}),[oe,p,ce,g]),De=mt(()=>()=>z(cn,{buttonStyle:"icon-label",className:`${ue}__removeButton`,disabled:c?.admin?.readOnly||!1,icon:"x",onClick:G=>{G.preventDefault(),K()},round:!0,tooltip:"Remove Block"}),[c?.admin?.readOnly,K]),it=mt(()=>({children:G,disableBlockName:fe,editButton:J,errorCount:q,fieldHasErrors:X,Label:se,removeButton:We})=>z("div",{className:ue+" "+ue+"-"+o.blockType,children:z(Va,{className:[`${ue}__row`,X?`${ue}__row--has-errors`:`${ue}__row--no-errors`].join(" "),collapsibleStyle:X?"error":"default",header:ut("div",{className:`${ue}__block-header`,children:[se??S?se??S:ut("div",{children:[z(qa,{className:`${ue}__block-pill ${ue}__block-pill-${o?.blockType}`,pillStyle:"white",size:"small",children:oe??o?.blockType}),!fe&&z(ec,{path:"blockName",readOnly:c?.admin?.readOnly||!1}),X&&z(Xa,{count:q??0,i18n:te,withMessage:!0})]}),ut("div",{children:[k&&J!==!1||!k&&J?z(le,{}):null,We!==!1&&D.isEditable()?z(De,{}):null]})]}),isCollapsed:$,onToggle:jr=>{re(jr),U(jr)},children:G},0)}),[k,S,le,De,oe,D,o.blockType,te,$,re,c?.admin?.readOnly]),Dt=W?.fields??[],Hr=mt(()=>()=>z(Ja,{children:z(Ka,{className:"",slug:T,title:ce(`lexical:blocks:inlineBlocks:${o?.id?"edit":"create"}`,{label:oe??ce("lexical:blocks:inlineBlocks:label")}),children:N?ut(Wa,{children:[z(Qa,{fields:Dt,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:v,permissions:!0,readOnly:!1}),z(Ya,{programmaticSubmit:!0,children:ce("fields:saveChanges")})]}):null})}),[N,T,oe,ce,W?.fields,v,a]),ha=mt(()=>N?z(za,{beforeSubmit:[async({formState:G})=>await Y({formState:G,submit:!0})],el:"div",fields:Dt,initialState:N,onChange:[Y],onSubmit:(G,fe)=>{fe.blockType=o.blockType,D.update(()=>{let J=Wt(r);J&&pt(J)&&J.setFields(fe,!0)}),g()},submitted:n,uuid:cc(),children:z(sn,{baseClass:ue,BlockDrawer:Hr,Collapsible:it,CustomBlock:k,EditButton:le,errorCount:I,formSchema:Dt,initialState:N,nodeKey:r,RemoveButton:De})}):null,[it,Hr,k,Dt,De,le,D,I,g,W?.fields,N,r,Y,n]);return W?ha:z(it,{disableBlockName:!0,fieldHasErrors:!0,children:ut("div",{className:"lexical-block-not-found",children:["Error: Block '",o.blockType,"' not found in the config but exists in the lexical data"]})})};var be=class extends ct{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=Vt(e.fields);return o.setFormat(e.format),o}decorate(e,o){return uc(mn,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Vt(t){return new be({fields:{...t,id:t?.id||new dc.default().toHexString()}})}function pt(t){return t instanceof be}import{createCommand as pn}from"lexical";var Ke=pn("INSERT_BLOCK_COMMAND"),Je=pn("INSERT_INLINE_BLOCK_COMMAND");import{c as mc}from"react/compiler-runtime";import{useLexicalComposerContext as pc}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as fc,$wrapNodeInElement as hc,mergeRegister as gc}from"@lexical/utils";import{formatDrawerSlug as xc,useEditDepth as Cc}from"@payloadcms/ui";import{$createParagraphNode as bc,$getNodeByKey as _c,$getPreviousSelection as Tc,$getSelection as kc,$insertNodes as Ec,$isParagraphNode as wc,$isRangeSelection as Nc,$isRootOrShadowRoot as Sc,COMMAND_PRIORITY_EDITOR as fn}from"lexical";import{useEffect as Lc,useState as yc}from"react";var hn=()=>{let t=mc(12),[e]=pc(),[o,r]=yc(null),{setCreatedInlineBlock:n,uuid:i}=j(),l=Cc(),s="lexical-inlineBlocks-create-"+i,u;t[0]!==l||t[1]!==s?(u=xc({slug:s,depth:l}),t[0]=l,t[1]=s,t[2]=u):u=t[2];let c=u,{toggleDrawer:d}=xe(c,!0),a;t[3]!==e||t[4]!==n||t[5]!==o?(a=()=>{if(!e.hasNodes([be]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return gc(e.registerCommand(Ke,m=>(e.update(()=>{let f=kc()||Tc();if(Nc(f)){let h=Vt(m),{focus:x}=f,_=x.getNode();fc(h),wc(_)&&!_.__first&&_.remove()}}),!0),fn),e.registerCommand(Je,m=>{if(o){let h=_c(o);return!h||!Eo(h)?!1:(h.setFields(m),r(null),!0)}let f=ko(m);return n?.(f),Ec([f]),Sc(f.getParentOrThrow())&&hc(f,bc).selectEnd(),!0},fn))},t[3]=e,t[4]=n,t[5]=o,t[6]=a):a=t[6];let p;return t[7]!==e||t[8]!==n||t[9]!==o||t[10]!==d?(p=[e,n,o,d],t[7]=e,t[8]=n,t[9]=o,t[10]=d,t[11]=p):p=t[11],Lc(a,p),null};var Ic=y(({config:t,featureClientSchemaMap:e,props:o,schemaPath:r})=>{let n=`${r}.lexical_internal_feature.blocks.lexical_blocks`,i=`${r}.lexical_internal_feature.blocks.lexical_inline_blocks`,l=e.blocks;if(!l)return{};let s=Object.entries(l).filter(([a])=>a.startsWith(n+".")&&!a.replace(n+".","").includes(".")).map(([,a])=>a[0]),u=Object.entries(l).filter(([a])=>a.startsWith(i+".")&&!a.replace(i+".","").includes(".")).map(([,a])=>a[0]),c=s.map(a=>a.blockReferences?typeof a.blockReferences[0]=="string"?t.blocksMap[a.blockReferences[0]]:a.blockReferences[0]:a.blocks[0]).filter(a=>a!==void 0),d=u.map(a=>a.blockReferences?typeof a.blockReferences[0]=="string"?t.blocksMap[a.blockReferences[0]]:a.blockReferences[0]:a.blocks[0]).filter(a=>a!==void 0);return{nodes:[be,To],plugins:[{Component:hn,position:"normal"}],sanitizedClientFeatureProps:o,slashMenu:{groups:[c?.length?{items:c.map(a=>({Icon:jt(a.imageURL,a.imageAltText),key:"block-"+a.slug,keywords:["block","blocks",a.slug],label:({i18n:p})=>a?.labels?.singular?Kt(a.labels.singular,p):a?.slug,onSelect:({editor:p})=>{p.dispatchCommand(Ke,{blockName:"",blockType:a.slug})}})),key:"blocks",label:({i18n:a})=>a.t("lexical:blocks:label")}:null,d?.length?{items:d.map(a=>({Icon:Ht,key:"inlineBlocks-"+a.slug,keywords:["inlineBlock","inline block",a.slug],label:({i18n:p})=>a?.labels?.singular?Kt(a.labels.singular,p):a?.slug,onSelect:({editor:p})=>{p.dispatchCommand(Je,{blockName:"",blockType:a.slug})}})),key:"inlineBlocks",label:({i18n:a})=>a.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[c.length?{type:"dropdown",ChildComponent:Bt,items:c.map((a,p)=>({ChildComponent:jt(a.imageURL,a.imageAltText),isActive:void 0,key:"block-"+a.slug,label:({i18n:m})=>a?.labels?.singular?Kt(a.labels.singular,m):a?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Ke,{blockName:"",blockType:a.slug})},order:p})),key:"blocks",order:20}:null,d?.length?{type:"dropdown",ChildComponent:Ht,items:d.map((a,p)=>({ChildComponent:a.imageURL?jt(a.imageURL,a.imageAltText):Ht,isActive:void 0,key:"inlineBlock-"+a.slug,label:({i18n:m})=>a?.labels?.singular?Kt(a.labels.singular,m):a?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Je,{blockName:"",blockType:a.slug})},order:p})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as Mc}from"react/compiler-runtime";import{jsx as $e,jsxs as $o}from"react/jsx-runtime";import{useLexicalComposerContext as Ac}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Dc,$createTextNode as Oc,$getRoot as Fc,getDOMSelection as Do}from"lexical";import*as _n from"react";import{useCallback as Fe,useEffect as Oo,useLayoutEffect as xn,useRef as Fo,useState as Jt}from"react";var Rc=ae&&"documentMode"in document?document.documentMode:null,gn=ae&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Xb=ae&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),zb=ae&&"InputEvent"in window&&!Rc?"getTargetRanges"in new window.InputEvent("input"):!1,Zb=ae&&/Version\/[\d.].*Safari/.test(navigator.userAgent),Yb=ae&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,qb=ae&&/Android/.test(navigator.userAgent),Qb=ae&&/Win/.test(navigator.platform),vc=ae&&/^(?=.*Chrome).*/i.test(navigator.userAgent),e0=ae&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!vc;var $c=t=>{let e=document.createElement("textarea");e.value=t||"",e.style.position="absolute",e.style.opacity="0",document.body?.appendChild(e),e.focus(),e.select();try{let o=document.execCommand("copy");console.log(o)}catch(o){console.error(o)}document.body?.removeChild(e)},Pc=(t,e)=>{let o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e||"")),o.setAttribute("download",t),o.style.display="none",document.body?.appendChild(o),o.click(),document.body?.removeChild(o)},Bc=t=>{let o=((r,n)=>{switch(r){case"click":return` await page.mouse.click(${n.x}, ${n.y});`;case"keydown":return` await page.keyboard.keydown('${n}');`;case"keyup":return` await page.keyboard.keyup('${n}');`;case"press":return` await page.keyboard.press('${n}');`;case"selectAll":return" await selectAll(page);";case"snapshot":return` await assertHTMLSnapshot(page);
|
|
4
4
|
await assertSelection(page, {
|
|
5
5
|
anchorPath: [${n.anchorPath.toString()}],
|
|
6
6
|
anchorOffset: ${n.anchorOffset},
|