@payloadcms/richtext-lexical 3.0.2-canary.03cffa2 → 3.0.2-canary.935d33d
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-NVIJGYLP.js +2 -0
- package/dist/exports/client/{Field-KKSJXHR7.js.map → Field-NVIJGYLP.js.map} +3 -3
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-WW3TJZ7E.js +12 -0
- package/dist/exports/client/chunk-WW3TJZ7E.js.map +7 -0
- package/dist/exports/client/index.js +11 -9
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blockquote/markdownTransformer.d.ts +1 -1
- package/dist/features/blockquote/markdownTransformer.d.ts.map +1 -1
- package/dist/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/client/markdownTransformer.d.ts +2 -1
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -1
- package/dist/features/blocks/client/markdownTransformer.js +2 -1
- package/dist/features/blocks/client/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/server/markdownTransformer.d.ts +1 -1
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -1
- package/dist/features/blocks/server/markdownTransformer.js +1 -1
- package/dist/features/blocks/server/markdownTransformer.js.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.d.ts +1 -1
- package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.js +2 -1
- package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
- package/dist/features/format/bold/markdownTransformers.d.ts +1 -1
- package/dist/features/format/bold/markdownTransformers.d.ts.map +1 -1
- package/dist/features/format/bold/markdownTransformers.js.map +1 -1
- package/dist/features/format/inlineCode/markdownTransformers.d.ts +1 -1
- package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +1 -1
- package/dist/features/format/inlineCode/markdownTransformers.js.map +1 -1
- package/dist/features/format/italic/markdownTransformers.d.ts +1 -1
- package/dist/features/format/italic/markdownTransformers.d.ts.map +1 -1
- package/dist/features/format/italic/markdownTransformers.js.map +1 -1
- package/dist/features/format/strikethrough/markdownTransformers.d.ts +1 -1
- package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +1 -1
- package/dist/features/format/strikethrough/markdownTransformers.js.map +1 -1
- package/dist/features/heading/markdownTransformer.d.ts +1 -1
- package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
- package/dist/features/heading/markdownTransformer.js.map +1 -1
- package/dist/features/horizontalRule/client/markdownTransformer.d.ts +1 -1
- package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
- package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
- package/dist/features/horizontalRule/server/markdownTransformer.d.ts +1 -1
- package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
- package/dist/features/link/markdownTransformer.d.ts +1 -1
- package/dist/features/link/markdownTransformer.d.ts.map +1 -1
- package/dist/features/link/markdownTransformer.js.map +1 -1
- package/dist/features/lists/checklist/markdownTransformers.d.ts +1 -1
- package/dist/features/lists/checklist/markdownTransformers.d.ts.map +1 -1
- package/dist/features/lists/checklist/markdownTransformers.js.map +1 -1
- package/dist/features/lists/orderedList/markdownTransformer.d.ts +1 -1
- package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +1 -1
- package/dist/features/lists/orderedList/markdownTransformer.js.map +1 -1
- package/dist/features/lists/shared/markdown.d.ts +1 -1
- package/dist/features/lists/shared/markdown.d.ts.map +1 -1
- package/dist/features/lists/shared/markdown.js.map +1 -1
- package/dist/features/lists/unorderedList/markdownTransformer.d.ts +1 -1
- package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +1 -1
- package/dist/features/lists/unorderedList/markdownTransformer.js.map +1 -1
- package/dist/features/typesClient.d.ts +1 -1
- package/dist/features/typesClient.d.ts.map +1 -1
- package/dist/features/typesClient.js.map +1 -1
- package/dist/features/typesServer.d.ts +1 -1
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
- package/dist/lexical/plugins/MarkdownShortcut/index.js +16 -11
- package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
- package/dist/lexical/utils/markdown/createBlockNode.d.ts +1 -1
- package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
- package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
- package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -1
- package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
- package/dist/lexical-proxy/@lexical-markdown.js +1 -1
- package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +14 -0
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownExport.js +144 -0
- package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +14 -0
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownImport.js +315 -0
- package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +11 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +302 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +144 -0
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js +250 -0
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -0
- package/dist/packages/@lexical/markdown/index.d.ts +29 -0
- package/dist/packages/@lexical/markdown/index.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/index.js +39 -0
- package/dist/packages/@lexical/markdown/index.js.map +1 -0
- package/dist/packages/@lexical/markdown/utils.d.ts +34 -0
- package/dist/packages/@lexical/markdown/utils.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/utils.js +267 -0
- package/dist/packages/@lexical/markdown/utils.js.map +1 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts +1 -1
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts.map +1 -1
- package/dist/utilities/jsx/lexicalMarkdownCopy.js +1 -1
- package/dist/utilities/jsx/lexicalMarkdownCopy.js.map +1 -1
- package/package.json +6 -8
- package/dist/exports/client/Field-KKSJXHR7.js +0 -2
- package/dist/exports/client/chunk-QPPOQTHD.js +0 -2
- package/dist/exports/client/chunk-QPPOQTHD.js.map +0 -7
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{c as ue,g as H,h as B,j as fe,k as pe,l as ge,m as he,n as ye}from"./chunk-WW3TJZ7E.js";import{a as de,b as k}from"./chunk-CUIBIFW2.js";import{jsx as ie,jsxs as re}from"react/jsx-runtime";import{FieldLabel as Ut,useEditDepth as Vt,useField as qt,withCondition as Jt}from"@payloadcms/ui";import{mergeFieldStyles as Qt}from"@payloadcms/ui/shared";import{useCallback as Qe,useMemo as Xt}from"react";import{ErrorBoundary as Zt}from"react-error-boundary";import{jsx as L}from"react/jsx-runtime";import{LexicalComposer as Wt}from"@lexical/react/LexicalComposer.js";import*as Ve from"react";import{useMemo as Yt}from"react";import{c as Mt}from"react/compiler-runtime";import{jsx as P,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Bt}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Lt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as At}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Dt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Ft}from"@lexical/react/LexicalRichTextPlugin.js";import{TabIndentationPlugin as Ot}from"@lexical/react/LexicalTabIndentationPlugin.js";import{BLUR_COMMAND as _t,COMMAND_PRIORITY_LOW as Ge,FOCUS_COMMAND as $t}from"lexical";import*as W from"react";import{useEffect as We,useState as Ye}from"react";import{jsx as xe}from"react/jsx-runtime";import"react";var F=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&xe(o.Component,{anchorElem:t,clientProps:e}):o.Component&&xe(o.Component,{clientProps:e});import{jsx as le}from"react/jsx-runtime";import{useLexicalComposerContext as rt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as it}from"lexical";import*as Ne from"react";import{useCallback as st,useEffect as Ce,useRef as lt,useState as at}from"react";import{createPortal as ct}from"react-dom";var j=(t,e,o,i,r=50,f=25)=>{let l=0;if(t&&!t.contains(i)){let{bottom:c,left:d,right:y,top:g}=t.getBoundingClientRect(),m=g+window.scrollY,n=c+window.scrollY;if(o<m-f||o>n+f||e<d-r||e>y+r)return-1;(e<d||e>y)&&(l=e<d?e-d:e-y)}return l};import{$getNodeByKey as Q}from"lexical";function z(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let i=o.split(",").pop();return e.y=e.y-Number(i?.replace(")","")),e}function J(t){let e=(d,y)=>d?parseFloat(window.getComputedStyle(d)[y]):0,{marginBottom:o,marginTop:i}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),f=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(i),r);return{marginBottom:Math.max(parseFloat(o),f),marginTop:l}}import{$getRoot as Ze}from"lexical";function O(t){return t.getEditorState().read(()=>Ze().getChildrenKeys())}var et=1,tt=-1,Ee=0,v={props:null,result:null};function ot(t,e,o=20){let i=t.x-e.x,r=t.y-e.y;return i*i+r*r<=o*o}function K(t){let{anchorElem:e,cache_threshold:o=20,editor:i,fuzzy:r=!1,horizontalOffset:f=0,point:{x:l,y:c},startIndex:d=0,useEdgeAsDefault:y=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&ot(v.props.point,t.point,o))return v.result;let g=e.getBoundingClientRect(),m=O(i),n={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return i.getEditorState().read(()=>{if(y){let[h,a]=[i.getElementByKey(m[0]),i.getElementByKey(m[m.length-1])];if(h&&a){let[p,s]=[z(h),z(a)];if(c<p.top?(n.blockElem=h,n.distance=p.top-c,n.blockNode=Q(m[0]),n.foundAtIndex=0):c>s.bottom&&(n.distance=c-s.bottom,n.blockNode=Q(m[m.length-1]),n.blockElem=a,n.foundAtIndex=m.length-1),n?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let u=d,x=Ee;for(;u>=0&&u<m.length;){let h=m[u],a=i.getElementByKey(h);if(a===null)break;let p=new B(l+f,c),s=he.fromDOMRect(z(a)),{marginBottom:E,marginTop:b}=J(a),w=s.generateNewRect({bottom:s.bottom+E,left:g.left,right:g.right,top:s.top-b}),{distance:C,isOnBottomSide:T,isOnTopSide:N}=w.distanceFromPoint(p);if(C===0){n.blockElem=a,n.blockNode=Q(h),n.foundAtIndex=u,n.distance=C,n.blockNode&&n.blockNode.getType()==="paragraph"&&n.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(n.blockElem=null,n.blockNode=null),n.isFoundNodeEmptyParagraph=!0);break}else r&&C<n.distance&&(n.blockElem=a,n.blockNode=Q(h),n.distance=C,n.foundAtIndex=u);x===Ee&&(N?x=tt:T?x=et:x=1/0),u+=x}}),v.props=t,v.result={blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph},{blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph}}function X(t,e){return!!t.closest(`.${e}`)}var nt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function be(t){if(!t||nt.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 Z(t,e,o,i=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),f=window.getComputedStyle(t),l=e.getBoundingClientRect(),c=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(m=>t.firstElementChild?.classList.contains(m)))d=r.top+8-c.top;else{let m=be(t)?parseInt(f.lineHeight,10):0;d=r.top+(m-l.height)/2-c.top}let g=i;e.style.opacity="1",e.style.transform=`translate(${g}px, ${d}px)`}var mt="add-block-menu",ee=1/0;function dt(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function ut(t,e,o){let i=e.parentElement,{editorConfig:r}=k(),f=r?.admin?.hideGutter?-24:12,l=lt(null),[c,d]=at(null);Ce(()=>{function g(m){let n=m.target;if(!H(n))return;let u=j(i,m.pageX,m.pageY,n);if(u===-1){d(null);return}if(X(n,mt))return;let x=O(t),{blockElem:h,blockNode:a,foundAtIndex:p}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-u,point:new B(m.x,m.y),returnEmptyParagraphs:!0,startIndex:dt(x.length),useEdgeAsDefault:!1});ee=p,h&&a&&(c?.node!==a||c?.elem!==h)&&d({elem:h,node:a})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[i,e,t,c]),Ce(()=>{l.current&&c?.node&&Z(c?.elem,l.current,e,f)},[e,c,f]);let y=st(g=>{let m=c;m?.node&&(t.update(()=>{let n=!0;if((m?.node.getType()!=="paragraph"||m.node.getTextContent()!=="")&&(n=!1),!n){let u=it();m?.node.insertAfter(u),setTimeout(()=>{m={elem:t.getElementByKey(u.getKey()),node:u},d(m)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),m?.node&&"select"in m.node&&typeof m.node.select=="function"&&m.node.select()})},1),setTimeout(()=>{t.dispatchCommand(pe,{node:m?.node})},2),g.stopPropagation(),g.preventDefault())},[t,c]);return ct(le(Ne.Fragment,{children:le("button",{className:"icon add-block-menu",onClick:g=>{y(g)},ref:l,type:"button",children:le("div",{className:o?"icon":""})})}),e)}function we(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[i]=rt();return ut(i,o,i._editable)}import{jsx as te,jsxs as pt}from"react/jsx-runtime";import{useLexicalComposerContext as gt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Te,$getNodeByKey as ht}from"lexical";import*as Be from"react";import{useEffect as ae,useRef as oe,useState as Se}from"react";import{createPortal as yt}from"react-dom";var Pe=0,ft=-24;var _=0;function Re(t,e,o,i,r,f,l,c,d,y=!1){let{height:g,top:m}=i.getBoundingClientRect(),{top:n,width:u}=l.getBoundingClientRect(),{marginBottom:x,marginTop:h}=J(i),a=m,p=f>=m+g/2+window.scrollY,s=!1;if(r?.elem)if(i!==r?.elem)(p&&r?.elem&&r?.elem===i.nextElementSibling||!p&&r?.elem&&r?.elem===i.previousElementSibling)&&(_++,_<200&&(s=!0));else{_++;let C=r?.boundingBox?.y,T=i.getBoundingClientRect().y;(p===r?.isBelow&&C===T||_<200)&&(s=!1)}if(s)return{isBelow:p,willStayInSamePosition:s};y?a+=g/2:p?a+=g+x/2:a-=h/2;let E=0;y||(p?E=-Pe:E=Pe);let b=a-n+E,w=ft-e;return o.style.width=`calc(${u}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${w}px, calc(${b}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===i?p?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),_=0,{isBelow:p,willStayInSamePosition:s}}var xt="draggable-block-menu",ve="application/x-lexical-drag-block",V=1/0;function Ie(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function Et(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Me(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function bt(t,e,o){let i=e.parentElement,r=oe(null),f=oe(null),l=oe(null),c=oe(!1),[d,y]=Se(null),[g,m]=Se(null),{editorConfig:n}=k(),u=n?.admin?.hideGutter?-44:-8;ae(()=>{function a(p){let s=p.target;if(!H(s))return;let E=j(i,p.pageX,p.pageY,s);if(E===-1){y(null);return}if(X(s,xt))return;let b=O(t),{blockElem:w,foundAtIndex:C,isFoundNodeEmptyParagraph:T}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(p.x,p.y),startIndex:Ie(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!w&&!T)&&d!==w&&y(w)}return document?.addEventListener("mousemove",a),()=>{document?.removeEventListener("mousemove",a)}},[i,e,t,d]),ae(()=>{r.current&&Z(d,r.current,e,u)},[e,d,u]),ae(()=>{function a(s){if(!c.current)return!1;let[E]=ke(s);if(E)return!1;let{pageY:b,target:w}=s;if(!H(w))return!1;let C=j(i,s.pageX,s.pageY,w,100,50),T=O(t),{blockElem:N,foundAtIndex:Y,isFoundNodeEmptyParagraph:A}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(s.x,s.y),startIndex:Ie(T.length),useEdgeAsDefault:!0,verbose:!0});V=Y;let M=f.current;if(N===null||M===null)return!1;if(d!==N){let{isBelow:S,willStayInSamePosition:$}=Re(n?.admin?.hideGutter?"0px":"3rem",u+(n?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),M,N,g,b,e,s,l,A);s.preventDefault(),$||m({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:S})}else g?.elem&&(Me(M,g.elem),m({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function p(s){if(!c.current)return!1;let[E]=ke(s);if(E)return!1;let{dataTransfer:b,pageY:w,target:C}=s,T=b?.getData(ve)||"";return t.update(()=>{let N=ht(T);if(!N||!H(C))return!1;let Y=j(i,s.pageX,s.pageY,C,100,50),{blockElem:A,isFoundNodeEmptyParagraph:M}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-Y,point:new B(s.x,s.y),useEdgeAsDefault:!0});if(!A)return!1;let S=Te(A);if(!S)return!1;if(S===N)return!0;let{height:$,top:se}=z(A),U=w>=se+$/2+window.scrollY;M?(S.insertBefore(N),S.remove()):U?S.insertAfter(N):S.insertBefore(N),d!==null&&y(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let Xe=t.getElementByKey(N.getKey());setTimeout(()=>{let D=Xe?.getBoundingClientRect();if(!D)return;let R=document.createElement("div");R.className="lexical-block-highlighter",R.style.backgroundColor="var(--theme-elevation-1000",R.style.transition="opacity 0.5s ease-in-out",R.style.zIndex="1",R.style.pointerEvents="none",R.style.boxSizing="border-box",R.style.borderRadius="4px",R.style.position="absolute",document.body.appendChild(R),R.style.opacity="0.1",R.style.height=`${D.height+8}px`,R.style.width=`${D.width+8}px`,R.style.top=`${D.top+window.scrollY-4}px`,R.style.left=`${D.left-4}px`,setTimeout(()=>{R.style.opacity="0",setTimeout(()=>{R.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",a),document.addEventListener("drop",p),()=>{document.removeEventListener("dragover",a),document.removeEventListener("drop",p)}},[i,u,e,t,g,d,n?.admin?.hideGutter]);function x(a){let p=a.dataTransfer;if(!p||!d)return;Et(p,d);let s="";t.update(()=>{let E=Te(d);E&&(s=E.getKey())}),c.current=!0,p.setData(ve,s)}function h(){c.current=!1,g?.elem&&Me(f.current,g?.elem)}return yt(pt(Be.Fragment,{children:[te("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:h,onDragStart:x,ref:r,children:te("div",{className:o?"icon":""})}),te("div",{className:"draggable-block-target-line",ref:f}),te("div",{className:"debug-highlight",ref:l})]}),e)}function Le(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[i]=gt();return bt(i,o,i._editable)}import{c as Ct}from"react/compiler-runtime";import{useLexicalComposerContext as Nt}from"@lexical/react/LexicalComposerContext";import*as Ae from"react";var De=()=>{let t=Ct(4),{editorConfig:e}=k(),[o]=Nt(),i,r;return t[0]!==o||t[1]!==e.features.markdownTransformers?(i=()=>ue(o,e.features.markdownTransformers??[]),r=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=i,t[3]=r):(i=t[2],r=t[3]),Ae.useEffect(i,r),null};import{jsx as G,jsxs as _e}from"react/jsx-runtime";import{useLexicalComposerContext as Pt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as $e}from"@payloadcms/ui";import{useCallback as Oe,useMemo as Rt,useState as kt}from"react";import"react";import*as He from"react-dom";import{c as wt}from"react/compiler-runtime";import"react";function Fe(t,e){let o=wt(4),{maxLength:i,minLength:r}=e,f=i===void 0?75:i,l=r===void 0?1:r,c;return o[0]!==t||o[1]!==f||o[2]!==l?(c=d=>{let{query:y}=d,g="[^"+t+fe+"\\s]",n=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+f+"}))$").exec(y);if(n!==null){let u=n[1],x=n[3];if(x.length>=l)return{leadOffset:n.index+u.length,matchingString:x,replaceableString:n[2]}}return null},o[0]=t,o[1]=f,o[2]=l,o[3]=c):c=o[3],c}var I="slash-menu-popup";function Tt({isSelected:t,item:e,onClick:o,onMouseEnter:i}){let{fieldProps:{featureClientSchemaMap:r,schemaPath:f}}=k(),{i18n:l}=$e(),c=`${I}__item ${I}__item-${e.key}`;t&&(c+=` ${I}__item--selected`);let d=e.key;return e.label&&(d=typeof e.label=="function"?e.label({featureClientSchemaMap:r,i18n:l,schemaPath:f}):e.label),d.length>25&&(d=d.substring(0,25)+"..."),_e("button",{"aria-selected":t,className:c,id:I+"__item-"+e.key,onClick:o,onMouseEnter:i,ref:y=>{e.ref={current:y}},role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&G(e.Icon,{}),G("span",{className:`${I}__item-text`,children:d})]},e.key)}function je({anchorElem:t=document.body}){let[e]=Pt(),[o,i]=kt(null),{editorConfig:r}=k(),{i18n:f}=$e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:c}}=k(),d=Fe("/",{minLength:0}),y=Oe(()=>{let n=[];for(let u of r.features.slashMenu.dynamicGroups)if(o){let x=u({editor:e,queryString:o});n=n.concat(x)}return n},[e,o,r?.features]),g=Rt(()=>{let n=[];for(let u of r?.features.slashMenu.groups??[])n.push(u);if(o){n=n.map(x=>{let h=x.items.filter(a=>{let p=a.key;return a.label&&(p=typeof a.label=="function"?a.label({featureClientSchemaMap:l,i18n:f,schemaPath:c}):a.label),new RegExp(o,"gi").exec(p)?!0:a.keywords!=null?a.keywords.some(s=>new RegExp(o,"gi").exec(s)):!1});return h.length?{...x,items:h}:null}),n=n.filter(x=>x!=null);let u=y();for(let x of u){let h=n.find(a=>a.key===x.key);h?n=n.filter(a=>a.key!==x.key):h={...x,items:[]},h?.items?.length&&(h.items=h.items.concat(h.items)),n.push(h)}}return n},[o,r?.features.slashMenu.groups,y,l,f,c]),m=Oe((n,u,x)=>{u(),n.onSelect({editor:e,queryString:x})},[e]);return G(ge,{anchorElem:t,groups:g,menuRenderFn:(n,{selectedItemKey:u,selectItemAndCleanUp:x,setSelectedItemKey:h})=>n.current&&g.length?He.createPortal(G("div",{className:I,children:g.map(a=>{let p=a.key;return a.label&&l&&(p=typeof a.label=="function"?a.label({featureClientSchemaMap:l,i18n:f,schemaPath:c}):a.label),_e("div",{className:`${I}__group ${I}__group-${a.key}`,children:[G("div",{className:`${I}__group-title`,children:p}),a.items.map((s,E)=>G(Tt,{index:E,isSelected:u===s.key,item:s,onClick:()=>{h(s.key),x(s)},onMouseEnter:()=>{h(s.key)}},s.key))]},a.key)})}),n.current):null,onQueryChange:i,onSelectItem:m,triggerFn:d})}import{c as St}from"react/compiler-runtime";import{jsx as ze}from"react/jsx-runtime";import{ContentEditable as vt}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as It}from"@payloadcms/ui";import"react";function Ke(t){let e=St(3),{className:o}=t,{t:i}=It(),r;return e[0]!==i||e[1]!==o?(r=ze(vt,{"aria-placeholder":i("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:ze("p",{className:"editor-placeholder",children:i("lexical:general:placeholder")})}),e[0]=i,e[1]=o,e[2]=r):r=e[2],r}var Ue=t=>{let e=Mt(22),{editorConfig:o,editorContainerRef:i,onChange:r}=t,f=k(),[l]=Bt(),[c,d]=Ye(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=s=>{s!==null&&d(s)},e[0]=y):y=e[0];let g=y,m,n;e[1]!==f||e[2]!==l?(m=()=>{if(!f?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}f?.parentEditor?.uuid&&f.parentEditor?.registerChild(f.uuid,f);let s=()=>{f.focusEditor(f)},E=()=>{f.blurEditor(f)},b=l.registerCommand($t,()=>(s(),!0),Ge),w=l.registerCommand(_t,()=>(E(),!0),Ge);return()=>{b(),w(),f.parentEditor?.unregisterChild?.(f.uuid)}},n=[l,f],e[1]=f,e[2]=l,e[3]=m,e[4]=n):(m=e[3],n=e[4]),We(m,n);let[u,x]=Ye(!1),h,a;e[5]!==u?(h=()=>{let s=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==u&&x(E)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},a=[u],e[5]=u,e[6]=h,e[7]=a):(h=e[6],a=e[7]),We(h,a);let p;if(e[8]!==o.features||e[9]!==r||e[10]!==c||e[11]!==u||e[12]!==l||e[13]!==i){let s;e[15]!==r?(s=(b,w,C)=>{(!C.has("focus")||C.size>1)&&r?.(b,w,C)},e[15]=r,e[16]=s):s=e[16];let E;e[17]!==c||e[18]!==u||e[19]!==l||e[20]!==o?(E=c&&q(W.Fragment,{children:[!u&&l.isEditable()&&q(W.Fragment,{children:[P(Le,{anchorElem:c}),P(we,{anchorElem:c})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&u))return P(F,{anchorElem:c,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&P(W.Fragment,{children:P(je,{anchorElem:c})})]}),e[17]=c,e[18]=u,e[19]=l,e[20]=o,e[21]=E):E=e[21],p=q(W.Fragment,{children:[o.features.plugins?.map(Ht),q("div",{className:"editor-container",ref:i,children:[o.features.plugins?.map(jt),P(Ft,{contentEditable:P("div",{className:"editor-scroller",children:P("div",{className:"editor",ref:g,children:P(Ke,{})})}),ErrorBoundary:Lt}),P(Dt,{ignoreSelectionChange:!0,onChange:s}),E,l.isEditable()&&q(W.Fragment,{children:[P(At,{}),o?.features?.markdownTransformers?.length>0&&P(De,{})]}),P(Ot,{}),o.features.plugins?.map(zt),o.features.plugins?.map(Kt)]}),o.features.plugins?.map(Gt)]}),e[8]=o.features,e[9]=r,e[10]=c,e[11]=u,e[12]=l,e[13]=i,e[14]=p}else p=e[14];return p};function Ht(t){if(t.position==="aboveContainer")return P(F,{clientProps:t.clientProps,plugin:t},t.key)}function jt(t){if(t.position==="top")return P(F,{clientProps:t.clientProps,plugin:t},t.key)}function zt(t){if(t.position==="normal")return P(F,{clientProps:t.clientProps,plugin:t},t.key)}function Kt(t){if(t.position==="bottom")return P(F,{clientProps:t.clientProps,plugin:t},t.key)}function Gt(t){if(t.position==="belowContainer")return P(F,{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?L(o,{children:L(qe,{providers:e.slice(1),children:t})}):L(o,{children:t})},Je=t=>{let{composerKey:e,editorConfig:o,fieldProps:i,onChange:r,readOnly:f,value:l}=t,c=k(),d=Ve.useRef(null),y=Yt(()=>{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/beta/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/beta/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:f!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:ye({editorConfig:o}),onError:g=>{throw g},theme:o.lexical.theme}},[o]);return y?L(Wt,{initialConfig:y,children:L(de,{editorConfig:o,editorContainerRef:d,fieldProps:i,parentContext:c,children:L(qe,{providers:o.features.providers,children:L(Ue,{editorConfig:o,editorContainerRef:d,onChange:r})})})},e+y.editable):L("p",{children:"Loading..."})};import"./bundled.css";var ne="rich-text-lexical",eo=t=>{let{editorConfig:e,field:o,field:{name:i,admin:{className:r,readOnly:f}={},label:l,localized:c,required:d},path:y,readOnly:g,validate:m}=t,n=g||f,u=y??i,x=Vt(),h=Qe((U,me)=>{if(typeof m=="function")return m(U,{...me,required:d})},[m,d]),{customComponents:{AfterInput:a,BeforeInput:p,Description:s,Error:E,Label:b}={},formInitializing:w,formProcessing:C,initialValue:T,setValue:N,showError:Y,value:A}=qt({path:u,validate:h}),M=n||C||w,S=[ne,"field-type",r,Y&&"error",M&&`${ne}--read-only`,e?.admin?.hideGutter!==!0?`${ne}--show-gutter`:null].filter(Boolean).join(" "),$=`${u}.${x}`,se=Qe(U=>{N(U.toJSON())},[N]),ce=Xt(()=>Qt(o),[o]);return re("div",{className:S,style:ce,children:[E,b||ie(Ut,{label:l,localized:c,required:d}),re("div",{className:`${ne}__wrap`,children:[re(Zt,{fallbackRender:to,onReset:()=>{},children:[p,ie(Je,{composerKey:$,editorConfig:e,fieldProps:t,onChange:se,readOnly:M,value:A},JSON.stringify({initialValue:T,path:u})),a]}),s]})]},$)};function to({error:t}){return re("div",{className:"errorBoundary",role:"alert",children:[ie("p",{children:"Something went wrong:"}),ie("pre",{style:{color:"red"},children:t.message})]})}var ar=Jt(eo);export{ar as RichText};
|
|
2
|
+
//# sourceMappingURL=Field-NVIJGYLP.js.map
|