@payloadcms/richtext-lexical 3.12.0 → 3.12.1-canary.7fea7e5
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-7XFZE2MU.js → Field-Q6F2LMIQ.js} +2 -2
- package/dist/exports/client/chunk-WCORQHZQ.js +12 -0
- package/dist/exports/client/chunk-WCORQHZQ.js.map +7 -0
- package/dist/exports/client/index.js +11 -11
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/link/markdownTransformer.d.ts.map +1 -1
- package/dist/features/link/markdownTransformer.js +6 -11
- package/dist/features/link/markdownTransformer.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.js +68 -14
- package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +6 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.js +3 -119
- package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +4 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +22 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +88 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +21 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +54 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -0
- package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +18 -0
- package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/importTextTransformers.js +55 -0
- package/dist/packages/@lexical/markdown/importTextTransformers.js.map +1 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts.map +1 -1
- package/dist/utilities/jsx/lexicalMarkdownCopy.js +11 -6
- package/dist/utilities/jsx/lexicalMarkdownCopy.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/chunk-XOABLBHB.js +0 -12
- package/dist/exports/client/chunk-XOABLBHB.js.map +0 -7
- /package/dist/exports/client/{Field-7XFZE2MU.js.map → Field-Q6F2LMIQ.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{c as fe,g as j,h as B,j as pe,k as ge,l as he,m as ye,n as xe}from"./chunk-XOABLBHB.js";import{a as de,b as R}from"./chunk-CUIBIFW2.js";import{jsx as F,jsxs as se}from"react/jsx-runtime";import{FieldDescription as eo,FieldError as to,FieldLabel as oo,RenderCustomComponent as Ze,useEditDepth as no,useField as ro}from"@payloadcms/ui";import{mergeFieldStyles as io}from"@payloadcms/ui/shared";import{useCallback as et,useMemo as so}from"react";import{ErrorBoundary as lo}from"react-error-boundary";import"./bundled.css";import{jsx as A}from"react/jsx-runtime";import{LexicalComposer as Xt}from"@lexical/react/LexicalComposer.js";import*as Je from"react";import{useMemo as Zt}from"react";import{c as $t}from"react/compiler-runtime";import{jsx as w,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Ht}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as jt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as zt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Kt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Gt}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Wt,COMMAND_PRIORITY_LOW as Ye,FOCUS_COMMAND as Yt}from"lexical";import*as Y from"react";import{useEffect as Ue,useState as Ve}from"react";import{jsx as Ee}from"react/jsx-runtime";import"react";var O=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ee(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ee(o.Component,{clientProps:e});import{jsx as ce}from"react/jsx-runtime";import{useLexicalComposerContext as st}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as lt}from"lexical";import*as Pe from"react";import{useCallback as at,useEffect as Ne,useRef as ct,useState as mt}from"react";import{createPortal as ut}from"react-dom";var z=(t,e,o,n,r=50,m=25)=>{let l=0;if(t&&!t.contains(n)){let{bottom:a,left:d,right:g,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,i=a+window.scrollY;if(o<s-m||o>i+m||e<d-r||e>g+r)return-1;(e<d||e>g)&&(l=e<d?e-d:e-g)}return l};import{$getNodeByKey as Z}from"lexical";function K(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let n=o.split(",").pop();return e.y=e.y-Number(n?.replace(")","")),e}function X(t){let e=(d,g)=>d?parseFloat(window.getComputedStyle(d)[g]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),m=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),m),marginTop:l}}import{$getRoot as tt}from"lexical";function _(t){return t.getEditorState().read(()=>tt().getChildrenKeys())}var ot=1,nt=-1,be=0,v={props:null,result:null};function rt(t,e,o=20){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:m=0,point:{x:l,y:a},startIndex:d=0,useEdgeAsDefault:g=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&rt(v.props.point,t.point,o))return v.result;let y=e.getBoundingClientRect(),s=_(n),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(g){let[p,h]=[n.getElementByKey(s[0]),n.getElementByKey(s[s.length-1])];if(p&&h){let[f,c]=[K(p),K(h)];if(a<f.top?(i.blockElem=p,i.distance=f.top-a,i.blockNode=Z(s[0]),i.foundAtIndex=0):a>c.bottom&&(i.distance=a-c.bottom,i.blockNode=Z(s[s.length-1]),i.blockElem=h,i.foundAtIndex=s.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let u=d,x=be;for(;u>=0&&u<s.length;){let p=s[u],h=n.getElementByKey(p);if(h===null)break;let f=new B(l+m,a),c=ye.fromDOMRect(K(h)),{marginBottom:E,marginTop:b}=X(h),N=c.generateNewRect({bottom:c.bottom+E,left:y.left,right:y.right,top:c.top-b}),{distance:C,isOnBottomSide:k,isOnTopSide:P}=N.distanceFromPoint(f);if(C===0){i.blockElem=h,i.blockNode=Z(p),i.foundAtIndex=u,i.distance=C,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else r&&C<i.distance&&(i.blockElem=h,i.blockNode=Z(p),i.distance=C,i.foundAtIndex=u);x===be&&(P?x=nt:k?x=ot:x=1/0),u+=x}}),v.props=t,v.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var it=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ce(t){if(!t||it.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function te(t,e,o,n=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),m=window.getComputedStyle(t),l=e.getBoundingClientRect(),a=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))d=r.top+8-a.top;else{let s=Ce(t)?parseInt(m.lineHeight,10):0;d=r.top+(s-l.height)/2-a.top}let y=n;e.style.opacity="1",e.style.transform=`translate(${y}px, ${d}px)`}var dt="add-block-menu",oe=1/0;function ft(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function pt(t,e,o){let n=e.parentElement,{editorConfig:r}=R(),m=r?.admin?.hideGutter?-24:12,l=ct(null),[a,d]=mt(null);Ne(()=>{function y(s){let i=s.target;if(!j(i))return;let u=z(n,s.pageX,s.pageY,i);if(u===-1){d(null);return}if(ee(i,dt))return;let x=_(t),{blockElem:p,blockNode:h,foundAtIndex:f}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-u,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:ft(x.length),useEdgeAsDefault:!1});oe=f,p&&h&&(a?.node!==h||a?.elem!==p)&&d({elem:p,node:h})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[n,e,t,a]),Ne(()=>{l.current&&a?.node&&te(a?.elem,l.current,e,m)},[e,a,m]);let g=at(y=>{let s=a;s?.node&&(t.update(()=>{let i=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(i=!1),!i){let u=lt();s?.node.insertAfter(u),setTimeout(()=>{s={elem:t.getElementByKey(u.getKey()),node:u},d(s)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),s?.node&&"select"in s.node&&typeof s.node.select=="function"&&s.node.select()})},1),setTimeout(()=>{t.dispatchCommand(ge,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,a]);return ut(ce(Pe.Fragment,{children:ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{g(y)},ref:l,type:"button",children:ce("div",{className:o?"icon":""})})}),e)}function we(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=st();return pt(n,o,n._editable)}import{jsx as ne,jsxs as ht}from"react/jsx-runtime";import{useLexicalComposerContext as yt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Se,$getNodeByKey as xt}from"lexical";import*as Ae from"react";import{useEffect as me,useRef as re,useState as ve}from"react";import{createPortal as Et}from"react-dom";var Te=0,gt=-24;var $=0;function Re(t,e,o,n,r,m,l,a,d,g=!1){let{height:y,top:s}=n.getBoundingClientRect(),{top:i,width:u}=l.getBoundingClientRect(),{marginBottom:x,marginTop:p}=X(n),h=s,f=m>=s+y/2+window.scrollY,c=!1;if(r?.elem)if(n!==r?.elem)(f&&r?.elem&&r?.elem===n.nextElementSibling||!f&&r?.elem&&r?.elem===n.previousElementSibling)&&($++,$<200&&(c=!0));else{$++;let C=r?.boundingBox?.y,k=n.getBoundingClientRect().y;(f===r?.isBelow&&C===k||$<200)&&(c=!1)}if(c)return{isBelow:f,willStayInSamePosition:c};g?h+=y/2:f?h+=y+x/2:h-=p/2;let E=0;g||(f?E=-Te:E=Te);let b=h-i+E,N=gt-e;return o.style.width=`calc(${u}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?f?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),$=0,{isBelow:f,willStayInSamePosition:c}}var bt="draggable-block-menu",Me="application/x-lexical-drag-block",V=1/0;function Le(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function Ct(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Be(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Nt(t,e,o){let n=e.parentElement,r=re(null),m=re(null),l=re(null),a=re(!1),[d,g]=ve(null),[y,s]=ve(null),{editorConfig:i}=R(),u=i?.admin?.hideGutter?-44:-8;me(()=>{function h(f){let c=f.target;if(!j(c))return;let E=z(n,f.pageX,f.pageY,c);if(E===-1){g(null);return}if(ee(c,bt))return;let b=_(t),{blockElem:N,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(f.x,f.y),startIndex:Le(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!N&&!k)&&d!==N&&g(N)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[n,e,t,d]),me(()=>{r.current&&te(d,r.current,e,u)},[e,d,u]),me(()=>{function h(c){if(!a.current)return!1;let[E]=ke(c);if(E)return!1;let{pageY:b,target:N}=c;if(!j(N))return!1;let C=z(n,c.pageX,c.pageY,N,100,50),k=_(t),{blockElem:P,foundAtIndex:H,isFoundNodeEmptyParagraph:L}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(c.x,c.y),startIndex:Le(k.length),useEdgeAsDefault:!0,verbose:!0});V=H;let I=m.current;if(P===null||I===null)return!1;if(d!==P){let{isBelow:S,willStayInSamePosition:U}=Re(i?.admin?.hideGutter?"0px":"3rem",u+(i?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),I,P,y,b,e,c,l,L);c.preventDefault(),U||s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:S})}else y?.elem&&(Be(I,y.elem),s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:!1}));return!0}function f(c){if(!a.current)return!1;let[E]=ke(c);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=c,k=b?.getData(Me)||"";return t.update(()=>{let P=xt(k);if(!P||!j(C))return!1;let H=z(n,c.pageX,c.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-H,point:new B(c.x,c.y),useEdgeAsDefault:!0});if(!L)return!1;let S=Se(L);if(!S)return!1;if(S===P)return!0;let{height:U,top:J}=K(L),le=N>=J+U/2+window.scrollY;I?(S.insertBefore(P),S.remove()):le?S.insertAfter(P):S.insertBefore(P),d!==null&&g(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let ae=t.getElementByKey(P.getKey());setTimeout(()=>{let D=ae?.getBoundingClientRect();if(!D)return;let T=document.createElement("div");T.className="lexical-block-highlighter",T.style.backgroundColor="var(--theme-elevation-1000",T.style.transition="opacity 0.5s ease-in-out",T.style.zIndex="1",T.style.pointerEvents="none",T.style.boxSizing="border-box",T.style.borderRadius="4px",T.style.position="absolute",document.body.appendChild(T),T.style.opacity="0.1",T.style.height=`${D.height+8}px`,T.style.width=`${D.width+8}px`,T.style.top=`${D.top+window.scrollY-4}px`,T.style.left=`${D.left-4}px`,setTimeout(()=>{T.style.opacity="0",setTimeout(()=>{T.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",f)}},[n,u,e,t,y,d,i?.admin?.hideGutter]);function x(h){let f=h.dataTransfer;if(!f||!d)return;Ct(f,d);let c="";t.update(()=>{let E=Se(d);E&&(c=E.getKey())}),a.current=!0,f.setData(Me,c)}function p(){a.current=!1,y?.elem&&Be(m.current,y?.elem)}return Et(ht(Ae.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:p,onDragStart:x,ref:r,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:m}),ne("div",{className:"debug-highlight",ref:l})]}),e)}function Fe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=yt();return Nt(n,o,n._editable)}import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import*as Ie from"react";var De=()=>{let t=Pt(4),{editorConfig:e}=R(),[o]=wt(),n,r;return t[0]!==o||t[1]!==e.features.markdownTransformers?(n=()=>fe(o,e.features.markdownTransformers??[]),r=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=n,t[3]=r):(n=t[2],r=t[3]),Ie.useEffect(n,r),null};import{jsx as W,jsxs as _e}from"react/jsx-runtime";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as $e}from"@payloadcms/ui";import{useCallback as kt,useMemo as St,useState as vt}from"react";import"react";import*as He from"react-dom";import{c as Tt}from"react/compiler-runtime";import"react";function Oe(t,e){let o=Tt(4),{maxLength:n,minLength:r}=e,m=n===void 0?75:n,l=r===void 0?1:r,a;return o[0]!==m||o[1]!==l||o[2]!==t?(a=d=>{let{query:g}=d,y="[^"+t+pe+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+m+"}))$").exec(g);if(i!==null){let u=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+u.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=m,o[1]=l,o[2]=t,o[3]=a):a=o[3],a}var M="slash-menu-popup";function Mt({isSelected:t,item:e,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:m,schemaPath:l}}=R(),{i18n:a}=$e(),d=`${M}__item ${M}__item-${e.key}`;t&&(d+=` ${M}__item--selected`);let g=e.key;return e.label&&(g=typeof e.label=="function"?e.label({featureClientSchemaMap:m,i18n:a,schemaPath:l}):e.label),g.length>25&&(g=g.substring(0,25)+"..."),_e("button",{"aria-selected":t,className:d,id:M+"__item-"+e.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&W(e.Icon,{}),W("span",{className:`${M}__item-text`,children:g})]},e.key)}function je({anchorElem:t=document.body}){let[e]=Rt(),[o,n]=vt(null),{editorConfig:r}=R(),{i18n:m}=$e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:a}}=R(),d=Oe("/",{minLength:0}),g=kt(()=>{let s=[];for(let i of r.features.slashMenu.dynamicGroups)if(o){let u=i({editor:e,queryString:o});s=s.concat(u)}return s},[e,o,r?.features]),y=St(()=>{let s=[];for(let i of r?.features.slashMenu.groups??[])s.push(i);if(o){s=s.map(u=>{let x=u.items.filter(p=>{let h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:m,schemaPath:a}):p.label),new RegExp(o,"gi").exec(h)?!0:p.keywords!=null?p.keywords.some(f=>new RegExp(o,"gi").exec(f)):!1});return x.length?{...u,items:x}:null}),s=s.filter(u=>u!=null);let i=g();for(let u of i){let x=s.find(p=>p.key===u.key);x?s=s.filter(p=>p.key!==u.key):x={...u,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,r?.features.slashMenu.groups,g,l,m,a]);return W(he,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:i,selectItemAndCleanUp:u,setSelectedItemKey:x})=>s.current&&y.length?He.createPortal(W("div",{className:M,children:y.map(p=>{let h=p.key;return p.label&&l&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:m,schemaPath:a}):p.label),_e("div",{className:`${M}__group ${M}__group-${p.key}`,children:[W("div",{className:`${M}__group-title`,children:h}),p.items.map((f,c)=>W(Mt,{index:c,isSelected:i===f.key,item:f,onClick:()=>{x(f.key),u(f)},onMouseEnter:()=>{x(f.key)},ref:E=>{f.ref={current:E}}},f.key))]},p.key)})}),s.current):null,onQueryChange:n,triggerFn:d})}import{c as Lt}from"react/compiler-runtime";import{useLexicalComposerContext as Bt}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as ze,TextNode as At}from"lexical";import{useEffect as Ft}from"react";function Ke(t){let e=Lt(6),{features:o}=t,[n]=Bt(),r;e[0]!==n||e[1]!==o.enabledFormats?(r=()=>{let l=It(o.enabledFormats);if(l.length!==0)return n.registerNodeTransform(At,a=>{l.forEach(d=>{a.hasFormat(d)&&a.toggleFormat(d)})})},e[0]=n,e[1]=o.enabledFormats,e[2]=r):r=e[2];let m;return e[3]!==n||e[4]!==o?(m=[n,o],e[3]=n,e[4]=o,e[5]=m):m=e[5],Ft(r,m),null}function It(t){delete ze.highlight;let e=Object.keys(ze),o=new Set(t);return e.filter(n=>!o.has(n))}import{c as Dt}from"react/compiler-runtime";import{jsx as Ge}from"react/jsx-runtime";import{ContentEditable as Ot}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as _t}from"@payloadcms/ui";import"react";function We(t){let e=Dt(3),{className:o}=t,{t:n}=_t(),r;return e[0]!==o||e[1]!==n?(r=Ge(Ot,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ge("p",{className:"editor-placeholder",children:n("lexical:general:placeholder")})}),e[0]=o,e[1]=n,e[2]=r):r=e[2],r}var qe=t=>{let e=$t(22),{editorConfig:o,editorContainerRef:n,onChange:r}=t,m=R(),[l]=Ht(),[a,d]=Ve(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=c=>{c!==null&&d(c)},e[0]=g):g=e[0];let y=g,s,i;e[1]!==l||e[2]!==m?(s=()=>{if(!m?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}m?.parentEditor?.uuid&&m.parentEditor?.registerChild(m.uuid,m);let c=()=>{m.focusEditor(m)},E=()=>{m.blurEditor(m)},b=l.registerCommand(Yt,()=>(c(),!0),Ye),N=l.registerCommand(Wt,()=>(E(),!0),Ye);return()=>{b(),N(),m.parentEditor?.unregisterChild?.(m.uuid)}},i=[l,m],e[1]=l,e[2]=m,e[3]=s,e[4]=i):(s=e[3],i=e[4]),Ue(s,i);let[u,x]=Ve(!1),p,h;e[5]!==u?(p=()=>{let c=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==u&&x(E)};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},h=[u],e[5]=u,e[6]=p,e[7]=h):(p=e[6],h=e[7]),Ue(p,h);let f;if(e[8]!==l||e[9]!==o.features||e[10]!==n||e[11]!==a||e[12]!==u||e[13]!==r){let c;e[15]!==r?(c=(b,N,C)=>{(!C.has("focus")||C.size>1)&&r?.(b,N,C)},e[15]=r,e[16]=c):c=e[16];let E;e[17]!==l||e[18]!==o.features.plugins||e[19]!==a||e[20]!==u?(E=a&&q(Y.Fragment,{children:[!u&&l.isEditable()&&q(Y.Fragment,{children:[w(Fe,{anchorElem:a}),w(we,{anchorElem:a})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&u))return w(O,{anchorElem:a,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&w(Y.Fragment,{children:w(je,{anchorElem:a})})]}),e[17]=l,e[18]=o.features.plugins,e[19]=a,e[20]=u,e[21]=E):E=e[21],f=q(Y.Fragment,{children:[o.features.plugins?.map(Ut),q("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(Vt),w(Gt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:y,tabIndex:-1,children:w(We,{})})}),ErrorBoundary:jt}),w(Ke,{features:o.features}),w(Kt,{ignoreSelectionChange:!0,onChange:c}),E,l.isEditable()&&q(Y.Fragment,{children:[w(zt,{}),o?.features?.markdownTransformers?.length>0&&w(De,{})]}),o.features.plugins?.map(qt),o.features.plugins?.map(Jt)]}),o.features.plugins?.map(Qt)]}),e[8]=l,e[9]=o.features,e[10]=n,e[11]=a,e[12]=u,e[13]=r,e[14]=f}else f=e[14];return f};function Ut(t){if(t.position==="aboveContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Vt(t){if(t.position==="top")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function qt(t){if(t.position==="normal")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Jt(t){if(t.position==="bottom")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Qt(t){if(t.position==="belowContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}var Qe=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?A(o,{children:A(Qe,{providers:e.slice(1),children:t})}):A(o,{children:t})},Xe=t=>{let{composerKey:e,editorConfig:o,fieldProps:n,onChange:r,readOnly:m,value:l}=t,a=R(),d=Je.useRef(null),g=Zt(()=>{if(l&&typeof l!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(l));if(l&&Array.isArray(l)&&!("root"in l))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:m!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:xe({editorConfig:o}),onError:y=>{throw y},theme:o.lexical.theme}},[o]);return g?A(Xt,{initialConfig:g,children:A(de,{editorConfig:o,editorContainerRef:d,fieldProps:n,parentContext:a,children:A(Qe,{providers:o.features.providers,children:A(qe,{editorConfig:o,editorContainerRef:d,onChange:r})})})},e+g.editable):A("p",{children:"Loading..."})};var ie="rich-text-lexical",ao=t=>{let{editorConfig:e,field:o,field:{name:n,admin:{className:r,description:m,readOnly:l}={},label:a,localized:d,required:g},path:y,readOnly:s,validate:i}=t,u=s||l,x=y??n,p=no(),h=et((Q,ae)=>typeof i=="function"?i(Q,{...ae,required:g}):!0,[i,g]),{customComponents:{AfterInput:f,BeforeInput:c,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:k,initialValue:P,setValue:H,showError:L,value:I}=ro({path:x,validate:h}),S=u||k||C,U=[ie,"field-type",r,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${p}`,ue=et(Q=>{H(Q.toJSON())},[H]),le=so(()=>io(o),[o]);return se("div",{className:U,style:le,children:[F(Ze,{CustomComponent:b,Fallback:F(to,{path:x,showError:L})}),N||F(oo,{label:a,localized:d,path:x,required:g}),se("div",{className:`${ie}__wrap`,children:[se(lo,{fallbackRender:co,onReset:()=>{},children:[c,F(Xe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:ue,readOnly:S,value:I},JSON.stringify({initialValue:P,path:x})),f]}),E,F(Ze,{CustomComponent:E,Fallback:F(eo,{description:m,path:x})})]})]},J)};function co({error:t}){return se("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Cr=ao;export{Cr as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-
|
|
1
|
+
"use client";import{c as fe,g as j,h as B,j as pe,k as ge,l as he,m as ye,n as xe}from"./chunk-WCORQHZQ.js";import{a as de,b as R}from"./chunk-CUIBIFW2.js";import{jsx as F,jsxs as se}from"react/jsx-runtime";import{FieldDescription as eo,FieldError as to,FieldLabel as oo,RenderCustomComponent as Ze,useEditDepth as no,useField as ro}from"@payloadcms/ui";import{mergeFieldStyles as io}from"@payloadcms/ui/shared";import{useCallback as et,useMemo as so}from"react";import{ErrorBoundary as lo}from"react-error-boundary";import"./bundled.css";import{jsx as A}from"react/jsx-runtime";import{LexicalComposer as Xt}from"@lexical/react/LexicalComposer.js";import*as Je from"react";import{useMemo as Zt}from"react";import{c as $t}from"react/compiler-runtime";import{jsx as w,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Ht}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as jt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as zt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Kt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Gt}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Wt,COMMAND_PRIORITY_LOW as Ye,FOCUS_COMMAND as Yt}from"lexical";import*as Y from"react";import{useEffect as Ue,useState as Ve}from"react";import{jsx as Ee}from"react/jsx-runtime";import"react";var O=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ee(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ee(o.Component,{clientProps:e});import{jsx as ce}from"react/jsx-runtime";import{useLexicalComposerContext as st}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as lt}from"lexical";import*as Pe from"react";import{useCallback as at,useEffect as Ne,useRef as ct,useState as mt}from"react";import{createPortal as ut}from"react-dom";var z=(t,e,o,n,r=50,m=25)=>{let l=0;if(t&&!t.contains(n)){let{bottom:a,left:d,right:g,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,i=a+window.scrollY;if(o<s-m||o>i+m||e<d-r||e>g+r)return-1;(e<d||e>g)&&(l=e<d?e-d:e-g)}return l};import{$getNodeByKey as Z}from"lexical";function K(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let n=o.split(",").pop();return e.y=e.y-Number(n?.replace(")","")),e}function X(t){let e=(d,g)=>d?parseFloat(window.getComputedStyle(d)[g]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),m=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),m),marginTop:l}}import{$getRoot as tt}from"lexical";function _(t){return t.getEditorState().read(()=>tt().getChildrenKeys())}var ot=1,nt=-1,be=0,v={props:null,result:null};function rt(t,e,o=20){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:m=0,point:{x:l,y:a},startIndex:d=0,useEdgeAsDefault:g=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&rt(v.props.point,t.point,o))return v.result;let y=e.getBoundingClientRect(),s=_(n),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(g){let[p,h]=[n.getElementByKey(s[0]),n.getElementByKey(s[s.length-1])];if(p&&h){let[f,c]=[K(p),K(h)];if(a<f.top?(i.blockElem=p,i.distance=f.top-a,i.blockNode=Z(s[0]),i.foundAtIndex=0):a>c.bottom&&(i.distance=a-c.bottom,i.blockNode=Z(s[s.length-1]),i.blockElem=h,i.foundAtIndex=s.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let u=d,x=be;for(;u>=0&&u<s.length;){let p=s[u],h=n.getElementByKey(p);if(h===null)break;let f=new B(l+m,a),c=ye.fromDOMRect(K(h)),{marginBottom:E,marginTop:b}=X(h),N=c.generateNewRect({bottom:c.bottom+E,left:y.left,right:y.right,top:c.top-b}),{distance:C,isOnBottomSide:k,isOnTopSide:P}=N.distanceFromPoint(f);if(C===0){i.blockElem=h,i.blockNode=Z(p),i.foundAtIndex=u,i.distance=C,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else r&&C<i.distance&&(i.blockElem=h,i.blockNode=Z(p),i.distance=C,i.foundAtIndex=u);x===be&&(P?x=nt:k?x=ot:x=1/0),u+=x}}),v.props=t,v.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var it=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ce(t){if(!t||it.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function te(t,e,o,n=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),m=window.getComputedStyle(t),l=e.getBoundingClientRect(),a=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))d=r.top+8-a.top;else{let s=Ce(t)?parseInt(m.lineHeight,10):0;d=r.top+(s-l.height)/2-a.top}let y=n;e.style.opacity="1",e.style.transform=`translate(${y}px, ${d}px)`}var dt="add-block-menu",oe=1/0;function ft(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function pt(t,e,o){let n=e.parentElement,{editorConfig:r}=R(),m=r?.admin?.hideGutter?-24:12,l=ct(null),[a,d]=mt(null);Ne(()=>{function y(s){let i=s.target;if(!j(i))return;let u=z(n,s.pageX,s.pageY,i);if(u===-1){d(null);return}if(ee(i,dt))return;let x=_(t),{blockElem:p,blockNode:h,foundAtIndex:f}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-u,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:ft(x.length),useEdgeAsDefault:!1});oe=f,p&&h&&(a?.node!==h||a?.elem!==p)&&d({elem:p,node:h})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[n,e,t,a]),Ne(()=>{l.current&&a?.node&&te(a?.elem,l.current,e,m)},[e,a,m]);let g=at(y=>{let s=a;s?.node&&(t.update(()=>{let i=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(i=!1),!i){let u=lt();s?.node.insertAfter(u),setTimeout(()=>{s={elem:t.getElementByKey(u.getKey()),node:u},d(s)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),s?.node&&"select"in s.node&&typeof s.node.select=="function"&&s.node.select()})},1),setTimeout(()=>{t.dispatchCommand(ge,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,a]);return ut(ce(Pe.Fragment,{children:ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{g(y)},ref:l,type:"button",children:ce("div",{className:o?"icon":""})})}),e)}function we(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=st();return pt(n,o,n._editable)}import{jsx as ne,jsxs as ht}from"react/jsx-runtime";import{useLexicalComposerContext as yt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Se,$getNodeByKey as xt}from"lexical";import*as Ae from"react";import{useEffect as me,useRef as re,useState as ve}from"react";import{createPortal as Et}from"react-dom";var Te=0,gt=-24;var $=0;function Re(t,e,o,n,r,m,l,a,d,g=!1){let{height:y,top:s}=n.getBoundingClientRect(),{top:i,width:u}=l.getBoundingClientRect(),{marginBottom:x,marginTop:p}=X(n),h=s,f=m>=s+y/2+window.scrollY,c=!1;if(r?.elem)if(n!==r?.elem)(f&&r?.elem&&r?.elem===n.nextElementSibling||!f&&r?.elem&&r?.elem===n.previousElementSibling)&&($++,$<200&&(c=!0));else{$++;let C=r?.boundingBox?.y,k=n.getBoundingClientRect().y;(f===r?.isBelow&&C===k||$<200)&&(c=!1)}if(c)return{isBelow:f,willStayInSamePosition:c};g?h+=y/2:f?h+=y+x/2:h-=p/2;let E=0;g||(f?E=-Te:E=Te);let b=h-i+E,N=gt-e;return o.style.width=`calc(${u}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?f?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),$=0,{isBelow:f,willStayInSamePosition:c}}var bt="draggable-block-menu",Me="application/x-lexical-drag-block",V=1/0;function Le(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function Ct(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Be(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Nt(t,e,o){let n=e.parentElement,r=re(null),m=re(null),l=re(null),a=re(!1),[d,g]=ve(null),[y,s]=ve(null),{editorConfig:i}=R(),u=i?.admin?.hideGutter?-44:-8;me(()=>{function h(f){let c=f.target;if(!j(c))return;let E=z(n,f.pageX,f.pageY,c);if(E===-1){g(null);return}if(ee(c,bt))return;let b=_(t),{blockElem:N,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(f.x,f.y),startIndex:Le(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!N&&!k)&&d!==N&&g(N)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[n,e,t,d]),me(()=>{r.current&&te(d,r.current,e,u)},[e,d,u]),me(()=>{function h(c){if(!a.current)return!1;let[E]=ke(c);if(E)return!1;let{pageY:b,target:N}=c;if(!j(N))return!1;let C=z(n,c.pageX,c.pageY,N,100,50),k=_(t),{blockElem:P,foundAtIndex:H,isFoundNodeEmptyParagraph:L}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(c.x,c.y),startIndex:Le(k.length),useEdgeAsDefault:!0,verbose:!0});V=H;let I=m.current;if(P===null||I===null)return!1;if(d!==P){let{isBelow:S,willStayInSamePosition:U}=Re(i?.admin?.hideGutter?"0px":"3rem",u+(i?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),I,P,y,b,e,c,l,L);c.preventDefault(),U||s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:S})}else y?.elem&&(Be(I,y.elem),s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:!1}));return!0}function f(c){if(!a.current)return!1;let[E]=ke(c);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=c,k=b?.getData(Me)||"";return t.update(()=>{let P=xt(k);if(!P||!j(C))return!1;let H=z(n,c.pageX,c.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-H,point:new B(c.x,c.y),useEdgeAsDefault:!0});if(!L)return!1;let S=Se(L);if(!S)return!1;if(S===P)return!0;let{height:U,top:J}=K(L),le=N>=J+U/2+window.scrollY;I?(S.insertBefore(P),S.remove()):le?S.insertAfter(P):S.insertBefore(P),d!==null&&g(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let ae=t.getElementByKey(P.getKey());setTimeout(()=>{let D=ae?.getBoundingClientRect();if(!D)return;let T=document.createElement("div");T.className="lexical-block-highlighter",T.style.backgroundColor="var(--theme-elevation-1000",T.style.transition="opacity 0.5s ease-in-out",T.style.zIndex="1",T.style.pointerEvents="none",T.style.boxSizing="border-box",T.style.borderRadius="4px",T.style.position="absolute",document.body.appendChild(T),T.style.opacity="0.1",T.style.height=`${D.height+8}px`,T.style.width=`${D.width+8}px`,T.style.top=`${D.top+window.scrollY-4}px`,T.style.left=`${D.left-4}px`,setTimeout(()=>{T.style.opacity="0",setTimeout(()=>{T.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",f)}},[n,u,e,t,y,d,i?.admin?.hideGutter]);function x(h){let f=h.dataTransfer;if(!f||!d)return;Ct(f,d);let c="";t.update(()=>{let E=Se(d);E&&(c=E.getKey())}),a.current=!0,f.setData(Me,c)}function p(){a.current=!1,y?.elem&&Be(m.current,y?.elem)}return Et(ht(Ae.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:p,onDragStart:x,ref:r,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:m}),ne("div",{className:"debug-highlight",ref:l})]}),e)}function Fe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=yt();return Nt(n,o,n._editable)}import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import*as Ie from"react";var De=()=>{let t=Pt(4),{editorConfig:e}=R(),[o]=wt(),n,r;return t[0]!==o||t[1]!==e.features.markdownTransformers?(n=()=>fe(o,e.features.markdownTransformers??[]),r=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=n,t[3]=r):(n=t[2],r=t[3]),Ie.useEffect(n,r),null};import{jsx as W,jsxs as _e}from"react/jsx-runtime";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as $e}from"@payloadcms/ui";import{useCallback as kt,useMemo as St,useState as vt}from"react";import"react";import*as He from"react-dom";import{c as Tt}from"react/compiler-runtime";import"react";function Oe(t,e){let o=Tt(4),{maxLength:n,minLength:r}=e,m=n===void 0?75:n,l=r===void 0?1:r,a;return o[0]!==m||o[1]!==l||o[2]!==t?(a=d=>{let{query:g}=d,y="[^"+t+pe+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+m+"}))$").exec(g);if(i!==null){let u=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+u.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=m,o[1]=l,o[2]=t,o[3]=a):a=o[3],a}var M="slash-menu-popup";function Mt({isSelected:t,item:e,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:m,schemaPath:l}}=R(),{i18n:a}=$e(),d=`${M}__item ${M}__item-${e.key}`;t&&(d+=` ${M}__item--selected`);let g=e.key;return e.label&&(g=typeof e.label=="function"?e.label({featureClientSchemaMap:m,i18n:a,schemaPath:l}):e.label),g.length>25&&(g=g.substring(0,25)+"..."),_e("button",{"aria-selected":t,className:d,id:M+"__item-"+e.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&W(e.Icon,{}),W("span",{className:`${M}__item-text`,children:g})]},e.key)}function je({anchorElem:t=document.body}){let[e]=Rt(),[o,n]=vt(null),{editorConfig:r}=R(),{i18n:m}=$e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:a}}=R(),d=Oe("/",{minLength:0}),g=kt(()=>{let s=[];for(let i of r.features.slashMenu.dynamicGroups)if(o){let u=i({editor:e,queryString:o});s=s.concat(u)}return s},[e,o,r?.features]),y=St(()=>{let s=[];for(let i of r?.features.slashMenu.groups??[])s.push(i);if(o){s=s.map(u=>{let x=u.items.filter(p=>{let h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:m,schemaPath:a}):p.label),new RegExp(o,"gi").exec(h)?!0:p.keywords!=null?p.keywords.some(f=>new RegExp(o,"gi").exec(f)):!1});return x.length?{...u,items:x}:null}),s=s.filter(u=>u!=null);let i=g();for(let u of i){let x=s.find(p=>p.key===u.key);x?s=s.filter(p=>p.key!==u.key):x={...u,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,r?.features.slashMenu.groups,g,l,m,a]);return W(he,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:i,selectItemAndCleanUp:u,setSelectedItemKey:x})=>s.current&&y.length?He.createPortal(W("div",{className:M,children:y.map(p=>{let h=p.key;return p.label&&l&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:m,schemaPath:a}):p.label),_e("div",{className:`${M}__group ${M}__group-${p.key}`,children:[W("div",{className:`${M}__group-title`,children:h}),p.items.map((f,c)=>W(Mt,{index:c,isSelected:i===f.key,item:f,onClick:()=>{x(f.key),u(f)},onMouseEnter:()=>{x(f.key)},ref:E=>{f.ref={current:E}}},f.key))]},p.key)})}),s.current):null,onQueryChange:n,triggerFn:d})}import{c as Lt}from"react/compiler-runtime";import{useLexicalComposerContext as Bt}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as ze,TextNode as At}from"lexical";import{useEffect as Ft}from"react";function Ke(t){let e=Lt(6),{features:o}=t,[n]=Bt(),r;e[0]!==n||e[1]!==o.enabledFormats?(r=()=>{let l=It(o.enabledFormats);if(l.length!==0)return n.registerNodeTransform(At,a=>{l.forEach(d=>{a.hasFormat(d)&&a.toggleFormat(d)})})},e[0]=n,e[1]=o.enabledFormats,e[2]=r):r=e[2];let m;return e[3]!==n||e[4]!==o?(m=[n,o],e[3]=n,e[4]=o,e[5]=m):m=e[5],Ft(r,m),null}function It(t){delete ze.highlight;let e=Object.keys(ze),o=new Set(t);return e.filter(n=>!o.has(n))}import{c as Dt}from"react/compiler-runtime";import{jsx as Ge}from"react/jsx-runtime";import{ContentEditable as Ot}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as _t}from"@payloadcms/ui";import"react";function We(t){let e=Dt(3),{className:o}=t,{t:n}=_t(),r;return e[0]!==o||e[1]!==n?(r=Ge(Ot,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ge("p",{className:"editor-placeholder",children:n("lexical:general:placeholder")})}),e[0]=o,e[1]=n,e[2]=r):r=e[2],r}var qe=t=>{let e=$t(22),{editorConfig:o,editorContainerRef:n,onChange:r}=t,m=R(),[l]=Ht(),[a,d]=Ve(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=c=>{c!==null&&d(c)},e[0]=g):g=e[0];let y=g,s,i;e[1]!==l||e[2]!==m?(s=()=>{if(!m?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}m?.parentEditor?.uuid&&m.parentEditor?.registerChild(m.uuid,m);let c=()=>{m.focusEditor(m)},E=()=>{m.blurEditor(m)},b=l.registerCommand(Yt,()=>(c(),!0),Ye),N=l.registerCommand(Wt,()=>(E(),!0),Ye);return()=>{b(),N(),m.parentEditor?.unregisterChild?.(m.uuid)}},i=[l,m],e[1]=l,e[2]=m,e[3]=s,e[4]=i):(s=e[3],i=e[4]),Ue(s,i);let[u,x]=Ve(!1),p,h;e[5]!==u?(p=()=>{let c=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==u&&x(E)};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},h=[u],e[5]=u,e[6]=p,e[7]=h):(p=e[6],h=e[7]),Ue(p,h);let f;if(e[8]!==l||e[9]!==o.features||e[10]!==n||e[11]!==a||e[12]!==u||e[13]!==r){let c;e[15]!==r?(c=(b,N,C)=>{(!C.has("focus")||C.size>1)&&r?.(b,N,C)},e[15]=r,e[16]=c):c=e[16];let E;e[17]!==l||e[18]!==o.features.plugins||e[19]!==a||e[20]!==u?(E=a&&q(Y.Fragment,{children:[!u&&l.isEditable()&&q(Y.Fragment,{children:[w(Fe,{anchorElem:a}),w(we,{anchorElem:a})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&u))return w(O,{anchorElem:a,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&w(Y.Fragment,{children:w(je,{anchorElem:a})})]}),e[17]=l,e[18]=o.features.plugins,e[19]=a,e[20]=u,e[21]=E):E=e[21],f=q(Y.Fragment,{children:[o.features.plugins?.map(Ut),q("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(Vt),w(Gt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:y,tabIndex:-1,children:w(We,{})})}),ErrorBoundary:jt}),w(Ke,{features:o.features}),w(Kt,{ignoreSelectionChange:!0,onChange:c}),E,l.isEditable()&&q(Y.Fragment,{children:[w(zt,{}),o?.features?.markdownTransformers?.length>0&&w(De,{})]}),o.features.plugins?.map(qt),o.features.plugins?.map(Jt)]}),o.features.plugins?.map(Qt)]}),e[8]=l,e[9]=o.features,e[10]=n,e[11]=a,e[12]=u,e[13]=r,e[14]=f}else f=e[14];return f};function Ut(t){if(t.position==="aboveContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Vt(t){if(t.position==="top")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function qt(t){if(t.position==="normal")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Jt(t){if(t.position==="bottom")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Qt(t){if(t.position==="belowContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}var Qe=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?A(o,{children:A(Qe,{providers:e.slice(1),children:t})}):A(o,{children:t})},Xe=t=>{let{composerKey:e,editorConfig:o,fieldProps:n,onChange:r,readOnly:m,value:l}=t,a=R(),d=Je.useRef(null),g=Zt(()=>{if(l&&typeof l!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(l));if(l&&Array.isArray(l)&&!("root"in l))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:m!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:xe({editorConfig:o}),onError:y=>{throw y},theme:o.lexical.theme}},[o]);return g?A(Xt,{initialConfig:g,children:A(de,{editorConfig:o,editorContainerRef:d,fieldProps:n,parentContext:a,children:A(Qe,{providers:o.features.providers,children:A(qe,{editorConfig:o,editorContainerRef:d,onChange:r})})})},e+g.editable):A("p",{children:"Loading..."})};var ie="rich-text-lexical",ao=t=>{let{editorConfig:e,field:o,field:{name:n,admin:{className:r,description:m,readOnly:l}={},label:a,localized:d,required:g},path:y,readOnly:s,validate:i}=t,u=s||l,x=y??n,p=no(),h=et((Q,ae)=>typeof i=="function"?i(Q,{...ae,required:g}):!0,[i,g]),{customComponents:{AfterInput:f,BeforeInput:c,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:k,initialValue:P,setValue:H,showError:L,value:I}=ro({path:x,validate:h}),S=u||k||C,U=[ie,"field-type",r,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${p}`,ue=et(Q=>{H(Q.toJSON())},[H]),le=so(()=>io(o),[o]);return se("div",{className:U,style:le,children:[F(Ze,{CustomComponent:b,Fallback:F(to,{path:x,showError:L})}),N||F(oo,{label:a,localized:d,path:x,required:g}),se("div",{className:`${ie}__wrap`,children:[se(lo,{fallbackRender:co,onReset:()=>{},children:[c,F(Xe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:ue,readOnly:S,value:I},JSON.stringify({initialValue:P,path:x})),f]}),E,F(Ze,{CustomComponent:E,Fallback:F(eo,{description:m,path:x})})]})]},J)};function co({error:t}){return se("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Cr=ao;export{Cr as RichText};
|
|
2
|
+
//# sourceMappingURL=Field-Q6F2LMIQ.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var C=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pn(r){return r instanceof HTMLElement}var j=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 ft(r){return r instanceof j}import{c as Ce}from"react/compiler-runtime";import{jsx as Re}from"react/jsx-runtime";import{useLexicalComposerContext as Ie}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Fe}from"@lexical/utils";import{$getSelection as Z,$isRangeSelection as J,$isTextNode as Ne,COMMAND_PRIORITY_LOW as Ae,createCommand as ye}from"lexical";import{useEffect as _t,useState as Oe}from"react";import*as V from"react";import{c as pt}from"react/compiler-runtime";import{useLexicalComposerContext as ht}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ut}from"@lexical/utils";import{$getSelection as se,$isRangeSelection as ae,COMMAND_PRIORITY_LOW as M,createCommand as ce,KEY_ARROW_DOWN_COMMAND as le,KEY_ARROW_UP_COMMAND as fe,KEY_ENTER_COMMAND as ue,KEY_ESCAPE_COMMAND as de,KEY_TAB_COMMAND as me}from"lexical";import{useCallback as q,useEffect as L,useLayoutEffect as ge,useMemo as pe,useRef as he,useState as xe}from"react";var Ee="slash-menu-popup",dt=r=>{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"}),r.scrollIntoView({block:"nearest"})};function _e(r,t,e){let n=e;for(let o=n;o<=t.length;o++)r.substring(r.length-o)===t.substring(0,o)&&(n=o);return n}function Te(r){let t=se();if(!ae(t)||!t.isCollapsed())return null;let e=t.anchor;if(e.type!=="text")return null;let n=e.getNode();if(!n.isSimpleText())return null;let o=e.offset,i=n.getTextContent().slice(0,o),s=r.replaceableString.length,a=_e(i,r.matchingString,s),c=o-a;if(c<0)return null;let l;return c===0?[l]=n.splitText(o):[,l]=n.splitText(c,o),l}function Se(r,t){let e=getComputedStyle(r),n=e.position==="absolute",o=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let i=r;i=i.parentElement;)if(e=getComputedStyle(i),!(n&&e.position==="static")&&o.test(e.overflow+e.overflowY+e.overflowX))return i;return document.body}function mt(r,t){let e=r.getBoundingClientRect(),n=t.getBoundingClientRect();return e.top>n.top&&e.top<n.bottom}function we(r,t,e,n){let o=pt(12),[i]=ht(),s;o[0]!==i||o[1]!==e||o[2]!==n||o[3]!==r||o[4]!==t.current?(s=()=>{let c=t.current;if(c!=null&&r!=null){let l=i.getRootElement(),f=l!=null?Se(l,!1):document.body,m;m=!1;let g;g=mt(c,f);let p=function(){m||(window.requestAnimationFrame(function(){e(),m=!1}),m=!0);let d=mt(c,f);d!==g&&(g=d,n?.(d))},u=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",p,{capture:!0,passive:!0}),u.observe(c),()=>{u.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",p,!0)}}},o[0]=i,o[1]=e,o[2]=n,o[3]=r,o[4]=t.current,o[5]=s):s=o[5];let a;o[6]!==i||o[7]!==e||o[8]!==n||o[9]!==r||o[10]!==t?(a=[i,n,e,r,t],o[6]=i,o[7]=e,o[8]=n,o[9]=r,o[10]=t,o[11]=a):a=o[11],L(s,a)}var gt=ce("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function xt({anchorElementRef:r,close:t,editor:e,groups:n,menuRenderFn:o,resolution:i,shouldSplitNodeWithQuery:s=!1}){let[a,c]=xe(null),l=i.match&&i.match.matchingString||"",f=q(u=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${Ee}__item-${u.key}`),c(u.key))},[e]),m=q(()=>{if(n!==null&&l!=null){let u=n.flatMap(d=>d.items);if(u.length){let d=u[0];f(d)}}},[n,f,l]);L(()=>{m()},[l,m]);let g=q(u=>{t(),e.update(()=>{let d=i.match!=null&&s?Te(i.match):null;d&&d.remove()}),setTimeout(()=>{u.onSelect({editor:e,queryString:i.match?i.match.matchingString:""})},0)},[e,s,i.match,t]);L(()=>()=>{let u=e.getRootElement();u!==null&&u.removeAttribute("aria-activedescendant")},[e]),ge(()=>{n===null?c(null):a===null&&m()},[n,a,f,m]),L(()=>ut(e.registerCommand(gt,({item:u})=>u.ref&&u.ref.current!=null?(dt(u.ref.current),!0):!1,M)),[e,f]),L(()=>ut(e.registerCommand(le,u=>{let d=u;if(n!==null&&n.length&&a!==null){let x=n.flatMap(_=>_.items),h=x.findIndex(_=>_.key===a),T=h!==x.length-1?h+1:0,E=x[T];f(E),E.ref!=null&&E.ref.current&&e.dispatchCommand(gt,{index:T,item:E}),d.preventDefault(),d.stopImmediatePropagation()}return!0},M),e.registerCommand(fe,u=>{let d=u;if(n!==null&&n.length&&a!==null){let x=n.flatMap(_=>_.items),h=x.findIndex(_=>_.key===a),T=h!==0?h-1:x.length-1,E=x[T];f(E),E.ref!=null&&E.ref.current&&dt(E.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},M),e.registerCommand(de,u=>{let d=u;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},M),e.registerCommand(me,u=>{let d=u;if(n===null||a===null)return!1;let h=n.flatMap(T=>T.items).find(T=>T.key===a);return h?(d.preventDefault(),d.stopImmediatePropagation(),g(h),!0):!1},M),e.registerCommand(ue,u=>{if(n===null||a===null)return!1;let x=n.flatMap(h=>h.items).find(h=>h.key===a);return x?(u!==null&&(u.preventDefault(),u.stopImmediatePropagation()),g(x),!0):!1},M)),[g,t,e,n,a,f]);let p=pe(()=>({groups:n,selectedItemKey:a,selectItemAndCleanUp:g,setSelectedItemKey:c}),[g,a,n]);return o(r,p,i.match?i.match.matchingString:"")}function Et(r,t,e,n){let o=pt(14),[i]=ht(),s;o[0]===Symbol.for("react.memo_cache_sentinel")?(s=C?document.createElement("div"):null,o[0]=s):s=o[0];let a=he(s),c;o[1]!==r||o[2]!==n||o[3]!==i||o[4]!==t?(c=()=>{if(a.current===null||parent===void 0)return;let u=i.getRootElement(),d=a.current,x=d.firstChild;if(u!==null&&t!==null){let{height:h,width:T}=t.getRect(),{left:E,top:_}=t.getRect(),N=_;if(_=_-(r.getBoundingClientRect().top+window.scrollY),E=E-(r.getBoundingClientRect().left+window.scrollX),d.style.left=`${E+window.scrollX}px`,d.style.height=`${h}px`,d.style.width=`${T}px`,x!==null){let S=x.getBoundingClientRect(),F=S.height,w=S.width,A=u.getBoundingClientRect();E+w>A.right&&(d.style.left=`${A.right-w+window.scrollX}px`);let y=N+F+32>window.innerHeight,b=N<0;y&&!b?d.style.top=`${_+32-F+window.scrollY-(h+24)}px`:d.style.top=`${_+window.scrollY+32}px`}d.isConnected||(n!=null&&(d.className=n),d.setAttribute("aria-label","Slash menu"),d.setAttribute("id","slash-menu"),d.setAttribute("role","listbox"),d.style.display="block",d.style.position="absolute",r.append(d)),a.current=d,u.setAttribute("aria-controls","slash-menu")}},o[1]=r,o[2]=n,o[3]=i,o[4]=t,o[5]=c):c=o[5];let l=c,f,m;o[6]!==i||o[7]!==l||o[8]!==t?(f=()=>{let u=i.getRootElement();if(t!==null)return l(),()=>{u!==null&&u.removeAttribute("aria-controls");let d=a.current;d!==null&&d.isConnected&&d.remove()}},m=[i,l,t],o[6]=i,o[7]=l,o[8]=t,o[9]=f,o[10]=m):(f=o[9],m=o[10]),L(f,m);let g;return o[11]!==t||o[12]!==e?(g=u=>{t!==null&&(u||e(null))},o[11]=t,o[12]=e,o[13]=g):g=o[13],we(t,a,l,g),a}var no=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function be(r){let t=r.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let n=t.offset;return e.getTextContent().slice(0,n)}function Tt(r,t,e){let n=e.getSelection();if(n===null||!n.isCollapsed)return!1;let o=n.anchorNode,i=r,s=n.anchorOffset;if(o==null||s==null)return!1;try{t.setStart(o,i),t.setEnd(o,s>1?s:1)}catch{return!1}return!0}function ke(r){let t;return r.getEditorState().read(()=>{let e=Z();J(e)&&(t=be(e))}),t}function St(r,t){return t!==0?!1:r.getEditorState().read(()=>{let e=Z();if(J(e)){let i=e.anchor.getNode().getPreviousSibling();return Ne(i)&&i.isTextEntity()}return!1})}function wt(r){V.startTransition?V.startTransition(r):r()}var Me=ye("ENABLE_SLASH_MENU_COMMAND");function oo(r){let t=Ce(30),{anchorClassName:e,anchorElem:n,groups:o,menuRenderFn:i,onClose:s,onOpen:a,onQueryChange:c,triggerFn:l}=r,[f]=Ie(),[m,g]=Oe(null),p=Et(n,m,g,e),u;t[0]!==s||t[1]!==m?(u=()=>{g(null),s!=null&&m!==null&&s()},t[0]=s,t[1]=m,t[2]=u):u=t[2];let d=u,x;t[3]!==a||t[4]!==m?(x=F=>{g(F),a!=null&&m===null&&a(F)},t[3]=a,t[4]=m,t[5]=x):x=t[5];let h=x,T,E;t[6]!==f||t[7]!==h?(T=()=>Fe(f.registerCommand(Me,F=>{let{node:w}=F;return f.getEditorState().read(()=>{let A={leadOffset:0,matchingString:"",replaceableString:""};if(!St(f,A.leadOffset)&&w!==null){let y=f._window??window,b=y.document.createRange();Tt(A.leadOffset,b,y)!==null&&wt(()=>h({getRect:()=>b.getBoundingClientRect(),match:A}));return}}),!0},Ae)),E=[f,h],t[6]=f,t[7]=h,t[8]=T,t[9]=E):(T=t[8],E=t[9]),_t(T,E);let _;t[10]!==d||t[11]!==f||t[12]!==c||t[13]!==h||t[14]!==l?(_=()=>{let F=()=>{f.getEditorState().read(()=>{let A=f._window??window,y=A.document.createRange(),b=Z(),Q=ke(f);if(!J(b)||!b.isCollapsed()||Q===void 0||y===null){d();return}let k=l({editor:f,query:Q});if(c(k?k.matchingString:null),k!==null&&!St(f,k.leadOffset)&&Tt(k.leadOffset,y,A)!==null){wt(()=>h({getRect:()=>y.getBoundingClientRect(),match:k}));return}d()})},w=f.registerUpdateListener(F);return()=>{w()}},t[10]=d,t[11]=f,t[12]=c,t[13]=h,t[14]=l,t[15]=_):_=t[15];let N;t[16]!==d||t[17]!==f||t[18]!==c||t[19]!==h||t[20]!==m||t[21]!==l?(N=[f,l,c,m,d,h],t[16]=d,t[17]=f,t[18]=c,t[19]=h,t[20]=m,t[21]=l,t[22]=N):N=t[22],_t(_,N);let S;return t[23]!==p||t[24]!==d||t[25]!==f||t[26]!==o||t[27]!==i||t[28]!==m?(S=p.current===null||m===null||f===null?null:Re(xt,{anchorElementRef:p,close:d,editor:f,groups:o,menuRenderFn:i,resolution:m,shouldSplitNodeWithQuery:!0}),t[23]=p,t[24]=d,t[25]=f,t[26]=o,t[27]=i,t[28]=m,t[29]=S):S=t[29],S}var Ct=class r{_bottom;_left;_right;_top;constructor(t,e,n,o){let[i,s]=e<=o?[e,o]:[o,e],[a,c]=t<=n?[t,n]:[n,t];this._top=i,this._right=c,this._left=a,this._bottom=s}static fromDOM(t){let{height:e,left:n,top:o,width:i}=t.getBoundingClientRect();return r.fromLWTH(n,i,o,e)}static fromDOMRect(t){let{height:e,left:n,top:o,width:i}=t;return r.fromLWTH(n,i,o,e)}static fromLTRB(t,e,n,o){return new r(t,e,n,o)}static fromLWTH(t,e,n,o){return new r(t,n,t+e,n+o)}static fromPoints(t,e){let{x:n,y:o}=t,{x:i,y:s}=e;return r.fromLTRB(n,o,i,s)}contains(t){if(ft(t)){let{x:s,y:a}=t,c=a<this._top,l=a>this._bottom,f=s<this._left,m=s>this._right;return{reason:{isOnBottomSide:l,isOnLeftSide:f,isOnRightSide:m,isOnTopSide:c},result:!c&&!l&&!f&&!m}}let{bottom:e,left:n,right:o,top:i}=t;return i>=this._top&&i<=this._bottom&&e>=this._top&&e<=this._bottom&&n>=this._left&&n<=this._right&&o>=this._left&&o<=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 n=0,o=0;return t.x<this._left?n=this._left-t.x:t.x>this._right&&(n=t.x-this._right),t.y<this._top?o=this._top-t.y:t.y>this._bottom&&(o=t.y-this._bottom),{distance:Math.sqrt(n*n+o*o),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:n,top:o}){return o===this._top&&t===this._bottom&&e===this._left&&n===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:n=this.right,top:o=this.top}){return new r(e,o,n,t)}intersectsWith(t){let{height:e,left:n,top:o,width:i}=t,{height:s,left:a,top:c,width:l}=this,f=n+i>=a+l?n+i:a+l,m=o+e>=c+s?o+e:c+s,g=n<=a?n:a,p=o<=c?o:c;return f-g<=i+l&&m-p<=e+s}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)}};function ao({editorConfig:r}){return Le({nodes:r.features.nodes})}function Le({nodes:r}){return r.map(t=>"node"in t?t.node:t)}var $e=C&&"documentMode"in document?document.documentMode:null,fo=C&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),uo=C&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),mo=C&&"InputEvent"in window&&!$e?"getTargetRanges"in new window.InputEvent("input"):!1,tt=C&&/Version\/[\d.].*Safari/.test(navigator.userAgent),et=C&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,go=C&&/Android/.test(navigator.userAgent),po=C&&/Win/.test(navigator.platform),De=C&&/^(?=.*Chrome).*/i.test(navigator.userAgent),nt=C&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!De;import{$getRoot as Xe,$isDecoratorNode as At,$isElementNode as W,$isLineBreakNode as ze,$isTextNode as G}from"lexical";import{$isListItemNode as Be,$isListNode as Rt}from"@lexical/list";import{$isHeadingNode as Pe,$isQuoteNode as ve}from"@lexical/rich-text";import{$isParagraphNode as He,$isTextNode as Ke}from"lexical";var R={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},I={...R,requiresParagraphStart:!0},To={...I,export:$(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},So={...I,export:$(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},wo={...I,export:$(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Co={...I,export:$(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},Ro={...I,export:$(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},Io={...I,export:$(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},Fo={...I,export:We,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},No={...I,export:ot,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},Ao={...I,export:ot,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},yo={...I,export:ot,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},Oo={...I,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},bo={...I,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},ko={...R,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},Mo={...R,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},Lo={...R,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},$o={...R,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},Do={...R,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Bo={...R,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Po={...R,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},vo={...R,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},Ho={...R,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},Ko={...R,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Uo={...R,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},Wo={...R,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function $(r){return(t,e)=>Pe(t)&&t.getTag()==="h"+r?"#".repeat(r)+" "+e(t):null}function ot(r,t){return Rt(r)?It(r,t,0):null}var Ue=4;function It(r,t,e){let n=[],o=r.getChildren(),i=0;for(let s of o)if(Be(s)){if(s.getChildrenSize()===1){let l=s.getFirstChild();if(Rt(l)){n.push(It(l,t,e+1));continue}}let a=" ".repeat(e*Ue),c=r.getListType()==="bullet"?"- ":`${r.getStart()+i}. `;n.push(a+c+t(s)),i++}return n.join(`
|
|
2
|
+
`)}function We(r,t){return ve(r)?"> "+t(r):null}function K(r,t){let e={};for(let n of r){let o=t(n);o&&(e[o]?e[o].push(n):e[o]=[n])}return e}function D(r){let t=K(r,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var B=/[!-/:-@[-`{-~\s]/,Ge=/^\s{0,3}$/;function H(r){if(!He(r))return!1;let t=r.getFirstChild();return t==null||r.getChildrenSize()===1&&Ke(t)&&Ge.test(t.getTextContent())}function yt(r,t=!1){let e=D(r),n=[...e.multilineElement,...e.element],o=!t,i=e.textFormat.filter(s=>s.format.length===1);return s=>{let a=[],c=(s||Xe()).getChildren();for(let l=0;l<c.length;l++){let f=c[l],m=Ye(f,n,i,e.textMatch);m!=null&&a.push(o&&l>0&&!H(f)&&!H(c[l-1])?`
|
|
3
|
+
`.concat(m):m)}return a.join(`
|
|
4
|
+
`)}}function Ye(r,t,e,n){for(let o of t){if(!o.export)continue;let i=o.export(r,s=>X(s,e,n));if(i!=null)return i}return W(r)?X(r,e,n):At(r)?r.getTextContent():null}function X(r,t,e,n,o){let i=[],s=r.getChildren();n||(n=[]),o||(o=[]);t:for(let a of s){for(let c of e){if(!c.export)continue;let l=c.export(a,f=>X(f,t,e,n,[...o,...n]),(f,m)=>Ft(f,m,t,n,o));if(l!=null){i.push(l);continue t}}ze(a)?i.push(`
|
|
5
|
+
`):G(a)?i.push(Ft(a,a.getTextContent(),t,n,o)):W(a)?i.push(X(a,t,e,n,o)):At(a)&&i.push(a.getTextContent())}return i.join("")}function Ft(r,t,e,n,o){let i=t.trim(),s=i,a="",c="",l="",f=Nt(r,!0),m=Nt(r,!1),g=new Set;for(let p of e){let u=p.format[0],d=p.tag;U(r,u)&&!g.has(u)&&(g.add(u),(!U(f,u)||!n.find(x=>x.tag===d))&&(n.push({format:u,tag:d}),a+=d))}for(let p=0;p<n.length;p++){let u=U(r,n[p].format),d=U(m,n[p].format);if(u&&d)continue;let x=[...n];for(;x.length>p;){let h=x.pop();o&&h&&o.find(T=>T.tag===h.tag)||(h&&typeof h.tag=="string"&&(u?d||(l+=h.tag):c+=h.tag),n.pop())}break}return s=a+s+l,c+t.replace(i,()=>s)}function Nt(r,t){let e=t?r.getPreviousSibling():r.getNextSibling();if(!e){let n=r.getParentOrThrow();n.isInline()&&(e=t?n.getPreviousSibling():n.getNextSibling())}for(;e;){if(W(e)){if(!e.isInline())break;let n=t?e.getLastDescendant():e.getFirstDescendant();if(G(n))return n;e=t?e.getPreviousSibling():e.getNextSibling()}if(G(e))return e;if(!W(e))return null}return null}function U(r,t){return G(r)&&r.hasFormat(t)}import{$isListItemNode as je,$isListNode as Lt}from"@lexical/list";import{$isQuoteNode as qe}from"@lexical/rich-text";import{$findMatchingParent as Ve}from"@lexical/utils";import{$createLineBreakNode as Ze,$createParagraphNode as Je,$createTextNode as tn,$getRoot as en,$getSelection as nn,$isParagraphNode as on}from"lexical";import{$isTextNode as P}from"lexical";function Ot(r,t){let e=r.getTextContent(),n=Qe(e,t);if(!n)return null;let o=n.index||0,i=o+n[0].length,s=t.transformersByTag[n[1]];return{endIndex:i,match:n,startIndex:o,transformer:s}}function Qe(r,t){let e=r.match(t.openTagsRegExp);if(e==null)return null;for(let n of e){let o=n.replace(/^\s/,""),i=t.fullMatchRegExpByTag[o];if(i==null)continue;let s=r.match(i),a=t.transformersByTag[o];if(s!=null&&a!=null){if(a.intraword!==!1)return s;let{index:c=0}=s,l=r[c-1],f=r[c+s[0].length];if((!l||B.test(l))&&(!f||B.test(f)))return s}}return null}function bt(r,t,e,n,o){let i=r.getTextContent(),s,a,c;if(o[0]===i?c=r:t===0?[c,s]=r.splitText(e):[a,c,s]=r.splitText(t,e),c.setTextContent(o[2]),n)for(let l of n.format)c.hasFormat(l)||c.toggleFormat(l);return{nodeAfter:s,nodeBefore:a,transformedNode:c}}function kt(r,t){let e=r,n,o,i,s;for(let a of t){if(!a.replace||!a.importRegExp)continue;let c=e.getTextContent().match(a.importRegExp);if(!c)continue;let l=c.index||0,f=a.getEndIndex?a.getEndIndex(e,c):l+c[0].length;f!==!1&&(n===void 0||o===void 0||l<n&&f>o)&&(n=l,o=f,i=a,s=c)}return n===void 0||o===void 0||i===void 0||s===void 0?null:{endIndex:o,match:s,startIndex:n,transformer:i}}function Mt(r,t,e,n,o){let i,s,a;if(t===0?[a,i]=r.splitText(e):[s,a,i]=r.splitText(t,e),!n.replace)return null;let c=n.replace(a,o);return{nodeAfter:i,nodeBefore:s,transformedNode:c||void 0}}function O(r,t,e){let n=Ot(r,t),o=kt(r,e);if(n&&o&&(n.startIndex<=o.startIndex&&n.endIndex>=o.endIndex?o=null:n=null),n){let i=bt(r,n.startIndex,n.endIndex,n.transformer,n.match);i.nodeAfter&&P(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&O(i.nodeAfter,t,e),i.nodeBefore&&P(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&O(i.nodeBefore,t,e),i.transformedNode&&P(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&O(i.transformedNode,t,e);return}else if(o){let i=Mt(r,o.startIndex,o.endIndex,o.transformer,o.match);if(!i)return;i.nodeAfter&&P(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&O(i.nodeAfter,t,e),i.nodeBefore&&P(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&O(i.nodeBefore,t,e),i.transformedNode&&P(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&O(i.transformedNode,t,e);return}else return}function $t(r,t=!1){let e=D(r),n=an(e.textFormat);return(o,i)=>{let s=o.split(`
|
|
6
|
+
`),a=s.length,c=i||en();c.clear();for(let f=0;f<a;f++){let m=s[f],[g,p]=rn(s,f,e.multilineElement,c);if(g){f=p;continue}sn(m,c,e.element,n,e.textMatch)}let l=c.getChildren();for(let f of l)!t&&H(f)&&c.getChildrenSize()>1&&f.remove();nn()!==null&&c.selectStart()}}function rn(r,t,e,n){for(let o of e){let{handleImportAfterStartMatch:i,regExpEnd:s,regExpStart:a,replace:c}=o,l=r[t].match(a);if(!l)continue;if(i){let u=i({lines:r,rootNode:n,startLineIndex:t,startMatch:l,transformer:o});if(u===null)continue;if(u)return u}let f=typeof s=="object"&&"regExp"in s?s.regExp:s,m=s&&typeof s=="object"&&"optional"in s?s.optional:!s,g=t,p=r.length;for(;g<p;){let u=f?r[g].match(f):null;if(!u&&(!m||m&&g<p-1)){g++;continue}if(u&&t===g&&u.index===l.index){g++;continue}let d=[];if(u&&t===g)d.push(r[t].slice(l[0].length,-u[0].length));else for(let x=t;x<=g;x++)if(x===t){let h=r[x].slice(l[0].length);d.push(h)}else if(x===g&&u){let h=r[x].slice(0,-u[0].length);d.push(h)}else d.push(r[x]);if(c(n,null,l,u,d,!0)!==!1)return[!0,g];break}}return[!1,t]}function sn(r,t,e,n,o){let i=tn(r),s=Je();s.append(i),t.append(s);for(let{regExp:a,replace:c}of e){let l=r.match(a);if(l&&(i.setTextContent(r.slice(l[0].length)),c(s,[i],l,!0)!==!1))break}if(O(i,n,o),s.isAttached()&&r.length>0){let a=s.getPreviousSibling();if(on(a)||qe(a)||Lt(a)){let c=a;if(Lt(a)){let l=a.getLastDescendant();l==null?c=null:c=Ve(l,je)}c!=null&&c.getTextContentSize()>0&&(c.splice(c.getChildrenSize(),0,[Ze(),...s.getChildren()]),s.remove())}}}function an(r){let t={},e={},n=[],o="(?<![\\\\])";for(let i of r){let{tag:s}=i;t[s]=i;let a=s.replace(/([*^+])/g,"\\$1");n.push(a),tt||et||nt?e[s]=new RegExp(`(${a})(?![${a}\\s])(.*?[^${a}\\s])${a}(?!${a})`):e[s]=new RegExp(`(?<![\\\\${a}])(${a})((\\\\${a})?.*?[^${a}\\s](\\\\${a})?)((?<!\\\\)|(?<=\\\\\\\\))(${a})(?![\\\\${a}])`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp((tt||et||nt?"":`${o}`)+"("+n.join("|")+")","g"),transformersByTag:t}}import{$createRangeSelection as cn,$getSelection as rt,$isLineBreakNode as ln,$isRangeSelection as it,$isRootOrShadowRoot as Bt,$isTextNode as Pt,$setSelection as fn}from"lexical";function un(r,t,e,n){let o=r.getParent();if(!Bt(o)||r.getFirstChild()!==t)return!1;let i=t.getTextContent();if(i[e-1]!==" ")return!1;for(let{regExp:s,replace:a}of n){let c=i.match(s);if(c&&c[0].length===(c[0].endsWith(" ")?e:e-1)){let l=t.getNextSiblings(),[f,m]=t.splitText(e);f.remove();let g=m?[m,...l]:l;if(a(r,g,c,!1)!==!1)return!0}}return!1}function dn(r,t,e,n){let o=r.getParent();if(!Bt(o)||r.getFirstChild()!==t)return!1;let i=t.getTextContent();if(i[e-1]!==" ")return!1;for(let{regExpEnd:s,regExpStart:a,replace:c}of n){if(s&&!("optional"in s)||s&&"optional"in s&&!s.optional)continue;let l=i.match(a);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let f=t.getNextSiblings(),[m,g]=t.splitText(e);m.remove();let p=g?[g,...f]:f;if(c(r,p,l,null,null,!1)!==!1)return!0}}return!1}function mn(r,t,e){let n=r.getTextContent(),o=n[t-1],i=e[o];if(i==null)return!1;t<n.length&&(n=n.slice(0,t));for(let s of i){if(!s.replace||!s.regExp)continue;let a=n.match(s.regExp);if(a===null)continue;let c=a.index||0,l=c+a[0].length,f;return c===0?[f]=r.splitText(l):[,f]=r.splitText(c,l),f.selectNext(0,0),s.replace(f,a),!0}return!1}function gn(r,t,e){let n=r.getTextContent(),o=t-1,i=n[o],s=e[i];if(!s)return!1;for(let a of s){let{tag:c}=a,l=c.length,f=o-l+1;if(l>1&&!vt(n,f,c,0,l)||n[f-1]===" ")continue;let m=n[o+1];if(a.intraword===!1&&m&&!B.test(m))continue;let g=r,p=g,u=Dt(n,f,c),d=p;for(;u<0&&(d=d.getPreviousSibling())&&!ln(d);)if(Pt(d)){let w=d.getTextContent();p=d,u=Dt(w,w.length,c)}if(u<0||p===g&&u+l===f)continue;let x=p.getTextContent();if(u>0&&x[u-1]===i)continue;let h=x[u-1];if(a.intraword===!1&&h&&!B.test(h))continue;let T=g.getTextContent(),E=T.slice(0,f)+T.slice(o+1);g.setTextContent(E);let _=p===g?E:x;p.setTextContent(_.slice(0,u)+_.slice(u+l));let N=rt(),S=cn();fn(S);let F=o-l*(p===g?2:1)+1;S.anchor.set(p.__key,u,"text"),S.focus.set(g.__key,F,"text");for(let w of a.format)S.hasFormat(w)||S.formatText(w);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(let w of a.format)S.hasFormat(w)&&S.toggleFormat(w);return it(N)&&(S.format=N.format),!0}return!1}function Dt(r,t,e){let n=e.length;for(let o=t;o>=n;o--){let i=o-n;if(vt(r,i,e,0,n)&&r[i+n]!==" ")return i}return-1}function vt(r,t,e,n,o){for(let i=0;i<o;i++)if(r[t+i]!==e[n+i])return!1;return!0}function dr(r,t=z){let e=D(t),n=K(e.textFormat,({tag:s})=>s[s.length-1]),o=K(e.textMatch,({trigger:s})=>s);for(let s of t){let a=s.type;if(a==="element"||a==="text-match"||a==="multiline-element"){let c=s.dependencies;for(let l of c)if(!r.hasNode(l))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+l.getType())}}let i=(s,a,c)=>{un(s,a,c,e.element)||dn(s,a,c,e.multilineElement)||mn(a,c,o)||gn(a,c,n)};return r.registerUpdateListener(({dirtyLeaves:s,editorState:a,prevEditorState:c,tags:l})=>{if(l.has("collaboration")||l.has("historic")||r.isComposing())return;let f=a.read(rt),m=c.read(rt);if(!it(m)||!it(f)||!f.isCollapsed()||f.is(m))return;let g=f.anchor.key,p=f.anchor.offset,u=a._nodeMap.get(g);!Pt(u)||!s.has(g)||p!==1&&p>m.anchor.offset+1||r.update(()=>{if(u.hasFormat("code"))return;let d=u.getParent();d!==null&&i(d,u,f.anchor.offset)})})}import{$createListItemNode as pn,$createListNode as hn,$isListItemNode as xn,$isListNode as v,ListItemNode as at,ListNode as ct}from"@lexical/list";import{$createHeadingNode as En,$createQuoteNode as _n,$isHeadingNode as Tn,$isQuoteNode as Ht,HeadingNode as Sn,QuoteNode as wn}from"@lexical/rich-text";import{$createLineBreakNode as Cn}from"lexical";var Kt=/^(\s*)(\d+)\.\s/,Ut=/^(\s*)[-*+]\s/,Wt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,st=/^(#{1,6})\s/,Gt=/^>\s/,Rn=/^[ \t]*```(\w+)?/,In=/[ \t]*```$/,Fn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,Nn=/^\|(.+)\|\s?$/,An=/^(\| ?:?-*:? ?)+\|\s?$/,yn=r=>(t,e,n)=>{let o=r(n);o.append(...e),t.replace(o),o.select(0,0)},Xt=4;function On(r){let t=r.match(/\t/g),e=r.match(/ /g),n=0;return t&&(n+=t.length),e&&(n+=Math.floor(e.length/Xt)),n}var lt=r=>(t,e,n)=>{let o=t.getPreviousSibling(),i=t.getNextSibling(),s=pn(r==="check"?n[3]==="x":void 0);if(v(i)&&i.getListType()===r){let c=i.getFirstChild();c!==null?c.insertBefore(s):i.append(s),t.remove()}else if(v(o)&&o.getListType()===r)o.append(s),t.remove();else{let c=hn(r,r==="number"?Number(n[2]):void 0);c.append(s),t.replace(c)}s.append(...e),s.select(0,0);let a=On(n[1]);a&&s.setIndent(a)},Y=(r,t,e)=>{let n=[],o=r.getChildren(),i=0;for(let s of o)if(xn(s)){if(s.getChildrenSize()===1){let f=s.getFirstChild();if(v(f)){n.push(Y(f,t,e+1));continue}}let a=" ".repeat(e*Xt),c=r.getListType(),l=c==="number"?`${r.getStart()+i}. `:c==="check"?`- [${s.getChecked()?"x":" "}] `:"- ";n.push(a+l+t(s)),i++}return n.join(`
|
|
7
|
+
`)},zt={type:"element",dependencies:[Sn],export:(r,t)=>{if(!Tn(r))return null;let e=Number(r.getTag().slice(1));return"#".repeat(e)+" "+t(r)},regExp:st,replace:yn(r=>{let t="h"+r[1].length;return En(t)})},Yt={type:"element",dependencies:[wn],export:(r,t)=>{if(!Ht(r))return null;let e=t(r).split(`
|
|
8
|
+
`),n=[];for(let o of e)n.push("> "+o);return n.join(`
|
|
9
|
+
`)},regExp:Gt,replace:(r,t,e,n)=>{if(n){let i=r.getPreviousSibling();if(Ht(i)){i.splice(i.getChildrenSize(),0,[Cn(),...t]),i.select(0,0),r.remove();return}}let o=_n();o.append(...t),r.replace(o),o.select(0,0)}},Qt={type:"element",dependencies:[ct,at],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:Ut,replace:lt("bullet")},bn={type:"element",dependencies:[ct,at],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:Wt,replace:lt("check")},jt={type:"element",dependencies:[ct,at],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:Kt,replace:lt("number")},qt={type:"text-format",format:["code"],tag:"`"},Vt={type:"text-format",format:["highlight"],tag:"=="},Zt={type:"text-format",format:["bold","italic"],tag:"***"},Jt={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},te={type:"text-format",format:["bold"],tag:"**"},ee={type:"text-format",format:["bold"],intraword:!1,tag:"__"},ne={type:"text-format",format:["strikethrough"],tag:"~~"},oe={type:"text-format",format:["italic"],tag:"*"},re={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function ie(r,t=!1){let e=r.split(`
|
|
10
|
+
`),n=!1,o=[];for(let i=0;i<e.length;i++){let s=e[i],a=o[o.length-1];if(Fn.test(s)){o.push(s);continue}if(Rn.test(s)||In.test(s)){n=!n,o.push(s);continue}if(n){o.push(s);continue}s===""||a===""||!a||st.test(a)||st.test(s)||Gt.test(s)||Kt.test(s)||Ut.test(s)||Wt.test(s)||Nn.test(s)||An.test(s)||!t?o.push(s):o[o.length-1]=a+s}return o.join(`
|
|
11
|
+
`)}var kn=[zt,Yt,Qt,jt],Mn=[],Ln=[qt,Zt,Jt,te,ee,Vt,oe,re,ne],$n=[],z=[...kn,...Mn,...Ln,...$n];function Sr(r,t=z,e,n=!1,o=!1){let i=n?r:ie(r,o);return $t(t,n)(i,e)}function wr(r=z,t,e=!1){return yt(r,e)(t)}export{C as a,fo as b,dr as c,z as d,Sr as e,wr as f,Pn as g,j as h,ft as i,no as j,Me as k,oo as l,Ct as m,ao as n};
|
|
12
|
+
//# sourceMappingURL=chunk-WCORQHZQ.js.map
|