@payloadcms/richtext-lexical 3.0.0-beta.129 → 3.0.0-beta.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/exports/client/{Field-SHUAQNQD.js → Field-GWJ72IYP.js} +2 -2
  2. package/dist/exports/client/{RelationshipComponent-IMM4CFBE.js → RelationshipComponent-2RT3YXUT.js} +2 -2
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/{chunk-352SHIZR.js → chunk-AE5XKHR4.js} +2 -2
  5. package/dist/exports/client/{chunk-PDAZFJVO.js → chunk-CUIBIFW2.js} +1 -1
  6. package/dist/exports/client/chunk-CUIBIFW2.js.map +7 -0
  7. package/dist/exports/client/{chunk-O4IOO4EU.js → chunk-MI5HS4QX.js} +2 -2
  8. package/dist/exports/client/{chunk-75T7MDBH.js → chunk-XDEGE6I5.js} +2 -2
  9. package/dist/exports/client/{chunk-ZOYGBIAN.js → chunk-YGRKYSDC.js} +2 -2
  10. package/dist/exports/client/{component-YE2TDR5O.js → component-YICNYPTU.js} +2 -2
  11. package/dist/exports/client/{component-EHTN2BHZ.js → component-YNHK5J3P.js} +2 -2
  12. package/dist/exports/client/{componentInline-N5LJ2LY2.js → componentInline-6RPSMLNJ.js} +2 -2
  13. package/dist/exports/client/index.js +2 -2
  14. package/dist/field/bundled.css +1 -1
  15. package/dist/field/rscEntry.d.ts +2 -2
  16. package/dist/field/rscEntry.d.ts.map +1 -1
  17. package/dist/field/rscEntry.js +0 -3
  18. package/dist/field/rscEntry.js.map +1 -1
  19. package/dist/lexical/config/client/EditorConfigProvider.d.ts +1 -1
  20. package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  21. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  22. package/package.json +7 -7
  23. package/dist/exports/client/chunk-PDAZFJVO.js.map +0 -7
  24. /package/dist/exports/client/{Field-SHUAQNQD.js.map → Field-GWJ72IYP.js.map} +0 -0
  25. /package/dist/exports/client/{RelationshipComponent-IMM4CFBE.js.map → RelationshipComponent-2RT3YXUT.js.map} +0 -0
  26. /package/dist/exports/client/{chunk-352SHIZR.js.map → chunk-AE5XKHR4.js.map} +0 -0
  27. /package/dist/exports/client/{chunk-O4IOO4EU.js.map → chunk-MI5HS4QX.js.map} +0 -0
  28. /package/dist/exports/client/{chunk-75T7MDBH.js.map → chunk-XDEGE6I5.js.map} +0 -0
  29. /package/dist/exports/client/{chunk-ZOYGBIAN.js.map → chunk-YGRKYSDC.js.map} +0 -0
  30. /package/dist/exports/client/{component-YE2TDR5O.js.map → component-YICNYPTU.js.map} +0 -0
  31. /package/dist/exports/client/{component-EHTN2BHZ.js.map → component-YNHK5J3P.js.map} +0 -0
  32. /package/dist/exports/client/{componentInline-N5LJ2LY2.js.map → componentInline-6RPSMLNJ.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- "use client";import{b as H,c as M,e as ue,f as fe,g as pe,h as ge,i as he}from"./chunk-OOBB5GCO.js";import{a as de,b as R}from"./chunk-PDAZFJVO.js";import{jsx as le,jsxs as se}from"react/jsx-runtime";import{FieldLabel as Wt,useEditDepth as Yt,useField as Ut,withCondition as Vt}from"@payloadcms/ui";import{useCallback as qt}from"react";import{ErrorBoundary as Jt}from"react-error-boundary";import{jsx as B}from"react/jsx-runtime";import{LexicalComposer as Gt}from"@lexical/react/LexicalComposer.js";import*as Ue from"react";import{useMemo as Ye}from"react";import{c as It}from"react/compiler-runtime";import{jsx as w,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Mt}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Bt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Lt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as At}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Dt}from"@lexical/react/LexicalRichTextPlugin.js";import{TabIndentationPlugin as Ft}from"@lexical/react/LexicalTabIndentationPlugin.js";import{BLUR_COMMAND as Ot,COMMAND_PRIORITY_LOW as ze,FOCUS_COMMAND as _t}from"lexical";import*as W from"react";import{useEffect as Ke,useState as Ge}from"react";import{jsx as ye}from"react/jsx-runtime";import"react";var O=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&ye(o.Component,{anchorElem:t,clientProps:e}):o.Component&&ye(o.Component,{clientProps:e});import{jsx as ae}from"react/jsx-runtime";import{useLexicalComposerContext as ot}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as nt}from"lexical";import*as Ce from"react";import{useCallback as rt,useEffect as be,useRef as it,useState as st}from"react";import{createPortal as lt}from"react-dom";var j=(t,e,o,s,r=50,m=25)=>{let d=0;if(t&&!t.contains(s)){let{bottom:c,left:u,right:f,top:h}=t.getBoundingClientRect(),l=h+window.scrollY,n=c+window.scrollY;if(o<l-m||o>n+m||e<u-r||e>f+r)return-1;(e<u||e>f)&&(d=e<u?e-u:e-f)}return d};import{$getNodeByKey as Z}from"lexical";function z(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let s=o.split(",").pop();return e.y=e.y-Number(s?.replace(")","")),e}function X(t){let e=(u,f)=>u?parseFloat(window.getComputedStyle(u)[f]):0,{marginBottom:o,marginTop:s}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),m=e(t.nextElementSibling,"marginTop"),d=Math.max(parseFloat(s),r);return{marginBottom:Math.max(parseFloat(o),m),marginTop:d}}import{$getRoot as Qe}from"lexical";function _(t){return t.getEditorState().read(()=>Qe().getChildrenKeys())}var Xe=1,Ze=-1,xe=0,v={props:null,result:null};function et(t,e,o=20){let s=t.x-e.x,r=t.y-e.y;return s*s+r*r<=o*o}function K(t){let{anchorElem:e,cache_threshold:o=20,editor:s,fuzzy:r=!1,horizontalOffset:m=0,point:{x:d,y:c},startIndex:u=0,useEdgeAsDefault:f=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&et(v.props.point,t.point,o))return v.result;let h=e.getBoundingClientRect(),l=_(s),n={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return s.getEditorState().read(()=>{if(f){let[y,a]=[s.getElementByKey(l[0]),s.getElementByKey(l[l.length-1])];if(y&&a){let[g,i]=[z(y),z(a)];if(c<g.top?(n.blockElem=y,n.distance=g.top-c,n.blockNode=Z(l[0]),n.foundAtIndex=0):c>i.bottom&&(n.distance=c-i.bottom,n.blockNode=Z(l[l.length-1]),n.blockElem=a,n.foundAtIndex=l.length-1),n?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=u,x=xe;for(;p>=0&&p<l.length;){let y=l[p],a=s.getElementByKey(y);if(a===null)break;let g=new M(d+m,c),i=ge.fromDOMRect(z(a)),{marginBottom:E,marginTop:b}=X(a),N=i.generateNewRect({bottom:i.bottom+E,left:h.left,right:h.right,top:i.top-b}),{distance:C,isOnBottomSide:T,isOnTopSide:P}=N.distanceFromPoint(g);if(C===0){n.blockElem=a,n.blockNode=Z(y),n.foundAtIndex=p,n.distance=C,n.blockNode&&n.blockNode.getType()==="paragraph"&&n.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(n.blockElem=null,n.blockNode=null),n.isFoundNodeEmptyParagraph=!0);break}else r&&C<n.distance&&(n.blockElem=a,n.blockNode=Z(y),n.distance=C,n.foundAtIndex=p);x===xe&&(P?x=Ze:T?x=Xe:x=1/0),p+=x}}),v.props=t,v.result={blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph},{blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var tt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ee(t){if(!t||tt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function te(t,e,o,s=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),m=window.getComputedStyle(t),d=e.getBoundingClientRect(),c=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(l=>t.firstElementChild?.classList.contains(l)))u=r.top+8-c.top;else{let l=Ee(t)?parseInt(m.lineHeight,10):0;u=r.top+(l-d.height)/2-c.top}let h=s;e.style.opacity="1",e.style.transform=`translate(${h}px, ${u}px)`}var at="add-block-menu",oe=1/0;function ct(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function mt(t,e,o){let s=e.parentElement,{editorConfig:r}=R(),m=r?.admin?.hideGutter?-24:12,d=it(null),[c,u]=st(null);be(()=>{function h(l){let n=l.target;if(!H(n))return;let p=j(s,l.pageX,l.pageY,n);if(p===-1){u(null);return}if(ee(n,at))return;let x=_(t),{blockElem:y,blockNode:a,foundAtIndex:g}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new M(l.x,l.y),returnEmptyParagraphs:!0,startIndex:ct(x.length),useEdgeAsDefault:!1});oe=g,y&&a&&(c?.node!==a||c?.elem!==y)&&u({elem:y,node:a})}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[s,e,t,c]),be(()=>{d.current&&c?.node&&te(c?.elem,d.current,e,m)},[e,c,m]);let f=rt(h=>{let l=c;l?.node&&(t.update(()=>{let n=!0;if((l?.node.getType()!=="paragraph"||l.node.getTextContent()!=="")&&(n=!1),!n){let p=nt();l?.node.insertAfter(p),setTimeout(()=>{l={elem:t.getElementByKey(p.getKey()),node:p},u(l)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),l?.node&&"select"in l.node&&typeof l.node.select=="function"&&l.node.select()})},1),setTimeout(()=>{t.dispatchCommand(fe,{node:l?.node})},2),h.stopPropagation(),h.preventDefault())},[t,c]);return lt(ae(Ce.Fragment,{children:ae("button",{className:"icon add-block-menu",onClick:h=>{f(h)},ref:d,type:"button",children:ae("div",{className:o?"icon":""})})}),e)}function Ne(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[s]=ot();return mt(s,o,s._editable)}import{jsx as ne,jsxs as ut}from"react/jsx-runtime";import{useLexicalComposerContext as ft}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Re,$getNodeByKey as pt}from"lexical";import*as Me from"react";import{useEffect as ce,useRef as re,useState as Te}from"react";import{createPortal as gt}from"react-dom";var Pe=0,dt=-24;var $=0;function we(t,e,o,s,r,m,d,c,u,f=!1){let{height:h,top:l}=s.getBoundingClientRect(),{top:n,width:p}=d.getBoundingClientRect(),{marginBottom:x,marginTop:y}=X(s),a=l,g=m>=l+h/2+window.scrollY,i=!1;if(r?.elem)if(s!==r?.elem)(g&&r?.elem&&r?.elem===s.nextElementSibling||!g&&r?.elem&&r?.elem===s.previousElementSibling)&&($++,$<200&&(i=!0));else{$++;let C=r?.boundingBox?.y,T=s.getBoundingClientRect().y;(g===r?.isBelow&&C===T||$<200)&&(i=!1)}if(i)return{isBelow:g,willStayInSamePosition:i};f?a+=h/2:g?a+=h+x/2:a-=y/2;let E=0;f||(g?E=-Pe:E=Pe);let b=a-n+E,N=dt-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===s?g?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),$=0,{isBelow:g,willStayInSamePosition:i}}var ht="draggable-block-menu",Se="application/x-lexical-drag-block",V=1/0;function ve(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function yt(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Ie(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function xt(t,e,o){let s=e.parentElement,r=re(null),m=re(null),d=re(null),c=re(!1),[u,f]=Te(null),[h,l]=Te(null),{editorConfig:n}=R(),p=n?.admin?.hideGutter?-44:-8;ce(()=>{function a(g){let i=g.target;if(!H(i))return;let E=j(s,g.pageX,g.pageY,i);if(E===-1){f(null);return}if(ee(i,ht))return;let b=_(t),{blockElem:N,foundAtIndex:C,isFoundNodeEmptyParagraph:T}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new M(g.x,g.y),startIndex:ve(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!N&&!T)&&u!==N&&f(N)}return document?.addEventListener("mousemove",a),()=>{document?.removeEventListener("mousemove",a)}},[s,e,t,u]),ce(()=>{r.current&&te(u,r.current,e,p)},[e,u,p]),ce(()=>{function a(i){if(!c.current)return!1;let[E]=ke(i);if(E)return!1;let{pageY:b,target:N}=i;if(!H(N))return!1;let C=j(s,i.pageX,i.pageY,N,100,50),T=_(t),{blockElem:P,foundAtIndex:Y,isFoundNodeEmptyParagraph:L}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new M(i.x,i.y),startIndex:ve(T.length),useEdgeAsDefault:!0,verbose:!0});V=Y;let A=m.current;if(P===null||A===null)return!1;if(u!==P){let{isBelow:S,willStayInSamePosition:U}=we(n?.admin?.hideGutter?"0px":"3rem",p+(n?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),A,P,h,b,e,i,d,L);i.preventDefault(),U||l({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:S})}else h?.elem&&(Ie(A,h.elem),l({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:!1}));return!0}function g(i){if(!c.current)return!1;let[E]=ke(i);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=i,T=b?.getData(Se)||"";return t.update(()=>{let P=pt(T);if(!P||!H(C))return!1;let Y=j(s,i.pageX,i.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:A}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-Y,point:new M(i.x,i.y),useEdgeAsDefault:!0});if(!L)return!1;let S=Re(L);if(!S)return!1;if(S===P)return!0;let{height:U,top:J}=z(L),D=N>=J+U/2+window.scrollY;A?(S.insertBefore(P),S.remove()):D?S.insertAfter(P):S.insertBefore(P),u!==null&&f(null),document.querySelectorAll(".lexical-block-highlighter").forEach(F=>{F.remove()});let Je=t.getElementByKey(P.getKey());setTimeout(()=>{let F=Je?.getBoundingClientRect();if(!F)return;let k=document.createElement("div");k.className="lexical-block-highlighter",k.style.backgroundColor="var(--theme-elevation-1000",k.style.transition="opacity 0.5s ease-in-out",k.style.zIndex="1",k.style.pointerEvents="none",k.style.boxSizing="border-box",k.style.borderRadius="4px",k.style.position="absolute",document.body.appendChild(k),k.style.opacity="0.1",k.style.height=`${F.height+8}px`,k.style.width=`${F.width+8}px`,k.style.top=`${F.top+window.scrollY-4}px`,k.style.left=`${F.left-4}px`,setTimeout(()=>{k.style.opacity="0",setTimeout(()=>{k.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",a),document.addEventListener("drop",g),()=>{document.removeEventListener("dragover",a),document.removeEventListener("drop",g)}},[s,p,e,t,h,u,n?.admin?.hideGutter]);function x(a){let g=a.dataTransfer;if(!g||!u)return;yt(g,u);let i="";t.update(()=>{let E=Re(u);E&&(i=E.getKey())}),c.current=!0,g.setData(Se,i)}function y(){c.current=!1,h?.elem&&Ie(m.current,h?.elem)}return gt(ut(Me.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:y,onDragStart:x,ref:r,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:m}),ne("div",{className:"debug-highlight",ref:d})]}),e)}function Be(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[s]=ft();return xt(s,o,s._editable)}import{c as Et}from"react/compiler-runtime";import{jsx as bt}from"react/jsx-runtime";import{MarkdownShortcutPlugin as Ct}from"@lexical/react/LexicalMarkdownShortcutPlugin.js";import"react";var Le=()=>{let t=Et(2),{editorConfig:e}=R(),o;return t[0]!==e.features.markdownTransformers?(o=bt(Ct,{transformers:e.features.markdownTransformers}),t[0]=e.features.markdownTransformers,t[1]=o):o=t[1],o};import{jsx as G,jsxs as Fe}from"react/jsx-runtime";import{useLexicalComposerContext as Pt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as Oe}from"@payloadcms/ui";import{useCallback as De,useMemo as wt,useState as kt}from"react";import"react";import*as _e from"react-dom";import{c as Nt}from"react/compiler-runtime";import"react";function Ae(t,e){let o=Nt(4),{maxLength:s,minLength:r}=e,m=s===void 0?75:s,d=r===void 0?1:r,c;return o[0]!==t||o[1]!==m||o[2]!==d?(c=u=>{let{query:f}=u,h="[^"+t+ue+"\\s]",n=new RegExp("(^|\\s|\\()(["+t+"]((?:"+h+"){0,"+m+"}))$").exec(f);if(n!==null){let p=n[1],x=n[3];if(x.length>=d)return{leadOffset:n.index+p.length,matchingString:x,replaceableString:n[2]}}return null},o[0]=t,o[1]=m,o[2]=d,o[3]=c):c=o[3],c}var I="slash-menu-popup";function Rt({isSelected:t,item:e,onClick:o,onMouseEnter:s}){let{fieldProps:{featureClientSchemaMap:r,schemaPath:m}}=R(),{i18n:d}=Oe(),c=`${I}__item ${I}__item-${e.key}`;t&&(c+=` ${I}__item--selected`);let u=e.key;return e.label&&(u=typeof e.label=="function"?e.label({featureClientSchemaMap:r,i18n:d,schemaPath:m}):e.label),u.length>25&&(u=u.substring(0,25)+"..."),Fe("button",{"aria-selected":t,className:c,id:I+"__item-"+e.key,onClick:o,onMouseEnter:s,ref:f=>{e.ref={current:f}},role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&G(e.Icon,{}),G("span",{className:`${I}__item-text`,children:u})]},e.key)}function $e({anchorElem:t=document.body}){let[e]=Pt(),[o,s]=kt(null),{editorConfig:r}=R(),{i18n:m}=Oe(),{fieldProps:{featureClientSchemaMap:d,schemaPath:c}}=R(),u=Ae("/",{minLength:0}),f=De(()=>{let n=[];for(let p of r.features.slashMenu.dynamicGroups)if(o){let x=p({editor:e,queryString:o});n=n.concat(x)}return n},[e,o,r?.features]),h=wt(()=>{let n=[];for(let p of r?.features.slashMenu.groups??[])n.push(p);if(o){n=n.map(x=>{let y=x.items.filter(a=>{let g=a.key;return a.label&&(g=typeof a.label=="function"?a.label({featureClientSchemaMap:d,i18n:m,schemaPath:c}):a.label),new RegExp(o,"gi").exec(g)?!0:a.keywords!=null?a.keywords.some(i=>new RegExp(o,"gi").exec(i)):!1});return y.length?{...x,items:y}:null}),n=n.filter(x=>x!=null);let p=f();for(let x of p){let y=n.find(a=>a.key===x.key);y?n=n.filter(a=>a.key!==x.key):y={...x,items:[]},y?.items?.length&&(y.items=y.items.concat(y.items)),n.push(y)}}return n},[o,r?.features.slashMenu.groups,f,d,m,c]),l=De((n,p,x)=>{p(),n.onSelect({editor:e,queryString:x})},[e]);return G(pe,{anchorElem:t,groups:h,menuRenderFn:(n,{selectedItemKey:p,selectItemAndCleanUp:x,setSelectedItemKey:y})=>n.current&&h.length?_e.createPortal(G("div",{className:I,children:h.map(a=>{let g=a.key;return a.label&&d&&(g=typeof a.label=="function"?a.label({featureClientSchemaMap:d,i18n:m,schemaPath:c}):a.label),Fe("div",{className:`${I}__group ${I}__group-${a.key}`,children:[G("div",{className:`${I}__group-title`,children:g}),a.items.map((i,E)=>G(Rt,{index:E,isSelected:p===i.key,item:i,onClick:()=>{y(i.key),x(i)},onMouseEnter:()=>{y(i.key)}},i.key))]},a.key)})}),n.current):null,onQueryChange:s,onSelectItem:l,triggerFn:u})}import{c as Tt}from"react/compiler-runtime";import{jsx as He}from"react/jsx-runtime";import{ContentEditable as St}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as vt}from"@payloadcms/ui";import"react";function je(t){let e=Tt(3),{className:o}=t,{t:s}=vt(),r;return e[0]!==s||e[1]!==o?(r=He(St,{"aria-placeholder":s("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:He("p",{className:"editor-placeholder",children:s("lexical:general:placeholder")})}),e[0]=s,e[1]=o,e[2]=r):r=e[2],r}var We=t=>{let e=It(22),{editorConfig:o,editorContainerRef:s,onChange:r}=t,m=R(),[d]=Mt(),[c,u]=Ge(null),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=i=>{i!==null&&u(i)},e[0]=f):f=e[0];let h=f,l,n;e[1]!==m||e[2]!==d?(l=()=>{if(!m?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}m?.parentEditor?.uuid&&m.parentEditor?.registerChild(m.uuid,m);let i=()=>{m.focusEditor(m)},E=()=>{m.blurEditor(m)},b=d.registerCommand(_t,()=>(i(),!0),ze),N=d.registerCommand(Ot,()=>(E(),!0),ze);return()=>{b(),N(),m.parentEditor?.unregisterChild?.(m.uuid)}},n=[d,m],e[1]=m,e[2]=d,e[3]=l,e[4]=n):(l=e[3],n=e[4]),Ke(l,n);let[p,x]=Ge(!1),y,a;e[5]!==p?(y=()=>{let i=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==p&&x(E)};return i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},a=[p],e[5]=p,e[6]=y,e[7]=a):(y=e[6],a=e[7]),Ke(y,a);let g;if(e[8]!==o.features||e[9]!==r||e[10]!==c||e[11]!==p||e[12]!==d||e[13]!==s){let i;e[15]!==r?(i=(b,N,C)=>{(!C.has("focus")||C.size>1)&&r?.(b,N,C)},e[15]=r,e[16]=i):i=e[16];let E;e[17]!==c||e[18]!==p||e[19]!==d||e[20]!==o?(E=c&&q(W.Fragment,{children:[!p&&d.isEditable()&&q(W.Fragment,{children:[w(Be,{anchorElem:c}),w(Ne,{anchorElem:c})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&p))return w(O,{anchorElem:c,clientProps:b.clientProps,plugin:b},b.key)}),d.isEditable()&&w(W.Fragment,{children:w($e,{anchorElem:c})})]}),e[17]=c,e[18]=p,e[19]=d,e[20]=o,e[21]=E):E=e[21],g=q(W.Fragment,{children:[o.features.plugins?.map($t),q("div",{className:"editor-container",ref:s,children:[o.features.plugins?.map(Ht),w(Dt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:h,children:w(je,{})})}),ErrorBoundary:Bt}),w(At,{ignoreSelectionChange:!0,onChange:i}),E,d.isEditable()&&q(W.Fragment,{children:[w(Lt,{}),o?.features?.markdownTransformers?.length>0&&w(Le,{})]}),w(Ft,{}),o.features.plugins?.map(jt),o.features.plugins?.map(zt)]}),o.features.plugins?.map(Kt)]}),e[8]=o.features,e[9]=r,e[10]=c,e[11]=p,e[12]=d,e[13]=s,e[14]=g}else g=e[14];return g};function $t(t){if(t.position==="aboveContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Ht(t){if(t.position==="top")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function jt(t){if(t.position==="normal")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function zt(t){if(t.position==="bottom")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Kt(t){if(t.position==="belowContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}var Ve=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?B(o,{children:B(Ve,{providers:e.slice(1),children:t})}):B(o,{children:t})},qe=t=>{let{composerKey:e,editorConfig:o,fieldProps:s,onChange:r,readOnly:m,value:d}=t,c=R(),u=Ue.useRef(null),f=Ye(()=>{let l=d;return o?.features?.hooks?.load?.length&&o.features.hooks.load.forEach(n=>{l=n({incomingEditorState:l})}),l},[o,d]),h=Ye(()=>{if(f&&typeof f!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(f));if(f&&Array.isArray(f)&&!("root"in f))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/beta/lexical/migration#migration-via-migration-script-recommended");if(f&&"jsonContent"in f)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/beta/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:m!==!0,editorState:f!=null?JSON.stringify(f):void 0,namespace:o.lexical.namespace,nodes:he({editorConfig:o}),onError:l=>{throw l},theme:o.lexical.theme}},[o,f,m]);return h?B(Gt,{initialConfig:h,children:B(de,{editorConfig:o,editorContainerRef:u,fieldProps:s,parentContext:c,children:B(Ve,{providers:o.features.providers,children:B(We,{editorConfig:o,editorContainerRef:u,onChange:r})})})},e+h.editable):B("p",{children:"Loading..."})};import"./bundled.css";var ie="rich-text-lexical",Qt=t=>{let{editorConfig:e,field:{name:o,admin:{className:s,readOnly:r,style:m,width:d}={},label:c,localized:u,required:f},path:h,readOnly:l,validate:n}=t,p=l||r,x=h??o,y=Yt(),a=qt((Q,D)=>{if(typeof n=="function")return n(Q,{...D,props:t,required:f})},[n,f]),{customComponents:{AfterInput:g,BeforeInput:i,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:T,initialValue:P,setValue:Y,showError:L,value:A}=Ut({path:x,validate:a}),S=p||T||C,U=[ie,"field-type",s,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${y}`;return se("div",{className:U,style:{...m,width:d},children:[b,N||le(Wt,{label:c,localized:u,required:f}),se("div",{className:`${ie}__wrap`,children:[se(Jt,{fallbackRender:Xt,onReset:()=>{},children:[i,le(qe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:Q=>{let D=Q.toJSON();e?.features?.hooks?.save?.length&&e.features.hooks.save.forEach(me=>{D=me({incomingEditorState:D})}),Y(D)},readOnly:S,value:A},JSON.stringify({initialValue:P,path:x})),g]}),E]})]},J)};function Xt({error:t}){return se("div",{className:"errorBoundary",role:"alert",children:[le("p",{children:"Something went wrong:"}),le("pre",{style:{color:"red"},children:t.message})]})}var ir=Vt(Qt);export{ir as RichText};
2
- //# sourceMappingURL=Field-SHUAQNQD.js.map
1
+ "use client";import{b as H,c as M,e as ue,f as fe,g as pe,h as ge,i as he}from"./chunk-OOBB5GCO.js";import{a as de,b as R}from"./chunk-CUIBIFW2.js";import{jsx as le,jsxs as se}from"react/jsx-runtime";import{FieldLabel as Wt,useEditDepth as Yt,useField as Ut,withCondition as Vt}from"@payloadcms/ui";import{useCallback as qt}from"react";import{ErrorBoundary as Jt}from"react-error-boundary";import{jsx as B}from"react/jsx-runtime";import{LexicalComposer as Gt}from"@lexical/react/LexicalComposer.js";import*as Ue from"react";import{useMemo as Ye}from"react";import{c as It}from"react/compiler-runtime";import{jsx as w,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Mt}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Bt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Lt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as At}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Dt}from"@lexical/react/LexicalRichTextPlugin.js";import{TabIndentationPlugin as Ft}from"@lexical/react/LexicalTabIndentationPlugin.js";import{BLUR_COMMAND as Ot,COMMAND_PRIORITY_LOW as ze,FOCUS_COMMAND as _t}from"lexical";import*as W from"react";import{useEffect as Ke,useState as Ge}from"react";import{jsx as ye}from"react/jsx-runtime";import"react";var O=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&ye(o.Component,{anchorElem:t,clientProps:e}):o.Component&&ye(o.Component,{clientProps:e});import{jsx as ae}from"react/jsx-runtime";import{useLexicalComposerContext as ot}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as nt}from"lexical";import*as Ce from"react";import{useCallback as rt,useEffect as be,useRef as it,useState as st}from"react";import{createPortal as lt}from"react-dom";var j=(t,e,o,s,r=50,m=25)=>{let d=0;if(t&&!t.contains(s)){let{bottom:c,left:u,right:f,top:h}=t.getBoundingClientRect(),l=h+window.scrollY,n=c+window.scrollY;if(o<l-m||o>n+m||e<u-r||e>f+r)return-1;(e<u||e>f)&&(d=e<u?e-u:e-f)}return d};import{$getNodeByKey as Z}from"lexical";function z(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let s=o.split(",").pop();return e.y=e.y-Number(s?.replace(")","")),e}function X(t){let e=(u,f)=>u?parseFloat(window.getComputedStyle(u)[f]):0,{marginBottom:o,marginTop:s}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),m=e(t.nextElementSibling,"marginTop"),d=Math.max(parseFloat(s),r);return{marginBottom:Math.max(parseFloat(o),m),marginTop:d}}import{$getRoot as Qe}from"lexical";function _(t){return t.getEditorState().read(()=>Qe().getChildrenKeys())}var Xe=1,Ze=-1,xe=0,v={props:null,result:null};function et(t,e,o=20){let s=t.x-e.x,r=t.y-e.y;return s*s+r*r<=o*o}function K(t){let{anchorElem:e,cache_threshold:o=20,editor:s,fuzzy:r=!1,horizontalOffset:m=0,point:{x:d,y:c},startIndex:u=0,useEdgeAsDefault:f=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&et(v.props.point,t.point,o))return v.result;let h=e.getBoundingClientRect(),l=_(s),n={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return s.getEditorState().read(()=>{if(f){let[y,a]=[s.getElementByKey(l[0]),s.getElementByKey(l[l.length-1])];if(y&&a){let[g,i]=[z(y),z(a)];if(c<g.top?(n.blockElem=y,n.distance=g.top-c,n.blockNode=Z(l[0]),n.foundAtIndex=0):c>i.bottom&&(n.distance=c-i.bottom,n.blockNode=Z(l[l.length-1]),n.blockElem=a,n.foundAtIndex=l.length-1),n?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=u,x=xe;for(;p>=0&&p<l.length;){let y=l[p],a=s.getElementByKey(y);if(a===null)break;let g=new M(d+m,c),i=ge.fromDOMRect(z(a)),{marginBottom:E,marginTop:b}=X(a),N=i.generateNewRect({bottom:i.bottom+E,left:h.left,right:h.right,top:i.top-b}),{distance:C,isOnBottomSide:T,isOnTopSide:P}=N.distanceFromPoint(g);if(C===0){n.blockElem=a,n.blockNode=Z(y),n.foundAtIndex=p,n.distance=C,n.blockNode&&n.blockNode.getType()==="paragraph"&&n.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(n.blockElem=null,n.blockNode=null),n.isFoundNodeEmptyParagraph=!0);break}else r&&C<n.distance&&(n.blockElem=a,n.blockNode=Z(y),n.distance=C,n.foundAtIndex=p);x===xe&&(P?x=Ze:T?x=Xe:x=1/0),p+=x}}),v.props=t,v.result={blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph},{blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var tt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ee(t){if(!t||tt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function te(t,e,o,s=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),m=window.getComputedStyle(t),d=e.getBoundingClientRect(),c=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(l=>t.firstElementChild?.classList.contains(l)))u=r.top+8-c.top;else{let l=Ee(t)?parseInt(m.lineHeight,10):0;u=r.top+(l-d.height)/2-c.top}let h=s;e.style.opacity="1",e.style.transform=`translate(${h}px, ${u}px)`}var at="add-block-menu",oe=1/0;function ct(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function mt(t,e,o){let s=e.parentElement,{editorConfig:r}=R(),m=r?.admin?.hideGutter?-24:12,d=it(null),[c,u]=st(null);be(()=>{function h(l){let n=l.target;if(!H(n))return;let p=j(s,l.pageX,l.pageY,n);if(p===-1){u(null);return}if(ee(n,at))return;let x=_(t),{blockElem:y,blockNode:a,foundAtIndex:g}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new M(l.x,l.y),returnEmptyParagraphs:!0,startIndex:ct(x.length),useEdgeAsDefault:!1});oe=g,y&&a&&(c?.node!==a||c?.elem!==y)&&u({elem:y,node:a})}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[s,e,t,c]),be(()=>{d.current&&c?.node&&te(c?.elem,d.current,e,m)},[e,c,m]);let f=rt(h=>{let l=c;l?.node&&(t.update(()=>{let n=!0;if((l?.node.getType()!=="paragraph"||l.node.getTextContent()!=="")&&(n=!1),!n){let p=nt();l?.node.insertAfter(p),setTimeout(()=>{l={elem:t.getElementByKey(p.getKey()),node:p},u(l)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),l?.node&&"select"in l.node&&typeof l.node.select=="function"&&l.node.select()})},1),setTimeout(()=>{t.dispatchCommand(fe,{node:l?.node})},2),h.stopPropagation(),h.preventDefault())},[t,c]);return lt(ae(Ce.Fragment,{children:ae("button",{className:"icon add-block-menu",onClick:h=>{f(h)},ref:d,type:"button",children:ae("div",{className:o?"icon":""})})}),e)}function Ne(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[s]=ot();return mt(s,o,s._editable)}import{jsx as ne,jsxs as ut}from"react/jsx-runtime";import{useLexicalComposerContext as ft}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Re,$getNodeByKey as pt}from"lexical";import*as Me from"react";import{useEffect as ce,useRef as re,useState as Te}from"react";import{createPortal as gt}from"react-dom";var Pe=0,dt=-24;var $=0;function we(t,e,o,s,r,m,d,c,u,f=!1){let{height:h,top:l}=s.getBoundingClientRect(),{top:n,width:p}=d.getBoundingClientRect(),{marginBottom:x,marginTop:y}=X(s),a=l,g=m>=l+h/2+window.scrollY,i=!1;if(r?.elem)if(s!==r?.elem)(g&&r?.elem&&r?.elem===s.nextElementSibling||!g&&r?.elem&&r?.elem===s.previousElementSibling)&&($++,$<200&&(i=!0));else{$++;let C=r?.boundingBox?.y,T=s.getBoundingClientRect().y;(g===r?.isBelow&&C===T||$<200)&&(i=!1)}if(i)return{isBelow:g,willStayInSamePosition:i};f?a+=h/2:g?a+=h+x/2:a-=y/2;let E=0;f||(g?E=-Pe:E=Pe);let b=a-n+E,N=dt-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===s?g?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),$=0,{isBelow:g,willStayInSamePosition:i}}var ht="draggable-block-menu",Se="application/x-lexical-drag-block",V=1/0;function ve(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function yt(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Ie(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function xt(t,e,o){let s=e.parentElement,r=re(null),m=re(null),d=re(null),c=re(!1),[u,f]=Te(null),[h,l]=Te(null),{editorConfig:n}=R(),p=n?.admin?.hideGutter?-44:-8;ce(()=>{function a(g){let i=g.target;if(!H(i))return;let E=j(s,g.pageX,g.pageY,i);if(E===-1){f(null);return}if(ee(i,ht))return;let b=_(t),{blockElem:N,foundAtIndex:C,isFoundNodeEmptyParagraph:T}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new M(g.x,g.y),startIndex:ve(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!N&&!T)&&u!==N&&f(N)}return document?.addEventListener("mousemove",a),()=>{document?.removeEventListener("mousemove",a)}},[s,e,t,u]),ce(()=>{r.current&&te(u,r.current,e,p)},[e,u,p]),ce(()=>{function a(i){if(!c.current)return!1;let[E]=ke(i);if(E)return!1;let{pageY:b,target:N}=i;if(!H(N))return!1;let C=j(s,i.pageX,i.pageY,N,100,50),T=_(t),{blockElem:P,foundAtIndex:Y,isFoundNodeEmptyParagraph:L}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new M(i.x,i.y),startIndex:ve(T.length),useEdgeAsDefault:!0,verbose:!0});V=Y;let A=m.current;if(P===null||A===null)return!1;if(u!==P){let{isBelow:S,willStayInSamePosition:U}=we(n?.admin?.hideGutter?"0px":"3rem",p+(n?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),A,P,h,b,e,i,d,L);i.preventDefault(),U||l({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:S})}else h?.elem&&(Ie(A,h.elem),l({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:!1}));return!0}function g(i){if(!c.current)return!1;let[E]=ke(i);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=i,T=b?.getData(Se)||"";return t.update(()=>{let P=pt(T);if(!P||!H(C))return!1;let Y=j(s,i.pageX,i.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:A}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-Y,point:new M(i.x,i.y),useEdgeAsDefault:!0});if(!L)return!1;let S=Re(L);if(!S)return!1;if(S===P)return!0;let{height:U,top:J}=z(L),D=N>=J+U/2+window.scrollY;A?(S.insertBefore(P),S.remove()):D?S.insertAfter(P):S.insertBefore(P),u!==null&&f(null),document.querySelectorAll(".lexical-block-highlighter").forEach(F=>{F.remove()});let Je=t.getElementByKey(P.getKey());setTimeout(()=>{let F=Je?.getBoundingClientRect();if(!F)return;let k=document.createElement("div");k.className="lexical-block-highlighter",k.style.backgroundColor="var(--theme-elevation-1000",k.style.transition="opacity 0.5s ease-in-out",k.style.zIndex="1",k.style.pointerEvents="none",k.style.boxSizing="border-box",k.style.borderRadius="4px",k.style.position="absolute",document.body.appendChild(k),k.style.opacity="0.1",k.style.height=`${F.height+8}px`,k.style.width=`${F.width+8}px`,k.style.top=`${F.top+window.scrollY-4}px`,k.style.left=`${F.left-4}px`,setTimeout(()=>{k.style.opacity="0",setTimeout(()=>{k.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",a),document.addEventListener("drop",g),()=>{document.removeEventListener("dragover",a),document.removeEventListener("drop",g)}},[s,p,e,t,h,u,n?.admin?.hideGutter]);function x(a){let g=a.dataTransfer;if(!g||!u)return;yt(g,u);let i="";t.update(()=>{let E=Re(u);E&&(i=E.getKey())}),c.current=!0,g.setData(Se,i)}function y(){c.current=!1,h?.elem&&Ie(m.current,h?.elem)}return gt(ut(Me.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:y,onDragStart:x,ref:r,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:m}),ne("div",{className:"debug-highlight",ref:d})]}),e)}function Be(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[s]=ft();return xt(s,o,s._editable)}import{c as Et}from"react/compiler-runtime";import{jsx as bt}from"react/jsx-runtime";import{MarkdownShortcutPlugin as Ct}from"@lexical/react/LexicalMarkdownShortcutPlugin.js";import"react";var Le=()=>{let t=Et(2),{editorConfig:e}=R(),o;return t[0]!==e.features.markdownTransformers?(o=bt(Ct,{transformers:e.features.markdownTransformers}),t[0]=e.features.markdownTransformers,t[1]=o):o=t[1],o};import{jsx as G,jsxs as Fe}from"react/jsx-runtime";import{useLexicalComposerContext as Pt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as Oe}from"@payloadcms/ui";import{useCallback as De,useMemo as wt,useState as kt}from"react";import"react";import*as _e from"react-dom";import{c as Nt}from"react/compiler-runtime";import"react";function Ae(t,e){let o=Nt(4),{maxLength:s,minLength:r}=e,m=s===void 0?75:s,d=r===void 0?1:r,c;return o[0]!==t||o[1]!==m||o[2]!==d?(c=u=>{let{query:f}=u,h="[^"+t+ue+"\\s]",n=new RegExp("(^|\\s|\\()(["+t+"]((?:"+h+"){0,"+m+"}))$").exec(f);if(n!==null){let p=n[1],x=n[3];if(x.length>=d)return{leadOffset:n.index+p.length,matchingString:x,replaceableString:n[2]}}return null},o[0]=t,o[1]=m,o[2]=d,o[3]=c):c=o[3],c}var I="slash-menu-popup";function Rt({isSelected:t,item:e,onClick:o,onMouseEnter:s}){let{fieldProps:{featureClientSchemaMap:r,schemaPath:m}}=R(),{i18n:d}=Oe(),c=`${I}__item ${I}__item-${e.key}`;t&&(c+=` ${I}__item--selected`);let u=e.key;return e.label&&(u=typeof e.label=="function"?e.label({featureClientSchemaMap:r,i18n:d,schemaPath:m}):e.label),u.length>25&&(u=u.substring(0,25)+"..."),Fe("button",{"aria-selected":t,className:c,id:I+"__item-"+e.key,onClick:o,onMouseEnter:s,ref:f=>{e.ref={current:f}},role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&G(e.Icon,{}),G("span",{className:`${I}__item-text`,children:u})]},e.key)}function $e({anchorElem:t=document.body}){let[e]=Pt(),[o,s]=kt(null),{editorConfig:r}=R(),{i18n:m}=Oe(),{fieldProps:{featureClientSchemaMap:d,schemaPath:c}}=R(),u=Ae("/",{minLength:0}),f=De(()=>{let n=[];for(let p of r.features.slashMenu.dynamicGroups)if(o){let x=p({editor:e,queryString:o});n=n.concat(x)}return n},[e,o,r?.features]),h=wt(()=>{let n=[];for(let p of r?.features.slashMenu.groups??[])n.push(p);if(o){n=n.map(x=>{let y=x.items.filter(a=>{let g=a.key;return a.label&&(g=typeof a.label=="function"?a.label({featureClientSchemaMap:d,i18n:m,schemaPath:c}):a.label),new RegExp(o,"gi").exec(g)?!0:a.keywords!=null?a.keywords.some(i=>new RegExp(o,"gi").exec(i)):!1});return y.length?{...x,items:y}:null}),n=n.filter(x=>x!=null);let p=f();for(let x of p){let y=n.find(a=>a.key===x.key);y?n=n.filter(a=>a.key!==x.key):y={...x,items:[]},y?.items?.length&&(y.items=y.items.concat(y.items)),n.push(y)}}return n},[o,r?.features.slashMenu.groups,f,d,m,c]),l=De((n,p,x)=>{p(),n.onSelect({editor:e,queryString:x})},[e]);return G(pe,{anchorElem:t,groups:h,menuRenderFn:(n,{selectedItemKey:p,selectItemAndCleanUp:x,setSelectedItemKey:y})=>n.current&&h.length?_e.createPortal(G("div",{className:I,children:h.map(a=>{let g=a.key;return a.label&&d&&(g=typeof a.label=="function"?a.label({featureClientSchemaMap:d,i18n:m,schemaPath:c}):a.label),Fe("div",{className:`${I}__group ${I}__group-${a.key}`,children:[G("div",{className:`${I}__group-title`,children:g}),a.items.map((i,E)=>G(Rt,{index:E,isSelected:p===i.key,item:i,onClick:()=>{y(i.key),x(i)},onMouseEnter:()=>{y(i.key)}},i.key))]},a.key)})}),n.current):null,onQueryChange:s,onSelectItem:l,triggerFn:u})}import{c as Tt}from"react/compiler-runtime";import{jsx as He}from"react/jsx-runtime";import{ContentEditable as St}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as vt}from"@payloadcms/ui";import"react";function je(t){let e=Tt(3),{className:o}=t,{t:s}=vt(),r;return e[0]!==s||e[1]!==o?(r=He(St,{"aria-placeholder":s("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:He("p",{className:"editor-placeholder",children:s("lexical:general:placeholder")})}),e[0]=s,e[1]=o,e[2]=r):r=e[2],r}var We=t=>{let e=It(22),{editorConfig:o,editorContainerRef:s,onChange:r}=t,m=R(),[d]=Mt(),[c,u]=Ge(null),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=i=>{i!==null&&u(i)},e[0]=f):f=e[0];let h=f,l,n;e[1]!==m||e[2]!==d?(l=()=>{if(!m?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}m?.parentEditor?.uuid&&m.parentEditor?.registerChild(m.uuid,m);let i=()=>{m.focusEditor(m)},E=()=>{m.blurEditor(m)},b=d.registerCommand(_t,()=>(i(),!0),ze),N=d.registerCommand(Ot,()=>(E(),!0),ze);return()=>{b(),N(),m.parentEditor?.unregisterChild?.(m.uuid)}},n=[d,m],e[1]=m,e[2]=d,e[3]=l,e[4]=n):(l=e[3],n=e[4]),Ke(l,n);let[p,x]=Ge(!1),y,a;e[5]!==p?(y=()=>{let i=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==p&&x(E)};return i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},a=[p],e[5]=p,e[6]=y,e[7]=a):(y=e[6],a=e[7]),Ke(y,a);let g;if(e[8]!==o.features||e[9]!==r||e[10]!==c||e[11]!==p||e[12]!==d||e[13]!==s){let i;e[15]!==r?(i=(b,N,C)=>{(!C.has("focus")||C.size>1)&&r?.(b,N,C)},e[15]=r,e[16]=i):i=e[16];let E;e[17]!==c||e[18]!==p||e[19]!==d||e[20]!==o?(E=c&&q(W.Fragment,{children:[!p&&d.isEditable()&&q(W.Fragment,{children:[w(Be,{anchorElem:c}),w(Ne,{anchorElem:c})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&p))return w(O,{anchorElem:c,clientProps:b.clientProps,plugin:b},b.key)}),d.isEditable()&&w(W.Fragment,{children:w($e,{anchorElem:c})})]}),e[17]=c,e[18]=p,e[19]=d,e[20]=o,e[21]=E):E=e[21],g=q(W.Fragment,{children:[o.features.plugins?.map($t),q("div",{className:"editor-container",ref:s,children:[o.features.plugins?.map(Ht),w(Dt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:h,children:w(je,{})})}),ErrorBoundary:Bt}),w(At,{ignoreSelectionChange:!0,onChange:i}),E,d.isEditable()&&q(W.Fragment,{children:[w(Lt,{}),o?.features?.markdownTransformers?.length>0&&w(Le,{})]}),w(Ft,{}),o.features.plugins?.map(jt),o.features.plugins?.map(zt)]}),o.features.plugins?.map(Kt)]}),e[8]=o.features,e[9]=r,e[10]=c,e[11]=p,e[12]=d,e[13]=s,e[14]=g}else g=e[14];return g};function $t(t){if(t.position==="aboveContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Ht(t){if(t.position==="top")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function jt(t){if(t.position==="normal")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function zt(t){if(t.position==="bottom")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Kt(t){if(t.position==="belowContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}var Ve=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?B(o,{children:B(Ve,{providers:e.slice(1),children:t})}):B(o,{children:t})},qe=t=>{let{composerKey:e,editorConfig:o,fieldProps:s,onChange:r,readOnly:m,value:d}=t,c=R(),u=Ue.useRef(null),f=Ye(()=>{let l=d;return o?.features?.hooks?.load?.length&&o.features.hooks.load.forEach(n=>{l=n({incomingEditorState:l})}),l},[o,d]),h=Ye(()=>{if(f&&typeof f!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(f));if(f&&Array.isArray(f)&&!("root"in f))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/beta/lexical/migration#migration-via-migration-script-recommended");if(f&&"jsonContent"in f)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/beta/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:m!==!0,editorState:f!=null?JSON.stringify(f):void 0,namespace:o.lexical.namespace,nodes:he({editorConfig:o}),onError:l=>{throw l},theme:o.lexical.theme}},[o,f,m]);return h?B(Gt,{initialConfig:h,children:B(de,{editorConfig:o,editorContainerRef:u,fieldProps:s,parentContext:c,children:B(Ve,{providers:o.features.providers,children:B(We,{editorConfig:o,editorContainerRef:u,onChange:r})})})},e+h.editable):B("p",{children:"Loading..."})};import"./bundled.css";var ie="rich-text-lexical",Qt=t=>{let{editorConfig:e,field:{name:o,admin:{className:s,readOnly:r,style:m,width:d}={},label:c,localized:u,required:f},path:h,readOnly:l,validate:n}=t,p=l||r,x=h??o,y=Yt(),a=qt((Q,D)=>{if(typeof n=="function")return n(Q,{...D,props:t,required:f})},[n,f]),{customComponents:{AfterInput:g,BeforeInput:i,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:T,initialValue:P,setValue:Y,showError:L,value:A}=Ut({path:x,validate:a}),S=p||T||C,U=[ie,"field-type",s,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${y}`;return se("div",{className:U,style:{...m,width:d},children:[b,N||le(Wt,{label:c,localized:u,required:f}),se("div",{className:`${ie}__wrap`,children:[se(Jt,{fallbackRender:Xt,onReset:()=>{},children:[i,le(qe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:Q=>{let D=Q.toJSON();e?.features?.hooks?.save?.length&&e.features.hooks.save.forEach(me=>{D=me({incomingEditorState:D})}),Y(D)},readOnly:S,value:A},JSON.stringify({initialValue:P,path:x})),g]}),E]})]},J)};function Xt({error:t}){return se("div",{className:"errorBoundary",role:"alert",children:[le("p",{children:"Something went wrong:"}),le("pre",{style:{color:"red"},children:t.message})]})}var ir=Vt(Qt);export{ir as RichText};
2
+ //# sourceMappingURL=Field-GWJ72IYP.js.map
@@ -1,2 +1,2 @@
1
- "use client";import{a as S,d as w}from"./chunk-O4IOO4EU.js";import{a as x}from"./chunk-5PBXL4HT.js";import{b as E}from"./chunk-PDAZFJVO.js";import{jsx as l,jsxs as h}from"react/jsx-runtime";import{useLexicalComposerContext as W}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as Y}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as H}from"@lexical/utils";import{getTranslation as U}from"@payloadcms/translations";import{Button as A,useConfig as q,usePayloadAPI as z,useTranslation as F}from"@payloadcms/ui";import{$getNodeByKey as G,$getSelection as J,$isNodeSelection as Q,CLICK_COMMAND as V,COMMAND_PRIORITY_LOW as C,KEY_BACKSPACE_COMMAND as X,KEY_DELETE_COMMAND as Z}from"lexical";import ee,{useCallback as _,useEffect as te,useReducer as oe,useRef as se,useState as le}from"react";var o="lexical-relationship",T={depth:0},ne=u=>{let{data:{relationTo:M,value:r},nodeKey:n}=u;if(typeof r=="object")throw new Error("Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.");let d=se(null),[e]=W(),[s,c,m]=Y(n),{fieldProps:{readOnly:g}}=E(),{config:{collections:y,routes:{api:L},serverURL:O}}=q(),[i,ie]=le(()=>y.find(t=>t.slug===M)),{i18n:B,t:p}=F(),[R,I]=oe(t=>t+1,0),[{data:b},{setParams:N}]=z(`${O}${L}/${i.slug}/${r}`,{initialParams:T}),{closeDocumentDrawer:v,DocumentDrawer:P,DocumentDrawerToggler:j}=x({id:r,collectionSlug:i.slug}),K=_(()=>{e.update(()=>{G(n)?.remove()})},[e,n]),k=ee.useCallback(({doc:t})=>{N({...T,cacheBust:R}),v(),I()},[R,N,v]),f=_(t=>{let a=J();return s&&Q(a)&&(t.preventDefault(),e.update(()=>{a.getNodes().forEach($=>{w($)&&$.remove()})})),!1},[e,s]),D=_(t=>{let a=t;return a.target===d.current||d.current?.contains(a.target)?(a.shiftKey?c(!s):s||(m(),c(!0)),!0):!1},[s,c,m]);return te(()=>H(e.registerCommand(V,D,C),e.registerCommand(Z,f,C),e.registerCommand(X,f,C)),[m,e,s,n,f,c,D]),h("div",{className:[o,s&&`${o}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:d,children:[h("div",{className:`${o}__wrap`,children:[l("p",{className:`${o}__label`,children:p("fields:labelRelationship",{label:i.labels?.singular?U(i.labels?.singular,B):i.slug})}),l(j,{className:`${o}__doc-drawer-toggler`,children:l("p",{className:`${o}__title`,children:b?b[i?.admin?.useAsTitle||"id"]:r})})]}),e.isEditable()&&h("div",{className:`${o}__actions`,children:[l(A,{buttonStyle:"icon-label",className:`${o}__swapButton`,disabled:g,el:"button",icon:"swap",onClick:()=>{n&&e.dispatchCommand(S,{replace:{nodeKey:n}})},round:!0,tooltip:p("fields:swapRelationship")}),l(A,{buttonStyle:"icon-label",className:`${o}__removeButton`,disabled:g,icon:"x",onClick:t=>{t.preventDefault(),K()},round:!0,tooltip:p("fields:removeRelationship")})]}),!!r&&l(P,{onSave:k})]})},be=u=>l(ne,{...u});export{be as RelationshipComponent};
2
- //# sourceMappingURL=RelationshipComponent-IMM4CFBE.js.map
1
+ "use client";import{a as S,d as w}from"./chunk-MI5HS4QX.js";import{a as x}from"./chunk-5PBXL4HT.js";import{b as E}from"./chunk-CUIBIFW2.js";import{jsx as l,jsxs as h}from"react/jsx-runtime";import{useLexicalComposerContext as W}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as Y}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as H}from"@lexical/utils";import{getTranslation as U}from"@payloadcms/translations";import{Button as A,useConfig as q,usePayloadAPI as z,useTranslation as F}from"@payloadcms/ui";import{$getNodeByKey as G,$getSelection as J,$isNodeSelection as Q,CLICK_COMMAND as V,COMMAND_PRIORITY_LOW as C,KEY_BACKSPACE_COMMAND as X,KEY_DELETE_COMMAND as Z}from"lexical";import ee,{useCallback as _,useEffect as te,useReducer as oe,useRef as se,useState as le}from"react";var o="lexical-relationship",T={depth:0},ne=u=>{let{data:{relationTo:M,value:r},nodeKey:n}=u;if(typeof r=="object")throw new Error("Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.");let d=se(null),[e]=W(),[s,c,m]=Y(n),{fieldProps:{readOnly:g}}=E(),{config:{collections:y,routes:{api:L},serverURL:O}}=q(),[i,ie]=le(()=>y.find(t=>t.slug===M)),{i18n:B,t:p}=F(),[R,I]=oe(t=>t+1,0),[{data:b},{setParams:N}]=z(`${O}${L}/${i.slug}/${r}`,{initialParams:T}),{closeDocumentDrawer:v,DocumentDrawer:P,DocumentDrawerToggler:j}=x({id:r,collectionSlug:i.slug}),K=_(()=>{e.update(()=>{G(n)?.remove()})},[e,n]),k=ee.useCallback(({doc:t})=>{N({...T,cacheBust:R}),v(),I()},[R,N,v]),f=_(t=>{let a=J();return s&&Q(a)&&(t.preventDefault(),e.update(()=>{a.getNodes().forEach($=>{w($)&&$.remove()})})),!1},[e,s]),D=_(t=>{let a=t;return a.target===d.current||d.current?.contains(a.target)?(a.shiftKey?c(!s):s||(m(),c(!0)),!0):!1},[s,c,m]);return te(()=>H(e.registerCommand(V,D,C),e.registerCommand(Z,f,C),e.registerCommand(X,f,C)),[m,e,s,n,f,c,D]),h("div",{className:[o,s&&`${o}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:d,children:[h("div",{className:`${o}__wrap`,children:[l("p",{className:`${o}__label`,children:p("fields:labelRelationship",{label:i.labels?.singular?U(i.labels?.singular,B):i.slug})}),l(j,{className:`${o}__doc-drawer-toggler`,children:l("p",{className:`${o}__title`,children:b?b[i?.admin?.useAsTitle||"id"]:r})})]}),e.isEditable()&&h("div",{className:`${o}__actions`,children:[l(A,{buttonStyle:"icon-label",className:`${o}__swapButton`,disabled:g,el:"button",icon:"swap",onClick:()=>{n&&e.dispatchCommand(S,{replace:{nodeKey:n}})},round:!0,tooltip:p("fields:swapRelationship")}),l(A,{buttonStyle:"icon-label",className:`${o}__removeButton`,disabled:g,icon:"x",onClick:t=>{t.preventDefault(),K()},round:!0,tooltip:p("fields:removeRelationship")})]}),!!r&&l(P,{onSave:k})]})},be=u=>l(ne,{...u});export{be as RelationshipComponent};
2
+ //# sourceMappingURL=RelationshipComponent-2RT3YXUT.js.map