@payloadcms/richtext-lexical 3.90.1 → 3.91.0-internal.07e4582
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-5ZXLEL3U.js +2 -0
- package/dist/exports/client/{Field-YZR46UCY.js.map → Field-5ZXLEL3U.js.map} +3 -3
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-XFA5M7FY.js → chunk-IIZYDMRJ.js} +2 -2
- package/dist/exports/client/chunk-IIZYDMRJ.js.map +7 -0
- package/dist/exports/client/componentInline-YMJQCGVL.js +2 -0
- package/dist/exports/client/index.js +17 -17
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +6 -6
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +3 -3
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +23 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.spec.js +51 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.spec.js.map +1 -0
- package/package.json +6 -6
- package/dist/exports/client/Field-YZR46UCY.js +0 -2
- package/dist/exports/client/chunk-XFA5M7FY.js.map +0 -7
- package/dist/exports/client/componentInline-A4H3EY3L.js +0 -2
- /package/dist/exports/client/{componentInline-A4H3EY3L.js.map → componentInline-YMJQCGVL.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{a as Ae,e as Be,g as O,h as I,j as Oe,k as Ie,l as Fe,m as $e,n as be,o as Ne,p as Ke}from"./chunk-QAW5QKEM.js";import{a as Me,b as w}from"./chunk-BZZVLW4U.js";import{jsx as D,jsxs as le}from"react/jsx-runtime";import{BulkUploadProvider as nr,FieldDescription as rr,FieldError as ir,FieldLabel as sr,isFieldRTL as lr,RenderCustomComponent as Mt,useConfig as ar,useEditDepth as cr,useEffectEvent as ur,useField as dr,useLocale as fr}from"@payloadcms/ui";import{mergeFieldStyles as mr}from"@payloadcms/ui/shared";import{dequal as pr}from"dequal/lite";import At,{useCallback as Bt,useEffect as Ot,useMemo as gr,useState as It}from"react";import{ErrorBoundary as hr}from"react-error-boundary";import"./bundled.css";import{jsx as F}from"react/jsx-runtime";import{LexicalComposer as Un}from"@lexical/react/LexicalComposer.js";import{useEditDepth as Jn}from"@payloadcms/ui";import*as kt from"react";import{useMemo as qn}from"react";import{c as Ln}from"react/compiler-runtime";import{jsx as E,jsxs as ie}from"react/jsx-runtime";import{useLexicalComposerContext as Mn}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as An}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Bn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as On}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as In}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as Fn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as $n,COMMAND_PRIORITY_LOW as Rt,FOCUS_COMMAND as Kn}from"lexical";import*as X from"react";import{useEffect as jn,useState as zn}from"react";import{jsx as je}from"react/jsx-runtime";import"react";var K=({anchorElem:e,clientProps:t,plugin:o})=>o.position==="floatingAnchorElem"&&e?o.Component&&je(o.Component,{anchorElem:e,clientProps:t}):o.Component&&je(o.Component,{clientProps:t});import{c as zt}from"react/compiler-runtime";import{copyToClipboard as ze}from"@lexical/clipboard";import{useLexicalComposerContext as Ht}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Vt}from"@lexical/utils";import He from"bson-objectid";import{$getSelection as Wt,$isNodeSelection as Yt,COMMAND_PRIORITY_LOW as Gt,COPY_COMMAND as Ut}from"lexical";import{useEffect as Jt}from"react";var we=e=>{if("fields"in e&&typeof e.fields=="object"&&e.fields!==null&&"id"in e.fields?e.fields.id=new He.default().toHexString():"id"in e&&(e.id=new He.default().toHexString()),e.children)for(let t of e.children)we(t)};function Ve(){let e=zt(3),[t]=Ht(),o,n;return e[0]!==t?(o=()=>t.registerCommand(Ut,r=>{let c=Wt();if(Yt(c)){let s=c.getNodes()[0]?.exportJSON(),a=JSON.parse(JSON.stringify(s));we(a);let f={namespace:t._config.namespace,nodes:[a]},p=JSON.stringify(f);return ze(t,null,{"application/x-lexical-editor":p,"text/plain":""}).catch(qt),!0}return ze(t,Vt(r,ClipboardEvent)?r:null).then(()=>{if(!(r instanceof ClipboardEvent)||!r.clipboardData)throw new Error("No clipboard event");let l=r.clipboardData.getData("application/x-lexical-editor");if(!l)return!0;let s=JSON.parse(l);for(let f of s.nodes)we(f);let a=JSON.stringify(s);r.clipboardData.setData("application/x-lexical-editor",a)}).catch(l=>{throw r instanceof ClipboardEvent&&r.clipboardData?.setData("application/x-lexical-editor",""),l}),!0},Gt),n=[t],e[0]=t,e[1]=o,e[2]=n):(o=e[1],n=e[2]),Jt(o,n),null}function qt(e){throw e}import{c as Qt}from"react/compiler-runtime";import{useLexicalComposerContext as Xt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ae,mergeRegister as Zt}from"@lexical/utils";import{$createNodeSelection as eo,$getEditor as oe,$getNearestNodeFromDOMNode as to,$getSelection as ce,$isDecoratorNode as j,$isElementNode as Se,$isLineBreakNode as oo,$isNodeSelection as ue,$isRangeSelection as We,$isRootOrShadowRoot as no,$isTextNode as ro,$setSelection as Ye,CLICK_COMMAND as io,COMMAND_PRIORITY_LOW as G,KEY_ARROW_DOWN_COMMAND as so,KEY_ARROW_UP_COMMAND as lo,KEY_BACKSPACE_COMMAND as ao,KEY_DELETE_COMMAND as co,SELECTION_CHANGE_COMMAND as uo}from"lexical";import{useEffect as fo}from"react";function Ge(){let e=Qt(3),[t]=Xt(),o=Co,n,r;return e[0]!==t?(n=()=>Zt(t.registerCommand(io,xo,G),t.registerCommand(co,o,G),t.registerCommand(ao,o,G),t.registerCommand(uo,yo,G),t.registerCommand(lo,go,G),t.registerCommand(so,mo,G)),r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),fo(n,r),null}function mo(e){let t=ce();if(ue(t)){e.preventDefault();let l=t.getNodes()[0]?.getNextSibling();if(j(l)){let f=oe().getElementByKey(l.getKey());return f&&ne({element:f,node:l}),!0}if(!Se(l))return!0;let s=l.getFirstDescendant()??l;return s&&(ae(s,de)?.selectEnd(),e.preventDefault()),!0}if(!We(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=ae(n,po),c=r?.getNextSibling();if(!r||c!==Ue(r))return!1;if(j(c)){let l=oe().getElementByKey(c.getKey());if(l)return ne({element:l,node:c}),e.preventDefault(),!0}return!1}function po(e){return Ue(e)!==null}function go(e){let t=ce();if(ue(t)){let l=t.getNodes()[0]?.getPreviousSibling();if(j(l)){let f=oe().getElementByKey(l.getKey());return f?(ne({element:f,node:l}),e.preventDefault(),!0):!1}if(!Se(l))return!1;let s=l.getLastDescendant()??l;return s?(ae(s,de)?.selectStart(),e.preventDefault(),!0):!1}if(!We(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=ae(n,ho),c=r?.getPreviousSibling();if(!r||c!==Je(r))return!1;if(j(c)){let l=oe().getElementByKey(c.getKey());if(l)return ne({element:l,node:c}),e.preventDefault(),!0}return!1}function ho(e){return Je(e)!==null}function yo(){let e=No();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),e?(e.element?.classList.add("decorator-selected"),!0):!1}function xo(e){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let t=bo(e);if(!t)return!0;let{target:o}=e;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Ye(null):ne(t),!0}function Co(e){let t=ce();return ue(t)?(e.preventDefault(),t.getNodes().forEach(Eo),!0):!1}function Eo(e){e.remove()}function bo(e){if(!(e.target instanceof HTMLElement))return;let t=e.target.closest('[data-lexical-decorator="true"]');if(!(t instanceof HTMLElement))return;let o=to(t);return j(o)?{element:t,node:o}:void 0}function No(){let e=ce();if(!ue(e))return;let t=e.getNodes();if(t.length!==1)return;let o=t[0];return j(o)?{decorator:o,element:oe().getElementByKey(o.getKey())}:void 0}function ne({element:e,node:t}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=eo();o.add(t.getKey()),Ye(o),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.classList.add("decorator-selected")}function de(e){if(j(e)&&!e.isInline())return!0;if(!Se(e)||no(e))return!1;let t=e.getFirstChild(),o=t===null||oo(t)||ro(t)||t.isInline();return!e.isInline()&&e.canBeEmpty()!==!1&&o}function Ue(e){let t=e.getNextSibling();for(;t!==null;){if(de(t))return t;t=t.getNextSibling()}return null}function Je(e){let t=e.getPreviousSibling();for(;t!==null;){if(de(t))return t;t=t.getPreviousSibling()}return null}import{jsx as Pe}from"react/jsx-runtime";import{useLexicalComposerContext as ko}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as _o,isHTMLElement as vo}from"lexical";import*as Ze from"react";import{useCallback as Do,useEffect as Xe,useRef as Lo,useState as Mo}from"react";import{createPortal as Ao}from"react-dom";var U=(e,t,o,n,r=50,c=25)=>{let l=0;if(e&&!e.contains(n)){let{bottom:s,left:a,right:f,top:p}=e.getBoundingClientRect(),u=p+window.scrollY,i=s+window.scrollY;if(o<u-c||o>i+c||t<a-r||t>f+r)return-1;(t<a||t>f)&&(l=t<a?t-a:t-f)}return l};import{$getNodeByKey as me}from"lexical";function J(e){let t=e.getBoundingClientRect(),o=getComputedStyle(e).getPropertyValue("transform");if(!o||o==="none")return t;let n=o.split(",").pop();return t.y=t.y-Number(n?.replace(")","")),t}function fe(e){let t=(a,f)=>a?parseFloat(window.getComputedStyle(a)[f]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(e),r=t(e.previousElementSibling,"marginBottom"),c=t(e.nextElementSibling,"marginTop"),l=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),c),marginTop:l}}import{$getRoot as wo}from"lexical";function z(e){return e.getEditorState().read(()=>wo().getChildrenKeys())}var So=1,Po=-1,qe=0,A={props:null,result:null};function Ro(e,t,o=20){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=o*o}function q(e){let{anchorElem:t,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:c=0,point:{x:l,y:s},startIndex:a=0,useEdgeAsDefault:f=!1}=e;if(o>0&&A.props&&A.result&&A.props.fuzzy===e.fuzzy&&A.props.horizontalOffset===e.horizontalOffset&&A.props.useEdgeAsDefault===e.useEdgeAsDefault&&Ro(A.props.point,e.point,o))return A.result;let p=t.getBoundingClientRect(),u=z(n),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(f){let h=n.getElementByKey(u[0]),m=n.getElementByKey(u[u.length-1]);if(h&&m){let[d,g]=[J(h),J(m)];if(s<d.top?(i.blockElem=h,i.distance=d.top-s,i.blockNode=me(u[0]),i.foundAtIndex=0):s>g.bottom&&(i.distance=s-g.bottom,i.blockNode=me(u[u.length-1]),i.blockElem=m,i.foundAtIndex=u.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let y=a,x=qe;for(;y>=0&&y<u.length;){let h=u[y],m=n.getElementByKey(h);if(m===null)break;let d=new I(l+c,s),g=$e.fromDOMRect(J(m)),{marginBottom:C,marginTop:P}=fe(m),R=g.generateNewRect({bottom:g.bottom+C,left:p.left,right:p.right,top:g.top-P}),{distance:S,isOnBottomSide:k,isOnTopSide:N}=R.distanceFromPoint(d);if(S===0){i.blockElem=m,i.blockNode=me(h),i.foundAtIndex=y,i.distance=S,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!r&&!e.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else r&&S<i.distance&&(i.blockElem=m,i.blockNode=me(h),i.distance=S,i.foundAtIndex=y);x===qe&&(N?x=Po:k?x=So:x=1/0),y+=x}}),A.props=e,A.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 pe(e,t){return!!e.closest(`.${t}`)}var To=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Qe(e){if(!e||To.includes(e.tagName)||e.offsetHeight===0||e.offsetWidth===0)return!1;let t=window.getComputedStyle(e);return!(t.display==="table-cell"||t.position==="absolute"||t.visibility==="hidden"||t.opacity==="0")}function ge(e,t,o,n=0){if(!e){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}let r=e.getBoundingClientRect(),c=window.getComputedStyle(e),l=t.getBoundingClientRect(),s=o.getBoundingClientRect(),a;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(u=>e.classList.contains(u)||e.firstElementChild?.classList.contains(u)))a=r.top+8-s.top;else{let u=Qe(e)?parseInt(c.lineHeight,10):0;a=r.top+(u-l.height)/2-s.top}let p=n;t.style.opacity="1",t.style.transform=`translate(${p}px, ${a}px)`}var Bo="add-block-menu",he=1/0;function Oo(e){return e===0?1/0:he>=0&&he<e?he:Math.floor(e/2)}function Io(e,t,o){let n=t.parentElement,{editorConfig:r}=w(),c=r?.admin?.hideGutter?-24:12,l=Lo(null),[s,a]=Mo(null);Xe(()=>{function p(u){let i=u.target;if(!vo(i))return;let y=U(n,u.pageX,u.pageY,i);if(y===-1){a(null);return}if(pe(i,Bo))return;let x=z(e),{blockElem:h,blockNode:m,foundAtIndex:d}=q({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-y,point:new I(u.x,u.y),returnEmptyParagraphs:!0,startIndex:Oo(x.length),useEdgeAsDefault:!1});he=d,h&&m&&(s?.node!==m||s?.elem!==h)&&a({elem:h,node:m})}return document?.addEventListener("mousemove",p),()=>{document?.removeEventListener("mousemove",p)}},[n,t,e,s]),Xe(()=>{l.current&&s?.node&&ge(s?.elem,l.current,t,c)},[t,s,c]);let f=Do(p=>{let u=s;u?.node&&(e.update(()=>{let i=!0;if((u?.node.getType()!=="paragraph"||u.node.getTextContent()!=="")&&(i=!1),!i){let y=_o();u?.node.insertAfter(y),setTimeout(()=>{u={elem:e.getElementByKey(y.getKey()),node:y},a(u)},0)}}),setTimeout(()=>{e.update(()=>{e.focus(),u?.node&&"select"in u.node&&typeof u.node.select=="function"&&u.node.select()})},1),setTimeout(()=>{e.dispatchCommand(Ie,{node:u?.node})},2),p.stopPropagation(),p.preventDefault())},[e,s]);return Ao(Pe(Ze.Fragment,{children:Pe("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:p=>{f(p)},ref:l,type:"button",children:Pe("div",{className:o?"icon":""})})}),t)}function et(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=ko();return Io(n,o,n._editable)}import{jsx as ye,jsxs as $o}from"react/jsx-runtime";import{useLexicalComposerContext as Ko}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as nt}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as rt,$getNodeByKey as jo,isHTMLElement as Re}from"lexical";import*as ct from"react";import{useEffect as Te,useRef as xe,useState as it}from"react";import{createPortal as zo}from"react-dom";var tt=0,Fo=-24;var H=0;function ot(e,t,o,n,r,c,l,s,a,f=!1){let{height:p,top:u}=n.getBoundingClientRect(),{top:i,width:y}=l.getBoundingClientRect(),{marginBottom:x,marginTop:h}=fe(n),m=u,d=c>=u+p/2+window.scrollY,g=!1;if(r?.elem)if(n!==r?.elem)(d&&r?.elem&&r?.elem===n.nextElementSibling||!d&&r?.elem&&r?.elem===n.previousElementSibling)&&(H++,H<200&&(g=!0));else{H++;let S=r?.boundingBox?.y,k=n.getBoundingClientRect().y;(d===r?.isBelow&&S===k||H<200)&&(g=!1)}if(g)return{isBelow:d,willStayInSamePosition:g};f?m+=p/2:d?m+=p+x/2:m-=h/2;let C=0;f||(d?C=-tt:C=tt);let P=m-i+C,R=Fo-t;return o.style.width=`calc(${y}px - ${e})`,o.style.opacity=".8",o.style.transform=`translate(${R}px, calc(${P}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?d?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),H=0,{isBelow:d,willStayInSamePosition:g}}var Ho="draggable-block-menu",st="application/x-lexical-drag-block",re=1/0;function lt(e){return e===0?1/0:re>=0&&re<e?re:Math.floor(e/2)}function Vo(e,t){let{transform:o}=t.style;e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function at(e,t){e&&(e.style.opacity="0"),t&&(t.style.opacity="",t.style.marginBottom="",t.style.marginTop="")}function Wo(e,t,o){let n=t.parentElement,r=xe(null),c=xe(null),l=xe(null),s=xe(!1),[a,f]=it(null),[p,u]=it(null),{editorConfig:i}=w(),y=i?.admin?.hideGutter?-44:-8;Te(()=>{function m(d){let g=d.target;if(!Re(g))return;let C=U(n,d.pageX,d.pageY,g);if(C===-1){f(null);return}if(pe(g,Ho))return;let P=z(e),{blockElem:R,foundAtIndex:S,isFoundNodeEmptyParagraph:k}=q({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-C,point:new I(d.x,d.y),startIndex:lt(P.length),useEdgeAsDefault:!1,verbose:!1});re=S,!(!R&&!k)&&a!==R&&f(R)}return document?.addEventListener("mousemove",m),()=>{document?.removeEventListener("mousemove",m)}},[n,t,e,a]),Te(()=>{r.current&&ge(a,r.current,t,y)},[t,a,y]),Te(()=>{function m(g){if(!s.current)return!1;let[C]=nt(g);if(C)return!1;let{pageY:P,target:R}=g;if(!Re(R))return!1;let S=U(n,g.pageX,g.pageY,R,100,50),k=z(e),{blockElem:N,foundAtIndex:ee,isFoundNodeEmptyParagraph:v}=q({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-S,point:new I(g.x,g.y),startIndex:lt(k.length),useEdgeAsDefault:!0,verbose:!0});re=ee;let T=c.current;if(N===null||T===null)return!1;if(a!==N){let{isBelow:_,willStayInSamePosition:V}=ot(i?.admin?.hideGutter?"0px":"3rem",y+(i?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),T,N,p,P,t,g,l,v);g.preventDefault(),V||u({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:_})}else p?.elem&&(at(T,p.elem),u({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function d(g){if(!s.current)return!1;let[C]=nt(g);if(C)return!1;let{dataTransfer:P,pageY:R,target:S}=g,k=P?.getData(st)||"";return e.update(()=>{let N=jo(k);if(!N||!Re(S))return!1;let ee=U(n,g.pageX,g.pageY,S,100,50),{blockElem:v,isFoundNodeEmptyParagraph:T}=q({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-ee,point:new I(g.x,g.y),useEdgeAsDefault:!0});if(!v)return!1;let _=rt(v);if(!_)return!1;if(_===N)return!0;let{height:V,top:$}=J(v),W=R>=$+V/2+window.scrollY;T?(_.insertBefore(N),_.remove()):W?_.insertAfter(N):_.insertBefore(N),a!==null&&f(null),document.querySelectorAll(".lexical-block-highlighter").forEach(L=>{L.remove()});let Ee=e.getElementByKey(N.getKey());setTimeout(()=>{let L=Ee?.getBoundingClientRect();if(!L)return;let b=document.createElement("div");b.className="lexical-block-highlighter",b.style.backgroundColor="var(--theme-elevation-1000",b.style.transition="opacity 0.5s ease-in-out",b.style.zIndex="1",b.style.pointerEvents="none",b.style.boxSizing="border-box",b.style.borderRadius="4px",b.style.position="absolute",document.body.appendChild(b),b.style.opacity="0.1",b.style.height=`${L.height+8}px`,b.style.width=`${L.width+8}px`,b.style.top=`${L.top+window.scrollY-4}px`,b.style.left=`${L.left-4}px`,setTimeout(()=>{b.style.opacity="0",setTimeout(()=>{b.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",m),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",m),document.removeEventListener("drop",d)}},[n,y,t,e,p,a,i?.admin?.hideGutter]);function x(m){let d=m.dataTransfer;if(!d||!a)return;Vo(d,a);let g="";e.update(()=>{let C=rt(a);C&&(g=C.getKey())}),s.current=!0,d.setData(st,g)}function h(){s.current=!1,p?.elem&&at(c.current,p?.elem)}return zo($o(ct.Fragment,{children:[ye("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:h,onDragStart:x,ref:r,type:"button",children:ye("div",{className:o?"icon":""})}),ye("div",{className:"draggable-block-target-line",ref:c}),ye("div",{className:"debug-highlight",ref:l})]}),t)}function ut(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=Ko();return Wo(n,o,n._editable)}import{c as Yo}from"react/compiler-runtime";import{jsx as ke}from"react/jsx-runtime";import{useLexicalComposerContext as Go}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Uo,$getRoot as Jo}from"lexical";import"react";var dt="insert-paragraph-at-end",ft=()=>{let e=Yo(2),[t]=Go(),{editorConfig:o}=w();if(o?.admin?.hideInsertParagraphAtEnd)return null;let n;return e[0]!==t?(n=ke("div",{"aria-label":"Insert Paragraph",className:dt,onClick:()=>{t.update(qo)},role:"button",tabIndex:0,children:ke("div",{className:`${dt}-inside`,children:ke("span",{children:"+"})})}),e[0]=t,e[1]=n):n=e[1],n};function qo(){let e=Uo();Jo().append(e),e.select()}import{c as Qo}from"react/compiler-runtime";import{useLexicalComposerContext as Xo}from"@lexical/react/LexicalComposerContext";import*as mt from"react";var pt=()=>{let e=Qo(4),{editorConfig:t}=w(),[o]=Xo(),n,r;return e[0]!==o||e[1]!==t.features.markdownTransformers?(n=()=>Ae(o,t.features.markdownTransformers??[]),r=[o,t.features.markdownTransformers],e[0]=o,e[1]=t.features.markdownTransformers,e[2]=n,e[3]=r):(n=e[2],r=e[3]),mt.useEffect(n,r),null};import{c as Zo}from"react/compiler-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext.js";import{$getRoot as tn,HISTORY_MERGE_TAG as on}from"lexical";import{useEffect as nn}from"react";function rn(e){e.update(()=>{let t=o=>{let n=o.getType();if((n==="block"||n==="inlineBlock")&&o.markDirty(),"getChildren"in o&&typeof o.getChildren=="function")for(let r of o.getChildren())t(r)};t(tn())},{tag:on})}function gt(){let e=Zo(5),[t]=en(),{currentView:o,views:n}=O(),r,c;return e[0]!==o||e[1]!==t||e[2]!==n?(r=()=>{n&&(o==="default"?n.default?be(t,n.default?.nodes):Ne(t):n[o]&&(Ne(t),be(t,n[o]?.nodes)),rn(t))},c=[t,n,o],e[0]=o,e[1]=t,e[2]=n,e[3]=r,e[4]=c):(r=e[3],c=e[4]),nn(r,c),null}import{useLexicalComposerContext as sn}from"@lexical/react/LexicalComposerContext";import{$getSelection as ln,$isRangeSelection as an,RootNode as cn}from"lexical";import{useEffect as un}from"react";function ht(){let[e]=sn();return un(()=>e.registerNodeTransform(cn,t=>{let o=ln();if(an(o)){let n=o.anchor.getNode(),r=o.focus.getNode();(!n.isAttached()||!r.isAttached())&&(t.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[e]),null}import{useLexicalComposerContext as dn}from"@lexical/react/LexicalComposerContext";import{$getSelection as fn,COMMAND_PRIORITY_LOW as mn,SELECT_ALL_COMMAND as pn}from"lexical";import{useEffect as gn}from"react";function yt(){let[e]=dn();return gn(()=>e.registerCommand(pn,()=>{if(fn())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},mn),[e]),null}import{jsx as Q,jsxs as Ct}from"react/jsx-runtime";import{useLexicalComposerContext as yn}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as Et}from"@payloadcms/ui";import{useCallback as xn,useMemo as Cn,useState as En}from"react";import"react";import*as bt from"react-dom";import{c as hn}from"react/compiler-runtime";import"react";function xt(e,t){let o=hn(4),{maxLength:n,minLength:r}=t,c=n===void 0?75:n,l=r===void 0?1:r,s;return o[0]!==c||o[1]!==l||o[2]!==e?(s=a=>{let{query:f}=a,p="[^"+e+Oe+"\\s]",i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+p+"){0,"+c+"}))$").exec(f);if(i!==null){let y=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+y.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=c,o[1]=l,o[2]=e,o[3]=s):s=o[3],s}var B="slash-menu-popup";function bn({isSelected:e,item:t,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:l}}=w(),{i18n:s}=Et(),a=`${B}__item ${B}__item-${t.key}`;e&&(a+=` ${B}__item--selected`);let f=t.key;return t.label&&(f=typeof t.label=="function"?t.label({featureClientSchemaMap:c,i18n:s,schemaPath:l}):t.label),f.length>25&&(f=f.substring(0,25)+"..."),Ct("button",{"aria-selected":e,className:a,id:B+"__item-"+t.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[t?.Icon&&Q(t.Icon,{}),Q("span",{className:`${B}__item-text`,children:f})]},t.key)}function Nt({anchorElem:e=document.body}){let[t]=yn(),[o,n]=En(null),{editorConfig:r}=w(),{i18n:c}=Et(),{fieldProps:{featureClientSchemaMap:l,schemaPath:s}}=w(),a=xt("/",{minLength:0}),f=xn(()=>{let u=[];for(let i of r.features.slashMenu.dynamicGroups)if(o){let y=i({editor:t,queryString:o});u=u.concat(y)}return u},[t,o,r?.features]),p=Cn(()=>{let u=[];for(let i of r?.features.slashMenu.groups??[])u.push(i);if(o){let i=o.toLowerCase().replace(/[\s\-_]/g,"");u=u.map(x=>{let h=x.items.filter(m=>{let d=m.key;return m.label&&(d=typeof m.label=="function"?m.label({featureClientSchemaMap:l,i18n:c,schemaPath:s}):m.label),new RegExp(o,"gi").exec(d)||d.toLowerCase().replace(/[\s\-_]/g,"").includes(i)?!0:m.keywords!=null?m.keywords.some(C=>new RegExp(o,"gi").exec(C)?!0:C.toLowerCase().replace(/[\s\-_]/g,"").includes(i)):!1});return h.length?{...x,items:h}:null}),u=u.filter(x=>x!=null);let y=f();for(let x of y){let h=u.find(m=>m.key===x.key);h?u=u.filter(m=>m.key!==x.key):h={...x,items:[]},h?.items?.length&&(h.items=h.items.concat(h.items)),u.push(h)}}return u},[o,r?.features.slashMenu.groups,f,l,c,s]);return Q(Fe,{anchorElem:e,groups:p,menuRenderFn:(u,{selectedItemKey:i,selectItemAndCleanUp:y,setSelectedItemKey:x})=>u.current&&p.length?bt.createPortal(Q("div",{className:B,children:p.map(h=>{let m=h.key;return h.label&&l&&(m=typeof h.label=="function"?h.label({featureClientSchemaMap:l,i18n:c,schemaPath:s}):h.label),Ct("div",{className:`${B}__group ${B}__group-${h.key}`,children:[Q("div",{className:`${B}__group-title`,children:m}),h.items.map((d,g)=>Q(bn,{index:g,isSelected:i===d.key,item:d,onClick:()=>{x(d.key),y(d)},onMouseEnter:()=>{x(d.key)},ref:C=>{d.ref={current:C}}},d.key))]},h.key)})}),u.current):null,onQueryChange:n,triggerFn:a})}import{c as Nn}from"react/compiler-runtime";import{useLexicalComposerContext as wn}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Sn,TextNode as Pn}from"lexical";import{useEffect as Rn}from"react";function wt(e){let t=Nn(6),{features:o}=e,[n]=wn(),r;t[0]!==n||t[1]!==o.enabledFormats?(r=()=>{let l=Tn(o.enabledFormats);if(l.length!==0)return n.registerNodeTransform(Pn,s=>{l.forEach(a=>{s.hasFormat(a)&&s.toggleFormat(a)})})},t[0]=n,t[1]=o.enabledFormats,t[2]=r):r=t[2];let c;return t[3]!==n||t[4]!==o?(c=[n,o],t[3]=n,t[4]=o,t[5]=c):c=t[5],Rn(r,c),null}function Tn(e){let t=Object.keys(Sn),o=new Set(e);return t.filter(n=>!o.has(n))}import{c as kn}from"react/compiler-runtime";import{jsx as St}from"react/jsx-runtime";import{useLexicalComposerContext as _n}from"@lexical/react/LexicalComposerContext";import{ContentEditable as vn}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Dn}from"@payloadcms/ui";import"react";function Pt(e){let t=kn(5),{className:o,editorConfig:n}=e,{t:r}=Dn(),[,c]=_n(),{getTheme:l}=c,s;if(t[0]!==o||t[1]!==n?.admin?.placeholder||t[2]!==l||t[3]!==r){let a=l();s=St(vn,{"aria-placeholder":r("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:St("p",{className:a?.placeholder,children:n?.admin?.placeholder??r("lexical:general:placeholder")})}),t[0]=o,t[1]=n?.admin?.placeholder,t[2]=l,t[3]=r,t[4]=s}else s=t[4];return s}var Tt=e=>{let t=Ln(13),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:c,rtl:l}=e,s=w(),[a]=Mn(),f=Fn(),[p,u]=zn(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=d=>{d!==null&&u(d)},t[0]=i):i=t[0];let y=i,x,h;t[1]!==a||t[2]!==s?(x=()=>{if(!s?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}s?.parentEditor?.uuid&&s.parentEditor?.registerChild(s.uuid,s);let d=()=>{s.focusEditor(s)},g=()=>{s.blurEditor(s)},C=a.registerCommand(Kn,()=>(d(),!0),Rt),P=a.registerCommand($n,()=>(g(),!0),Rt);return()=>{C(),P(),s.parentEditor?.unregisterChild?.(s.uuid)}},h=[a,s],t[1]=a,t[2]=s,t[3]=x,t[4]=h):(x=t[3],h=t[4]),jn(x,h);let m;return t[5]!==o||t[6]!==n||t[7]!==p||t[8]!==f||t[9]!==r||t[10]!==c||t[11]!==l?(m=ie(X.Fragment,{children:[o.features.plugins?.map(Hn),ie("div",{className:"editor-container",dir:l?"rtl":void 0,ref:n,children:[o.features.plugins?.map(Vn),E(In,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:y,children:E(Pt,{editorConfig:o})})}),ErrorBoundary:An}),E(ht,{}),f&&E(ft,{}),E(Ge,{}),E(Ve,{}),E(wt,{features:o.features}),E(yt,{}),E(gt,{}),f&&E(On,{ignoreSelectionChange:!0,onChange:(d,g,C)=>{(!C.has("focus")||C.size>1)&&c?.(d,g,C)}}),p&&ie(X.Fragment,{children:[!r&&f&&ie(X.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:E(ut,{anchorElem:p}),o.admin?.hideAddBlockButton?null:E(et,{anchorElem:p})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&r))return E(K,{anchorElem:p,clientProps:d.clientProps,plugin:d},d.key)}),f&&E(X.Fragment,{children:E(Nt,{anchorElem:p})})]}),f&&ie(X.Fragment,{children:[E(Bn,{}),o?.features?.markdownTransformers?.length>0&&E(pt,{})]}),o.features.plugins?.map(Wn),o.features.plugins?.map(Yn)]}),o.features.plugins?.map(Gn)]}),t[5]=o,t[6]=n,t[7]=p,t[8]=f,t[9]=r,t[10]=c,t[11]=l,t[12]=m):m=t[12],m};function Hn(e){if(e.position==="aboveContainer")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Vn(e){if(e.position==="top")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Wn(e){if(e.position==="normal")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Yn(e){if(e.position==="bottom")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Gn(e){if(e.position==="belowContainer")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}var _t=({children:e,providers:t})=>{if(!t?.length)return e;let o=t[0];return t.length>1?F(o,{children:F(_t,{providers:t.slice(1),children:e})}):F(o,{children:e})},vt=e=>{let{composerKey:t,editorConfig:o,fieldProps:n,isSmallWidthViewport:r,onChange:c,readOnly:l,rtl:s,value:a}=e,{currentView:f,views:p}=O(),u=w(),i=Jn(),y=kt.useRef(null),x=qn(()=>{if(a&&typeof a!="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(a));if(a&&Array.isArray(a)&&!("root"in a))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(a&&"jsonContent"in a)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");let h=p?.[f]?.nodes;return{editable:l!==!0,editorState:a!=null?JSON.stringify(a):void 0,namespace:o.lexical.namespace,nodes:Ke({editorConfig:o,nodeViews:h}),onError:m=>{throw m},theme:o.lexical.theme}},[o,p,f]);return x?F(Un,{initialConfig:x,children:F(Me,{editorConfig:o,editorContainerRef:y,fieldProps:n,parentContext:u?.editDepth===i?u:void 0,children:F(_t,{providers:o.features.providers,children:F(Tt,{editorConfig:o,editorContainerRef:y,isSmallWidthViewport:r,onChange:c,rtl:s})})})},t+x.editable+f):F("p",{children:"Loading..."})};import{c as Qn}from"react/compiler-runtime";import{jsx as Z,jsxs as Xn}from"react/jsx-runtime";import{ChevronIcon as Zn,Popup as er,PopupList as Dt}from"@payloadcms/ui";import"react";function Lt(){let e=Qn(5),{currentView:t,setCurrentView:o,views:n}=O();if(!n||Object.keys(n).length===0)return null;let r,c;if(e[0]!==t||e[1]!==o||e[2]!==n){c=Symbol.for("react.early_return_sentinel");e:{let l=Object.keys(n);if(!l.some(or)){c=null;break e}let a=["default",...l.filter(tr)],f=t.charAt(0).toUpperCase()+t.slice(1);r=Z("div",{className:"lexical-view-selector",children:Z(er,{button:Xn("button",{className:"lexical-view-selector__button",type:"button",children:[Z("span",{className:"lexical-view-selector__label",children:f}),Z(Zn,{className:"lexical-view-selector__icon"})]}),buttonType:"custom",horizontalAlign:"left",render:p=>{let{close:u}=p;return Z(Dt.ButtonGroup,{children:a.map(i=>{let y=i.charAt(0).toUpperCase()+i.slice(1);return Z(Dt.Button,{active:i===t,disabled:i===t,onClick:()=>{o?.(i),u()},children:y},i)})})},size:"large"})})}e[0]=t,e[1]=o,e[2]=n,e[3]=r,e[4]=c}else r=e[3],c=e[4];return c!==Symbol.for("react.early_return_sentinel")?c:r}function tr(e){return e!=="default"}function or(e){return e!=="default"}var se="rich-text-lexical",yr=e=>{let{editorConfig:t,field:o,field:{admin:{className:n,description:r,readOnly:c}={},label:l,localized:s,required:a},path:f,readOnly:p,schemaPath:u,validate:i}=e,y=p||c,x=fr(),{config:{localization:h}}=ar(),m=lr({fieldLocalized:s,locale:x,localizationConfig:h||void 0}),d=cr(),{isControlledByParent:g}=O(),C=Bt((M,te)=>typeof i=="function"?i(M,{...te,required:a}):!0,[i,a]),{customComponents:{AfterInput:P,BeforeInput:R,Description:S,Error:k,Label:N}={},disabled:ee,initialValue:v,path:T,setValue:_,showError:V,value:$}=dr({potentiallyStalePath:f,validate:C}),Ce=y||ee,[W,_e]=It(!1),[Ee,L]=It(),b=At.useRef(v),Y=At.useRef($);Ot(()=>{let M=()=>{let te=window.matchMedia("(max-width: 768px)").matches;te!==W&&_e(te)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[W]);let Ft=["field-type",se,n,V&&"error",Ce&&`${se}--read-only`,t?.admin?.hideGutter!==!0&&!W?`${se}--show-gutter`:null].filter(Boolean).join(" "),ve=`${T}.${d}`,De=Be(),$t=Bt(M=>{De(()=>{let Le=M.toJSON();Y.current=Le,_(Le)})},[_,De]),Kt=gr(()=>mr(o),[o]),jt=ur(M=>{Y.current!==$&&!pr(Y.current!=null?JSON.parse(JSON.stringify(Y.current)):Y.current,$)&&(b.current=M,Y.current=$,L(new Date))});return Ot(()=>{Object.is(v,b.current)||jt(v)},[v]),le("div",{className:Ft,"data-field-path":T,"data-field-schemapath":u,"data-lexical-view":t?.view,style:Kt,children:[D(Mt,{CustomComponent:k,Fallback:D(ir,{path:T,showError:V})}),le("div",{className:`${se}__label-row`,children:[N||D(sr,{label:l,localized:s,path:T,required:a}),!g&&D(Lt,{})]}),le("div",{className:`${se}__wrap`,children:[le(hr,{fallbackRender:xr,onReset:()=>{},children:[R,D(nr,{drawerSlugPrefix:`lexical-${T}`,children:D(vt,{composerKey:ve,editorConfig:t,fieldProps:e,isSmallWidthViewport:W,onChange:$t,readOnly:Ce,rtl:m,value:$},JSON.stringify({path:T,rerenderProviderKey:Ee}))}),P]}),D(Mt,{CustomComponent:S,Fallback:D(rr,{description:r,path:T})})]})]},ve)};function xr({error:e}){return le("div",{className:"errorBoundary",role:"alert",children:[D("p",{children:"Something went wrong:"}),D("pre",{style:{color:"red"},children:e.message})]})}var _l=yr;export{_l as RichText};
|
|
2
|
+
//# sourceMappingURL=Field-5ZXLEL3U.js.map
|