@frontify/guideline-blocks-settings 3.0.0 → 3.0.1
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/components/Attachments/AttachmentItem.es.js +88 -92
- package/dist/components/Attachments/AttachmentItem.es.js.map +1 -1
- package/dist/components/Attachments/Attachments.es.js +91 -82
- package/dist/components/Attachments/Attachments.es.js.map +1 -1
- package/dist/index.cjs.js +7 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ export declare type AttachmentsProps = {
|
|
|
92
92
|
onReplaceWithBrowse: (attachmentToReplace: Asset, newAsset: Asset) => Promise<void>;
|
|
93
93
|
onDelete: (attachmentToDelete: Asset) => void;
|
|
94
94
|
onUpload: (uploadedAttachments: Asset[]) => Promise<void>;
|
|
95
|
-
onBrowse: (browserAttachments: Asset[]) => void
|
|
95
|
+
onBrowse: (browserAttachments: Asset[]) => void | Promise<void>;
|
|
96
96
|
onSorted: (sortedAttachments: Asset[]) => void;
|
|
97
97
|
triggerComponent?: React.ForwardRefExoticComponent<AttachmentsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
98
98
|
} & ({
|
package/dist/index.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(i,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@frontify/sidebar-settings"),require("react/jsx-runtime"),require("@frontify/fondue/rte"),require("@frontify/app-bridge"),require("react"),require("@dnd-kit/core"),require("@dnd-kit/modifiers"),require("@dnd-kit/sortable"),require("@frontify/fondue"),require("@frontify/fondue/components"),require("@frontify/fondue/icons"),require("@react-aria/focus"),require("react-dom"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","@frontify/sidebar-settings","react/jsx-runtime","@frontify/fondue/rte","@frontify/app-bridge","react","@dnd-kit/core","@dnd-kit/modifiers","@dnd-kit/sortable","@frontify/fondue","@frontify/fondue/components","@frontify/fondue/icons","@react-aria/focus","react-dom","@ctrl/tinycolor"],g):(i=typeof globalThis<"u"?globalThis:i||self,g(i.GuidelineBlocksSettings={},i.sidebarSettings,i.jsxRuntime,i.rte,i.appBridge,i.React,i.core,i.modifiers,i.sortable,i.fondue,i.components,i.icons,i.focus,i.ReactDOM,i.tinycolor))})(this,(function(i,g,o,a,G,h,z,xn,ht,tt,f,x,En,mt,H){"use strict";const V=t=>t.filter(Boolean).join(" "),In=({onDrop:t,label:e,icon:n,secondaryLabel:s,isLoading:r,fillParentContainer:l,onAssetChooseClick:c,onUploadClick:u,withMenu:d=!0,onClick:w,validFileType:y,verticalLayout:m})=>{const[p,C]=h.useState(!1),[v,P]=h.useState(),L=h.useRef(null),[A,D]=h.useState(void 0),W=T=>{if(T.preventDefault(),C(!1),!F(T.dataTransfer.files)){D("Invalid"),setTimeout(()=>{D(void 0)},1e3);return}t?.(T.dataTransfer.files)},F=T=>{if(!y)return!0;for(let O=0;O<T.length;O++){const Z=T[O].name.split(".").pop()??"";if(!G.FileExtensionSets[y].includes(Z))return!1}return!0},U=T=>{if(!L.current||r)return;const{clientX:O,clientY:Z}=T,gt=O===0&&Z===0,{left:Tt,top:te,width:ee,height:Pt}=L.current.getBoundingClientRect(),xt=gt?ee/2:O-Tt,q=gt?Pt/2:Z-te;P([xt,q])},N=h.useCallback(T=>{T(),P(void 0)},[]),Rt=h.useMemo(()=>{const T=[];return u&&T.push({onSelect:()=>N(u),title:"Upload asset",icon:o.jsx(x.IconArrowCircleUp,{size:"20"})}),c&&T.push({onSelect:()=>N(c),title:"Browse asset",icon:o.jsx(x.IconImageStack,{size:"20"})}),T},[c,u,N]);return o.jsxs("button",{type:"button",ref:L,"data-test-id":"block-inject-button",className:V(["tw-body-medium tw-relative tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",m?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",l?"tw-h-full":"tw-h-[72px]",p&&!r?"tw-border-dashed":"tw-border-solid",v&&"tw-bg-surface-hover",p&&"tw-bg-surface",A?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-line-mid",r||v||p||A?"":"tw-text-secondary hover:tw-text-primary hover:tw-bg-surface hover:tw-border-line-strong active:tw-text-primary active:tw-bg-surface-hover active:tw-border-line-strong",(p||v)&&!A?"[&>*]:tw-pointer-events-none tw-border-line-strong":"tw-bg-surface-dim tw-text-secondary"]),onDragEnter:t?T=>{if(C(!0),y==="Images")for(const O of Array.from(T.dataTransfer.items))O?.type?.startsWith("image/")?D(void 0):D("Invalid")}:void 0,onDragOver:t?T=>{T.preventDefault()}:void 0,onDragLeave:t?()=>{C(!1),D(void 0)}:void 0,onDrop:t?W:void 0,onClick:T=>{d&&!v&&U(T),w?.()},children:[r?o.jsx(f.LoadingCircle,{}):A?o.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[o.jsx(x.IconExclamationMarkTriangle,{size:"16"}),A]}):o.jsxs(o.Fragment,{children:[n&&o.jsx("div",{children:n}),(e||s)&&o.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[e&&o.jsx("div",{className:"tw-font-medium",children:e}),s&&o.jsx("div",{className:"tw-font-normal",children:s})]})]}),v&&o.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:v[0],top:v[1]},children:o.jsxs(f.Flyout.Root,{open:!0,onOpenChange:T=>!T&&P(void 0),children:[o.jsx(f.Flyout.Trigger,{children:o.jsx("div",{})}),o.jsx(f.Flyout.Content,{triggerOffset:"compact",children:o.jsxs(f.Dropdown.Root,{open:!0,children:[o.jsx(f.Dropdown.Trigger,{children:o.jsx("div",{})}),o.jsx(f.Dropdown.Content,{triggerOffset:"compact",children:Rt.map(T=>o.jsxs(f.Dropdown.Item,{onSelect:T.onSelect,children:[T.icon,T.title]},T.title))})]})})]})})]})},K=t=>{const e=s=>typeof s=="object"&&["red","green","blue"].every(l=>s.hasOwnProperty(l)),n=s=>{const r=typeof s.alpha=="number"?s.alpha:1;return{r:s.red,g:s.green,b:s.blue,a:r}};return e(t)?n(t):t},Sn=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Nn=(t,e)=>{const n=Sn(t)?K(t):t,s=new H.TinyColor(n);return e?s.getBrightness()<e:s.isDark()||s.getAlpha()>.25&&s.getAlpha()<1},Bn=t=>new H.TinyColor(K(t)).toHex8String(),Ln=t=>new H.TinyColor(K(t)).toHexString(),Et=t=>new H.TinyColor(K(t)).toRgbString(),An=(t,e)=>new H.TinyColor(e).setAlpha(t).toRgbString(),Dn=t=>{const{r:e,g:n,b:s,a:r}=new H.TinyColor(t);return{red:e,green:n,blue:s,alpha:r}},oe=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Mn=(t,e)=>{const n=oe(t)?K(t):t,s=oe(e)?K(e):e;let r=new H.TinyColor(n);const l=new H.TinyColor(s);for(;H.readability(r,l)<4.5;)r=r.darken(1);return r.toRgbString()},Fn=t=>({backgroundColor:Et(t)}),On={red:241,green:241,blue:241,alpha:1},ae={red:234,green:235,blue:235,alpha:1},_n="1px",dt="24px",ct="24px";var _=(t=>(t.Solid="Solid",t.Dashed="Dashed",t.Dotted="Dotted",t))(_||{});const se={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var $=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))($||{});const j={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var Y=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(Y||{});const et={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var Q=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(Q||{});const nt={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var X=(t=>(t.Global="Global",t.Custom="Custom",t))(X||{}),J=(t=>(t.Auto="Auto",t.S="S",t.M="M",t.L="L",t))(J||{});const re={Auto:"4px",S:"10px",M:"30px",L:"50px"},Un=(t=_.Solid,e="1px",n=ae)=>({borderStyle:se[t],borderWidth:e,borderColor:Et(n)}),Hn=(t,e=!1,n)=>({borderRadius:e?n:j[t]}),It=h.createContext(!1);It.displayName="DragPreviewContext";const ie=({children:t,isDragPreview:e})=>o.jsx(It.Provider,{value:e,children:t}),ot=()=>h.useContext(It),St=h.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});St.displayName="MultiFlyoutContext";const le=({children:t,openFlyoutIds:e,setOpenFlyoutIds:n})=>{const s=h.useMemo(()=>({openFlyoutIds:e,setOpenFlyoutIds:n}),[e,n]);return o.jsx(St.Provider,{value:s,children:t})},de=()=>h.useContext(St),ft=t=>{const{openFlyoutIds:e,setOpenFlyoutIds:n}=de(),s=h.useCallback(r=>{n(l=>{const c=l.filter(u=>u!==t);return r?[...c,t]:c})},[t,n]);return{isOpen:e.includes(t),onOpenChange:s}},Nt=(t,e)=>{const{blockAssets:n,addAssetIdsToKey:s,deleteAssetIdsFromKey:r,updateAssetIdsFromKey:l}=e,c=n?.[t]||[];return{onAttachmentsAdd:async m=>{await s(t,m.map(p=>p.id))},onAttachmentDelete:async m=>{await r(t,[m.id])},onAttachmentReplace:async(m,p)=>{const C=c.map(v=>v.id===m.id?p.id:v.id);await l(t,C)},onAttachmentsSorted:async m=>{const p=m.map(C=>C.id);await l(t,p)},attachments:c}},ce=(t,e)=>{const{onAttachmentsAdd:n,onAttachmentDelete:s,onAttachmentReplace:r,onAttachmentsSorted:l,attachments:c}=Nt(e,G.useBlockAssets(t));return{onAttachmentsAdd:n,onAttachmentDelete:s,onAttachmentReplace:r,onAttachmentsSorted:l,attachments:c,appBridge:t}},pt=h.createContext(null);pt.displayName="AttachmentsContext";const ue=({appBridge:t,children:e,assetId:n})=>{const s=ce(t,n);return o.jsx(pt.Provider,{value:s,children:e})},zn=({blockAssetBundle:t,appBridge:e,children:n,assetId:s})=>{const r=Nt(s,t);return o.jsx(pt.Provider,{value:{...r,appBridge:e},children:n})},ge=()=>{const t=h.useContext(pt);if(!t)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return t},Vn=(t,e)=>{const n=s=>o.jsx(ue,{appBridge:s.appBridge,assetId:e,children:o.jsx(t,{...s})});return n.displayName="withAttachmentsProvider",n},$n=t=>t==="IMAGE"?o.jsx(x.IconImage,{size:"24"}):t==="VIDEO"?o.jsx(x.IconPlayFrame,{size:"24"}):t==="AUDIO"?o.jsx(x.IconMusicNote,{size:"24"}):o.jsx(x.IconDocument,{size:"24"}),he=h.forwardRef(({item:t,isEditing:e,draggableProps:n,transformStyle:s,isDragging:r,isOverlay:l,isLoading:c,onDelete:u,onReplaceWithBrowse:d,onReplaceWithUpload:w,onDownload:y},m)=>{const[p,C]=h.useState(),[v,{selectedFiles:P}]=G.useFileInput({multiple:!0,accept:"image/*"}),[L,{results:A,doneAll:D}]=G.useAssetUpload(),{focusProps:W,isFocusVisible:F}=En.useFocusRing();h.useEffect(()=>{P&&L(P[0])},[P]),h.useEffect(()=>{D&&w(A[0])},[D,A]);const U=c||P&&!D;return o.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!p&&y?.(),ref:m,style:{...s,opacity:r&&!l?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:V(["tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-container-secondary-hover -tw-outline-offset-1",r?"tw-bg-container-secondary-hover":""]),children:[o.jsx("div",{className:"tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:U?o.jsx(f.LoadingCircle,{size:"small"}):$n(t.objectType)}),o.jsxs("div",{className:"tw-text-small tw-flex-1 tw-min-w-0",children:[o.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:t.title}),o.jsx("div",{className:"tw-text-secondary",children:`${t.fileSizeHumanReadable} - ${t.extension}`})]}),e&&o.jsxs("div",{"data-test-id":"attachments-actionbar",className:V(["tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",l||p?.id===t.id?"tw-opacity-100":"tw-opacity-0"]),children:[o.jsx("button",{type:"button",...W,...n,"aria-label":"Drag attachment",className:V([" tw-border-primary tw-bg-container-secondary active:tw-bg-container-secondary-active tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded-medium tw-h-9 tw-w-9 ",r||l?"tw-cursor-grabbing tw-bg-container-secondary-active hover:tw-bg-container-secondary-active":"tw-cursor-grab hover:tw-bg-container-secondary-hover",F&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none",F&&"tw-z-[2]"]),children:o.jsx(x.IconGrabHandle,{})}),o.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:o.jsxs(f.Dropdown.Root,{open:p?.id===t.id,onOpenChange:N=>C(N?t:void 0),children:[o.jsx(f.Dropdown.Trigger,{children:o.jsx(f.Button,{aspect:"square",ref:m,onPress:N=>{N?.stopPropagation(),N?.preventDefault()},emphasis:"default",children:o.jsx(x.IconPen,{size:"20"})})}),o.jsxs(f.Dropdown.Content,{side:"right",children:[o.jsxs(f.Dropdown.Group,{children:[o.jsxs(f.Dropdown.Item,{"data-test-id":"menu-item",onSelect:N=>{N?.stopPropagation(),v(),C(void 0)},children:[o.jsx(x.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),o.jsxs(f.Dropdown.Item,{onSelect:N=>{N?.stopPropagation(),d(),C(void 0)},children:[o.jsx(x.IconImageStack,{size:"20"}),"Replace with asset"]})]}),o.jsx(f.Dropdown.Group,{children:o.jsxs(f.Dropdown.Item,{emphasis:"danger",onSelect:N=>{N?.stopPropagation(),u(),C(void 0)},children:[o.jsx(x.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});he.displayName="AttachmentItem";const Wn=t=>{const{attributes:e,listeners:n,setNodeRef:s,transform:r,transition:l,isDragging:c}=ht.useSortable({id:t.item.id}),u={transform:r?`translate(${r.x}px, ${r.y}px)`:"",transition:l,zIndex:c?2:1},d={...e,...n};return o.jsx(he,{ref:s,isDragging:c,transformStyle:u,draggableProps:d,...t})},me=h.forwardRef(({children:t,...e},n)=>o.jsxs(f.Button,{ref:n,size:"small",rounding:"full",emphasis:"default","data-test-id":"attachments-button-trigger",className:"tw-body-medium",...e,children:[o.jsx(x.IconPaperclip,{size:"16"}),t,o.jsx(x.IconCaretDown,{size:"12"})]}));me.displayName="AttachmentsButtonTrigger";const fe=({items:t=[],onDelete:e,onReplaceWithBrowse:n,onReplaceWithUpload:s,onBrowse:r,onUpload:l,onSorted:c,appBridge:u,triggerComponent:d=me,isOpen:w,onOpenChange:y})=>{const[m,p]=h.useState(t),[C,v]=h.useState(!1),P=z.useSensors(z.useSensor(z.PointerSensor),z.useSensor(z.KeyboardSensor)),[L,A]=h.useState(void 0),[D,W]=h.useState(!1),[F,U]=h.useState([]),[N,Rt]=h.useState(null),T=G.useEditorState(u),{openAssetChooser:O,closeAssetChooser:Z}=G.useAssetChooser(u),gt=w!==void 0,Tt=gt?w:C,te=m?.find(k=>k.id===L),[ee,{results:Pt,doneAll:xt}]=G.useAssetUpload({onUploadProgress:()=>!D&&W(!0)}),q=k=>{(gt?y:v)?.(k)};h.useEffect(()=>{p(t)},[t]),h.useEffect(()=>{N&&(W(!0),ee(N))},[N]),h.useEffect(()=>{(async()=>xt&&(await l(Pt),W(!1)))()},[xt,Pt]);const Fa=()=>{q(!1),O(k=>{r(k),Z(),q(!0)},{multiSelection:!0,selectedValueIds:m.map(k=>k.id)})},Oa=k=>{q(!1),O(async M=>{q(!0),Z(),U([...F,k.id]),await n(k,M[0]),U(F.filter(R=>R!==k.id))},{multiSelection:!1,selectedValueIds:m.map(M=>M.id)})},_a=async(k,M)=>{U([...F,k.id]),await s(k,M),U(F.filter(R=>R!==k.id))},Ua=k=>{const{active:M}=k;A(M.id)},Ha=k=>{const{active:M,over:R}=k;if(R&&M.id!==R.id&&m){const Va=m.findIndex(ne=>ne.id===M.id),$a=m.findIndex(ne=>ne.id===R.id),Pn=ht.arrayMove(m,Va,$a);p(Pn),c(Pn)}A(void 0)},za={onEscapeKeyDown:k=>{k.stopPropagation(),q(!1)}};return T||(m?.length??0)>0?o.jsx("div",{"data-test-id":"attachments-flyout-button",children:o.jsx(f.Flyout.Root,{open:Tt,onOpenChange:k=>q(te?!0:k),children:o.jsxs(f.Tooltip.Root,{enterDelay:500,children:[o.jsx(f.Tooltip.Trigger,{asChild:!0,children:o.jsx(f.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:o.jsx(d,{isFlyoutOpen:Tt,children:o.jsx("div",{children:t.length>0?t.length:"Add"})})})}),o.jsx(f.Flyout.Content,{side:"bottom",align:"end",...za,children:o.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[m.length>0&&o.jsx(z.DndContext,{sensors:P,collisionDetection:z.closestCenter,onDragStart:Ua,onDragEnd:Ha,modifiers:[xn.restrictToVerticalAxis],children:o.jsx(ht.SortableContext,{items:m,strategy:ht.rectSortingStrategy,children:o.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:m.map(k=>o.jsx(Wn,{isEditing:T,isLoading:F.includes(k.id),item:k,onDelete:()=>e(k),onReplaceWithBrowse:()=>Oa(k),onReplaceWithUpload:M=>_a(k,M),onDownload:()=>u.dispatch({name:"downloadAsset",payload:k})},k.id))})})}),T&&o.jsxs("div",{className:"tw-px-5 tw-py-3",children:[o.jsx("div",{className:"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4",children:"Add attachments"}),o.jsx(tt.AssetInput,{isLoading:D,size:tt.AssetInputSize.Small,onUploadClick:k=>Rt(k),onLibraryClick:Fa})]})]})}),o.jsx(f.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},qn=(t,e)=>{const n=[tt.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded-medium","tw-body-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-container-secondary-active","tw-text-container-secondary-on-secondary-container",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active","tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),V(n)},at=h.forwardRef(({onClick:t,children:e,forceActiveStyle:n,cursor:s="pointer","data-test-id":r="base-toolbar-button",...l},c)=>o.jsx("button",{onClick:t,className:qn(s,n),"data-test-id":r,...l,ref:c,children:e}));at.displayName="BaseToolbarButton";const pe=h.forwardRef(({children:t,isFlyoutOpen:e,...n},s)=>o.jsxs(at,{forceActiveStyle:e,"data-test-id":"attachments-toolbar-button-trigger",ref:s,...n,children:[o.jsx(x.IconPaperclip,{size:"16"}),t,o.jsx(x.IconCaretDown,{size:"12"})]}));pe.displayName="AttachmentsToolbarButtonTrigger";const we="attachments",ye=({flyoutId:t=we})=>{const{appBridge:e,attachments:n,onAttachmentsAdd:s,onAttachmentDelete:r,onAttachmentReplace:l,onAttachmentsSorted:c}=ge(),{isOpen:u,onOpenChange:d}=ft(t),w=ot();return o.jsx(fe,{onUpload:s,onDelete:r,onReplaceWithBrowse:l,onReplaceWithUpload:l,onSorted:c,onBrowse:s,items:n,appBridge:e,triggerComponent:pe,isOpen:u&&!w,onOpenChange:d})},be="Drag or press ↵ to move",ve="Move with ↑↓←→ and confirm with ↵",Bt=({content:t,children:e,open:n,disabled:s})=>s?e:o.jsxs(f.Tooltip.Root,{enterDelay:300,open:n,children:[o.jsx(f.Tooltip.Trigger,{asChild:!0,children:e}),o.jsx(f.Tooltip.Content,{side:"top",children:o.jsx("div",{children:t})})]}),Ce=({tooltip:t,icon:e,setActivatorNodeRef:n,draggableProps:s})=>{const r=ot(),{activatorEvent:l}=z.useDndContext(),c=l instanceof KeyboardEvent;return o.jsx(Bt,{...r&&{open:c},content:o.jsx("div",{children:r?ve:t??be}),children:o.jsx(at,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:r,cursor:"grab",...s,children:e})})},ke=({content:t,icon:e,tooltip:n,flyoutId:s,flyoutFooter:r,flyoutHeader:l})=>{const{isOpen:c,onOpenChange:u}=ft(s),d=ot();return o.jsx(Bt,{disabled:d||c,content:n,children:o.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:o.jsxs(f.Flyout.Root,{open:c&&!d,onOpenChange:u,children:[o.jsx(f.Flyout.Trigger,{asChild:!0,children:o.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:c&&!d,children:e})}),o.jsxs(f.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[l?o.jsx(f.Flyout.Header,{children:l}):null,o.jsx(f.Flyout.Body,{children:t}),r?o.jsx(f.Flyout.Footer,{children:r}):null]})]})})})},Lt="menu",Te=({items:t,flyoutId:e=Lt,tooltip:n="Options"})=>{const{isOpen:s,onOpenChange:r}=ft(e),l=ot();return o.jsx(f.Dropdown.Root,{open:s&&!l,onOpenChange:r,children:o.jsxs(f.Tooltip.Root,{children:[o.jsx(f.Tooltip.Trigger,{asChild:!0,children:o.jsx(f.Dropdown.Trigger,{asChild:!0,children:o.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:o.jsx(x.IconDotsHorizontal,{size:"16"})})})}),o.jsx(f.Dropdown.Content,{children:t.map((c,u)=>o.jsx(f.Dropdown.Group,{children:c.map((d,w)=>o.jsxs(f.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{r(!1),d.onClick()},emphasis:d.style||"default",children:[o.jsx("div",{className:"tw-mr-2",children:d.icon}),o.jsx("span",{children:d.title})]},`${u}-${w}`))},u))}),o.jsx(f.Tooltip.Content,{children:n})]})})},Gn=({tooltip:t,icon:e,onClick:n})=>{const s=ot();return o.jsx(Bt,{disabled:s,content:t??"",children:o.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:e})})},Pe=({children:t})=>o.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-segment",className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:t}),xe=({items:t,attachments:e})=>o.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[e.isEnabled&&o.jsx(Pe,{children:o.jsx(ye,{})}),t.length>0&&o.jsx(Pe,{children:t.map(n=>{switch(n.type){case"dragHandle":return o.jsx(Ce,{...n},n.tooltip+n.type);case"menu":return o.jsx(Te,{...n},n.tooltip+n.type);case"flyout":return o.jsx(ke,{...n},n.tooltip+n.type);default:return o.jsx(Gn,{...n},n.tooltip+n.type)}})})]}),Ee=h.memo(({children:t,toolbarItems:e,shouldHideWrapper:n,shouldHideComponent:s=!1,isDragging:r=!1,shouldFillContainer:l,outlineOffset:c=0,shouldBeShown:u=!1,showAttachments:d=!1})=>{const[w,y]=h.useState(u?[Lt]:[]),m=h.useRef(null);if(n)return o.jsx(o.Fragment,{children:t});const p=e?.filter(v=>v!==void 0),C=w.length>0||u;return o.jsx(ie,{isDragPreview:r,children:o.jsx(le,{openFlyoutIds:w,setOpenFlyoutIds:y,children:o.jsxs("div",{ref:m,"data-test-id":"block-item-wrapper",style:{outlineOffset:c},className:V(["tw-relative tw-group",l&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container",C&&"tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container",s&&"tw-opacity-0"]),children:[o.jsx("div",{style:{right:-1-c,bottom:`calc(100% - ${2+c}px)`},className:V(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",C&&"tw-opacity-100"]),children:o.jsx(xe,{attachments:{isEnabled:d},items:p})}),t]})})})});Ee.displayName="BlockItemWrapper";const Kn=({ref:t,disabled:e,onChange:n})=>{h.useEffect(()=>{if(e||!t.current)return;let s=!1;const r=new IntersectionObserver(([l])=>{l.isIntersecting!==s&&(s=l.isIntersecting,n(l.isIntersecting))});return r.observe(t.current),()=>{r.disconnect()}},[t,e,n])},jn=({value:t="",gap:e,customClass:n,show:s=!0,plugins:r})=>{const[l,c]=h.useState(null);return h.useEffect(()=>{(async()=>{const d=await a.serializeRawToHtmlAsync(t,r,void 0,e,n);c(d)})().catch(console.error)},[t,e,r,n]),!s||l==="<br />"||l===null?null:o.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:l}})},At=a.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(t=>({reset:()=>{t.url(""),t.text(""),t.buttonStyle("primary"),t.newTab(!1),t.mode(""),t.isEditing(!1)}})).extendActions(t=>({show:(e,n)=>{t.mode(e),t.isEditing(!1),t.openEditorId(n)},hide:()=>{t.reset(),t.openEditorId(null)}})).extendSelectors(t=>({isOpen:e=>t.openEditorId===e})),S=At.set,B=At.get,ut=()=>At.use,Ie=t=>{if(!t)return!1;const e=n=>n.some(s=>s.text?s.text!=="":s.children?e(s.children):!1);try{const n=JSON.parse(t);return e(n)}catch{return!1}},Yn=(t="p",e="",n)=>Ie(e)?e:JSON.stringify([{type:t,children:[{text:e,textStyle:t}],align:n}]),Qn=(t,e,n)=>t===X.Custom?e:n,Dt=(t,e)=>{const n=a.getAboveNode(t,{match:{type:a.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},Xn=t=>Dt(t,e=>e.chosenLink?.searchResult?.link||""),Jn=t=>Dt(t,e=>e.url||""),Mt=t=>t.url||t.chosenLink?.searchResult?.link||"",Zn=t=>Dt(t,Mt),Ft=/^\/(document|r)\/\S+$/i,wt=t=>{if(Ft.test(t))return t;try{return new URL(t),t}catch{return`https://${t}`}},yt=t=>{if(Ft.test(t))return!0;try{const e=new URL(t);return["http:","https:","mailto:","tel:"].includes(e.protocol)&&e.pathname!==""}catch{return!1}},st=t=>yt(wt(t))||t==="",Se=(t,{type:e})=>{const{apply:n,normalizeNode:s}=t;return t.apply=r=>{if(r.type!=="set_selection"){n(r);return}const l=r.newProperties;if(!l?.focus||!l.anchor||!a.isCollapsed(l)){n(r);return}const c=a.getAboveNode(t,{at:l,match:{type:a.getPluginType(t,E)}});if(c){const[,u]=c;let d;a.isStartPoint(t,l.focus,u)&&(d=a.getPreviousNodeEndPoint(t,u)),a.isEndPoint(t,l.focus,u)&&(d=a.getNextNodeStartPoint(t,u)),d&&(r.newProperties={anchor:d,focus:d})}n(r)},t.normalizeNode=([r,l])=>{if(r.type===a.getPluginType(t,E)){const c=t.selection;if(c&&a.isCollapsed(c)&&a.isEndPoint(t,c.focus,l)){const u=a.getNextNodeStartPoint(t,l);if(u)a.select(t,u);else{const d=a.Path.next(l);a.insertNodes(t,{text:""},{at:d}),a.select(t,d)}}}s([r,l])},a.withRemoveEmptyNodes(t,a.mockPlugin({options:{types:e}}))},Ne=(t,e,n)=>{a.insertNodes(t,[De(t,e)],n)},Ot=t=>{if(!t.selection)return;const{isUrl:e,forceSubmit:n}=a.getPluginOptions(t,E),s=B.url();if(!(e?.(s)||n))return;const l=B.text(),c=B.buttonStyle(),u=B.newTab()?void 0:"_self";return S.reset(),Be(t,{url:s,text:l,buttonStyle:c,target:u,isUrl:d=>n||!e?!0:e(d)}),setTimeout(()=>{a.focusEditor(t,t.selection??void 0)},0),!0},rt=(t,e)=>a.withoutNormalizing(t,()=>{if(e?.split){if(a.getAboveNode(t,{at:t.selection?.anchor,match:{type:a.getPluginType(t,E)}}))return a.splitNodes(t,{at:t.selection?.anchor,match:r=>a.isElement(r)&&r.type===a.getPluginType(t,E)}),rt(t,{at:t.selection?.anchor}),!0;if(a.getAboveNode(t,{at:t.selection?.focus,match:{type:a.getPluginType(t,E)}}))return a.splitNodes(t,{at:t.selection?.focus,match:r=>a.isElement(r)&&r.type===a.getPluginType(t,E)}),rt(t,{at:t.selection?.focus}),!0}a.unwrapNodes(t,{match:{type:a.getPluginType(t,E)},...e})}),Be=(t,{url:e,text:n,buttonStyle:s,target:r,insertTextInButton:l,insertNodesOptions:c,isUrl:u=a.getPluginOptions(t,E).isUrl})=>{const d=t.selection;if(!d)return;const w=a.getAboveNode(t,{at:d,match:{type:a.getPluginType(t,E)}});if(l&&w)return t.insertText(e),!0;if(!u?.(e))return;if(a.isDefined(n)&&n.length===0&&(n=e),w)return eo(e,t,w,r,s,n),!0;const y=a.findNode(t,{at:d,match:{type:a.getPluginType(t,E)}}),[m,p]=y??[],C=Rn(t,p,n);if(a.isExpanded(d))return to(w,t,e,s,r,n),!0;C&&a.removeNodes(t,{at:p});const v=a.getNodeProps(m??{}),P=t.selection?.focus.path;if(!P)return;const L=a.getNodeLeaf(t,P);return n?.length||(n=e),Ne(t,{...v,url:e,target:r,children:[{...L,text:n}]},c),!0};function Rn(t,e,n){return e&&n?.length&&n!==a.getEditorString(t,e)}function to(t,e,n,s,r,l){t?rt(e,{at:t[1]}):rt(e,{split:!0}),Le(e,{url:n,buttonStyle:s,target:r}),_t(e,{text:l})}function eo(t,e,n,s,r,l){(t!==n[0]?.url||s!==n[0]?.target||r!==n[0]?.buttonStyle)&&a.setNodes(e,{url:t,target:s,buttonStyle:r},{at:n[1]}),_t(e,{text:l})}const _t=(t,{text:e})=>{const n=a.getAboveNode(t,{match:{type:a.getPluginType(t,E)}});if(n){const[s,r]=n;if(e?.length&&e!==a.getEditorString(t,r)){const l=s.children[0];a.replaceNodeChildren(t,{at:r,nodes:{...l,text:e},insertOptions:{select:!0}})}}},Le=(t,{url:e,buttonStyle:n,target:s,...r})=>{a.wrapNodes(t,{type:a.getPluginType(t,E),url:e,buttonStyle:n,target:s,children:[]},{split:!0,...r})},no=(t,e)=>{const n=a.getAboveNode(t,{match:{type:E}});return Array.isArray(n)?e(n[0]):""},Ae=t=>no(t,e=>e.url??""),De=(t,{url:e,text:n="",buttonStyle:s="primary",target:r,children:l})=>({type:a.getPluginType(t,E),url:e,target:r,buttonStyle:s,children:l??[{text:n}]}),Me=(t,{focused:e}={})=>{if(B.mode()==="edit"){bt(t);return}Ut(t,{focused:e})},bt=t=>{const e=a.findNode(t,{match:{type:a.getPluginType(t,E)}});if(!e)return;const[n,s]=e;let r=a.getEditorString(t,s);S.url(n.url),S.newTab(n.target===void 0),r===n.url&&(r=""),S.text(r),S.isEditing(!0)},Ut=(t,{focused:e}={})=>{B.mode()||!e||a.isRangeAcrossBlocks(t,{at:t.selection})||a.someNode(t,{match:{type:a.getPluginType(t,E)}})||(S.text(a.getEditorString(t,t.selection)),S.show("insert",t.id))},Ht={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},vt={buttonPrimary:{...Ht,fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{...Ht,fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{...Ht,fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},oo=t=>{const{attributes:e,children:n}=t,s=t.element.url||t.element.chosenLink?.searchResult?.link||"",r=t.element.target||"_self",l=String(t.element.buttonStyle)||"primary";return o.jsx(ao,{attributes:e,href:s,target:r,styles:vt[`button${l.charAt(0).toUpperCase()+l.slice(1)}`],children:n})},ao=({attributes:t,styles:e={hover:{}},children:n,href:s="#",target:r})=>{const[l,c]=h.useState(!1);return o.jsx("a",{...t,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:s,target:r,style:l?{...e,...e.hover}:e,children:n})};class so extends a.MarkupElement{constructor(e=E,n=oo){super(e,n)}}const Fe=h.forwardRef((t,e)=>{const n=a.useEditorRef();return o.jsx(a.ToolbarButton,{ref:e,...t,onMouseDown:s=>{s.preventDefault(),a.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{Me(n,{focused:!0})},children:o.jsx(a.IconStylingWrapper,{icon:o.jsx(x.IconButton,{size:16})})})});Fe.displayName="ButtonToolbarButton";const ro=({editorId:t,id:e})=>{const n=a.useEditorState(a.useEventPlateId(t)),s=!!a.isRangeInSameBlock(n,{at:n.selection}),r=a.getPluginType(n,E),l=!!n?.selection&&a.someNode(n,{match:{type:r}});return o.jsx("div",{"data-plugin-id":e,children:o.jsx(Fe,{pressed:l,disabled:!s,tooltip:a.getTooltip(s?`Button
|
|
2
|
-
${a.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},
|
|
1
|
+
(function(i,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@frontify/sidebar-settings"),require("react/jsx-runtime"),require("@frontify/fondue/rte"),require("@frontify/app-bridge"),require("react"),require("@dnd-kit/core"),require("@dnd-kit/modifiers"),require("@dnd-kit/sortable"),require("@frontify/fondue/components"),require("@frontify/fondue/icons"),require("@frontify/fondue"),require("react-dom"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","@frontify/sidebar-settings","react/jsx-runtime","@frontify/fondue/rte","@frontify/app-bridge","react","@dnd-kit/core","@dnd-kit/modifiers","@dnd-kit/sortable","@frontify/fondue/components","@frontify/fondue/icons","@frontify/fondue","react-dom","@ctrl/tinycolor"],h):(i=typeof globalThis<"u"?globalThis:i||self,h(i.GuidelineBlocksSettings={},i.sidebarSettings,i.jsxRuntime,i.rte,i.appBridge,i.React,i.core,i.modifiers,i.sortable,i.components,i.icons,i.fondue,i.ReactDOM,i.tinycolor))})(this,(function(i,h,o,a,q,g,H,En,ht,m,P,mt,ft,_){"use strict";const z=t=>t.filter(Boolean).join(" "),Sn=({onDrop:t,label:e,icon:n,secondaryLabel:s,isLoading:r,fillParentContainer:l,onAssetChooseClick:c,onUploadClick:u,withMenu:d=!0,onClick:w,validFileType:y,verticalLayout:f})=>{const[p,C]=g.useState(!1),[v,x]=g.useState(),A=g.useRef(null),[L,D]=g.useState(void 0),$=T=>{if(T.preventDefault(),C(!1),!N(T.dataTransfer.files)){D("Invalid"),setTimeout(()=>{D(void 0)},1e3);return}t?.(T.dataTransfer.files)},N=T=>{if(!y)return!0;for(let O=0;O<T.length;O++){const W=T[O].name.split(".").pop()??"";if(!q.FileExtensionSets[y].includes(W))return!1}return!0},rt=T=>{if(!A.current||r)return;const{clientX:O,clientY:W}=T,gt=O===0&&W===0,{left:Pt,top:xt,width:It,height:ee}=A.current.getBoundingClientRect(),ne=gt?It/2:O-Pt,Et=gt?ee/2:W-xt;x([ne,Et])},U=g.useCallback(T=>{T(),x(void 0)},[]),it=g.useMemo(()=>{const T=[];return u&&T.push({onSelect:()=>U(u),title:"Upload asset",icon:o.jsx(P.IconArrowCircleUp,{size:"20"})}),c&&T.push({onSelect:()=>U(c),title:"Browse asset",icon:o.jsx(P.IconImageStack,{size:"20"})}),T},[c,u,U]);return o.jsxs("button",{type:"button",ref:A,"data-test-id":"block-inject-button",className:z(["tw-body-medium tw-relative tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",f?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",l?"tw-h-full":"tw-h-[72px]",p&&!r?"tw-border-dashed":"tw-border-solid",v&&"tw-bg-surface-hover",p&&"tw-bg-surface",L?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-line-mid",r||v||p||L?"":"tw-text-secondary hover:tw-text-primary hover:tw-bg-surface hover:tw-border-line-strong active:tw-text-primary active:tw-bg-surface-hover active:tw-border-line-strong",(p||v)&&!L?"[&>*]:tw-pointer-events-none tw-border-line-strong":"tw-bg-surface-dim tw-text-secondary"]),onDragEnter:t?T=>{if(C(!0),y==="Images")for(const O of Array.from(T.dataTransfer.items))O?.type?.startsWith("image/")?D(void 0):D("Invalid")}:void 0,onDragOver:t?T=>{T.preventDefault()}:void 0,onDragLeave:t?()=>{C(!1),D(void 0)}:void 0,onDrop:t?$:void 0,onClick:T=>{d&&!v&&rt(T),w?.()},children:[r?o.jsx(m.LoadingCircle,{}):L?o.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[o.jsx(P.IconExclamationMarkTriangle,{size:"16"}),L]}):o.jsxs(o.Fragment,{children:[n&&o.jsx("div",{children:n}),(e||s)&&o.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[e&&o.jsx("div",{className:"tw-font-medium",children:e}),s&&o.jsx("div",{className:"tw-font-normal",children:s})]})]}),v&&o.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:v[0],top:v[1]},children:o.jsxs(m.Flyout.Root,{open:!0,onOpenChange:T=>!T&&x(void 0),children:[o.jsx(m.Flyout.Trigger,{children:o.jsx("div",{})}),o.jsx(m.Flyout.Content,{triggerOffset:"compact",children:o.jsxs(m.Dropdown.Root,{open:!0,children:[o.jsx(m.Dropdown.Trigger,{children:o.jsx("div",{})}),o.jsx(m.Dropdown.Content,{triggerOffset:"compact",children:it.map(T=>o.jsxs(m.Dropdown.Item,{onSelect:T.onSelect,children:[T.icon,T.title]},T.title))})]})})]})})]})},G=t=>{const e=s=>typeof s=="object"&&["red","green","blue"].every(l=>s.hasOwnProperty(l)),n=s=>{const r=typeof s.alpha=="number"?s.alpha:1;return{r:s.red,g:s.green,b:s.blue,a:r}};return e(t)?n(t):t},Bn=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Nn=(t,e)=>{const n=Bn(t)?G(t):t,s=new _.TinyColor(n);return e?s.getBrightness()<e:s.isDark()||s.getAlpha()>.25&&s.getAlpha()<1},An=t=>new _.TinyColor(G(t)).toHex8String(),Ln=t=>new _.TinyColor(G(t)).toHexString(),St=t=>new _.TinyColor(G(t)).toRgbString(),Dn=(t,e)=>new _.TinyColor(e).setAlpha(t).toRgbString(),Mn=t=>{const{r:e,g:n,b:s,a:r}=new _.TinyColor(t);return{red:e,green:n,blue:s,alpha:r}},ae=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Fn=(t,e)=>{const n=ae(t)?G(t):t,s=ae(e)?G(e):e;let r=new _.TinyColor(n);const l=new _.TinyColor(s);for(;_.readability(r,l)<4.5;)r=r.darken(1);return r.toRgbString()},On=t=>({backgroundColor:St(t)}),_n={red:241,green:241,blue:241,alpha:1},se={red:234,green:235,blue:235,alpha:1},Un="1px",dt="24px",ct="24px";var F=(t=>(t.Solid="Solid",t.Dashed="Dashed",t.Dotted="Dotted",t))(F||{});const re={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var V=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(V||{});const K={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var j=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(j||{});const Z={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var Y=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(Y||{});const R={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var Q=(t=>(t.Global="Global",t.Custom="Custom",t))(Q||{}),X=(t=>(t.Auto="Auto",t.S="S",t.M="M",t.L="L",t))(X||{});const ie={Auto:"4px",S:"10px",M:"30px",L:"50px"},Hn=(t=F.Solid,e="1px",n=se)=>({borderStyle:re[t],borderWidth:e,borderColor:St(n)}),zn=(t,e=!1,n)=>({borderRadius:e?n:K[t]}),Bt=g.createContext(!1);Bt.displayName="DragPreviewContext";const le=({children:t,isDragPreview:e})=>o.jsx(Bt.Provider,{value:e,children:t}),tt=()=>g.useContext(Bt),Nt=g.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Nt.displayName="MultiFlyoutContext";const de=({children:t,openFlyoutIds:e,setOpenFlyoutIds:n})=>{const s=g.useMemo(()=>({openFlyoutIds:e,setOpenFlyoutIds:n}),[e,n]);return o.jsx(Nt.Provider,{value:s,children:t})},ce=()=>g.useContext(Nt),pt=t=>{const{openFlyoutIds:e,setOpenFlyoutIds:n}=ce(),s=g.useCallback(r=>{n(l=>{const c=l.filter(u=>u!==t);return r?[...c,t]:c})},[t,n]);return{isOpen:e.includes(t),onOpenChange:s}},At=(t,e)=>{const{blockAssets:n,addAssetIdsToKey:s,deleteAssetIdsFromKey:r,updateAssetIdsFromKey:l}=e,c=n?.[t]||[];return{onAttachmentsAdd:async f=>{await s(t,f.map(p=>p.id))},onAttachmentDelete:async f=>{await r(t,[f.id])},onAttachmentReplace:async(f,p)=>{const C=c.map(v=>v.id===f.id?p.id:v.id);await l(t,C)},onAttachmentsSorted:async f=>{const p=f.map(C=>C.id);await l(t,p)},attachments:c}},ue=(t,e)=>{const{onAttachmentsAdd:n,onAttachmentDelete:s,onAttachmentReplace:r,onAttachmentsSorted:l,attachments:c}=At(e,q.useBlockAssets(t));return{onAttachmentsAdd:n,onAttachmentDelete:s,onAttachmentReplace:r,onAttachmentsSorted:l,attachments:c,appBridge:t}},wt=g.createContext(null);wt.displayName="AttachmentsContext";const ge=({appBridge:t,children:e,assetId:n})=>{const s=ue(t,n);return o.jsx(wt.Provider,{value:s,children:e})},Vn=({blockAssetBundle:t,appBridge:e,children:n,assetId:s})=>{const r=At(s,t);return o.jsx(wt.Provider,{value:{...r,appBridge:e},children:n})},he=()=>{const t=g.useContext(wt);if(!t)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return t},$n=(t,e)=>{const n=s=>o.jsx(ge,{appBridge:s.appBridge,assetId:e,children:o.jsx(t,{...s})});return n.displayName="withAttachmentsProvider",n},Wn=t=>t==="IMAGE"?o.jsx(P.IconImage,{size:"24"}):t==="VIDEO"?o.jsx(P.IconPlayFrame,{size:"24"}):t==="AUDIO"?o.jsx(P.IconMusicNote,{size:"24"}):o.jsx(P.IconDocument,{size:"24"}),me=g.forwardRef(({item:t,isEditing:e,draggableProps:n,transformStyle:s,isDragging:r,isOverlay:l,isLoading:c,onDelete:u,onReplaceWithBrowse:d,onReplaceWithUpload:w,onDownload:y},f)=>{const[p,C]=g.useState(),[v,{selectedFiles:x}]=q.useFileInput({multiple:!0,accept:"image/*"}),[A,{results:L,doneAll:D}]=q.useAssetUpload();g.useEffect(()=>{x&&A(x[0])},[x]),g.useEffect(()=>{D&&w(L[0])},[D,L]);const $=c||x&&!D;return o.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!p&&y?.(),ref:f,style:{...s,opacity:r&&!l?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:z(["tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-surface-hover focus-visible:tw-outline focus-visible:!-tw-outline-offset-4",r?"tw-bg-surface-hover":""]),children:[o.jsx("div",{className:"tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:$?o.jsx(m.LoadingCircle,{size:"small"}):Wn(t.objectType)}),o.jsxs("div",{className:"tw-text-small tw-flex-1 tw-min-w-0",children:[o.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:t.title}),o.jsx("div",{className:"tw-text-secondary",children:`${t.fileSizeHumanReadable} - ${t.extension}`})]}),e&&o.jsxs("div",{"data-test-id":"attachments-actionbar",className:z(["tw-flex tw-gap-0.5 group-hover:tw-opacity-100 group-focus-visible:tw-opacity-100 has-[:focus-visible]:tw-opacity-100",l||p?.id===t.id?"tw-opacity-100":"tw-opacity-0"]),children:[o.jsx(m.Button,{aspect:"square",emphasis:"weak","aria-label":"Drag attachment",className:z([r||l?"tw-cursor-grabbing":"tw-cursor-grab","focus-visible:tw-z-[2]"]),...n,children:o.jsx(P.IconGrabHandle,{})}),o.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:o.jsxs(m.Dropdown.Root,{open:p?.id===t.id,onOpenChange:N=>C(N?t:void 0),children:[o.jsx(m.Dropdown.Trigger,{children:o.jsx(m.Button,{aspect:"square",emphasis:p?.id===t.id?"default":"weak",onPress:N=>{N?.stopPropagation(),N?.preventDefault()},children:o.jsx(P.IconPen,{size:"20"})})}),o.jsxs(m.Dropdown.Content,{side:"right",children:[o.jsxs(m.Dropdown.Group,{children:[o.jsxs(m.Dropdown.Item,{"data-test-id":"menu-item",onSelect:N=>{N?.stopPropagation(),v(),C(void 0)},children:[o.jsx(P.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),o.jsxs(m.Dropdown.Item,{onSelect:N=>{N?.stopPropagation(),d(),C(void 0)},children:[o.jsx(P.IconImageStack,{size:"20"}),"Replace with asset"]})]}),o.jsx(m.Dropdown.Group,{children:o.jsxs(m.Dropdown.Item,{emphasis:"danger",onSelect:N=>{N?.stopPropagation(),u(),C(void 0)},children:[o.jsx(P.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});me.displayName="AttachmentItem";const qn=t=>{const{attributes:e,listeners:n,setNodeRef:s,transform:r,transition:l,isDragging:c}=ht.useSortable({id:t.item.id}),u={transform:r?`translate(${r.x}px, ${r.y}px)`:"",transition:l,zIndex:c?2:1},d={...e,...n};return o.jsx(me,{ref:s,isDragging:c,transformStyle:u,draggableProps:d,...t})},fe=g.forwardRef(({children:t,...e},n)=>o.jsxs(m.Button,{ref:n,size:"small",rounding:"full",emphasis:"default","data-test-id":"attachments-button-trigger",className:"tw-body-medium",...e,children:[o.jsx(P.IconPaperclip,{size:"16"}),t,o.jsx(P.IconCaretDown,{size:"12"})]}));fe.displayName="AttachmentsButtonTrigger";const pe=({items:t=[],onDelete:e,onReplaceWithBrowse:n,onReplaceWithUpload:s,onBrowse:r,onUpload:l,onSorted:c,appBridge:u,triggerComponent:d=fe,isOpen:w,onOpenChange:y})=>{const[f,p]=g.useState(t),[C,v]=g.useState(!1),x=H.useSensors(H.useSensor(H.PointerSensor),H.useSensor(H.KeyboardSensor)),[A,L]=g.useState(void 0),[D,$]=g.useState(!1),[N,rt]=g.useState(!1),[U,it]=g.useState([]),[T,O]=g.useState(null),W=q.useEditorState(u),{openAssetChooser:gt,closeAssetChooser:Pt}=q.useAssetChooser(u),xt=w!==void 0,It=xt?w:C,ee=f?.find(k=>k.id===A),[ne,{results:Et,doneAll:xn}]=q.useAssetUpload({onUploadProgress:()=>!D&&$(!0)}),lt=k=>{(xt?y:v)?.(k)};g.useEffect(()=>{p(t)},[t]),g.useEffect(()=>{T&&($(!0),ne(T))},[T]),g.useEffect(()=>{(async()=>xn&&(await l(Et),$(!1)))()},[xn,Et]);const Oa=()=>{lt(!1),gt(async k=>{Pt(),lt(!0),rt(!0),await r(k),rt(!1)},{multiSelection:!0,selectedValueIds:f.map(k=>k.id)})},_a=k=>{lt(!1),gt(async M=>{lt(!0),Pt(),it([...U,k.id]),await n(k,M[0]),it(U.filter(J=>J!==k.id))},{multiSelection:!1,selectedValueIds:f.map(M=>M.id)})},Ua=async(k,M)=>{it([...U,k.id]),await s(k,M),it(U.filter(J=>J!==k.id))},Ha=k=>{const{active:M}=k;L(M.id)},za=k=>{const{active:M,over:J}=k;if(J&&M.id!==J.id&&f){const $a=f.findIndex(oe=>oe.id===M.id),Wa=f.findIndex(oe=>oe.id===J.id),In=ht.arrayMove(f,$a,Wa);p(In),c(In)}L(void 0)},Va={onEscapeKeyDown:k=>{k.stopPropagation(),lt(!1)}};return W||(f?.length??0)>0?o.jsx("div",{"data-test-id":"attachments-flyout-button",children:o.jsx(m.Flyout.Root,{open:It,onOpenChange:k=>lt(ee?!0:k),children:o.jsxs(m.Tooltip.Root,{enterDelay:500,children:[o.jsx(m.Tooltip.Trigger,{asChild:!0,children:o.jsx(m.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:o.jsx(d,{isFlyoutOpen:It,children:o.jsx("div",{children:t.length>0?t.length:"Add"})})})}),o.jsx(m.Flyout.Content,{side:"bottom",align:"end",width:"300px",...Va,children:o.jsxs("div",{className:"tw-w-full","data-test-id":"attachments-flyout-content",children:[f.length>0&&o.jsx(H.DndContext,{sensors:x,collisionDetection:H.closestCenter,onDragStart:Ha,onDragEnd:za,modifiers:[En.restrictToParentElement],children:o.jsx(ht.SortableContext,{items:f,strategy:ht.rectSortingStrategy,children:o.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:f.map(k=>o.jsx(qn,{isEditing:W,isLoading:U.includes(k.id),item:k,onDelete:()=>e(k),onReplaceWithBrowse:()=>_a(k),onReplaceWithUpload:M=>Ua(k,M),onDownload:()=>u.dispatch({name:"downloadAsset",payload:k})},k.id))})})}),W&&o.jsxs("div",{className:"tw-px-5 tw-py-3","data-test-id":"asset-input-placeholder",children:[o.jsx("div",{className:"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4",children:"Add attachments"}),D||N?o.jsxs(m.AssetInput.Root,{orientation:"horizontal",children:[o.jsx(m.AssetInput.Preview,{children:o.jsx(m.AssetInput.PreviewLoading,{})}),o.jsx(m.AssetInput.Title,{children:"Asset"}),o.jsx(m.AssetInput.Metadata,{children:o.jsx(m.AssetInput.MetadataItem,{children:o.jsxs(m.Flex,{align:"center",gap:.5,children:[N?o.jsx(P.IconImageStack,{size:16}):o.jsx(P.IconArrowCircleUp,{size:16}),N?"Loading":"Uploading"]})})})]}):o.jsxs(m.AssetInput.Placeholder,{children:[o.jsx(m.AssetInput.UploadInput,{allowMultiple:!0,onSelect:k=>O(k.target.files)}),o.jsx(m.AssetInput.BrowseInput,{onBrowse:Oa})]})]})]})}),o.jsx(m.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},Gn=(t,e)=>{const n=[mt.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded-medium","tw-body-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-container-secondary-active","tw-text-container-secondary-on-secondary-container",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active","tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),z(n)},et=g.forwardRef(({onClick:t,children:e,forceActiveStyle:n,cursor:s="pointer","data-test-id":r="base-toolbar-button",...l},c)=>o.jsx("button",{onClick:t,className:Gn(s,n),"data-test-id":r,...l,ref:c,children:e}));et.displayName="BaseToolbarButton";const we=g.forwardRef(({children:t,isFlyoutOpen:e,...n},s)=>o.jsxs(et,{forceActiveStyle:e,"data-test-id":"attachments-toolbar-button-trigger",ref:s,...n,children:[o.jsx(P.IconPaperclip,{size:"16"}),t,o.jsx(P.IconCaretDown,{size:"12"})]}));we.displayName="AttachmentsToolbarButtonTrigger";const ye="attachments",be=({flyoutId:t=ye})=>{const{appBridge:e,attachments:n,onAttachmentsAdd:s,onAttachmentDelete:r,onAttachmentReplace:l,onAttachmentsSorted:c}=he(),{isOpen:u,onOpenChange:d}=pt(t),w=tt();return o.jsx(pe,{onUpload:s,onDelete:r,onReplaceWithBrowse:l,onReplaceWithUpload:l,onSorted:c,onBrowse:s,items:n,appBridge:e,triggerComponent:we,isOpen:u&&!w,onOpenChange:d})},ve="Drag or press ↵ to move",Ce="Move with ↑↓←→ and confirm with ↵",Lt=({content:t,children:e,open:n,disabled:s})=>s?e:o.jsxs(m.Tooltip.Root,{enterDelay:300,open:n,children:[o.jsx(m.Tooltip.Trigger,{asChild:!0,children:e}),o.jsx(m.Tooltip.Content,{side:"top",children:o.jsx("div",{children:t})})]}),ke=({tooltip:t,icon:e,setActivatorNodeRef:n,draggableProps:s})=>{const r=tt(),{activatorEvent:l}=H.useDndContext(),c=l instanceof KeyboardEvent;return o.jsx(Lt,{...r&&{open:c},content:o.jsx("div",{children:r?Ce:t??ve}),children:o.jsx(et,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:r,cursor:"grab",...s,children:e})})},Te=({content:t,icon:e,tooltip:n,flyoutId:s,flyoutFooter:r,flyoutHeader:l})=>{const{isOpen:c,onOpenChange:u}=pt(s),d=tt();return o.jsx(Lt,{disabled:d||c,content:n,children:o.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:o.jsxs(m.Flyout.Root,{open:c&&!d,onOpenChange:u,children:[o.jsx(m.Flyout.Trigger,{asChild:!0,children:o.jsx(et,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:c&&!d,children:e})}),o.jsxs(m.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[l?o.jsx(m.Flyout.Header,{children:l}):null,o.jsx(m.Flyout.Body,{children:t}),r?o.jsx(m.Flyout.Footer,{children:r}):null]})]})})})},Dt="menu",Pe=({items:t,flyoutId:e=Dt,tooltip:n="Options"})=>{const{isOpen:s,onOpenChange:r}=pt(e),l=tt();return o.jsx(m.Dropdown.Root,{open:s&&!l,onOpenChange:r,children:o.jsxs(m.Tooltip.Root,{children:[o.jsx(m.Tooltip.Trigger,{asChild:!0,children:o.jsx(m.Dropdown.Trigger,{asChild:!0,children:o.jsx(et,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:o.jsx(P.IconDotsHorizontal,{size:"16"})})})}),o.jsx(m.Dropdown.Content,{children:t.map((c,u)=>o.jsx(m.Dropdown.Group,{children:c.map((d,w)=>o.jsxs(m.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{r(!1),d.onClick()},emphasis:d.style||"default",children:[o.jsx("div",{className:"tw-mr-2",children:d.icon}),o.jsx("span",{children:d.title})]},`${u}-${w}`))},u))}),o.jsx(m.Tooltip.Content,{children:n})]})})},Kn=({tooltip:t,icon:e,onClick:n})=>{const s=tt();return o.jsx(Lt,{disabled:s,content:t??"",children:o.jsx(et,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:e})})},xe=({children:t})=>o.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-segment",className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:t}),Ie=({items:t,attachments:e})=>o.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[e.isEnabled&&o.jsx(xe,{children:o.jsx(be,{})}),t.length>0&&o.jsx(xe,{children:t.map(n=>{switch(n.type){case"dragHandle":return o.jsx(ke,{...n},n.tooltip+n.type);case"menu":return o.jsx(Pe,{...n},n.tooltip+n.type);case"flyout":return o.jsx(Te,{...n},n.tooltip+n.type);default:return o.jsx(Kn,{...n},n.tooltip+n.type)}})})]}),Ee=g.memo(({children:t,toolbarItems:e,shouldHideWrapper:n,shouldHideComponent:s=!1,isDragging:r=!1,shouldFillContainer:l,outlineOffset:c=0,shouldBeShown:u=!1,showAttachments:d=!1})=>{const[w,y]=g.useState(u?[Dt]:[]),f=g.useRef(null);if(n)return o.jsx(o.Fragment,{children:t});const p=e?.filter(v=>v!==void 0),C=w.length>0||u;return o.jsx(le,{isDragPreview:r,children:o.jsx(de,{openFlyoutIds:w,setOpenFlyoutIds:y,children:o.jsxs("div",{ref:f,"data-test-id":"block-item-wrapper",style:{outlineOffset:c},className:z(["tw-relative tw-group",l&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container",C&&"tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container",s&&"tw-opacity-0"]),children:[o.jsx("div",{style:{right:-1-c,bottom:`calc(100% - ${2+c}px)`},className:z(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",C&&"tw-opacity-100"]),children:o.jsx(Ie,{attachments:{isEnabled:d},items:p})}),t]})})})});Ee.displayName="BlockItemWrapper";const jn=({ref:t,disabled:e,onChange:n})=>{g.useEffect(()=>{if(e||!t.current)return;let s=!1;const r=new IntersectionObserver(([l])=>{l.isIntersecting!==s&&(s=l.isIntersecting,n(l.isIntersecting))});return r.observe(t.current),()=>{r.disconnect()}},[t,e,n])},Yn=({value:t="",gap:e,customClass:n,show:s=!0,plugins:r})=>{const[l,c]=g.useState(null);return g.useEffect(()=>{(async()=>{const d=await a.serializeRawToHtmlAsync(t,r,void 0,e,n);c(d)})().catch(console.error)},[t,e,r,n]),!s||l==="<br />"||l===null?null:o.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:l}})},Mt=a.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(t=>({reset:()=>{t.url(""),t.text(""),t.buttonStyle("primary"),t.newTab(!1),t.mode(""),t.isEditing(!1)}})).extendActions(t=>({show:(e,n)=>{t.mode(e),t.isEditing(!1),t.openEditorId(n)},hide:()=>{t.reset(),t.openEditorId(null)}})).extendSelectors(t=>({isOpen:e=>t.openEditorId===e})),S=Mt.set,B=Mt.get,ut=()=>Mt.use,Se=t=>{if(!t)return!1;const e=n=>n.some(s=>s.text?s.text!=="":s.children?e(s.children):!1);try{const n=JSON.parse(t);return e(n)}catch{return!1}},Qn=(t="p",e="",n)=>Se(e)?e:JSON.stringify([{type:t,children:[{text:e,textStyle:t}],align:n}]),Xn=(t,e,n)=>t===Q.Custom?e:n,Ft=(t,e)=>{const n=a.getAboveNode(t,{match:{type:a.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},Jn=t=>Ft(t,e=>e.chosenLink?.searchResult?.link||""),Zn=t=>Ft(t,e=>e.url||""),Ot=t=>t.url||t.chosenLink?.searchResult?.link||"",Rn=t=>Ft(t,Ot),_t=/^\/(document|r)\/\S+$/i,yt=t=>{if(_t.test(t))return t;try{return new URL(t),t}catch{return`https://${t}`}},bt=t=>{if(_t.test(t))return!0;try{const e=new URL(t);return["http:","https:","mailto:","tel:"].includes(e.protocol)&&e.pathname!==""}catch{return!1}},nt=t=>bt(yt(t))||t==="",Be=(t,{type:e})=>{const{apply:n,normalizeNode:s}=t;return t.apply=r=>{if(r.type!=="set_selection"){n(r);return}const l=r.newProperties;if(!l?.focus||!l.anchor||!a.isCollapsed(l)){n(r);return}const c=a.getAboveNode(t,{at:l,match:{type:a.getPluginType(t,I)}});if(c){const[,u]=c;let d;a.isStartPoint(t,l.focus,u)&&(d=a.getPreviousNodeEndPoint(t,u)),a.isEndPoint(t,l.focus,u)&&(d=a.getNextNodeStartPoint(t,u)),d&&(r.newProperties={anchor:d,focus:d})}n(r)},t.normalizeNode=([r,l])=>{if(r.type===a.getPluginType(t,I)){const c=t.selection;if(c&&a.isCollapsed(c)&&a.isEndPoint(t,c.focus,l)){const u=a.getNextNodeStartPoint(t,l);if(u)a.select(t,u);else{const d=a.Path.next(l);a.insertNodes(t,{text:""},{at:d}),a.select(t,d)}}}s([r,l])},a.withRemoveEmptyNodes(t,a.mockPlugin({options:{types:e}}))},Ne=(t,e,n)=>{a.insertNodes(t,[Me(t,e)],n)},Ut=t=>{if(!t.selection)return;const{isUrl:e,forceSubmit:n}=a.getPluginOptions(t,I),s=B.url();if(!(e?.(s)||n))return;const l=B.text(),c=B.buttonStyle(),u=B.newTab()?void 0:"_self";return S.reset(),Ae(t,{url:s,text:l,buttonStyle:c,target:u,isUrl:d=>n||!e?!0:e(d)}),setTimeout(()=>{a.focusEditor(t,t.selection??void 0)},0),!0},ot=(t,e)=>a.withoutNormalizing(t,()=>{if(e?.split){if(a.getAboveNode(t,{at:t.selection?.anchor,match:{type:a.getPluginType(t,I)}}))return a.splitNodes(t,{at:t.selection?.anchor,match:r=>a.isElement(r)&&r.type===a.getPluginType(t,I)}),ot(t,{at:t.selection?.anchor}),!0;if(a.getAboveNode(t,{at:t.selection?.focus,match:{type:a.getPluginType(t,I)}}))return a.splitNodes(t,{at:t.selection?.focus,match:r=>a.isElement(r)&&r.type===a.getPluginType(t,I)}),ot(t,{at:t.selection?.focus}),!0}a.unwrapNodes(t,{match:{type:a.getPluginType(t,I)},...e})}),Ae=(t,{url:e,text:n,buttonStyle:s,target:r,insertTextInButton:l,insertNodesOptions:c,isUrl:u=a.getPluginOptions(t,I).isUrl})=>{const d=t.selection;if(!d)return;const w=a.getAboveNode(t,{at:d,match:{type:a.getPluginType(t,I)}});if(l&&w)return t.insertText(e),!0;if(!u?.(e))return;if(a.isDefined(n)&&n.length===0&&(n=e),w)return no(e,t,w,r,s,n),!0;const y=a.findNode(t,{at:d,match:{type:a.getPluginType(t,I)}}),[f,p]=y??[],C=to(t,p,n);if(a.isExpanded(d))return eo(w,t,e,s,r,n),!0;C&&a.removeNodes(t,{at:p});const v=a.getNodeProps(f??{}),x=t.selection?.focus.path;if(!x)return;const A=a.getNodeLeaf(t,x);return n?.length||(n=e),Ne(t,{...v,url:e,target:r,children:[{...A,text:n}]},c),!0};function to(t,e,n){return e&&n?.length&&n!==a.getEditorString(t,e)}function eo(t,e,n,s,r,l){t?ot(e,{at:t[1]}):ot(e,{split:!0}),Le(e,{url:n,buttonStyle:s,target:r}),Ht(e,{text:l})}function no(t,e,n,s,r,l){(t!==n[0]?.url||s!==n[0]?.target||r!==n[0]?.buttonStyle)&&a.setNodes(e,{url:t,target:s,buttonStyle:r},{at:n[1]}),Ht(e,{text:l})}const Ht=(t,{text:e})=>{const n=a.getAboveNode(t,{match:{type:a.getPluginType(t,I)}});if(n){const[s,r]=n;if(e?.length&&e!==a.getEditorString(t,r)){const l=s.children[0];a.replaceNodeChildren(t,{at:r,nodes:{...l,text:e},insertOptions:{select:!0}})}}},Le=(t,{url:e,buttonStyle:n,target:s,...r})=>{a.wrapNodes(t,{type:a.getPluginType(t,I),url:e,buttonStyle:n,target:s,children:[]},{split:!0,...r})},oo=(t,e)=>{const n=a.getAboveNode(t,{match:{type:I}});return Array.isArray(n)?e(n[0]):""},De=t=>oo(t,e=>e.url??""),Me=(t,{url:e,text:n="",buttonStyle:s="primary",target:r,children:l})=>({type:a.getPluginType(t,I),url:e,target:r,buttonStyle:s,children:l??[{text:n}]}),Fe=(t,{focused:e}={})=>{if(B.mode()==="edit"){vt(t);return}zt(t,{focused:e})},vt=t=>{const e=a.findNode(t,{match:{type:a.getPluginType(t,I)}});if(!e)return;const[n,s]=e;let r=a.getEditorString(t,s);S.url(n.url),S.newTab(n.target===void 0),r===n.url&&(r=""),S.text(r),S.isEditing(!0)},zt=(t,{focused:e}={})=>{B.mode()||!e||a.isRangeAcrossBlocks(t,{at:t.selection})||a.someNode(t,{match:{type:a.getPluginType(t,I)}})||(S.text(a.getEditorString(t,t.selection)),S.show("insert",t.id))},Vt={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},Ct={buttonPrimary:{...Vt,fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{...Vt,fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{...Vt,fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},ao=t=>{const{attributes:e,children:n}=t,s=t.element.url||t.element.chosenLink?.searchResult?.link||"",r=t.element.target||"_self",l=String(t.element.buttonStyle)||"primary";return o.jsx(so,{attributes:e,href:s,target:r,styles:Ct[`button${l.charAt(0).toUpperCase()+l.slice(1)}`],children:n})},so=({attributes:t,styles:e={hover:{}},children:n,href:s="#",target:r})=>{const[l,c]=g.useState(!1);return o.jsx("a",{...t,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:s,target:r,style:l?{...e,...e.hover}:e,children:n})};class ro extends a.MarkupElement{constructor(e=I,n=ao){super(e,n)}}const Oe=g.forwardRef((t,e)=>{const n=a.useEditorRef();return o.jsx(a.ToolbarButton,{ref:e,...t,onMouseDown:s=>{s.preventDefault(),a.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{Fe(n,{focused:!0})},children:o.jsx(a.IconStylingWrapper,{icon:o.jsx(P.IconButton,{size:16})})})});Oe.displayName="ButtonToolbarButton";const io=({editorId:t,id:e})=>{const n=a.useEditorState(a.useEventPlateId(t)),s=!!a.isRangeInSameBlock(n,{at:n.selection}),r=a.getPluginType(n,I),l=!!n?.selection&&a.someNode(n,{match:{type:r}});return o.jsx("div",{"data-plugin-id":e,children:o.jsx(Oe,{pressed:l,disabled:!s,tooltip:a.getTooltip(s?`Button
|
|
2
|
+
${a.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},at="link-plugin";var b=(t=>(t.heading1="heading1",t.heading2="heading2",t.heading3="heading3",t.heading4="heading4",t.custom1="custom1",t.custom2="custom2",t.custom3="custom3",t.quote="quote",t.imageCaption="imageCaption",t.imageTitle="imageTitle",t.p="p",t))(b||{});const E={heading1:{fontSize:"var(--f-theme-settings-heading1-font-size)",lineHeight:"var(--f-theme-settings-heading1-line-height)",marginTop:"var(--f-theme-settings-heading1-margin-top)",marginBottom:"var(--f-theme-settings-heading1-margin-bottom)",textDecoration:"var(--f-theme-settings-heading1-text-decoration)",fontStyle:"var(--f-theme-settings-heading1-font-style)",textTransform:"var(--f-theme-settings-heading1-text-transform)",letterSpacing:"var(--f-theme-settings-heading1-letter-spacing)",fontWeight:"var(--f-theme-settings-heading1-font-weight)",fontFamily:"var(--f-theme-settings-heading1-font-family)",color:"var(--f-theme-settings-heading1-color)"},heading2:{fontSize:"var(--f-theme-settings-heading2-font-size)",lineHeight:"var(--f-theme-settings-heading2-line-height)",marginTop:"var(--f-theme-settings-heading2-margin-top)",marginBottom:"var(--f-theme-settings-heading2-margin-bottom)",textDecoration:"var(--f-theme-settings-heading2-text-decoration)",fontStyle:"var(--f-theme-settings-heading2-font-style)",textTransform:"var(--f-theme-settings-heading2-text-transform)",letterSpacing:"var(--f-theme-settings-heading2-letter-spacing)",fontWeight:"var(--f-theme-settings-heading2-font-weight)",fontFamily:"var(--f-theme-settings-heading2-font-family)",color:"var(--f-theme-settings-heading2-color)"},heading3:{fontSize:"var(--f-theme-settings-heading3-font-size)",lineHeight:"var(--f-theme-settings-heading3-line-height)",marginTop:"var(--f-theme-settings-heading3-margin-top)",marginBottom:"var(--f-theme-settings-heading3-margin-bottom)",textDecoration:"var(--f-theme-settings-heading3-text-decoration)",fontStyle:"var(--f-theme-settings-heading3-font-style)",textTransform:"var(--f-theme-settings-heading3-text-transform)",letterSpacing:"var(--f-theme-settings-heading3-letter-spacing)",fontWeight:"var(--f-theme-settings-heading3-font-weight)",fontFamily:"var(--f-theme-settings-heading3-font-family)",color:"var(--f-theme-settings-heading3-color)"},heading4:{fontSize:"var(--f-theme-settings-heading4-font-size)",lineHeight:"var(--f-theme-settings-heading4-line-height)",marginTop:"var(--f-theme-settings-heading4-margin-top)",marginBottom:"var(--f-theme-settings-heading4-margin-bottom)",textDecoration:"var(--f-theme-settings-heading4-text-decoration)",fontStyle:"var(--f-theme-settings-heading4-font-style)",textTransform:"var(--f-theme-settings-heading4-text-transform)",letterSpacing:"var(--f-theme-settings-heading4-letter-spacing)",fontWeight:"var(--f-theme-settings-heading4-font-weight)",fontFamily:"var(--f-theme-settings-heading4-font-family)",color:"var(--f-theme-settings-heading4-color)"},custom1:{fontSize:"var(--f-theme-settings-custom1-font-size)",lineHeight:"var(--f-theme-settings-custom1-line-height)",marginTop:"var(--f-theme-settings-custom1-margin-top)",marginBottom:"var(--f-theme-settings-custom1-margin-bottom)",textDecoration:"var(--f-theme-settings-custom1-text-decoration)",fontStyle:"var(--f-theme-settings-custom1-font-style)",textTransform:"var(--f-theme-settings-custom1-text-transform)",letterSpacing:"var(--f-theme-settings-custom1-letter-spacing)",fontWeight:"var(--f-theme-settings-custom1-font-weight)",fontFamily:"var(--f-theme-settings-custom1-font-family)",color:"var(--f-theme-settings-custom1-color)"},custom2:{fontSize:"var(--f-theme-settings-custom2-font-size)",lineHeight:"var(--f-theme-settings-custom2-line-height)",marginTop:"var(--f-theme-settings-custom2-margin-top)",marginBottom:"var(--f-theme-settings-custom2-margin-bottom)",textDecoration:"var(--f-theme-settings-custom2-text-decoration)",fontStyle:"var(--f-theme-settings-custom2-font-style)",textTransform:"var(--f-theme-settings-custom2-text-transform)",letterSpacing:"var(--f-theme-settings-custom2-letter-spacing)",fontWeight:"var(--f-theme-settings-custom2-font-weight)",fontFamily:"var(--f-theme-settings-custom2-font-family)",color:"var(--f-theme-settings-custom2-color)"},custom3:{fontSize:"var(--f-theme-settings-custom3-font-size)",lineHeight:"var(--f-theme-settings-custom3-line-height)",marginTop:"var(--f-theme-settings-custom3-margin-top)",marginBottom:"var(--f-theme-settings-custom3-margin-bottom)",textDecoration:"var(--f-theme-settings-custom3-text-decoration)",fontStyle:"var(--f-theme-settings-custom3-font-style)",textTransform:"var(--f-theme-settings-custom3-text-transform)",letterSpacing:"var(--f-theme-settings-custom3-letter-spacing)",fontWeight:"var(--f-theme-settings-custom3-font-weight)",fontFamily:"var(--f-theme-settings-custom3-font-family)",color:"var(--f-theme-settings-custom3-color)"},p:{fontSize:"var(--f-theme-settings-body-font-size)",lineHeight:"var(--f-theme-settings-body-line-height)",marginTop:"var(--f-theme-settings-body-margin-top)",marginBottom:"var(--f-theme-settings-body-margin-bottom)",textDecoration:"var(--f-theme-settings-body-text-decoration)",fontStyle:"var(--f-theme-settings-body-font-style)",textTransform:"var(--f-theme-settings-body-text-transform)",letterSpacing:"var(--f-theme-settings-body-letter-spacing)",fontWeight:"var(--f-theme-settings-body-font-weight)",fontFamily:"var(--f-theme-settings-body-font-family)",color:"var(--f-theme-settings-body-color)"},quote:{fontSize:"var(--f-theme-settings-quote-font-size)",lineHeight:"var(--f-theme-settings-quote-line-height)",marginTop:"var(--f-theme-settings-quote-margin-top)",marginBottom:"var(--f-theme-settings-quote-margin-bottom)",textDecoration:"var(--f-theme-settings-quote-text-decoration)",fontStyle:"var(--f-theme-settings-quote-font-style)",textTransform:"var(--f-theme-settings-quote-text-transform)",letterSpacing:"var(--f-theme-settings-quote-letter-spacing)",fontWeight:"var(--f-theme-settings-quote-font-weight)",fontFamily:"var(--f-theme-settings-quote-font-family)",color:"var(--f-theme-settings-quote-color)"},imageCaption:{fontSize:"var(--f-theme-settings-image-caption-font-size)",lineHeight:"var(--f-theme-settings-image-caption-line-height)",marginTop:"var(--f-theme-settings-image-caption-margin-top)",marginBottom:"var(--f-theme-settings-image-caption-margin-bottom)",textDecoration:"var(--f-theme-settings-image-caption-text-decoration)",fontStyle:"var(--f-theme-settings-image-caption-font-style)",textTransform:"var(--f-theme-settings-image-caption-text-transform)",letterSpacing:"var(--f-theme-settings-image-caption-letter-spacing)",fontWeight:"var(--f-theme-settings-image-caption-font-weight)",fontFamily:"var(--f-theme-settings-image-caption-font-family)",color:"var(--f-theme-settings-image-caption-color)"},imageTitle:{fontSize:"var(--f-theme-settings-image-title-font-size)",lineHeight:"var(--f-theme-settings-image-title-line-height)",marginTop:"var(--f-theme-settings-image-title-margin-top)",marginBottom:"var(--f-theme-settings-image-title-margin-bottom)",textDecoration:"var(--f-theme-settings-image-title-text-decoration)",fontStyle:"var(--f-theme-settings-image-title-font-style)",textTransform:"var(--f-theme-settings-image-title-text-transform)",letterSpacing:"var(--f-theme-settings-image-title-letter-spacing)",fontWeight:"var(--f-theme-settings-image-title-font-weight)",fontFamily:"var(--f-theme-settings-image-title-font-family)",color:"var(--f-theme-settings-image-title-color)"},[at]:{fontSize:"var(--f-theme-settings-link-font-size)",lineHeight:"var(--f-theme-settings-link-line-height)",marginTop:"var(--f-theme-settings-link-margin-top)",marginBottom:"var(--f-theme-settings-link-margin-bottom)",textDecoration:"var(--f-theme-settings-link-text-decoration)",fontStyle:"var(--f-theme-settings-link-font-style)",textTransform:"var(--f-theme-settings-link-text-transform)",letterSpacing:"var(--f-theme-settings-link-letter-spacing)",fontWeight:"var(--f-theme-settings-link-font-weight)",fontFamily:"var(--f-theme-settings-link-font-family)",color:"var(--f-theme-settings-link-color)"},...Ct},lo=()=>{const t=a.useEditorRef();return o.jsx(a.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:o.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[o.jsx("a",{"data-test-id":"floating-button-edit-url",href:B.url(),target:"_blank",rel:"noopener noreferrer",style:E[at],className:"tw-break-all",children:B.url()}),o.jsxs("span",{className:"tw-flex tw-gap-2",children:[o.jsx("button",{onClick:()=>{vt(t)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:o.jsx(P.IconPen,{size:16})}),o.jsx("button",{onClick:()=>{ot(t),a.focusEditor(t,t.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:o.jsx(P.IconTrashBin,{size:16})})]})]})})},_e=t=>t.filter(e=>!!e.title?.trim()),Ue=()=>o.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:o.jsx(m.LoadingCircle,{size:"small"})}),co=({section:t,selectedUrl:e,onSelectUrl:n})=>{const s=t.permanentLink===e;return o.jsx("button",{"data-test-id":"internal-link-selector-section-link",type:"button","data-is-active":s,className:`
|
|
3
3
|
tw-py-2 tw-pr-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full
|
|
4
|
-
${s?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:o.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[o.jsx(
|
|
4
|
+
${s?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:o.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[o.jsx(P.IconDocumentText,{size:16}),o.jsx("span",{className:"tw-text-small",children:t.title}),o.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Section"})]})})},uo=({page:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r})=>{const[l,c]=g.useState(t.id===s.documentId),[u,d]=g.useState([]),w=t.permanentLink===e;g.useEffect(()=>{(async()=>{const p=await r(t.id),C=_e(p);d(C)})()},[t.id,r]),g.useEffect(()=>{t.id===s.pageId&&c(!0)},[s,t.id]);const y=u.length>0;return o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button","data-test-id":"internal-link-selector-page-link",className:`
|
|
5
5
|
tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full
|
|
6
6
|
${y?"tw-pl-7 ":"tw-pl-12 "}
|
|
7
|
-
${w?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover ":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container "}`,onClick:()=>n(t.permanentLink),children:o.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[y&&o.jsx("button",{type:"button",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!l),onKeyDown:
|
|
8
|
-
${l?"tw-rotate-90 ":""}`})}),o.jsx("span",{className:"tw-text-small",children:t.title}),o.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Page"})]},t.id)}),l&&u.length>0&&u.map(m=>o.jsx(lo,{section:m,selectedUrl:e,onSelectUrl:n},m.id))]})},uo=({documentId:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r,getDocumentPagesByDocumentId:l})=>{const[c,u]=h.useState([]),[d,w]=h.useState(!0),y=[...c.values()],m=!d&&y.length>0;return h.useEffect(()=>{l(t).then(p=>{const C=p.filter(P=>!!P.category).sort((P,L)=>P.category.sort===L.category.sort?P.sort-L.sort:P.category.sort-L.category.sort),v=p.filter(P=>!P.category).sort((P,L)=>P.sort-L.sort);u([...C,...v])}).finally(()=>{w(!1)})},[]),d?o.jsx(_e,{}):m?o.jsx(o.Fragment,{children:y.map(p=>o.jsx(co,{page:p,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r},p.id))}):o.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-small tw-text-secondary",children:"This document does not contain any pages."})},go=({document:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r,getDocumentPagesByDocumentId:l})=>{const[c,u]=h.useState(t.id===s.documentId),d=t.permanentLink===e;return h.useEffect(()=>{t.id===s.documentId&&u(!0)},[s,t.id]),o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button","data-test-id":"internal-link-selector-document-link",className:`tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-w-full ${d?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:[o.jsx("button",{type:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>u(!c),onKeyDown:w=>w.key==="Enter"&&w.stopPropagation(),children:o.jsx("div",{className:`tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong ${c?"tw-rotate-90":""}`})}),o.jsx(x.IconColorFan,{size:16}),o.jsx("span",{className:"tw-text-small",children:t.title}),o.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Document"})]}),c&&o.jsx(uo,{documentId:t.id,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r,getDocumentPagesByDocumentId:l})]})},ho=({selectedUrl:t,onSelectUrl:e,getAllDocuments:n,getDocumentPagesByDocumentId:s,getDocumentSectionsByDocumentPageId:r})=>{const[l,c]=h.useState(!0),[u,d]=h.useState([]),[w,y]=h.useState({documentId:void 0,pageId:void 0});h.useEffect(()=>{t&&u.length>0&&m().then(p=>{y(p)})},[u.length]),h.useEffect(()=>{n().then(p=>{d(p)}).finally(()=>{c(!1)})},[]);const m=async()=>{const p={documentId:void 0,pageId:void 0};if(u.find(v=>v.permanentLink===t))return p;for(const v of u){const P=await s(v.id);if(!!P.find(A=>A.permanentLink===t))return p.documentId=v.id,p;for(const A of P){const D=await r(A.id);if(!!Oe(D).find(U=>U.permanentLink===t))return p.documentId=v.id,p.pageId=A.id,p}}return p};return l?o.jsx(_e,{}):o.jsx(o.Fragment,{children:u.map(p=>o.jsx(go,{document:p,selectedUrl:t,onSelectUrl:e,itemsToExpandInitially:w,getDocumentSectionsByDocumentPageId:r,getDocumentPagesByDocumentId:s},p.id))})},Ue=({url:t,onUrlChange:e,buttonSize:n="medium",getAllDocuments:s,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:l})=>{const[c,u]=h.useState(!1),[d,w]=h.useState(t),y=v=>{w(v)},m=v=>{v.key==="Enter"&&(v.preventDefault(),p())};h.useEffect(()=>{t&&!d&&w(t)},[t,d]);const p=()=>{e?.(d),u(!1)},C={onOpenAutoFocus:()=>{},showUnderlay:!0,"data-is-underlay":!0,minWidth:"800px"};return o.jsx("div",{onPointerDown:v=>{v.preventDefault()},"data-test-id":"internal-link-selector",onKeyDown:m,children:o.jsxs(f.Dialog.Root,{modal:!0,open:c,onOpenChange:u,children:[o.jsx(f.Dialog.Trigger,{asChild:!0,children:o.jsxs(f.Button,{size:n,emphasis:"default",children:[o.jsx(x.IconLink,{size:"20"}),"Internal link"]})}),o.jsxs(f.Dialog.Content,{...C,children:[o.jsx(f.Dialog.Header,{children:o.jsx(f.Dialog.Title,{children:"Select internal link"})}),o.jsx(f.Dialog.Body,{padding:"none",children:o.jsx(f.ScrollArea,{padding:"compact",children:o.jsx(ho,{selectedUrl:d,onSelectUrl:y,getAllDocuments:s,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:l})})}),o.jsxs(f.Dialog.Footer,{children:[o.jsx(f.Button,{size:n,emphasis:"default",onPress:()=>u(!1),children:"Cancel"}),o.jsx(f.Button,{size:n,disabled:!d,emphasis:"strong",onPress:()=>p(),children:"Choose"})]})]})]})})},He=({onUrlChange:t,onToggleTab:e,isValidUrlOrEmpty:n,appBridge:s,placeholder:r,newTab:l,url:c="",required:u,info:d,label:w,buttonSize:y,hideInternalLinkButton:m})=>{const p=n?n(c):st(c);return o.jsxs("div",{"data-test-id":"link-input",children:[o.jsx(tt.FormControl,{label:{children:w,htmlFor:"url",required:u,tooltip:d?{content:d,position:"top"}:void 0},children:o.jsx(f.TextInput,{"data-test-id":"text-input",id:"url",value:c,onChange:C=>t?.(C.target.value),placeholder:r??"https://example.com"})}),!p&&o.jsx("div",{className:"tw-text-error tw-mt-1 tw-text-small",children:"Please enter a valid URL."}),!m&&o.jsx("div",{className:"tw-mt-3",children:o.jsx(Ue,{url:c,onUrlChange:t,buttonSize:y??"medium",getAllDocuments:()=>s.getAllDocuments(),getDocumentPagesByDocumentId:C=>s.getDocumentPagesByDocumentId(C),getDocumentSectionsByDocumentPageId:C=>s.getDocumentSectionsByDocumentPageId(C)})}),o.jsxs("div",{className:"tw-mt-3 tw-flex tw-items-center tw-gap-1.5",children:[o.jsx(f.Checkbox,{id:"new-tab",value:l,onChange:()=>e?.(!l)}),o.jsx(f.Label,{id:"new-tab-label",htmlFor:"new-tab",className:"tw-whitespace-nowrap",children:"Open in new tab"})]})]})},ze=({state:t,onTextChange:e,onUrlChange:n,onToggleTab:s,onCancel:r,onSave:l,isValidUrlOrEmpty:c,hasValues:u,testId:d,appBridge:w,children:y})=>o.jsxs(a.FloatingModalWrapper,{"data-test-id":d,padding:"28px",minWidth:"400px",children:[o.jsx(tt.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:o.jsx(f.TextInput,{id:"linkText",value:t.text,placeholder:"Link Text",onChange:m=>e(m.target.value)})}),y,o.jsx("div",{className:"tw-mt-5",children:o.jsx(He,{url:t.url,newTab:t.newTab,onUrlChange:n,onToggleTab:s,isValidUrlOrEmpty:c,appBridge:w})}),o.jsx("div",{className:"tw-mt-3",children:o.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[o.jsx(f.Button,{"data-test-id":"button",onPress:r,size:"medium",emphasis:"default",children:"Cancel"}),o.jsxs(f.Button,{"data-test-id":"button",onPress:l,size:"medium",disabled:!c(t?.url)||!u,children:[o.jsx(x.IconCheckMark,{size:"20"}),"Save"]})]})})]}),mo=t=>{const e=a.getAboveNode(t,{match:{type:E}});return Array.isArray(e)&&e[0]?.buttonStyle||"primary"},fo={url:"",text:"",buttonStyle:"primary",newTab:!1},po=()=>{const[t,e]=h.useReducer((n,s)=>{const{type:r,payload:l}=s;switch(r){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...l};default:return n}},fo);return[t,e]},wo=()=>{const t=a.useEditorRef(),[e,n]=po();h.useEffect(()=>{const m=mo(t);n({type:"INIT",payload:{text:B.text()||B.url(),buttonStyle:m,newTab:!!B.newTab(),url:B.url()}})},[n,t]);const s=m=>{n({type:"TEXT",payload:{text:m}})},r=m=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:m}})},l=m=>{n({type:"URL",payload:{url:m}})},c=m=>{n(m?{type:"NEW_TAB"}:{type:"SAME_TAB"})},u=()=>{S.reset()},d=m=>{if(!st(e.url)||!w)return;const p=wt(e.url);S.text(e.text),S.url(p),S.buttonStyle(e.buttonStyle),S.newTab(e.newTab),Ot(t)&&m?.preventDefault()},w=e.url!==""&&e.text!=="",{appBridge:y}=a.getPluginOptions(t,E);return a.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:s,onButtonStyleChange:r,onUrlChange:l,onToggleTab:c,onCancel:u,onSave:d,hasValues:w,isValidUrlOrEmpty:st,appBridge:y}},yo=()=>{const t=wo(),{state:e,onButtonStyleChange:n}=t;return o.jsx(ze,{...t,testId:"floating-button-insert",children:o.jsx("div",{className:"tw-pt-5",children:o.jsxs(tt.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[o.jsx(zt,{id:"primary",styles:I.buttonPrimary,isActive:e.buttonStyle==="primary",onClick:()=>n("primary"),children:e.text||"Primary Button"}),o.jsx(zt,{id:"secondary",styles:I.buttonSecondary,isActive:e.buttonStyle==="secondary",onClick:()=>n("secondary"),children:e.text||"Secondary Button"}),o.jsx(zt,{id:"tertiary",styles:I.buttonTertiary,isActive:e.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:e.text||"Tertiary Button"})]})})})},zt=({id:t,styles:e,isActive:n,onClick:s,children:r})=>{const[l,c]=h.useState(!1),u=()=>e&&e.hover&&l?{...e,...e.hover}:e;return o.jsx("button",{"data-test-id":`floating-button-insert-${t}`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:s,style:{...u(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:r})},Ve={placement:"bottom-start",strategy:"absolute",middleware:[a.offset(12),a.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},bo=()=>{const{ref:t,...e}=ko(Ve),{ref:n,...s}=vo(Ve),r=a.useEditorRef(),l=ut(),c=l.isOpen(r.id),u=l.isEditing(),d=l.mode(),w=o.jsx(yo,{}),y=u?w:o.jsx(io,{});return o.jsxs(o.Fragment,{children:[c&&d==="insert"&&mt.createPortal(o.jsx("div",{"data-is-underlay":!0,ref:t,...e,style:{...e.style,...I[a.TextStyles.p]},children:w}),document.body),c&&d==="edit"&&mt.createPortal(o.jsx("div",{"data-is-underlay":!0,ref:n,...s,style:{...s.style,...I[a.TextStyles.p]},children:y}),document.body)]})},E="button",$e="button-plugin",We=t=>a.createPluginFactory({key:E,isElement:!0,isInline:!0,props:({element:e})=>({nodeProps:{href:e?.url,target:e?.target}}),withOverrides:Se,renderAfterEditable:bo,options:{isUrl:yt,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:t},then:(e,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:s=>({type:n,url:s.getAttribute("href"),target:s.getAttribute("target")||"_blank"})}})})();class qe extends a.Plugin{styles={};appBridge;constructor({styles:e=vt,...n}){super($e,{button:ro,markupElement:new so,...n}),this.styles=e,this.appBridge=n?.appBridge}plugins(){return[We(this.appBridge)]}}const vo=t=>{const e=a.useEditorRef(),n=ut().mode(),s=ut().isOpen(e.id),r=a.useEditorVersion(),{triggerFloatingButtonHotkeys:l}=a.getPluginOptions(e,E),c=h.useCallback(()=>{const m=a.getAboveNode(e,{match:{type:a.getPluginType(e,E)}});if(m){const[,p]=m;return a.getRangeBoundingClientRect(e,{anchor:a.getStartPoint(e,p),focus:a.getEndPoint(e,p)})}return a.getDefaultBoundingClientRect()},[e]),u=s&&n==="edit",{update:d,style:w,floating:y}=Ke({open:u,getBoundingClientRect:c,...t});return h.useEffect(()=>{const m=Ae(e);if(m&&S.url(m),e.selection&&a.someNode(e,{match:{type:a.getPluginType(e,E)}})){S.show("edit",e.id),d();return}B.mode()==="edit"&&S.reset()},[e,r,d]),a.useHotkeys(l,m=>{m.preventDefault(),B.mode()==="edit"&&bt(e)},{enableOnContentEditable:!0},[]),Co(),Ge(),{style:w,ref:a.useComposedRef(y)}},Co=()=>{const t=a.useEditorRef();a.useHotkeys("*",e=>{e.key==="Enter"&&Ot(t)&&e.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Ge=()=>{const t=a.useEditorRef();a.useHotkeys("escape",()=>{if(B.mode()==="edit"){if(B.isEditing()){S.show("edit",t.id),a.focusEditor(t,t.selection??void 0);return}S.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},ko=t=>{const e=a.useEditorRef(),n=a.useFocused(),s=ut().mode(),r=ut().isOpen(e.id),{triggerFloatingButtonHotkeys:l}=a.getPluginOptions(e,E);a.useHotkeys(l,w=>{w.preventDefault(),Ut(e,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:c,style:u,floating:d}=Ke({open:r&&s==="insert",getBoundingClientRect:a.getSelectionBoundingClientRect,whileElementsMounted:void 0,...t});return h.useEffect(()=>{r&&c(),S.updated(r)},[r,c]),Ge(),{style:u,ref:a.useComposedRef(d)}},To=12,Po=-22,xo=96,Ke=t=>a.useVirtualFloating({placement:"bottom-start",middleware:[a.offset({mainAxis:To,alignmentAxis:Po}),a.flip({padding:xo})],...t}),Vt="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @md:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @md:[&_.tw-break-after-column]:!tw-break-after-column @md:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",je={1:"tw-columns-1",2:"tw-columns-1 @sm:!tw-columns-2 [&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @sm:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @sm:[&_.tw-break-after-column]:!tw-break-after-column @sm:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",3:`tw-columns-1 @md:!tw-columns-3 ${Vt}`,4:`tw-columns-1 @md:!tw-columns-4 ${Vt}`,5:`tw-columns-1 @md:!tw-columns-5 ${Vt}`},Ye=t=>t?je[t]||je[1]:"",Eo=t=>{B.isOpen(t)&&S.reset()},Qe=h.memo(({isEnabled:t,value:e,columns:n,gap:s,placeholder:r,plugins:l,onTextChange:c,showSerializedText:u})=>{const d=Ye(n),[w,y]=h.useState(!1),m=h.useId(),p=h.useCallback(v=>{v!==e&&c?.(v),y(!1)},[c,e]),C=h.useCallback(()=>y(!0),[]);return h.useEffect(()=>{const v=P=>{P.preventDefault(),P.returnValue="Unprocessed changes"};return w&&window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[w]),t?o.jsx(a.RichTextEditor,{id:m,value:e,border:!1,placeholder:r,plugins:l,onValueChanged:C,onTextChange:p,hideExternalFloatingModals:Eo,placeholderOpacity:"high"}):o.jsx(jn,{value:e,gap:s,customClass:d,show:u,plugins:l})});Qe.displayName="InternalRichTextEditor";const Io=t=>{const e=h.useRef(null),[n,s]=h.useState(!1),{isEditing:r,...l}=t,c=h.useCallback(u=>{u&&s(!0)},[]);return Kn({ref:e,disabled:!r,onChange:c}),h.useEffect(()=>{r||s(!1)},[r]),o.jsx("div",{"data-test-id":"rich-text-editor-container",className:"tw-block tw-w-full tw-@container",ref:e,children:o.jsx(Qe,{...l,isEnabled:r&&n})})},So=({editButtonProps:t,unlinkButtonProps:e})=>{const{element:n}=a.useLinkOpenButtonState(),s=n?Mt(n):"";return o.jsx(a.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:o.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[o.jsx("a",{"data-test-id":"floating-link-edit-url",href:s,target:"_blank",rel:"noopener noreferrer",style:I[it],className:"tw-break-all",children:s}),o.jsxs("span",{className:"tw-flex tw-gap-2",children:[o.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...t,children:o.jsx(x.IconPen,{size:16})}),o.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...e,children:o.jsx(x.IconTrashBin,{size:16})})]})]})})},Xe=(t,e)=>{const n=a.getAboveNode(t,{match:{type:a.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},No=t=>Xe(t,e=>e.chosenLink?.searchResult?.link||""),Bo=t=>Xe(t,e=>e.url||""),Lo={url:"",text:"",newTab:!1},Ao=()=>{const[t,e]=h.useReducer((n,s)=>{const{type:r,payload:l}=s;switch(r){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"INIT":return{...n,...l};default:return n}},Lo);return[t,e]},Do=()=>{const t=a.useEditorRef(),[e,n]=Ao();h.useEffect(()=>{const y=No(t),m=Bo(t),p=a.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:a.floatingLinkSelectors.text()||a.floatingLinkSelectors.url(),newTab:p,url:y&&m===""?y:a.floatingLinkSelectors.url()}})},[n,t]);const s=y=>{n({type:"TEXT",payload:{text:y}})},r=y=>{n({type:"URL",payload:{url:y}})},l=y=>{n(y?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{a.floatingLinkActions.reset()},u=y=>{!st(e.url)||!d||(a.floatingLinkActions.text(e.text),a.floatingLinkActions.url(wt(e.url)),a.floatingLinkActions.newTab(e.newTab),a.submitFloatingLink(t)&&y?.preventDefault())},d=e.url!==""&&e.text!=="",{appBridge:w}=a.getPluginOptions(t,a.ELEMENT_LINK);return a.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:s,onUrlChange:r,onToggleTab:l,onCancel:c,onSave:u,hasValues:d,isValidUrlOrEmpty:st,appBridge:w}},Mo=()=>o.jsx(ze,{...Do(),testId:"floating-link-insert"}),Je={placement:"bottom-start",strategy:"absolute",middleware:[a.offset(12),a.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Fo=()=>{const t=a.useFloatingLinkInsertState({floatingOptions:Je}),{props:e,ref:n,hidden:s}=a.useFloatingLinkInsert(t),r=a.useFloatingLinkEditState({floatingOptions:Je}),{props:l,ref:c,editButtonProps:u,unlinkButtonProps:d}=a.useFloatingLinkEdit(r);if(s)return null;const w=o.jsx(Mo,{}),y=r.isEditing?w:o.jsx(So,{editButtonProps:u,unlinkButtonProps:d});return o.jsxs(o.Fragment,{children:[t.isOpen&&!r.isOpen&&mt.createPortal(o.jsx("div",{"data-is-underlay":!0,ref:n,...e,style:{...e.style,...I[b.p]},children:w}),document.body),r.isOpen&&mt.createPortal(o.jsx("div",{"data-is-underlay":!0,ref:c,...l,style:{...l.style,...I[b.p]},children:y}),document.body)]})},Ze=h.forwardRef((t,e)=>{const n=a.useEditorRef(),s=a.useLinkToolbarButtonState(),{props:r}=a.useLinkToolbarButton(s);return o.jsx(a.ToolbarButton,{onMouseDown:l=>{l.preventDefault(),a.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:e,...r,...t,children:o.jsx(a.IconStylingWrapper,{icon:o.jsx(x.IconLink,{size:16})})})});Ze.displayName="LinkToolbarButton";const Oo=({id:t,editorId:e})=>{const n=a.useEditorState(a.useEventPlateId(e)),s=!!a.isRangeInSameBlock(n,{at:n.selection});return o.jsx("div",{"data-plugin-id":t,children:o.jsx(Ze,{disabled:!s,tooltip:a.getTooltip(s?`Link
|
|
9
|
-
${a.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},_o=t=>{const{attributes:e,children:n}=t,{styles:s}=a.useRichTextEditorContext(),r=t.element.url||t.element.chosenLink?.searchResult?.link||"",l=t.element.target||"_self";return o.jsx("a",{...e,href:r,target:l,style:s[it],children:n})};class Uo extends a.MarkupElement{constructor(e=a.ELEMENT_LINK,n=_o){super(e,n)}}const Re=t=>a.createPluginFactory({...a.createLinkPlugin(),renderAfterEditable:Fo,options:{isUrl:yt,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:t}})();class tn extends a.Plugin{styles={};appBridge;constructor({styles:e=I[it],...n}){super(it,{button:Oo,markupElement:new Uo,...n}),this.styles=e,this.appBridge=n.appBridge}plugins(){return[Re(this.appBridge)]}}const Ho="breakAfterColumn",en="normal";class zo extends a.Plugin{columns;gap;customClass;constructor(e){super("break-after-plugin",{button:a.ColumnBreakButton,...e}),this.columns=e?.columns??1,this.gap=e?.gap??en,this.customClass=Ye(this.columns)}plugins(){return[a.createColumnBreakPlugin(this.columns,this.gap,this.customClass)]}}const Vo="textstyle-custom1-plugin";class nn extends a.Plugin{styles={};constructor({styles:e=I.custom1,...n}={}){super(b.custom1,{label:"Custom 1",markupElement:new $o,...n}),this.styles=e}plugins(){return[Wo(this.styles)]}}class $o extends a.MarkupElement{constructor(e=Vo,n=on){super(e,n)}}const on=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,style:s,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),children:n})},Wo=t=>a.createPluginFactory({key:b.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:b.custom1}]}})({component:e=>o.jsx(on,{...e,styles:t})}),qo="textstyle-custom2-plugin";class an extends a.Plugin{styles={};constructor({styles:e=I.custom2,...n}={}){super(b.custom2,{label:"Custom 2",markupElement:new Go,...n}),this.styles=e}plugins(){return[Ko(this.styles)]}}class Go extends a.MarkupElement{constructor(e=qo,n=sn){super(e,n)}}const sn=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},Ko=t=>a.createPluginFactory({key:b.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:b.custom2}]}})({component:e=>o.jsx(sn,{...e,styles:t})}),jo="textstyle-custom3-plugin";class rn extends a.Plugin{styles={};constructor({styles:e=I.custom3,...n}={}){super(a.TextStyles.custom3,{label:"Custom 3",markupElement:new Yo,...n}),this.styles=e}plugins(){return[Qo(this.styles)]}}class Yo extends a.MarkupElement{constructor(e=jo,n=ln){super(e,n)}}const ln=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},Qo=t=>a.createPluginFactory({key:a.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:a.TextStyles.custom3}]}})({component:e=>o.jsx(ln,{...e,styles:t})}),Xo="textstyle-heading1-plugin";class dn extends a.Plugin{styles={};constructor({styles:e=I.heading1,...n}={}){super(b.heading1,{label:"Heading 1",markupElement:new Jo,...n}),this.styles=e}plugins(){return[Zo(this.styles)]}}class Jo extends a.MarkupElement{constructor(e=Xo,n=$t){super(e,n)}}const $t=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("h1",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},Zo=t=>a.createPluginFactory({key:b.heading1,isElement:!0,component:$t,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:e=>o.jsx($t,{...e,styles:t})}),Ro="textstyle-heading2-plugin";class cn extends a.Plugin{styles={};constructor({styles:e=I.heading2,...n}={}){super(b.heading2,{label:"Heading 2",markupElement:new ta,...n}),this.styles=e}plugins(){return[ea(this.styles)]}}class ta extends a.MarkupElement{constructor(e=Ro,n=Wt){super(e,n)}}const Wt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("h2",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},ea=t=>a.createPluginFactory({key:b.heading2,isElement:!0,component:Wt,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:e=>o.jsx(Wt,{...e,styles:t})}),na="textstyle-heading3-plugin";class un extends a.Plugin{styles={};constructor({styles:e=I.heading3,...n}={}){super(b.heading3,{label:"Heading 3",markupElement:new oa,...n}),this.styles=e}plugins(){return[aa(this.styles)]}}class oa extends a.MarkupElement{constructor(e=na,n=qt){super(e,n)}}const qt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("h3",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},aa=t=>a.createPluginFactory({key:b.heading3,isElement:!0,component:qt,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:e=>o.jsx(qt,{...e,styles:t})}),sa="textstyle-heading4-plugin";class gn extends a.Plugin{styles={};constructor({styles:e=I.heading4,...n}={}){super(b.heading4,{label:"Heading 4",markupElement:new ra,...n}),this.styles=e}plugins(){return[ia(this.styles)]}}class ra extends a.MarkupElement{constructor(e=sa,n=Gt){super(e,n)}}const Gt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("h4",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},ia=t=>a.createPluginFactory({key:b.heading4,isElement:!0,component:Gt,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:e=>o.jsx(Gt,{...e,styles:t})}),la="textstyle-imageCaption-plugin";class hn extends a.Plugin{styles={};constructor({styles:e=I.imageCaption,...n}={}){super(b.imageCaption,{label:"Image Caption",markupElement:new da,...n}),this.styles=e}plugins(){return[ca(this.styles)]}}class da extends a.MarkupElement{constructor(e=la,n=Kt){super(e,n)}}const Kt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},ca=t=>a.createPluginFactory({key:b.imageCaption,isElement:!0,component:Kt,deserializeHtml:{rules:[{validClassName:b.imageCaption}]}})({component:e=>o.jsx(Kt,{...e,styles:t})}),ua="textstyle-imageTitle-plugin";class mn extends a.Plugin{styles={};constructor({styles:e=I.imageTitle,...n}={}){super(b.imageTitle,{label:"Image Title",markupElement:new ga,...n}),this.styles=e}plugins(){return[ha(this.styles)]}}class ga extends a.MarkupElement{constructor(e=ua,n=jt){super(e,n)}}const jt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},ha=t=>a.createPluginFactory({key:b.imageTitle,isElement:!0,component:jt,deserializeHtml:{rules:[{validClassName:b.imageTitle}]}})({component:e=>o.jsx(jt,{...e,styles:t})});class fn extends a.Plugin{styles={};constructor({styles:e=I.p,...n}={}){super(b.p,{markupElement:new wn,label:"Body Text",...n}),this.styles=e}plugins(){return[yn(this.styles)]}}const pn="tw-m-0 tw-px-0 tw-py-0",Ct=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align,l=a.merge([r&&a.alignmentClassnames[r],pn,a.getColumnBreakClasses(t)]);return o.jsx("p",{...e,className:l,style:s,children:n})};class wn extends a.MarkupElement{constructor(e=b.p,n=Ct){super(e,n)}}const yn=t=>a.createPluginFactory({...a.createParagraphPlugin(),key:b.p,isElement:!0,component:Ct})({component:e=>o.jsx(Ct,{...e,styles:t})}),ma="textstyle-quote-plugin";class bn extends a.Plugin{styles={};constructor({styles:e=I.quote,...n}={}){super(b.quote,{label:"Quote",markupElement:new fa,...n}),this.styles=e}plugins(){return[vn(this.styles)]}}class fa extends a.MarkupElement{constructor(e=ma,n=kt){super(e,n)}}const kt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("blockquote",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},vn=t=>a.createPluginFactory({key:b.quote,isElement:!0,component:kt,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:e=>o.jsx(kt,{...e,styles:t})}),Yt=[new dn,new cn,new un,new gn,new nn,new an,new rn,new bn,new fn],lt=[b.heading1,b.heading2,b.heading3,b.heading4,b.custom1,b.custom2,b.custom3,b.quote,b.p],pa=[...Yt,new hn,new mn],wa=[...lt,b.imageCaption,b.imageTitle],ya=[{color:"var(--f-theme-settings-list-bullet1-color, currentColor)",shape:"var(--f-theme-settings-list-bullet1-shape, '•')",size:"var(--f-theme-settings-list-bullet1-size, 1em)"},{color:"var(--f-theme-settings-list-bullet2-color, currentColor)",shape:"var(--f-theme-settings-list-bullet2-shape, '•')",size:"var(--f-theme-settings-list-bullet2-size, 1em)"},{color:"var(--f-theme-settings-list-bullet3-color, currentColor)",shape:"var(--f-theme-settings-list-bullet3-shape, '•')",size:"var(--f-theme-settings-list-bullet3-size, 1em)"}];class Cn extends a.UnorderedListPlugin{constructor(e){super({listStyles:ya,...e})}}const ba=[{counterType:"var(--f-theme-settings-list-numbered1-counter-type, decimal)",color:"var(--f-theme-settings-list-numbered1-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered2-counter-type, lower-alpha)",color:"var(--f-theme-settings-list-numbered2-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered3-counter-type, lower-roman)",color:"var(--f-theme-settings-list-numbered3-color, currentColor)"}];class kn extends a.OrderedListPlugin{constructor(e){super({listStyles:ba,...e})}}const va=t=>new a.PluginComposer().setPlugin(new a.SoftBreakPlugin,new a.TextStylePlugin({textStyles:Yt})).setPlugin([new a.BoldPlugin,new a.ItalicPlugin,new a.UnderlinePlugin,new a.StrikethroughPlugin,new tn({appBridge:t}),new qe({appBridge:t}),new a.CodePlugin],[new a.AlignLeftPlugin({validTypes:lt}),new a.AlignCenterPlugin({validTypes:lt}),new a.AlignRightPlugin({validTypes:lt}),new a.AlignJustifyPlugin({validTypes:lt}),new Cn,new a.CheckboxListPlugin,new kn,new a.ResetFormattingPlugin,new a.AutoformatPlugin]),Ca="--f-theme-settings-",ka=t=>{const e=t?.id?`hasBackground${t.id}`:"hasBackground",n=t?.id?`backgroundColor${t.id}`:"backgroundColor",s=t?.preventDefaultColor?void 0:t?.defaultColor||On,r=t?.label?t.label:"Background",l=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:r,type:"switch",switchLabel:l,defaultValue:!!t?.defaultValue,on:[{id:n,defaultValue:s,type:"colorInput"}]}},Ta=t=>{const e=t?.id?`hasBorder_${t.id}`:"hasBorder",n=t?.id?`borderSelection_${t.id}`:"borderSelection",s=t?.id?`borderStyle_${t.id}`:"borderStyle",r=t?.id?`borderWidth_${t.id}`:"borderWidth",l=t?.id?`borderColor_${t.id}`:"borderColor",c=t?.defaultColor||ae,u=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:"Border",type:"switch",switchLabel:u,defaultValue:!!t?.defaultValue,on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:s,type:"dropdown",defaultValue:_.Solid,choices:[{value:_.Solid,label:_.Solid},{value:_.Dotted,label:_.Dotted},{value:_.Dashed,label:_.Dashed}]},{id:r,type:"input",defaultValue:_n,rules:[g.numericalOrPixelRule,g.minimumNumericalOrPixelRule(0),g.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px",onChange:d=>g.appendUnit(d,r)},{id:l,type:"colorInput",defaultValue:c}]}],off:[]}},Qt=(t,e=$.None)=>({id:t,type:"segmentedControls",defaultValue:e,choices:[{value:$.None,label:"None"},{value:$.Small,label:"S"},{value:$.Medium,label:"M"},{value:$.Large,label:"L"}]}),Pa=t=>{const e=t?.id?`hasRadius_${t.id}`:"hasRadius",n=t?.id?`radiusValue_${t.id}`:"radiusValue",s=t?.id?`radiusChoice_${t.id}`:"radiusChoice",r=t?.defaultRadius||$.None;return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:l=>t?.dependentSettingId?!!l.getBlock(t.dependentSettingId)?.value:!0,onChange:l=>g.presetCustomValue(l,s,n,t?.radiusStyleMap||j),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[g.numericalOrPixelRule,g.minimumNumericalOrPixelRule(0)],onChange:l=>g.appendUnit(l,n)}],off:[Qt(s,r)]}},xa=t=>{const e=t?.id?`hasExtendedCustomRadius_${t.id}`:"hasExtendedCustomRadius",n=t?.id?`extendedRadiusValue_${t.id}`:"extendedRadiusValue",s=t?.id?`extendedRadiusChoice_${t.id}`:"extendedRadiusChoice",r=t?.id?`extendedRadiusTopLeft_${t.id}`:"extendedRadiusTopLeft",l=t?.id?`extendedRadiusTopRight_${t.id}`:"extendedRadiusTopRight",c=t?.id?`extendedRadiusBottomLeft_${t.id}`:"extendedRadiusBottomLeft",u=t?.id?`extendedRadiusBottomRight_${t.id}`:"extendedRadiusBottomRight";return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:d=>t?.dependentSettingId?!!d.getBlock(t.dependentSettingId)?.value:!0,onChange:d=>{g.presetCustomValue(d,s,r,j),g.presetCustomValue(d,s,l,j),g.presetCustomValue(d,s,c,j),g.presetCustomValue(d,s,u,j)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,blocks:[{id:r,type:"input",label:"Top Left",rules:[g.numericalOrPixelRule],onChange:d=>g.appendUnit(d,r)},{id:l,type:"input",label:"Top Right",rules:[g.numericalOrPixelRule],onChange:d=>g.appendUnit(d,l)},{id:c,type:"input",label:"Bottom Left",rules:[g.numericalOrPixelRule],onChange:d=>g.appendUnit(d,c)},{id:u,type:"input",label:"Bottom Right",rules:[g.numericalOrPixelRule],onChange:d=>g.appendUnit(d,u)}]}],off:[Qt(s,t?.defaultValue)]}},Ea=t=>{const e=t?.id?t.id:"hasCustomSpacing",n=t?.dependentSettingId?t.dependentSettingId:"columns",s=t?.spacingChoiceId?t.spacingChoiceId:"spacingChoice",r=t?.spacingCustomId?t.spacingCustomId:"spacingCustom",l=t?.defaultValueChoices?t.defaultValueChoices:J.M;return{id:e,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:c=>g.presetCustomValue(c,s,r,re),show:c=>c.getBlock(n)?.value!=="1",on:[{id:r,type:"input",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,r)}],off:[{id:s,type:"slider",defaultValue:l,choices:[{value:J.Auto,label:"Auto"},{value:J.S,label:"S"},{value:J.M,label:"M"},{value:J.L,label:"L"}]}]}},Xt=t=>({id:t,type:"segmentedControls",defaultValue:Q.None,choices:[{value:Q.None,label:"None"},{value:Q.Small,label:"S"},{value:Q.Medium,label:"M"},{value:Q.Large,label:"L"}]}),Ia=t=>{const e=t?.id?`hasCustomMarginValue_${t?.id}`:"hasCustomMarginValue",n=t?.id?`marginValue_${t?.id}`:"marginValue",s=t?.id?`marginChoice_${t?.id}`:"marginChoice";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:r=>g.presetCustomValue(r,s,n,t?.marginStyleMap||nt),on:[{id:n,type:"input",placeholder:ct,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:r=>g.appendUnit(r,n)}],off:[Xt(s)]}},Sa=t=>{const e=t?.id?`hasExtendedCustomMargin_${t?.id}`:"hasExtendedCustomMargin",n=t?.id?`extendedMarginValues_${t?.id}`:"extendedMarginValues",s=t?.id?`extendedMarginChoice_${t?.id}`:"extendedMarginChoice",r=t?.id?`extendedMarginTop_${t?.id}`:"extendedMarginTop",l=t?.id?`extendedMarginLeft_${t?.id}`:"extendedMarginLeft",c=t?.id?`extendedMarginRight_${t?.id}`:"extendedMarginRight",u=t?.id?`extendedMarginBottom_${t?.id}`:"extendedMarginBottom";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:d=>{g.presetCustomValue(d,s,r,nt),g.presetCustomValue(d,s,l,nt),g.presetCustomValue(d,s,c,nt),g.presetCustomValue(d,s,u,nt)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:r,type:"input",label:"Top",placeholder:ct,onChange:d=>g.appendUnit(d,r),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:l,type:"input",label:"Left",placeholder:ct,onChange:d=>g.appendUnit(d,l),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:ct,onChange:d=>g.appendUnit(d,c),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:ct,onChange:d=>g.appendUnit(d,u),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Xt(s)]}},Jt=t=>({id:t,type:"segmentedControls",defaultValue:Y.Small,choices:[{value:Y.None,label:"None"},{value:Y.Small,label:"S"},{value:Y.Medium,label:"M"},{value:Y.Large,label:"L"}]}),Na=t=>{const e=t?.id?`hasCustomPaddingValue_${t?.id}`:"hasCustomPaddingValue",n=t?.id?`paddingValue_${t?.id}`:"paddingValue",s=t?.id?`paddingChoice_${t?.id}`:"paddingChoice";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:r=>g.presetCustomValue(r,s,n,t?.paddingStyleMap||et),on:[{id:n,type:"input",placeholder:dt,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:r=>g.appendUnit(r,n)}],off:[Jt(s)]}},Ba=t=>{const e=t?.id?`hasExtendedCustomPadding_${t?.id}`:"hasExtendedCustomPadding",n=t?.id?`extendedPaddingValues_${t?.id}`:"extendedPaddingValues",s=t?.id?`extendedPaddingChoice_${t?.id}`:"extendedPaddingChoice",r=t?.id?`extendedPaddingTop_${t?.id}`:"extendedPaddingTop",l=t?.id?`extendedPaddingLeft_${t?.id}`:"extendedPaddingLeft",c=t?.id?`extendedPaddingRight_${t?.id}`:"extendedPaddingRight",u=t?.id?`extendedPaddingBottom_${t?.id}`:"extendedPaddingBottom";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:d=>{g.presetCustomValue(d,s,r,et),g.presetCustomValue(d,s,l,et),g.presetCustomValue(d,s,c,et),g.presetCustomValue(d,s,u,et)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:r,type:"input",label:"Top",placeholder:dt,onChange:d=>g.appendUnit(d,r),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:l,type:"input",label:"Left",placeholder:dt,onChange:d=>g.appendUnit(d,l),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:dt,onChange:d=>g.appendUnit(d,c),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:dt,onChange:d=>g.appendUnit(d,u),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Jt(s)]}},La=t=>{const e=Zt(t?.globalControlId);return{id:t?.id?t.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>n.getBlock(e)?.value===X.Custom}},Zt=t=>t||"security",Aa=t=>[{id:Zt(t),type:"segmentedControls",defaultValue:X.Global,choices:[{value:X.Global,label:"Global Settings"},{value:X.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:g.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Tn=(t=>(t.Main="main",t.Basics="basics",t.Layout="layout",t.Style="style",t.Security="security",t.Targets="targets",t))(Tn||{});const Da=t=>t,Ma=t=>t;i.AllTextStylePlugins=pa,i.AllTextStyles=wa,i.AttachmentOperationsProvider=zn,i.Attachments=fe,i.AttachmentsProvider=ue,i.AttachmentsToolbarButton=ye,i.BUTTON_PLUGIN=$e,i.BlockButtonStyles=vt,i.BlockInjectButton=In,i.BlockItemWrapper=Ee,i.BlockStyles=I,i.BorderStyle=_,i.BreakAfterPlugin=zo,i.ButtonPlugin=qe,i.Custom1Plugin=nn,i.Custom2Plugin=an,i.Custom3Plugin=rn,i.DEFAULT_ATTACHMENTS_BUTTON_ID=we,i.DEFAULT_DRAGGING_TOOLTIP=ve,i.DEFAULT_DRAG_TOOLTIP=be,i.DEFAULT_MENU_BUTTON_ID=Lt,i.DragHandleToolbarButton=Ce,i.DragPreviewContextProvider=ie,i.ELEMENT_BUTTON=E,i.FlyoutToolbarButton=ke,i.GAP_DEFAULT=en,i.GutterSpacing=J,i.Heading1Plugin=dn,i.Heading2Plugin=cn,i.Heading3Plugin=un,i.Heading4Plugin=gn,i.ImageCaptionPlugin=hn,i.ImageTitlePlugin=mn,i.KEY_ELEMENT_BREAK_AFTER_COLUMN=Ho,i.LinkInput=He,i.LinkPlugin=tn,i.LinkSelector=Ue,i.Margin=Q,i.MenuToolbarButton=Te,i.MultiFlyoutContextProvider=le,i.OrderedListPlugin=kn,i.PARAGRAPH_CLASSES=pn,i.Padding=Y,i.ParagraphMarkupElement=wn,i.ParagraphMarkupElementNode=Ct,i.ParagraphPlugin=fn,i.QuoteMarkupElementNode=kt,i.QuotePlugin=bn,i.Radius=$,i.RichTextEditor=Io,i.Sections=Tn,i.Security=X,i.THEME_PREFIX=Ca,i.TextStylePluginsWithoutImage=Yt,i.TextStyles=b,i.TextStylesWithoutImage=lt,i.Toolbar=xe,i.UnorderedListPlugin=Cn,i.addHttps=wt,i.borderStyleMap=se,i.convertToRteValue=Yn,i.createButtonNode=De,i.createButtonPlugin=We,i.createLinkPlugin=Re,i.createParagraphPlugin=yn,i.createQuotePlugin=vn,i.defineBlock=Da,i.defineSettings=Ma,i.getBackgroundColorStyles=Fn,i.getBackgroundSettings=ka,i.getBorderRadiusSettings=Pa,i.getBorderRadiusSlider=Qt,i.getBorderSettings=Ta,i.getBorderStyles=Un,i.getDefaultPluginsWithLinkChooser=va,i.getExtendedBorderRadiusSettings=xa,i.getGutterSettings=Ea,i.getLegacyUrl=Xn,i.getLinkFromEditor=Zn,i.getMarginExtendedSettings=Sa,i.getMarginSettings=Ia,i.getMarginSlider=Xt,i.getPaddingExtendedSettings=Ba,i.getPaddingSettings=Na,i.getPaddingSlider=Jt,i.getRadiusStyles=Hn,i.getReadableColor=Mn,i.getSecurityDownloadableSetting=La,i.getSecurityGlobalControlId=Zt,i.getSecurityGlobalControlSetting=Aa,i.getUrl=Jn,i.getUrlFromEditor=Ae,i.getUrlFromLinkOrLegacyLink=Mt,i.gutterSpacingStyleMap=re,i.hasRichTextValue=Ie,i.insertButton=Ne,i.isDark=Nn,i.isDownloadable=Qn,i.isValidUrl=yt,i.isValidUrlOrEmpty=st,i.joinClassNames=V,i.marginStyleMap=nt,i.paddingStyleMap=et,i.radiusStyleMap=j,i.relativeUrlRegex=Ft,i.setAlpha=An,i.submitFloatingButton=Ot,i.toColorObject=Dn,i.toHex8String=Bn,i.toHexString=Ln,i.toRgbaString=Et,i.toShortRgba=K,i.triggerFloatingButton=Me,i.triggerFloatingButtonEdit=bt,i.triggerFloatingButtonInsert=Ut,i.unwrapButton=rt,i.upsertButton=Be,i.upsertButtonText=_t,i.useAttachmentOperations=Nt,i.useAttachments=ce,i.useAttachmentsContext=ge,i.useDragPreviewContext=ot,i.useMultiFlyoutContext=de,i.useMultiFlyoutState=ft,i.withAttachmentsProvider=Vn,i.withButton=Se,i.wrapButton=Le,Object.keys(g).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:()=>g[t]})}),Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
7
|
+
${w?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover ":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container "}`,onClick:()=>n(t.permanentLink),children:o.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[y&&o.jsx("button",{type:"button",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!l),onKeyDown:f=>f.key==="Enter"&&f.stopPropagation(),children:o.jsx("div",{className:`tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong
|
|
8
|
+
${l?"tw-rotate-90 ":""}`})}),o.jsx("span",{className:"tw-text-small",children:t.title}),o.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Page"})]},t.id)}),l&&u.length>0&&u.map(f=>o.jsx(co,{section:f,selectedUrl:e,onSelectUrl:n},f.id))]})},go=({documentId:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r,getDocumentPagesByDocumentId:l})=>{const[c,u]=g.useState([]),[d,w]=g.useState(!0),y=[...c.values()],f=!d&&y.length>0;return g.useEffect(()=>{l(t).then(p=>{const C=p.filter(x=>!!x.category).sort((x,A)=>x.category.sort===A.category.sort?x.sort-A.sort:x.category.sort-A.category.sort),v=p.filter(x=>!x.category).sort((x,A)=>x.sort-A.sort);u([...C,...v])}).finally(()=>{w(!1)})},[]),d?o.jsx(Ue,{}):f?o.jsx(o.Fragment,{children:y.map(p=>o.jsx(uo,{page:p,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r},p.id))}):o.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-small tw-text-secondary",children:"This document does not contain any pages."})},ho=({document:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r,getDocumentPagesByDocumentId:l})=>{const[c,u]=g.useState(t.id===s.documentId),d=t.permanentLink===e;return g.useEffect(()=>{t.id===s.documentId&&u(!0)},[s,t.id]),o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button","data-test-id":"internal-link-selector-document-link",className:`tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-w-full ${d?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:[o.jsx("button",{type:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>u(!c),onKeyDown:w=>w.key==="Enter"&&w.stopPropagation(),children:o.jsx("div",{className:`tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong ${c?"tw-rotate-90":""}`})}),o.jsx(P.IconColorFan,{size:16}),o.jsx("span",{className:"tw-text-small",children:t.title}),o.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Document"})]}),c&&o.jsx(go,{documentId:t.id,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:r,getDocumentPagesByDocumentId:l})]})},mo=({selectedUrl:t,onSelectUrl:e,getAllDocuments:n,getDocumentPagesByDocumentId:s,getDocumentSectionsByDocumentPageId:r})=>{const[l,c]=g.useState(!0),[u,d]=g.useState([]),[w,y]=g.useState({documentId:void 0,pageId:void 0});g.useEffect(()=>{t&&u.length>0&&f().then(p=>{y(p)})},[u.length]),g.useEffect(()=>{n().then(p=>{d(p)}).finally(()=>{c(!1)})},[]);const f=async()=>{const p={documentId:void 0,pageId:void 0};if(u.find(v=>v.permanentLink===t))return p;for(const v of u){const x=await s(v.id);if(!!x.find(L=>L.permanentLink===t))return p.documentId=v.id,p;for(const L of x){const D=await r(L.id);if(!!_e(D).find(rt=>rt.permanentLink===t))return p.documentId=v.id,p.pageId=L.id,p}}return p};return l?o.jsx(Ue,{}):o.jsx(o.Fragment,{children:u.map(p=>o.jsx(ho,{document:p,selectedUrl:t,onSelectUrl:e,itemsToExpandInitially:w,getDocumentSectionsByDocumentPageId:r,getDocumentPagesByDocumentId:s},p.id))})},He=({url:t,onUrlChange:e,buttonSize:n="medium",getAllDocuments:s,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:l})=>{const[c,u]=g.useState(!1),[d,w]=g.useState(t),y=v=>{w(v)},f=v=>{v.key==="Enter"&&(v.preventDefault(),p())};g.useEffect(()=>{t&&!d&&w(t)},[t,d]);const p=()=>{e?.(d),u(!1)},C={onOpenAutoFocus:()=>{},showUnderlay:!0,"data-is-underlay":!0,minWidth:"800px"};return o.jsx("div",{onPointerDown:v=>{v.preventDefault()},"data-test-id":"internal-link-selector",onKeyDown:f,children:o.jsxs(m.Dialog.Root,{modal:!0,open:c,onOpenChange:u,children:[o.jsx(m.Dialog.Trigger,{asChild:!0,children:o.jsxs(m.Button,{size:n,emphasis:"default",children:[o.jsx(P.IconLink,{size:"20"}),"Internal link"]})}),o.jsxs(m.Dialog.Content,{...C,children:[o.jsx(m.Dialog.Header,{children:o.jsx(m.Dialog.Title,{children:"Select internal link"})}),o.jsx(m.Dialog.Body,{padding:"none",children:o.jsx(m.ScrollArea,{padding:"compact",children:o.jsx(mo,{selectedUrl:d,onSelectUrl:y,getAllDocuments:s,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:l})})}),o.jsxs(m.Dialog.Footer,{children:[o.jsx(m.Button,{size:n,emphasis:"default",onPress:()=>u(!1),children:"Cancel"}),o.jsx(m.Button,{size:n,disabled:!d,emphasis:"strong",onPress:()=>p(),children:"Choose"})]})]})]})})},ze=({onUrlChange:t,onToggleTab:e,isValidUrlOrEmpty:n,appBridge:s,placeholder:r,newTab:l,url:c="",required:u,info:d,label:w,buttonSize:y,hideInternalLinkButton:f})=>{const p=n?n(c):nt(c);return o.jsxs("div",{"data-test-id":"link-input",children:[o.jsx(mt.FormControl,{label:{children:w,htmlFor:"url",required:u,tooltip:d?{content:d,position:"top"}:void 0},children:o.jsx(m.TextInput,{"data-test-id":"text-input",id:"url",value:c,onChange:C=>t?.(C.target.value),placeholder:r??"https://example.com"})}),!p&&o.jsx("div",{className:"tw-text-error tw-mt-1 tw-text-small",children:"Please enter a valid URL."}),!f&&o.jsx("div",{className:"tw-mt-3",children:o.jsx(He,{url:c,onUrlChange:t,buttonSize:y??"medium",getAllDocuments:()=>s.getAllDocuments(),getDocumentPagesByDocumentId:C=>s.getDocumentPagesByDocumentId(C),getDocumentSectionsByDocumentPageId:C=>s.getDocumentSectionsByDocumentPageId(C)})}),o.jsxs("div",{className:"tw-mt-3 tw-flex tw-items-center tw-gap-1.5",children:[o.jsx(m.Checkbox,{id:"new-tab",value:l,onChange:()=>e?.(!l)}),o.jsx(m.Label,{id:"new-tab-label",htmlFor:"new-tab",className:"tw-whitespace-nowrap",children:"Open in new tab"})]})]})},Ve=({state:t,onTextChange:e,onUrlChange:n,onToggleTab:s,onCancel:r,onSave:l,isValidUrlOrEmpty:c,hasValues:u,testId:d,appBridge:w,children:y})=>o.jsxs(a.FloatingModalWrapper,{"data-test-id":d,padding:"28px",minWidth:"400px",children:[o.jsx(mt.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:o.jsx(m.TextInput,{id:"linkText",value:t.text,placeholder:"Link Text",onChange:f=>e(f.target.value)})}),y,o.jsx("div",{className:"tw-mt-5",children:o.jsx(ze,{url:t.url,newTab:t.newTab,onUrlChange:n,onToggleTab:s,isValidUrlOrEmpty:c,appBridge:w})}),o.jsx("div",{className:"tw-mt-3",children:o.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[o.jsx(m.Button,{"data-test-id":"button",onPress:r,size:"medium",emphasis:"default",children:"Cancel"}),o.jsxs(m.Button,{"data-test-id":"button",onPress:l,size:"medium",disabled:!c(t?.url)||!u,children:[o.jsx(P.IconCheckMark,{size:"20"}),"Save"]})]})})]}),fo=t=>{const e=a.getAboveNode(t,{match:{type:I}});return Array.isArray(e)&&e[0]?.buttonStyle||"primary"},po={url:"",text:"",buttonStyle:"primary",newTab:!1},wo=()=>{const[t,e]=g.useReducer((n,s)=>{const{type:r,payload:l}=s;switch(r){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...l};default:return n}},po);return[t,e]},yo=()=>{const t=a.useEditorRef(),[e,n]=wo();g.useEffect(()=>{const f=fo(t);n({type:"INIT",payload:{text:B.text()||B.url(),buttonStyle:f,newTab:!!B.newTab(),url:B.url()}})},[n,t]);const s=f=>{n({type:"TEXT",payload:{text:f}})},r=f=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:f}})},l=f=>{n({type:"URL",payload:{url:f}})},c=f=>{n(f?{type:"NEW_TAB"}:{type:"SAME_TAB"})},u=()=>{S.reset()},d=f=>{if(!nt(e.url)||!w)return;const p=yt(e.url);S.text(e.text),S.url(p),S.buttonStyle(e.buttonStyle),S.newTab(e.newTab),Ut(t)&&f?.preventDefault()},w=e.url!==""&&e.text!=="",{appBridge:y}=a.getPluginOptions(t,I);return a.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:s,onButtonStyleChange:r,onUrlChange:l,onToggleTab:c,onCancel:u,onSave:d,hasValues:w,isValidUrlOrEmpty:nt,appBridge:y}},bo=()=>{const t=yo(),{state:e,onButtonStyleChange:n}=t;return o.jsx(Ve,{...t,testId:"floating-button-insert",children:o.jsx("div",{className:"tw-pt-5",children:o.jsxs(mt.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[o.jsx($t,{id:"primary",styles:E.buttonPrimary,isActive:e.buttonStyle==="primary",onClick:()=>n("primary"),children:e.text||"Primary Button"}),o.jsx($t,{id:"secondary",styles:E.buttonSecondary,isActive:e.buttonStyle==="secondary",onClick:()=>n("secondary"),children:e.text||"Secondary Button"}),o.jsx($t,{id:"tertiary",styles:E.buttonTertiary,isActive:e.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:e.text||"Tertiary Button"})]})})})},$t=({id:t,styles:e,isActive:n,onClick:s,children:r})=>{const[l,c]=g.useState(!1),u=()=>e&&e.hover&&l?{...e,...e.hover}:e;return o.jsx("button",{"data-test-id":`floating-button-insert-${t}`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:s,style:{...u(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:r})},$e={placement:"bottom-start",strategy:"absolute",middleware:[a.offset(12),a.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},vo=()=>{const{ref:t,...e}=To($e),{ref:n,...s}=Co($e),r=a.useEditorRef(),l=ut(),c=l.isOpen(r.id),u=l.isEditing(),d=l.mode(),w=o.jsx(bo,{}),y=u?w:o.jsx(lo,{});return o.jsxs(o.Fragment,{children:[c&&d==="insert"&&ft.createPortal(o.jsx("div",{"data-is-underlay":!0,ref:t,...e,style:{...e.style,...E[a.TextStyles.p]},children:w}),document.body),c&&d==="edit"&&ft.createPortal(o.jsx("div",{"data-is-underlay":!0,ref:n,...s,style:{...s.style,...E[a.TextStyles.p]},children:y}),document.body)]})},I="button",We="button-plugin",qe=t=>a.createPluginFactory({key:I,isElement:!0,isInline:!0,props:({element:e})=>({nodeProps:{href:e?.url,target:e?.target}}),withOverrides:Be,renderAfterEditable:vo,options:{isUrl:bt,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:t},then:(e,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:s=>({type:n,url:s.getAttribute("href"),target:s.getAttribute("target")||"_blank"})}})})();class Ge extends a.Plugin{styles={};appBridge;constructor({styles:e=Ct,...n}){super(We,{button:io,markupElement:new ro,...n}),this.styles=e,this.appBridge=n?.appBridge}plugins(){return[qe(this.appBridge)]}}const Co=t=>{const e=a.useEditorRef(),n=ut().mode(),s=ut().isOpen(e.id),r=a.useEditorVersion(),{triggerFloatingButtonHotkeys:l}=a.getPluginOptions(e,I),c=g.useCallback(()=>{const f=a.getAboveNode(e,{match:{type:a.getPluginType(e,I)}});if(f){const[,p]=f;return a.getRangeBoundingClientRect(e,{anchor:a.getStartPoint(e,p),focus:a.getEndPoint(e,p)})}return a.getDefaultBoundingClientRect()},[e]),u=s&&n==="edit",{update:d,style:w,floating:y}=je({open:u,getBoundingClientRect:c,...t});return g.useEffect(()=>{const f=De(e);if(f&&S.url(f),e.selection&&a.someNode(e,{match:{type:a.getPluginType(e,I)}})){S.show("edit",e.id),d();return}B.mode()==="edit"&&S.reset()},[e,r,d]),a.useHotkeys(l,f=>{f.preventDefault(),B.mode()==="edit"&&vt(e)},{enableOnContentEditable:!0},[]),ko(),Ke(),{style:w,ref:a.useComposedRef(y)}},ko=()=>{const t=a.useEditorRef();a.useHotkeys("*",e=>{e.key==="Enter"&&Ut(t)&&e.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Ke=()=>{const t=a.useEditorRef();a.useHotkeys("escape",()=>{if(B.mode()==="edit"){if(B.isEditing()){S.show("edit",t.id),a.focusEditor(t,t.selection??void 0);return}S.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},To=t=>{const e=a.useEditorRef(),n=a.useFocused(),s=ut().mode(),r=ut().isOpen(e.id),{triggerFloatingButtonHotkeys:l}=a.getPluginOptions(e,I);a.useHotkeys(l,w=>{w.preventDefault(),zt(e,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:c,style:u,floating:d}=je({open:r&&s==="insert",getBoundingClientRect:a.getSelectionBoundingClientRect,whileElementsMounted:void 0,...t});return g.useEffect(()=>{r&&c(),S.updated(r)},[r,c]),Ke(),{style:u,ref:a.useComposedRef(d)}},Po=12,xo=-22,Io=96,je=t=>a.useVirtualFloating({placement:"bottom-start",middleware:[a.offset({mainAxis:Po,alignmentAxis:xo}),a.flip({padding:Io})],...t}),Wt="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @md:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @md:[&_.tw-break-after-column]:!tw-break-after-column @md:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",Ye={1:"tw-columns-1",2:"tw-columns-1 @sm:!tw-columns-2 [&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @sm:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @sm:[&_.tw-break-after-column]:!tw-break-after-column @sm:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",3:`tw-columns-1 @md:!tw-columns-3 ${Wt}`,4:`tw-columns-1 @md:!tw-columns-4 ${Wt}`,5:`tw-columns-1 @md:!tw-columns-5 ${Wt}`},Qe=t=>t?Ye[t]||Ye[1]:"",Eo=t=>{B.isOpen(t)&&S.reset()},Xe=g.memo(({isEnabled:t,value:e,columns:n,gap:s,placeholder:r,plugins:l,onTextChange:c,showSerializedText:u})=>{const d=Qe(n),[w,y]=g.useState(!1),f=g.useId(),p=g.useCallback(v=>{v!==e&&c?.(v),y(!1)},[c,e]),C=g.useCallback(()=>y(!0),[]);return g.useEffect(()=>{const v=x=>{x.preventDefault(),x.returnValue="Unprocessed changes"};return w&&window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[w]),t?o.jsx(a.RichTextEditor,{id:f,value:e,border:!1,placeholder:r,plugins:l,onValueChanged:C,onTextChange:p,hideExternalFloatingModals:Eo,placeholderOpacity:"high"}):o.jsx(Yn,{value:e,gap:s,customClass:d,show:u,plugins:l})});Xe.displayName="InternalRichTextEditor";const So=t=>{const e=g.useRef(null),[n,s]=g.useState(!1),{isEditing:r,...l}=t,c=g.useCallback(u=>{u&&s(!0)},[]);return jn({ref:e,disabled:!r,onChange:c}),g.useEffect(()=>{r||s(!1)},[r]),o.jsx("div",{"data-test-id":"rich-text-editor-container",className:"tw-block tw-w-full tw-@container",ref:e,children:o.jsx(Xe,{...l,isEnabled:r&&n})})},Bo=({editButtonProps:t,unlinkButtonProps:e})=>{const{element:n}=a.useLinkOpenButtonState(),s=n?Ot(n):"";return o.jsx(a.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:o.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[o.jsx("a",{"data-test-id":"floating-link-edit-url",href:s,target:"_blank",rel:"noopener noreferrer",style:E[at],className:"tw-break-all",children:s}),o.jsxs("span",{className:"tw-flex tw-gap-2",children:[o.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...t,children:o.jsx(P.IconPen,{size:16})}),o.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...e,children:o.jsx(P.IconTrashBin,{size:16})})]})]})})},Je=(t,e)=>{const n=a.getAboveNode(t,{match:{type:a.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},No=t=>Je(t,e=>e.chosenLink?.searchResult?.link||""),Ao=t=>Je(t,e=>e.url||""),Lo={url:"",text:"",newTab:!1},Do=()=>{const[t,e]=g.useReducer((n,s)=>{const{type:r,payload:l}=s;switch(r){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"INIT":return{...n,...l};default:return n}},Lo);return[t,e]},Mo=()=>{const t=a.useEditorRef(),[e,n]=Do();g.useEffect(()=>{const y=No(t),f=Ao(t),p=a.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:a.floatingLinkSelectors.text()||a.floatingLinkSelectors.url(),newTab:p,url:y&&f===""?y:a.floatingLinkSelectors.url()}})},[n,t]);const s=y=>{n({type:"TEXT",payload:{text:y}})},r=y=>{n({type:"URL",payload:{url:y}})},l=y=>{n(y?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{a.floatingLinkActions.reset()},u=y=>{!nt(e.url)||!d||(a.floatingLinkActions.text(e.text),a.floatingLinkActions.url(yt(e.url)),a.floatingLinkActions.newTab(e.newTab),a.submitFloatingLink(t)&&y?.preventDefault())},d=e.url!==""&&e.text!=="",{appBridge:w}=a.getPluginOptions(t,a.ELEMENT_LINK);return a.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:s,onUrlChange:r,onToggleTab:l,onCancel:c,onSave:u,hasValues:d,isValidUrlOrEmpty:nt,appBridge:w}},Fo=()=>o.jsx(Ve,{...Mo(),testId:"floating-link-insert"}),Ze={placement:"bottom-start",strategy:"absolute",middleware:[a.offset(12),a.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Oo=()=>{const t=a.useFloatingLinkInsertState({floatingOptions:Ze}),{props:e,ref:n,hidden:s}=a.useFloatingLinkInsert(t),r=a.useFloatingLinkEditState({floatingOptions:Ze}),{props:l,ref:c,editButtonProps:u,unlinkButtonProps:d}=a.useFloatingLinkEdit(r);if(s)return null;const w=o.jsx(Fo,{}),y=r.isEditing?w:o.jsx(Bo,{editButtonProps:u,unlinkButtonProps:d});return o.jsxs(o.Fragment,{children:[t.isOpen&&!r.isOpen&&ft.createPortal(o.jsx("div",{"data-is-underlay":!0,ref:n,...e,style:{...e.style,...E[b.p]},children:w}),document.body),r.isOpen&&ft.createPortal(o.jsx("div",{"data-is-underlay":!0,ref:c,...l,style:{...l.style,...E[b.p]},children:y}),document.body)]})},Re=g.forwardRef((t,e)=>{const n=a.useEditorRef(),s=a.useLinkToolbarButtonState(),{props:r}=a.useLinkToolbarButton(s);return o.jsx(a.ToolbarButton,{onMouseDown:l=>{l.preventDefault(),a.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:e,...r,...t,children:o.jsx(a.IconStylingWrapper,{icon:o.jsx(P.IconLink,{size:16})})})});Re.displayName="LinkToolbarButton";const _o=({id:t,editorId:e})=>{const n=a.useEditorState(a.useEventPlateId(e)),s=!!a.isRangeInSameBlock(n,{at:n.selection});return o.jsx("div",{"data-plugin-id":t,children:o.jsx(Re,{disabled:!s,tooltip:a.getTooltip(s?`Link
|
|
9
|
+
${a.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},Uo=t=>{const{attributes:e,children:n}=t,{styles:s}=a.useRichTextEditorContext(),r=t.element.url||t.element.chosenLink?.searchResult?.link||"",l=t.element.target||"_self";return o.jsx("a",{...e,href:r,target:l,style:s[at],children:n})};class Ho extends a.MarkupElement{constructor(e=a.ELEMENT_LINK,n=Uo){super(e,n)}}const tn=t=>a.createPluginFactory({...a.createLinkPlugin(),renderAfterEditable:Oo,options:{isUrl:bt,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:t}})();class en extends a.Plugin{styles={};appBridge;constructor({styles:e=E[at],...n}){super(at,{button:_o,markupElement:new Ho,...n}),this.styles=e,this.appBridge=n.appBridge}plugins(){return[tn(this.appBridge)]}}const zo="breakAfterColumn",nn="normal";class Vo extends a.Plugin{columns;gap;customClass;constructor(e){super("break-after-plugin",{button:a.ColumnBreakButton,...e}),this.columns=e?.columns??1,this.gap=e?.gap??nn,this.customClass=Qe(this.columns)}plugins(){return[a.createColumnBreakPlugin(this.columns,this.gap,this.customClass)]}}const $o="textstyle-custom1-plugin";class on extends a.Plugin{styles={};constructor({styles:e=E.custom1,...n}={}){super(b.custom1,{label:"Custom 1",markupElement:new Wo,...n}),this.styles=e}plugins(){return[qo(this.styles)]}}class Wo extends a.MarkupElement{constructor(e=$o,n=an){super(e,n)}}const an=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,style:s,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),children:n})},qo=t=>a.createPluginFactory({key:b.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:b.custom1}]}})({component:e=>o.jsx(an,{...e,styles:t})}),Go="textstyle-custom2-plugin";class sn extends a.Plugin{styles={};constructor({styles:e=E.custom2,...n}={}){super(b.custom2,{label:"Custom 2",markupElement:new Ko,...n}),this.styles=e}plugins(){return[jo(this.styles)]}}class Ko extends a.MarkupElement{constructor(e=Go,n=rn){super(e,n)}}const rn=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},jo=t=>a.createPluginFactory({key:b.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:b.custom2}]}})({component:e=>o.jsx(rn,{...e,styles:t})}),Yo="textstyle-custom3-plugin";class ln extends a.Plugin{styles={};constructor({styles:e=E.custom3,...n}={}){super(a.TextStyles.custom3,{label:"Custom 3",markupElement:new Qo,...n}),this.styles=e}plugins(){return[Xo(this.styles)]}}class Qo extends a.MarkupElement{constructor(e=Yo,n=dn){super(e,n)}}const dn=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},Xo=t=>a.createPluginFactory({key:a.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:a.TextStyles.custom3}]}})({component:e=>o.jsx(dn,{...e,styles:t})}),Jo="textstyle-heading1-plugin";class cn extends a.Plugin{styles={};constructor({styles:e=E.heading1,...n}={}){super(b.heading1,{label:"Heading 1",markupElement:new Zo,...n}),this.styles=e}plugins(){return[Ro(this.styles)]}}class Zo extends a.MarkupElement{constructor(e=Jo,n=qt){super(e,n)}}const qt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("h1",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},Ro=t=>a.createPluginFactory({key:b.heading1,isElement:!0,component:qt,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:e=>o.jsx(qt,{...e,styles:t})}),ta="textstyle-heading2-plugin";class un extends a.Plugin{styles={};constructor({styles:e=E.heading2,...n}={}){super(b.heading2,{label:"Heading 2",markupElement:new ea,...n}),this.styles=e}plugins(){return[na(this.styles)]}}class ea extends a.MarkupElement{constructor(e=ta,n=Gt){super(e,n)}}const Gt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("h2",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},na=t=>a.createPluginFactory({key:b.heading2,isElement:!0,component:Gt,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:e=>o.jsx(Gt,{...e,styles:t})}),oa="textstyle-heading3-plugin";class gn extends a.Plugin{styles={};constructor({styles:e=E.heading3,...n}={}){super(b.heading3,{label:"Heading 3",markupElement:new aa,...n}),this.styles=e}plugins(){return[sa(this.styles)]}}class aa extends a.MarkupElement{constructor(e=oa,n=Kt){super(e,n)}}const Kt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("h3",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},sa=t=>a.createPluginFactory({key:b.heading3,isElement:!0,component:Kt,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:e=>o.jsx(Kt,{...e,styles:t})}),ra="textstyle-heading4-plugin";class hn extends a.Plugin{styles={};constructor({styles:e=E.heading4,...n}={}){super(b.heading4,{label:"Heading 4",markupElement:new ia,...n}),this.styles=e}plugins(){return[la(this.styles)]}}class ia extends a.MarkupElement{constructor(e=ra,n=jt){super(e,n)}}const jt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("h4",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},la=t=>a.createPluginFactory({key:b.heading4,isElement:!0,component:jt,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:e=>o.jsx(jt,{...e,styles:t})}),da="textstyle-imageCaption-plugin";class mn extends a.Plugin{styles={};constructor({styles:e=E.imageCaption,...n}={}){super(b.imageCaption,{label:"Image Caption",markupElement:new ca,...n}),this.styles=e}plugins(){return[ua(this.styles)]}}class ca extends a.MarkupElement{constructor(e=da,n=Yt){super(e,n)}}const Yt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},ua=t=>a.createPluginFactory({key:b.imageCaption,isElement:!0,component:Yt,deserializeHtml:{rules:[{validClassName:b.imageCaption}]}})({component:e=>o.jsx(Yt,{...e,styles:t})}),ga="textstyle-imageTitle-plugin";class fn extends a.Plugin{styles={};constructor({styles:e=E.imageTitle,...n}={}){super(b.imageTitle,{label:"Image Title",markupElement:new ha,...n}),this.styles=e}plugins(){return[ma(this.styles)]}}class ha extends a.MarkupElement{constructor(e=ga,n=Qt){super(e,n)}}const Qt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("p",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},ma=t=>a.createPluginFactory({key:b.imageTitle,isElement:!0,component:Qt,deserializeHtml:{rules:[{validClassName:b.imageTitle}]}})({component:e=>o.jsx(Qt,{...e,styles:t})});class pn extends a.Plugin{styles={};constructor({styles:e=E.p,...n}={}){super(b.p,{markupElement:new yn,label:"Body Text",...n}),this.styles=e}plugins(){return[bn(this.styles)]}}const wn="tw-m-0 tw-px-0 tw-py-0",kt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align,l=a.merge([r&&a.alignmentClassnames[r],wn,a.getColumnBreakClasses(t)]);return o.jsx("p",{...e,className:l,style:s,children:n})};class yn extends a.MarkupElement{constructor(e=b.p,n=kt){super(e,n)}}const bn=t=>a.createPluginFactory({...a.createParagraphPlugin(),key:b.p,isElement:!0,component:kt})({component:e=>o.jsx(kt,{...e,styles:t})}),fa="textstyle-quote-plugin";class vn extends a.Plugin{styles={};constructor({styles:e=E.quote,...n}={}){super(b.quote,{label:"Quote",markupElement:new pa,...n}),this.styles=e}plugins(){return[Cn(this.styles)]}}class pa extends a.MarkupElement{constructor(e=fa,n=Tt){super(e,n)}}const Tt=({element:t,attributes:e,children:n,styles:s})=>{const r=t.align;return o.jsx("blockquote",{...e,className:a.merge([r&&a.alignmentClassnames[r],a.getColumnBreakClasses(t)]),style:s,children:n})},Cn=t=>a.createPluginFactory({key:b.quote,isElement:!0,component:Tt,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:e=>o.jsx(Tt,{...e,styles:t})}),Xt=[new cn,new un,new gn,new hn,new on,new sn,new ln,new vn,new pn],st=[b.heading1,b.heading2,b.heading3,b.heading4,b.custom1,b.custom2,b.custom3,b.quote,b.p],wa=[...Xt,new mn,new fn],ya=[...st,b.imageCaption,b.imageTitle],ba=[{color:"var(--f-theme-settings-list-bullet1-color, currentColor)",shape:"var(--f-theme-settings-list-bullet1-shape, '•')",size:"var(--f-theme-settings-list-bullet1-size, 1em)"},{color:"var(--f-theme-settings-list-bullet2-color, currentColor)",shape:"var(--f-theme-settings-list-bullet2-shape, '•')",size:"var(--f-theme-settings-list-bullet2-size, 1em)"},{color:"var(--f-theme-settings-list-bullet3-color, currentColor)",shape:"var(--f-theme-settings-list-bullet3-shape, '•')",size:"var(--f-theme-settings-list-bullet3-size, 1em)"}];class kn extends a.UnorderedListPlugin{constructor(e){super({listStyles:ba,...e})}}const va=[{counterType:"var(--f-theme-settings-list-numbered1-counter-type, decimal)",color:"var(--f-theme-settings-list-numbered1-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered2-counter-type, lower-alpha)",color:"var(--f-theme-settings-list-numbered2-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered3-counter-type, lower-roman)",color:"var(--f-theme-settings-list-numbered3-color, currentColor)"}];class Tn extends a.OrderedListPlugin{constructor(e){super({listStyles:va,...e})}}const Ca=t=>new a.PluginComposer().setPlugin(new a.SoftBreakPlugin,new a.TextStylePlugin({textStyles:Xt})).setPlugin([new a.BoldPlugin,new a.ItalicPlugin,new a.UnderlinePlugin,new a.StrikethroughPlugin,new en({appBridge:t}),new Ge({appBridge:t}),new a.CodePlugin],[new a.AlignLeftPlugin({validTypes:st}),new a.AlignCenterPlugin({validTypes:st}),new a.AlignRightPlugin({validTypes:st}),new a.AlignJustifyPlugin({validTypes:st}),new kn,new a.CheckboxListPlugin,new Tn,new a.ResetFormattingPlugin,new a.AutoformatPlugin]),ka="--f-theme-settings-",Ta=t=>{const e=t?.id?`hasBackground${t.id}`:"hasBackground",n=t?.id?`backgroundColor${t.id}`:"backgroundColor",s=t?.preventDefaultColor?void 0:t?.defaultColor||_n,r=t?.label?t.label:"Background",l=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:r,type:"switch",switchLabel:l,defaultValue:!!t?.defaultValue,on:[{id:n,defaultValue:s,type:"colorInput"}]}},Pa=t=>{const e=t?.id?`hasBorder_${t.id}`:"hasBorder",n=t?.id?`borderSelection_${t.id}`:"borderSelection",s=t?.id?`borderStyle_${t.id}`:"borderStyle",r=t?.id?`borderWidth_${t.id}`:"borderWidth",l=t?.id?`borderColor_${t.id}`:"borderColor",c=t?.defaultColor||se,u=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:"Border",type:"switch",switchLabel:u,defaultValue:!!t?.defaultValue,on:[{id:n,type:"multiInput",layout:h.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:s,type:"dropdown",defaultValue:F.Solid,choices:[{value:F.Solid,label:F.Solid},{value:F.Dotted,label:F.Dotted},{value:F.Dashed,label:F.Dashed}]},{id:r,type:"input",defaultValue:Un,rules:[h.numericalOrPixelRule,h.minimumNumericalOrPixelRule(0),h.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px",onChange:d=>h.appendUnit(d,r)},{id:l,type:"colorInput",defaultValue:c}]}],off:[]}},Jt=(t,e=V.None)=>({id:t,type:"segmentedControls",defaultValue:e,choices:[{value:V.None,label:"None"},{value:V.Small,label:"S"},{value:V.Medium,label:"M"},{value:V.Large,label:"L"}]}),xa=t=>{const e=t?.id?`hasRadius_${t.id}`:"hasRadius",n=t?.id?`radiusValue_${t.id}`:"radiusValue",s=t?.id?`radiusChoice_${t.id}`:"radiusChoice",r=t?.defaultRadius||V.None;return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:l=>t?.dependentSettingId?!!l.getBlock(t.dependentSettingId)?.value:!0,onChange:l=>h.presetCustomValue(l,s,n,t?.radiusStyleMap||K),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[h.numericalOrPixelRule,h.minimumNumericalOrPixelRule(0)],onChange:l=>h.appendUnit(l,n)}],off:[Jt(s,r)]}},Ia=t=>{const e=t?.id?`hasExtendedCustomRadius_${t.id}`:"hasExtendedCustomRadius",n=t?.id?`extendedRadiusValue_${t.id}`:"extendedRadiusValue",s=t?.id?`extendedRadiusChoice_${t.id}`:"extendedRadiusChoice",r=t?.id?`extendedRadiusTopLeft_${t.id}`:"extendedRadiusTopLeft",l=t?.id?`extendedRadiusTopRight_${t.id}`:"extendedRadiusTopRight",c=t?.id?`extendedRadiusBottomLeft_${t.id}`:"extendedRadiusBottomLeft",u=t?.id?`extendedRadiusBottomRight_${t.id}`:"extendedRadiusBottomRight";return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:d=>t?.dependentSettingId?!!d.getBlock(t.dependentSettingId)?.value:!0,onChange:d=>{h.presetCustomValue(d,s,r,K),h.presetCustomValue(d,s,l,K),h.presetCustomValue(d,s,c,K),h.presetCustomValue(d,s,u,K)},on:[{id:n,type:"multiInput",layout:h.MultiInputLayout.Columns,blocks:[{id:r,type:"input",label:"Top Left",rules:[h.numericalOrPixelRule],onChange:d=>h.appendUnit(d,r)},{id:l,type:"input",label:"Top Right",rules:[h.numericalOrPixelRule],onChange:d=>h.appendUnit(d,l)},{id:c,type:"input",label:"Bottom Left",rules:[h.numericalOrPixelRule],onChange:d=>h.appendUnit(d,c)},{id:u,type:"input",label:"Bottom Right",rules:[h.numericalOrPixelRule],onChange:d=>h.appendUnit(d,u)}]}],off:[Jt(s,t?.defaultValue)]}},Ea=t=>{const e=t?.id?t.id:"hasCustomSpacing",n=t?.dependentSettingId?t.dependentSettingId:"columns",s=t?.spacingChoiceId?t.spacingChoiceId:"spacingChoice",r=t?.spacingCustomId?t.spacingCustomId:"spacingCustom",l=t?.defaultValueChoices?t.defaultValueChoices:X.M;return{id:e,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:c=>h.presetCustomValue(c,s,r,ie),show:c=>c.getBlock(n)?.value!=="1",on:[{id:r,type:"input",rules:[h.numericalOrPixelRule],onChange:c=>h.appendUnit(c,r)}],off:[{id:s,type:"slider",defaultValue:l,choices:[{value:X.Auto,label:"Auto"},{value:X.S,label:"S"},{value:X.M,label:"M"},{value:X.L,label:"L"}]}]}},Zt=t=>({id:t,type:"segmentedControls",defaultValue:Y.None,choices:[{value:Y.None,label:"None"},{value:Y.Small,label:"S"},{value:Y.Medium,label:"M"},{value:Y.Large,label:"L"}]}),Sa=t=>{const e=t?.id?`hasCustomMarginValue_${t?.id}`:"hasCustomMarginValue",n=t?.id?`marginValue_${t?.id}`:"marginValue",s=t?.id?`marginChoice_${t?.id}`:"marginChoice";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:r=>h.presetCustomValue(r,s,n,t?.marginStyleMap||R),on:[{id:n,type:"input",placeholder:ct,rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)],onChange:r=>h.appendUnit(r,n)}],off:[Zt(s)]}},Ba=t=>{const e=t?.id?`hasExtendedCustomMargin_${t?.id}`:"hasExtendedCustomMargin",n=t?.id?`extendedMarginValues_${t?.id}`:"extendedMarginValues",s=t?.id?`extendedMarginChoice_${t?.id}`:"extendedMarginChoice",r=t?.id?`extendedMarginTop_${t?.id}`:"extendedMarginTop",l=t?.id?`extendedMarginLeft_${t?.id}`:"extendedMarginLeft",c=t?.id?`extendedMarginRight_${t?.id}`:"extendedMarginRight",u=t?.id?`extendedMarginBottom_${t?.id}`:"extendedMarginBottom";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:d=>{h.presetCustomValue(d,s,r,R),h.presetCustomValue(d,s,l,R),h.presetCustomValue(d,s,c,R),h.presetCustomValue(d,s,u,R)},on:[{id:n,type:"multiInput",layout:h.MultiInputLayout.Spider,blocks:[{id:r,type:"input",label:"Top",placeholder:ct,onChange:d=>h.appendUnit(d,r),rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)]},{id:l,type:"input",label:"Left",placeholder:ct,onChange:d=>h.appendUnit(d,l),rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:ct,onChange:d=>h.appendUnit(d,c),rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:ct,onChange:d=>h.appendUnit(d,u),rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Zt(s)]}},Rt=t=>({id:t,type:"segmentedControls",defaultValue:j.Small,choices:[{value:j.None,label:"None"},{value:j.Small,label:"S"},{value:j.Medium,label:"M"},{value:j.Large,label:"L"}]}),Na=t=>{const e=t?.id?`hasCustomPaddingValue_${t?.id}`:"hasCustomPaddingValue",n=t?.id?`paddingValue_${t?.id}`:"paddingValue",s=t?.id?`paddingChoice_${t?.id}`:"paddingChoice";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:r=>h.presetCustomValue(r,s,n,t?.paddingStyleMap||Z),on:[{id:n,type:"input",placeholder:dt,rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)],onChange:r=>h.appendUnit(r,n)}],off:[Rt(s)]}},Aa=t=>{const e=t?.id?`hasExtendedCustomPadding_${t?.id}`:"hasExtendedCustomPadding",n=t?.id?`extendedPaddingValues_${t?.id}`:"extendedPaddingValues",s=t?.id?`extendedPaddingChoice_${t?.id}`:"extendedPaddingChoice",r=t?.id?`extendedPaddingTop_${t?.id}`:"extendedPaddingTop",l=t?.id?`extendedPaddingLeft_${t?.id}`:"extendedPaddingLeft",c=t?.id?`extendedPaddingRight_${t?.id}`:"extendedPaddingRight",u=t?.id?`extendedPaddingBottom_${t?.id}`:"extendedPaddingBottom";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:d=>{h.presetCustomValue(d,s,r,Z),h.presetCustomValue(d,s,l,Z),h.presetCustomValue(d,s,c,Z),h.presetCustomValue(d,s,u,Z)},on:[{id:n,type:"multiInput",layout:h.MultiInputLayout.Spider,blocks:[{id:r,type:"input",label:"Top",placeholder:dt,onChange:d=>h.appendUnit(d,r),rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)]},{id:l,type:"input",label:"Left",placeholder:dt,onChange:d=>h.appendUnit(d,l),rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:dt,onChange:d=>h.appendUnit(d,c),rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:dt,onChange:d=>h.appendUnit(d,u),rules:[h.numericalOrPixelRule,h.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Rt(s)]}},La=t=>{const e=te(t?.globalControlId);return{id:t?.id?t.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>n.getBlock(e)?.value===Q.Custom}},te=t=>t||"security",Da=t=>[{id:te(t),type:"segmentedControls",defaultValue:Q.Global,choices:[{value:Q.Global,label:"Global Settings"},{value:Q.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:h.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Pn=(t=>(t.Main="main",t.Basics="basics",t.Layout="layout",t.Style="style",t.Security="security",t.Targets="targets",t))(Pn||{});const Ma=t=>t,Fa=t=>t;i.AllTextStylePlugins=wa,i.AllTextStyles=ya,i.AttachmentOperationsProvider=Vn,i.Attachments=pe,i.AttachmentsProvider=ge,i.AttachmentsToolbarButton=be,i.BUTTON_PLUGIN=We,i.BlockButtonStyles=Ct,i.BlockInjectButton=Sn,i.BlockItemWrapper=Ee,i.BlockStyles=E,i.BorderStyle=F,i.BreakAfterPlugin=Vo,i.ButtonPlugin=Ge,i.Custom1Plugin=on,i.Custom2Plugin=sn,i.Custom3Plugin=ln,i.DEFAULT_ATTACHMENTS_BUTTON_ID=ye,i.DEFAULT_DRAGGING_TOOLTIP=Ce,i.DEFAULT_DRAG_TOOLTIP=ve,i.DEFAULT_MENU_BUTTON_ID=Dt,i.DragHandleToolbarButton=ke,i.DragPreviewContextProvider=le,i.ELEMENT_BUTTON=I,i.FlyoutToolbarButton=Te,i.GAP_DEFAULT=nn,i.GutterSpacing=X,i.Heading1Plugin=cn,i.Heading2Plugin=un,i.Heading3Plugin=gn,i.Heading4Plugin=hn,i.ImageCaptionPlugin=mn,i.ImageTitlePlugin=fn,i.KEY_ELEMENT_BREAK_AFTER_COLUMN=zo,i.LinkInput=ze,i.LinkPlugin=en,i.LinkSelector=He,i.Margin=Y,i.MenuToolbarButton=Pe,i.MultiFlyoutContextProvider=de,i.OrderedListPlugin=Tn,i.PARAGRAPH_CLASSES=wn,i.Padding=j,i.ParagraphMarkupElement=yn,i.ParagraphMarkupElementNode=kt,i.ParagraphPlugin=pn,i.QuoteMarkupElementNode=Tt,i.QuotePlugin=vn,i.Radius=V,i.RichTextEditor=So,i.Sections=Pn,i.Security=Q,i.THEME_PREFIX=ka,i.TextStylePluginsWithoutImage=Xt,i.TextStyles=b,i.TextStylesWithoutImage=st,i.Toolbar=Ie,i.UnorderedListPlugin=kn,i.addHttps=yt,i.borderStyleMap=re,i.convertToRteValue=Qn,i.createButtonNode=Me,i.createButtonPlugin=qe,i.createLinkPlugin=tn,i.createParagraphPlugin=bn,i.createQuotePlugin=Cn,i.defineBlock=Ma,i.defineSettings=Fa,i.getBackgroundColorStyles=On,i.getBackgroundSettings=Ta,i.getBorderRadiusSettings=xa,i.getBorderRadiusSlider=Jt,i.getBorderSettings=Pa,i.getBorderStyles=Hn,i.getDefaultPluginsWithLinkChooser=Ca,i.getExtendedBorderRadiusSettings=Ia,i.getGutterSettings=Ea,i.getLegacyUrl=Jn,i.getLinkFromEditor=Rn,i.getMarginExtendedSettings=Ba,i.getMarginSettings=Sa,i.getMarginSlider=Zt,i.getPaddingExtendedSettings=Aa,i.getPaddingSettings=Na,i.getPaddingSlider=Rt,i.getRadiusStyles=zn,i.getReadableColor=Fn,i.getSecurityDownloadableSetting=La,i.getSecurityGlobalControlId=te,i.getSecurityGlobalControlSetting=Da,i.getUrl=Zn,i.getUrlFromEditor=De,i.getUrlFromLinkOrLegacyLink=Ot,i.gutterSpacingStyleMap=ie,i.hasRichTextValue=Se,i.insertButton=Ne,i.isDark=Nn,i.isDownloadable=Xn,i.isValidUrl=bt,i.isValidUrlOrEmpty=nt,i.joinClassNames=z,i.marginStyleMap=R,i.paddingStyleMap=Z,i.radiusStyleMap=K,i.relativeUrlRegex=_t,i.setAlpha=Dn,i.submitFloatingButton=Ut,i.toColorObject=Mn,i.toHex8String=An,i.toHexString=Ln,i.toRgbaString=St,i.toShortRgba=G,i.triggerFloatingButton=Fe,i.triggerFloatingButtonEdit=vt,i.triggerFloatingButtonInsert=zt,i.unwrapButton=ot,i.upsertButton=Ae,i.upsertButtonText=Ht,i.useAttachmentOperations=At,i.useAttachments=ue,i.useAttachmentsContext=he,i.useDragPreviewContext=tt,i.useMultiFlyoutContext=ce,i.useMultiFlyoutState=pt,i.withAttachmentsProvider=$n,i.withButton=Be,i.wrapButton=Le,Object.keys(h).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:()=>h[t]})}),Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
10
10
|
//# sourceMappingURL=index.umd.js.map
|