@payloadcms/richtext-lexical 3.56.0-internal.72f4fd2 → 3.57.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/exports/client/Field-SOED2PIU.js +2 -0
  2. package/dist/exports/client/{Field-PKJPWZJL.js.map → Field-SOED2PIU.js.map} +2 -2
  3. package/dist/exports/client/chunk-FSKAVN4P.js +2 -0
  4. package/dist/exports/client/{chunk-CYLMY5ZJ.js.map → chunk-FSKAVN4P.js.map} +2 -2
  5. package/dist/exports/client/chunk-KZKGNMS3.js +12 -0
  6. package/dist/exports/client/{chunk-YCH4JNUH.js.map → chunk-KZKGNMS3.js.map} +2 -2
  7. package/dist/exports/client/{component-3PENNOM3.js → component-M3U253XK.js} +2 -2
  8. package/dist/exports/client/index.d.ts +0 -2
  9. package/dist/exports/client/index.d.ts.map +1 -1
  10. package/dist/exports/client/index.js +10 -10
  11. package/dist/exports/client/index.js.map +4 -4
  12. package/dist/features/blocks/client/component/BlockContent.js +10 -8
  13. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  14. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +5 -3
  15. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  16. package/dist/features/relationship/client/plugins/index.js +37 -20
  17. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  18. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +53 -28
  19. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
  20. package/dist/features/toolbars/shared/ToolbarButton/index.js +37 -35
  21. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  22. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +30 -20
  23. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  24. package/dist/index.d.ts +0 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -3
  27. package/dist/index.js.map +1 -1
  28. package/dist/lexical/LexicalEditor.js +35 -22
  29. package/dist/lexical/LexicalEditor.js.map +1 -1
  30. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +15 -7
  31. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  32. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +15 -7
  33. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  34. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +141 -75
  35. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  36. package/dist/lexical/ui/ContentEditable.js +11 -2
  37. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  38. package/dist/nodeTypes.d.ts +1 -13
  39. package/dist/nodeTypes.d.ts.map +1 -1
  40. package/dist/nodeTypes.js +1 -4
  41. package/dist/nodeTypes.js.map +1 -1
  42. package/package.json +11 -11
  43. package/dist/exports/client/Field-PKJPWZJL.js +0 -2
  44. package/dist/exports/client/chunk-CYLMY5ZJ.js +0 -2
  45. package/dist/exports/client/chunk-YCH4JNUH.js +0 -12
  46. package/dist/field/RenderLexical/index.d.ts +0 -23
  47. package/dist/field/RenderLexical/index.d.ts.map +0 -1
  48. package/dist/field/RenderLexical/index.js +0 -124
  49. package/dist/field/RenderLexical/index.js.map +0 -1
  50. package/dist/utilities/buildEditorState.d.ts +0 -11
  51. package/dist/utilities/buildEditorState.d.ts.map +0 -1
  52. package/dist/utilities/buildEditorState.js +0 -76
  53. package/dist/utilities/buildEditorState.js.map +0 -1
  54. /package/dist/exports/client/{component-3PENNOM3.js.map → component-M3U253XK.js.map} +0 -0
@@ -1,12 +0,0 @@
1
- var nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";import{c as ce}from"react/compiler-runtime";import{useRef as ae}from"react";function Un(n){let t=ce(2),e=n===void 0?500:n,o=ae(void 0),r;return t[0]!==e?(r=s=>new Promise(i=>{let a=()=>{s(),i()};"requestIdleCallback"in window?("cancelIdleCallback"in window&&o.current!==void 0&&cancelIdleCallback(o.current),o.current=requestIdleCallback(a,{timeout:e})):le().then(a)}),t[0]=e,t[1]=r):r=t[1],r}function le(){return new Promise(n=>{setTimeout(n,100),requestAnimationFrame(()=>{setTimeout(n,0)})})}var G=class{_x;_y;constructor(t,e){this._x=t,this._y=e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}equals({x:t,y:e}){return this.x===t&&this.y===e}get x(){return this._x}get y(){return this._y}};function ot(n){return n instanceof G}import{jsx as ye}from"react/jsx-runtime";import{useLexicalComposerContext as be}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ke}from"@lexical/utils";import{$getSelection as Y,$isRangeSelection as W,$isTextNode as Ae,COMMAND_PRIORITY_LOW as Oe,createCommand as Me,getDOMSelection as Le}from"lexical";import{useCallback as mt,useEffect as gt,useState as $e}from"react";import*as X from"react";import{c as at}from"react/compiler-runtime";import{useLexicalComposerContext as lt}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as rt}from"@lexical/utils";import{$getSelection as ft,$isRangeSelection as fe,$setSelection as ue,COMMAND_PRIORITY_LOW as N,createCommand as de,KEY_ARROW_DOWN_COMMAND as me,KEY_ARROW_UP_COMMAND as ge,KEY_ENTER_COMMAND as pe,KEY_ESCAPE_COMMAND as he,KEY_TAB_COMMAND as xe}from"lexical";import{useCallback as z,useEffect as y,useLayoutEffect as Ee,useMemo as _e,useRef as Te,useState as Se}from"react";var we="slash-menu-popup",it=n=>{let t=document.getElementById("slash-menu");if(!t)return;let e=t.getBoundingClientRect();e.top+e.height>window.innerHeight&&t.scrollIntoView({block:"center"}),e.top<0&&t.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function Re(n,t,e){let o=e;for(let r=o;r<=t.length;r++)n.substring(n.length-r)===t.substring(0,r)&&(o=r);return o}function Ce(n){let t=ft();if(!fe(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let o=e.getNode();if(!o.isSimpleText())return;let r=e.offset,c=o.getTextContent().slice(0,r),s=n.replaceableString.length,i=Re(c,n.matchingString,s),a=r-i;if(a<0)return;let l;return a===0?[l]=o.splitText(r):[,l]=o.splitText(a,r),l}function Fe(n,t){let e=getComputedStyle(n),o=e.position==="absolute",r=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let c=n;c=c.parentElement;)if(e=getComputedStyle(c),!(o&&e.position==="static")&&r.test(e.overflow+e.overflowY+e.overflowX))return c;return document.body}function st(n,t){let e=n.getBoundingClientRect(),o=t.getBoundingClientRect();return e.top>o.top&&e.top<o.bottom}function Ie(n,t,e,o){let r=at(7),[c]=lt(),s,i;r[0]!==c||r[1]!==e||r[2]!==o||r[3]!==n||r[4]!==t?(s=()=>{let a=t.current;if(a!=null&&n!=null){let l=c.getRootElement(),u=l!=null?Fe(l,!1):document.body,g=!1,m=st(a,u),p=function(){g||(window.requestAnimationFrame(function(){e(),g=!1}),g=!0);let d=st(a,u);d!==m&&(m=d,o?.(d))},f=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",p,{capture:!0,passive:!0}),f.observe(a),()=>{f.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",p,!0)}}},i=[c,o,e,n,t],r[0]=c,r[1]=e,r[2]=o,r[3]=n,r[4]=t,r[5]=s,r[6]=i):(s=r[5],i=r[6]),y(s,i)}var ct=de("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function ut({anchorElementRef:n,close:t,editor:e,groups:o,menuRenderFn:r,resolution:c,shouldSplitNodeWithQuery:s=!1}){let[i,a]=Se(null),l=c.match&&c.match.matchingString||"",u=z(f=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${we}__item-${f.key}`),a(f.key))},[e]),g=z(()=>{if(o!==null&&l!=null){let f=o.flatMap(d=>d.items);if(f.length){let d=f[0];u(d)}}},[o,u,l]);y(()=>{g()},[l,g]);let m=z(f=>{t(),e.update(()=>{let d=c.match!=null&&s?Ce(c.match):null;d&&d.remove()}),setTimeout(()=>{let d;e.read(()=>{d=ft()?.clone()}),e.update(()=>{d&&ue(d)}),f.onSelect({editor:e,queryString:c.match?c.match.matchingString:""})},0)},[e,s,c.match,t]);y(()=>()=>{let f=e.getRootElement();f!==null&&f.removeAttribute("aria-activedescendant")},[e]),Ee(()=>{o===null?a(null):i===null&&g()},[o,i,u,g]),y(()=>rt(e.registerCommand(ct,({item:f})=>f.ref&&f.ref.current!=null?(it(f.ref.current),!0):!1,N)),[e,u]),y(()=>rt(e.registerCommand(me,f=>{let d=f;if(o!==null&&o.length&&i!==null){let h=o.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==h.length-1?x+1:0,_=h[E];if(!_)return!1;u(_),_.ref!=null&&_.ref.current&&e.dispatchCommand(ct,{index:E,item:_}),d.preventDefault(),d.stopImmediatePropagation()}return!0},N),e.registerCommand(ge,f=>{let d=f;if(o!==null&&o.length&&i!==null){let h=o.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==0?x-1:h.length-1,_=h[E];if(!_)return!1;u(_),_.ref!=null&&_.ref.current&&it(_.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},N),e.registerCommand(he,f=>{let d=f;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},N),e.registerCommand(xe,f=>{let d=f;if(o===null||i===null)return!1;let x=o.flatMap(E=>E.items).find(E=>E.key===i);return x?(d.preventDefault(),d.stopImmediatePropagation(),m(x),!0):!1},N),e.registerCommand(pe,f=>{if(o===null||i===null)return!1;let h=o.flatMap(x=>x.items).find(x=>x.key===i);return h?(f!==null&&(f.preventDefault(),f.stopImmediatePropagation()),m(h),!0):!1},N)),[m,t,e,o,i,u]);let p=_e(()=>({groups:o,selectedItemKey:i,selectItemAndCleanUp:m,setSelectedItemKey:a}),[m,i,o]);return r(n,p,c.match?c.match.matchingString:"")}function Ne(n,t){t!=null&&(n.className=t),n.setAttribute("aria-label","Slash menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function dt(n,t,e,o){let r=at(14),[c]=lt(),s;r[0]===Symbol.for("react.memo_cache_sentinel")?(s=nt?document.createElement("div"):null,r[0]=s):s=r[0];let i=Te(s),a;r[1]!==n||r[2]!==o||r[3]!==c||r[4]!==t?(a=()=>{if(i.current===null||parent===void 0)return;let f=c.getRootElement(),d=i.current,h=d.firstChild;if(f!==null&&t!==null){let{height:x,width:E}=t.getRect(),{left:_,top:T}=t.getRect(),I=T;if(T=T-(n.getBoundingClientRect().top+window.scrollY),_=_-(n.getBoundingClientRect().left+window.scrollX),d.style.left=`${_+window.scrollX}px`,d.style.height=`${x}px`,d.style.width=`${E}px`,h!==null){let S=h.getBoundingClientRect(),$=S.height,C=S.width,et=f.getBoundingClientRect();_+C>et.right&&(d.style.left=`${et.right-C+window.scrollX}px`);let ie=I+$+32>window.innerHeight,se=I<0;ie&&!se?d.style.top=`${T+32-$+window.scrollY-(x+24)}px`:d.style.top=`${T+window.scrollY+32}px`}d.isConnected||(Ne(d,o),n.append(d)),d.setAttribute("id","slash-menu"),i.current=d,f.setAttribute("aria-controls","slash-menu")}},r[1]=n,r[2]=o,r[3]=c,r[4]=t,r[5]=a):a=r[5];let l=a,u,g;r[6]!==c||r[7]!==l||r[8]!==t?(u=()=>{let f=c.getRootElement();if(t!==null)return l(),()=>{f!==null&&f.removeAttribute("aria-controls");let d=i.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},g=[c,l,t],r[6]=c,r[7]=l,r[8]=t,r[9]=u,r[10]=g):(u=r[9],g=r[10]),y(u,g);let m;return r[11]!==t||r[12]!==e?(m=f=>{t!==null&&(f||e(null))},r[11]=t,r[12]=e,r[13]=m):m=r[13],Ie(t,i,l,m),i}var ro=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function De(n){let t=n.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let o=t.offset;return e.getTextContent().slice(0,o)}function pt(n,t,e){let o=Le(e);if(o===null||!o.isCollapsed)return!1;let r=o.anchorNode,c=n,s=o.anchorOffset;if(r==null||s==null)return!1;try{t.setStart(r,c),t.setEnd(r,s>1?s:1)}catch{return!1}return!0}function Be(n){let t;return n.getEditorState().read(()=>{let e=Y();W(e)&&(t=De(e))}),t}function ht(n,t){return t!==0?!1:n.getEditorState().read(()=>{let e=Y();if(W(e)){let c=e.anchor.getNode().getPreviousSibling();return Ae(c)&&c.isTextEntity()}return!1})}function xt(n){X.startTransition?X.startTransition(n):n()}var Pe=Me("ENABLE_SLASH_MENU_COMMAND");function io({anchorClassName:n,anchorElem:t,groups:e,menuRenderFn:o,onClose:r,onOpen:c,onQueryChange:s,triggerFn:i}){let[a]=be(),[l,u]=$e(null),g=dt(t,l,u,n),m=mt(()=>{u(null),r!=null&&l!==null&&r()},[r,l]),p=mt(f=>{u(f),c!=null&&l===null&&c(f)},[c,l]);return gt(()=>ke(a.registerCommand(Pe,({node:f})=>(a.getEditorState().read(()=>{let d={leadOffset:0,matchingString:"",replaceableString:""};if(!ht(a,d.leadOffset)&&f!==null){let h=a._window??window,x=h.document.createRange();pt(d.leadOffset,x,h)!==null&&xt(()=>p({getRect:()=>x.getBoundingClientRect(),match:d}));return}}),!0),Oe)),[a,p]),gt(()=>{let f=()=>{a.getEditorState().read(()=>{let h=a._window??window,x=h.document.createRange(),E=Y(),_=Be(a);if(!W(E)||!E.isCollapsed()||_===void 0||x===null){m();return}let T=i({editor:a,query:_});if(s(T?T.matchingString:null),T!==null&&!ht(a,T.leadOffset)&&pt(T.leadOffset,x,h)!==null){xt(()=>p({getRect:()=>x.getBoundingClientRect(),match:T}));return}m()})},d=a.registerUpdateListener(f);return()=>{d()}},[a,i,s,l,m,p]),g.current===null||l===null||a===null?null:ye(ut,{anchorElementRef:g,close:m,editor:a,groups:e,menuRenderFn:o,resolution:l,shouldSplitNodeWithQuery:!0})}var Et=class n{_bottom;_left;_right;_top;constructor(t,e,o,r){let[c,s]=e<=r?[e,r]:[r,e],[i,a]=t<=o?[t,o]:[o,t];this._top=c,this._right=a,this._left=i,this._bottom=s}static fromDOM(t){let{height:e,left:o,top:r,width:c}=t.getBoundingClientRect();return n.fromLWTH(o,c,r,e)}static fromDOMRect(t){let{height:e,left:o,top:r,width:c}=t;return n.fromLWTH(o,c,r,e)}static fromLTRB(t,e,o,r){return new n(t,e,o,r)}static fromLWTH(t,e,o,r){return new n(t,o,t+e,o+r)}static fromPoints(t,e){let{x:o,y:r}=t,{x:c,y:s}=e;return n.fromLTRB(o,r,c,s)}contains(t){if(ot(t)){let{x:s,y:i}=t,a=i<this._top,l=i>this._bottom,u=s<this._left,g=s>this._right;return{reason:{isOnBottomSide:l,isOnLeftSide:u,isOnRightSide:g,isOnTopSide:a},result:!a&&!l&&!u&&!g}}let{bottom:e,left:o,right:r,top:c}=t;return c>=this._top&&c<=this._bottom&&e>=this._top&&e<=this._bottom&&o>=this._left&&o<=this._right&&r>=this._left&&r<=this._right}distanceFromPoint(t){let e=this.contains(t);if(e.result)return{distance:0,isOnBottomSide:e.reason.isOnBottomSide,isOnLeftSide:e.reason.isOnLeftSide,isOnRightSide:e.reason.isOnRightSide,isOnTopSide:e.reason.isOnTopSide};let o=0,r=0;return t.x<this._left?o=this._left-t.x:t.x>this._right&&(o=t.x-this._right),t.y<this._top?r=this._top-t.y:t.y>this._bottom&&(r=t.y-this._bottom),{distance:Math.sqrt(o*o+r*r),isOnBottomSide:t.y>this._bottom,isOnLeftSide:t.x<this._left,isOnRightSide:t.x>this._right,isOnTopSide:t.y<this._top}}equals({bottom:t,left:e,right:o,top:r}){return r===this._top&&t===this._bottom&&e===this._left&&o===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:o=this.right,top:r=this.top}){return new n(e,r,o,t)}intersectsWith(t){let{height:e,left:o,top:r,width:c}=t,{height:s,left:i,top:a,width:l}=this,u=o+c>=i+l?o+c:i+l,g=r+e>=a+s?r+e:a+s,m=o<=i?o:i,p=r<=a?r:a;return u-m<=c+l&&g-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 lo({editorConfig:n}){return ve({nodes:n.features.nodes})}function ve({nodes:n}){return n.map(t=>"node"in t?t.node:t)}import{$getRoot as qe,$isDecoratorNode as Rt,$isElementNode as P,$isLineBreakNode as Qe,$isTextNode as v}from"lexical";import{$isListItemNode as He,$isListNode as _t}from"@lexical/list";import{$isHeadingNode as Ke,$isQuoteNode as Ue}from"@lexical/rich-text";import{$isParagraphNode as Ge,$isTextNode as ze}from"lexical";var w={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...w,requiresParagraphStart:!0},po={...R,export:b(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},ho={...R,export:b(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},xo={...R,export:b(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Eo={...R,export:b(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},_o={...R,export:b(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},To={...R,export:b(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},So={...R,export:Ye,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},wo={...R,export:q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},Ro={...R,export:q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},Co={...R,export:q,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},Fo={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},Io={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},No={...w,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},yo={...w,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},bo={...w,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},ko={...w,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},Ao={...w,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Oo={...w,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Mo={...w,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},Lo={...w,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},$o={...w,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},Do={...w,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Bo={...w,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},Po={...w,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function b(n){return(t,e)=>Ke(t)&&t.getTag()==="h"+n?"#".repeat(n)+" "+e(t):null}function q(n,t){return _t(n)?Tt(n,t,0):null}var Xe=4;function Tt(n,t,e){let o=[],r=n.getChildren(),c=0;for(let s of r)if(He(s)){if(s.getChildrenSize()===1){let l=s.getFirstChild();if(_t(l)){o.push(Tt(l,t,e+1));continue}}let i=" ".repeat(e*Xe),a=n.getListType()==="bullet"?"- ":`${n.getStart()+c}. `;o.push(i+a+t(s)),c++}return o.join(`
2
- `)}function Ye(n,t){return Ue(n)?"> "+t(n):null}function D(n,t){let e={};for(let o of n){let r=t(o);r&&(e[r]?e[r].push(o):e[r]=[o])}return e}function k(n){let t=D(n,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var A=/[!-/:-@[-`{-~\s]/,We=/^\s{0,3}$/;function L(n){if(!Ge(n))return!1;let t=n.getFirstChild();return t==null||n.getChildrenSize()===1&&ze(t)&&We.test(t.getTextContent())}function Ct(n,t=!1){let e=k(n),o=[...e.multilineElement,...e.element],r=!t,c=e.textFormat.filter(s=>s.format.length===1).sort((s,i)=>s.format.includes("code")&&!i.format.includes("code")?1:!s.format.includes("code")&&i.format.includes("code")?-1:0);return s=>{let i=[],a=(s||qe()).getChildren();return a.forEach((l,u)=>{let g=je(l,o,c,e.textMatch);g!=null&&i.push(r&&u>0&&!L(l)&&!L(a[u-1])?`
3
- `.concat(g):g)}),i.join(`
4
- `)}}function je(n,t,e,o){for(let r of t){if(!r.export)continue;let c=r.export(n,s=>H(s,e,o));if(c!=null)return c}return P(n)?H(n,e,o):Rt(n)?n.getTextContent():null}function H(n,t,e,o,r){let c=[],s=n.getChildren();o||(o=[]),r||(r=[]);t:for(let i of s){for(let a of e){if(!a.export)continue;let l=a.export(i,u=>H(u,t,e,o,[...r,...o]),(u,g)=>St(u,g,t,o,r));if(l!=null){c.push(l);continue t}}Qe(i)?c.push(`
5
- `):v(i)?c.push(St(i,i.getTextContent(),t,o,r)):P(i)?c.push(H(i,t,e,o,r)):Rt(i)&&c.push(i.getTextContent())}return c.join("")}function St(n,t,e,o,r){let c=t.trim(),s=c;n.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",a="",l="",u=wt(n,!0),g=wt(n,!1),m=new Set;for(let p of e){let f=p.format[0],d=p.tag;B(n,f)&&!m.has(f)&&(m.add(f),(!B(u,f)||!o.find(h=>h.tag===d))&&(o.push({format:f,tag:d}),i+=d))}for(let p=0;p<o.length;p++){let f=o[p],d=B(n,f.format),h=B(g,f.format);if(d&&h)continue;let x=[...o];for(;x.length>p;){let E=x.pop();r&&E&&r.find(_=>_.tag===E.tag)||(E&&typeof E.tag=="string"&&(d?h||(l+=E.tag):a+=E.tag),o.pop())}break}return s=i+s+l,a+t.replace(c,()=>s)}function wt(n,t){let e=t?n.getPreviousSibling():n.getNextSibling();if(!e){let o=n.getParentOrThrow();o.isInline()&&(e=t?o.getPreviousSibling():o.getNextSibling())}for(;e;){if(P(e)){if(!e.isInline())break;let o=t?e.getLastDescendant():e.getFirstDescendant();if(v(o))return o;e=t?e.getPreviousSibling():e.getNextSibling()}if(v(e))return e;if(!P(e))return null}return null}function B(n,t){return v(n)&&n.hasFormat(t)}import{$isListItemNode as Ze,$isListNode as bt}from"@lexical/list";import{$isQuoteNode as Je}from"@lexical/rich-text";import{$findMatchingParent as tn}from"@lexical/utils";import{$createLineBreakNode as en,$createParagraphNode as nn,$createTextNode as on,$getRoot as rn,$getSelection as sn,$isParagraphNode as cn}from"lexical";import{$isTextNode as O}from"lexical";function Ft(n,t){let e=n.getTextContent(),o=Ve(e,t);if(!o)return null;let r=o.index||0,c=r+o[0].length,s=t.transformersByTag[o[1]];return{endIndex:c,match:o,startIndex:r,transformer:s}}function Ve(n,t){let e=n.match(t.openTagsRegExp);if(e==null)return null;for(let o of e){let r=o.replace(/^\s/,""),c=t.fullMatchRegExpByTag[r];if(c==null)continue;let s=n.match(c),i=t.transformersByTag[r];if(s!=null&&i!=null){if(i.intraword!==!1)return s;let{index:a=0}=s,l=n[a-1],u=n[a+s[0].length];if((!l||A.test(l))&&(!u||A.test(u)))return s}}return null}function It(n,t,e,o,r){let c=n.getTextContent(),s,i,a;if(r[0]===c?a=n:t===0?[a,s]=n.splitText(e):[i,a,s]=n.splitText(t,e),a.setTextContent(r[2]),o)for(let l of o.format)a.hasFormat(l)||a.toggleFormat(l);return{nodeAfter:s,nodeBefore:i,transformedNode:a}}function Nt(n,t){let e=n,o,r,c,s;for(let i of t){if(!i.replace||!i.importRegExp)continue;let a=e.getTextContent().match(i.importRegExp);if(!a)continue;let l=a.index||0,u=i.getEndIndex?i.getEndIndex(e,a):l+a[0].length;u!==!1&&(o===void 0||r===void 0||l<o&&u>r)&&(o=l,r=u,c=i,s=a)}return o===void 0||r===void 0||c===void 0||s===void 0?null:{endIndex:r,match:s,startIndex:o,transformer:c}}function yt(n,t,e,o,r){let c,s,i;if(t===0?[i,c]=n.splitText(e):[s,i,c]=n.splitText(t,e),!o.replace)return null;let a=i?o.replace(i,r):void 0;return{nodeAfter:c,nodeBefore:s,transformedNode:a||void 0}}function F(n,t,e){let o=Ft(n,t),r=Nt(n,e);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){let i=It(n,o.startIndex,o.endIndex,o.transformer,o.match);i.nodeAfter&&O(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&F(i.nodeAfter,t,e),i.nodeBefore&&O(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&F(i.nodeBefore,t,e),i.transformedNode&&O(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&F(i.transformedNode,t,e)}else if(r){let i=yt(n,r.startIndex,r.endIndex,r.transformer,r.match);if(!i)return;i.nodeAfter&&O(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&F(i.nodeAfter,t,e),i.nodeBefore&&O(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&F(i.nodeBefore,t,e),i.transformedNode&&O(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&F(i.transformedNode,t,e)}let s=n.getTextContent().replace(/\\([*_`~])/g,"$1");n.setTextContent(s)}function kt(n,t=!1){let e=k(n),o=fn(e.textFormat);return(r,c)=>{let s=r.split(`
6
- `),i=s.length,a=c||rn();a.clear();for(let u=0;u<i;u++){let g=s[u],[m,p]=an(s,u,e.multilineElement,a);if(m){u=p;continue}ln(g,a,e.element,o,e.textMatch)}let l=a.getChildren();for(let u of l)!t&&L(u)&&a.getChildrenSize()>1&&u.remove();sn()!==null&&a.selectStart()}}function an(n,t,e,o){for(let r of e){let{handleImportAfterStartMatch:c,regExpEnd:s,regExpStart:i,replace:a}=r,l=n[t]?.match(i);if(!l)continue;if(c){let f=c({lines:n,rootNode:o,startLineIndex:t,startMatch:l,transformer:r});if(f===null)continue;if(f)return f}let u=typeof s=="object"&&"regExp"in s?s.regExp:s,g=s&&typeof s=="object"&&"optional"in s?s.optional:!s,m=t,p=n.length;for(;m<p;){let f=u?n[m]?.match(u):null;if(!f&&(!g||g&&m<p-1)){m++;continue}if(f&&t===m&&f.index===l.index){m++;continue}let d=[];if(f&&t===m)d.push(n[t].slice(l[0].length,-f[0].length));else for(let h=t;h<=m;h++){let x=n[h];if(h===t){let E=x.slice(l[0].length);d.push(E)}else if(h===m&&f){let E=x.slice(0,-f[0].length);d.push(E)}else d.push(x)}if(a(o,null,l,f,d,!0)!==!1)return[!0,m];break}}return[!1,t]}function ln(n,t,e,o,r){let c=on(n),s=nn();s.append(c),t.append(s);for(let{regExp:i,replace:a}of e){let l=n.match(i);if(l&&(c.setTextContent(n.slice(l[0].length)),a(s,[c],l,!0)!==!1))break}if(F(c,o,r),s.isAttached()&&n.length>0){let i=s.getPreviousSibling();if(cn(i)||Je(i)||bt(i)){let a=i;if(bt(i)){let l=i.getLastDescendant();l==null?a=null:a=tn(l,Ze)}a!=null&&a.getTextContentSize()>0&&(a.splice(a.getChildrenSize(),0,[en(),...s.getChildren()]),s.remove())}}}function fn(n){let t={},e={},o=[],r="(?<![\\\\])";for(let c of n){let{tag:s}=c;t[s]=c;let i=s.replace(/([*^+])/g,"\\$1");o.push(i),s.length===1?e[s]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):e[s]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:t}}import{$createRangeSelection as un,$getSelection as Q,$isLineBreakNode as dn,$isRangeSelection as j,$isRootOrShadowRoot as Ot,$isTextNode as Mt,$setSelection as mn}from"lexical";function gn(n,t,e,o){let r=n.getParent();if(!Ot(r)||n.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExp:s,replace:i}of o){let a=c.match(s);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let l=t.getNextSiblings(),[u,g]=t.splitText(e);u?.remove();let m=g?[g,...l]:l;if(i(n,m,a,!1)!==!1)return!0}}return!1}function pn(n,t,e,o){let r=n.getParent();if(!Ot(r)||n.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExpEnd:s,regExpStart:i,replace:a}of o){if(s&&!("optional"in s)||s&&"optional"in s&&!s.optional)continue;let l=c.match(i);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let u=t.getNextSiblings(),[g,m]=t.splitText(e);g?.remove();let p=m?[m,...u]:u;if(a(n,p,l,null,null,!1)!==!1)return!0}}return!1}function hn(n,t,e){let o=n.getTextContent(),r=o[t-1],c=e[r];if(c==null)return!1;t<o.length&&(o=o.slice(0,t));for(let s of c){if(!s.replace||!s.regExp)continue;let i=o.match(s.regExp);if(i===null)continue;let a=i.index||0,l=a+i[0].length,u;return a===0?[u]=n.splitText(l):[,u]=n.splitText(a,l),u&&(u.selectNext(0,0),s.replace(u,i)),!0}return!1}function xn(n,t,e){let o=n.getTextContent(),r=t-1,c=o[r],s=e[c];if(!s)return!1;for(let i of s){let{tag:a}=i,l=a.length,u=r-l+1;if(l>1&&!Lt(o,u,a,0,l)||o[u-1]===" ")continue;let g=o[r+1];if(i.intraword===!1&&g&&!A.test(g))continue;let m=n,p=m,f=At(o,u,a),d=p;for(;f<0&&(d=d.getPreviousSibling())&&!dn(d);)if(Mt(d)){let C=d.getTextContent();p=d,f=At(C,C.length,a)}if(f<0||p===m&&f+l===u)continue;let h=p.getTextContent();if(f>0&&h[f-1]===c)continue;let x=h[f-1];if(i.intraword===!1&&x&&!A.test(x))continue;let E=m.getTextContent(),_=E.slice(0,u)+E.slice(r+1);m.setTextContent(_);let T=p===m?_:h;p.setTextContent(T.slice(0,f)+T.slice(f+l));let I=Q(),S=un();mn(S);let $=r-l*(p===m?2:1)+1;S.anchor.set(p.__key,f,"text"),S.focus.set(m.__key,$,"text");for(let C of i.format)S.hasFormat(C)||S.formatText(C);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(let C of i.format)S.hasFormat(C)&&S.toggleFormat(C);return j(I)&&(S.format=I.format),!0}return!1}function At(n,t,e){let o=e.length;for(let r=t;r>=o;r--){let c=r-o;if(Lt(n,c,e,0,o)&&n[c+o]!==" ")return c}return-1}function Lt(n,t,e,o,r){for(let c=0;c<r;c++)if(n[t+c]!==e[o+c])return!1;return!0}function sr(n,t=K){let e=k(t),o=D(e.textFormat,({tag:s})=>s[s.length-1]),r=D(e.textMatch,({trigger:s})=>s);for(let s of t){let i=s.type;if(i==="element"||i==="text-match"||i==="multiline-element"){let a=s.dependencies;for(let l of a)if(!n.hasNode(l))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+l.getType())}}let c=(s,i,a)=>{gn(s,i,a,e.element)||pn(s,i,a,e.multilineElement)||hn(i,a,r)||xn(i,a,o)};return n.registerUpdateListener(({dirtyLeaves:s,editorState:i,prevEditorState:a,tags:l})=>{if(l.has("collaboration")||l.has("historic")||n.isComposing())return;let u=i.read(Q),g=a.read(Q);if(!j(g)||!j(u)||!u.isCollapsed()||u.is(g))return;let m=u.anchor.key,p=u.anchor.offset,f=i._nodeMap.get(m);!Mt(f)||!s.has(m)||p!==1&&p>g.anchor.offset+1||n.update(()=>{if(f.hasFormat("code"))return;let d=f.getParent();d!==null&&c(d,f,u.anchor.offset)})})}import{$createListItemNode as En,$createListNode as _n,$isListItemNode as Tn,$isListNode as M,ListItemNode as Z,ListNode as J}from"@lexical/list";import{$createHeadingNode as Sn,$createQuoteNode as wn,$isHeadingNode as Rn,$isQuoteNode as $t,HeadingNode as Cn,QuoteNode as Fn}from"@lexical/rich-text";import{$createLineBreakNode as In}from"lexical";var Dt=/^[\t ]*$/,Ht=/^(\s*)(\d+)\.\s/,Kt=/^(\s*)[-*+]\s/,Ut=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,V=/^(#{1,6})\s/,Gt=/^>\s/,Nn=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,Bt=/[ \t]*(\\`\\`\\`|```)$/,yn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,bn=/^\|(.+)\|\s?$/,kn=/^(\| ?:?-*:? ?)+\|\s?$/,Pt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,vt=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,An=n=>(t,e,o)=>{let r=n(o);r.append(...e),t.replace(r),r.select(0,0)},zt=4;function On(n){let t=n.match(/\t/g),e=n.match(/ /g),o=0;return t&&(o+=t.length),e&&(o+=Math.floor(e.length/zt)),o}var tt=n=>(t,e,o)=>{let r=t.getPreviousSibling(),c=t.getNextSibling(),s=En(n==="check"?o[3]==="x":void 0);if(M(c)&&c.getListType()===n){let a=c.getFirstChild();a!==null?a.insertBefore(s):c.append(s),t.remove()}else if(M(r)&&r.getListType()===n)r.append(s),t.remove();else{let a=_n(n,n==="number"?Number(o[2]):void 0);a.append(s),t.replace(a)}s.append(...e),s.select(0,0);let i=On(o[1]);i&&s.setIndent(i)},U=(n,t,e)=>{let o=[],r=n.getChildren(),c=0;for(let s of r)if(Tn(s)){if(s.getChildrenSize()===1){let u=s.getFirstChild();if(M(u)){o.push(U(u,t,e+1));continue}}let i=" ".repeat(e*zt),a=n.getListType(),l=a==="number"?`${n.getStart()+c}. `:a==="check"?`- [${s.getChecked()?"x":" "}] `:"- ";o.push(i+l+t(s)),c++}return o.join(`
7
- `)},Xt={type:"element",dependencies:[Cn],export:(n,t)=>{if(!Rn(n))return null;let e=Number(n.getTag().slice(1));return"#".repeat(e)+" "+t(n)},regExp:V,replace:An(n=>{let t="h"+n[1].length;return Sn(t)})},Yt={type:"element",dependencies:[Fn],export:(n,t)=>{if(!$t(n))return null;let e=t(n).split(`
8
- `),o=[];for(let r of e)o.push("> "+r);return o.join(`
9
- `)},regExp:Gt,replace:(n,t,e,o)=>{if(o){let c=n.getPreviousSibling();if($t(c)){c.splice(c.getChildrenSize(),0,[In(),...t]),c.select(0,0),n.remove();return}}let r=wn();r.append(...t),n.replace(r),r.select(0,0)}},Wt={type:"element",dependencies:[J,Z],export:(n,t)=>M(n)?U(n,t,0):null,regExp:Kt,replace:tt("bullet")},Mn={type:"element",dependencies:[J,Z],export:(n,t)=>M(n)?U(n,t,0):null,regExp:Ut,replace:tt("check")},qt={type:"element",dependencies:[J,Z],export:(n,t)=>M(n)?U(n,t,0):null,regExp:Ht,replace:tt("number")},Qt={type:"text-format",format:["code"],tag:"`"},jt={type:"text-format",format:["highlight"],tag:"=="},Vt={type:"text-format",format:["bold","italic"],tag:"***"},Zt={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},Jt={type:"text-format",format:["bold"],tag:"**"},te={type:"text-format",format:["bold"],intraword:!1,tag:"__"},ee={type:"text-format",format:["strikethrough"],tag:"~~"},ne={type:"text-format",format:["italic"],tag:"*"},oe={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function re(n,t){let e=n.split(`
10
- `),o=!1,r=[],c=0;for(let s=0;s<e.length;s++){let i=e[s],a=r[r.length-1];if(yn.test(i)){r.push(i);continue}if(Bt.test(i)){c===0&&(o=!0),c===1&&(o=!1),c>0&&c--,r.push(i);continue}if(Nn.test(i)){o=!0,c++,r.push(i);continue}if(o){r.push(i);continue}Dt.test(i)||Dt.test(a)||!a||V.test(a)||V.test(i)||Gt.test(i)||Ht.test(i)||Kt.test(i)||Ut.test(i)||bn.test(i)||kn.test(i)||!t||Pt.test(i)||vt.test(i)||Pt.test(a)||vt.test(a)||Bt.test(a)?r.push(i):r[r.length-1]=a+" "+i.trim()}return r.join(`
11
- `)}var Ln=[Xt,Yt,Wt,qt],$n=[],Dn=[Qt,Vt,Zt,Jt,te,jt,ne,oe,ee],Bn=[],K=[...Ln,...$n,...Dn,...Bn];function pr(n,t=K,e,o=!1,r=!0){let c=o?n:re(n,r);return kt(t,o)(c,e)}function hr(n=K,t,e=!1){return Ct(n,e)(t)}export{nt as a,Un as b,sr as c,pr as d,hr as e,G as f,ot as g,ro as h,Pe as i,io as j,Et as k,lo as l};
12
- //# sourceMappingURL=chunk-YCH4JNUH.js.map
@@ -1,23 +0,0 @@
1
- import { type FieldType, type RenderFieldServerFnArgs } from '@payloadcms/ui';
2
- import React from 'react';
3
- import type { DefaultTypedEditorState } from '../../nodeTypes.js';
4
- /**
5
- * Utility to render a lexical editor on the client.
6
- *
7
- * @experimental - may break in minor releases
8
- * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx
9
- */
10
- export declare const RenderLexical: React.FC<
11
- /**
12
- * If value or setValue, or both, is provided, this component will manage its own value.
13
- * If neither is passed, it will rely on the parent form to manage the value.
14
- */
15
- {
16
- /**
17
- * Override the loading state while the field component is being fetched and rendered.
18
- */
19
- Loading?: React.ReactElement;
20
- setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue'];
21
- value?: FieldType<DefaultTypedEditorState | undefined>['value'];
22
- } & RenderFieldServerFnArgs>;
23
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/field/RenderLexical/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,uBAAuB,EAK7B,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAyC,MAAM,OAAO,CAAA;AAE7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE;AAClC;;;GAGG;AACH;IACE;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,CAAA;IAE5B,QAAQ,CAAC,EAAE,SAAS,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC,UAAU,CAAC,CAAA;IACrE,KAAK,CAAC,EAAE,SAAS,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAA;CAChE,GAAG,uBAAuB,CAoF5B,CAAA"}
@@ -1,124 +0,0 @@
1
- 'use client';
2
-
3
- import { c as _c } from "react/compiler-runtime";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- import { FieldContext, FieldPathContext, ServerFunctionsContext, ShimmerEffect, useServerFunctions } from '@payloadcms/ui';
6
- import React, { useCallback, useEffect, useRef } from 'react';
7
- /**
8
- * Utility to render a lexical editor on the client.
9
- *
10
- * @experimental - may break in minor releases
11
- * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx
12
- */
13
- export const RenderLexical = args => {
14
- const $ = _c(9);
15
- const {
16
- field,
17
- initialValue,
18
- Loading,
19
- path,
20
- schemaPath,
21
- setValue,
22
- value
23
- } = args;
24
- const [Component, setComponent] = React.useState(null);
25
- const serverFunctionContext = useServerFunctions();
26
- const {
27
- _internal_renderField
28
- } = serverFunctionContext;
29
- const [entityType, entitySlug] = schemaPath.split(".");
30
- const fieldPath = path ?? (field && "name" in field ? field?.name : "") ?? "";
31
- let t0;
32
- if ($[0] !== _internal_renderField || $[1] !== field || $[2] !== initialValue || $[3] !== path || $[4] !== schemaPath) {
33
- t0 = () => {
34
- const render = async function render() {
35
- const {
36
- Field
37
- } = await _internal_renderField({
38
- field,
39
- initialValue: initialValue ?? undefined,
40
- path,
41
- schemaPath
42
- });
43
- setComponent(Field);
44
- };
45
- render();
46
- };
47
- $[0] = _internal_renderField;
48
- $[1] = field;
49
- $[2] = initialValue;
50
- $[3] = path;
51
- $[4] = schemaPath;
52
- $[5] = t0;
53
- } else {
54
- t0 = $[5];
55
- }
56
- const renderLexical = t0;
57
- const mounted = useRef(false);
58
- let t1;
59
- let t2;
60
- if ($[6] !== renderLexical) {
61
- t1 = () => {
62
- if (mounted.current) {
63
- return;
64
- }
65
- mounted.current = true;
66
- renderLexical();
67
- };
68
- t2 = [renderLexical];
69
- $[6] = renderLexical;
70
- $[7] = t1;
71
- $[8] = t2;
72
- } else {
73
- t1 = $[7];
74
- t2 = $[8];
75
- }
76
- useEffect(t1, t2);
77
- if (!Component) {
78
- return typeof Loading !== "undefined" ? Loading : _jsx(ShimmerEffect, {});
79
- }
80
- const adjustedServerFunctionContext = {
81
- ...serverFunctionContext,
82
- getFormState: async getFormStateArgs => serverFunctionContext.getFormState({
83
- ...getFormStateArgs,
84
- collectionSlug: entityType === "collection" ? entitySlug : undefined,
85
- globalSlug: entityType === "global" ? entitySlug : undefined
86
- })
87
- };
88
- if (typeof value === "undefined" && !setValue) {
89
- return _jsx(ServerFunctionsContext, {
90
- value: {
91
- ...adjustedServerFunctionContext
92
- },
93
- children: _jsx(FieldPathContext, {
94
- value: fieldPath,
95
- children: Component
96
- }, fieldPath)
97
- });
98
- }
99
- const fieldValue = {
100
- disabled: false,
101
- formInitializing: false,
102
- formProcessing: false,
103
- formSubmitted: false,
104
- initialValue: value,
105
- path: fieldPath,
106
- setValue: setValue ?? _temp,
107
- showError: false,
108
- value
109
- };
110
- return _jsx(ServerFunctionsContext, {
111
- value: {
112
- ...adjustedServerFunctionContext
113
- },
114
- children: _jsx(FieldPathContext, {
115
- value: fieldPath,
116
- children: _jsx(FieldContext, {
117
- value: fieldValue,
118
- children: Component
119
- })
120
- }, fieldPath)
121
- });
122
- };
123
- function _temp() {}
124
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["c","_c","FieldContext","FieldPathContext","ServerFunctionsContext","ShimmerEffect","useServerFunctions","React","useCallback","useEffect","useRef","RenderLexical","args","$","field","initialValue","Loading","path","schemaPath","setValue","value","Component","setComponent","useState","serverFunctionContext","_internal_renderField","entityType","entitySlug","split","fieldPath","name","t0","render","Field","undefined","renderLexical","mounted","t1","t2","current","_jsx","adjustedServerFunctionContext","getFormState","getFormStateArgs","collectionSlug","globalSlug","children","fieldValue","disabled","formInitializing","formProcessing","formSubmitted","_temp","showError"],"sources":["../../../src/field/RenderLexical/index.tsx"],"sourcesContent":["'use client'\nimport {\n FieldContext,\n FieldPathContext,\n type FieldType,\n type RenderFieldServerFnArgs,\n ServerFunctionsContext,\n type ServerFunctionsContextType,\n ShimmerEffect,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useRef } from 'react'\n\nimport type { DefaultTypedEditorState } from '../../nodeTypes.js'\n\n/**\n * Utility to render a lexical editor on the client.\n *\n * @experimental - may break in minor releases\n * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx\n */\nexport const RenderLexical: React.FC<\n /**\n * If value or setValue, or both, is provided, this component will manage its own value.\n * If neither is passed, it will rely on the parent form to manage the value.\n */\n {\n /**\n * Override the loading state while the field component is being fetched and rendered.\n */\n Loading?: React.ReactElement\n\n setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue']\n value?: FieldType<DefaultTypedEditorState | undefined>['value']\n } & RenderFieldServerFnArgs\n> = (args) => {\n const { field, initialValue, Loading, path, schemaPath, setValue, value } = args\n const [Component, setComponent] = React.useState<null | React.ReactNode>(null)\n const serverFunctionContext = useServerFunctions()\n const { _internal_renderField } = serverFunctionContext\n\n const [entityType, entitySlug] = schemaPath.split('.')\n\n const fieldPath = path ?? (field && 'name' in field ? field?.name : '') ?? ''\n\n const renderLexical = useCallback(() => {\n async function render() {\n const { Field } = await _internal_renderField({\n field,\n initialValue: initialValue ?? undefined,\n path,\n schemaPath,\n })\n\n setComponent(Field)\n }\n void render()\n }, [_internal_renderField, schemaPath, path, field, initialValue])\n\n const mounted = useRef(false)\n\n useEffect(() => {\n if (mounted.current) {\n return\n }\n mounted.current = true\n void renderLexical()\n }, [renderLexical])\n\n if (!Component) {\n return typeof Loading !== 'undefined' ? Loading : <ShimmerEffect />\n }\n\n /**\n * By default, the lexical will make form state requests (e.g. to get drawer fields), passing in the arguments\n * of the current field. However, we need to override those arguments to get it to make requests based on the\n * *target* field. The server only knows the schema map of the target field.\n */\n const adjustedServerFunctionContext: ServerFunctionsContextType = {\n ...serverFunctionContext,\n getFormState: async (getFormStateArgs) => {\n return serverFunctionContext.getFormState({\n ...getFormStateArgs,\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n })\n },\n }\n\n if (typeof value === 'undefined' && !setValue) {\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n {Component}\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n }\n\n const fieldValue: FieldType<DefaultTypedEditorState | undefined> = {\n disabled: false,\n formInitializing: false,\n formProcessing: false,\n formSubmitted: false,\n initialValue: value,\n path: fieldPath,\n setValue: setValue ?? (() => undefined),\n showError: false,\n value,\n }\n\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n <FieldContext value={fieldValue}>{Component}</FieldContext>\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n}\n"],"mappings":"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","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- import type { SerializedLexicalNode } from 'lexical';
2
- import type { DefaultTypedEditorState, TypedEditorState } from '../nodeTypes.js';
3
- export declare function buildEditorState(args: {
4
- nodes?: DefaultTypedEditorState['root']['children'];
5
- text?: string;
6
- }): DefaultTypedEditorState;
7
- export declare function buildEditorState<T extends SerializedLexicalNode>(args: {
8
- nodes?: TypedEditorState<T>['root']['children'];
9
- text?: string;
10
- }): TypedEditorState<T>;
11
- //# sourceMappingURL=buildEditorState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEhF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,KAAK,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IACnD,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,uBAAuB,CAAA;AAE3B,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE;IAEtE,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAA"}
@@ -1,76 +0,0 @@
1
- /**
2
- * Helper to build lexical editor state JSON from text and/or nodes.
3
- *
4
- * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.
5
- * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.
6
- * @returns The constructed editor state JSON.
7
- *
8
- * @example
9
- *
10
- * just passing text:
11
- *
12
- * ```ts
13
- * const editorState = buildEditorState({ text: 'Hello world' }) // result typed as DefaultTypedEditorState
14
- * ```
15
- *
16
- * @example
17
- *
18
- * passing nodes:
19
- *
20
- * ```ts
21
- * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)
22
- * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes
23
- * nodes: [
24
- * {
25
- * type: 'block',
26
- * fields: {
27
- * id: 'id',
28
- * blockName: 'Cool block',
29
- * blockType: 'myBlock',
30
- * },
31
- * format: 'left',
32
- * version: 1,
33
- * }
34
- * ],
35
- * })
36
- * ```
37
- */export function buildEditorState({
38
- nodes,
39
- text
40
- }) {
41
- const editorJSON = {
42
- root: {
43
- type: 'root',
44
- children: [],
45
- direction: 'ltr',
46
- format: '',
47
- indent: 0,
48
- version: 1
49
- }
50
- };
51
- if (text) {
52
- editorJSON.root.children.push({
53
- type: 'paragraph',
54
- children: [{
55
- type: 'text',
56
- detail: 0,
57
- format: 0,
58
- mode: 'normal',
59
- style: '',
60
- text,
61
- version: 1
62
- }],
63
- direction: 'ltr',
64
- format: '',
65
- indent: 0,
66
- textFormat: 0,
67
- textStyle: '',
68
- version: 1
69
- });
70
- }
71
- if (nodes?.length) {
72
- editorJSON.root.children.push(...nodes);
73
- }
74
- return editorJSON;
75
- }
76
- //# sourceMappingURL=buildEditorState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type { DefaultTypedEditorState, TypedEditorState } from '../nodeTypes.js'\n\nexport function buildEditorState(args: {\n nodes?: DefaultTypedEditorState['root']['children']\n text?: string\n}): DefaultTypedEditorState\n\nexport function buildEditorState<T extends SerializedLexicalNode>(args: {\n // If you pass children typed for a specific schema T, the return is TypedEditorState<T>\n nodes?: TypedEditorState<T>['root']['children']\n text?: string\n}): TypedEditorState<T>\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n */\nexport function buildEditorState<T extends SerializedLexicalNode>({\n nodes,\n text,\n}: {\n nodes?: DefaultTypedEditorState['root']['children'] | TypedEditorState<T>['root']['children']\n text?: string\n}): DefaultTypedEditorState | TypedEditorState<T> {\n const editorJSON: DefaultTypedEditorState = {\n root: {\n type: 'root',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n\n if (text) {\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [\n {\n type: 'text',\n detail: 0,\n format: 0,\n mode: 'normal',\n style: '',\n text,\n version: 1,\n },\n ],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n if (nodes?.length) {\n editorJSON.root.children.push(...(nodes as any))\n }\n\n return editorJSON\n}\n"],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCA,OAAO,SAASA,iBAAkD;EAChEC,KAAK;EACLC;AAAI,CAIL;EACC,MAAMC,UAAA,GAAsC;IAC1CC,IAAA,EAAM;MACJC,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;EACF;EAEA,IAAIR,IAAA,EAAM;IACRC,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,CACR;QACED,IAAA,EAAM;QACNO,MAAA,EAAQ;QACRJ,MAAA,EAAQ;QACRK,IAAA,EAAM;QACNC,KAAA,EAAO;QACPZ,IAAA;QACAQ,OAAA,EAAS;MACX,EACD;MACDH,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,IAAIT,KAAA,EAAOgB,MAAA,EAAQ;IACjBd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,IAAKV,KAAA;EACpC;EAEA,OAAOE,UAAA;AACT","ignoreList":[]}