@payloadcms/richtext-lexical 3.59.0-internal.56a1b3b → 3.59.0-internal.898dbd3
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/index.js +2 -2
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +19 -17
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/package.json +7 -7
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
`,o&&d<0){let _=k.match(o);if(_?.index!==void 0){C=S,x=_.index+_[0].length-1;break}}if(S===u.length-1&&!t&&!p)throw new Error("End match not found for lines "+e.join(`
|
|
8
8
|
`)+`
|
|
9
9
|
|
|
10
|
-
. Start match: `+JSON.stringify(n))}return{afterEndLine:u[C].trim().slice(x),beforeStartLine:h,content:s,endLineIndex:r+C,endlineLastCharIndex:x,propsString:i}}import{jsx as au}from"react/jsx-runtime";import cu from"bson-objectid";import"react";import{DecoratorBlockNode as Ac}from"@lexical/react/LexicalDecoratorBlockNode.js";import $c from"bson-objectid";var ht=class extends Ac{__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=Oc(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 Oc(t){return new ht({fields:{...t,id:t?.id||new $c.default().toHexString()}})}import{jsx as G,jsxs as gt,Fragment as wn}from"react/jsx-runtime";import{Button as En,Collapsible as Wc,Drawer as Gc,EditDepthProvider as Vc,ErrorPill as Kc,Form as Jc,formatDrawerSlug as Xc,FormSubmit as zc,Pill as Zc,RenderFields as Yc,SectionTitle as qc,useConfig as Qc,useDocumentForm as eu,useDocumentInfo as Sn,useEditDepth as tu,useFormSubmitted as ou,useServerFunctions as ru,useTranslation as nu}from"@payloadcms/ui";import{abortAndIgnore as Wo}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as to,reduceFieldsToValues as Nn}from"payload/shared";import xt,{useCallback as Go,useEffect as Vo,useMemo as Ct,useRef as Ko}from"react";import{useLexicalComposerContext as lu}from"@lexical/react/LexicalComposerContext";import{getTranslation as iu}from"@payloadcms/translations";import{$getNodeByKey as oo}from"lexical";import{v4 as su}from"uuid";import{c as Fc}from"react/compiler-runtime";import{jsx as eo,jsxs as Pc}from"react/jsx-runtime";import{RenderFields as Bc,useFormSubmitted as jc}from"@payloadcms/ui";import Hc,{createContext as Uc}from"react";var kn=Uc({baseClass:"lexical-block",BlockCollapsible:()=>null,BlockDrawer:()=>null,CustomBlock:null,EditButton:()=>null,errorCount:0,formSchema:[],initialState:!1,nodeKey:"",RemoveButton:()=>null}),ge=()=>Hc.use(kn),_n=t=>{let e=Fc(4),{Collapsible:o,...r}=t,{BlockDrawer:n,CustomBlock:l,errorCount:i,formSchema:s}=r,c=jc()&&i>0,d;e[0]!==o||e[1]!==i||e[2]!==c?(d=m=>{let{children:p,...f}=m;return eo(o,{errorCount:i,fieldHasErrors:c,...f,children:p})},e[0]=o,e[1]=i,e[2]=c,e[3]=d):d=e[3];let a=d;return l?Pc(kn,{value:{...r,BlockCollapsible:a},children:[l,eo(n,{})]}):eo(a,{children:eo(Bc,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})})};function Tn({fields:t}){for(let e in t){let o=t[e];Array.isArray(o?.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var te="lexical-block",Ln=t=>{let{cacheBuster:e,formData:o,nodeKey:r}=t,n=ou(),{id:l,collectionSlug:i,globalSlug:s}=Sn(),{fieldProps:{featureClientSchemaMap:u,field:c,initialLexicalFormState:d,readOnly:a,schemaPath:m},uuid:p}=j(),{fields:f}=eu(),h=Ko(new AbortController),x=tu(),[C,T]=xt.useState(0),{config:S}=Qc(),b=Xc({slug:`lexical-blocks-create-${p}-${o.id}`,depth:x}),{toggleDrawer:k}=fe(b),{getDocPreferences:g,setDocFieldPreferences:w}=Sn(),[_]=lu(),y=o.blockType,{getFormState:O}=ru(),v=`${m}.lexical_internal_feature.blocks.lexical_blocks.${y}.fields`,[N,E]=xt.useState(()=>d?.[o.id]?.formState?{...d?.[o.id]?.formState,blockName:{initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName}}:!1),L=Ko(!1),D=Ko(e);Vo(()=>{L.current?(D.current!==e&&E(!1),D.current=e):L.current=!0},[e]);let[I,A]=xt.useState(N?._components?.customComponents?.BlockLabel??void 0),[R,F]=xt.useState(N?._components?.customComponents?.Block??void 0);Vo(()=>{let H=new AbortController;return o&&!N&&(async()=>{let{state:V}=await O({id:l,collectionSlug:i,data:o,docPermissions:{fields:!0},docPreferences:await g(),documentFormState:to(f),globalSlug:s,initialBlockData:o,operation:"update",renderAllFields:!0,schemaPath:v,signal:H.signal});if(V){V.blockName={initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName};let X=Nn(to(V),!0);_.update(()=>{let Y=oo(r);if(Y&&De(Y)){let ne=X;ne.blockType=y,Y.setFields(ne,!0)}}),E(V),A(V._components?.customComponents?.BlockLabel??void 0),F(V._components?.customComponents?.Block??void 0)}})(),()=>{Wo(H)}},[O,v,l,o,_,r,N,i,s,g,f,y]);let[W,Q]=xt.useState(d?.[o.id]?.collapsed??!1),re=`${m}.lexical_internal_feature.blocks.lexical_blocks.${y}`,J=u.blocks?.[re]?.[0],U=J.blockReferences?typeof J?.blockReferences?.[0]=="string"?S.blocksMap[J?.blockReferences?.[0]]:J?.blockReferences?.[0]:J?.blocks?.[0],{i18n:We,t:Se}=nu(),pe=Go(async({formState:H,submit:ue})=>{Wo(h.current);let V=new AbortController;h.current=V;let{state:X}=await O({id:l,collectionSlug:i,docPermissions:{fields:!0},docPreferences:await g(),documentFormState:to(f),formState:H,globalSlug:s,initialBlockFormState:H,operation:"update",renderAllFields:!!ue,schemaPath:v,signal:V.signal});if(!X)return H;H.blockName&&(X.blockName=H.blockName);let Y=Nn(Tn({fields:to(X)}),!0);if(setTimeout(()=>{_.update(()=>{let ne=oo(r);if(ne&&De(ne)){let Ve=Y;Ve.blockType=y,ne.setFields(Ve,!0)}})},0),ue){A(X._components?.customComponents?.BlockLabel??void 0),F(X._components?.customComponents?.Block??void 0);let ne=0;for(let Ve of Object.values(X))Ve?.valid===!1&&ne++;T(ne)}return X},[O,l,i,g,s,v,y,f,_,r]);Vo(()=>()=>{Wo(h.current)},[]);let Bt=Go(()=>{_.update(()=>{oo(r)?.remove()})},[_,r]),Ne=U?.labels?.singular?iu(U.labels.singular,We):U?.slug,jt=Go(H=>{g().then(ue=>{let X=ue?.fields?.[c.name]?.collapsed,Y=X&&X?.length?X:[];H?Y.includes(o.id)||Y.push(o.id):Y.includes(o.id)&&Y.splice(Y.indexOf(o.id),1),w(c.name,{collapsed:Y,hello:"hi"})})},[g,c.name,w,o.id]),Ge=Ct(()=>()=>G(En,{buttonStyle:"icon-label",className:`${te}__editButton`,disabled:a,el:"button",icon:"edit",onClick:H=>(H.preventDefault(),H.stopPropagation(),k(),!1),onMouseDown:H=>{H.preventDefault()},round:!0,size:"small",tooltip:Se("lexical:blocks:inlineBlocks:edit",{label:Ne})}),[Ne,a,Se,k]),Ht=Ct(()=>()=>G(En,{buttonStyle:"icon-label",className:`${te}__removeButton`,disabled:c?.admin?.readOnly||!1,icon:"x",onClick:H=>{H.preventDefault(),Bt()},round:!0,tooltip:"Remove Block"}),[c?.admin?.readOnly,Bt]),Ao=Ct(()=>({Actions:H,children:ue,className:V,collapsibleProps:X,disableBlockName:Y,editButton:ne,errorCount:Ve,fieldHasErrors:$o,Label:Qr,Pill:en,removeButton:ac})=>G("div",{className:te+" "+te+"-"+y,children:G(Wc,{className:[`${te}__row`,$o?`${te}__row--has-errors`:`${te}__row--no-errors`,V].filter(Boolean).join(" "),collapsibleStyle:$o?"error":"default",header:gt("div",{className:`${te}__block-header`,children:[typeof Qr<"u"?Qr:typeof I<"u"?I:gt("div",{className:`${te}__block-label`,children:[typeof en<"u"?en:G(Zc,{className:`${te}__block-pill ${te}__block-pill-${y}`,pillStyle:"white",size:"small",children:Ne??y}),!Y&&!U?.admin?.disableBlockName&&G(qc,{path:"blockName",readOnly:c?.admin?.readOnly||!1}),$o&&G(Kc,{count:Ve??0,i18n:We,withMessage:!0})]}),G("div",{className:`${te}__block-actions`,children:typeof H<"u"?H:gt(wn,{children:[R&&ne!==!1||!R&&ne?G(Ge,{}):null,ac!==!1&&_.isEditable()?G(Ht,{}):null]})})]}),isCollapsed:W,onToggle:tn=>{jt(tn),Q(tn)},...X||{},children:ue},0)}),[R,I,Ge,Ht,Ne,U?.admin?.disableBlockName,_,y,We,W,jt,c?.admin?.readOnly]),Yr=o?.id,qr=Ct(()=>()=>G(Vc,{children:G(Gc,{className:"",slug:b,title:Se(`lexical:blocks:inlineBlocks:${Yr?"edit":"create"}`,{label:Ne??Se("lexical:blocks:inlineBlocks:label")}),children:N?gt(wn,{children:[G(Yc,{fields:U?.fields??[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:v,permissions:!0,readOnly:!1}),G(zc,{programmaticSubmit:!0,children:Se("fields:saveChanges")})]}):null})}),[N,b,Yr,Ne,Se,U?.fields,v]),sc=Ct(()=>N?G(Jc,{beforeSubmit:[async({formState:H})=>await pe({formState:H,submit:!0})],el:"div",fields:U?.fields??[],initialState:N,onChange:[pe],onSubmit:(H,ue)=>{ue.blockType=y,_.update(()=>{let V=oo(r);V&&De(V)&&V.setFields(ue,!0)}),k()},submitted:n,uuid:su(),children:G(_n,{baseClass:te,BlockDrawer:qr,Collapsible:Ao,CustomBlock:R,EditButton:Ge,errorCount:C,formSchema:U?.fields??[],initialState:N,nodeKey:r,RemoveButton:Ht})}):null,[Ao,qr,R,y,Ht,Ge,_,C,k,U?.fields,N,r,pe,n]);return U?sc:G(Ao,{disableBlockName:!0,fieldHasErrors:!0,children:gt("div",{className:"lexical-block-not-found",children:["Error: Block '",y,"' not found in the config but exists in the lexical data"]})})};var se=class extends ht{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=Ae(e.fields);return o.setFormat(e.format),o}decorate(e,o){return au(Ln,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ae(t){return new se({fields:{...t,id:t?.id||new cu.default().toHexString()}})}function De(t){return t instanceof se}import{createHeadlessEditor as uu}from"@lexical/headless";function Jo(t,e){return({editorState:r})=>{let n=uu({nodes:t});try{n.setEditorState(n.parseEditorState(r))}catch(i){console.error("getLexicalToMarkdown: ERROR parsing editor state",i)}let l="";return n.getEditorState().read(()=>{l=Wt(e)}),l}}import{createHeadlessEditor as du}from"@lexical/headless";function ro(t,e){return({markdown:r})=>{let n=du({nodes:t});return n.update(()=>{Ut(r,e)},{discrete:!0}),n.getEditorState().toJSON()}}function mu(t){let e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{regExpEnd:new RegExp(`</(${e})\\s*>|<${e}[^>]*?/>`,"i"),regExpStart:new RegExp(`<(${e})([^>]*?)\\s*(/?)>`,"i")}}var In=({blocks:t,inlineBlocks:e})=>{if(!t?.length&&!e?.length)return[];let o=[];if(t?.length)for(let r of t){let n=Rn(r,!1);n&&(o=o.concat(n))}if(e?.length)for(let r of e){let n=Rn(r,!0);n&&(o=o.concat(n))}return o};function Rn(t,e){if(!t.jsx)return null;let o=mu(t.slug),r=[];return e?(r.push(({allNodes:n,allTransformers:l})=>({type:"text-match",dependencies:[at],export:i=>{if(!ut(i)||i.getFields()?.blockType?.toLowerCase()!==t.slug.toLowerCase())return null;let s=i.getFields(),u=Jo(n,l),c=t.jsx.export({fields:s,lexicalToMarkdown:u});if(c===!1)return null;if(typeof c=="string")return c;let d=c.props&&Object.keys(c.props)?.length>0,a=c.props??{};return c?.children?.length?`<${s.blockType}${d?" "+ft({props:a}):""}>${c.children}</${s.blockType}>`:`<${s.blockType}${d?" "+ft({props:a}):""}/>`},getEndIndex:(i,s)=>{let{endlineLastCharIndex:u}=Qt({isEndOptional:!1,lines:[i.getTextContent()],regexpEndRegex:o.regExpEnd,startLineIndex:0,startMatch:s,trimChildren:!1});return u},importRegExp:t.jsx?.customStartRegex??o.regExpStart,regExp:/___ignoreignoreignore___/g,replace(i,s){let{content:u,propsString:c}=Qt({isEndOptional:!1,lines:[i.getTextContent()],regexpEndRegex:o.regExpEnd,startLineIndex:0,startMatch:{...s,index:0},trimChildren:!1});if(!t?.jsx?.import)return;let d=ro(n,l),a=t.jsx.import({children:u,closeMatch:null,htmlToLexical:null,markdownToLexical:d,openMatch:s,props:c?qt({propsString:c}):{}});if(a===!1)return;let m=ct({blockType:t.slug,...a});i.replace(m)}})),r):(r.push(({allNodes:n,allTransformers:l})=>({dependencies:[se],export:i=>{if(!De(i)||i.getFields()?.blockType?.toLowerCase()!==t.slug.toLowerCase())return null;let s=i.getFields(),u=Jo(n,l),c=t.jsx.export({fields:s,lexicalToMarkdown:u});if(c===!1)return null;if(typeof c=="string")return c;let d=c.props&&Object.keys(c.props)?.length>0,a=c.props??{};if(c?.children?.length){let m=c.children,p="";if(m.includes(`
|
|
10
|
+
. Start match: `+JSON.stringify(n))}return{afterEndLine:u[C].trim().slice(x),beforeStartLine:h,content:s,endLineIndex:r+C,endlineLastCharIndex:x,propsString:i}}import{jsx as au}from"react/jsx-runtime";import cu from"bson-objectid";import"react";import{DecoratorBlockNode as Ac}from"@lexical/react/LexicalDecoratorBlockNode.js";import $c from"bson-objectid";var ht=class extends Ac{__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=Oc(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 Oc(t){return new ht({fields:{...t,id:t?.id||new $c.default().toHexString()}})}import{jsx as G,jsxs as gt,Fragment as wn}from"react/jsx-runtime";import{Button as En,Collapsible as Wc,Drawer as Gc,EditDepthProvider as Vc,ErrorPill as Kc,Form as Jc,formatDrawerSlug as Xc,FormSubmit as zc,Pill as Zc,RenderFields as Yc,SectionTitle as qc,useConfig as Qc,useDocumentForm as eu,useDocumentInfo as Sn,useEditDepth as tu,useFormSubmitted as ou,useServerFunctions as ru,useTranslation as nu}from"@payloadcms/ui";import{abortAndIgnore as Wo}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as to,reduceFieldsToValues as Nn}from"payload/shared";import xt,{useCallback as Go,useEffect as Vo,useMemo as Ct,useRef as Ko}from"react";import{useLexicalComposerContext as lu}from"@lexical/react/LexicalComposerContext";import{getTranslation as iu}from"@payloadcms/translations";import{$getNodeByKey as oo}from"lexical";import{v4 as su}from"uuid";import{c as Fc}from"react/compiler-runtime";import{jsx as eo,jsxs as Pc}from"react/jsx-runtime";import{RenderFields as Bc,useFormSubmitted as jc}from"@payloadcms/ui";import Hc,{createContext as Uc}from"react";var kn=Uc({baseClass:"lexical-block",BlockCollapsible:()=>null,BlockDrawer:()=>null,CustomBlock:null,EditButton:()=>null,errorCount:0,formSchema:[],initialState:!1,nodeKey:"",RemoveButton:()=>null}),ge=()=>Hc.use(kn),_n=t=>{let e=Fc(4),{Collapsible:o,...r}=t,{BlockDrawer:n,CustomBlock:l,errorCount:i,formSchema:s}=r,c=jc()&&i>0,d;e[0]!==o||e[1]!==i||e[2]!==c?(d=m=>{let{children:p,...f}=m;return eo(o,{errorCount:i,fieldHasErrors:c,...f,children:p})},e[0]=o,e[1]=i,e[2]=c,e[3]=d):d=e[3];let a=d;return l?Pc(kn,{value:{...r,BlockCollapsible:a},children:[l,eo(n,{})]}):eo(a,{children:eo(Bc,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})})};function Tn({fields:t}){for(let e in t){let o=t[e];Array.isArray(o?.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var te="lexical-block",Ln=t=>{let{cacheBuster:e,formData:o,nodeKey:r}=t,n=ou(),{id:l,collectionSlug:i,globalSlug:s}=Sn(),{fieldProps:{featureClientSchemaMap:u,field:c,initialLexicalFormState:d,readOnly:a,schemaPath:m},uuid:p}=j(),{fields:f}=eu(),h=Ko(new AbortController),x=tu(),[C,T]=xt.useState(0),{config:S}=Qc(),b=Xc({slug:`lexical-blocks-create-${p}-${o.id}`,depth:x}),{toggleDrawer:k}=fe(b),{getDocPreferences:g,setDocFieldPreferences:w}=Sn(),[_]=lu(),y=o.blockType,{getFormState:O}=ru(),v=`${m}.lexical_internal_feature.blocks.lexical_blocks.${y}.fields`,[N,E]=xt.useState(()=>d?.[o.id]?.formState?{...d?.[o.id]?.formState,blockName:{initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName}}:!1),L=Ko(!1),D=Ko(e);Vo(()=>{L.current?(D.current!==e&&E(!1),D.current=e):L.current=!0},[e]);let[I,A]=xt.useState(N?._components?.customComponents?.BlockLabel??void 0),[R,F]=xt.useState(N?._components?.customComponents?.Block??void 0);Vo(()=>{let H=new AbortController;return o&&!N&&(async()=>{let{state:V}=await O({id:l,collectionSlug:i,data:o,docPermissions:{fields:!0},docPreferences:await g(),documentFormState:to(f),globalSlug:s,initialBlockData:o,operation:"update",renderAllFields:!0,schemaPath:v,signal:H.signal});if(V){V.blockName={initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName};let X=Nn(to(V),!0);_.update(()=>{let q=oo(r);if(q&&De(q)){let ne=X;ne.blockType=y,q.setFields(ne,!0)}}),E(V),A(V._components?.customComponents?.BlockLabel??void 0),F(V._components?.customComponents?.Block??void 0)}})(),()=>{Wo(H)}},[O,v,l,o,_,r,N,i,s,g,f,y]);let[W,Q]=xt.useState(d?.[o.id]?.collapsed??!1),re=`${m}.lexical_internal_feature.blocks.lexical_blocks.${y}`,J=u.blocks?.[re]?.[0],U=J.blockReferences?typeof J?.blockReferences?.[0]=="string"?S.blocksMap[J?.blockReferences?.[0]]:J?.blockReferences?.[0]:J?.blocks?.[0],{i18n:We,t:Se}=nu(),pe=Go(async({formState:H,submit:ue})=>{Wo(h.current);let V=new AbortController;h.current=V;let{state:X}=await O({id:l,collectionSlug:i,docPermissions:{fields:!0},docPreferences:await g(),documentFormState:to(f),formState:H,globalSlug:s,initialBlockFormState:H,operation:"update",renderAllFields:!!ue,schemaPath:v,signal:V.signal});if(!X)return H;H.blockName&&(X.blockName=H.blockName);let q=Nn(Tn({fields:to(X)}),!0);if(setTimeout(()=>{_.update(()=>{let ne=oo(r);if(ne&&De(ne)){let Ve=q;Ve.blockType=y,ne.setFields(Ve,!0)}})},0),ue){A(X._components?.customComponents?.BlockLabel??void 0),F(X._components?.customComponents?.Block??void 0);let ne=0;for(let Ve of Object.values(X))Ve?.valid===!1&&ne++;T(ne)}return X},[O,l,i,g,s,v,y,f,_,r]);Vo(()=>()=>{Wo(h.current)},[]);let Bt=Go(()=>{_.update(()=>{oo(r)?.remove()})},[_,r]),Ne=U?.labels?.singular?iu(U.labels.singular,We):U?.slug,jt=Go(H=>{g().then(ue=>{let X=ue?.fields?.[c.name]?.collapsed,q=X&&X?.length?X:[];H?q.includes(o.id)||q.push(o.id):q.includes(o.id)&&q.splice(q.indexOf(o.id),1),w(c.name,{collapsed:q,hello:"hi"})})},[g,c.name,w,o.id]),Ge=Ct(()=>()=>G(En,{buttonStyle:"icon-label",className:`${te}__editButton`,disabled:a,el:"button",icon:"edit",onClick:H=>(H.preventDefault(),H.stopPropagation(),k(),!1),onMouseDown:H=>{H.preventDefault()},round:!0,size:"small",tooltip:Se("lexical:blocks:inlineBlocks:edit",{label:Ne})}),[Ne,a,Se,k]),Ht=Ct(()=>()=>G(En,{buttonStyle:"icon-label",className:`${te}__removeButton`,disabled:c?.admin?.readOnly||!1,icon:"x",onClick:H=>{H.preventDefault(),Bt()},round:!0,tooltip:"Remove Block"}),[c?.admin?.readOnly,Bt]),Ao=Ct(()=>({Actions:H,children:ue,className:V,collapsibleProps:X,disableBlockName:q,editButton:ne,errorCount:Ve,fieldHasErrors:$o,Label:Qr,Pill:en,removeButton:ac})=>G("div",{className:te+" "+te+"-"+y,children:G(Wc,{className:[`${te}__row`,$o?`${te}__row--has-errors`:`${te}__row--no-errors`,V].filter(Boolean).join(" "),collapsibleStyle:$o?"error":"default",header:gt("div",{className:`${te}__block-header`,children:[typeof Qr<"u"?Qr:typeof I<"u"?I:gt("div",{className:`${te}__block-label`,children:[typeof en<"u"?en:G(Zc,{className:`${te}__block-pill ${te}__block-pill-${y}`,pillStyle:"white",size:"small",children:Ne??y}),!q&&!U?.admin?.disableBlockName&&G(qc,{path:"blockName",readOnly:c?.admin?.readOnly||!1}),$o&&G(Kc,{count:Ve??0,i18n:We,withMessage:!0})]}),G("div",{className:`${te}__block-actions`,children:typeof H<"u"?H:gt(wn,{children:[R&&ne!==!1||!R&&ne?G(Ge,{}):null,ac!==!1&&_.isEditable()?G(Ht,{}):null]})})]}),isCollapsed:W,onToggle:tn=>{jt(tn),Q(tn)},...X||{},children:ue},0)}),[R,I,Ge,Ht,Ne,U?.admin?.disableBlockName,_,y,We,W,jt,c?.admin?.readOnly]),Yr=o?.id,qr=Ct(()=>()=>G(Vc,{children:G(Gc,{className:"",slug:b,title:Se(`lexical:blocks:inlineBlocks:${Yr?"edit":"create"}`,{label:Ne??Se("lexical:blocks:inlineBlocks:label")}),children:N?gt(wn,{children:[G(Yc,{fields:U?.fields??[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:v,permissions:!0,readOnly:!1}),G(zc,{programmaticSubmit:!0,children:Se("fields:saveChanges")})]}):null})}),[N,b,Yr,Ne,Se,U?.fields,v]),sc=Ct(()=>N?G(Jc,{beforeSubmit:[async({formState:H})=>await pe({formState:H,submit:!0})],el:"div",fields:U?.fields??[],initialState:N,onChange:[pe],onSubmit:(H,ue)=>{ue.blockType=y,_.update(()=>{let V=oo(r);V&&De(V)&&V.setFields(ue,!0)}),k()},submitted:n,uuid:su(),children:G(_n,{baseClass:te,BlockDrawer:qr,Collapsible:Ao,CustomBlock:R,EditButton:Ge,errorCount:C,formSchema:U?.fields??[],initialState:N,nodeKey:r,RemoveButton:Ht})}):null,[Ao,qr,R,y,Ht,Ge,_,C,k,U?.fields,N,r,pe,n]);return U?sc:G(Ao,{disableBlockName:!0,fieldHasErrors:!0,children:gt("div",{className:"lexical-block-not-found",children:["Error: Block '",y,"' not found in the config but exists in the lexical data"]})})};var se=class extends ht{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=Ae(e.fields);return o.setFormat(e.format),o}decorate(e,o){return au(Ln,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ae(t){return new se({fields:{...t,id:t?.id||new cu.default().toHexString()}})}function De(t){return t instanceof se}import{createHeadlessEditor as uu}from"@lexical/headless";function Jo(t,e){return({editorState:r})=>{let n=uu({nodes:t});try{n.setEditorState(n.parseEditorState(r))}catch(i){console.error("getLexicalToMarkdown: ERROR parsing editor state",i)}let l="";return n.getEditorState().read(()=>{l=Wt(e)}),l}}import{createHeadlessEditor as du}from"@lexical/headless";function ro(t,e){return({markdown:r})=>{let n=du({nodes:t});return n.update(()=>{Ut(r,e)},{discrete:!0}),n.getEditorState().toJSON()}}function mu(t){let e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{regExpEnd:new RegExp(`</(${e})\\s*>|<${e}[^>]*?/>`,"i"),regExpStart:new RegExp(`<(${e})([^>]*?)\\s*(/?)>`,"i")}}var In=({blocks:t,inlineBlocks:e})=>{if(!t?.length&&!e?.length)return[];let o=[];if(t?.length)for(let r of t){let n=Rn(r,!1);n&&(o=o.concat(n))}if(e?.length)for(let r of e){let n=Rn(r,!0);n&&(o=o.concat(n))}return o};function Rn(t,e){if(!t.jsx)return null;let o=mu(t.slug),r=[];return e?(r.push(({allNodes:n,allTransformers:l})=>({type:"text-match",dependencies:[at],export:i=>{if(!ut(i)||i.getFields()?.blockType?.toLowerCase()!==t.slug.toLowerCase())return null;let s=i.getFields(),u=Jo(n,l),c=t.jsx.export({fields:s,lexicalToMarkdown:u});if(c===!1)return null;if(typeof c=="string")return c;let d=c.props&&Object.keys(c.props)?.length>0,a=c.props??{};return c?.children?.length?`<${s.blockType}${d?" "+ft({props:a}):""}>${c.children}</${s.blockType}>`:`<${s.blockType}${d?" "+ft({props:a}):""}/>`},getEndIndex:(i,s)=>{let{endlineLastCharIndex:u}=Qt({isEndOptional:!1,lines:[i.getTextContent()],regexpEndRegex:o.regExpEnd,startLineIndex:0,startMatch:s,trimChildren:!1});return u},importRegExp:t.jsx?.customStartRegex??o.regExpStart,regExp:/___ignoreignoreignore___/g,replace(i,s){let{content:u,propsString:c}=Qt({isEndOptional:!1,lines:[i.getTextContent()],regexpEndRegex:o.regExpEnd,startLineIndex:0,startMatch:{...s,index:0},trimChildren:!1});if(!t?.jsx?.import)return;let d=ro(n,l),a=t.jsx.import({children:u,closeMatch:null,htmlToLexical:null,markdownToLexical:d,openMatch:s,props:c?qt({propsString:c}):{}});if(a===!1)return;let m=ct({blockType:t.slug,...a});i.replace(m)}})),r):(r.push(({allNodes:n,allTransformers:l})=>({dependencies:[se],export:i=>{if(!De(i)||i.getFields()?.blockType?.toLowerCase()!==t.slug.toLowerCase())return null;let s=i.getFields(),u=Jo(n,l),c=t.jsx.export({fields:s,lexicalToMarkdown:u});if(c===!1)return null;if(typeof c=="string")return c;let d=c.props&&Object.keys(c.props)?.length>0,a=c.props??{};if(c?.children?.length){let m=c.children,p="";if(m.includes(`
|
|
11
11
|
`))for(let f of m.split(`
|
|
12
12
|
`)){let h="";!t?.jsx?.doNotTrimChildren&&f!==""&&(h=" "),h+=f+`
|
|
13
13
|
`,p+=h}else p=(t?.jsx?.doNotTrimChildren?"":" ")+m+`
|
|
@@ -62,5 +62,5 @@ ${e.map(ju).join(`
|
|
|
62
62
|
`+t.code:"")+"\n```",import:({children:t,closeMatch:e,openMatch:o})=>{let r=o?.[1];return t.startsWith(`
|
|
63
63
|
`)&&(t=t.slice(1)),t.endsWith(`
|
|
64
64
|
`)&&(t=t.slice(0,-1)),!!e&&!t.includes(`
|
|
65
|
-
`)&&o?.input?.trim()!=="```"+r?{code:r+(t?.length?t:""),language:""}:{code:t,language:r}}};import{jsx as eC}from"react/jsx-runtime";import{CodeField as tC,useFormFields as oC}from"@payloadcms/ui";import{useMemo as rC}from"react";var nC=({autoComplete:t,field:e,forceRender:o,languages:r={js:"JavaScript",plaintext:"Plain Text",ts:"TypeScript"},path:n,permissions:l,readOnly:i,renderedBlocks:s,schemaPath:u,typescript:c,validate:d})=>{let a=oC(([x])=>x.language),m=a?.value||a?.initialValue||"typescript",p=r[m],f=rC(()=>({...e,type:"code",admin:{...e.admin,editorOptions:{},language:m}}),[e,m]),h=`${e.name}-${m}-${p}`;return f&&eC(tC,{autoComplete:t,field:f,forceRender:o,onMount:(x,C)=>{C.editor.defineTheme("vs-dark",{base:"vs-dark",colors:{"editor.background":"#222222"},inherit:!0,rules:[]}),C.editor.defineTheme("vs",{base:"vs",colors:{"editor.background":"#f5f5f5"},inherit:!0,rules:[]}),C.languages.typescript.typescriptDefaults.setCompilerOptions({allowNonTsExtensions:!0,moduleResolution:C.languages.typescript.ModuleResolutionKind.NodeJs,paths:c?.paths,target:C.languages.typescript.ScriptTarget[c?.target??"ESNext"],typeRoots:c?.typeRoots??["node_modules/@types"]}),(async()=>{c?.fetchTypes&&Array.isArray(c.fetchTypes)&&c.fetchTypes.length>0&&await Promise.all(c.fetchTypes.map(async S=>{let k=await(await fetch(S.url)).text();C.languages.typescript.typescriptDefaults.addExtraLib(k,S.filePath)}))})()},path:n,permissions:l,readOnly:i,renderedBlocks:s,schemaPath:u,validate:d},h)};import{c as dC}from"react/compiler-runtime";import{jsx as
|
|
65
|
+
`)&&o?.input?.trim()!=="```"+r?{code:r+(t?.length?t:""),language:""}:{code:t,language:r}}};import{jsx as eC}from"react/jsx-runtime";import{CodeField as tC,useFormFields as oC}from"@payloadcms/ui";import{useMemo as rC}from"react";var nC=({autoComplete:t,field:e,forceRender:o,languages:r={js:"JavaScript",plaintext:"Plain Text",ts:"TypeScript"},path:n,permissions:l,readOnly:i,renderedBlocks:s,schemaPath:u,typescript:c,validate:d})=>{let a=oC(([x])=>x.language),m=a?.value||a?.initialValue||"typescript",p=r[m],f=rC(()=>({...e,type:"code",admin:{...e.admin,editorOptions:{},language:m}}),[e,m]),h=`${e.name}-${m}-${p}`;return f&&eC(tC,{autoComplete:t,field:f,forceRender:o,onMount:(x,C)=>{C.editor.defineTheme("vs-dark",{base:"vs-dark",colors:{"editor.background":"#222222"},inherit:!0,rules:[]}),C.editor.defineTheme("vs",{base:"vs",colors:{"editor.background":"#f5f5f5"},inherit:!0,rules:[]}),C.languages.typescript.typescriptDefaults.setCompilerOptions({allowNonTsExtensions:!0,moduleResolution:C.languages.typescript.ModuleResolutionKind.NodeJs,paths:c?.paths,target:C.languages.typescript.ScriptTarget[c?.target??"ESNext"],typeRoots:c?.typeRoots??["node_modules/@types"]}),(async()=>{c?.fetchTypes&&Array.isArray(c.fetchTypes)&&c.fetchTypes.length>0&&await Promise.all(c.fetchTypes.map(async S=>{let k=await(await fetch(S.url)).text();C.languages.typescript.typescriptDefaults.addExtraLib(k,S.filePath)}))})()},path:n,permissions:l,readOnly:i,renderedBlocks:s,schemaPath:u,validate:d},h)};import{c as dC}from"react/compiler-runtime";import{jsx as Y,jsxs as oc,Fragment as mC}from"react/jsx-runtime";import{ChevronIcon as pC,CopyToClipboard as fC,Popup as hC,PopupList as rc,RenderFields as gC,useForm as xC,useFormFields as nc}from"@payloadcms/ui";import"react";import{jsx as za}from"react/jsx-runtime";import"react";var Za=()=>za("svg",{fill:"none",height:"12",viewBox:"0 0 15 12",width:"15",xmlns:"http://www.w3.org/2000/svg",children:za("path",{d:"M11.3738 8.62598L14.0404 5.95931L11.3738 3.29264M3.37376 3.29264L0.707092 5.95931L3.37376 8.62598M9.04043 0.625977L5.70709 11.2926",stroke:"currentColor",strokeLinecap:"square"})});import{jsx as qa}from"react/jsx-runtime";import"react";import{useCollapsible as iC}from"@payloadcms/ui";import{jsx as Ya}from"react/jsx-runtime";import"react";var Do=()=>Ya("svg",{fill:"none",height:"15",viewBox:"0 0 15 15",width:"15",xmlns:"http://www.w3.org/2000/svg",children:Ya("path",{d:"M7.16667 13.8333V9.83333M7.16667 9.83333L9.16667 11.8333M7.16667 9.83333L5.16667 11.8333M7.16667 4.5V0.5M7.16667 4.5L9.16667 2.5M7.16667 4.5L5.16667 2.5M1.83333 7.16667H0.5M5.83333 7.16667H4.5M9.83333 7.16667H8.5M13.8333 7.16667H12.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})});var lC="code-block-collapse-button",Qa=()=>{let{toggle:t}=iC();return qa("button",{className:lC,onClick:t,type:"button",children:qa(Do,{})})};import{jsx as ec,jsxs as sC}from"react/jsx-runtime";import"react";import{useCollapsible as cC,useTranslation as uC}from"@payloadcms/ui";var aC="code-block-floating-collapse-button",tc=()=>{let{isCollapsed:t,toggle:e}=cC(),{t:o}=uC();return t?sC("button",{className:aC,onClick:e,type:"button",children:[ec("span",{children:o("general:collapse")}),ec(Do,{})]}):null};var Ue="payload-richtext-code-block",CC=t=>{let e=dC(14),{languages:o}=t,{BlockCollapsible:r,formSchema:n,RemoveButton:l}=ge(),{setModified:i}=xC(),{codeField:s}=nc(bC),u;e[0]!==i?(u=f=>{let[h,x]=f;return{selectedLanguageField:h?.language,setSelectedLanguage:C=>{x({type:"UPDATE",path:"language",value:C}),i(!0)}}},e[0]=i,e[1]=u):u=e[1];let{selectedLanguageField:c,setSelectedLanguage:d}=nc(u),a=o[c?.value],m=c?.value,p;if(e[2]!==r||e[3]!==l||e[4]!==s?.value||e[5]!==n||e[6]!==o||e[7]!==a||e[8]!==d||e[9]!==m){let f;e[11]!==o||e[12]!==d?(f=h=>{let{close:x}=h;return Y(rc.ButtonGroup,{children:Object.entries(o).map(C=>{let[T,S]=C;return Y(rc.Button,{active:!1,disabled:!1,onClick:()=>{d(T),x()},children:Y("span",{className:`${Ue}__language-code`,"data-language":T,children:S})},T)})})},e[11]=o,e[12]=d,e[13]=f):f=e[13],p=Y(r,{Actions:oc("div",{className:`${Ue}__actions`,children:[Y(hC,{button:oc("div",{className:`${Ue}__language-selector-button`,"data-selected-language":m,children:[Y("span",{children:a}),Y(pC,{className:`${Ue}__chevron`})]}),className:`${Ue}__language-selector`,horizontalAlign:"right",render:f,showScrollbar:!0,size:"large"}),Y(fC,{value:s?.value??""}),Y(Qa,{}),Y(l,{})]}),className:Ue,collapsibleProps:{AfterCollapsible:Y(tc,{}),disableHeaderToggle:!0,disableToggleIndicator:!0},Pill:Y("div",{className:`${Ue}__pill`,children:Y(Za,{})}),children:Y(mC,{children:Y(gC,{fields:n,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})})}),e[2]=r,e[3]=l,e[4]=s?.value,e[5]=n,e[6]=o,e[7]=a,e[8]=d,e[9]=m,e[10]=p}else p=e[10];return p};function bC(t){let[e]=t;return{codeField:e?.code}}import{c as kC}from"react/compiler-runtime";import{jsx as st}from"react/jsx-runtime";import{FieldContext as _C,FieldPathContext as lc,ServerFunctionsContext as ic,ShimmerEffect as TC,useServerFunctions as wC}from"@payloadcms/ui";import EC,{useEffect as SC,useRef as NC}from"react";var LC=t=>{let e=kC(9),{field:o,initialValue:r,Loading:n,path:l,schemaPath:i,setValue:s,value:u}=t,[c,d]=EC.useState(null),a=wC(),{_internal_renderField:m}=a,[p,f]=i.split("."),h=l??(o&&"name"in o?o?.name:"")??"",x;e[0]!==m||e[1]!==o||e[2]!==r||e[3]!==l||e[4]!==i?(x=()=>{(async function(){let{Field:y}=await m({field:{...o||{},type:"richText",admin:{hidden:!1}},initialValue:r??void 0,path:l,schemaPath:i});d(y)})()},e[0]=m,e[1]=o,e[2]=r,e[3]=l,e[4]=i,e[5]=x):x=e[5];let C=x,T=NC(!1),S,b;if(e[6]!==C?(S=()=>{T.current||(T.current=!0,C())},b=[C],e[6]=C,e[7]=S,e[8]=b):(S=e[7],b=e[8]),SC(S,b),!c)return typeof n<"u"?n:st(TC,{});let k={...a,getFormState:async w=>a.getFormState({...w,collectionSlug:p==="collection"?f:void 0,globalSlug:p==="global"?f:void 0})};if(typeof u>"u"&&!s)return st(ic,{value:{...k},children:st(lc,{value:h,children:c},h)});let g={disabled:!1,formInitializing:!1,formProcessing:!1,formSubmitted:!1,initialValue:u,path:h,setValue:s??yC,showError:!1,value:u};return st(ic,{value:{...k},children:st(lc,{value:h,children:st(_C,{value:g,children:c})},h)})};function yC(){}function RC({nodes:t,text:e}){let o={root:{type:"root",children:[],direction:"ltr",format:"",indent:0,version:1}};return e&&o.root.children.push({type:"paragraph",children:[{type:"text",detail:0,format:0,mode:"normal",style:"",text:e,version:1}],direction:"ltr",format:"",indent:0,textFormat:0,textStyle:"",version:1}),t?.length&&o.root.children.push(...t),o}export{Tt as $createAutoLinkNode,Ae as $createBlockNode,ct as $createInlineBlockNode,Ce as $createLinkNode,je as $createRelationshipNode,Me as $createUploadNode,ke as $isAutoLinkNode,De as $isBlockNode,ut as $isInlineBlockNode,K as $isLinkNode,wr as $isRelationshipNode,it as $isUploadNode,kc as AlignFeatureClient,be as AutoLinkNode,Vx as BlockCollapsible,Xx as BlockEditButton,se as BlockNode,Yx as BlockRemoveButton,Sc as BlockquoteFeatureClient,Iu as BlocksFeatureClient,Qu as BoldFeatureClient,le as CAN_USE_DOM,of as ChecklistFeatureClient,CC as CodeBlockBlockComponent,nC as CodeComponent,Jf as DETAIL_TYPE_TO_DETAIL,Wf as DOUBLE_LINE_BREAK,n0 as DebugJsxConverterFeatureClient,zf as ELEMENT_FORMAT_TO_TYPE,Xf as ELEMENT_TYPE_TO_FORMAT,pc as ENABLE_SLASH_MENU_COMMAND,cc as EditorConfigProvider,dt as FieldsDrawer,N1 as FixedToolbarFeatureClient,Xd as HeadingFeatureClient,mm as HorizontalRuleFeatureClient,Je as INSERT_BLOCK_COMMAND,Xe as INSERT_INLINE_BLOCK_COMMAND,Hf as IS_ALL_FORMATTING,ym as IndentFeatureClient,Wx as InlineBlockContainer,Ax as InlineBlockEditButton,jx as InlineBlockLabel,at as InlineBlockNode,Fx as InlineBlockRemoveButton,nd as InlineCodeFeatureClient,F1 as InlineToolbarFeatureClient,ad as ItalicFeatureClient,Vf as LTR_REGEX,Sf as LexicalPluginToLexicalFeatureClient,Hp as LinkFeatureClient,oe as LinkNode,Uf as NON_BREAKING_SPACE,$ as NodeFormat,df as OrderedListFeatureClient,Df as ParagraphFeatureClient,dc as Point,Gf as RTL_REGEX,fc as Rect,G0 as RelationshipFeatureClient,Te as RelationshipNode,LC as RenderLexical,Ex as RichTextField,vf as SlateToLexicalFeatureClient,pd as StrikethroughFeatureClient,xd as SubscriptFeatureClient,_d as SuperscriptFeatureClient,Zf as TEXT_MODE_TO_TYPE,Kf as TEXT_TYPE_TO_FORMAT,Yf as TEXT_TYPE_TO_MODE,de as TOGGLE_LINK_COMMAND,yg as TableFeatureClient,Gu as TestRecorderFeatureClient,Fd as TextStateFeatureClient,Dt as ToolbarButton,He as ToolbarDropdown,zu as TreeViewFeatureClient,Nd as UnderlineFeatureClient,bf as UnorderedListFeatureClient,fx as UploadFeatureClient,ie as UploadNode,vx as addSwipeDownListener,yx as addSwipeLeftListener,Rx as addSwipeRightListener,Ix as addSwipeUpListener,RC as buildEditorState,Xa as codeConverterClient,tr as createBlockNode,M as createClientFeature,l0 as defaultColors,Io as defaultEditorLexicalConfig,yr as getDOMRangeRect,hc as getEnabledNodes,Qx as getRestPopulateFn,ze as getSelectedNode,Sx as isHTMLElement,mc as isPoint,Nx as joinClasses,zr as sanitizeClientEditorConfig,Ka as sanitizeClientFeatures,bo as setFloatingElemPosition,po as setFloatingElemPositionForLinkEditor,z as slashMenuBasicGroupWithItems,xe as toolbarAddDropdownGroupWithItems,rr as toolbarFeatureButtonsGroupWithItems,Z as toolbarFormatGroupWithItems,ee as toolbarTextDropdownGroupWithItems,ge as useBlockComponentContext,j as useEditorConfigContext,he as useInlineBlockComponentContext,uc as useLexicalDocumentDrawer,fe as useLexicalDrawer,Mt as useLexicalListDrawer};
|
|
66
66
|
//# sourceMappingURL=index.js.map
|