UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 6.07 kB
import{c as y,m as h,b as G,r as x,j as a,a_ as J}from"./index-ztdGKvBm.js";import{aF as U}from"./agent-icon-BYWtutu9.js";import{s as Q}from"./Trash01-BxBhF2b8.js";const V=new Set(["http:","https:","mailto:","tel:","ftp:"]);function X(s){if(s.startsWith("/")||s.startsWith(".")||s.startsWith("#"))return!0;try{const e=new URL(s,"https://placeholder.invalid");return V.has(e.protocol)}catch{return!1}}function Y(s){const e=s.trim();return e?e.startsWith("/")||e.startsWith(".")||e.startsWith("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)?e:`https://${e}`:""}const ee="noopener noreferrer nofollow";function D(s){const e=y.c(8),{active:n,label:i,onClick:c,children:r}=s,l=n?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground";let t;e[0]!==l?(t=h("flex h-7 w-7 items-center justify-center rounded-[var(--studio-control-radius,var(--radius))] transition-colors cursor-pointer",l),e[0]=l,e[1]=t):t=e[1];let u;return e[2]!==n||e[3]!==r||e[4]!==i||e[5]!==c||e[6]!==t?(u=a.jsx("button",{type:"button","aria-label":i,"aria-pressed":n,onMouseDown:te,onClick:c,className:t,children:r}),e[2]=n,e[3]=r,e[4]=i,e[5]=c,e[6]=t,e[7]=u):u=e[7],u}function te(s){return s.preventDefault()}function K(s){const e=y.c(7),{active:n,label:i,onSelect:c}=s,r=n?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground";let l;e[0]!==r?(l=h("flex-1 rounded-[var(--studio-control-radius,var(--radius))] px-2 py-1 text-xs transition-colors cursor-pointer",r),e[0]=r,e[1]=l):l=e[1];let t;return e[2]!==n||e[3]!==i||e[4]!==c||e[5]!==l?(t=a.jsx("button",{type:"button","aria-pressed":n,onMouseDown:ne,onClick:c,className:l,children:i}),e[2]=n,e[3]=i,e[4]=c,e[5]=l,e[6]=t):t=e[6],t}function ne(s){return s.preventDefault()}function P(s){const e=y.c(8),{active:n,icon:i,label:c,onSelect:r}=s,l=n?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground";let t;e[0]!==l?(t=h("flex flex-1 items-center justify-center gap-1 rounded-[var(--studio-control-radius,var(--radius))] px-2 py-1 text-xs transition-colors cursor-pointer",l),e[0]=l,e[1]=t):t=e[1];let u;return e[2]!==n||e[3]!==i||e[4]!==c||e[5]!==r||e[6]!==t?(u=a.jsxs("button",{type:"button","aria-pressed":n,onMouseDown:re,onClick:r,className:t,children:[i,c]}),e[2]=n,e[3]=i,e[4]=c,e[5]=r,e[6]=t,e[7]=u):u=e[7],u}function re(s){return s.preventDefault()}function ie(s){const e=y.c(27),{editor:n,active:i,open:c,onOpenChange:r,sources:l}=s,t=G(),[u,z]=x.useState(""),[d,C]=x.useState(!0),[A,E]=x.useState(!1),[S,_]=x.useState("url");let m;e[0]!==i||e[1]!==n||e[2]!==r?(m=()=>{const o=n.getAttributes("link");z(typeof o.href=="string"?o.href:""),C(i?o.target==="_blank":!0),E(!1),_("url"),r(!0)},e[0]=i,e[1]=n,e[2]=r,e[3]=m):m=e[3];const Z=m;let v;e[4]!==n||e[5]!==r?(v=()=>{r(!1),n.chain().focus().run()},e[4]=n,e[5]=r,e[6]=v):v=e[6];const M=v;let b;e[7]!==n||e[8]!==d||e[9]!==r?(b=(o,B)=>{const F=B===void 0?!1:B,R=F?o.trim():Y(o);if(R===""){n.chain().focus().extendMarkRange("link").unsetLink().run(),r(!1);return}if(!F&&!X(R)){E(!0);return}n.chain().focus().extendMarkRange("link").setLink({href:R,target:d?"_blank":null,rel:d?ee:null}).run(),r(!1)},e[7]=n,e[8]=d,e[9]=r,e[10]=b):b=e[10];const g=b;let k;e[11]!==g||e[12]!==u?(k=()=>g(u),e[11]=g,e[12]=u,e[13]=k):k=e[13];const W=k;let L;e[14]!==n||e[15]!==r?(L=()=>{n.chain().focus().extendMarkRange("link").unsetLink().run(),r(!1)},e[14]=n,e[15]=r,e[16]=L):L=e[16];const q=L,I=!!l?.length,$=l?.find(o=>o.id===S),O=x.useRef(null),H="relative";let f;e[17]!==t?(f=t("sectionsEditor.richTextLinkControl.linkButtonLabel"),e[17]=t,e[18]=f):f=e[18];const w=c?M:Z;let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(U,{size:14}),e[19]=j):j=e[19];let p;e[20]!==i||e[21]!==f||e[22]!==w?(p=a.jsx(D,{active:i,label:f,onClick:w,children:j}),e[20]=i,e[21]=f,e[22]=w,e[23]=p):p=e[23];const N=c&&a.jsxs("div",{ref:O,className:h("absolute left-0 top-full z-20 mt-1.5 flex flex-col gap-1 rounded-[var(--studio-surface-radius,var(--radius-md))] bg-popover p-1 shadow-soft",I?"w-80":"w-64"),onBlur:()=>{requestAnimationFrame(()=>{O.current?.contains(document.activeElement)||r(!1)})},children:[I&&a.jsxs("div",{className:"flex items-center gap-0.5 rounded-[var(--studio-control-radius,var(--radius))] bg-muted/40 p-0.5",children:[a.jsx(P,{active:S==="url",icon:a.jsx(U,{size:12}),label:t("sectionsEditor.richTextLinkControl.tabUrl"),onSelect:()=>_("url")}),l?.map(o=>a.jsx(P,{active:S===o.id,icon:o.icon,label:o.label,onSelect:()=>_(o.id)},o.id))]}),$?$.render(o=>g(o,!0)):a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("input",{autoFocus:!0,type:"text","aria-label":t("sectionsEditor.richTextLinkControl.urlInputAriaLabel"),"aria-invalid":A,placeholder:t("sectionsEditor.richTextLinkControl.urlInputPlaceholder"),value:u,onChange:o=>{z(o.target.value),E(!1)},onKeyDown:o=>{o.key==="Enter"?(o.preventDefault(),W()):o.key==="Escape"&&(o.preventDefault(),M())},className:h("h-7 flex-1 rounded-[var(--studio-control-radius,var(--radius))] bg-transparent px-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none",A&&"text-destructive")}),a.jsx(D,{active:!1,label:t("sectionsEditor.richTextLinkControl.applyLinkLabel"),onClick:W,children:a.jsx(J,{size:14})}),i&&a.jsx(D,{active:!1,label:t("sectionsEditor.richTextLinkControl.removeLinkLabel"),onClick:q,children:a.jsx(Q,{size:14})})]}),a.jsxs("div",{className:"flex items-center gap-0.5 rounded-[var(--studio-control-radius,var(--radius))] bg-muted/40 p-0.5",children:[a.jsx(K,{active:!d,label:t("sectionsEditor.richTextLinkControl.sameTabLabel"),onSelect:()=>C(!1)}),a.jsx(K,{active:d,label:t("sectionsEditor.richTextLinkControl.newTabLabel"),onSelect:()=>C(!0)})]})]});let T;return e[24]!==p||e[25]!==N?(T=a.jsxs("div",{className:H,children:[p,N]}),e[24]=p,e[25]=N,e[26]=T):T=e[26],T}const le="[&_a]:cursor-pointer [&_a]:text-primary [&_a]:underline [&_a]:decoration-primary/60 [&_a]:underline-offset-2 [&_a]:rounded-sm [&_a]:bg-primary/5 [&_a]:px-0.5";export{le as E,ie as R,D as T,X as i,Y as n};