@payloadcms/richtext-lexical 3.8.0 → 3.9.0
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-G3GIPW2U.js → Field-X3CJV3SY.js} +1 -1
- package/dist/exports/client/{Field-G3GIPW2U.js.map → Field-X3CJV3SY.js.map} +2 -2
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/index.js +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/lexical/plugins/TextPlugin/index.d.ts +1 -1
- package/dist/lexical/plugins/TextPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/utilities/jsx/jsx.spec.d.ts +0 -2
- package/dist/utilities/jsx/jsx.spec.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
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-XOABLBHB.js";import{a as de,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 ut}from"react-dom";var z=(t,e,o,n,r=50,m=25)=>{let l=0;if(t&&!t.contains(n)){let{bottom:a,left:d,right:g,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,i=a+window.scrollY;if(o<s-m||o>i+m||e<d-r||e>g+r)return-1;(e<d||e>g)&&(l=e<d?e-d: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 n=o.split(",").pop();return e.y=e.y-Number(n?.replace(")","")),e}function X(t){let e=(d,g)=>d?parseFloat(window.getComputedStyle(d)[g]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),m=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),m),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 n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:m=0,point:{x:l,y:a},startIndex:d=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=_(n),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(g){let[p,h]=[n.getElementByKey(s[0]),n.getElementByKey(s[s.length-1])];if(p&&h){let[f,c]=[K(p),K(h)];if(a<f.top?(i.blockElem=p,i.distance=f.top-a,i.blockNode=Z(s[0]),i.foundAtIndex=0):a>c.bottom&&(i.distance=a-c.bottom,i.blockNode=Z(s[s.length-1]),i.blockElem=h,i.foundAtIndex=s.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let u=d,x=be;for(;u>=0&&u<s.length;){let p=s[u],h=n.getElementByKey(p);if(h===null)break;let f=new B(l+m,a),c=ye.fromDOMRect(K(h)),{marginBottom:E,marginTop:b}=X(h),N=c.generateNewRect({bottom:c.bottom+E,left:y.left,right:y.right,top:c.top-b}),{distance:C,isOnBottomSide:k,isOnTopSide:P}=N.distanceFromPoint(f);if(C===0){i.blockElem=h,i.blockNode=Z(p),i.foundAtIndex=u,i.distance=C,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else r&&C<i.distance&&(i.blockElem=h,i.blockNode=Z(p),i.distance=C,i.foundAtIndex=u);x===be&&(P?x=nt:k?x=ot:x=1/0),u+=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,n=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),m=window.getComputedStyle(t),l=e.getBoundingClientRect(),a=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))d=r.top+8-a.top;else{let s=Ce(t)?parseInt(m.lineHeight,10):0;d=r.top+(s-l.height)/2-a.top}let y=n;e.style.opacity="1",e.style.transform=`translate(${y}px, ${d}px)`}var dt="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 n=e.parentElement,{editorConfig:r}=R(),m=r?.admin?.hideGutter?-24:12,l=ct(null),[a,d]=mt(null);Ne(()=>{function y(s){let i=s.target;if(!j(i))return;let u=z(n,s.pageX,s.pageY,i);if(u===-1){d(null);return}if(ee(i,dt))return;let x=_(t),{blockElem:p,blockNode:h,foundAtIndex:f}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-u,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:ft(x.length),useEdgeAsDefault:!1});oe=f,p&&h&&(a?.node!==h||a?.elem!==p)&&d({elem:p,node:h})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[n,e,t,a]),Ne(()=>{l.current&&a?.node&&te(a?.elem,l.current,e,m)},[e,a,m]);let g=at(y=>{let s=a;s?.node&&(t.update(()=>{let i=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(i=!1),!i){let u=lt();s?.node.insertAfter(u),setTimeout(()=>{s={elem:t.getElementByKey(u.getKey()),node:u},d(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,a]);return ut(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,[n]=st();return pt(n,o,n._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,n,r,m,l,a,d,g=!1){let{height:y,top:s}=n.getBoundingClientRect(),{top:i,width:u}=l.getBoundingClientRect(),{marginBottom:x,marginTop:p}=X(n),h=s,f=m>=s+y/2+window.scrollY,c=!1;if(r?.elem)if(n!==r?.elem)(f&&r?.elem&&r?.elem===n.nextElementSibling||!f&&r?.elem&&r?.elem===n.previousElementSibling)&&($++,$<200&&(c=!0));else{$++;let C=r?.boundingBox?.y,k=n.getBoundingClientRect().y;(f===r?.isBelow&&C===k||$<200)&&(c=!1)}if(c)return{isBelow:f,willStayInSamePosition:c};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(${u}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?f?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),$=0,{isBelow:f,willStayInSamePosition:c}}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 n=e.parentElement,r=re(null),m=re(null),l=re(null),a=re(!1),[d,g]=ve(null),[y,s]=ve(null),{editorConfig:i}=R(),u=i?.admin?.hideGutter?-44:-8;me(()=>{function h(f){let c=f.target;if(!j(c))return;let E=z(n,f.pageX,f.pageY,c);if(E===-1){g(null);return}if(ee(c,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)&&d!==N&&g(N)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[n,e,t,d]),me(()=>{r.current&&te(d,r.current,e,u)},[e,d,u]),me(()=>{function h(c){if(!a.current)return!1;let[E]=ke(c);if(E)return!1;let{pageY:b,target:N}=c;if(!j(N))return!1;let C=z(n,c.pageX,c.pageY,N,100,50),k=_(t),{blockElem:P,foundAtIndex:H,isFoundNodeEmptyParagraph:L}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(c.x,c.y),startIndex:Le(k.length),useEdgeAsDefault:!0,verbose:!0});V=H;let I=m.current;if(P===null||I===null)return!1;if(d!==P){let{isBelow:S,willStayInSamePosition:U}=Re(i?.admin?.hideGutter?"0px":"3rem",u+(i?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),I,P,y,b,e,c,l,L);c.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(c){if(!a.current)return!1;let[E]=ke(c);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=c,k=b?.getData(Me)||"";return t.update(()=>{let P=xt(k);if(!P||!j(C))return!1;let H=z(n,c.pageX,c.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-H,point:new B(c.x,c.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),d!==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)}},[n,u,e,t,y,d,i?.admin?.hideGutter]);function x(h){let f=h.dataTransfer;if(!f||!d)return;Ct(f,d);let c="";t.update(()=>{let E=Se(d);E&&(c=E.getKey())}),a.current=!0,f.setData(Me,c)}function p(){a.current=!1,y?.elem&&Be(m.current,y?.elem)}return Et(ht(Ae.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:p,onDragStart:x,ref:r,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:m}),ne("div",{className:"debug-highlight",ref:l})]}),e)}function Fe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=yt();return Nt(n,o,n._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(),n,r;return t[0]!==o||t[1]!==e.features.markdownTransformers?(n=()=>fe(o,e.features.markdownTransformers??[]),r=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=n,t[3]=r):(n=t[2],r=t[3]),Ie.useEffect(n,r),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:n,minLength:r}=e,m=n===void 0?75:n,l=r===void 0?1:r,a;return o[0]!==m||o[1]!==l||o[2]!==t?(a=d=>{let{query:g}=d,y="[^"+t+pe+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+m+"}))$").exec(g);if(i!==null){let u=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+u.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=m,o[1]=l,o[2]=t,o[3]=a):a=o[3],a}var M="slash-menu-popup";function Mt({isSelected:t,item:e,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:m,schemaPath:l}}=R(),{i18n:a}=$e(),d=`${M}__item ${M}__item-${e.key}`;t&&(d+=` ${M}__item--selected`);let g=e.key;return e.label&&(g=typeof e.label=="function"?e.label({featureClientSchemaMap:m,i18n:a,schemaPath:l}):e.label),g.length>25&&(g=g.substring(0,25)+"..."),_e("button",{"aria-selected":t,className:d,id:M+"__item-"+e.key,onClick:o,onMouseEnter:n,ref:r,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,n]=vt(null),{editorConfig:r}=R(),{i18n:m}=$e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:a}}=R(),d=Oe("/",{minLength:0}),g=kt(()=>{let s=[];for(let i of r.features.slashMenu.dynamicGroups)if(o){let u=i({editor:e,queryString:o});s=s.concat(u)}return s},[e,o,r?.features]),y=St(()=>{let s=[];for(let i of r?.features.slashMenu.groups??[])s.push(i);if(o){s=s.map(u=>{let x=u.items.filter(p=>{let h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:m,schemaPath:a}):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?{...u,items:x}:null}),s=s.filter(u=>u!=null);let i=g();for(let u of i){let x=s.find(p=>p.key===u.key);x?s=s.filter(p=>p.key!==u.key):x={...u,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,r?.features.slashMenu.groups,g,l,m,a]);return W(he,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:i,selectItemAndCleanUp:u,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:m,schemaPath:a}):p.label),_e("div",{className:`${M}__group ${M}__group-${p.key}`,children:[W("div",{className:`${M}__group-title`,children:h}),p.items.map((f,c)=>W(Mt,{index:c,isSelected:i===f.key,item:f,onClick:()=>{x(f.key),u(f)},onMouseEnter:()=>{x(f.key)},ref:E=>{f.ref={current:E}}},f.key))]},p.key)})}),s.current):null,onQueryChange:n,triggerFn:d})}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,[n]=Bt(),r;e[0]!==n||e[1]!==o.enabledFormats?(r=()=>{let l=It(o.enabledFormats);if(l.length!==0)return n.registerNodeTransform(At,a=>{l.forEach(d=>{a.hasFormat(d)&&a.toggleFormat(d)})})},e[0]=n,e[1]=o.enabledFormats,e[2]=r):r=e[2];let m;return e[3]!==n||e[4]!==o?(m=[n,o],e[3]=n,e[4]=o,e[5]=m):m=e[5],Ft(r,m),null}function It(t){delete ze.highlight;let e=Object.keys(ze),o=new Set(t);return e.filter(n=>!o.has(n))}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(3),{className:o}=t,{t:n}=_t(),r;return e[0]!==o||e[1]!==n?(r=Ge(Ot,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ge("p",{className:"editor-placeholder",children:n("lexical:general:placeholder")})}),e[0]=o,e[1]=n,e[2]=r):r=e[2],r}var qe=t=>{let e=$t(22),{editorConfig:o,editorContainerRef:n,onChange:r}=t,m=R(),[l]=Ht(),[a,d]=Ve(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=c=>{c!==null&&d(c)},e[0]=g):g=e[0];let y=g,s,i;e[1]!==l||e[2]!==m?(s=()=>{if(!m?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}m?.parentEditor?.uuid&&m.parentEditor?.registerChild(m.uuid,m);let c=()=>{m.focusEditor(m)},E=()=>{m.blurEditor(m)},b=l.registerCommand(Yt,()=>(c(),!0),Ye),N=l.registerCommand(Wt,()=>(E(),!0),Ye);return()=>{b(),N(),m.parentEditor?.unregisterChild?.(m.uuid)}},i=[l,m],e[1]=l,e[2]=m,e[3]=s,e[4]=i):(s=e[3],i=e[4]),Ue(s,i);let[u,x]=Ve(!1),p,h;e[5]!==u?(p=()=>{let c=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==u&&x(E)};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},h=[u],e[5]=u,e[6]=p,e[7]=h):(p=e[6],h=e[7]),Ue(p,h);let f;if(e[8]!==l||e[9]!==o.features||e[10]!==n||e[11]!==a||e[12]!==u||e[13]!==r){let c;e[15]!==r?(c=(b,N,C)=>{(!C.has("focus")||C.size>1)&&r?.(b,N,C)},e[15]=r,e[16]=c):c=e[16];let E;e[17]!==l||e[18]!==o.features.plugins||e[19]!==a||e[20]!==u?(E=a&&q(Y.Fragment,{children:[!u&&l.isEditable()&&q(Y.Fragment,{children:[w(Fe,{anchorElem:a}),w(we,{anchorElem:a})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&u))return w(O,{anchorElem:a,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&w(Y.Fragment,{children:w(je,{anchorElem:a})})]}),e[17]=l,e[18]=o.features.plugins,e[19]=a,e[20]=u,e[21]=E):E=e[21],f=q(Y.Fragment,{children:[o.features.plugins?.map(Ut),q("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(Vt),w(Gt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:y,tabIndex:-1,children:w(We,{})})}),ErrorBoundary:jt}),w(Ke,{features:o.features}),w(Kt,{ignoreSelectionChange:!0,onChange:c}),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.features,e[10]=n,e[11]=a,e[12]=u,e[13]=r,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:n,onChange:r,readOnly:m,value:l}=t,a=R(),d=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:m!==!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(de,{editorConfig:o,editorContainerRef:d,fieldProps:n,parentContext:a,children:A(Qe,{providers:o.features.providers,children:A(qe,{editorConfig:o,editorContainerRef:d,onChange:r})})})},e+g.editable):A("p",{children:"Loading..."})};var ie="rich-text-lexical",ao=t=>{let{editorConfig:e,field:o,field:{name:n,admin:{className:r,description:m,readOnly:l}={},label:a,localized:d,required:g},path:y,readOnly:s,validate:i}=t,u=s||l,x=y??n,p=no(),h=et((Q,ae)=>typeof i=="function"?i(Q,{...ae,required:g}):!0,[i,g]),{customComponents:{AfterInput:f,BeforeInput:c,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:k,initialValue:P,setValue:H,showError:L,value:I}=ro({path:x,validate:h}),S=u||k||C,U=[ie,"field-type",r,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${p}`,ue=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:a,localized:d,required:g}),se("div",{className:`${ie}__wrap`,children:[se(lo,{fallbackRender:co,onReset:()=>{},children:[c,F(Xe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:ue,readOnly:S,value:I},JSON.stringify({initialValue:P,path:x})),f]}),E,F(Ze,{CustomComponent:E,Fallback:F(eo,{description:m,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-
|
|
2
|
+
//# sourceMappingURL=Field-X3CJV3SY.js.map
|