@payloadcms/richtext-lexical 3.15.1 → 3.15.2-canary.595a742
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/{Field-C3BBYNYR.js → Field-VBZQOYLK.js} +2 -2
- package/dist/exports/client/{RelationshipComponent-F77EQHRG.js → RelationshipComponent-N4C5MX3U.js} +2 -2
- package/dist/exports/client/chunk-BB2LUWM3.js +2 -0
- package/dist/exports/client/chunk-BB2LUWM3.js.map +7 -0
- package/dist/exports/client/{chunk-JSFV2MHZ.js → chunk-HTQL4HTC.js} +2 -2
- package/dist/exports/client/{chunk-PGMIO4IN.js → chunk-JRIUM7SP.js} +2 -2
- package/dist/exports/client/chunk-KG5EWFU5.js +2 -0
- package/dist/exports/client/chunk-KG5EWFU5.js.map +7 -0
- package/dist/exports/client/{component-OQJ5KXCS.js → component-TYBPYPLA.js} +2 -2
- package/dist/exports/client/componentInline-BZ7YHWLV.js +2 -0
- package/dist/exports/client/index.js +5 -5
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +12 -7
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js +16 -12
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts +3 -0
- package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +4 -1
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/package.json +7 -7
- package/dist/exports/client/chunk-CUIBIFW2.js +0 -2
- package/dist/exports/client/chunk-CUIBIFW2.js.map +0 -7
- package/dist/exports/client/chunk-QNRPT52J.js +0 -2
- package/dist/exports/client/chunk-QNRPT52J.js.map +0 -7
- package/dist/exports/client/componentInline-TPGMZRGQ.js +0 -2
- /package/dist/exports/client/{Field-C3BBYNYR.js.map → Field-VBZQOYLK.js.map} +0 -0
- /package/dist/exports/client/{RelationshipComponent-F77EQHRG.js.map → RelationshipComponent-N4C5MX3U.js.map} +0 -0
- /package/dist/exports/client/{chunk-JSFV2MHZ.js.map → chunk-HTQL4HTC.js.map} +0 -0
- /package/dist/exports/client/{chunk-PGMIO4IN.js.map → chunk-JRIUM7SP.js.map} +0 -0
- /package/dist/exports/client/{component-OQJ5KXCS.js.map → component-TYBPYPLA.js.map} +0 -0
- /package/dist/exports/client/{componentInline-TPGMZRGQ.js.map → componentInline-BZ7YHWLV.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{c as fe,g as j,h as B,j as pe,k as ge,l as he,m as ye,n as xe}from"./chunk-PZPNMC5Y.js";import{a as ue,b as R}from"./chunk-CUIBIFW2.js";import{jsx as F,jsxs as se}from"react/jsx-runtime";import{FieldDescription as eo,FieldError as to,FieldLabel as oo,RenderCustomComponent as Ze,useEditDepth as no,useField as ro}from"@payloadcms/ui";import{mergeFieldStyles as io}from"@payloadcms/ui/shared";import{useCallback as et,useMemo as so}from"react";import{ErrorBoundary as lo}from"react-error-boundary";import"./bundled.css";import{jsx as A}from"react/jsx-runtime";import{LexicalComposer as Xt}from"@lexical/react/LexicalComposer.js";import*as Je from"react";import{useMemo as Zt}from"react";import{c as $t}from"react/compiler-runtime";import{jsx as w,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Ht}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as jt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as zt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Kt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Gt}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Wt,COMMAND_PRIORITY_LOW as Ye,FOCUS_COMMAND as Yt}from"lexical";import*as Y from"react";import{useEffect as Ue,useState as Ve}from"react";import{jsx as Ee}from"react/jsx-runtime";import"react";var O=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ee(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ee(o.Component,{clientProps:e});import{jsx as ce}from"react/jsx-runtime";import{useLexicalComposerContext as st}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as lt}from"lexical";import*as Pe from"react";import{useCallback as at,useEffect as Ne,useRef as ct,useState as mt}from"react";import{createPortal as dt}from"react-dom";var z=(t,e,o,r,n=50,a=25)=>{let l=0;if(t&&!t.contains(r)){let{bottom:c,left:u,right:g,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,i=c+window.scrollY;if(o<s-a||o>i+a||e<u-n||e>g+n)return-1;(e<u||e>g)&&(l=e<u?e-u:e-g)}return l};import{$getNodeByKey as Z}from"lexical";function K(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function X(t){let e=(u,g)=>u?parseFloat(window.getComputedStyle(u)[g]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),a=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),a),marginTop:l}}import{$getRoot as tt}from"lexical";function _(t){return t.getEditorState().read(()=>tt().getChildrenKeys())}var ot=1,nt=-1,be=0,v={props:null,result:null};function rt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:a=0,point:{x:l,y:c},startIndex:u=0,useEdgeAsDefault:g=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&rt(v.props.point,t.point,o))return v.result;let y=e.getBoundingClientRect(),s=_(r),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(g){let[p,h]=[r.getElementByKey(s[0]),r.getElementByKey(s[s.length-1])];if(p&&h){let[f,m]=[K(p),K(h)];if(c<f.top?(i.blockElem=p,i.distance=f.top-c,i.blockNode=Z(s[0]),i.foundAtIndex=0):c>m.bottom&&(i.distance=c-m.bottom,i.blockNode=Z(s[s.length-1]),i.blockElem=h,i.foundAtIndex=s.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let d=u,x=be;for(;d>=0&&d<s.length;){let p=s[d],h=r.getElementByKey(p);if(h===null)break;let f=new B(l+a,c),m=ye.fromDOMRect(K(h)),{marginBottom:E,marginTop:b}=X(h),N=m.generateNewRect({bottom:m.bottom+E,left:y.left,right:y.right,top:m.top-b}),{distance:C,isOnBottomSide:k,isOnTopSide:P}=N.distanceFromPoint(f);if(C===0){i.blockElem=h,i.blockNode=Z(p),i.foundAtIndex=d,i.distance=C,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else n&&C<i.distance&&(i.blockElem=h,i.blockNode=Z(p),i.distance=C,i.foundAtIndex=d);x===be&&(P?x=nt:k?x=ot:x=1/0),d+=x}}),v.props=t,v.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var it=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ce(t){if(!t||it.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,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),a=window.getComputedStyle(t),l=e.getBoundingClientRect(),c=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))u=n.top+8-c.top;else{let s=Ce(t)?parseInt(a.lineHeight,10):0;u=n.top+(s-l.height)/2-c.top}let y=r;e.style.opacity="1",e.style.transform=`translate(${y}px, ${u}px)`}var ut="add-block-menu",oe=1/0;function ft(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function pt(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),a=n?.admin?.hideGutter?-24:12,l=ct(null),[c,u]=mt(null);Ne(()=>{function y(s){let i=s.target;if(!j(i))return;let d=z(r,s.pageX,s.pageY,i);if(d===-1){u(null);return}if(ee(i,ut))return;let x=_(t),{blockElem:p,blockNode:h,foundAtIndex:f}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-d,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:ft(x.length),useEdgeAsDefault:!1});oe=f,p&&h&&(c?.node!==h||c?.elem!==p)&&u({elem:p,node:h})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,c]),Ne(()=>{l.current&&c?.node&&te(c?.elem,l.current,e,a)},[e,c,a]);let g=at(y=>{let s=c;s?.node&&(t.update(()=>{let i=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(i=!1),!i){let d=lt();s?.node.insertAfter(d),setTimeout(()=>{s={elem:t.getElementByKey(d.getKey()),node:d},u(s)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),s?.node&&"select"in s.node&&typeof s.node.select=="function"&&s.node.select()})},1),setTimeout(()=>{t.dispatchCommand(ge,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,c]);return dt(ce(Pe.Fragment,{children:ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{g(y)},ref:l,type:"button",children:ce("div",{className:o?"icon":""})})}),e)}function we(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=st();return pt(r,o,r._editable)}import{jsx as ne,jsxs as ht}from"react/jsx-runtime";import{useLexicalComposerContext as yt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Se,$getNodeByKey as xt}from"lexical";import*as Ae from"react";import{useEffect as me,useRef as re,useState as ve}from"react";import{createPortal as Et}from"react-dom";var Te=0,gt=-24;var $=0;function Re(t,e,o,r,n,a,l,c,u,g=!1){let{height:y,top:s}=r.getBoundingClientRect(),{top:i,width:d}=l.getBoundingClientRect(),{marginBottom:x,marginTop:p}=X(r),h=s,f=a>=s+y/2+window.scrollY,m=!1;if(n?.elem)if(r!==n?.elem)(f&&n?.elem&&n?.elem===r.nextElementSibling||!f&&n?.elem&&n?.elem===r.previousElementSibling)&&($++,$<200&&(m=!0));else{$++;let C=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(f===n?.isBelow&&C===k||$<200)&&(m=!1)}if(m)return{isBelow:f,willStayInSamePosition:m};g?h+=y/2:f?h+=y+x/2:h-=p/2;let E=0;g||(f?E=-Te:E=Te);let b=h-i+E,N=gt-e;return o.style.width=`calc(${d}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?f?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),$=0,{isBelow:f,willStayInSamePosition:m}}var bt="draggable-block-menu",Me="application/x-lexical-drag-block",V=1/0;function Le(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function Ct(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Be(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Nt(t,e,o){let r=e.parentElement,n=re(null),a=re(null),l=re(null),c=re(!1),[u,g]=ve(null),[y,s]=ve(null),{editorConfig:i}=R(),d=i?.admin?.hideGutter?-44:-8;me(()=>{function h(f){let m=f.target;if(!j(m))return;let E=z(r,f.pageX,f.pageY,m);if(E===-1){g(null);return}if(ee(m,bt))return;let b=_(t),{blockElem:N,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(f.x,f.y),startIndex:Le(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!N&&!k)&&u!==N&&g(N)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,u]),me(()=>{n.current&&te(u,n.current,e,d)},[e,u,d]),me(()=>{function h(m){if(!c.current)return!1;let[E]=ke(m);if(E)return!1;let{pageY:b,target:N}=m;if(!j(N))return!1;let C=z(r,m.pageX,m.pageY,N,100,50),k=_(t),{blockElem:P,foundAtIndex:H,isFoundNodeEmptyParagraph:L}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(m.x,m.y),startIndex:Le(k.length),useEdgeAsDefault:!0,verbose:!0});V=H;let I=a.current;if(P===null||I===null)return!1;if(u!==P){let{isBelow:S,willStayInSamePosition:U}=Re(i?.admin?.hideGutter?"0px":"3rem",d+(i?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),I,P,y,b,e,m,l,L);m.preventDefault(),U||s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:S})}else y?.elem&&(Be(I,y.elem),s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:!1}));return!0}function f(m){if(!c.current)return!1;let[E]=ke(m);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=m,k=b?.getData(Me)||"";return t.update(()=>{let P=xt(k);if(!P||!j(C))return!1;let H=z(r,m.pageX,m.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-H,point:new B(m.x,m.y),useEdgeAsDefault:!0});if(!L)return!1;let S=Se(L);if(!S)return!1;if(S===P)return!0;let{height:U,top:J}=K(L),le=N>=J+U/2+window.scrollY;I?(S.insertBefore(P),S.remove()):le?S.insertAfter(P):S.insertBefore(P),u!==null&&g(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let ae=t.getElementByKey(P.getKey());setTimeout(()=>{let D=ae?.getBoundingClientRect();if(!D)return;let T=document.createElement("div");T.className="lexical-block-highlighter",T.style.backgroundColor="var(--theme-elevation-1000",T.style.transition="opacity 0.5s ease-in-out",T.style.zIndex="1",T.style.pointerEvents="none",T.style.boxSizing="border-box",T.style.borderRadius="4px",T.style.position="absolute",document.body.appendChild(T),T.style.opacity="0.1",T.style.height=`${D.height+8}px`,T.style.width=`${D.width+8}px`,T.style.top=`${D.top+window.scrollY-4}px`,T.style.left=`${D.left-4}px`,setTimeout(()=>{T.style.opacity="0",setTimeout(()=>{T.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",f)}},[r,d,e,t,y,u,i?.admin?.hideGutter]);function x(h){let f=h.dataTransfer;if(!f||!u)return;Ct(f,u);let m="";t.update(()=>{let E=Se(u);E&&(m=E.getKey())}),c.current=!0,f.setData(Me,m)}function p(){c.current=!1,y?.elem&&Be(a.current,y?.elem)}return Et(ht(Ae.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:p,onDragStart:x,ref:n,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:a}),ne("div",{className:"debug-highlight",ref:l})]}),e)}function Fe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=yt();return Nt(r,o,r._editable)}import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import*as Ie from"react";var De=()=>{let t=Pt(4),{editorConfig:e}=R(),[o]=wt(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>fe(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),Ie.useEffect(r,n),null};import{jsx as W,jsxs as _e}from"react/jsx-runtime";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as $e}from"@payloadcms/ui";import{useCallback as kt,useMemo as St,useState as vt}from"react";import"react";import*as He from"react-dom";import{c as Tt}from"react/compiler-runtime";import"react";function Oe(t,e){let o=Tt(4),{maxLength:r,minLength:n}=e,a=r===void 0?75:r,l=n===void 0?1:n,c;return o[0]!==a||o[1]!==l||o[2]!==t?(c=u=>{let{query:g}=u,y="[^"+t+pe+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+a+"}))$").exec(g);if(i!==null){let d=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+d.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=a,o[1]=l,o[2]=t,o[3]=c):c=o[3],c}var M="slash-menu-popup";function Mt({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:a,schemaPath:l}}=R(),{i18n:c}=$e(),u=`${M}__item ${M}__item-${e.key}`;t&&(u+=` ${M}__item--selected`);let g=e.key;return e.label&&(g=typeof e.label=="function"?e.label({featureClientSchemaMap:a,i18n:c,schemaPath:l}):e.label),g.length>25&&(g=g.substring(0,25)+"..."),_e("button",{"aria-selected":t,className:u,id:M+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&W(e.Icon,{}),W("span",{className:`${M}__item-text`,children:g})]},e.key)}function je({anchorElem:t=document.body}){let[e]=Rt(),[o,r]=vt(null),{editorConfig:n}=R(),{i18n:a}=$e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:c}}=R(),u=Oe("/",{minLength:0}),g=kt(()=>{let s=[];for(let i of n.features.slashMenu.dynamicGroups)if(o){let d=i({editor:e,queryString:o});s=s.concat(d)}return s},[e,o,n?.features]),y=St(()=>{let s=[];for(let i of n?.features.slashMenu.groups??[])s.push(i);if(o){s=s.map(d=>{let x=d.items.filter(p=>{let h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:a,schemaPath:c}):p.label),new RegExp(o,"gi").exec(h)?!0:p.keywords!=null?p.keywords.some(f=>new RegExp(o,"gi").exec(f)):!1});return x.length?{...d,items:x}:null}),s=s.filter(d=>d!=null);let i=g();for(let d of i){let x=s.find(p=>p.key===d.key);x?s=s.filter(p=>p.key!==d.key):x={...d,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,n?.features.slashMenu.groups,g,l,a,c]);return W(he,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:i,selectItemAndCleanUp:d,setSelectedItemKey:x})=>s.current&&y.length?He.createPortal(W("div",{className:M,children:y.map(p=>{let h=p.key;return p.label&&l&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:a,schemaPath:c}):p.label),_e("div",{className:`${M}__group ${M}__group-${p.key}`,children:[W("div",{className:`${M}__group-title`,children:h}),p.items.map((f,m)=>W(Mt,{index:m,isSelected:i===f.key,item:f,onClick:()=>{x(f.key),d(f)},onMouseEnter:()=>{x(f.key)},ref:E=>{f.ref={current:E}}},f.key))]},p.key)})}),s.current):null,onQueryChange:r,triggerFn:u})}import{c as Lt}from"react/compiler-runtime";import{useLexicalComposerContext as Bt}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as ze,TextNode as At}from"lexical";import{useEffect as Ft}from"react";function Ke(t){let e=Lt(6),{features:o}=t,[r]=Bt(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let l=It(o.enabledFormats);if(l.length!==0)return r.registerNodeTransform(At,c=>{l.forEach(u=>{c.hasFormat(u)&&c.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let a;return e[3]!==r||e[4]!==o?(a=[r,o],e[3]=r,e[4]=o,e[5]=a):a=e[5],Ft(n,a),null}function It(t){delete ze.highlight;let e=Object.keys(ze),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Dt}from"react/compiler-runtime";import{jsx as Ge}from"react/jsx-runtime";import{ContentEditable as Ot}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as _t}from"@payloadcms/ui";import"react";function We(t){let e=Dt(7),{className:o,editorConfig:r}=t,{t:n}=_t(),a;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let l;e[4]!==r?.admin?.placeholder||e[5]!==n?(l=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=l):l=e[6],a=Ge(Ot,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ge("p",{className:"editor-placeholder",children:l})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=a}else a=e[3];return a}var qe=t=>{let e=$t(22),{editorConfig:o,editorContainerRef:r,onChange:n}=t,a=R(),[l]=Ht(),[c,u]=Ve(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&u(m)},e[0]=g):g=e[0];let y=g,s,i;e[1]!==l||e[2]!==a?(s=()=>{if(!a?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}a?.parentEditor?.uuid&&a.parentEditor?.registerChild(a.uuid,a);let m=()=>{a.focusEditor(a)},E=()=>{a.blurEditor(a)},b=l.registerCommand(Yt,()=>(m(),!0),Ye),N=l.registerCommand(Wt,()=>(E(),!0),Ye);return()=>{b(),N(),a.parentEditor?.unregisterChild?.(a.uuid)}},i=[l,a],e[1]=l,e[2]=a,e[3]=s,e[4]=i):(s=e[3],i=e[4]),Ue(s,i);let[d,x]=Ve(!1),p,h;e[5]!==d?(p=()=>{let m=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==d&&x(E)};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},h=[d],e[5]=d,e[6]=p,e[7]=h):(p=e[6],h=e[7]),Ue(p,h);let f;if(e[8]!==l||e[9]!==o||e[10]!==r||e[11]!==c||e[12]!==d||e[13]!==n){let m;e[15]!==n?(m=(b,N,C)=>{(!C.has("focus")||C.size>1)&&n?.(b,N,C)},e[15]=n,e[16]=m):m=e[16];let E;e[17]!==l||e[18]!==o.features.plugins||e[19]!==c||e[20]!==d?(E=c&&q(Y.Fragment,{children:[!d&&l.isEditable()&&q(Y.Fragment,{children:[w(Fe,{anchorElem:c}),w(we,{anchorElem:c})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&d))return w(O,{anchorElem:c,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&w(Y.Fragment,{children:w(je,{anchorElem:c})})]}),e[17]=l,e[18]=o.features.plugins,e[19]=c,e[20]=d,e[21]=E):E=e[21],f=q(Y.Fragment,{children:[o.features.plugins?.map(Ut),q("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Vt),w(Gt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:y,children:w(We,{editorConfig:o})})}),ErrorBoundary:jt}),w(Ke,{features:o.features}),w(Kt,{ignoreSelectionChange:!0,onChange:m}),E,l.isEditable()&&q(Y.Fragment,{children:[w(zt,{}),o?.features?.markdownTransformers?.length>0&&w(De,{})]}),o.features.plugins?.map(qt),o.features.plugins?.map(Jt)]}),o.features.plugins?.map(Qt)]}),e[8]=l,e[9]=o,e[10]=r,e[11]=c,e[12]=d,e[13]=n,e[14]=f}else f=e[14];return f};function Ut(t){if(t.position==="aboveContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Vt(t){if(t.position==="top")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function qt(t){if(t.position==="normal")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Jt(t){if(t.position==="bottom")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Qt(t){if(t.position==="belowContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}var Qe=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?A(o,{children:A(Qe,{providers:e.slice(1),children:t})}):A(o,{children:t})},Xe=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,onChange:n,readOnly:a,value:l}=t,c=R(),u=Je.useRef(null),g=Zt(()=>{if(l&&typeof l!="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(l));if(l&&Array.isArray(l)&&!("root"in l))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/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)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/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:a!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:xe({editorConfig:o}),onError:y=>{throw y},theme:o.lexical.theme}},[o]);return g?A(Xt,{initialConfig:g,children:A(ue,{editorConfig:o,editorContainerRef:u,fieldProps:r,parentContext:c,children:A(Qe,{providers:o.features.providers,children:A(qe,{editorConfig:o,editorContainerRef:u,onChange:n})})})},e+g.editable):A("p",{children:"Loading..."})};var ie="rich-text-lexical",ao=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:a,readOnly:l}={},label:c,localized:u,required:g},path:y,readOnly:s,validate:i}=t,d=s||l,x=y??r,p=no(),h=et((Q,ae)=>typeof i=="function"?i(Q,{...ae,required:g}):!0,[i,g]),{customComponents:{AfterInput:f,BeforeInput:m,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:k,initialValue:P,setValue:H,showError:L,value:I}=ro({path:x,validate:h}),S=d||k||C,U=[ie,"field-type",n,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${p}`,de=et(Q=>{H(Q.toJSON())},[H]),le=so(()=>io(o),[o]);return se("div",{className:U,style:le,children:[F(Ze,{CustomComponent:b,Fallback:F(to,{path:x,showError:L})}),N||F(oo,{label:c,localized:u,path:x,required:g}),se("div",{className:`${ie}__wrap`,children:[se(lo,{fallbackRender:co,onReset:()=>{},children:[m,F(Xe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:de,readOnly:S,value:I},JSON.stringify({initialValue:P,path:x})),f]}),E,F(Ze,{CustomComponent:E,Fallback:F(eo,{description:a,path:x})})]})]},J)};function co({error:t}){return se("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Cr=ao;export{Cr as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-
|
|
1
|
+
"use client";import{c as fe,g as j,h as B,j as pe,k as ge,l as he,m as ye,n as xe}from"./chunk-PZPNMC5Y.js";import{a as ue,b as R}from"./chunk-BB2LUWM3.js";import{jsx as F,jsxs as se}from"react/jsx-runtime";import{FieldDescription as eo,FieldError as to,FieldLabel as oo,RenderCustomComponent as Ze,useEditDepth as no,useField as ro}from"@payloadcms/ui";import{mergeFieldStyles as io}from"@payloadcms/ui/shared";import{useCallback as et,useMemo as so}from"react";import{ErrorBoundary as lo}from"react-error-boundary";import"./bundled.css";import{jsx as A}from"react/jsx-runtime";import{LexicalComposer as Xt}from"@lexical/react/LexicalComposer.js";import*as Je from"react";import{useMemo as Zt}from"react";import{c as $t}from"react/compiler-runtime";import{jsx as w,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Ht}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as jt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as zt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Kt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Gt}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Wt,COMMAND_PRIORITY_LOW as Ye,FOCUS_COMMAND as Yt}from"lexical";import*as Y from"react";import{useEffect as Ue,useState as Ve}from"react";import{jsx as Ee}from"react/jsx-runtime";import"react";var O=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ee(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ee(o.Component,{clientProps:e});import{jsx as ce}from"react/jsx-runtime";import{useLexicalComposerContext as st}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as lt}from"lexical";import*as Pe from"react";import{useCallback as at,useEffect as Ne,useRef as ct,useState as mt}from"react";import{createPortal as dt}from"react-dom";var z=(t,e,o,r,n=50,a=25)=>{let l=0;if(t&&!t.contains(r)){let{bottom:c,left:u,right:g,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,i=c+window.scrollY;if(o<s-a||o>i+a||e<u-n||e>g+n)return-1;(e<u||e>g)&&(l=e<u?e-u:e-g)}return l};import{$getNodeByKey as Z}from"lexical";function K(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function X(t){let e=(u,g)=>u?parseFloat(window.getComputedStyle(u)[g]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),a=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),a),marginTop:l}}import{$getRoot as tt}from"lexical";function _(t){return t.getEditorState().read(()=>tt().getChildrenKeys())}var ot=1,nt=-1,be=0,v={props:null,result:null};function rt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:a=0,point:{x:l,y:c},startIndex:u=0,useEdgeAsDefault:g=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&rt(v.props.point,t.point,o))return v.result;let y=e.getBoundingClientRect(),s=_(r),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(g){let[p,h]=[r.getElementByKey(s[0]),r.getElementByKey(s[s.length-1])];if(p&&h){let[f,m]=[K(p),K(h)];if(c<f.top?(i.blockElem=p,i.distance=f.top-c,i.blockNode=Z(s[0]),i.foundAtIndex=0):c>m.bottom&&(i.distance=c-m.bottom,i.blockNode=Z(s[s.length-1]),i.blockElem=h,i.foundAtIndex=s.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let d=u,x=be;for(;d>=0&&d<s.length;){let p=s[d],h=r.getElementByKey(p);if(h===null)break;let f=new B(l+a,c),m=ye.fromDOMRect(K(h)),{marginBottom:E,marginTop:b}=X(h),N=m.generateNewRect({bottom:m.bottom+E,left:y.left,right:y.right,top:m.top-b}),{distance:C,isOnBottomSide:k,isOnTopSide:P}=N.distanceFromPoint(f);if(C===0){i.blockElem=h,i.blockNode=Z(p),i.foundAtIndex=d,i.distance=C,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else n&&C<i.distance&&(i.blockElem=h,i.blockNode=Z(p),i.distance=C,i.foundAtIndex=d);x===be&&(P?x=nt:k?x=ot:x=1/0),d+=x}}),v.props=t,v.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var it=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ce(t){if(!t||it.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,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),a=window.getComputedStyle(t),l=e.getBoundingClientRect(),c=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))u=n.top+8-c.top;else{let s=Ce(t)?parseInt(a.lineHeight,10):0;u=n.top+(s-l.height)/2-c.top}let y=r;e.style.opacity="1",e.style.transform=`translate(${y}px, ${u}px)`}var ut="add-block-menu",oe=1/0;function ft(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function pt(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),a=n?.admin?.hideGutter?-24:12,l=ct(null),[c,u]=mt(null);Ne(()=>{function y(s){let i=s.target;if(!j(i))return;let d=z(r,s.pageX,s.pageY,i);if(d===-1){u(null);return}if(ee(i,ut))return;let x=_(t),{blockElem:p,blockNode:h,foundAtIndex:f}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-d,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:ft(x.length),useEdgeAsDefault:!1});oe=f,p&&h&&(c?.node!==h||c?.elem!==p)&&u({elem:p,node:h})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,c]),Ne(()=>{l.current&&c?.node&&te(c?.elem,l.current,e,a)},[e,c,a]);let g=at(y=>{let s=c;s?.node&&(t.update(()=>{let i=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(i=!1),!i){let d=lt();s?.node.insertAfter(d),setTimeout(()=>{s={elem:t.getElementByKey(d.getKey()),node:d},u(s)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),s?.node&&"select"in s.node&&typeof s.node.select=="function"&&s.node.select()})},1),setTimeout(()=>{t.dispatchCommand(ge,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,c]);return dt(ce(Pe.Fragment,{children:ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{g(y)},ref:l,type:"button",children:ce("div",{className:o?"icon":""})})}),e)}function we(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=st();return pt(r,o,r._editable)}import{jsx as ne,jsxs as ht}from"react/jsx-runtime";import{useLexicalComposerContext as yt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Se,$getNodeByKey as xt}from"lexical";import*as Ae from"react";import{useEffect as me,useRef as re,useState as ve}from"react";import{createPortal as Et}from"react-dom";var Te=0,gt=-24;var $=0;function Re(t,e,o,r,n,a,l,c,u,g=!1){let{height:y,top:s}=r.getBoundingClientRect(),{top:i,width:d}=l.getBoundingClientRect(),{marginBottom:x,marginTop:p}=X(r),h=s,f=a>=s+y/2+window.scrollY,m=!1;if(n?.elem)if(r!==n?.elem)(f&&n?.elem&&n?.elem===r.nextElementSibling||!f&&n?.elem&&n?.elem===r.previousElementSibling)&&($++,$<200&&(m=!0));else{$++;let C=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(f===n?.isBelow&&C===k||$<200)&&(m=!1)}if(m)return{isBelow:f,willStayInSamePosition:m};g?h+=y/2:f?h+=y+x/2:h-=p/2;let E=0;g||(f?E=-Te:E=Te);let b=h-i+E,N=gt-e;return o.style.width=`calc(${d}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?f?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),$=0,{isBelow:f,willStayInSamePosition:m}}var bt="draggable-block-menu",Me="application/x-lexical-drag-block",V=1/0;function Le(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function Ct(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Be(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Nt(t,e,o){let r=e.parentElement,n=re(null),a=re(null),l=re(null),c=re(!1),[u,g]=ve(null),[y,s]=ve(null),{editorConfig:i}=R(),d=i?.admin?.hideGutter?-44:-8;me(()=>{function h(f){let m=f.target;if(!j(m))return;let E=z(r,f.pageX,f.pageY,m);if(E===-1){g(null);return}if(ee(m,bt))return;let b=_(t),{blockElem:N,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(f.x,f.y),startIndex:Le(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!N&&!k)&&u!==N&&g(N)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,u]),me(()=>{n.current&&te(u,n.current,e,d)},[e,u,d]),me(()=>{function h(m){if(!c.current)return!1;let[E]=ke(m);if(E)return!1;let{pageY:b,target:N}=m;if(!j(N))return!1;let C=z(r,m.pageX,m.pageY,N,100,50),k=_(t),{blockElem:P,foundAtIndex:H,isFoundNodeEmptyParagraph:L}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(m.x,m.y),startIndex:Le(k.length),useEdgeAsDefault:!0,verbose:!0});V=H;let I=a.current;if(P===null||I===null)return!1;if(u!==P){let{isBelow:S,willStayInSamePosition:U}=Re(i?.admin?.hideGutter?"0px":"3rem",d+(i?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),I,P,y,b,e,m,l,L);m.preventDefault(),U||s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:S})}else y?.elem&&(Be(I,y.elem),s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:!1}));return!0}function f(m){if(!c.current)return!1;let[E]=ke(m);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=m,k=b?.getData(Me)||"";return t.update(()=>{let P=xt(k);if(!P||!j(C))return!1;let H=z(r,m.pageX,m.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-H,point:new B(m.x,m.y),useEdgeAsDefault:!0});if(!L)return!1;let S=Se(L);if(!S)return!1;if(S===P)return!0;let{height:U,top:J}=K(L),le=N>=J+U/2+window.scrollY;I?(S.insertBefore(P),S.remove()):le?S.insertAfter(P):S.insertBefore(P),u!==null&&g(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let ae=t.getElementByKey(P.getKey());setTimeout(()=>{let D=ae?.getBoundingClientRect();if(!D)return;let T=document.createElement("div");T.className="lexical-block-highlighter",T.style.backgroundColor="var(--theme-elevation-1000",T.style.transition="opacity 0.5s ease-in-out",T.style.zIndex="1",T.style.pointerEvents="none",T.style.boxSizing="border-box",T.style.borderRadius="4px",T.style.position="absolute",document.body.appendChild(T),T.style.opacity="0.1",T.style.height=`${D.height+8}px`,T.style.width=`${D.width+8}px`,T.style.top=`${D.top+window.scrollY-4}px`,T.style.left=`${D.left-4}px`,setTimeout(()=>{T.style.opacity="0",setTimeout(()=>{T.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",f)}},[r,d,e,t,y,u,i?.admin?.hideGutter]);function x(h){let f=h.dataTransfer;if(!f||!u)return;Ct(f,u);let m="";t.update(()=>{let E=Se(u);E&&(m=E.getKey())}),c.current=!0,f.setData(Me,m)}function p(){c.current=!1,y?.elem&&Be(a.current,y?.elem)}return Et(ht(Ae.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:p,onDragStart:x,ref:n,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:a}),ne("div",{className:"debug-highlight",ref:l})]}),e)}function Fe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=yt();return Nt(r,o,r._editable)}import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import*as Ie from"react";var De=()=>{let t=Pt(4),{editorConfig:e}=R(),[o]=wt(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>fe(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),Ie.useEffect(r,n),null};import{jsx as W,jsxs as _e}from"react/jsx-runtime";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as $e}from"@payloadcms/ui";import{useCallback as kt,useMemo as St,useState as vt}from"react";import"react";import*as He from"react-dom";import{c as Tt}from"react/compiler-runtime";import"react";function Oe(t,e){let o=Tt(4),{maxLength:r,minLength:n}=e,a=r===void 0?75:r,l=n===void 0?1:n,c;return o[0]!==a||o[1]!==l||o[2]!==t?(c=u=>{let{query:g}=u,y="[^"+t+pe+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+a+"}))$").exec(g);if(i!==null){let d=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+d.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=a,o[1]=l,o[2]=t,o[3]=c):c=o[3],c}var M="slash-menu-popup";function Mt({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:a,schemaPath:l}}=R(),{i18n:c}=$e(),u=`${M}__item ${M}__item-${e.key}`;t&&(u+=` ${M}__item--selected`);let g=e.key;return e.label&&(g=typeof e.label=="function"?e.label({featureClientSchemaMap:a,i18n:c,schemaPath:l}):e.label),g.length>25&&(g=g.substring(0,25)+"..."),_e("button",{"aria-selected":t,className:u,id:M+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&W(e.Icon,{}),W("span",{className:`${M}__item-text`,children:g})]},e.key)}function je({anchorElem:t=document.body}){let[e]=Rt(),[o,r]=vt(null),{editorConfig:n}=R(),{i18n:a}=$e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:c}}=R(),u=Oe("/",{minLength:0}),g=kt(()=>{let s=[];for(let i of n.features.slashMenu.dynamicGroups)if(o){let d=i({editor:e,queryString:o});s=s.concat(d)}return s},[e,o,n?.features]),y=St(()=>{let s=[];for(let i of n?.features.slashMenu.groups??[])s.push(i);if(o){s=s.map(d=>{let x=d.items.filter(p=>{let h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:a,schemaPath:c}):p.label),new RegExp(o,"gi").exec(h)?!0:p.keywords!=null?p.keywords.some(f=>new RegExp(o,"gi").exec(f)):!1});return x.length?{...d,items:x}:null}),s=s.filter(d=>d!=null);let i=g();for(let d of i){let x=s.find(p=>p.key===d.key);x?s=s.filter(p=>p.key!==d.key):x={...d,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,n?.features.slashMenu.groups,g,l,a,c]);return W(he,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:i,selectItemAndCleanUp:d,setSelectedItemKey:x})=>s.current&&y.length?He.createPortal(W("div",{className:M,children:y.map(p=>{let h=p.key;return p.label&&l&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:a,schemaPath:c}):p.label),_e("div",{className:`${M}__group ${M}__group-${p.key}`,children:[W("div",{className:`${M}__group-title`,children:h}),p.items.map((f,m)=>W(Mt,{index:m,isSelected:i===f.key,item:f,onClick:()=>{x(f.key),d(f)},onMouseEnter:()=>{x(f.key)},ref:E=>{f.ref={current:E}}},f.key))]},p.key)})}),s.current):null,onQueryChange:r,triggerFn:u})}import{c as Lt}from"react/compiler-runtime";import{useLexicalComposerContext as Bt}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as ze,TextNode as At}from"lexical";import{useEffect as Ft}from"react";function Ke(t){let e=Lt(6),{features:o}=t,[r]=Bt(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let l=It(o.enabledFormats);if(l.length!==0)return r.registerNodeTransform(At,c=>{l.forEach(u=>{c.hasFormat(u)&&c.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let a;return e[3]!==r||e[4]!==o?(a=[r,o],e[3]=r,e[4]=o,e[5]=a):a=e[5],Ft(n,a),null}function It(t){delete ze.highlight;let e=Object.keys(ze),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Dt}from"react/compiler-runtime";import{jsx as Ge}from"react/jsx-runtime";import{ContentEditable as Ot}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as _t}from"@payloadcms/ui";import"react";function We(t){let e=Dt(7),{className:o,editorConfig:r}=t,{t:n}=_t(),a;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let l;e[4]!==r?.admin?.placeholder||e[5]!==n?(l=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=l):l=e[6],a=Ge(Ot,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ge("p",{className:"editor-placeholder",children:l})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=a}else a=e[3];return a}var qe=t=>{let e=$t(22),{editorConfig:o,editorContainerRef:r,onChange:n}=t,a=R(),[l]=Ht(),[c,u]=Ve(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&u(m)},e[0]=g):g=e[0];let y=g,s,i;e[1]!==l||e[2]!==a?(s=()=>{if(!a?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}a?.parentEditor?.uuid&&a.parentEditor?.registerChild(a.uuid,a);let m=()=>{a.focusEditor(a)},E=()=>{a.blurEditor(a)},b=l.registerCommand(Yt,()=>(m(),!0),Ye),N=l.registerCommand(Wt,()=>(E(),!0),Ye);return()=>{b(),N(),a.parentEditor?.unregisterChild?.(a.uuid)}},i=[l,a],e[1]=l,e[2]=a,e[3]=s,e[4]=i):(s=e[3],i=e[4]),Ue(s,i);let[d,x]=Ve(!1),p,h;e[5]!==d?(p=()=>{let m=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==d&&x(E)};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},h=[d],e[5]=d,e[6]=p,e[7]=h):(p=e[6],h=e[7]),Ue(p,h);let f;if(e[8]!==l||e[9]!==o||e[10]!==r||e[11]!==c||e[12]!==d||e[13]!==n){let m;e[15]!==n?(m=(b,N,C)=>{(!C.has("focus")||C.size>1)&&n?.(b,N,C)},e[15]=n,e[16]=m):m=e[16];let E;e[17]!==l||e[18]!==o.features.plugins||e[19]!==c||e[20]!==d?(E=c&&q(Y.Fragment,{children:[!d&&l.isEditable()&&q(Y.Fragment,{children:[w(Fe,{anchorElem:c}),w(we,{anchorElem:c})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&d))return w(O,{anchorElem:c,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&w(Y.Fragment,{children:w(je,{anchorElem:c})})]}),e[17]=l,e[18]=o.features.plugins,e[19]=c,e[20]=d,e[21]=E):E=e[21],f=q(Y.Fragment,{children:[o.features.plugins?.map(Ut),q("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Vt),w(Gt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:y,children:w(We,{editorConfig:o})})}),ErrorBoundary:jt}),w(Ke,{features:o.features}),w(Kt,{ignoreSelectionChange:!0,onChange:m}),E,l.isEditable()&&q(Y.Fragment,{children:[w(zt,{}),o?.features?.markdownTransformers?.length>0&&w(De,{})]}),o.features.plugins?.map(qt),o.features.plugins?.map(Jt)]}),o.features.plugins?.map(Qt)]}),e[8]=l,e[9]=o,e[10]=r,e[11]=c,e[12]=d,e[13]=n,e[14]=f}else f=e[14];return f};function Ut(t){if(t.position==="aboveContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Vt(t){if(t.position==="top")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function qt(t){if(t.position==="normal")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Jt(t){if(t.position==="bottom")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Qt(t){if(t.position==="belowContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}var Qe=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?A(o,{children:A(Qe,{providers:e.slice(1),children:t})}):A(o,{children:t})},Xe=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,onChange:n,readOnly:a,value:l}=t,c=R(),u=Je.useRef(null),g=Zt(()=>{if(l&&typeof l!="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(l));if(l&&Array.isArray(l)&&!("root"in l))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/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)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/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:a!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:xe({editorConfig:o}),onError:y=>{throw y},theme:o.lexical.theme}},[o]);return g?A(Xt,{initialConfig:g,children:A(ue,{editorConfig:o,editorContainerRef:u,fieldProps:r,parentContext:c,children:A(Qe,{providers:o.features.providers,children:A(qe,{editorConfig:o,editorContainerRef:u,onChange:n})})})},e+g.editable):A("p",{children:"Loading..."})};var ie="rich-text-lexical",ao=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:a,readOnly:l}={},label:c,localized:u,required:g},path:y,readOnly:s,validate:i}=t,d=s||l,x=y??r,p=no(),h=et((Q,ae)=>typeof i=="function"?i(Q,{...ae,required:g}):!0,[i,g]),{customComponents:{AfterInput:f,BeforeInput:m,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:k,initialValue:P,setValue:H,showError:L,value:I}=ro({path:x,validate:h}),S=d||k||C,U=[ie,"field-type",n,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${p}`,de=et(Q=>{H(Q.toJSON())},[H]),le=so(()=>io(o),[o]);return se("div",{className:U,style:le,children:[F(Ze,{CustomComponent:b,Fallback:F(to,{path:x,showError:L})}),N||F(oo,{label:c,localized:u,path:x,required:g}),se("div",{className:`${ie}__wrap`,children:[se(lo,{fallbackRender:co,onReset:()=>{},children:[m,F(Xe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:de,readOnly:S,value:I},JSON.stringify({initialValue:P,path:x})),f]}),E,F(Ze,{CustomComponent:E,Fallback:F(eo,{description:a,path:x})})]})]},J)};function co({error:t}){return se("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Cr=ao;export{Cr as RichText};
|
|
2
|
+
//# sourceMappingURL=Field-VBZQOYLK.js.map
|
package/dist/exports/client/{RelationshipComponent-F77EQHRG.js → RelationshipComponent-N4C5MX3U.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{a as S,d as w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=RelationshipComponent-
|
|
1
|
+
"use client";import{a as S,d as w}from"./chunk-JRIUM7SP.js";import{a as x}from"./chunk-F26IQ5RE.js";import{b as E}from"./chunk-BB2LUWM3.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 m=se(null),[e]=W(),[s,c,d]=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(()=>{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===m.current||m.current?.contains(a.target)?(a.shiftKey?c(!s):s||(d(),c(!0)),!0):!1},[s,c,d]);return te(()=>H(e.registerCommand(V,D,C),e.registerCommand(Z,f,C),e.registerCommand(X,f,C)),[d,e,s,n,f,c,D]),h("div",{className:[o,s&&`${o}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:m,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-N4C5MX3U.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as x}from"react/jsx-runtime";import{useLexicalComposerContext as M}from"@lexical/react/LexicalComposerContext.js";import"react";import{createContext as b,useContext as v,useMemo as S,useRef as h,useState as s}from"react";function k(){return Math.random().toString(36).substring(2,12)+Math.random().toString(36).substring(2,12)}var p=b({editorConfig:null,fieldProps:null,uuid:null}),F=({children:o,editorConfig:c,editorContainerRef:d,fieldProps:a,parentContext:n})=>{let[f]=M(),[l]=s(k()),t=h(new Map),[E,w]=s(null),u=h(new Set),[m,g]=s(),C=S(()=>({blurEditor:r=>{u.current.clear()},childrenEditors:t,createdInlineBlock:m,editor:f,editorConfig:c,editorContainerRef:d,fieldProps:a,focusedEditor:E,focusEditor:r=>{let e=r.uuid;u.current.has(e)||(u.current.add(e),w(r),n?.uuid&&n.focusEditor(r),t.current.forEach(i=>{i.focusEditor(r)}),u.current.clear())},parentEditor:n,registerChild:(r,e)=>{if(!t.current.has(r)){let i=new Map(t.current);i.set(r,e),t.current=i}},setCreatedInlineBlock:g,unregisterChild:r=>{if(t.current.has(r)){let e=new Map(t.current);e.delete(r),t.current=e}},uuid:l}),[m,g,f,t,c,d,a,E,n,l]);return x(p.Provider,{value:C,children:o})},G=()=>{let o=v(p);if(o===void 0)throw new Error("useEditorConfigContext must be used within an EditorConfigProvider");return o};export{F as a,G as b};
|
|
2
|
+
//# sourceMappingURL=chunk-BB2LUWM3.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lexical/config/client/EditorConfigProvider.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport type { LexicalEditor } from 'lexical'\nimport type { MarkRequired } from 'ts-essentials'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport * as React from 'react'\nimport { createContext, useContext, useMemo, useRef, useState } from 'react'\n\nimport type { InlineBlockNode } from '../../../features/blocks/client/nodes/InlineBlocksNode.js'\nimport type { LexicalRichTextFieldProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\n\nexport interface EditorConfigContextType {\n // Editor focus handling\n blurEditor: (editorContext: EditorConfigContextType) => void\n childrenEditors: React.RefObject<Map<string, EditorConfigContextType>>\n createdInlineBlock?: InlineBlockNode\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n\n editorContainerRef: React.RefObject<HTMLDivElement>\n fieldProps: MarkRequired<LexicalRichTextFieldProps, 'path' | 'schemaPath'>\n focusedEditor: EditorConfigContextType | null\n // Editor focus handling\n focusEditor: (editorContext: EditorConfigContextType) => void\n parentEditor: EditorConfigContextType\n registerChild: (uuid: string, editorContext: EditorConfigContextType) => void\n setCreatedInlineBlock?: React.Dispatch<React.SetStateAction<InlineBlockNode | undefined>>\n unregisterChild?: (uuid: string) => void\n uuid: string\n}\n\n// @ts-expect-error: TODO: Fix this\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n fieldProps: null,\n uuid: null,\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n editorContainerRef,\n fieldProps,\n parentContext,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n\n fieldProps: LexicalRichTextFieldProps\n parentContext?: EditorConfigContextType\n}): React.ReactNode => {\n const [editor] = useLexicalComposerContext()\n // State to store the UUID\n const [uuid] = useState(generateQuickGuid())\n\n const childrenEditors = useRef<Map<string, EditorConfigContextType>>(new Map())\n const [focusedEditor, setFocusedEditor] = useState<EditorConfigContextType | null>(null)\n const focusHistory = useRef<Set<string>>(new Set())\n const [createdInlineBlock, setCreatedInlineBlock] = useState<InlineBlockNode>()\n\n const editorContext = useMemo(\n () =>\n ({\n blurEditor: (editorContext: EditorConfigContextType) => {\n //setFocusedEditor(null) // Clear focused editor\n focusHistory.current.clear() // Reset focus history when focus is lost\n },\n childrenEditors,\n createdInlineBlock,\n editor,\n editorConfig,\n editorContainerRef,\n fieldProps,\n focusedEditor,\n focusEditor: (editorContext: EditorConfigContextType) => {\n const editorUUID = editorContext.uuid\n\n // Avoid recursion by checking if this editor is already focused in this cycle\n if (focusHistory.current.has(editorUUID)) {\n return\n }\n\n // Add this editor to the history to prevent future recursions in this cycle\n focusHistory.current.add(editorUUID)\n setFocusedEditor(editorContext)\n\n // Propagate focus event to parent and children, ensuring they do not refocus this editor\n if (parentContext?.uuid) {\n parentContext.focusEditor(editorContext)\n }\n childrenEditors.current.forEach((childEditor) => {\n childEditor.focusEditor(editorContext)\n })\n\n focusHistory.current.clear()\n },\n parentEditor: parentContext,\n registerChild: (childUUID, childEditorContext) => {\n if (!childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.set(childUUID, childEditorContext)\n childrenEditors.current = newMap\n }\n },\n setCreatedInlineBlock,\n unregisterChild: (childUUID) => {\n if (childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.delete(childUUID)\n childrenEditors.current = newMap\n }\n },\n\n uuid,\n }) as EditorConfigContextType,\n [\n createdInlineBlock,\n setCreatedInlineBlock,\n editor,\n childrenEditors,\n editorConfig,\n editorContainerRef,\n fieldProps,\n focusedEditor,\n parentContext,\n uuid,\n ],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],
|
|
5
|
+
"mappings": "wCAKA,OAASA,6BAAAA,MAAiC,2CAC1C,MAAuB,QACvB,OAASC,iBAAAA,EAAeC,cAAAA,EAAYC,WAAAA,EAASC,UAAAA,EAAQC,YAAAA,MAAgB,QAOrE,SAASC,GAAA,CACP,OAAOC,KAAKC,OAAM,EAAGC,SAAS,EAAA,EAAIC,UAAU,EAAG,EAAA,EAAMH,KAAKC,OAAM,EAAGC,SAAS,EAAA,EAAIC,UAAU,EAAG,EAAA,CAC/F,CAuBA,IAAMC,EAAkDV,EAAc,CACpEW,aAAc,KACdC,WAAY,KACZC,KAAM,IACR,CAAA,EAEaC,EAAuBA,CAAC,CACnCC,SAAAA,EACAJ,aAAAA,EACAK,mBAAAA,EACAJ,WAAAA,EACAK,cAAAA,CAAa,IAQd,CACC,GAA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J,CAAA,CACD,EAGH,OAAOgC,EAACnC,EAAQoC,SAAQ,CAACC,MAAOpB,WAAgBZ,GAClD,EAEaiC,EAAyBA,IAAA,CACpC,IAAAC,EAAgBhD,EAAAS,CAAW,EAAA,GACvBuC,IAAAC,OAAY,MAAA,IAAAC,MACE,oEAAA,EAAA,OAEXF,CAAA",
|
|
6
|
+
"names": ["useLexicalComposerContext", "createContext", "useContext", "useMemo", "useRef", "useState", "generateQuickGuid", "Math", "random", "toString", "substring", "Context", "editorConfig", "fieldProps", "uuid", "EditorConfigProvider", "children", "editorContainerRef", "parentContext", "editor", "childrenEditors", "Map", "focusedEditor", "setFocusedEditor", "focusHistory", "Set", "createdInlineBlock", "setCreatedInlineBlock", "editorContext", "blurEditor", "current", "clear", "focusEditor", "editorUUID", "has", "add", "forEach", "childEditor", "parentEditor", "registerChild", "childUUID", "childEditorContext", "newMap", "set", "unregisterChild", "delete", "_jsx", "Provider", "value", "useEditorConfigContext", "context", "undefined", "Error"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as P}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as P}from"./chunk-BB2LUWM3.js";import{c as Y}from"react/compiler-runtime";import{jsx as R}from"react/jsx-runtime";import{Drawer as Z,EditDepthProvider as N,useModal as z}from"@payloadcms/ui";import"react";import{jsx as T,jsxs as W}from"react/jsx-runtime";import{Form as H,FormSubmit as J,RenderFields as K,useDocumentInfo as L,useServerFunctions as B,useTranslation as G}from"@payloadcms/ui";import{abortAndIgnore as y}from"@payloadcms/ui/shared";import{useCallback as V,useEffect as I,useRef as q,useState as Q}from"react";import{v4 as X}from"uuid";var j=({data:e,featureKey:t,fieldMapOverride:r,handleDrawerSubmit:n,schemaFieldsPathOverride:o,schemaPath:p,schemaPathSuffix:m})=>{let{t:d}=G(),{id:s,collectionSlug:c,getDocPreferences:u,globalSlug:l}=L(),i=q(new AbortController),[f,a]=Q(!1),{fieldProps:{featureClientSchemaMap:h,permissions:w}}=P(),{getFormState:x}=B(),g=o??`${p}.lexical_internal_feature.${t}${m?`.${m}`:""}`,S=r??h[t]?.[g];I(()=>{let _=new AbortController;return(async()=>{let{state:v}=await x({id:s,collectionSlug:c,data:e??{},docPermissions:{fields:!0},docPreferences:await u(),globalSlug:l,operation:"update",renderAllFields:!0,schemaPath:g,signal:_.signal});a(v)})(),()=>{y(_)}},[g,s,e,x,c,l,u]);let E=V(async({formState:_})=>{y(i.current);let C=new AbortController;i.current=C;let{state:v}=await x({id:s,collectionSlug:c,docPermissions:{fields:!0},docPreferences:await u(),formState:_,globalSlug:l,operation:"update",schemaPath:g,signal:C.signal});return v||_},[x,s,c,u,l,g]);return I(()=>()=>{y(i.current)},[]),f===!1?null:W(H,{beforeSubmit:[E],disableValidationOnSubmit:!0,fields:Array.isArray(S)?S:[],initialState:f,onChange:[E],onSubmit:n,uuid:X(),children:[T(K,{fields:Array.isArray(S)?S:[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:g,permissions:w,readOnly:!1}),T(J,{children:d("fields:saveChanges")})]})};var Pt=e=>{let t=Y(15),{className:r,data:n,drawerSlug:o,drawerTitle:p,featureKey:m,fieldMapOverride:d,handleDrawerSubmit:s,schemaFieldsPathOverride:c,schemaPath:u,schemaPathSuffix:l}=e,{closeModal:i}=z(),f=p??"",a;t[0]!==i||t[1]!==o||t[2]!==s?(a=(w,x)=>{i(o),setTimeout(()=>{s(w,x)},1)},t[0]=i,t[1]=o,t[2]=s,t[3]=a):a=t[3];let h;return t[4]!==r||t[5]!==n||t[6]!==o||t[7]!==m||t[8]!==d||t[9]!==c||t[10]!==u||t[11]!==l||t[12]!==f||t[13]!==a?(h=R(N,{children:R(Z,{className:r,slug:o,title:f,children:R(j,{data:n,featureKey:m,fieldMapOverride:d,handleDrawerSubmit:a,schemaFieldsPathOverride:c,schemaPath:u,schemaPathSuffix:l})})}),t[4]=r,t[5]=n,t[6]=o,t[7]=m,t[8]=d,t[9]=c,t[10]=u,t[11]=l,t[12]=f,t[13]=a,t[14]=h):h=t[14],h};import{c as tt}from"react/compiler-runtime";import{jsx as et}from"react/jsx-runtime";import{useAuth as rt,useConfig as nt,useEntityVisibility as ot}from"@payloadcms/ui";import*as D from"react";var at=(e,t)=>e.filter(({slug:r,admin:{enableRichTextRelationship:n},upload:o})=>t?.visibleEntities.collections.includes(r)?t?.uploads?n&&!!o:o?!1:n:!1),Mt=e=>{let t=tt(20),r,n,o,p;t[0]!==e?({children:n,FallbackComponent:r,uploads:p,...o}=e,t[0]=e,t[1]=r,t[2]=n,t[3]=o,t[4]=p):(r=t[1],n=t[2],o=t[3],p=t[4]);let m=p===void 0?!1:p,{config:d}=nt(),{collections:s}=d,{user:c}=rt(),{visibleEntities:u}=ot(),l;t[5]!==s||t[6]!==m||t[7]!==c||t[8]!==u?(l=()=>at(s,{uploads:m,user:c,visibleEntities:u}).map(it),t[5]=s,t[6]=m,t[7]=c,t[8]=u,t[9]=l):l=t[9];let[i]=D.useState(l);if(!i.length){let a;return t[10]!==r||t[11]!==o?(a=r?et(r,{...o}):null,t[10]=r,t[11]=o,t[12]=a):a=t[12],a}let f;if(t[13]!==n||t[14]!==i||t[15]!==o){let a;t[17]!==i||t[18]!==o?(a={...o,enabledCollectionSlugs:i},t[17]=i,t[18]=o,t[19]=a):a=t[19],f=D.cloneElement(n,a),t[13]=n,t[14]=i,t[15]=o,t[16]=f}else f=t[16];return f};function it(e){let{slug:t}=e;return t}import{createCommand as lt}from"lexical";var kt=lt("INSERT_UPLOAD_WITH_DRAWER_COMMAND");import{jsx as mt}from"react/jsx-runtime";import F from"bson-objectid";import{$applyNodeReplacement as pt}from"lexical";import*as U from"react";import{jsx as st}from"react/jsx-runtime";import{DecoratorBlockNode as ct}from"@lexical/react/LexicalDecoratorBlockNode.js";import $ from"bson-objectid";import{$applyNodeReplacement as ut}from"lexical";import"react";function O(e){return e.parentElement!=null&&e.parentElement.tagName==="LI"&&e.previousSibling===null&&e.getAttribute("aria-roledescription")==="checkbox"}function ft(e){if(e.hasAttribute("data-lexical-upload-relation-to")&&e.hasAttribute("data-lexical-upload-id")){let r=e.getAttribute("data-lexical-upload-id"),n=e.getAttribute("data-lexical-upload-relation-to");if(r!=null&&n!=null)return{node:M({data:{fields:{},relationTo:n,value:r}})}}let t=e;return t.src.startsWith("file:///")||O(t),null}var b=class extends ct{__data;constructor({data:t,format:r,key:n}){super(r,n),this.__data=t}static clone(t){return new this({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"upload"}static importDOM(){return{img:t=>({conversion:ft,priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new $.default().toHexString(),t.version=3);let r={id:t.id,fields:t.fields,relationTo:t.relationTo,value:t.value},n=M({data:r});return n.setFormat(t.format),n}static isInline(){return!1}decorate(){return st(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let t=document.createElement("img");return t.setAttribute("data-lexical-upload-id",String(this.__data?.value)),t.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(t){let r=this.getWritable();r.__data=t}updateDOM(){return!1}};function M({data:e}){return e?.id||(e.id=new $.default().toHexString()),ut(new b({data:e}))}var dt=U.lazy(()=>import("./component-TYBPYPLA.js").then(e=>({default:e.UploadComponent})));function ht(e){if(e.hasAttribute("data-lexical-upload-relation-to")&&e.hasAttribute("data-lexical-upload-id")){let r=e.getAttribute("data-lexical-upload-id"),n=e.getAttribute("data-lexical-upload-relation-to");if(r!=null&&n!=null)return{node:k({data:{fields:{},relationTo:n,value:r}})}}let t=e;return t.src.startsWith("file:///")||O(t),null}var A=class extends b{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importDOM(){return{img:t=>({conversion:ht,priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new F.default().toHexString(),t.version=3);let r={id:t.id,fields:t.fields,relationTo:t.relationTo,value:t.value},n=k({data:r});return n.setFormat(t.format),n}decorate(){return mt(dt,{data:this.__data,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function k({data:e}){return e?.id||(e.id=new F.default().toHexString()),pt(new A({data:e}))}function Yt(e){return e instanceof A}export{Pt as a,Mt as b,kt as c,A as d,k as e,Yt as f};
|
|
2
|
+
//# sourceMappingURL=chunk-HTQL4HTC.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createCommand as u}from"lexical";var x=u("INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND");import{jsx as _}from"react/jsx-runtime";import*as l from"react";import{DecoratorBlockNode as c}from"@lexical/react/LexicalDecoratorBlockNode.js";function p(a){let t=a.getAttribute("data-lexical-relationship-id"),e=a.getAttribute("data-lexical-relationship-relationTo");return t!=null&&e!=null?{node:o({relationTo:e,value:t})}:null}var n=class extends c{__data;constructor({data:t,format:e,key:r}){super(e,r),this.__data=t}static clone(t){return new this({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"relationship"}static importDOM(){return{div:t=>!t.hasAttribute("data-lexical-relationship-relationTo")||!t.hasAttribute("data-lexical-relationship-id")?null:{conversion:p,priority:2}}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id);let e={relationTo:t.relationTo,value:t.value},r=o(e);return r.setFormat(t.format),r}static isInline(){return!1}decorate(t,e){return null}exportDOM(){let t=document.createElement("div");t.setAttribute("data-lexical-relationship-id",String(typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value)),t.setAttribute("data-lexical-relationship-relationTo",this.__data?.relationTo);let e=document.createTextNode(this.getTextContent());return t.append(e),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"relationship",version:2}}getData(){return this.getLatest().__data}getTextContent(){return`${this.__data?.relationTo} relation to ${typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value}`}setData(t){let e=this.getWritable();e.__data=t}};function o(a){return new n({data:a})}var h=l.lazy(()=>import("./RelationshipComponent-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{createCommand as u}from"lexical";var x=u("INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND");import{jsx as _}from"react/jsx-runtime";import*as l from"react";import{DecoratorBlockNode as c}from"@lexical/react/LexicalDecoratorBlockNode.js";function p(a){let t=a.getAttribute("data-lexical-relationship-id"),e=a.getAttribute("data-lexical-relationship-relationTo");return t!=null&&e!=null?{node:o({relationTo:e,value:t})}:null}var n=class extends c{__data;constructor({data:t,format:e,key:r}){super(e,r),this.__data=t}static clone(t){return new this({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"relationship"}static importDOM(){return{div:t=>!t.hasAttribute("data-lexical-relationship-relationTo")||!t.hasAttribute("data-lexical-relationship-id")?null:{conversion:p,priority:2}}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id);let e={relationTo:t.relationTo,value:t.value},r=o(e);return r.setFormat(t.format),r}static isInline(){return!1}decorate(t,e){return null}exportDOM(){let t=document.createElement("div");t.setAttribute("data-lexical-relationship-id",String(typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value)),t.setAttribute("data-lexical-relationship-relationTo",this.__data?.relationTo);let e=document.createTextNode(this.getTextContent());return t.append(e),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"relationship",version:2}}getData(){return this.getLatest().__data}getTextContent(){return`${this.__data?.relationTo} relation to ${typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value}`}setData(t){let e=this.getWritable();e.__data=t}};function o(a){return new n({data:a})}var h=l.lazy(()=>import("./RelationshipComponent-N4C5MX3U.js").then(a=>({default:a.RelationshipComponent})));function d(a){let t=a.getAttribute("data-lexical-relationship-id"),e=a.getAttribute("data-lexical-relationship-relationTo");return t!=null&&e!=null?{node:s({relationTo:e,value:t})}:null}var i=class extends n{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importDOM(){return{div:t=>!t.hasAttribute("data-lexical-relationship-relationTo")||!t.hasAttribute("data-lexical-relationship-id")?null:{conversion:d,priority:2}}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id);let e={relationTo:t.relationTo,value:t.value},r=s(e);return r.setFormat(t.format),r}decorate(t,e){return _(h,{className:e.theme.relationship??"LexicalEditorTheme__relationship",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function s(a){return new i({data:a})}function R(a){return a instanceof i}export{x as a,i as b,s as c,R as d};
|
|
2
|
+
//# sourceMappingURL=chunk-JRIUM7SP.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as oe}from"./chunk-INBEEENE.js";import{b as ne}from"./chunk-BB2LUWM3.js";import{jsx as i,jsxs as N,Fragment as De}from"react/jsx-runtime";import F,{createContext as ye,useCallback as k,useEffect as w,useMemo as v,useRef as A}from"react";import{useLexicalComposerContext as Ie}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as Ne}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as we}from"@lexical/utils";import{getTranslation as re}from"@payloadcms/translations";import{Button as le,Drawer as ve,EditDepthProvider as Fe,Form as Oe,formatDrawerSlug as $e,FormSubmit as Ee,RenderFields as Pe,ShimmerEffect as Me,useDocumentInfo as Te,useEditDepth as Le,useServerFunctions as Ae,useTranslation as Re}from"@payloadcms/ui";import{abortAndIgnore as R}from"@payloadcms/ui/shared";import{$getNodeByKey as ie,$getSelection as Ke,$isNodeSelection as je,CLICK_COMMAND as Je,COMMAND_PRIORITY_LOW as K,KEY_BACKSPACE_COMMAND as ze,KEY_DELETE_COMMAND as Ye}from"lexical";import{reduceFieldsToValues as He}from"payload/shared";import{v4 as Ve}from"uuid";import{jsx as he}from"react/jsx-runtime";import xe from"bson-objectid";import Se from"react";import ge from"bson-objectid";import{DecoratorNode as ke}from"lexical";var g=class extends ke{__fields;constructor({fields:e,key:t}){super(t),this.__fields=e}static clone(e){return new this({fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return Ce(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(){let e=document.createElement("span");return e.classList.add("inline-block-container"),e}decorate(e,t){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let t=document.createTextNode(this.getTextContent());return e.append(t),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e){let t=this.getWritable();t.__fields=e}updateDOM(){return!1}};function Ce(r){return new g({fields:{...r,id:r?.id||new ge.default().toHexString()}})}var _e=Se.lazy(()=>import("./componentInline-BZ7YHWLV.js").then(r=>({default:r.InlineBlockComponent}))),I=class extends g{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return Be(e.fields)}decorate(e,t){return he(_e,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Be(r){return new I({fields:{...r,id:r?.id||new xe.default().toHexString()}})}function L(r){return r instanceof I}var m="inline-block",se=ye({initialState:!1}),kt=()=>F.useContext(se),Ct=r=>{let{formData:e,nodeKey:t}=r,[s]=Ie(),{i18n:O,t:d}=Re(),{createdInlineBlock:j,fieldProps:{featureClientSchemaMap:ce,initialLexicalFormState:ae,permissions:ue,readOnly:C,schemaPath:J},setCreatedInlineBlock:z,uuid:de}=ne(),{getFormState:h}=Ae(),me=Le(),Y=A(!1),[a,fe]=F.useState(ae?.[e.id]?.formState),[$,H]=F.useState(a?._components?.customComponents?.BlockLabel),[V,W]=F.useState(a?._components?.customComponents?.Block),q=$e({slug:`lexical-inlineBlocks-create-${de}-${e.id}`,depth:me}),{toggleDrawer:f}=oe(q,!0),E=A(null),[u,x,P]=Ne(t),{id:S,collectionSlug:_,getDocPreferences:B,globalSlug:D}=Te(),pe=`${J}.lexical_internal_feature.blocks.lexical_inline_blocks.${e.blockType}`,c=ce.blocks[pe][0].blocks[0];w(()=>{!Y.current&&j?.getKey()===t&&(c.fields.length>2&&f(),z?.(void 0),Y.current=!0)},[c.fields.length,j,t,z,f]);let G=k(()=>{s.update(()=>{ie(t)?.remove()})},[s,t]),M=k(n=>{let l=Ke();return u&&je(l)&&(n.preventDefault(),s.update(()=>{l.getNodes().forEach(o=>{L(o)&&o.remove()})})),!1},[s,u]),Q=k(n=>{let l=n;return l.target===E.current||E.current?.contains(l.target)?(l.shiftKey?x(!u):u||(P(),x(!0)),!0):!1},[u,x,P]);w(()=>we(s.registerCommand(Je,Q,K),s.registerCommand(Ye,M,K),s.registerCommand(ze,M,K)),[P,s,u,t,M,x,Q]);let p=c?.labels?.singular?re(c.labels.singular,O):c?.slug,T=A(new AbortController),b=`${J}.lexical_internal_feature.blocks.lexical_inline_blocks.${c?.slug}.fields`;w(()=>{let n=new AbortController;return e&&!a&&(async()=>{let{state:o}=await h({id:S,collectionSlug:_,data:e,docPermissions:{fields:!0},docPreferences:await B(),globalSlug:D,operation:"update",renderAllFields:!0,schemaPath:b,signal:n.signal});o&&(fe(o),H(o._components?.customComponents?.BlockLabel),W(o._components?.customComponents?.Block))})(),()=>{R(n)}},[h,b,S,e,a,_,D,B]);let U=k(async({formState:n,submit:l})=>{R(T.current);let o=new AbortController;T.current=o;let{state:y}=await h({id:S,collectionSlug:_,docPermissions:{fields:!0},docPreferences:await B(),formState:n,globalSlug:D,operation:"update",renderAllFields:!!l,schemaPath:b,signal:o.signal});return y?(l&&(H(y._components?.customComponents?.BlockLabel),W(y._components?.customComponents?.Block)),y):n},[h,S,_,B,D,b]);w(()=>()=>{R(T.current)},[]);let be=k(n=>{let l=He(n);l.blockType=e.blockType,s.update(()=>{let o=ie(t);o&&L(o)&&o.setFields(l)})},[s,t,e]),X=v(()=>()=>i(le,{buttonStyle:"icon-label",className:`${m}__removeButton`,disabled:C,icon:"x",onClick:n=>{n.preventDefault(),G()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:remove",{label:p})}),[p,C,G,d]),Z=v(()=>()=>i(le,{buttonStyle:"icon-label",className:`${m}__editButton`,disabled:C,el:"button",icon:"edit",onClick:()=>{f()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:edit",{label:p})}),[p,C,d,f]),ee=v(()=>({children:n})=>i("div",{className:[m,m+"-"+e.blockType,u&&`${m}--selected`].filter(Boolean).join(" "),ref:E,children:n}),[e.blockType,u]),te=v(()=>$?()=>$:()=>i("div",{children:re(c.labels.singular,O)}),[$,c.labels,O]);return N(Oe,{beforeSubmit:[async({formState:n})=>await U({formState:n,submit:!0})],disableValidationOnSubmit:!0,fields:c.fields,initialState:a||{},onChange:[U],onSubmit:n=>{be(n),f()},uuid:Ve(),children:[i(Fe,{children:i(ve,{className:"",slug:q,title:d(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:p??d("lexical:blocks:inlineBlocks:label")}),children:a?N(De,{children:[i(Pe,{fields:c.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:b,permissions:ue,readOnly:!1}),i(Ee,{programmaticSubmit:!0,children:d("fields:saveChanges")})]}):null})}),V?i(se.Provider,{value:{EditButton:Z,initialState:a,InlineBlockContainer:ee,Label:te,nodeKey:t,RemoveButton:X},children:V}):N(ee,{children:[a?i(te,{}):i(Me,{height:"15px",width:"40px"}),s.isEditable()?N("div",{className:`${m}__actions`,children:[i(Z,{}),i(X,{})]}):null]})]})};export{kt as a,Ct as b,I as c,Be as d,L as e};
|
|
2
|
+
//# sourceMappingURL=chunk-KG5EWFU5.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[\n componentMapRenderedBlockPath\n ][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlock.fields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlock.fields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n formState: prevFormState,\n globalSlug,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n fields={clientBlock.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport type { EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields<TBlockFields>\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const writable = this.getWritable()\n writable.__fields = fields\n }\n\n updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
|
|
5
|
+
"mappings": "mJAEA,OAAOA,GAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,MAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,2BAAAA,OAA+B,yCACxC,OAASC,iBAAAA,OAAqB,iBAC9B,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OACEC,iBAAAA,GACAC,iBAAAA,GACAC,oBAAAA,GACAC,iBAAAA,GACAC,wBAAAA,EACAC,yBAAAA,GACAC,sBAAAA,OACK,UACP,OAASC,wBAAAA,OAA4B,iBAIrC,OAASC,MAAMC,OAAY,gDCpC3B,OAAOC,OAAc,gBACrB,OAAOC,OAAyB,QCUhC,OAAOC,OAAc,gBACrB,OAASC,iBAAAA,OAAqB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AAS,IAET,MAAM2E,EAAS,CAAE3E,UAAAA,EAAW6E,OAAQ,EAAK,CAAA,CAClD,EAEF+B,0BAAyB,GACzB9E,OAAQL,EAAYK,OACpB/D,aAAcA,GAAgB,CAAC,EAC/B4G,SAAU,CAACA,CAAA,EACXkC,SAAW7G,GAAA,CACT+E,GAAa/E,CAAA,EACbY,EAAA,CACF,EACAxB,KAAMA,GAAA,YAENiG,EAACyB,GAAA,UACCzB,EAAC0B,GAAA,CACCvB,UAAW,GACX9E,KAAMF,EACNwG,MAAOtI,EAAE,+BAA+BL,GAAU0B,GAAK,OAAS,QAAA,GAAY,CAC1EgG,MAAOpC,GAAoBjF,EAAE,mCAAA,CAC/B,CAAA,WAECX,EACC0I,EAAAQ,GAAA,WACE5B,EAAC6B,GAAA,CACCpF,OAAQL,EAAYK,OACpBqF,YAAW,GACXC,gBAAgB,GAChBC,WAAW,GACXC,iBAAkBrD,EAClBjF,YAAaA,GACbC,SAAU,KAEZoG,EAACkC,GAAA,CAAWC,mBAAoB,YAAO9I,EAAE,oBAAA,OAEzC,SAGP2B,EACCgF,EAACxH,GAA4B4J,SAAQ,CACnCC,MAAO,CACL1B,WAAAA,EACAjI,aAAAA,EACAmI,qBAAAA,GACAM,MAAAA,GACAlI,QAAAA,EACA6G,aAAAA,CACF,WAEC9E,IAGHoG,EAACP,GAAA,WACEnI,EAAesH,EAACmB,GAAA,CAAA,CAAA,EAAWnB,EAACsC,GAAA,CAAcC,OAAO,OAAOC,MAAM,SAC9DtJ,EAAOuJ,WAAU,EAChBrB,EAAC,MAAA,CAAIjB,UAAW,GAAG5H,CAAA,sBACjByH,EAACW,EAAA,CAAA,CAAA,EACDX,EAACF,EAAA,CAAA,CAAA,CAAA,IAED,IAAA,MAKd",
|
|
6
|
+
"names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "useLexicalNodeSelection", "mergeRegister", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "$getSelection", "$isNodeSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "React", "ObjectID", "DecoratorNode", "ServerInlineBlockNode", "__fields", "constructor", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getLatest", "setFields", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "editor", "config", "_jsx", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "useContext", "InlineBlockComponent", "props", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "permissions", "readOnly", "schemaPath", "setCreatedInlineBlock", "uuid", "uuidFromContext", "useEditorConfigContext", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "firstTimeDrawer", "useRef", "setInitialState", "useState", "id", "formState", "CustomLabel", "setCustomLabel", "customComponents", "BlockLabel", "CustomBlock", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "isSelected", "setSelected", "clearSelection", "useLexicalNodeSelection", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "componentMapRenderedBlockPath", "blockType", "clientBlock", "blocks", "useEffect", "current", "getKey", "fields", "length", "undefined", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "$onDelete", "event", "deleteSelection", "$getSelection", "$isNodeSelection", "preventDefault", "getNodes", "forEach", "node", "$isInlineBlockNode", "onClick", "payload", "target", "contains", "shiftKey", "mergeRegister", "registerCommand", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_DELETE_COMMAND", "KEY_BACKSPACE_COMMAND", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "docPreferences", "operation", "renderAllFields", "signal", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "onFormSubmit", "newData", "reduceFieldsToValues", "setFields", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "e", "round", "size", "tooltip", "label", "EditButton", "el", "InlineBlockContainer", "children", "filter", "Boolean", "join", "ref", "Label", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "title", "_Fragment", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "FormSubmit", "programmaticSubmit", "Provider", "value", "ShimmerEffect", "height", "width", "isEditable"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{a as M,b as A,c as T,f as O}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=component-
|
|
1
|
+
"use client";import{a as M,b as A,c as T,f as O}from"./chunk-HTQL4HTC.js";import{a as y}from"./chunk-INBEEENE.js";import{a as U}from"./chunk-F26IQ5RE.js";import{b}from"./chunk-BB2LUWM3.js";import{jsx as e,jsxs as c}from"react/jsx-runtime";import{useLexicalComposerContext as ae}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as le}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as re}from"@lexical/utils";import{getTranslation as F}from"@payloadcms/translations";import{Button as C,File as se,formatDrawerSlug as ie,useConfig as ne,useEditDepth as ce,usePayloadAPI as de,useTranslation as ue}from"@payloadcms/ui";import{$getNodeByKey as I,$getSelection as me,$isNodeSelection as pe,CLICK_COMMAND as fe,COMMAND_PRIORITY_LOW as w,KEY_BACKSPACE_COMMAND as ge,KEY_DELETE_COMMAND as he}from"lexical";import{useCallback as f,useEffect as _e,useId as De,useReducer as be,useRef as Ce,useState as we}from"react";var o="lexical-upload",K={depth:0},Ne=d=>{let{data:{fields:j,relationTo:N,value:n},nodeKey:l}=d;if(typeof n=="object")throw new Error("Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.");let{config:{collections:B,routes:{api:k},serverURL:W}}=ne(),g=Ce(null),{uuid:Y}=b(),z=ce(),[a]=ae(),[r,h,x]=le(l),{editorConfig:H,fieldProps:{readOnly:_,schemaPath:q}}=b(),{i18n:S,t:u}=ue(),[$,G]=be(t=>t+1,0),[s]=we(()=>B.find(t=>t.slug===N)),J=De(),v=ie({slug:"lexical-upload-drawer-"+Y+J,depth:z}),{toggleDrawer:Q}=y(v,!0),{closeDocumentDrawer:E,DocumentDrawer:V,DocumentDrawerToggler:X}=U({id:n,collectionSlug:s.slug}),[{data:m},{setParams:R}]=de(`${W}${k}/${s.slug}/${n}`,{initialParams:K}),L=m?.thumbnailURL||m?.url,Z=f(()=>{a.update(()=>{I(l)?.remove()})},[a,l]),ee=f(t=>{R({...K,cacheBust:$}),G(),E()},[R,$,E]),D=f(t=>{let p=me();return r&&pe(p)&&(t.preventDefault(),a.update(()=>{p.getNodes().forEach(i=>{O(i)&&i.remove()})})),!1},[a,r]);_e(()=>re(a.registerCommand(fe,t=>t.target===g.current||g.current?.contains(t.target)?(t.shiftKey?h(!r):r||(x(),h(!0)),!0):!1,w),a.registerCommand(he,D,w),a.registerCommand(ge,D,w)),[x,a,r,l,D,h]);let P=H?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[s.slug]?.hasExtraFields,te=f((t,p)=>{a.update(()=>{let i=I(l);if(i){let oe={...i.getData(),fields:p};i.setData(oe)}})},[a,l]);return c("div",{className:[o,r&&`${o}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:g,children:[c("div",{className:`${o}__card`,children:[c("div",{className:`${o}__topRow`,children:[e("div",{className:`${o}__thumbnail`,children:L?e("img",{alt:m?.filename,"data-lexical-upload-id":n,"data-lexical-upload-relation-to":N,src:L}):e(se,{})}),c("div",{className:`${o}__topRowRightPanel`,children:[e("div",{className:`${o}__collectionLabel`,children:F(s.labels.singular,S)}),a.isEditable()&&c("div",{className:`${o}__actions`,children:[P?e(C,{buttonStyle:"icon-label",className:`${o}__upload-drawer-toggler`,disabled:_,el:"button",icon:"edit",onClick:()=>{Q()},round:!0,tooltip:u("fields:editRelationship")}):null,e(C,{buttonStyle:"icon-label",className:`${o}__swap-drawer-toggler`,disabled:_,el:"button",icon:"swap",onClick:()=>{a.dispatchCommand(T,{replace:{nodeKey:l}})},round:!0,tooltip:u("fields:swapUpload")}),e(C,{buttonStyle:"icon-label",className:`${o}__removeButton`,disabled:_,icon:"x",onClick:t=>{t.preventDefault(),Z()},round:!0,tooltip:u("fields:removeUpload")})]})]})]}),e("div",{className:`${o}__bottomRow`,children:e(X,{className:`${o}__doc-drawer-toggler`,children:e("strong",{children:m?.filename})})})]}),n?e(V,{onSave:ee}):null,P?e(M,{data:j,drawerSlug:v,drawerTitle:u("general:editLabel",{label:F(s.labels.singular,S)}),featureKey:"upload",handleDrawerSubmit:te,schemaPath:q,schemaPathSuffix:s.slug}):null]})},Ke=d=>e(A,{...d,uploads:!0,children:e(Ne,{...d})});export{Ke as UploadComponent};
|
|
2
|
+
//# sourceMappingURL=component-TYBPYPLA.js.map
|