@payloadcms/richtext-lexical 3.85.1 → 3.85.2
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-KR4W3EZZ.js → Field-J6MIUIWP.js} +2 -2
- package/dist/exports/client/chunk-QAW5QKEM.js +12 -0
- package/dist/exports/client/chunk-QAW5QKEM.js.map +7 -0
- package/dist/exports/client/index.js +2 -2
- package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js +160 -0
- package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.js +9 -2
- package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.js +3 -2
- package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +27 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js +88 -4
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/chunk-FTT5KJ6W.js +0 -12
- package/dist/exports/client/chunk-FTT5KJ6W.js.map +0 -7
- /package/dist/exports/client/{Field-KR4W3EZZ.js.map → Field-J6MIUIWP.js.map} +0 -0
|
@@ -1,2 +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 Ee,o as Ne,p as Ke}from"./chunk-FTT5KJ6W.js";import{a as Me,b as w}from"./chunk-BZZVLW4U.js";import{jsx as L,jsxs as le}from"react/jsx-runtime";import{BulkUploadProvider as er,FieldDescription as tr,FieldError as or,FieldLabel as nr,isFieldRTL as rr,RenderCustomComponent as Mt,useConfig as ir,useEditDepth as sr,useEffectEvent as lr,useField as ar,useLocale as cr}from"@payloadcms/ui";import{mergeFieldStyles as ur}from"@payloadcms/ui/shared";import{dequal as dr}from"dequal/lite";import At,{useCallback as Bt,useEffect as Ot,useMemo as fr,useState as It}from"react";import{ErrorBoundary as mr}from"react-error-boundary";import"./bundled.css";import{jsx as F}from"react/jsx-runtime";import{LexicalComposer as Wn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as Yn}from"@payloadcms/ui";import*as _t from"react";import{useMemo as Gn}from"react";import{c as kn}from"react/compiler-runtime";import{jsx as b,jsxs as ie}from"react/jsx-runtime";import{useLexicalComposerContext as vn}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ln}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Dn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Mn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as An}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as Bn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as On,COMMAND_PRIORITY_LOW as Rt,FOCUS_COMMAND as In}from"lexical";import*as X from"react";import{useEffect as Fn,useState as $n}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=Eo(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(bo),!0):!1}function bo(e){e.remove()}function Eo(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 _o}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as ko,isHTMLElement as vo}from"lexical";import*as Ze from"react";import{useCallback as Lo,useEffect as Xe,useRef as Do,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:_,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:_?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=Do(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=Lo(p=>{let u=s;u?.node&&(e.update(()=>{let i=!0;if((u?.node.getType()!=="paragraph"||u.node.getTextContent()!=="")&&(i=!1),!i){let y=ko();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]=_o();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,_=n.getBoundingClientRect().y;(d===r?.isBelow&&S===_||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:_}=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&&!_)&&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),_=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(_.length),useEdgeAsDefault:!0,verbose:!0});re=ee;let T=c.current;if(N===null||T===null)return!1;if(a!==N){let{isBelow:k,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:k})}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,_=P?.getData(st)||"";return e.update(()=>{let N=jo(_);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 k=rt(v);if(!k)return!1;if(k===N)return!0;let{height:V,top:$}=J(v),W=R>=$+V/2+window.scrollY;T?(k.insertBefore(N),k.remove()):W?k.insertAfter(N):k.insertBefore(N),a!==null&&f(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let be=e.getElementByKey(N.getKey());setTimeout(()=>{let D=be?.getBoundingClientRect();if(!D)return;let E=document.createElement("div");E.className="lexical-block-highlighter",E.style.backgroundColor="var(--theme-elevation-1000",E.style.transition="opacity 0.5s ease-in-out",E.style.zIndex="1",E.style.pointerEvents="none",E.style.boxSizing="border-box",E.style.borderRadius="4px",E.style.position="absolute",document.body.appendChild(E),E.style.opacity="0.1",E.style.height=`${D.height+8}px`,E.style.width=`${D.width+8}px`,E.style.top=`${D.top+window.scrollY-4}px`,E.style.left=`${D.left-4}px`,setTimeout(()=>{E.style.opacity="0",setTimeout(()=>{E.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 _e}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=_e("div",{"aria-label":"Insert Paragraph",className:dt,onClick:()=>{t.update(qo)},role:"button",tabIndex:0,children:_e("div",{className:`${dt}-inside`,children:_e("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{useEffect as tn}from"react";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?Ee(t,n.default?.nodes):Ne(t):n[o]&&(Ne(t),Ee(t,n[o]?.nodes)))},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]),tn(r,c),null}import{useLexicalComposerContext as on}from"@lexical/react/LexicalComposerContext";import{$getSelection as nn,$isRangeSelection as rn,RootNode as sn}from"lexical";import{useEffect as ln}from"react";function ht(){let[e]=on();return ln(()=>e.registerNodeTransform(sn,t=>{let o=nn();if(rn(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 an}from"@lexical/react/LexicalComposerContext";import{$getSelection as cn,COMMAND_PRIORITY_LOW as un,SELECT_ALL_COMMAND as dn}from"lexical";import{useEffect as fn}from"react";function yt(){let[e]=an();return fn(()=>e.registerCommand(dn,()=>{if(cn())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},un),[e]),null}import{jsx as Q,jsxs as Ct}from"react/jsx-runtime";import{useLexicalComposerContext as pn}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as bt}from"@payloadcms/ui";import{useCallback as gn,useMemo as hn,useState as yn}from"react";import"react";import*as Et from"react-dom";import{c as mn}from"react/compiler-runtime";import"react";function xt(e,t){let o=mn(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 xn({isSelected:e,item:t,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:l}}=w(),{i18n:s}=bt(),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]=pn(),[o,n]=yn(null),{editorConfig:r}=w(),{i18n:c}=bt(),{fieldProps:{featureClientSchemaMap:l,schemaPath:s}}=w(),a=xt("/",{minLength:0}),f=gn(()=>{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=hn(()=>{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?Et.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(xn,{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 Cn}from"react/compiler-runtime";import{useLexicalComposerContext as bn}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as En,TextNode as Nn}from"lexical";import{useEffect as wn}from"react";function wt(e){let t=Cn(6),{features:o}=e,[n]=bn(),r;t[0]!==n||t[1]!==o.enabledFormats?(r=()=>{let l=Sn(o.enabledFormats);if(l.length!==0)return n.registerNodeTransform(Nn,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],wn(r,c),null}function Sn(e){let t=Object.keys(En),o=new Set(e);return t.filter(n=>!o.has(n))}import{c as Pn}from"react/compiler-runtime";import{jsx as St}from"react/jsx-runtime";import{useLexicalComposerContext as Rn}from"@lexical/react/LexicalComposerContext";import{ContentEditable as Tn}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as _n}from"@payloadcms/ui";import"react";function Pt(e){let t=Pn(5),{className:o,editorConfig:n}=e,{t:r}=_n(),[,c]=Rn(),{getTheme:l}=c,s;if(t[0]!==o||t[1]!==n?.admin?.placeholder||t[2]!==l||t[3]!==r){let a=l();s=St(Tn,{"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=kn(13),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:c,rtl:l}=e,s=w(),[a]=vn(),f=Bn(),[p,u]=$n(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(In,()=>(d(),!0),Rt),P=a.registerCommand(On,()=>(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]),Fn(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(Kn),ie("div",{className:"editor-container",dir:l?"rtl":void 0,ref:n,children:[o.features.plugins?.map(jn),b(An,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:y,children:b(Pt,{editorConfig:o})})}),ErrorBoundary:Ln}),b(ht,{}),f&&b(ft,{}),b(Ge,{}),b(Ve,{}),b(wt,{features:o.features}),b(yt,{}),b(gt,{}),f&&b(Mn,{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:b(ut,{anchorElem:p}),o.admin?.hideAddBlockButton?null:b(et,{anchorElem:p})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&r))return b(K,{anchorElem:p,clientProps:d.clientProps,plugin:d},d.key)}),f&&b(X.Fragment,{children:b(Nt,{anchorElem:p})})]}),f&&ie(X.Fragment,{children:[b(Dn,{}),o?.features?.markdownTransformers?.length>0&&b(pt,{})]}),o.features.plugins?.map(zn),o.features.plugins?.map(Hn)]}),o.features.plugins?.map(Vn)]}),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 Kn(e){if(e.position==="aboveContainer")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function jn(e){if(e.position==="top")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function zn(e){if(e.position==="normal")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function Hn(e){if(e.position==="bottom")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function Vn(e){if(e.position==="belowContainer")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}var kt=({children:e,providers:t})=>{if(!t?.length)return e;let o=t[0];return t.length>1?F(o,{children:F(kt,{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=Yn(),y=_t.useRef(null),x=Gn(()=>{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(Wn,{initialConfig:x,children:F(Me,{editorConfig:o,editorContainerRef:y,fieldProps:n,parentContext:u?.editDepth===i?u:void 0,children:F(kt,{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 Un}from"react/compiler-runtime";import{jsx as Z,jsxs as Jn}from"react/jsx-runtime";import{ChevronIcon as qn,Popup as Qn,PopupList as Lt}from"@payloadcms/ui";import"react";function Dt(){let e=Un(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(Zn)){c=null;break e}let a=["default",...l.filter(Xn)],f=t.charAt(0).toUpperCase()+t.slice(1);r=Z("div",{className:"lexical-view-selector",children:Z(Qn,{button:Jn("button",{className:"lexical-view-selector__button",type:"button",children:[Z("span",{className:"lexical-view-selector__label",children:f}),Z(qn,{className:"lexical-view-selector__icon"})]}),buttonType:"custom",horizontalAlign:"left",render:p=>{let{close:u}=p;return Z(Lt.ButtonGroup,{children:a.map(i=>{let y=i.charAt(0).toUpperCase()+i.slice(1);return Z(Lt.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 Xn(e){return e!=="default"}function Zn(e){return e!=="default"}var se="rich-text-lexical",pr=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=cr(),{config:{localization:h}}=ir(),m=rr({fieldLocalized:s,locale:x,localizationConfig:h||void 0}),d=sr(),{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:_,Label:N}={},disabled:ee,initialValue:v,path:T,setValue:k,showError:V,value:$}=ar({potentiallyStalePath:f,validate:C}),Ce=y||ee,[W,ke]=It(!1),[be,D]=It(),E=At.useRef(v),Y=At.useRef($);Ot(()=>{let M=()=>{let te=window.matchMedia("(max-width: 768px)").matches;te!==W&&ke(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}`,Le=Be(),$t=Bt(M=>{Le(()=>{let De=M.toJSON();Y.current=De,k(De)})},[k,Le]),Kt=fr(()=>ur(o),[o]),jt=lr(M=>{Y.current!==$&&!dr(Y.current!=null?JSON.parse(JSON.stringify(Y.current)):Y.current,$)&&(E.current=M,Y.current=$,D(new Date))});return Ot(()=>{Object.is(v,E.current)||jt(v)},[v]),le("div",{className:Ft,"data-field-path":T,"data-field-schemapath":u,"data-lexical-view":t?.view,style:Kt,children:[L(Mt,{CustomComponent:_,Fallback:L(or,{path:T,showError:V})}),le("div",{className:`${se}__label-row`,children:[N||L(nr,{label:l,localized:s,path:T,required:a}),!g&&L(Dt,{})]}),le("div",{className:`${se}__wrap`,children:[le(mr,{fallbackRender:gr,onReset:()=>{},children:[R,L(er,{drawerSlugPrefix:`lexical-${T}`,children:L(vt,{composerKey:ve,editorConfig:t,fieldProps:e,isSmallWidthViewport:W,onChange:$t,readOnly:Ce,rtl:m,value:$},JSON.stringify({path:T,rerenderProviderKey:be}))}),P]}),L(Mt,{CustomComponent:S,Fallback:L(tr,{description:r,path:T})})]})]},ve)};function gr({error:e}){return le("div",{className:"errorBoundary",role:"alert",children:[L("p",{children:"Something went wrong:"}),L("pre",{style:{color:"red"},children:e.message})]})}var Pl=pr;export{Pl as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-
|
|
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 Ee,o as Ne,p as Ke}from"./chunk-QAW5QKEM.js";import{a as Me,b as w}from"./chunk-BZZVLW4U.js";import{jsx as L,jsxs as le}from"react/jsx-runtime";import{BulkUploadProvider as er,FieldDescription as tr,FieldError as or,FieldLabel as nr,isFieldRTL as rr,RenderCustomComponent as Mt,useConfig as ir,useEditDepth as sr,useEffectEvent as lr,useField as ar,useLocale as cr}from"@payloadcms/ui";import{mergeFieldStyles as ur}from"@payloadcms/ui/shared";import{dequal as dr}from"dequal/lite";import At,{useCallback as Bt,useEffect as Ot,useMemo as fr,useState as It}from"react";import{ErrorBoundary as mr}from"react-error-boundary";import"./bundled.css";import{jsx as F}from"react/jsx-runtime";import{LexicalComposer as Wn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as Yn}from"@payloadcms/ui";import*as _t from"react";import{useMemo as Gn}from"react";import{c as kn}from"react/compiler-runtime";import{jsx as b,jsxs as ie}from"react/jsx-runtime";import{useLexicalComposerContext as vn}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ln}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Dn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Mn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as An}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as Bn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as On,COMMAND_PRIORITY_LOW as Rt,FOCUS_COMMAND as In}from"lexical";import*as X from"react";import{useEffect as Fn,useState as $n}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=Eo(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(bo),!0):!1}function bo(e){e.remove()}function Eo(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 _o}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as ko,isHTMLElement as vo}from"lexical";import*as Ze from"react";import{useCallback as Lo,useEffect as Xe,useRef as Do,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:_,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:_?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=Do(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=Lo(p=>{let u=s;u?.node&&(e.update(()=>{let i=!0;if((u?.node.getType()!=="paragraph"||u.node.getTextContent()!=="")&&(i=!1),!i){let y=ko();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]=_o();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,_=n.getBoundingClientRect().y;(d===r?.isBelow&&S===_||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:_}=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&&!_)&&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),_=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(_.length),useEdgeAsDefault:!0,verbose:!0});re=ee;let T=c.current;if(N===null||T===null)return!1;if(a!==N){let{isBelow:k,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:k})}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,_=P?.getData(st)||"";return e.update(()=>{let N=jo(_);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 k=rt(v);if(!k)return!1;if(k===N)return!0;let{height:V,top:$}=J(v),W=R>=$+V/2+window.scrollY;T?(k.insertBefore(N),k.remove()):W?k.insertAfter(N):k.insertBefore(N),a!==null&&f(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let be=e.getElementByKey(N.getKey());setTimeout(()=>{let D=be?.getBoundingClientRect();if(!D)return;let E=document.createElement("div");E.className="lexical-block-highlighter",E.style.backgroundColor="var(--theme-elevation-1000",E.style.transition="opacity 0.5s ease-in-out",E.style.zIndex="1",E.style.pointerEvents="none",E.style.boxSizing="border-box",E.style.borderRadius="4px",E.style.position="absolute",document.body.appendChild(E),E.style.opacity="0.1",E.style.height=`${D.height+8}px`,E.style.width=`${D.width+8}px`,E.style.top=`${D.top+window.scrollY-4}px`,E.style.left=`${D.left-4}px`,setTimeout(()=>{E.style.opacity="0",setTimeout(()=>{E.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 _e}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=_e("div",{"aria-label":"Insert Paragraph",className:dt,onClick:()=>{t.update(qo)},role:"button",tabIndex:0,children:_e("div",{className:`${dt}-inside`,children:_e("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{useEffect as tn}from"react";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?Ee(t,n.default?.nodes):Ne(t):n[o]&&(Ne(t),Ee(t,n[o]?.nodes)))},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]),tn(r,c),null}import{useLexicalComposerContext as on}from"@lexical/react/LexicalComposerContext";import{$getSelection as nn,$isRangeSelection as rn,RootNode as sn}from"lexical";import{useEffect as ln}from"react";function ht(){let[e]=on();return ln(()=>e.registerNodeTransform(sn,t=>{let o=nn();if(rn(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 an}from"@lexical/react/LexicalComposerContext";import{$getSelection as cn,COMMAND_PRIORITY_LOW as un,SELECT_ALL_COMMAND as dn}from"lexical";import{useEffect as fn}from"react";function yt(){let[e]=an();return fn(()=>e.registerCommand(dn,()=>{if(cn())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},un),[e]),null}import{jsx as Q,jsxs as Ct}from"react/jsx-runtime";import{useLexicalComposerContext as pn}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as bt}from"@payloadcms/ui";import{useCallback as gn,useMemo as hn,useState as yn}from"react";import"react";import*as Et from"react-dom";import{c as mn}from"react/compiler-runtime";import"react";function xt(e,t){let o=mn(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 xn({isSelected:e,item:t,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:l}}=w(),{i18n:s}=bt(),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]=pn(),[o,n]=yn(null),{editorConfig:r}=w(),{i18n:c}=bt(),{fieldProps:{featureClientSchemaMap:l,schemaPath:s}}=w(),a=xt("/",{minLength:0}),f=gn(()=>{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=hn(()=>{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?Et.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(xn,{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 Cn}from"react/compiler-runtime";import{useLexicalComposerContext as bn}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as En,TextNode as Nn}from"lexical";import{useEffect as wn}from"react";function wt(e){let t=Cn(6),{features:o}=e,[n]=bn(),r;t[0]!==n||t[1]!==o.enabledFormats?(r=()=>{let l=Sn(o.enabledFormats);if(l.length!==0)return n.registerNodeTransform(Nn,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],wn(r,c),null}function Sn(e){let t=Object.keys(En),o=new Set(e);return t.filter(n=>!o.has(n))}import{c as Pn}from"react/compiler-runtime";import{jsx as St}from"react/jsx-runtime";import{useLexicalComposerContext as Rn}from"@lexical/react/LexicalComposerContext";import{ContentEditable as Tn}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as _n}from"@payloadcms/ui";import"react";function Pt(e){let t=Pn(5),{className:o,editorConfig:n}=e,{t:r}=_n(),[,c]=Rn(),{getTheme:l}=c,s;if(t[0]!==o||t[1]!==n?.admin?.placeholder||t[2]!==l||t[3]!==r){let a=l();s=St(Tn,{"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=kn(13),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:c,rtl:l}=e,s=w(),[a]=vn(),f=Bn(),[p,u]=$n(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(In,()=>(d(),!0),Rt),P=a.registerCommand(On,()=>(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]),Fn(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(Kn),ie("div",{className:"editor-container",dir:l?"rtl":void 0,ref:n,children:[o.features.plugins?.map(jn),b(An,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:y,children:b(Pt,{editorConfig:o})})}),ErrorBoundary:Ln}),b(ht,{}),f&&b(ft,{}),b(Ge,{}),b(Ve,{}),b(wt,{features:o.features}),b(yt,{}),b(gt,{}),f&&b(Mn,{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:b(ut,{anchorElem:p}),o.admin?.hideAddBlockButton?null:b(et,{anchorElem:p})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&r))return b(K,{anchorElem:p,clientProps:d.clientProps,plugin:d},d.key)}),f&&b(X.Fragment,{children:b(Nt,{anchorElem:p})})]}),f&&ie(X.Fragment,{children:[b(Dn,{}),o?.features?.markdownTransformers?.length>0&&b(pt,{})]}),o.features.plugins?.map(zn),o.features.plugins?.map(Hn)]}),o.features.plugins?.map(Vn)]}),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 Kn(e){if(e.position==="aboveContainer")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function jn(e){if(e.position==="top")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function zn(e){if(e.position==="normal")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function Hn(e){if(e.position==="bottom")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}function Vn(e){if(e.position==="belowContainer")return b(K,{clientProps:e.clientProps,plugin:e},e.key)}var kt=({children:e,providers:t})=>{if(!t?.length)return e;let o=t[0];return t.length>1?F(o,{children:F(kt,{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=Yn(),y=_t.useRef(null),x=Gn(()=>{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(Wn,{initialConfig:x,children:F(Me,{editorConfig:o,editorContainerRef:y,fieldProps:n,parentContext:u?.editDepth===i?u:void 0,children:F(kt,{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 Un}from"react/compiler-runtime";import{jsx as Z,jsxs as Jn}from"react/jsx-runtime";import{ChevronIcon as qn,Popup as Qn,PopupList as Lt}from"@payloadcms/ui";import"react";function Dt(){let e=Un(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(Zn)){c=null;break e}let a=["default",...l.filter(Xn)],f=t.charAt(0).toUpperCase()+t.slice(1);r=Z("div",{className:"lexical-view-selector",children:Z(Qn,{button:Jn("button",{className:"lexical-view-selector__button",type:"button",children:[Z("span",{className:"lexical-view-selector__label",children:f}),Z(qn,{className:"lexical-view-selector__icon"})]}),buttonType:"custom",horizontalAlign:"left",render:p=>{let{close:u}=p;return Z(Lt.ButtonGroup,{children:a.map(i=>{let y=i.charAt(0).toUpperCase()+i.slice(1);return Z(Lt.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 Xn(e){return e!=="default"}function Zn(e){return e!=="default"}var se="rich-text-lexical",pr=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=cr(),{config:{localization:h}}=ir(),m=rr({fieldLocalized:s,locale:x,localizationConfig:h||void 0}),d=sr(),{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:_,Label:N}={},disabled:ee,initialValue:v,path:T,setValue:k,showError:V,value:$}=ar({potentiallyStalePath:f,validate:C}),Ce=y||ee,[W,ke]=It(!1),[be,D]=It(),E=At.useRef(v),Y=At.useRef($);Ot(()=>{let M=()=>{let te=window.matchMedia("(max-width: 768px)").matches;te!==W&&ke(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}`,Le=Be(),$t=Bt(M=>{Le(()=>{let De=M.toJSON();Y.current=De,k(De)})},[k,Le]),Kt=fr(()=>ur(o),[o]),jt=lr(M=>{Y.current!==$&&!dr(Y.current!=null?JSON.parse(JSON.stringify(Y.current)):Y.current,$)&&(E.current=M,Y.current=$,D(new Date))});return Ot(()=>{Object.is(v,E.current)||jt(v)},[v]),le("div",{className:Ft,"data-field-path":T,"data-field-schemapath":u,"data-lexical-view":t?.view,style:Kt,children:[L(Mt,{CustomComponent:_,Fallback:L(or,{path:T,showError:V})}),le("div",{className:`${se}__label-row`,children:[N||L(nr,{label:l,localized:s,path:T,required:a}),!g&&L(Dt,{})]}),le("div",{className:`${se}__wrap`,children:[le(mr,{fallbackRender:gr,onReset:()=>{},children:[R,L(er,{drawerSlugPrefix:`lexical-${T}`,children:L(vt,{composerKey:ve,editorConfig:t,fieldProps:e,isSmallWidthViewport:W,onChange:$t,readOnly:Ce,rtl:m,value:$},JSON.stringify({path:T,rerenderProviderKey:be}))}),P]}),L(Mt,{CustomComponent:S,Fallback:L(tr,{description:r,path:T})})]})]},ve)};function gr({error:e}){return le("div",{className:"errorBoundary",role:"alert",children:[L("p",{children:"Something went wrong:"}),L("pre",{style:{color:"red"},children:e.message})]})}var Pl=pr;export{Pl as RichText};
|
|
2
|
+
//# sourceMappingURL=Field-J6MIUIWP.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var at=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";import{c as _e}from"react/compiler-runtime";import{useRef as Te}from"react";function pr(n){let t=_e(2),e=n===void 0?500:n,o=Te(void 0),r;return t[0]!==e?(r=c=>new Promise(i=>{let l=()=>{c(),i()};"requestIdleCallback"in window?("cancelIdleCallback"in window&&o.current!==void 0&&cancelIdleCallback(o.current),o.current=requestIdleCallback(l,{timeout:e})):we().then(l)}),t[0]=e,t[1]=r):r=t[1],r}function we(){return new Promise(n=>{setTimeout(n,100),requestAnimationFrame(()=>{setTimeout(n,0)})})}import{jsx as Ce}from"react/jsx-runtime";import{useControllableState as Se}from"@payloadcms/ui";import{createContext as Re,use as ke,useMemo as ye}from"react";var ft=Re({currentView:"default",inheritable:!1,setCurrentView:()=>{}}),Tr=n=>{let t=be(),e=n.currentView!==void 0,o=t.inheritable&&(!!t.views||!!t.hasExplicitCurrentView),r=e||t.inheritable&&!!t.hasExplicitCurrentView,{children:s,currentView:c,inheritable:i,views:l}={children:n.children,currentView:o?t.currentView:n.currentView,inheritable:t.inheritable||n.inheritable,views:o&&t.views?t.views:n.views},[a,f]=Se(c,"default"),p=l&&a!=="default"&&!l[a]?"default":a,m=ye(()=>{let g=l?l[p]:void 0;return{currentView:p,currentViewMap:g,hasExplicitCurrentView:r,inheritable:i,isControlledByParent:o,setCurrentView:f,views:l}},[p,i,r,o,f,l]);return Ce(ft,{value:m,children:s})};function be(){return ke(ft)}var G=class{_x;_y;constructor(t,e){this._x=t,this._y=e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}equals({x:t,y:e}){return this.x===t&&this.y===e}get x(){return this._x}get y(){return this._y}};function ut(n){return n instanceof G}import{jsx as ze}from"react/jsx-runtime";import{useLexicalComposerContext as We}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Ye}from"@lexical/utils";import{$getSelection as Y,$isRangeSelection as j,$isTextNode as je,COMMAND_PRIORITY_LOW as qe,createCommand as Qe,getDOMSelection as Je}from"lexical";import{useCallback as Ct,useEffect as St,useState as Ze}from"react";import*as W from"react";import{c as xt}from"react/compiler-runtime";import{useLexicalComposerContext as Et}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as dt}from"@lexical/utils";import{$getSelection as _t,$isRangeSelection as Oe,$setSelection as Ne,COMMAND_PRIORITY_LOW as mt,COMMAND_PRIORITY_NORMAL as $,createCommand as Fe,KEY_ARROW_DOWN_COMMAND as Ie,KEY_ARROW_UP_COMMAND as Me,KEY_ENTER_COMMAND as Le,KEY_ESCAPE_COMMAND as Ae,KEY_TAB_COMMAND as De}from"lexical";import{useCallback as z,useEffect as b,useLayoutEffect as $e,useMemo as Be,useRef as ve,useState as Pe}from"react";var He="slash-menu-popup",pt=n=>{let t=document.getElementById("slash-menu");if(!t)return;let e=t.getBoundingClientRect();e.top+e.height>window.innerHeight&&t.scrollIntoView({block:"center"}),e.top<0&&t.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function Ke(n,t,e){let o=e;for(let r=o;r<=t.length;r++)n.substring(n.length-r)===t.substring(0,r)&&(o=r);return o}function Ue(n){let t=_t();if(!Oe(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let o=e.getNode();if(!o.isSimpleText())return;let r=e.offset,s=o.getTextContent().slice(0,r),c=n.replaceableString.length,i=Ke(s,n.matchingString,c),l=r-i;if(l<0)return;let a;return l===0?[a]=o.splitText(r):[,a]=o.splitText(l,r),a}function Ve(n,t){let e=getComputedStyle(n),o=e.position==="absolute",r=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let s=n;s=s.parentElement;)if(e=getComputedStyle(s),!(o&&e.position==="static")&&r.test(e.overflow+e.overflowY+e.overflowX))return s;return document.body}function gt(n,t){let e=n.getBoundingClientRect(),o=t.getBoundingClientRect();return e.top>o.top&&e.top<o.bottom}function Xe(n,t,e,o){let r=xt(7),[s]=Et(),c,i;r[0]!==s||r[1]!==e||r[2]!==o||r[3]!==n||r[4]!==t?(c=()=>{let l=t.current;if(l!=null&&n!=null){let a=s.getRootElement(),f=a!=null?Ve(a,!1):document.body,p=!1,m=gt(l,f),g=function(){p||(window.requestAnimationFrame(function(){e(),p=!1}),p=!0);let d=gt(l,f);d!==m&&(m=d,o?.(d))},u=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",g,{capture:!0,passive:!0}),u.observe(l),()=>{u.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",g,!0)}}},i=[s,o,e,n,t],r[0]=s,r[1]=e,r[2]=o,r[3]=n,r[4]=t,r[5]=c,r[6]=i):(c=r[5],i=r[6]),b(c,i)}var ht=Fe("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function Tt({anchorElementRef:n,close:t,editor:e,groups:o,menuRenderFn:r,resolution:s,shouldSplitNodeWithQuery:c=!1}){let[i,l]=Pe(null),a=s.match&&s.match.matchingString||"",f=z(u=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${He}__item-${u.key}`),l(u.key))},[e]),p=z(()=>{if(o!==null&&a!=null){let u=o.flatMap(d=>d.items);if(u.length){let d=u[0];f(d)}}},[o,f,a]);b(()=>{p()},[a,p]);let m=z(u=>{t(),e.update(()=>{let d=s.match!=null&&c?Ue(s.match):null;d&&d.remove()}),setTimeout(()=>{let d;e.read(()=>{d=_t()?.clone()}),e.update(()=>{d&&Ne(d)}),u.onSelect({editor:e,queryString:s.match?s.match.matchingString:""})},0)},[e,c,s.match,t]);b(()=>()=>{let u=e.getRootElement();u!==null&&u.removeAttribute("aria-activedescendant")},[e]),$e(()=>{o===null?l(null):i===null&&p()},[o,i,f,p]),b(()=>dt(e.registerCommand(ht,({item:u})=>u.ref&&u.ref.current!=null?(pt(u.ref.current),!0):!1,mt)),[e,f]),b(()=>dt(e.registerCommand(Ie,u=>{let d=u;if(o!==null&&o.length&&i!==null){let h=o.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==h.length-1?x+1:0,_=h[E];if(!_)return!1;f(_),_.ref!=null&&_.ref.current&&e.dispatchCommand(ht,{index:E,item:_}),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(Me,u=>{let d=u;if(o!==null&&o.length&&i!==null){let h=o.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==0?x-1:h.length-1,_=h[E];if(!_)return!1;f(_),_.ref!=null&&_.ref.current&&pt(_.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(Ae,u=>{let d=u;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},mt),e.registerCommand(De,u=>{let d=u;if(o===null||i===null)return!1;let x=o.flatMap(E=>E.items).find(E=>E.key===i);return x?(d.preventDefault(),d.stopImmediatePropagation(),m(x),!0):!1},$),e.registerCommand(Le,u=>{if(o===null||i===null)return!1;let h=o.flatMap(x=>x.items).find(x=>x.key===i);return h?(u!==null&&(u.preventDefault(),u.stopImmediatePropagation()),m(h),!0):!1},$)),[m,t,e,o,i,f]);let g=Be(()=>({groups:o,selectedItemKey:i,selectItemAndCleanUp:m,setSelectedItemKey:l}),[m,i,o]);return r(n,g,s.match?s.match.matchingString:"")}function Ge(n,t){t!=null&&(n.className=t),n.setAttribute("aria-label","Slash menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function wt(n,t,e,o){let r=xt(14),[s]=Et(),c;r[0]===Symbol.for("react.memo_cache_sentinel")?(c=at?document.createElement("div"):null,r[0]=c):c=r[0];let i=ve(c),l;r[1]!==n||r[2]!==o||r[3]!==s||r[4]!==t?(l=()=>{if(i.current===null||parent===void 0)return;let u=s.getRootElement(),d=i.current,h=d.firstChild;if(u!==null&&t!==null){let{height:x,width:E}=t.getRect(),{left:_,top:T}=t.getRect(),y=T;if(T=T-(n.getBoundingClientRect().top+window.scrollY),_=_-(n.getBoundingClientRect().left+window.scrollX),d.style.left=`${_+window.scrollX}px`,d.style.height=`${x}px`,d.style.width=`${E}px`,h!==null){let w=h.getBoundingClientRect(),D=w.height,S=w.width,X=u.getBoundingClientRect(),ct=document.dir==="rtl"||document.documentElement.dir==="rtl",ge=n.getBoundingClientRect(),lt=Math.max(0,X.left);if(!ct&&_+S>X.right)d.style.left=`${X.right-S+window.scrollX}px`;else if(ct&&w.left<lt){let Ee=lt+S-ge.left;d.style.left=`${Ee+window.scrollX}px`}let he=y+D+32>window.innerHeight,xe=y<0;he&&!xe?d.style.top=`${T+32-D+window.scrollY-(x+24)}px`:d.style.top=`${T+window.scrollY+32}px`}d.isConnected||(Ge(d,o),n.append(d)),d.setAttribute("id","slash-menu"),i.current=d,u.setAttribute("aria-controls","slash-menu")}},r[1]=n,r[2]=o,r[3]=s,r[4]=t,r[5]=l):l=r[5];let a=l,f,p;r[6]!==s||r[7]!==a||r[8]!==t?(f=()=>{let u=s.getRootElement();if(t!==null)return a(),()=>{u!==null&&u.removeAttribute("aria-controls");let d=i.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},p=[s,a,t],r[6]=s,r[7]=a,r[8]=t,r[9]=f,r[10]=p):(f=r[9],p=r[10]),b(f,p);let m;return r[11]!==t||r[12]!==e?(m=u=>{t!==null&&(u||e(null))},r[11]=t,r[12]=e,r[13]=m):m=r[13],Xe(t,i,a,m),i}var $r=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function tn(n){let t=n.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let o=t.offset;return e.getTextContent().slice(0,o)}function Rt(n,t,e){let o=Je(e);if(o===null||!o.isCollapsed)return!1;let r=o.anchorNode,s=n,c=o.anchorOffset;if(r==null||c==null)return!1;try{t.setStart(r,s),t.setEnd(r,c>1?c:1)}catch{return!1}return!0}function en(n){let t;return n.getEditorState().read(()=>{let e=Y();j(e)&&(t=tn(e))}),t}function kt(n,t){return t!==0?!1:n.getEditorState().read(()=>{let e=Y();if(j(e)){let s=e.anchor.getNode().getPreviousSibling();return je(s)&&s.isTextEntity()}return!1})}function yt(n){W.startTransition?W.startTransition(n):n()}var nn=Qe("ENABLE_SLASH_MENU_COMMAND");function Br({anchorClassName:n,anchorElem:t,groups:e,menuRenderFn:o,onClose:r,onOpen:s,onQueryChange:c,triggerFn:i}){let[l]=We(),[a,f]=Ze(null),p=wt(t,a,f,n),m=Ct(()=>{f(null),r!=null&&a!==null&&r()},[r,a]),g=Ct(u=>{f(u),s!=null&&a===null&&s(u)},[s,a]);return St(()=>Ye(l.registerCommand(nn,({node:u})=>(l.getEditorState().read(()=>{let d={leadOffset:0,matchingString:"",replaceableString:""};if(!kt(l,d.leadOffset)&&u!==null){let h=l._window??window,x=h.document.createRange();Rt(d.leadOffset,x,h)!==null&&yt(()=>g({getRect:()=>x.getBoundingClientRect(),match:d}));return}}),!0),qe)),[l,g]),St(()=>{let u=()=>{l.getEditorState().read(()=>{let h=l._window??window,x=h.document.createRange(),E=Y(),_=en(l);if(!j(E)||!E.isCollapsed()||_===void 0||x===null){m();return}let T=i({editor:l,query:_});if(c(T?T.matchingString:null),T!==null&&!kt(l,T.leadOffset)&&Rt(T.leadOffset,x,h)!==null){yt(()=>g({getRect:()=>x.getBoundingClientRect(),match:T}));return}m()})},d=l.registerUpdateListener(u);return()=>{d()}},[l,i,c,a,m,g]),p.current===null||a===null||l===null?null:ze(Tt,{anchorElementRef:p,close:m,editor:l,groups:e,menuRenderFn:o,resolution:a,shouldSplitNodeWithQuery:!0})}var bt=class n{_bottom;_left;_right;_top;constructor(t,e,o,r){let[s,c]=e<=r?[e,r]:[r,e],[i,l]=t<=o?[t,o]:[o,t];this._top=s,this._right=l,this._left=i,this._bottom=c}static fromDOM(t){let{height:e,left:o,top:r,width:s}=t.getBoundingClientRect();return n.fromLWTH(o,s,r,e)}static fromDOMRect(t){let{height:e,left:o,top:r,width:s}=t;return n.fromLWTH(o,s,r,e)}static fromLTRB(t,e,o,r){return new n(t,e,o,r)}static fromLWTH(t,e,o,r){return new n(t,o,t+e,o+r)}static fromPoints(t,e){let{x:o,y:r}=t,{x:s,y:c}=e;return n.fromLTRB(o,r,s,c)}contains(t){if(ut(t)){let{x:c,y:i}=t,l=i<this._top,a=i>this._bottom,f=c<this._left,p=c>this._right;return{reason:{isOnBottomSide:a,isOnLeftSide:f,isOnRightSide:p,isOnTopSide:l},result:!l&&!a&&!f&&!p}}let{bottom:e,left:o,right:r,top:s}=t;return s>=this._top&&s<=this._bottom&&e>=this._top&&e<=this._bottom&&o>=this._left&&o<=this._right&&r>=this._left&&r<=this._right}distanceFromPoint(t){let e=this.contains(t);if(e.result)return{distance:0,isOnBottomSide:e.reason.isOnBottomSide,isOnLeftSide:e.reason.isOnLeftSide,isOnRightSide:e.reason.isOnRightSide,isOnTopSide:e.reason.isOnTopSide};let o=0,r=0;return t.x<this._left?o=this._left-t.x:t.x>this._right&&(o=t.x-this._right),t.y<this._top?r=this._top-t.y:t.y>this._bottom&&(r=t.y-this._bottom),{distance:Math.sqrt(o*o+r*r),isOnBottomSide:t.y>this._bottom,isOnLeftSide:t.x<this._left,isOnRightSide:t.x>this._right,isOnTopSide:t.y<this._top}}equals({bottom:t,left:e,right:o,top:r}){return r===this._top&&t===this._bottom&&e===this._left&&o===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:o=this.right,top:r=this.top}){return new n(e,r,o,t)}intersectsWith(t){let{height:e,left:o,top:r,width:s}=t,{height:c,left:i,top:l,width:a}=this,f=o+s>=i+a?o+s:i+a,p=r+e>=l+c?r+e:l+c,m=o<=i?o:i,g=r<=l?r:l;return f-m<=s+a&&p-g<=e+c}get bottom(){return this._bottom}get height(){return Math.abs(this._bottom-this._top)}get left(){return this._left}get right(){return this._right}get top(){return this._top}get width(){return Math.abs(this._left-this._right)}};import q from"react";var L=new WeakMap;function Ur(n,t){L.has(n)||L.set(n,new Map);let e=L.get(n);for(let[o,r]of Object.entries(t))if(!(!r||typeof r!="object")){if(o==="blocks"){for(let[s,c]of Object.entries(r))e.set(`block:${s}`,c);continue}if(o==="inlineBlocks"){for(let[s,c]of Object.entries(r))e.set(`inlineBlock:${s}`,c);continue}e.set(o,r)}}function Vr(n){L.delete(n)}function Ot(n,t,e){let o=L.get(n);if(t==="block"&&e?.__fields?.blockType){let r=e.__fields.blockType;return o?.get(`block:${r}`)}if(t==="inlineBlock"&&e?.__fields?.blockType){let r=e.__fields.blockType;return o?.get(`inlineBlock:${r}`)}return o?.get(t)}function rn({node:n,nodeType:t}){if(!("getType"in n)||n.getType()!==t)return;let e=n;if(e.prototype._originalDecorate||(e.prototype._originalDecorate=e.prototype.decorate),e.prototype._originalCreateDOM||(e.prototype._originalCreateDOM=e.prototype.createDOM),e.prototype.decorate&&!e.prototype._decorateOverridden){e.prototype._decorateOverridden=!0;let o=!!e.prototype.createDOM;e.prototype.decorate=function(r,s){let c=Ot(r,t,this);if(c){if(c.Component)return c.Component({config:s,editor:r,isEditor:!0,isJSXConverter:!1,node:this});if(c.createDOM&&c.html){let l=typeof c.html=="function"?c.html({config:s,editor:r,isEditor:!0,isJSXConverter:!1,node:this}):c.html;return q.createElement("span",{dangerouslySetInnerHTML:{__html:l}})}if(c.html&&o&&!c.createDOM)return q.createElement(q.Fragment);if(t==="block"){let l=c;if(l.Block||l.Label)return e.prototype._originalDecorate.call(this,r,s,l.Block,l.Label)}else if(t==="inlineBlock"){let l=c;if(l.Block||l.Label)return e.prototype._originalDecorate.call(this,r,s,l.Block,l.Label)}}return e.prototype._originalDecorate.call(this,r,s)}}e.prototype.createDOM&&!e.prototype._createDOMOverridden&&(e.prototype._createDOMOverridden=!0,e.prototype.createDOM=function(o,r){let s=Ot(r,t,this);if(s){if(s.createDOM)return s.createDOM({config:o,editor:r,node:this});if(s.html){let c=typeof s.html=="function"?s.html({config:o,editor:r,isEditor:!0,isJSXConverter:!1,node:this}):s.html,i=document.createElement("div");return i.innerHTML=c,i.firstElementChild||i}}return e.prototype._originalCreateDOM.call(this,o,r)})}function Xr({editorConfig:n,nodeViews:t}){let e=on({nodes:n.features.nodes});if(t){let o=new Set;for(let[r,s]of Object.entries(t))!s||typeof s!="object"||(r==="blocks"&&Object.keys(s).length>0?o.add("block"):r==="inlineBlocks"&&Object.keys(s).length>0?o.add("inlineBlock"):o.add(r));for(let r of e)if("getType"in r){let s=r.getType();o.has(s)&&rn({node:r,nodeType:s})}}return e}function on({nodes:n}){return n.map(t=>"node"in t?t.node:t)}import{$getRoot as $n,$getState as Bn,$isDecoratorNode as re,$isElementNode as H,$isLineBreakNode as vn,$isTextNode as K}from"lexical";import{$createListItemNode as sn,$createListNode as cn,$isListItemNode as ln,$isListNode as O,ListItemNode as Z,ListNode as tt}from"@lexical/list";import{$createHeadingNode as an,$createQuoteNode as fn,$isHeadingNode as un,$isQuoteNode as Nt,HeadingNode as dn,QuoteNode as mn}from"@lexical/rich-text";import{$createLineBreakNode as pn,$isLineBreakNode as gn,$isTextNode as hn,$setState as xn,createState as En}from"lexical";var Ft=/^[\t ]*$/,At=/^(\s*)(\d+)\.\s/,Dt=/^(\s*)[-*+]\s/,$t=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,Q=/^(#{1,6})\s/,Bt=/^>\s/,_n=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,It=/[ \t]*(\\`\\`\\`|```)$/,Tn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,wn=/^\|(.+)\|\s?$/,Cn=/^(\| ?:?-*:? ?)+\|\s?$/,Mt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,Lt=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,et=En("mdHardLineBreak",{parse:n=>typeof n=="string"&&/^(\\| {2,})$/.test(n)?n:""});function J(n){if(n.endsWith("\\"))return[n.slice(0,-1),"\\"];let t=n.match(/^(.*?\S)( {2,})$/);return t?[t[1],t[2]]:null}function Sn(n,t){for(let e=t-1;e>=0;e--){if(gn(n[e]))return!1;if(/\S/.test(n[e].getTextContent()))return!0}return!1}function Rn(n){let t=n.getChildren(),e=t.length-1,o=t[e];if(!hn(o))return null;let r=o.getTextContent(),s=J(r);if(s!==null){let[c,i]=s;return o.setTextContent(c),i}return/^ {2,}$/.test(r)&&Sn(t,e)?(o.setTextContent(""),r):null}function nt(n){let t=pn(),e=Rn(n);return e!==null&&xn(t,et,e),t}var kn=n=>(t,e,o)=>{let r=n(o);r.append(...e),t.replace(r),r.select(0,0)},vt=4;function yn(n){let t=n.match(/\t/g),e=n.match(/ /g),o=0;return t&&(o+=t.length),e&&(o+=Math.floor(e.length/vt)),o}var rt=n=>(t,e,o)=>{let r=t.getPreviousSibling(),s=t.getNextSibling(),c=sn(n==="check"?o[3]==="x":void 0);if(O(s)&&s.getListType()===n){let l=s.getFirstChild();l!==null?l.insertBefore(c):s.append(c),t.remove()}else if(O(r)&&r.getListType()===n)r.append(c),t.remove();else{let l=cn(n,n==="number"?Number(o[2]):void 0);l.append(c),t.replace(l)}c.append(...e),c.select(0,0);let i=yn(o[1]);i&&c.setIndent(i)},B=(n,t,e)=>{let o=[],r=n.getChildren(),s=0;for(let c of r)if(ln(c)){if(c.getChildrenSize()===1){let f=c.getFirstChild();if(O(f)){o.push(B(f,t,e+1));continue}}let i=" ".repeat(e*vt),l=n.getListType(),a=l==="number"?`${n.getStart()+s}. `:l==="check"?`- [${c.getChecked()?"x":" "}] `:"- ";o.push(i+a+t(c)),s++}return o.join(`
|
|
2
|
+
`)},Pt={type:"element",dependencies:[dn],export:(n,t)=>{if(!un(n))return null;let e=Number(n.getTag().slice(1));return"#".repeat(e)+" "+t(n)},regExp:Q,replace:kn(n=>{let t="h"+n[1].length;return an(t)})},Ht={type:"element",dependencies:[mn],export:(n,t)=>{if(!Nt(n))return null;let e=t(n).split(`
|
|
3
|
+
`),o=[];for(let r of e)o.push("> "+r);return o.join(`
|
|
4
|
+
`)},regExp:Bt,replace:(n,t,e,o)=>{if(o){let s=n.getPreviousSibling();if(Nt(s)){s.splice(s.getChildrenSize(),0,[nt(s),...t]),s.select(0,0),n.remove();return}}let r=fn();r.append(...t),n.replace(r),r.select(0,0)}},Kt={type:"element",dependencies:[tt,Z],export:(n,t)=>O(n)?B(n,t,0):null,regExp:Dt,replace:rt("bullet")},bn={type:"element",dependencies:[tt,Z],export:(n,t)=>O(n)?B(n,t,0):null,regExp:$t,replace:rt("check")},Ut={type:"element",dependencies:[tt,Z],export:(n,t)=>O(n)?B(n,t,0):null,regExp:At,replace:rt("number")},Vt={type:"text-format",format:["code"],tag:"`"},Xt={type:"text-format",format:["highlight"],tag:"=="},Gt={type:"text-format",format:["bold","italic"],tag:"***"},zt={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},Wt={type:"text-format",format:["bold"],tag:"**"},Yt={type:"text-format",format:["bold"],intraword:!1,tag:"__"},jt={type:"text-format",format:["strikethrough"],tag:"~~"},qt={type:"text-format",format:["italic"],tag:"*"},Qt={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function Jt(n,t){let e=n.split(`
|
|
5
|
+
`),o=!1,r=[],s=0;for(let c=0;c<e.length;c++){let i=e[c],l=r[r.length-1],a=c<e.length-1?J(i):null,f=l!==void 0&&J(l)!==null;if(Tn.test(i)){r.push(i);continue}if(It.test(i)){s===0&&(o=!0),s===1&&(o=!1),s>0&&s--,r.push(i);continue}if(_n.test(i)){o=!0,s++,r.push(i);continue}if(o){r.push(i);continue}Ft.test(i)||Ft.test(l)||!l||Q.test(l)||Q.test(i)||Bt.test(i)||At.test(i)||Dt.test(i)||$t.test(i)||wn.test(i)||Cn.test(i)||f||!t||Mt.test(i)||Lt.test(i)||Mt.test(l)||Lt.test(l)||It.test(l)?r.push(i):r[r.length-1]=l+" "+(a===null?i.trim():i.trimStart())}return r.join(`
|
|
6
|
+
`)}import{$isListItemNode as On,$isListNode as Zt}from"@lexical/list";import{$isHeadingNode as Nn,$isQuoteNode as Fn}from"@lexical/rich-text";import{$isParagraphNode as In,$isTextNode as Mn}from"lexical";var C={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...C,requiresParagraphStart:!0},Zr={...R,export:N(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},to={...R,export:N(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},eo={...R,export:N(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},no={...R,export:N(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},ro={...R,export:N(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},oo={...R,export:N(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},io={...R,export:An,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},so={...R,export:ot,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},co={...R,export:ot,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},lo={...R,export:ot,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},ao={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},fo={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},uo={...C,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},mo={...C,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},po={...C,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},go={...C,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},ho={...C,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},xo={...C,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Eo={...C,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},_o={...C,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},To={...C,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},wo={...C,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Co={...C,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},So={...C,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function N(n){return(t,e)=>Nn(t)&&t.getTag()==="h"+n?"#".repeat(n)+" "+e(t):null}function ot(n,t){return Zt(n)?te(n,t,0):null}var Ln=4;function te(n,t,e){let o=[],r=n.getChildren(),s=0;for(let c of r)if(On(c)){if(c.getChildrenSize()===1){let a=c.getFirstChild();if(Zt(a)){o.push(te(a,t,e+1));continue}}let i=" ".repeat(e*Ln),l=n.getListType()==="bullet"?"- ":`${n.getStart()+s}. `;o.push(i+l+t(c)),s++}return o.join(`
|
|
7
|
+
`)}function An(n,t){return Fn(n)?"> "+t(n):null}function v(n,t){let e={};for(let o of n){let r=t(o);r&&(e[r]?e[r].push(o):e[r]=[o])}return e}function F(n){let t=v(n,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var I=/[!-/:-@[-`{-~\s]/,Dn=/^\s{0,3}$/;function A(n){if(!In(n))return!1;let t=n.getFirstChild();return t==null||n.getChildrenSize()===1&&Mn(t)&&Dn.test(t.getTextContent())}function oe(n,t=!1){let e=F(n),o=[...e.multilineElement,...e.element],r=!t,s=e.textFormat.filter(c=>c.format.length===1).sort((c,i)=>c.format.includes("code")&&!i.format.includes("code")?1:!c.format.includes("code")&&i.format.includes("code")?-1:0);return c=>{let i=[],l=(c||$n()).getChildren();return l.forEach((a,f)=>{let p=Pn(a,o,s,e.textMatch);p!=null&&i.push(r&&f>0&&!A(a)&&!A(l[f-1])?`
|
|
8
|
+
`.concat(p):p)}),i.join(`
|
|
9
|
+
`)}}function Pn(n,t,e,o){for(let r of t){if(!r.export)continue;let s=r.export(n,c=>U(c,e,o));if(s!=null)return s}return H(n)?U(n,e,o):re(n)?n.getTextContent():null}function U(n,t,e,o,r){let s=[],c=n.getChildren();o||(o=[]),r||(r=[]);t:for(let i of c){for(let l of e){if(!l.export)continue;let a=l.export(i,f=>U(f,t,e,o,[...r,...o]),(f,p)=>ee(f,p,t,o,r));if(a!=null){s.push(a);continue t}}vn(i)?s.push(Hn(i)):K(i)?s.push(ee(i,i.getTextContent(),t,o,r)):H(i)?s.push(U(i,t,e,o,r)):re(i)&&s.push(i.getTextContent())}return s.join("")}function Hn(n){return Bn(n,et)+`
|
|
10
|
+
`}function ee(n,t,e,o,r){let s=t.trim(),c=s;n.hasFormat("code")||(c=c.replace(/([*_`~\\])/g,"\\$1"));let i="",l="",a="",f=ne(n,!0),p=ne(n,!1),m=new Set;for(let g of e){let u=g.format[0],d=g.tag;P(n,u)&&!m.has(u)&&(m.add(u),(!P(f,u)||!o.find(h=>h.tag===d))&&(o.push({format:u,tag:d}),i+=d))}for(let g=0;g<o.length;g++){let u=o[g],d=P(n,u.format),h=P(p,u.format);if(d&&h)continue;let x=[...o];for(;x.length>g;){let E=x.pop();r&&E&&r.find(_=>_.tag===E.tag)||(E&&typeof E.tag=="string"&&(d?h||(a+=E.tag):l+=E.tag),o.pop())}break}return c=i+c+a,l+t.replace(s,()=>c)}function ne(n,t){let e=t?n.getPreviousSibling():n.getNextSibling();if(!e){let o=n.getParentOrThrow();o.isInline()&&(e=t?o.getPreviousSibling():o.getNextSibling())}for(;e;){if(H(e)){if(!e.isInline())break;let o=t?e.getLastDescendant():e.getFirstDescendant();if(K(o))return o;e=t?e.getPreviousSibling():e.getNextSibling()}if(K(e))return e;if(!H(e))return null}return null}function P(n,t){return K(n)&&n.hasFormat(t)}import{$isListItemNode as Un,$isListNode as ae}from"@lexical/list";import{$isQuoteNode as Vn}from"@lexical/rich-text";import{$findMatchingParent as Xn}from"@lexical/utils";import{$createParagraphNode as Gn,$createTextNode as zn,$getRoot as Wn,$getSelection as Yn,$isParagraphNode as jn}from"lexical";import{$isTextNode as M}from"lexical";function ie(n,t){let e=n.getTextContent(),o=Kn(e,t);if(!o)return null;let r=o.index||0,s=r+o[0].length,c=t.transformersByTag[o[1]];return{endIndex:s,match:o,startIndex:r,transformer:c}}function Kn(n,t){let e=n.match(t.openTagsRegExp);if(e==null)return null;for(let o of e){let r=o.replace(/^\s/,""),s=t.fullMatchRegExpByTag[r];if(s==null)continue;let c=n.match(s),i=t.transformersByTag[r];if(c!=null&&i!=null){if(i.intraword!==!1)return c;let{index:l=0}=c,a=n[l-1],f=n[l+c[0].length];if((!a||I.test(a))&&(!f||I.test(f)))return c}}return null}function se(n,t,e,o,r){let s=n.getTextContent(),c,i,l;if(r[0]===s?l=n:t===0?[l,c]=n.splitText(e):[i,l,c]=n.splitText(t,e),l.setTextContent(r[2]),o)for(let a of o.format)l.hasFormat(a)||l.toggleFormat(a);return{nodeAfter:c,nodeBefore:i,transformedNode:l}}function ce(n,t){let e=n,o,r,s,c;for(let i of t){if(!i.replace||!i.importRegExp)continue;let l=e.getTextContent().match(i.importRegExp);if(!l)continue;let a=l.index||0,f=i.getEndIndex?i.getEndIndex(e,l):a+l[0].length;f!==!1&&(o===void 0||r===void 0||a<o&&f>r)&&(o=a,r=f,s=i,c=l)}return o===void 0||r===void 0||s===void 0||c===void 0?null:{endIndex:r,match:c,startIndex:o,transformer:s}}function le(n,t,e,o,r){let s,c,i;if(t===0?[i,s]=n.splitText(e):[c,i,s]=n.splitText(t,e),!o.replace)return null;let l=i?o.replace(i,r):void 0;return{nodeAfter:s,nodeBefore:c,transformedNode:l||void 0}}function k(n,t,e){let o=ie(n,t),r=ce(n,e);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){let i=se(n,o.startIndex,o.endIndex,o.transformer,o.match);i.nodeAfter&&M(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&k(i.nodeAfter,t,e),i.nodeBefore&&M(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&k(i.nodeBefore,t,e),i.transformedNode&&M(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&k(i.transformedNode,t,e)}else if(r){let i=le(n,r.startIndex,r.endIndex,r.transformer,r.match);if(!i)return;i.nodeAfter&&M(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&k(i.nodeAfter,t,e),i.nodeBefore&&M(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&k(i.nodeBefore,t,e),i.transformedNode&&M(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&k(i.transformedNode,t,e)}let c=n.getTextContent().replace(/\\([*_`~])/g,"$1");n.setTextContent(c)}function fe(n,t=!1){let e=F(n),o=Jn(e.textFormat);return(r,s)=>{let c=r.split(`
|
|
11
|
+
`),i=c.length,l=s||Wn();l.clear();for(let f=0;f<i;f++){let p=c[f],[m,g]=qn(c,f,e.multilineElement,l);if(m){f=g;continue}Qn(p,l,e.element,o,e.textMatch)}let a=l.getChildren();for(let f of a)!t&&A(f)&&l.getChildrenSize()>1&&f.remove();Yn()!==null&&l.selectStart()}}function qn(n,t,e,o){for(let r of e){let{handleImportAfterStartMatch:s,regExpEnd:c,regExpStart:i,replace:l}=r,a=n[t]?.match(i);if(!a)continue;if(s){let u=s({lines:n,rootNode:o,startLineIndex:t,startMatch:a,transformer:r});if(u===null)continue;if(u)return u}let f=typeof c=="object"&&"regExp"in c?c.regExp:c,p=c&&typeof c=="object"&&"optional"in c?c.optional:!c,m=t,g=n.length;for(;m<g;){let u=f?n[m]?.match(f):null;if(!u&&(!p||p&&m<g-1)){m++;continue}if(u&&t===m&&u.index===a.index){m++;continue}let d=[];if(u&&t===m)d.push(n[t].slice(a[0].length,-u[0].length));else for(let h=t;h<=m;h++){let x=n[h];if(h===t){let E=x.slice(a[0].length);d.push(E)}else if(h===m&&u){let E=x.slice(0,-u[0].length);d.push(E)}else d.push(x)}if(l(o,null,a,u,d,!0)!==!1)return[!0,m];break}}return[!1,t]}function Qn(n,t,e,o,r){let s=zn(n),c=Gn();c.append(s),t.append(c);for(let{regExp:i,replace:l}of e){let a=n.match(i);if(a&&(s.setTextContent(n.slice(a[0].length)),l(c,[s],a,!0)!==!1))break}if(k(s,o,r),c.isAttached()&&n.length>0){let i=c.getPreviousSibling();if(jn(i)||Vn(i)||ae(i)){let l=i;if(ae(i)){let a=i.getLastDescendant();a==null?l=null:l=Xn(a,Un)}l!=null&&l.getTextContentSize()>0&&(l.splice(l.getChildrenSize(),0,[nt(l),...c.getChildren()]),c.remove())}}}function Jn(n){let t={},e={},o=[],r="(?<![\\\\])";for(let s of n){let{tag:c}=s;t[c]=s;let i=c.replace(/([*^+])/g,"\\$1");o.push(i),c.length===1?e[c]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):e[c]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:t}}import{$createRangeSelection as Zn,$getSelection as it,$isLineBreakNode as tr,$isRangeSelection as st,$isRootOrShadowRoot as de,$isTextNode as me,$setSelection as er}from"lexical";function nr(n,t,e,o){let r=n.getParent();if(!de(r)||n.getFirstChild()!==t)return!1;let s=t.getTextContent();if(s[e-1]!==" ")return!1;for(let{regExp:c,replace:i}of o){let l=s.match(c);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let a=t.getNextSiblings(),[f,p]=t.splitText(e);f?.remove();let m=p?[p,...a]:a;if(i(n,m,l,!1)!==!1)return!0}}return!1}function rr(n,t,e,o){let r=n.getParent();if(!de(r)||n.getFirstChild()!==t)return!1;let s=t.getTextContent();if(s[e-1]!==" ")return!1;for(let{regExpEnd:c,regExpStart:i,replace:l}of o){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;let a=s.match(i);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let f=t.getNextSiblings(),[p,m]=t.splitText(e);p?.remove();let g=m?[m,...f]:f;if(l(n,g,a,null,null,!1)!==!1)return!0}}return!1}function or(n,t,e){let o=n.getTextContent(),r=o[t-1],s=e[r];if(s==null)return!1;t<o.length&&(o=o.slice(0,t));for(let c of s){if(!c.replace||!c.regExp)continue;let i=o.match(c.regExp);if(i===null)continue;let l=i.index||0,a=l+i[0].length,f;return l===0?[f]=n.splitText(a):[,f]=n.splitText(l,a),f&&(f.selectNext(0,0),c.replace(f,i)),!0}return!1}function ir(n,t,e){let o=n.getTextContent(),r=t-1,s=o[r],c=e[s];if(!c)return!1;for(let i of c){let{tag:l}=i,a=l.length,f=r-a+1;if(a>1&&!pe(o,f,l,0,a)||o[f-1]===" ")continue;let p=o[r+1];if(i.intraword===!1&&p&&!I.test(p))continue;let m=n,g=m,u=ue(o,f,l),d=g;for(;u<0&&(d=d.getPreviousSibling())&&!tr(d);)if(me(d)){let S=d.getTextContent();g=d,u=ue(S,S.length,l)}if(u<0||g===m&&u+a===f)continue;let h=g.getTextContent();if(u>0&&h[u-1]===s)continue;let x=h[u-1];if(i.intraword===!1&&x&&!I.test(x))continue;let E=m.getTextContent(),_=E.slice(0,f)+E.slice(r+1);m.setTextContent(_);let T=g===m?_:h;g.setTextContent(T.slice(0,u)+T.slice(u+a));let y=it(),w=Zn();er(w);let D=r-a*(g===m?2:1)+1;w.anchor.set(g.__key,u,"text"),w.focus.set(m.__key,D,"text");for(let S of i.format)w.hasFormat(S)||w.formatText(S);w.anchor.set(w.focus.key,w.focus.offset,w.focus.type);for(let S of i.format)w.hasFormat(S)&&w.toggleFormat(S);return st(y)&&(w.format=y.format),!0}return!1}function ue(n,t,e){let o=e.length;for(let r=t;r>=o;r--){let s=r-o;if(pe(n,s,e,0,o)&&n[s+o]!==" ")return s}return-1}function pe(n,t,e,o,r){for(let s=0;s<r;s++)if(n[t+s]!==e[o+s])return!1;return!0}function Wo(n,t=V){let e=F(t),o=v(e.textFormat,({tag:c})=>c[c.length-1]),r=v(e.textMatch,({trigger:c})=>c);for(let c of t){let i=c.type;if(i==="element"||i==="text-match"||i==="multiline-element"){let l=c.dependencies;for(let a of l)if(!n.hasNode(a))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+a.getType())}}let s=(c,i,l)=>{nr(c,i,l,e.element)||rr(c,i,l,e.multilineElement)||or(i,l,r)||ir(i,l,o)};return n.registerUpdateListener(({dirtyLeaves:c,editorState:i,prevEditorState:l,tags:a})=>{if(a.has("collaboration")||a.has("historic")||n.isComposing())return;let f=i.read(it),p=l.read(it);if(!st(p)||!st(f)||!f.isCollapsed()||f.is(p))return;let m=f.anchor.key,g=f.anchor.offset,u=i._nodeMap.get(m);!me(u)||!c.has(m)||g!==1&&g>p.anchor.offset+1||n.update(()=>{if(u.hasFormat("code"))return;let d=u.getParent();d!==null&&s(d,u,f.anchor.offset)})})}var sr=[Pt,Ht,Kt,Ut],cr=[],lr=[Vt,Gt,zt,Wt,Yt,Xt,qt,Qt,jt],ar=[],V=[...sr,...cr,...lr,...ar];function Jo(n,t=V,e,o=!1,r=!0){let s=o?n:Jt(n,r);return fe(t,o)(s,e)}function Zo(n=V,t,e=!1){return oe(n,e)(t)}export{Wo as a,Jo as b,Zo as c,at as d,pr as e,Tr as f,be as g,G as h,ut as i,$r as j,nn as k,Br as l,bt as m,Ur as n,Vr as o,Xr as p};
|
|
12
|
+
//# sourceMappingURL=chunk-QAW5QKEM.js.map
|