domma-cms 1.32.0 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/CLAUDE.md +1 -1
  3. package/admin/js/lib/admin-brand.js +1 -1
  4. package/admin/js/lib/admin-theme.js +1 -1
  5. package/admin/js/lib/shortcode-context-menu.js +2 -2
  6. package/admin/js/lib/shortcode-registry.js +1 -1
  7. package/admin/js/lib/sidebar-frequent.js +1 -1
  8. package/admin/js/lib/sidebar-renderer.js +4 -4
  9. package/admin/js/lib/site-settings-arrange.js +2 -2
  10. package/admin/js/lib/theme-aware-logo.js +1 -0
  11. package/admin/js/templates/settings.html +7 -1
  12. package/admin/js/views/settings.js +2 -2
  13. package/docs/markdown-shortcodes.md +13 -0
  14. package/docs/starter-blocks.md +37 -1
  15. package/package.json +1 -1
  16. package/server/blocks/catalog.json +24 -0
  17. package/server/blocks/domma-block-comparison-card.css +20 -0
  18. package/server/blocks/domma-block-comparison-card.html +18 -0
  19. package/server/blocks/domma-block-comparison-card.meta.json +7 -0
  20. package/server/blocks/domma-block-cta-card.css +20 -0
  21. package/server/blocks/domma-block-cta-card.html +15 -0
  22. package/server/blocks/domma-block-cta-card.meta.json +7 -0
  23. package/server/blocks/domma-block-feature-card.css +20 -0
  24. package/server/blocks/domma-block-feature-card.html +15 -0
  25. package/server/blocks/domma-block-feature-card.meta.json +7 -0
  26. package/server/blocks/domma-block-image-card.css +20 -0
  27. package/server/blocks/domma-block-image-card.html +17 -0
  28. package/server/blocks/domma-block-image-card.meta.json +7 -0
  29. package/server/services/adminBrand.js +4 -1
  30. package/server/services/embedCsp.js +1 -1
  31. package/server/services/markdown.js +65 -6
  32. package/server/services/sidebarFrequent.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.33.0] - 2026-11-03
4
+
5
+ - **`[map]`** - a responsive Google Map of one place: `[map postcode="SW1A 2AA" zoom="15" caption="Visit us" /]`, or `address`, `pin="lat,lon"`, `lat` + `lon`. Zoom 1-20, `lng` as well as `lon`, ratio, width, alignment and a caption; malformed coordinates show a notice rather than a broken map. Google's embed host is always allowed to frame, so no `config/embeds.json` entry is needed. In the shortcode menus under Media.
6
+ - **Admin logo for dark themes** (Site Settings > Branding): an optional second logo, shown in the top bar and the sidebar whenever the admin theme has a dark background, switching as the theme changes.
7
+ - **Tracking** in the page editor's shortcode menu: expiry, visitor and IP settings now sit in their own Tracking submenu instead of among each shortcode's options.
8
+ - **Four more free blocks**: feature card, comparison card, image card and call-to-action card (21 in the library). Existing sites receive them when they upgrade.
9
+ - **Frequent holds 16** places in the sidebar, up from 12.
10
+ - **A plugin's shortcode matches its own name only.** `[map-guess]` and `[map-guess-leaderboard]` were caught by any plugin registering `[map]` (Blog Pro), and `[map-guess-leaderboard]` by `[map-guess]` itself; a name now has to end at a space, `/` or `]`. The shortcode context passes `renderMap`, so a plugin with its own `[map]` can hand back the tags it cannot draw (Blog Pro 0.7.2 does).
11
+
3
12
  ## [1.32.0] - 2026-11-03
4
13
 
5
14
  - **Block packs.** Blocks > the package action: make a versioned pack from chosen blocks (with their pictures, schema 2), export it as a `.dmblockpack.json` file, import one, and install it after a preview that lists every block it adds or changes. A block edited here since a pack put it there, or one of the same name the pack did not make, stops the install rather than being overwritten. Each install is kept, so the last one can be rolled back while nothing has been edited since. Two starter packs (Domma Base Block Pack, Domma cards) come with every site. The Manager can preview and install a pack on chosen sites.
package/CLAUDE.md CHANGED
@@ -68,7 +68,7 @@ Processing order (`parseMarkdown()` in `server/services/markdown.js`; earlier st
68
68
  3. `[dconfig]`
69
69
  4. Effects shortcodes, then plugin shortcodes
70
70
  5. `[tabs]`, `[accordion]`, `[carousel]`, `[countdown]`, `[timeline]`, `[listgroup]`, `[spacer]`, `[center]`, `[icon]`,
71
- `[demo]`, `[embed]`, `[image]`, `[form]`, `[hero]`, `[table]`
71
+ `[demo]`, `[embed]`, `[map]`, `[image]`, `[form]`, `[hero]`, `[table]`
72
72
  6. Inline tags: `[badge]`, `[text]`, `[button]`, `[link]`, `[cta]`
73
73
  7. `[grid]` / `[row]` / `[col]`
74
74
  8. `[card]` (and `[box]` - a headerless card, handled at the top of `processCardBlocks`)
@@ -1 +1 @@
1
- export const PRODUCT_NAME="Domma CMS";let t=null,f="",s=null,d=null;export function currentAdminBrand(){return t}export function brandedTabTitle(e,a,r=""){const o=i=>String(i||"").replace(/[ \t\n\f\r]+/g," ").trim(),n=o(a?.title),l=o(e);if(a?.enabled===!1){const i=[n,o(r),PRODUCT_NAME].filter(c=>c&&(l===c||l.endsWith(` - ${c}`))).sort((c,h)=>h.length-c.length)[0];return i?l===i?"Admin":l.slice(0,-i.length-3):String(e||"")}if(!n)return String(e||"");const b=i=>i&&(l===i||l.endsWith(` - ${i}`)),u=[n,o(r),PRODUCT_NAME].filter(b).sort((i,c)=>c.length-i.length)[0];return!u||u===n?String(e||""):l===u?n:l.slice(0,-u.length)+n}export function applyAdminBrand(e){const a=e&&(e.title||e.enabled===!1)?e:{title:PRODUCT_NAME};t?.enabled===!1&&a.enabled!==!1&&document.title===s&&d&&(document.title=d,s=null),t&&(t.title!==a.title||t.enabled===!1!=(a.enabled===!1))&&(f=t.title,s=null),t=a;const r=document.querySelector("#admin-topbar .topbar-brand");if(r&&(r.hidden=t.enabled===!1),r&&t.enabled===!1&&r.replaceChildren(),r&&t.enabled!==!1){const o=String(t.logo||"");let n;/^(?:\/(?!\/)|https?:\/\/)/i.test(o)?(n=document.createElement("img"),n.src=o,n.alt="",n.className="topbar-brand-logo"):(n=document.createElement("span"),n.setAttribute("data-icon",t.icon||"layout"));const l=document.createElement("span");l.className="topbar-brand-text",l.textContent=t.title,r.replaceChildren(n,l);try{I.scan(r)}catch{}}p(),retitleTab()}export function retitleTab(){if(!t||s!==null&&document.title===s)return;const e=brandedTabTitle(document.title,t,f);e!==document.title&&(t.enabled===!1&&(d=document.title),document.title=e,s=document.title)}let m=!1;function p(){if(m||typeof MutationObserver>"u")return;let e=document.querySelector("head > title");e||(e=document.createElement("title"),document.head.appendChild(e)),new MutationObserver(retitleTab).observe(e,{childList:!0,characterData:!0,subtree:!0}),m=!0}
1
+ import{syncThemeAwareLogos as b}from"./theme-aware-logo.js";export const PRODUCT_NAME="Domma CMS";let e=null,m="",d=null,f=null;export function currentAdminBrand(){return e}export function brandedTabTitle(t,c,o=""){const a=n=>String(n||"").replace(/[ \t\n\f\r]+/g," ").trim(),r=a(c?.title),i=a(t);if(c?.enabled===!1){const n=[r,a(o),PRODUCT_NAME].filter(s=>s&&(i===s||i.endsWith(` - ${s}`))).sort((s,h)=>h.length-s.length)[0];return n?i===n?"Admin":i.slice(0,-n.length-3):String(t||"")}if(!r)return String(t||"");const u=n=>n&&(i===n||i.endsWith(` - ${n}`)),l=[r,a(o),PRODUCT_NAME].filter(u).sort((n,s)=>s.length-n.length)[0];return!l||l===r?String(t||""):i===l?r:i.slice(0,-l.length)+r}export function applyAdminBrand(t){const c=t&&(t.title||t.enabled===!1)?t:{title:PRODUCT_NAME};e?.enabled===!1&&c.enabled!==!1&&document.title===d&&f&&(document.title=f,d=null),e&&(e.title!==c.title||e.enabled===!1!=(c.enabled===!1))&&(m=e.title,d=null),e=c;const o=document.querySelector("#admin-topbar .topbar-brand");if(o&&(o.hidden=e.enabled===!1),o&&e.enabled===!1&&o.replaceChildren(),o&&e.enabled!==!1){const a=String(e.logo||""),r=String(e.logoDark||""),i=/^(?:\/(?!\/)|https?:\/\/)/i.test(a),u=/^(?:\/(?!\/)|https?:\/\/)/i.test(r);let l;i||u?(l=document.createElement("img"),l.src=i?a:r,i&&(l.dataset.logoLight=a),u&&(l.dataset.logoDark=r),l.alt="",l.className="topbar-brand-logo"):(l=document.createElement("span"),l.setAttribute("data-icon",e.icon||"layout"));const n=document.createElement("span");n.className="topbar-brand-text",n.textContent=e.title,o.replaceChildren(l,n);try{I.scan(o)}catch{}b(o)}p(),retitleTab()}export function retitleTab(){if(!e||d!==null&&document.title===d)return;const t=brandedTabTitle(document.title,e,m);t!==document.title&&(e.enabled===!1&&(f=document.title),document.title=t,d=document.title)}let g=!1;function p(){if(g||typeof MutationObserver>"u")return;let t=document.querySelector("head > title");t||(t=document.createElement("title"),document.head.appendChild(t)),new MutationObserver(retitleTab).observe(t,{childList:!0,characterData:!0,subtree:!0}),g=!0}
@@ -1 +1 @@
1
- import{fontFamilyValue as i,fontStylesheetHref as r,isFontStylesheet as f}from"../../../public/js/font-families.mjs?v=20261029-cms-fonts";const a="dm-custom-themes";function y(e={}){const s=(c,d)=>{let m=document.getElementById(c);if(!d){m?.remove();return}m||(m=document.createElement("link"),m.id=c,m.rel="stylesheet",document.head.appendChild(m)),m.href=d},t=f(e.stylesheet)?e.stylesheet:"";s("dm-licensed-fonts",t);const o=r(e.family,{stylesheet:t});s("dm-admin-font-link",o===t?"":o);let n=document.getElementById("dm-admin-font");if(!e.family){n?.remove();return}n||(n=document.createElement("style"),n.id="dm-admin-font",document.head.appendChild(n));const l=i(e.family);n.textContent=`body[class] { --dm-font-sans: ${l}; font-family: var(--dm-font-sans); }`}export function applyAdminTheme(e){const s=e?.dommaTheme||"charcoal-dark";Domma.theme.init({theme:s,persist:!1,target:document.body});let t=document.getElementById(a);e?.css?(t||(t=document.createElement("style"),t.id=a,document.head.appendChild(t)),t.textContent=e.css):t&&t.remove();const o=document.body;for(const n of[...o.classList])n.startsWith("dm-custom-")&&o.classList.remove(n);e?.customClass&&o.classList.add(e.customClass),y(e?.font)}export async function refreshAdminTheme(e,s={}){try{applyAdminTheme(await e.theme.admin(),s)}catch{applyAdminTheme({dommaTheme:"charcoal-dark"},s)}}
1
+ import{fontFamilyValue as l,fontStylesheetHref as r,isFontStylesheet as f}from"../../../public/js/font-families.mjs?v=20261029-cms-fonts";import{syncThemeAwareLogos as y}from"./theme-aware-logo.js";const a="dm-custom-themes";function h(e={}){const s=(c,d)=>{let m=document.getElementById(c);if(!d){m?.remove();return}m||(m=document.createElement("link"),m.id=c,m.rel="stylesheet",document.head.appendChild(m)),m.href=d},t=f(e.stylesheet)?e.stylesheet:"";s("dm-licensed-fonts",t);const o=r(e.family,{stylesheet:t});s("dm-admin-font-link",o===t?"":o);let n=document.getElementById("dm-admin-font");if(!e.family){n?.remove();return}n||(n=document.createElement("style"),n.id="dm-admin-font",document.head.appendChild(n));const i=l(e.family);n.textContent=`body[class] { --dm-font-sans: ${i}; font-family: var(--dm-font-sans); }`}export function applyAdminTheme(e){const s=e?.dommaTheme||"charcoal-dark";Domma.theme.init({theme:s,persist:!1,target:document.body});let t=document.getElementById(a);e?.css?(t||(t=document.createElement("style"),t.id=a,document.head.appendChild(t)),t.textContent=e.css):t&&t.remove();const o=document.body;for(const n of[...o.classList])n.startsWith("dm-custom-")&&o.classList.remove(n);e?.customClass&&o.classList.add(e.customClass),y(),h(e?.font)}export async function refreshAdminTheme(e,s={}){try{applyAdminTheme(await e.theme.admin(),s)}catch{applyAdminTheme({dommaTheme:"charcoal-dark"},s)}}
@@ -1,3 +1,3 @@
1
- import{convertSelectionToBlock as Q}from"./selection-to-block.js";import{EDITOR_TOOLS as Z,SHORTCODES as R}from"./shortcode-registry.js";import{EFFECTS as _,CELEBRATION_THEMES as ee,getEffectAttrs as H}from"./effect-defs.js";import{boolState as te,boolValue as ne,findEnclosingShortcode as oe,setAttr as z,setAttrs as W,effectAttrKeys as se}from"./shortcode-tags.js";import{insertAtCursor as O,replaceRange as ie}from"./markdown-toolbar.js";import{clearLookupCache as ce,lookupOptions as ae}from"./shortcode-lookups.js";import{insertMenuGroups as le,insertShortcodeByName as j}from"./shortcode-insert.js";import{openShortcodeForm as M}from"./shortcode-form.js";import{pickMedia as re}from"./media-picker.js";import{blockTagSnippet as de}from"./block-tags.js";import{catalogueNow as pe,dommaHelp as me}from"./domma-catalogue.js";function ue(e){return ae(e,l?.span?.attrs||{})}const fe=R.map(e=>({name:e.name,selfClosing:e.name==="block"?!1:!!e.selfClosing})),F=new Map(R.map(e=>[e.name,e])),B=new Map(_.map(e=>[e.name,e])),he=_.map(e=>({name:e.name,selfClosing:!!e.selfClosing})),be=[...fe,...he],Y=new Set(["card","box","hero","banner","col","button"]);let l=null;const q="position:fixed;z-index:10000;min-width:210px;max-height:70vh;overflow-y:auto;background:var(--dm-surface,#1c1c30);border:1px solid var(--dm-border,#2a2a40);border-radius:6px;box-shadow:var(--dm-shadow-lg);padding:.3rem;font-size:.83rem;color:var(--dm-text,#e5e5e5);",u="display:flex;align-items:center;gap:.5rem;width:100%;text-align:left;padding:.35rem .55rem;border:none;background:transparent;color:inherit;border-radius:4px;cursor:pointer;font-size:.83rem;",k="padding:.3rem .55rem;color:var(--dm-text-muted,#8a8a9a);font-size:.68rem;text-transform:uppercase;letter-spacing:.06em;",P="flex:1;min-width:0;padding:.2rem .4rem;background:var(--dm-input-bg,#12121e);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.8rem;",xe="height:1px;background:var(--dm-border,#2a2a40);margin:.3rem .2rem;";function f(e){return e.addEventListener("mouseenter",()=>{e.style.background="var(--dm-primary,#4338ca)",e.style.color="var(--dm-primary-text,#fff)"}),e.addEventListener("mouseleave",()=>{e.style.background="transparent",e.style.color="inherit"}),e}export function attachContextMenu(e,{blocks:t=()=>[],openBlock:n=null}={}){const o=()=>{const i=t()||[],s=i.filter(a=>a.shortTag&&!F.has(a.name)&&!B.has(a.name));return{defs:i,specs:[...be,...s.map(a=>({name:a.name,selfClosing:a.selfClosing}))]}},c=(i,s)=>{p();const{defs:a,specs:r}=o();G(e,oe(e,r),i,s,a,n)};return typeof Domma>"u"||!Domma.elements?.contextMenu?(e.addEventListener("contextmenu",i=>{i.preventDefault(),c(i.clientX,i.clientY)}),null):Domma.elements.contextMenu(e,{inherit:!1,cursor:!1,render:i=>{c(i.x,i.y)}})}function p(){l&&(L(),l.root.remove(),document.removeEventListener("mousedown",U,!0),document.removeEventListener("keydown",V,!0),window.removeEventListener("scroll",K,!0),l=null)}const U=e=>{l&&!l.root.contains(e.target)&&!(l.submenu&&l.submenu.contains(e.target))&&p()},K=e=>{l&&!l.root.contains(e.target)&&!(l.submenu&&l.submenu.contains(e.target))&&p()},V=e=>{e.key==="Escape"&&p()};function G(e,t,n,o,c=[],i=null){ce();const s=document.createElement("div");s.className="dm-sc-menu",s.style.cssText=q,l={root:s,textarea:e,span:t,submenu:null,blocks:c,openBlock:i,keepEmpty:!1};const a=new Map(c.map(x=>[x.name,x])),r=t&&(F.get(t.name)||B.get(t.name)),d=t&&(r?t.name==="block"?a.get(String(t.attrs.template||"")):null:a.get(t.name)),b=t&&Y.has(t.name)?_.filter(x=>x.name in t.attrs):[];r&&ye(s,r),d&&Ee(s,d,!!r);for(const x of b)_e(s,x);(r||d||b.length)&&s.appendChild(S()),s.appendChild(C("Celebrations\u2026",()=>Se())),s.appendChild(C("Add effect\u2026",()=>$e())),s.appendChild(C("Insert\u2026",()=>Ae()));const m=e.selectionStart!==e.selectionEnd;if(m&&e.value.slice(e.selectionStart,e.selectionEnd).trim()){const x={start:e.selectionStart,end:e.selectionEnd,source:e.value},y=f(document.createElement("button"));y.type="button",y.style.cssText=u,y.textContent="Convert selection to Domma Block\u2026",y.addEventListener("click",()=>{p(),Q(e,x)}),s.appendChild(y)}(t||m)&&s.appendChild(C(m?"Wrap selection in\u2026":"Wrap in\u2026",()=>Ie())),c.length&&(s.appendChild(S()),s.appendChild(C("Add block\u2026",()=>Me()))),document.body.appendChild(s),J(s,n,o),document.addEventListener("mousedown",U,!0),document.addEventListener("keydown",V,!0),window.addEventListener("scroll",K,!0),window.I&&I.scan(s)}function S(){const e=document.createElement("div");return e.style.cssText=xe,e}function w(e){const t=document.createElement("div");return t.style.cssText=k,t.textContent=e,t}function ye(e,t){e.appendChild(w(`${t.label} options`));const n=f(document.createElement("button"));n.type="button",n.style.cssText=u,n.innerHTML='<span data-icon="edit" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>',n.appendChild(document.createTextNode(`Edit ${t.label}\u2026`)),n.addEventListener("click",()=>{const{textarea:i,span:s}=l;p(),M(i,{...t,attrs:H(t,s.attrs)},{span:s})}),e.appendChild(n);for(const i of t.actions||[]){const s=f(document.createElement("button"));s.type="button",s.style.cssText=u,s.innerHTML=`<span data-icon="${i.icon||"zap"}" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>`,s.appendChild(document.createTextNode(i.label)),s.addEventListener("click",()=>{const{textarea:a,span:r}=l;if(i.remove){ie(a,r.openTagStart,r.openTagEnd,""),p();return}l.span=W(a,r,i.set||{}),p()}),e.appendChild(s)}const o=Array.isArray(t.quickAttrs)?new Set(t.quickAttrs):null,c=H(t,l.span.attrs).filter(i=>!o||o.has(i.name));(t.actions||[]).length&&c.length&&e.appendChild(S());for(const i of c)e.appendChild(D(i))}function Ee(e,t,n){const{span:o}=l;if(l.keepEmpty=!0,n&&e.appendChild(S()),e.appendChild(w(n?`${t.name} parameters`:`${t.name} block`)),t.description&&!n){const s=document.createElement("div");s.style.cssText="padding:0 .55rem .3rem;font-size:.75rem;color:var(--dm-text-muted,#9a9aac);max-width:260px;",s.textContent=t.description,e.appendChild(s)}const c=(s,a,r)=>{const d=f(document.createElement("button"));d.type="button",d.style.cssText=u,d.innerHTML=`<span data-icon="${s}" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>`,d.appendChild(document.createTextNode(a)),d.addEventListener("click",r),e.appendChild(d)};t.attrs.length&&c("edit","Edit parameters\u2026",()=>{const{textarea:s}=l;p(),M(s,{...t,name:o.name,label:t.name},{span:o})});const{openBlock:i}=l;c(i?"layout":"external-link",i?"Edit the block":"Open the block",()=>{p(),i?i(t.name):location.hash=`#/blocks/edit/${encodeURIComponent(t.name)}`});for(const s of t.attrs)e.appendChild(D(s));if(!t.attrs.length){const s=document.createElement("div");s.style.cssText=k+"text-transform:none;letter-spacing:0;",s.textContent="This block takes no parameters.",e.appendChild(s)}}function D(e,t=e.name){const n=Ce(e,t),o=e.domma?me(pe(),e):"";return o&&n&&!n.title&&(n.title=o),n}function Ce(e,t){const n=l.span.attrs[t];switch(e.type){case"checkbox":return ge(e,t,te(n,e.default));case"select":return Te(e,t,n);case"lookup":return Le(e,t,n);case"colour":return we(e,t,n);case"icon":return ke(e,t,n);default:return ve(e,t,n)}}function T(e,t){if(l.span=z(l.textarea,l.span,e,l.keepEmpty&&t==null?"":t,{keepEmpty:l.keepEmpty}),e==="theme"){const{textarea:n,span:o,root:c}=l,i=c.getBoundingClientRect(),{blocks:s,openBlock:a}=l;p(),G(n,o,i.left,i.top,s,a)}}function ge(e,t,n){const o=f(document.createElement("label"));o.style.cssText=u;const c=document.createElement("input");return c.type="checkbox",c.checked=n,c.addEventListener("change",()=>T(t,ne(e,c.checked))),o.appendChild(c),o.appendChild(document.createTextNode(e.label)),o}function ve(e,t,n){const o=document.createElement("div");o.style.cssText=u+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.cssText="white-space:nowrap;color:var(--dm-text-muted,#9a9aac);";const i=document.createElement("input");i.type=e.type==="number"?"number":"text",i.value=n===!0||n==null?"":n,e.default!=null&&e.default!==""&&(i.placeholder=String(e.default)),i.style.cssText=P;let s=null;if(i.addEventListener("input",()=>{clearTimeout(s),s=setTimeout(()=>T(t,i.value.trim()),180)}),i.addEventListener("mousedown",a=>a.stopPropagation()),o.appendChild(c),o.appendChild(i),e.type==="image"){const a=document.createElement("button");a.type="button",a.textContent="Browse",a.title="Choose from Media",a.style.cssText="padding:2px 8px;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:inherit;cursor:pointer;flex-shrink:0;font:inherit;",a.addEventListener("mousedown",r=>r.stopPropagation()),a.addEventListener("click",async()=>{const{textarea:r,span:d}=l;p();const b=await re({current:i.value.trim()});b&&r.isConnected&&z(r,d,t,b)}),o.appendChild(a)}return o}function we(e,t,n){const o=document.createElement("div");o.style.cssText=u+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.flex="1";const i=document.createElement("input");return i.type="color",typeof n=="string"&&/^#/.test(n)?i.value=n:typeof e.default=="string"&&/^#/.test(e.default)&&(i.value=e.default),i.addEventListener("input",()=>T(t,i.value)),o.appendChild(c),o.appendChild(i),o}function Te(e,t,n){const o=n==null||n===!0?e.default??"":n;return C(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const c=g();for(const[i,s]of e.options||[]){const a=f(document.createElement("button"));a.type="button",a.style.cssText=u,a.textContent=s,i===o&&(a.style.fontWeight="700"),a.addEventListener("click",()=>{T(t,i),L()}),c.appendChild(a)}return c})}function ke(e,t,n){const o=n==null||n===!0?"":String(n),c=o?`${e.label}: ${o}`:e.label;return C(c,()=>{const i=g();i.style.width="232px";const s=document.createElement("input");s.type="text",s.placeholder="Search icons\u2026",s.style.cssText=P+"margin:6px;width:calc(100% - 12px);",s.addEventListener("mousedown",x=>x.stopPropagation()),i.appendChild(s);const a=f(document.createElement("button"));a.type="button",a.style.cssText=u,a.textContent="- none -",o||(a.style.fontWeight="700"),a.addEventListener("click",()=>{T(t,null),L()}),i.appendChild(a);const r=document.createElement("div");r.style.cssText="display:flex;flex-wrap:wrap;gap:2px;padding:4px 6px;max-height:220px;overflow-y:auto;",i.appendChild(r);const d=96,b=()=>{const x=typeof I<"u"&&typeof I.list=="function"?I.list():[],y=s.value.trim().toLowerCase(),$=y?x.filter(h=>h.toLowerCase().includes(y)):x;r.replaceChildren();for(const h of $.slice(0,d)){const v=f(document.createElement("button"));v.type="button",v.title=h,v.style.cssText="width:26px;height:26px;display:inline-flex;align-items:center;justify-content:center;background:none;border:1px solid transparent;border-radius:4px;cursor:pointer;color:inherit;",h===o&&(v.style.borderColor="var(--dm-primary,#5b8cff)");const A=document.createElement("span");A.setAttribute("data-icon",h),A.setAttribute("data-icon-size","15"),A.style.cssText="display:inline-flex;align-items:center;",v.appendChild(A),v.addEventListener("click",()=>{T(t,h),L()}),r.appendChild(v)}if($.length>d){const h=document.createElement("div");h.style.cssText=k,h.textContent=`${$.length-d} more - refine search`,r.appendChild(h)}if(!$.length){const h=document.createElement("div");h.style.cssText=k,h.textContent="No icons match",r.appendChild(h)}window.I&&I.scan(r)};let m=null;return s.addEventListener("input",()=>{clearTimeout(m),m=setTimeout(b,120)}),b(),setTimeout(()=>s.focus(),0),i})}function Le(e,t,n){const o=n==null||n===!0?e.default??"":n;return C(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const c=g();c.style.minHeight="48px";const i=typeof E<"u"&&E.loader?E.loader(c,{type:"dots"}):null;return ue(e.source).then(s=>{if(i&&i.destroy(),!l||l.submenu!==c)return;if(c.style.minHeight="",!s.length){const d=document.createElement("div");d.style.cssText=k,d.textContent="Nothing found",c.appendChild(d)}const a=s.some(([d])=>d===o),r=[["","- none -"],...s];o!==""&&!a&&r.push([o,`${o} (missing)`]);for(const[d,b]of r){const m=f(document.createElement("button"));m.type="button",m.style.cssText=u,m.textContent=b,d===o&&(m.style.fontWeight="700"),m.addEventListener("click",()=>{T(t,d===""?null:d),L()}),c.appendChild(m)}}),c})}function _e(e,t){e.appendChild(w(`Effect: ${t.label}`));for(const o of t.attrs||[])e.appendChild(D(o,`${t.name}-${o.name}`));const n=f(document.createElement("button"));n.type="button",n.style.cssText=u,n.innerHTML='<span data-icon="trash" data-icon-size="13" style="display:inline-flex;align-items:center;"></span> Remove effect',n.addEventListener("click",()=>{const o={};for(const c of se(l.span.attrs,t.name))o[c]=null;W(l.textarea,l.span,o),p()}),e.appendChild(n)}function Se(){const e=g();e.appendChild(w("Seasonal themes"));for(const[t,n]of[["auto","Auto (date-detected)"],...Object.entries(ee).map(([o,c])=>[o,c.label])]){const o=f(document.createElement("button"));o.type="button",o.style.cssText=u,o.textContent=n,o.addEventListener("click",()=>{O(l.textarea,`[celebrate theme="${t}" /]`),p()}),e.appendChild(o)}e.appendChild(S()),e.appendChild(w("Celebration effects"));for(const t of["butterflies","ticker-tape","firework","fireworks"]){const n=B.get(t),o=f(document.createElement("button"));o.type="button",o.style.cssText=u,o.textContent=n.label,o.addEventListener("click",()=>{const c=l.textarea;p(),M(c,n)}),e.appendChild(o)}return e}function $e(){const e=g(),t=l.span,n=t&&Y.has(t.name)?t.name:null;for(const o of[...new Set(_.map(c=>c.category))]){const c=_.filter(i=>i.category===o);if(c.length){e.appendChild(w(o));for(const i of c){const s=n&&(i.hosts||[]).includes(n)&&!(i.name in t.attrs),a=f(document.createElement("button"));if(a.type="button",a.style.cssText=u+"justify-content:space-between;",a.appendChild(document.createTextNode(i.label)),s){const r=document.createElement("span");r.textContent=`inject \u2192 [${n}]`,r.style.cssText="opacity:.6;font-size:.7rem;",a.appendChild(r)}a.addEventListener("click",()=>{if(s)z(l.textarea,l.span,i.name,!0);else{const r=i.selfClosing?`[${i.name} /]`:`[${i.name}]
1
+ import{convertSelectionToBlock as Z}from"./selection-to-block.js";import{EDITOR_TOOLS as ee,SHORTCODES as z}from"./shortcode-registry.js";import{EFFECTS as S,CELEBRATION_THEMES as te,getEffectAttrs as H}from"./effect-defs.js";import{boolState as ne,boolValue as oe,findEnclosingShortcode as se,setAttr as D,setAttrs as F,effectAttrKeys as ie}from"./shortcode-tags.js";import{insertAtCursor as P,replaceRange as ce}from"./markdown-toolbar.js";import{clearLookupCache as ae,lookupOptions as le}from"./shortcode-lookups.js";import{insertMenuGroups as re,insertShortcodeByName as W}from"./shortcode-insert.js";import{openShortcodeForm as R}from"./shortcode-form.js";import{pickMedia as de}from"./media-picker.js";import{blockTagSnippet as pe}from"./block-tags.js";import{catalogueNow as me,dommaHelp as ue}from"./domma-catalogue.js";import{SHORTCODE_EXPIRY_FIELDS as fe}from"../../../public/js/shortcode-expiry.mjs";const Y=new Set(fe.map(({name:e})=>e));export function splitTrackingAttrs(e=[]){const t=new Set,n=e.filter(o=>!Y.has(o.name)||t.has(o.name)?!1:(t.add(o.name),!0));return{main:e.filter(o=>!Y.has(o.name)),tracking:n}}function he(e){return le(e,r?.span?.attrs||{})}const xe=z.map(e=>({name:e.name,selfClosing:e.name==="block"?!1:!!e.selfClosing})),j=new Map(z.map(e=>[e.name,e])),B=new Map(S.map(e=>[e.name,e])),be=S.map(e=>({name:e.name,selfClosing:!!e.selfClosing})),Ee=[...xe,...be],q=new Set(["card","box","hero","banner","col","button"]);let r=null;const K="position:fixed;z-index:10000;min-width:210px;max-height:70vh;overflow-y:auto;background:var(--dm-surface,#1c1c30);border:1px solid var(--dm-border,#2a2a40);border-radius:6px;box-shadow:var(--dm-shadow-lg);padding:.3rem;font-size:.83rem;color:var(--dm-text,#e5e5e5);",f="display:flex;align-items:center;gap:.5rem;width:100%;text-align:left;padding:.35rem .55rem;border:none;background:transparent;color:inherit;border-radius:4px;cursor:pointer;font-size:.83rem;",k="padding:.3rem .55rem;color:var(--dm-text-muted,#8a8a9a);font-size:.68rem;text-transform:uppercase;letter-spacing:.06em;",M="flex:1;min-width:0;padding:.2rem .4rem;background:var(--dm-input-bg,#12121e);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.8rem;",ye="height:1px;background:var(--dm-border,#2a2a40);margin:.3rem .2rem;";function h(e){return e.addEventListener("mouseenter",()=>{e.style.background="var(--dm-primary,#4338ca)",e.style.color="var(--dm-primary-text,#fff)"}),e.addEventListener("mouseleave",()=>{e.style.background="transparent",e.style.color="inherit"}),e}export function attachContextMenu(e,{blocks:t=()=>[],openBlock:n=null}={}){const o=()=>{const i=t()||[],s=i.filter(a=>a.shortTag&&!j.has(a.name)&&!B.has(a.name));return{defs:i,specs:[...Ee,...s.map(a=>({name:a.name,selfClosing:a.selfClosing}))]}},c=(i,s)=>{p();const{defs:a,specs:l}=o();X(e,se(e,l),i,s,a,n)};return typeof Domma>"u"||!Domma.elements?.contextMenu?(e.addEventListener("contextmenu",i=>{i.preventDefault(),c(i.clientX,i.clientY)}),null):Domma.elements.contextMenu(e,{inherit:!1,cursor:!1,render:i=>{c(i.x,i.y)}})}function p(){r&&(_(),r.root.remove(),document.removeEventListener("mousedown",U,!0),document.removeEventListener("keydown",V,!0),window.removeEventListener("scroll",G,!0),r=null)}const U=e=>{r&&!r.root.contains(e.target)&&!(r.submenu&&r.submenu.contains(e.target))&&p()},G=e=>{r&&!r.root.contains(e.target)&&!(r.submenu&&r.submenu.contains(e.target))&&p()},V=e=>{e.key==="Escape"&&p()};function X(e,t,n,o,c=[],i=null){ae();const s=document.createElement("div");s.className="dm-sc-menu",s.style.cssText=K,r={root:s,textarea:e,span:t,submenu:null,blocks:c,openBlock:i,keepEmpty:!1};const a=new Map(c.map(b=>[b.name,b])),l=t&&(j.get(t.name)||B.get(t.name)),d=t&&(l?t.name==="block"?a.get(String(t.attrs.template||"")):null:a.get(t.name)),m=t&&q.has(t.name)?S.filter(b=>b.name in t.attrs):[];l&&Ce(s,l),d&&ve(s,d,!!l);for(const b of m)$e(s,b);(l||d||m.length)&&s.appendChild(L()),s.appendChild(y("Celebrations\u2026",()=>Ie())),s.appendChild(y("Add effect\u2026",()=>Re())),s.appendChild(y("Insert\u2026",()=>Me()));const u=e.selectionStart!==e.selectionEnd;if(u&&e.value.slice(e.selectionStart,e.selectionEnd).trim()){const b={start:e.selectionStart,end:e.selectionEnd,source:e.value},g=h(document.createElement("button"));g.type="button",g.style.cssText=f,g.textContent="Convert selection to Domma Block\u2026",g.addEventListener("click",()=>{p(),Z(e,b)}),s.appendChild(g)}(t||u)&&s.appendChild(y(u?"Wrap selection in\u2026":"Wrap in\u2026",()=>Oe())),c.length&&(s.appendChild(L()),s.appendChild(y("Add block\u2026",()=>Ne()))),document.body.appendChild(s),Q(s,n,o),document.addEventListener("mousedown",U,!0),document.addEventListener("keydown",V,!0),window.addEventListener("scroll",G,!0),window.I&&I.scan(s)}function L(){const e=document.createElement("div");return e.style.cssText=ye,e}function v(e){const t=document.createElement("div");return t.style.cssText=k,t.textContent=e,t}function Ce(e,t){e.appendChild(v(`${t.label} options`));const n=h(document.createElement("button"));n.type="button",n.style.cssText=f,n.innerHTML='<span data-icon="edit" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>',n.appendChild(document.createTextNode(`Edit ${t.label}\u2026`)),n.addEventListener("click",()=>{const{textarea:a,span:l}=r;p(),R(a,{...t,attrs:H(t,l.attrs)},{span:l})}),e.appendChild(n);for(const a of t.actions||[]){const l=h(document.createElement("button"));l.type="button",l.style.cssText=f,l.innerHTML=`<span data-icon="${a.icon||"zap"}" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>`,l.appendChild(document.createTextNode(a.label)),l.addEventListener("click",()=>{const{textarea:d,span:m}=r;if(a.remove){ce(d,m.openTagStart,m.openTagEnd,""),p();return}r.span=F(d,m,a.set||{}),p()}),e.appendChild(l)}const o=Array.isArray(t.quickAttrs)?new Set(t.quickAttrs):null,{main:c,tracking:i}=splitTrackingAttrs(H(t,r.span.attrs)),s=c.filter(a=>!o||o.has(a.name));(t.actions||[]).length&&s.length&&e.appendChild(L());for(const a of s)e.appendChild(N(a));i.length&&(((t.actions||[]).length||s.length)&&e.appendChild(L()),e.appendChild(y("Tracking",()=>{const a=C();a.appendChild(v("Tracking options"));for(const l of i)a.appendChild(ge(l));return a})))}function ge(e){if(e.type!=="select")return N(e);const t=document.createElement("label");t.style.cssText=f+"cursor:default;";const n=document.createElement("span");n.textContent=e.label,n.style.cssText="white-space:nowrap;color:var(--dm-text-muted,#9a9aac);";const o=document.createElement("select");o.style.cssText=M+"max-width:140px;";const c=r.span.attrs[e.name],i=c==null||c===!0?e.default??"":c;for(const[s,a]of e.options||[]){const l=document.createElement("option");l.value=s,l.textContent=a,l.selected=s===i,o.appendChild(l)}return o.addEventListener("change",()=>w(e.name,o.value)),t.append(n,o),t}function ve(e,t,n){const{span:o}=r;if(r.keepEmpty=!0,n&&e.appendChild(L()),e.appendChild(v(n?`${t.name} parameters`:`${t.name} block`)),t.description&&!n){const s=document.createElement("div");s.style.cssText="padding:0 .55rem .3rem;font-size:.75rem;color:var(--dm-text-muted,#9a9aac);max-width:260px;",s.textContent=t.description,e.appendChild(s)}const c=(s,a,l)=>{const d=h(document.createElement("button"));d.type="button",d.style.cssText=f,d.innerHTML=`<span data-icon="${s}" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>`,d.appendChild(document.createTextNode(a)),d.addEventListener("click",l),e.appendChild(d)};t.attrs.length&&c("edit","Edit parameters\u2026",()=>{const{textarea:s}=r;p(),R(s,{...t,name:o.name,label:t.name},{span:o})});const{openBlock:i}=r;c(i?"layout":"external-link",i?"Edit the block":"Open the block",()=>{p(),i?i(t.name):location.hash=`#/blocks/edit/${encodeURIComponent(t.name)}`});for(const s of t.attrs)e.appendChild(N(s));if(!t.attrs.length){const s=document.createElement("div");s.style.cssText=k+"text-transform:none;letter-spacing:0;",s.textContent="This block takes no parameters.",e.appendChild(s)}}function N(e,t=e.name){const n=we(e,t),o=e.domma?ue(me(),e):"";return o&&n&&!n.title&&(n.title=o),n}function we(e,t){const n=r.span.attrs[t];switch(e.type){case"checkbox":return Te(e,t,ne(n,e.default));case"select":return _e(e,t,n);case"lookup":return Ae(e,t,n);case"colour":return Le(e,t,n);case"icon":return Se(e,t,n);default:return ke(e,t,n)}}function w(e,t){if(r.span=D(r.textarea,r.span,e,r.keepEmpty&&t==null?"":t,{keepEmpty:r.keepEmpty}),e==="theme"){const{textarea:n,span:o,root:c}=r,i=c.getBoundingClientRect(),{blocks:s,openBlock:a}=r;p(),X(n,o,i.left,i.top,s,a)}}function Te(e,t,n){const o=h(document.createElement("label"));o.style.cssText=f;const c=document.createElement("input");return c.type="checkbox",c.checked=n,c.addEventListener("change",()=>w(t,oe(e,c.checked))),o.appendChild(c),o.appendChild(document.createTextNode(e.label)),o}function ke(e,t,n){const o=document.createElement("div");o.style.cssText=f+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.cssText="white-space:nowrap;color:var(--dm-text-muted,#9a9aac);";const i=document.createElement("input");i.type=e.type==="number"?"number":"text",i.value=n===!0||n==null?"":n,e.default!=null&&e.default!==""&&(i.placeholder=String(e.default)),i.style.cssText=M;let s=null;if(i.addEventListener("input",()=>{clearTimeout(s),s=setTimeout(()=>w(t,i.value.trim()),180)}),i.addEventListener("mousedown",a=>a.stopPropagation()),o.appendChild(c),o.appendChild(i),e.type==="image"){const a=document.createElement("button");a.type="button",a.textContent="Browse",a.title="Choose from Media",a.style.cssText="padding:2px 8px;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:inherit;cursor:pointer;flex-shrink:0;font:inherit;",a.addEventListener("mousedown",l=>l.stopPropagation()),a.addEventListener("click",async()=>{const{textarea:l,span:d}=r;p();const m=await de({current:i.value.trim()});m&&l.isConnected&&D(l,d,t,m)}),o.appendChild(a)}return o}function Le(e,t,n){const o=document.createElement("div");o.style.cssText=f+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.flex="1";const i=document.createElement("input");return i.type="color",typeof n=="string"&&/^#/.test(n)?i.value=n:typeof e.default=="string"&&/^#/.test(e.default)&&(i.value=e.default),i.addEventListener("input",()=>w(t,i.value)),o.appendChild(c),o.appendChild(i),o}function _e(e,t,n){const o=n==null||n===!0?e.default??"":n;return y(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const c=C();for(const[i,s]of e.options||[]){const a=h(document.createElement("button"));a.type="button",a.style.cssText=f,a.textContent=s,i===o&&(a.style.fontWeight="700"),a.addEventListener("click",()=>{w(t,i),_()}),c.appendChild(a)}return c})}function Se(e,t,n){const o=n==null||n===!0?"":String(n),c=o?`${e.label}: ${o}`:e.label;return y(c,()=>{const i=C();i.style.width="232px";const s=document.createElement("input");s.type="text",s.placeholder="Search icons\u2026",s.style.cssText=M+"margin:6px;width:calc(100% - 12px);",s.addEventListener("mousedown",b=>b.stopPropagation()),i.appendChild(s);const a=h(document.createElement("button"));a.type="button",a.style.cssText=f,a.textContent="- none -",o||(a.style.fontWeight="700"),a.addEventListener("click",()=>{w(t,null),_()}),i.appendChild(a);const l=document.createElement("div");l.style.cssText="display:flex;flex-wrap:wrap;gap:2px;padding:4px 6px;max-height:220px;overflow-y:auto;",i.appendChild(l);const d=96,m=()=>{const b=typeof I<"u"&&typeof I.list=="function"?I.list():[],g=s.value.trim().toLowerCase(),A=g?b.filter(x=>x.toLowerCase().includes(g)):b;l.replaceChildren();for(const x of A.slice(0,d)){const T=h(document.createElement("button"));T.type="button",T.title=x,T.style.cssText="width:26px;height:26px;display:inline-flex;align-items:center;justify-content:center;background:none;border:1px solid transparent;border-radius:4px;cursor:pointer;color:inherit;",x===o&&(T.style.borderColor="var(--dm-primary,#5b8cff)");const $=document.createElement("span");$.setAttribute("data-icon",x),$.setAttribute("data-icon-size","15"),$.style.cssText="display:inline-flex;align-items:center;",T.appendChild($),T.addEventListener("click",()=>{w(t,x),_()}),l.appendChild(T)}if(A.length>d){const x=document.createElement("div");x.style.cssText=k,x.textContent=`${A.length-d} more - refine search`,l.appendChild(x)}if(!A.length){const x=document.createElement("div");x.style.cssText=k,x.textContent="No icons match",l.appendChild(x)}window.I&&I.scan(l)};let u=null;return s.addEventListener("input",()=>{clearTimeout(u),u=setTimeout(m,120)}),m(),setTimeout(()=>s.focus(),0),i})}function Ae(e,t,n){const o=n==null||n===!0?e.default??"":n;return y(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const c=C();c.style.minHeight="48px";const i=typeof E<"u"&&E.loader?E.loader(c,{type:"dots"}):null;return he(e.source).then(s=>{if(i&&i.destroy(),!r||r.submenu!==c)return;if(c.style.minHeight="",!s.length){const d=document.createElement("div");d.style.cssText=k,d.textContent="Nothing found",c.appendChild(d)}const a=s.some(([d])=>d===o),l=[["","- none -"],...s];o!==""&&!a&&l.push([o,`${o} (missing)`]);for(const[d,m]of l){const u=h(document.createElement("button"));u.type="button",u.style.cssText=f,u.textContent=m,d===o&&(u.style.fontWeight="700"),u.addEventListener("click",()=>{w(t,d===""?null:d),_()}),c.appendChild(u)}}),c})}function $e(e,t){e.appendChild(v(`Effect: ${t.label}`));for(const o of t.attrs||[])e.appendChild(N(o,`${t.name}-${o.name}`));const n=h(document.createElement("button"));n.type="button",n.style.cssText=f,n.innerHTML='<span data-icon="trash" data-icon-size="13" style="display:inline-flex;align-items:center;"></span> Remove effect',n.addEventListener("click",()=>{const o={};for(const c of ie(r.span.attrs,t.name))o[c]=null;F(r.textarea,r.span,o),p()}),e.appendChild(n)}function Ie(){const e=C();e.appendChild(v("Seasonal themes"));for(const[t,n]of[["auto","Auto (date-detected)"],...Object.entries(te).map(([o,c])=>[o,c.label])]){const o=h(document.createElement("button"));o.type="button",o.style.cssText=f,o.textContent=n,o.addEventListener("click",()=>{P(r.textarea,`[celebrate theme="${t}" /]`),p()}),e.appendChild(o)}e.appendChild(L()),e.appendChild(v("Celebration effects"));for(const t of["butterflies","ticker-tape","firework","fireworks"]){const n=B.get(t),o=h(document.createElement("button"));o.type="button",o.style.cssText=f,o.textContent=n.label,o.addEventListener("click",()=>{const c=r.textarea;p(),R(c,n)}),e.appendChild(o)}return e}function Re(){const e=C(),t=r.span,n=t&&q.has(t.name)?t.name:null;for(const o of[...new Set(S.map(c=>c.category))]){const c=S.filter(i=>i.category===o);if(c.length){e.appendChild(v(o));for(const i of c){const s=n&&(i.hosts||[]).includes(n)&&!(i.name in t.attrs),a=h(document.createElement("button"));if(a.type="button",a.style.cssText=f+"justify-content:space-between;",a.appendChild(document.createTextNode(i.label)),s){const l=document.createElement("span");l.textContent=`inject \u2192 [${n}]`,l.style.cssText="opacity:.6;font-size:.7rem;",a.appendChild(l)}a.addEventListener("click",()=>{if(s)D(r.textarea,r.span,i.name,!0);else{const l=i.selfClosing?`[${i.name} /]`:`[${i.name}]
2
2
  Content
3
- [/${i.name}]`;O(l.textarea,r)}p()}),e.appendChild(a)}}}return e}function C(e,t){const n=f(document.createElement("button"));n.type="button",n.style.cssText=u+"justify-content:space-between;",n.appendChild(document.createTextNode(e));const o=document.createElement("span");return o.setAttribute("data-icon","chevron-right"),o.setAttribute("data-icon-size","12"),o.style.cssText="opacity:.6;display:inline-flex;align-items:center;flex-shrink:0;",n.appendChild(o),n.addEventListener("mouseenter",()=>X(n,t)),n.addEventListener("click",c=>{c.stopPropagation(),X(n,t)}),n}function g(){const e=document.createElement("div");return e.className="dm-sc-submenu",e.style.cssText=q,e}function X(e,t){L();const n=t();l.submenu=n,document.body.appendChild(n);const o=e.getBoundingClientRect();J(n,o.right+2,o.top,o.left-2),window.I&&I.scan(n)}function L(){l&&l.submenu&&(l.submenu.remove(),l.submenu=null)}function N(e){const t=f(document.createElement("button"));if(t.type="button",t.style.cssText=u,e.icon){const n=document.createElement("span");n.setAttribute("data-icon",e.icon),n.setAttribute("data-icon-size","14"),n.style.cssText="opacity:.75;display:inline-flex;align-items:center;flex-shrink:0;",t.appendChild(n)}return t.appendChild(document.createTextNode(e.label)),t}function Ae(){const e=g();for(const{category:t,items:n}of le()){e.appendChild(w(t));for(const o of n){const c=N(o);c.addEventListener("click",()=>{const i=l.textarea;p(),j(o.name,i)}),e.appendChild(c)}}return e}function Me(){const e=g();e.style.maxWidth="320px";const t=document.createElement("input");t.type="text",t.placeholder="Find a block\u2026",t.style.cssText=P+"margin:6px;width:calc(100% - 12px);",t.addEventListener("mousedown",c=>c.stopPropagation());const n=document.createElement("div");e.append(t,n);const o=()=>{const c=t.value.trim().toLowerCase(),i=l.blocks.filter(s=>!c||s.name.includes(c)||s.description.toLowerCase().includes(c));n.replaceChildren();for(const s of i){const a=N(s);if(s.description&&(a.title=s.description),!s.shortTag){const r=document.createElement("small");r.style.cssText="margin-left:auto;opacity:.6;",r.textContent="[block]",r.title='A built-in shortcode has this name, so it goes in as [block template="\u2026"]',a.appendChild(r)}a.addEventListener("click",()=>{const r=l.textarea;p();const d=r.selectionStart,b=de(s);O(r,b);const m=b.indexOf('=""');m>=0&&r.setSelectionRange(d+m+2,d+m+2),r.focus()}),n.appendChild(a)}if(!i.length){const s=document.createElement("div");s.style.cssText=k,s.textContent="No blocks match",n.appendChild(s)}window.I&&I.scan(n)};return t.addEventListener("input",o),o(),setTimeout(()=>t.focus(),0),e}function Ie(){const e=g();for(const t of R.filter(n=>n.wrappable||n.container)){const n=N(t);n.addEventListener("click",()=>{const o=l.textarea;p(),M(o,t)}),e.appendChild(n)}for(const t of Z.filter(n=>n.wrappable)){const n=N(t);n.addEventListener("click",()=>{const o=l.textarea;p(),j(t.name,o)}),e.appendChild(n)}return e}function J(e,t,n,o){e.style.left="0px",e.style.top="0px";const c=e.getBoundingClientRect();let i=t;t+c.width>window.innerWidth-8&&(i=o!=null?o-c.width:t-c.width);let s=n;n+c.height>window.innerHeight-8&&(s=Math.max(8,window.innerHeight-c.height-8)),e.style.left=`${Math.max(8,i)}px`,e.style.top=`${Math.max(8,s)}px`}
3
+ [/${i.name}]`;P(r.textarea,l)}p()}),e.appendChild(a)}}}return e}function y(e,t){const n=h(document.createElement("button"));n.type="button",n.style.cssText=f+"justify-content:space-between;",n.appendChild(document.createTextNode(e));const o=document.createElement("span");return o.setAttribute("data-icon","chevron-right"),o.setAttribute("data-icon-size","12"),o.style.cssText="opacity:.6;display:inline-flex;align-items:center;flex-shrink:0;",n.appendChild(o),n.addEventListener("mouseenter",()=>J(n,t)),n.addEventListener("click",c=>{c.stopPropagation(),J(n,t)}),n}function C(){const e=document.createElement("div");return e.className="dm-sc-submenu",e.style.cssText=K,e}function J(e,t){_();const n=t();r.submenu=n,document.body.appendChild(n);const o=e.getBoundingClientRect();Q(n,o.right+2,o.top,o.left-2),window.I&&I.scan(n)}function _(){r&&r.submenu&&(r.submenu.remove(),r.submenu=null)}function O(e){const t=h(document.createElement("button"));if(t.type="button",t.style.cssText=f,e.icon){const n=document.createElement("span");n.setAttribute("data-icon",e.icon),n.setAttribute("data-icon-size","14"),n.style.cssText="opacity:.75;display:inline-flex;align-items:center;flex-shrink:0;",t.appendChild(n)}return t.appendChild(document.createTextNode(e.label)),t}function Me(){const e=C();for(const{category:t,items:n}of re()){e.appendChild(v(t));for(const o of n){const c=O(o);c.addEventListener("click",()=>{const i=r.textarea;p(),W(o.name,i)}),e.appendChild(c)}}return e}function Ne(){const e=C();e.style.maxWidth="320px";const t=document.createElement("input");t.type="text",t.placeholder="Find a block\u2026",t.style.cssText=M+"margin:6px;width:calc(100% - 12px);",t.addEventListener("mousedown",c=>c.stopPropagation());const n=document.createElement("div");e.append(t,n);const o=()=>{const c=t.value.trim().toLowerCase(),i=r.blocks.filter(s=>!c||s.name.includes(c)||s.description.toLowerCase().includes(c));n.replaceChildren();for(const s of i){const a=O(s);if(s.description&&(a.title=s.description),!s.shortTag){const l=document.createElement("small");l.style.cssText="margin-left:auto;opacity:.6;",l.textContent="[block]",l.title='A built-in shortcode has this name, so it goes in as [block template="\u2026"]',a.appendChild(l)}a.addEventListener("click",()=>{const l=r.textarea;p();const d=l.selectionStart,m=pe(s);P(l,m);const u=m.indexOf('=""');u>=0&&l.setSelectionRange(d+u+2,d+u+2),l.focus()}),n.appendChild(a)}if(!i.length){const s=document.createElement("div");s.style.cssText=k,s.textContent="No blocks match",n.appendChild(s)}window.I&&I.scan(n)};return t.addEventListener("input",o),o(),setTimeout(()=>t.focus(),0),e}function Oe(){const e=C();for(const t of z.filter(n=>n.wrappable||n.container)){const n=O(t);n.addEventListener("click",()=>{const o=r.textarea;p(),R(o,t)}),e.appendChild(n)}for(const t of ee.filter(n=>n.wrappable)){const n=O(t);n.addEventListener("click",()=>{const o=r.textarea;p(),W(t.name,o)}),e.appendChild(n)}return e}function Q(e,t,n,o){e.style.left="0px",e.style.top="0px";const c=e.getBoundingClientRect();let i=t;t+c.width>window.innerWidth-8&&(i=o!=null?o-c.width:t-c.width);let s=n;n+c.height>window.innerHeight-8&&(s=Math.max(8,window.innerHeight-c.height-8)),e.style.left=`${Math.max(8,i)}px`,e.style.top=`${Math.max(8,s)}px`}
@@ -44,4 +44,4 @@ Optional body content.
44
44
  [/table]`,attrs:[{name:"striped",type:"checkbox",label:"Striped"},{name:"bordered",type:"checkbox",label:"Bordered"},{name:"compact",type:"checkbox",label:"Compact"},{name:"caption",type:"text",label:"Caption"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"badge",label:"Badge",icon:"badge",category:"Content",selfClosing:!1,container:!1,wrappable:!1,template:'[badge variant="success"]New[/badge]',inline:!0,attrs:[{name:"variant",type:"select",label:"Variant",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"],["light","Light"],["dark","Dark"]]},{name:"pill",type:"checkbox",label:"Pill"},{name:"outline",type:"checkbox",label:"Outline"},{name:"size",type:"select",label:"Size",options:[["","Default"],["small","Small"],["large","Large"]]}]},{name:"text",label:"Text",icon:"text-style",preview:"text",category:"Content",selfClosing:!1,container:!0,wrappable:!0,template:"[text]Styled text[/text]",inline:!0,actions:[{label:"Highlight - gradient with a shine",icon:"star",set:{gradient:"sunset",shine:"hover"}},{label:"Highlight that sweeps by itself",icon:"star",set:{gradient:"sunset",shine:"sweep"}},{label:"Light up as you read",icon:"eye",set:{"light-up":"true"}},{label:"Rise in word by word",icon:"arrow-up",set:{words:"true"}},{label:"Plain - no highlight or motion",icon:"minimize",set:{gradient:null,shine:null,"light-up":null,words:null}}],quickAttrs:["gradient","shine","align","size","bold","color"],attrs:[{name:"size",type:"select",label:"Size",options:[["xs","XS"],["sm","Small"],["base","Base"],["lg","Large"],["xl","XL"],["2xl","2XL"],["3xl","3XL"],["4xl","4XL"]]},{name:"weight",type:"select",label:"Weight",options:[["thin","Thin"],["light","Light"],["normal","Normal"],["medium","Medium"],["semibold","Semibold"],["bold","Bold"],["extrabold","Extra bold"],["black","Black"]]},{name:"point-size",type:"number",label:"Point size"},{name:"bold",type:"checkbox",label:"Bold"},{name:"italic",type:"checkbox",label:"Italic"},{name:"color",type:"colour",label:"Colour"},{name:"font",type:"select",label:"Font",options:Object.keys(l).map(e=>[e,n(e)?`${e} (licensed)`:e])},{name:"transform",type:"select",label:"Transform",options:[["upper","Uppercase"],["lower","Lowercase"],["capitalize","Capitalise"],["none","None"]]},{name:"decoration",type:"select",label:"Decoration",options:[["underline","Underline"],["line-through","Line through"],["none","None"]]},{name:"spacing",type:"select",label:"Letter spacing",options:[["tight","Tight"],["normal","Normal"],["wide","Wide"],["wider","Wider"]]},{name:"align",type:"select",label:"Align",options:[["","None"],["left","Left"],["center","Centre"],["right","Right"],["justify","Justify"]]},{name:"gradient",type:"select",label:"Gradient",options:[["","None"],["brand","Theme"],["sunset","Sunset"],["ocean","Ocean"],["forest","Forest"],["fire","Fire"],["candy","Candy"],["newspaper","Newspaper"],["grey-fire","Grey-fire"],["ice","Ice"],["summer","Summer"],["autumn","Autumn"],["spring","Spring"],["winter","Winter"],["aurora","Aurora"],["twilight","Twilight"],["rose-gold","Rose-gold"],["copper","Copper"],["amethyst","Amethyst"],["lagoon","Lagoon"],["cherry","Cherry"],["lavender","Lavender"],["midnight","Midnight"]]},{name:"shine",type:"select",label:"Shine (gradient)",options:[["","None"],["hover","Follows the pointer"],["sweep","Sweeps across"]]},{name:"light-up",type:"checkbox",label:"Words light up as you scroll"},{name:"words",type:"checkbox",label:"Rise in word by word"},{name:"style",type:"text",label:"Inline CSS"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"button",label:"Button",icon:"btn-insert",category:"Content",selfClosing:!0,container:!1,wrappable:!1,template:'[button href="/contact" variant="primary" label="Get in touch" /]',attrs:[{name:"href",type:"url",label:"Link"},{name:"label",type:"text",label:"Label"},{name:"variant",type:"select",label:"Variant",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"],["outline","Outline"],["ghost","Ghost"],["link","Link"],["outline-success","Outline success"],["outline-danger","Outline danger"],["outline-warning","Outline warning"],["outline-info","Outline info"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"icon",type:"icon",label:"Icon (before)"},{name:"icon-after",type:"icon",label:"Icon (after)"},{name:"target",type:"text",label:"Target"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"link",label:"Link",icon:"link-shortcode",category:"Content",selfClosing:!0,container:!1,wrappable:!1,template:'[link href="/about" label="About us" /]',formats:[{value:"markdown",label:"Markdown link",emit:e=>Object.keys(e).some(t=>t!=="href"&&t!=="label"&&e[t])||!e.href?null:`[${e.label||e.href}](${e.href})`},{value:"shortcode",label:"Link shortcode"}],attrs:[{name:"href",type:"url",label:"Link"},{name:"label",type:"text",label:"Label"},{name:"target",type:"text",label:"Target"},{name:"class",type:"text",label:"CSS class"},{name:"icon",type:"icon",label:"Icon (before)"},{name:"icon-after",type:"icon",label:"Icon (after)"},{name:"id",type:"text",label:"ID"}]},{name:"listgroup",label:"List group",icon:"list",category:"Content",selfClosing:!1,container:!0,wrappable:!1,template:`[listgroup]
45
45
  [item]First item[/item]
46
46
  [item]Second item[/item]
47
- [/listgroup]`,children:{name:"item",min:1,max:20},attrs:[{name:"variant",type:"select",label:"Variant",options:[["","Default"],["flush","Flush"],["numbered","Numbered"],["horizontal","Horizontal"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"itemvariant",type:"select",label:"Item variant",options:[["","Default"],["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"action",type:"checkbox",label:"Actionable items"}]},{name:"collection",label:"Collection",icon:"database",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[collection slug="enquiries" display="table" /]',attrs:[{name:"slug",type:"lookup",source:"collections",label:"Collection"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"limit",type:"number",label:"Limit"},{name:"sort",type:"lookup",source:"collection-fields",label:"Sort field"},{name:"order",type:"select",label:"Order",options:[["desc","Descending"],["asc","Ascending"]]},{name:"title-field",type:"lookup",source:"collection-fields",label:"Title field"},{name:"image-field",type:"lookup",source:"collection-fields",label:"Image field"},{name:"body-field",type:"lookup",source:"collection-fields",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"search",type:"checkbox",label:"Search (table)",default:!0},{name:"sortable",type:"checkbox",label:"Sortable (table)",default:!0},{name:"exportable",type:"checkbox",label:"CSV export"},{name:"page-size",type:"number",label:"Page size"},{name:"empty",type:"text",label:"Empty message"},{name:"scope",type:"select",label:"Scope",options:[["","All"],["mine","Current user"]]},{name:"cta",type:"lookup",source:"actions",label:"CTA action"},{name:"cta-label",type:"text",label:"CTA label"},{name:"cta-icon",type:"icon",label:"CTA icon"},{name:"cta-style",type:"select",label:"CTA style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"cta-confirm",type:"text",label:"CTA confirm text"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"view",label:"View",icon:"eye",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[view slug="products" display="table" limit="50" /]',attrs:[{name:"slug",type:"lookup",source:"views",label:"View"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"limit",type:"number",label:"Limit"},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"title-field",type:"text",label:"Title field"},{name:"image-field",type:"text",label:"Image field"},{name:"body-field",type:"text",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"empty",type:"text",label:"Empty message"}]},{name:"block",label:"Block",icon:"layout",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[block template="post-card" title="My Post" /]',attrs:[{name:"template",type:"lookup",source:"blocks",label:"Template"}]},{name:"form",label:"Form",icon:"file-text",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[form name="contact" /]',attrs:[{name:"name",type:"lookup",source:"forms",label:"Form"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"cta",label:"CTA",icon:"mouse-pointer",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[cta action="send-welcome" entry="abc123" style="primary" label="Send" /]',attrs:[{name:"action",type:"lookup",source:"actions",label:"Action"},{name:"entry",type:"text",label:"Entry ID"},{name:"style",type:"select",label:"Style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"icon",type:"icon",label:"Icon"},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"confirm",type:"text",label:"Confirm text"},{name:"label",type:"text",label:"Label"}]},{name:"menu",label:"Menu",icon:"menu",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[menu slug="legal" /]',attrs:[{name:"slug",type:"lookup",source:"menus",label:"Menu"},{name:"location",type:"lookup",source:"menu-locations",label:"Location slot"},{name:"variant",type:"text",label:"Variant"},{name:"class",type:"text",label:"CSS class"},{name:"depth",type:"number",label:"Max depth"},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"float",type:"select",label:"Floating",options:[["","Menu default"],["no","Render inline here"]]}]},{name:"contents",label:"Page contents (this page)",icon:"list",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[contents numbered="true" /]',actions:[{label:"Number the contents",icon:"hash",set:{numbered:"true"}},{label:"List H2 and H3 headings",icon:"list",set:{headings:"h2h3"}},{label:"Contents on the right",icon:"sidebar-right",set:{side:"right"}},{label:"Collapse the contents to a button",icon:"minimize",set:{collapsible:"true",collapsed:"true"}},{label:"Float the contents",icon:"move",set:{floating:"true","float-anchor":"TR",movable:"true"}},{label:"No contents on this page",icon:"eye-off",set:{hidden:"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["side","headings","numbered","title","collapsible","floating","hidden"],attrs:[{name:"side",type:"select",label:"Side",options:[["","Layout default"],["left","Left"],["right","Right"]]},{name:"width",type:"number",label:"Width (px, 160-480)"},{name:"headings",type:"select",label:"Headings",options:[["","Layout default"],["auto","Sections (H2s, else H3s)"],["h2","H2 only"],["h3","H3 only"],["h2h3","H2 and H3"]]},{name:"numbered",type:"select",label:"Numbered",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"title",type:"text",label:"Title above the list"},{name:"exclude",type:"text",label:"Leave out (headings, comma separated)"},{name:"sticky",type:"select",label:"Stays in view",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"scroll-spy",type:"select",label:"Marks the section being read",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsible",type:"select",label:"Collapsible to a button",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off its edge",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"floating",type:"select",label:"Floating panel",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Layout default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"movable",type:"select",label:"Visitors can move it",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hidden",type:"select",label:"No contents on this page",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Accent"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"}]},{name:"navbar",label:"Navbar settings (this page)",icon:"sliders",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[navbar collapsed="true" /]',actions:[{label:"Collapse the rail on this page",icon:"chevrons-right",set:{collapsible:"true",collapsed:"true",autohide:"false"}},{label:"Autohide the rail on this page",icon:"eye-off",set:{autohide:"true",collapsed:null}},{label:"Keep the rail open on this page",icon:"eye",set:{autohide:"false",collapsed:"false"}},{label:"Hide the bar on scroll on this page",icon:"arrow-up",set:{"hide-on-scroll":"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["position","width","collapsible","collapsed","autohide","hide-on-scroll"],attrs:[{name:"position",type:"select",label:"Position",options:[["","Menu default"],["sticky","Sticky"],["fixed","Fixed"],["static","Static"],["floating","Floating"]]},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"side",type:"select",label:"Rail side",options:[["","Menu default"],["left","Left"],["right","Right"]]},{name:"align",type:"select",label:"Alignment",options:[["","Menu default"],["left","Left"],["centre","Centre"],["right","Right"],["spread","Spread"]]},{name:"width",type:"number",label:"Rail width (px, 160-480)"},{name:"collapsible",type:"select",label:"Collapsible to icons",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off-screen",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hide-on-scroll",type:"select",label:"Hide on scroll (bar)",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover-open",type:"select",label:"Open dropdowns on hover",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"bar",type:"select",label:"Bar shape",options:[["","Menu default"],["pill","Pill"],["segmented","Segmented"],["underline","Underline glide"],["dock","Dock"],["neon","Neon"],["tabs","Tabs"],["tiles","Tiles"],["bubbles","Bubbles"],["brutalist","Brutalist"],["gradient","Gradient band"]]},{name:"shrink",type:"select",label:"Shrink on scroll",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"icons",type:"select",label:"Bar icons",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Accent"]]},{name:"brand",type:"select",label:"Branding shape",options:[["","Menu default"],["pill","Pill"]]},{name:"strip",type:"select",label:"Bar background",options:[["","Menu default"],["none","None - floating pills"],["band","Strip - keep the band"]]},{name:"dropdown",type:"select",label:"Dropdown style",options:[["","Menu default"],["cards","Cards"]]},{name:"tiles",type:"select",label:"Icon tiles (cards)",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Theme colour"],["neutral","Neutral"],["none","No tiles"]]},{name:"morph",type:"select",label:"Slide between cards",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Highlight colour"},{name:"variant",type:"text",label:"Variant"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"},{name:"letter-spacing",type:"text",label:"Letter spacing"},{name:"icon-size",type:"text",label:"Icon size"},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Menu default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"float-x",type:"number",label:"Float offset X (px)"},{name:"float-y",type:"number",label:"Float offset Y (px)"},{name:"float-width",type:"number",label:"Float width (px)"},{name:"float-collapsible",type:"select",label:"Float: collapsible",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"float-movable",type:"select",label:"Float: movable",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"class",type:"text",label:"CSS classes"}]},{name:"theme-switcher",label:"Theme switcher",icon:"palette",category:"Components",selfClosing:!0,container:!1,wrappable:!1,template:"[theme-switcher /]",attrs:[{name:"position",type:"select",label:"Position",options:[["","Inline - where the tag is"],["top-left","Top left"],["top-right","Top right"],["left-center","Left, centred"],["right-center","Right, centred"],["bottom-left","Bottom left"],["bottom-right","Bottom right"]]},{name:"offset-x",type:"number",label:"Offset from the side (px, pinned only)"},{name:"offset-y",type:"number",label:"Offset from the top/bottom (px, pinned only)"},{name:"themes",type:"text",label:"Themes (comma list - blank for the site's)"}]},{name:"icon",label:"Icon",icon:"icon-pick",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[icon name="arrow-right" /]',attrs:[{name:"name",type:"icon",label:"Icon name"},{name:"size",type:"number",label:"Size (px)"},{name:"color",type:"colour",label:"Colour"},{name:"class",type:"text",label:"CSS class"}]},{name:"image",label:"Image",icon:"image-add",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[image src="/media/photo.jpg" alt="" /]',custom:"image",quickAttrs:["zoom","align","width","shadow"],attrs:[{name:"src",type:"image",label:"Image",help:"The picture: choose it from Media, or type a /media/\u2026 path or an https:// address."},{name:"alt",type:"text",label:"Description (alt)",help:"What the picture shows, in a few words. Screen readers and search engines read it. Leave empty only for decoration."},{name:"caption",type:"text",label:"Caption",help:"Shown under the picture, and in the zoom view."},{name:"zoom",type:"checkbox",label:"Click to zoom",help:"Visitors click the picture to see it full size in a viewer: fitted first, then actual size with drag to pan. Best for screenshots with small text. Ignored when the picture has a link."},{name:"width",type:"text",label:"Width (480, 60%, 30rem)",help:"How wide the picture shows. A bare number is pixels. Empty: its own size, never wider than the column."},{name:"align",type:"select",label:"Alignment",options:[["","Default (left)"],["center","Centre"],["right","Right"],["float-left","Float left (text wraps)"],["float-right","Float right (text wraps)"]],help:"Floats let the text run beside the picture; on phones they stack."},{name:"group",type:"text",label:"Zoom group",help:"Give zoomable pictures the same group name and the viewer steps between them with arrows - a gallery or a tour."},{name:"zoom-src",type:"image",label:"Full-size file (zoom)",help:"Optional: a larger file for the zoom view, when the page shows a smaller copy."},{name:"title",type:"text",label:"Hover text (title)"},{name:"max-width",type:"text",label:"Max width (800, 50%)"},{name:"height",type:"text",label:"Height (240, 20rem)",help:"A set height crops the picture to fill the box (see Fit)."},{name:"fit",type:"select",label:"Fit (with a height)",options:[["","Fill and crop (default)"],["contain","Show it all"],["fill","Stretch"],["none","Actual size"],["scale-down","Shrink only"]]},{name:"radius",type:"select",label:"Corners",options:[["","Square"],["sm","Slightly rounded"],["md","Rounded"],["lg","Very rounded"],["full","Circle / pill"]]},{name:"border",type:"checkbox",label:"Border"},{name:"shadow",type:"select",label:"Shadow",options:[["","None"],["sm","Small"],["md","Medium"],["lg","Large"]]},{name:"link",type:"url",label:"Link to",help:"Clicking the picture goes here instead of zooming."},{name:"target",type:"select",label:"Open link in",options:[["","Same tab"],["_blank","New tab"]]},{name:"loading",type:"select",label:"Loading",options:[["","When scrolled near (lazy)"],["eager","Straight away (top of page)"]]},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"embed",label:"Embed",icon:"video",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[embed url="https://youtu.be/dQw4w9WgXcQ" /]',custom:"embed",attrs:[{name:"url",type:"url",label:"URL"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"],["9:16","9:16"],["3:4","3:4"]]},{name:"title",type:"text",label:"Title / caption"},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]},{name:"autoplay",type:"checkbox",label:"Autoplay"},{name:"loop",type:"checkbox",label:"Loop"},{name:"muted",type:"checkbox",label:"Muted"}]}];for(const e of SHORTCODES){e.attrs||(e.attrs=[]);for(const a of o)e.attrs.some(t=>t.name===a.name)||e.attrs.push(a)}export const EDITOR_TOOLS=[{name:"colourpick",label:"Colour picker",icon:"colour-picker",category:"Media",custom:"colourpick"},{name:"component",label:"Component",icon:"component",category:"Components",custom:"component"},{name:"scribe",label:"Scribe",icon:"scribe-insert",category:"Content",custom:"scribe"},{name:"highlight-text",label:"Highlight text",icon:"star",category:"Content",custom:"highlighttext",wrappable:!0}];
47
+ [/listgroup]`,children:{name:"item",min:1,max:20},attrs:[{name:"variant",type:"select",label:"Variant",options:[["","Default"],["flush","Flush"],["numbered","Numbered"],["horizontal","Horizontal"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"itemvariant",type:"select",label:"Item variant",options:[["","Default"],["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"action",type:"checkbox",label:"Actionable items"}]},{name:"collection",label:"Collection",icon:"database",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[collection slug="enquiries" display="table" /]',attrs:[{name:"slug",type:"lookup",source:"collections",label:"Collection"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"limit",type:"number",label:"Limit"},{name:"sort",type:"lookup",source:"collection-fields",label:"Sort field"},{name:"order",type:"select",label:"Order",options:[["desc","Descending"],["asc","Ascending"]]},{name:"title-field",type:"lookup",source:"collection-fields",label:"Title field"},{name:"image-field",type:"lookup",source:"collection-fields",label:"Image field"},{name:"body-field",type:"lookup",source:"collection-fields",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"search",type:"checkbox",label:"Search (table)",default:!0},{name:"sortable",type:"checkbox",label:"Sortable (table)",default:!0},{name:"exportable",type:"checkbox",label:"CSV export"},{name:"page-size",type:"number",label:"Page size"},{name:"empty",type:"text",label:"Empty message"},{name:"scope",type:"select",label:"Scope",options:[["","All"],["mine","Current user"]]},{name:"cta",type:"lookup",source:"actions",label:"CTA action"},{name:"cta-label",type:"text",label:"CTA label"},{name:"cta-icon",type:"icon",label:"CTA icon"},{name:"cta-style",type:"select",label:"CTA style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"cta-confirm",type:"text",label:"CTA confirm text"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"view",label:"View",icon:"eye",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[view slug="products" display="table" limit="50" /]',attrs:[{name:"slug",type:"lookup",source:"views",label:"View"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"limit",type:"number",label:"Limit"},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"title-field",type:"text",label:"Title field"},{name:"image-field",type:"text",label:"Image field"},{name:"body-field",type:"text",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"empty",type:"text",label:"Empty message"}]},{name:"block",label:"Block",icon:"layout",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[block template="post-card" title="My Post" /]',attrs:[{name:"template",type:"lookup",source:"blocks",label:"Template"}]},{name:"form",label:"Form",icon:"file-text",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[form name="contact" /]',attrs:[{name:"name",type:"lookup",source:"forms",label:"Form"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"cta",label:"CTA",icon:"mouse-pointer",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[cta action="send-welcome" entry="abc123" style="primary" label="Send" /]',attrs:[{name:"action",type:"lookup",source:"actions",label:"Action"},{name:"entry",type:"text",label:"Entry ID"},{name:"style",type:"select",label:"Style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"icon",type:"icon",label:"Icon"},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"confirm",type:"text",label:"Confirm text"},{name:"label",type:"text",label:"Label"}]},{name:"menu",label:"Menu",icon:"menu",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[menu slug="legal" /]',attrs:[{name:"slug",type:"lookup",source:"menus",label:"Menu"},{name:"location",type:"lookup",source:"menu-locations",label:"Location slot"},{name:"variant",type:"text",label:"Variant"},{name:"class",type:"text",label:"CSS class"},{name:"depth",type:"number",label:"Max depth"},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"float",type:"select",label:"Floating",options:[["","Menu default"],["no","Render inline here"]]}]},{name:"contents",label:"Page contents (this page)",icon:"list",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[contents numbered="true" /]',actions:[{label:"Number the contents",icon:"hash",set:{numbered:"true"}},{label:"List H2 and H3 headings",icon:"list",set:{headings:"h2h3"}},{label:"Contents on the right",icon:"sidebar-right",set:{side:"right"}},{label:"Collapse the contents to a button",icon:"minimize",set:{collapsible:"true",collapsed:"true"}},{label:"Float the contents",icon:"move",set:{floating:"true","float-anchor":"TR",movable:"true"}},{label:"No contents on this page",icon:"eye-off",set:{hidden:"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["side","headings","numbered","title","collapsible","floating","hidden"],attrs:[{name:"side",type:"select",label:"Side",options:[["","Layout default"],["left","Left"],["right","Right"]]},{name:"width",type:"number",label:"Width (px, 160-480)"},{name:"headings",type:"select",label:"Headings",options:[["","Layout default"],["auto","Sections (H2s, else H3s)"],["h2","H2 only"],["h3","H3 only"],["h2h3","H2 and H3"]]},{name:"numbered",type:"select",label:"Numbered",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"title",type:"text",label:"Title above the list"},{name:"exclude",type:"text",label:"Leave out (headings, comma separated)"},{name:"sticky",type:"select",label:"Stays in view",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"scroll-spy",type:"select",label:"Marks the section being read",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsible",type:"select",label:"Collapsible to a button",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off its edge",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"floating",type:"select",label:"Floating panel",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Layout default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"movable",type:"select",label:"Visitors can move it",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hidden",type:"select",label:"No contents on this page",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Accent"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"}]},{name:"navbar",label:"Navbar settings (this page)",icon:"sliders",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[navbar collapsed="true" /]',actions:[{label:"Collapse the rail on this page",icon:"chevrons-right",set:{collapsible:"true",collapsed:"true",autohide:"false"}},{label:"Autohide the rail on this page",icon:"eye-off",set:{autohide:"true",collapsed:null}},{label:"Keep the rail open on this page",icon:"eye",set:{autohide:"false",collapsed:"false"}},{label:"Hide the bar on scroll on this page",icon:"arrow-up",set:{"hide-on-scroll":"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["position","width","collapsible","collapsed","autohide","hide-on-scroll"],attrs:[{name:"position",type:"select",label:"Position",options:[["","Menu default"],["sticky","Sticky"],["fixed","Fixed"],["static","Static"],["floating","Floating"]]},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"side",type:"select",label:"Rail side",options:[["","Menu default"],["left","Left"],["right","Right"]]},{name:"align",type:"select",label:"Alignment",options:[["","Menu default"],["left","Left"],["centre","Centre"],["right","Right"],["spread","Spread"]]},{name:"width",type:"number",label:"Rail width (px, 160-480)"},{name:"collapsible",type:"select",label:"Collapsible to icons",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off-screen",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hide-on-scroll",type:"select",label:"Hide on scroll (bar)",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover-open",type:"select",label:"Open dropdowns on hover",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"bar",type:"select",label:"Bar shape",options:[["","Menu default"],["pill","Pill"],["segmented","Segmented"],["underline","Underline glide"],["dock","Dock"],["neon","Neon"],["tabs","Tabs"],["tiles","Tiles"],["bubbles","Bubbles"],["brutalist","Brutalist"],["gradient","Gradient band"]]},{name:"shrink",type:"select",label:"Shrink on scroll",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"icons",type:"select",label:"Bar icons",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Accent"]]},{name:"brand",type:"select",label:"Branding shape",options:[["","Menu default"],["pill","Pill"]]},{name:"strip",type:"select",label:"Bar background",options:[["","Menu default"],["none","None - floating pills"],["band","Strip - keep the band"]]},{name:"dropdown",type:"select",label:"Dropdown style",options:[["","Menu default"],["cards","Cards"]]},{name:"tiles",type:"select",label:"Icon tiles (cards)",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Theme colour"],["neutral","Neutral"],["none","No tiles"]]},{name:"morph",type:"select",label:"Slide between cards",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Highlight colour"},{name:"variant",type:"text",label:"Variant"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"},{name:"letter-spacing",type:"text",label:"Letter spacing"},{name:"icon-size",type:"text",label:"Icon size"},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Menu default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"float-x",type:"number",label:"Float offset X (px)"},{name:"float-y",type:"number",label:"Float offset Y (px)"},{name:"float-width",type:"number",label:"Float width (px)"},{name:"float-collapsible",type:"select",label:"Float: collapsible",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"float-movable",type:"select",label:"Float: movable",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"class",type:"text",label:"CSS classes"}]},{name:"theme-switcher",label:"Theme switcher",icon:"palette",category:"Components",selfClosing:!0,container:!1,wrappable:!1,template:"[theme-switcher /]",attrs:[{name:"position",type:"select",label:"Position",options:[["","Inline - where the tag is"],["top-left","Top left"],["top-right","Top right"],["left-center","Left, centred"],["right-center","Right, centred"],["bottom-left","Bottom left"],["bottom-right","Bottom right"]]},{name:"offset-x",type:"number",label:"Offset from the side (px, pinned only)"},{name:"offset-y",type:"number",label:"Offset from the top/bottom (px, pinned only)"},{name:"themes",type:"text",label:"Themes (comma list - blank for the site's)"}]},{name:"icon",label:"Icon",icon:"icon-pick",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[icon name="arrow-right" /]',attrs:[{name:"name",type:"icon",label:"Icon name"},{name:"size",type:"number",label:"Size (px)"},{name:"color",type:"colour",label:"Colour"},{name:"class",type:"text",label:"CSS class"}]},{name:"image",label:"Image",icon:"image-add",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[image src="/media/photo.jpg" alt="" /]',custom:"image",quickAttrs:["zoom","align","width","shadow"],attrs:[{name:"src",type:"image",label:"Image",help:"The picture: choose it from Media, or type a /media/\u2026 path or an https:// address."},{name:"alt",type:"text",label:"Description (alt)",help:"What the picture shows, in a few words. Screen readers and search engines read it. Leave empty only for decoration."},{name:"caption",type:"text",label:"Caption",help:"Shown under the picture, and in the zoom view."},{name:"zoom",type:"checkbox",label:"Click to zoom",help:"Visitors click the picture to see it full size in a viewer: fitted first, then actual size with drag to pan. Best for screenshots with small text. Ignored when the picture has a link."},{name:"width",type:"text",label:"Width (480, 60%, 30rem)",help:"How wide the picture shows. A bare number is pixels. Empty: its own size, never wider than the column."},{name:"align",type:"select",label:"Alignment",options:[["","Default (left)"],["center","Centre"],["right","Right"],["float-left","Float left (text wraps)"],["float-right","Float right (text wraps)"]],help:"Floats let the text run beside the picture; on phones they stack."},{name:"group",type:"text",label:"Zoom group",help:"Give zoomable pictures the same group name and the viewer steps between them with arrows - a gallery or a tour."},{name:"zoom-src",type:"image",label:"Full-size file (zoom)",help:"Optional: a larger file for the zoom view, when the page shows a smaller copy."},{name:"title",type:"text",label:"Hover text (title)"},{name:"max-width",type:"text",label:"Max width (800, 50%)"},{name:"height",type:"text",label:"Height (240, 20rem)",help:"A set height crops the picture to fill the box (see Fit)."},{name:"fit",type:"select",label:"Fit (with a height)",options:[["","Fill and crop (default)"],["contain","Show it all"],["fill","Stretch"],["none","Actual size"],["scale-down","Shrink only"]]},{name:"radius",type:"select",label:"Corners",options:[["","Square"],["sm","Slightly rounded"],["md","Rounded"],["lg","Very rounded"],["full","Circle / pill"]]},{name:"border",type:"checkbox",label:"Border"},{name:"shadow",type:"select",label:"Shadow",options:[["","None"],["sm","Small"],["md","Medium"],["lg","Large"]]},{name:"link",type:"url",label:"Link to",help:"Clicking the picture goes here instead of zooming."},{name:"target",type:"select",label:"Open link in",options:[["","Same tab"],["_blank","New tab"]]},{name:"loading",type:"select",label:"Loading",options:[["","When scrolled near (lazy)"],["eager","Straight away (top of page)"]]},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"map",label:"Map",icon:"map-pin",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[map address="10 Downing Street, London" zoom="15" /]',attrs:[{name:"pin",type:"text",label:"Pin (latitude, longitude)"},{name:"lat",type:"number",label:"Latitude"},{name:"lon",type:"number",label:"Longitude"},{name:"address",type:"text",label:"Address"},{name:"postcode",type:"text",label:"Postcode"},{name:"zoom",type:"number",label:"Zoom (1-20)"},{name:"title",type:"text",label:"Title"},{name:"caption",type:"text",label:"Caption"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"]]},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]}]},{name:"embed",label:"Embed",icon:"video",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[embed url="https://youtu.be/dQw4w9WgXcQ" /]',custom:"embed",attrs:[{name:"url",type:"url",label:"URL"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"],["9:16","9:16"],["3:4","3:4"]]},{name:"title",type:"text",label:"Title / caption"},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]},{name:"autoplay",type:"checkbox",label:"Autoplay"},{name:"loop",type:"checkbox",label:"Loop"},{name:"muted",type:"checkbox",label:"Muted"}]}];for(const e of SHORTCODES){e.attrs||(e.attrs=[]);for(const a of o)e.attrs.some(t=>t.name===a.name)||e.attrs.push(a)}export const EDITOR_TOOLS=[{name:"colourpick",label:"Colour picker",icon:"colour-picker",category:"Media",custom:"colourpick"},{name:"component",label:"Component",icon:"component",category:"Components",custom:"component"},{name:"scribe",label:"Scribe",icon:"scribe-insert",category:"Content",custom:"scribe"},{name:"highlight-text",label:"Highlight text",icon:"star",category:"Content",custom:"highlighttext",wrappable:!0}];
@@ -1 +1 @@
1
- export const FREQUENT_KEY="frequent",FREQUENT_MAX=12;export function findLeaf(e,t){for(const r of e||[])if(!(!r||r.type||r.hidden)){if(Array.isArray(r.items)&&r.items.length){const n=findLeaf(r.items,t);if(n)return n}else if(r.url===t)return r}return null}export function frequentFolder(e,t,{hidden:r=!1}={}){const n=[];for(const o of Array.isArray(t)?t:[]){const i=typeof o=="string"&&o?findLeaf(e,o):null;i&&n.push({text:i.text,url:i.url,...i.icon&&{icon:i.icon},...i.colour&&{colour:i.colour}})}return n.length?{text:"Frequent",key:FREQUENT_KEY,icon:"star",items:n,frequent:!0}:r?null:{text:"Frequent",key:FREQUENT_KEY,icon:"star",items:[],frequent:!0,empty:!0}}export function addFrequent(e,t){const r=(Array.isArray(e)?e:[]).filter(n=>typeof n=="string"&&n);return!t||r.includes(t)||r.length>=12?r:[...r,t]}export function removeFrequent(e,t){return(Array.isArray(e)?e:[]).filter(r=>r!==t)}export function moveFrequent(e,t,r){const n=Array.isArray(e)?[...e]:[],o=n.indexOf(t),i=o+r;return o<0||i<0||i>=n.length||([n[o],n[i]]=[n[i],n[o]]),n}export function storageKey(e){const t=e&&(e.id||e._id||e.email);return`sidebar.frequent.${t?String(t):"anon"}`}export function readFrequent(e){try{const t=S.get(storageKey(e));return Array.isArray(t)?t.filter(r=>typeof r=="string"&&r):[]}catch{return[]}}export function readFrequentHidden(e){try{return S.get(`${storageKey(e)}.hidden`)===!0}catch{return!1}}export function writeFrequentHidden(e,t){try{return S.set(`${storageKey(e)}.hidden`,!!t),!0}catch{return!1}}export function writeFrequent(e,t){try{return S.set(storageKey(e),Array.isArray(t)?t:[]),!0}catch{return!1}}let u=null;export function resetFrequentSync(){u=null}export function saveFrequent(e,t){return e.put("/sidebar/frequent",{urls:readFrequent(t),hidden:readFrequentHidden(t)})}export async function syncFrequent(e,t){const r=t&&(t.id||t._id||t.email);if(!r||u===String(r))return;const n=await e.get("/sidebar/frequent");if(!(!n||typeof n!="object")){if(u=String(r),!n.saved){(readFrequent(t).length||readFrequentHidden(t))&&await saveFrequent(e,t);return}writeFrequent(t,Array.isArray(n.urls)?n.urls:[]),writeFrequentHidden(t,n.hidden===!0)}}
1
+ export const FREQUENT_KEY="frequent",FREQUENT_MAX=16;export function findLeaf(e,t){for(const r of e||[])if(!(!r||r.type||r.hidden)){if(Array.isArray(r.items)&&r.items.length){const n=findLeaf(r.items,t);if(n)return n}else if(r.url===t)return r}return null}export function frequentFolder(e,t,{hidden:r=!1}={}){const n=[];for(const o of Array.isArray(t)?t:[]){const i=typeof o=="string"&&o?findLeaf(e,o):null;i&&n.push({text:i.text,url:i.url,...i.icon&&{icon:i.icon},...i.colour&&{colour:i.colour}})}return n.length?{text:"Frequent",key:FREQUENT_KEY,icon:"star",items:n,frequent:!0}:r?null:{text:"Frequent",key:FREQUENT_KEY,icon:"star",items:[],frequent:!0,empty:!0}}export function addFrequent(e,t){const r=(Array.isArray(e)?e:[]).filter(n=>typeof n=="string"&&n);return!t||r.includes(t)||r.length>=16?r:[...r,t]}export function removeFrequent(e,t){return(Array.isArray(e)?e:[]).filter(r=>r!==t)}export function moveFrequent(e,t,r){const n=Array.isArray(e)?[...e]:[],o=n.indexOf(t),i=o+r;return o<0||i<0||i>=n.length||([n[o],n[i]]=[n[i],n[o]]),n}export function storageKey(e){const t=e&&(e.id||e._id||e.email);return`sidebar.frequent.${t?String(t):"anon"}`}export function readFrequent(e){try{const t=S.get(storageKey(e));return Array.isArray(t)?t.filter(r=>typeof r=="string"&&r):[]}catch{return[]}}export function readFrequentHidden(e){try{return S.get(`${storageKey(e)}.hidden`)===!0}catch{return!1}}export function writeFrequentHidden(e,t){try{return S.set(`${storageKey(e)}.hidden`,!!t),!0}catch{return!1}}export function writeFrequent(e,t){try{return S.set(storageKey(e),Array.isArray(t)?t:[]),!0}catch{return!1}}let u=null;export function resetFrequentSync(){u=null}export function saveFrequent(e,t){return e.put("/sidebar/frequent",{urls:readFrequent(t),hidden:readFrequentHidden(t)})}export async function syncFrequent(e,t){const r=t&&(t.id||t._id||t.email);if(!r||u===String(r))return;const n=await e.get("/sidebar/frequent");if(!(!n||typeof n!="object")){if(u=String(r),!n.saved){(readFrequent(t).length||readFrequentHidden(t))&&await saveFrequent(e,t);return}writeFrequent(t,Array.isArray(n.urls)?n.urls:[]),writeFrequentHidden(t,n.hidden===!0)}}
@@ -1,7 +1,7 @@
1
- import{api as g,getUser as w,isAuthenticated as ke}from"../api.js";import{createRequestQueue as qe}from"./background-requests.js";import{requestSidebarCounts as Ce}from"./sidebar-counts.js";import{beginSidebarCounts as Ae,publishSidebarCount as Fe}from"./sidebar-count-cache.js";import{isPathAllowed as Le}from"./admin-scope.js";import{cleanNotify as Ee,noticeFromCount as je}from"./sidebar-notify.js";import{colourToCss as te,applyFloat as Be,applyHighlight as Oe,itemHighlightAttrs as Me}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{placeTools as Te,ensureLockedTools as Ne,managePluginsItem as He,stripItemByUrl as Re,insertFoldersBeforeSystem as Ie,pruneEmptyToolsFolder as Pe,sidebarStateKey as ne,canAny as W,filterByPermission as _e,MANAGE_PLUGINS_URL as se}from"./sidebar-grouping.js";import{arrangeButtonMarkup as Ue,canArrange as ze,startArrange as We}from"./sidebar-arrange.js";import{collapseButtonMarkup as De,wireSidebarSize as Ge,COLLAPSED_WIDTH as Ke}from"./sidebar-size.js";import{FREQUENT_MAX as oe,addFrequent as Ve,frequentFolder as Xe,moveFrequent as ie,readFrequent as K,readFrequentHidden as Ze,removeFrequent as Je,saveFrequent as Ye,syncFrequent as Qe,writeFrequent as et,writeFrequentHidden as ae}from"./sidebar-frequent.js";import{hotkeyFor as re,hotkeyTitle as tt,setHotkeyTree as nt}from"./hotkeys-ui.js";import{hotkeyLabel as st}from"./hotkeys.js";function m(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const ot=[{text:"Dashboard",url:"#/",icon:"home"},{text:"Site menus",url:"#/menus",icon:"menu",permission:"menus"}];async function it(e){if(!W(e,"projects"))return[];let n=[];try{n=await g.projects.listWithCounts()}catch{return[]}if(!Array.isArray(n))return[];const t=[{key:"pages",text:"Pages",icon:"file-text",path:"/pages"},{key:"collections",text:"Collections",icon:"database",path:"/collections"},{key:"forms",text:"Forms",icon:"layout",path:"/forms"},{key:"actions",text:"Actions",icon:"zap",path:"/actions"},{key:"menus",text:"Site menus",icon:"menu",path:"/menus"},{key:"blocks",text:"Blocks",icon:"box",path:"/blocks"},{key:"components",text:"Components",icon:"component",path:"/components"},{key:"views",text:"Views",icon:"eye",path:"/views"},{key:"roles",text:"Roles",icon:"shield",path:"/roles"},{key:"users",text:"Users",icon:"users",path:"/users"},{key:"apis",text:"APIs",icon:"code",path:"/apis"}];return n.map(o=>{const r="#/projects/"+encodeURIComponent(o.slug),u=o.counts||{},i=[{text:"Overview",url:r,icon:o.icon||"folder"}];for(const d of t){const l=Number(u[d.key])||0;l<=0||i.push({text:`${d.text} (${l})`,url:r+d.path,icon:d.icon})}i.push({text:"Settings",url:r+"/settings",icon:"settings"});const a=o.enabled===!1;return{text:o.name||o.slug,key:`project.${o.slug}`,icon:o.icon||"folder",items:i,...a&&{colour:"neutral",badge:{text:"off"}}}})}function at(e,n){for(const t of e)if(!t.hidden&&(t.key==="projects"||!t.key&&(t.text||"").toLowerCase()==="projects")){t.items=Array.isArray(t.items)?t.items.slice():[],t.items.push(...n);return}}function le(e,n){const t=de.includes(n.tone)?n.tone:"info",o=n.label||String(n.count);n.details?R.set(e,n.details):R.delete(e);const s=!n.inventory&&j.some(r=>r.url===e&&!r.inventory)?" data-live":"";return`<span class="sidebar-badge sidebar-badge--${t}" data-count-for="${m(e)}"${s} data-badge-label="${m(o)}" aria-label="${m(o)}">${m(String(n.count))}</span>`}function ce(e){for(const n of e.querySelectorAll("details")){const t=n.querySelector(":scope > summary");if(!t)continue;let o=0,s=!1;const r=[];for(const l of n.querySelectorAll(":scope > .sidebar-children .sidebar-badge[data-live]")){const f=Number(l.textContent)||0;f&&(o+=f,s||(s=l.classList.contains("sidebar-badge--danger")),r.push({text:l.closest("a")?.querySelector(".sidebar-text")?.textContent.trim()??"",meta:l.dataset.badgeLabel,tone:l.classList.contains("sidebar-badge--danger")?"danger":void 0}))}const u=`folder:${n.dataset.stateKey||t.textContent.trim()}`;let i=t.querySelector(":scope > .sidebar-badge--sum");if(!o){i?.remove(),R.delete(u);continue}i||(i=document.createElement("span"),t.querySelector(".sidebar-text")?.after(i));const a=t.querySelector(".sidebar-text")?.textContent.trim()||"This folder",d=r.map(l=>`${l.text}: ${l.meta}`).join(" \xB7 ");i.className=`sidebar-badge sidebar-badge--sum sidebar-badge--${s?"danger":"info"}`,i.dataset.countFor=u,i.dataset.badgeLabel=d,i.setAttribute("aria-label",d),i.textContent=String(o),R.set(u,{title:a,items:r})}}const R=new Map;function rt(e,n){if(!e.url||!n)return"";const t=n[e.url];return!t||!(t.count>0)&&!t.showZero?"":le(e.url,t)}const de=["info","attention","danger","live"],lt={"#/pages":["page","pages"],"#/media":["file in the media library","files in the media library"],"#/menus":["menu","menus"],"#/context-menus":["context menu","context menus"],"#/theme":["element override in the theme","element overrides in the theme"],"#/collections":["collection","collections"],"#/forms":["form","forms"],"#/views":["view","views"],"#/actions":["action","actions"],"#/blocks":["block","blocks"],"#/components":["component","components"],"#/users":["user","users"],"#/plugins":["plugin installed","plugins installed"],"#/system/notifications":["unread notification","unread notifications"]};function D(e,{fallbackLabel:n="",tone:t="info"}={}){const o=Number(typeof e=="object"&&e!==null?e.count:e);if(!Number.isFinite(o)||o<0)return null;const s=typeof e?.label=="string"&&e.label||(n?`${o} - ${n}`:String(o)),r={count:Math.round(o),label:s,tone:de.includes(e?.tone)?e.tone:t};e?.details&&typeof e.details=="object"&&(r.details=e.details),e?.inventory===!0&&(r.inventory=!0),e?.showZero===!0&&(r.showZero=!0);const u=Ee(e?.notify);return u&&(r.notify=u),r}function ue(e,n,t=null,{inFrequent:o=!1}={}){if(e&&e.type==="separator")return'<hr class="sidebar-divider">';if(e&&e.type==="theme-switcher")return"";if(e&&e.type==="spacer"){const b=["xs","sm","md","lg","xl","flex"].includes(e.size)?e.size:"md";return`<div class="sidebar-spacer sidebar-spacer--${m(b)}" aria-hidden="true"></div>`}const s=String(e.text||"?").trim().charAt(0).toUpperCase()||"?",r=e.icon?`<span data-icon="${m(e.icon)}"></span>`:`<span class="sidebar-initial" aria-hidden="true">${m(s)}</span>`,u=m(e.text||""),i=e.url?m(e.url):"",a=Array.isArray(e.items)&&e.items.length>0,d=e.colour?te(e.colour):"",l=Me(e),f=[l.hover&&` data-menu-item-hover="${m(l.hover)}"`,l.active&&` data-menu-item-active="${m(l.active)}"`].filter(Boolean).join(""),h=[d&&`color:${m(d)}`,l.accent&&`--dm-menu-highlight:${m(l.accent)}`].filter(Boolean).join(";"),v=h?` style="${h}"`:"",k=e.url?tt(e.url,e.text||"",{inFrequent:o}):"",q=k?` title="${m(k)}"`:"";let F="";if(e.badge&&e.badge.text!=null&&e.badge.text!==""){const b=e.badge.variant?te(e.badge.variant):"";F=`<span class="dm-menu-badge"${b?` style="background:${m(b)};color:var(--dm-text-inverse,#fff)"`:""}>${m(String(e.badge.text))}</span>`}if(e.frequent&&e.empty){const b=ne(e,t),A=S.get(b)!==!1;return`<details data-state-key="${m(b)}"${A?" open":""} data-frequent data-frequent-empty>
1
+ import{syncThemeAwareLogos as qe}from"./theme-aware-logo.js";import{api as g,getUser as k,isAuthenticated as Ce}from"../api.js";import{createRequestQueue as Ae}from"./background-requests.js";import{requestSidebarCounts as Le}from"./sidebar-counts.js";import{beginSidebarCounts as Fe,publishSidebarCount as Ee}from"./sidebar-count-cache.js";import{isPathAllowed as je}from"./admin-scope.js";import{cleanNotify as Be,noticeFromCount as Oe}from"./sidebar-notify.js";import{colourToCss as te,applyFloat as Te,applyHighlight as Me,itemHighlightAttrs as Ne}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{placeTools as He,ensureLockedTools as Re,managePluginsItem as Ie,stripItemByUrl as Pe,insertFoldersBeforeSystem as _e,pruneEmptyToolsFolder as Ue,sidebarStateKey as ne,canAny as G,filterByPermission as ze,MANAGE_PLUGINS_URL as se}from"./sidebar-grouping.js";import{arrangeButtonMarkup as De,canArrange as We,startArrange as Ge}from"./sidebar-arrange.js";import{collapseButtonMarkup as Ke,wireSidebarSize as Ve,COLLAPSED_WIDTH as Xe}from"./sidebar-size.js";import{FREQUENT_MAX as oe,addFrequent as Ze,frequentFolder as Je,moveFrequent as ie,readFrequent as V,readFrequentHidden as Ye,removeFrequent as Qe,saveFrequent as et,syncFrequent as tt,writeFrequent as nt,writeFrequentHidden as ae}from"./sidebar-frequent.js";import{hotkeyFor as re,hotkeyTitle as st,setHotkeyTree as ot}from"./hotkeys-ui.js";import{hotkeyLabel as it}from"./hotkeys.js";function m(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const at=[{text:"Dashboard",url:"#/",icon:"home"},{text:"Site menus",url:"#/menus",icon:"menu",permission:"menus"}];async function rt(e){if(!G(e,"projects"))return[];let n=[];try{n=await g.projects.listWithCounts()}catch{return[]}if(!Array.isArray(n))return[];const t=[{key:"pages",text:"Pages",icon:"file-text",path:"/pages"},{key:"collections",text:"Collections",icon:"database",path:"/collections"},{key:"forms",text:"Forms",icon:"layout",path:"/forms"},{key:"actions",text:"Actions",icon:"zap",path:"/actions"},{key:"menus",text:"Site menus",icon:"menu",path:"/menus"},{key:"blocks",text:"Blocks",icon:"box",path:"/blocks"},{key:"components",text:"Components",icon:"component",path:"/components"},{key:"views",text:"Views",icon:"eye",path:"/views"},{key:"roles",text:"Roles",icon:"shield",path:"/roles"},{key:"users",text:"Users",icon:"users",path:"/users"},{key:"apis",text:"APIs",icon:"code",path:"/apis"}];return n.map(o=>{const r="#/projects/"+encodeURIComponent(o.slug),u=o.counts||{},i=[{text:"Overview",url:r,icon:o.icon||"folder"}];for(const d of t){const l=Number(u[d.key])||0;l<=0||i.push({text:`${d.text} (${l})`,url:r+d.path,icon:d.icon})}i.push({text:"Settings",url:r+"/settings",icon:"settings"});const a=o.enabled===!1;return{text:o.name||o.slug,key:`project.${o.slug}`,icon:o.icon||"folder",items:i,...a&&{colour:"neutral",badge:{text:"off"}}}})}function lt(e,n){for(const t of e)if(!t.hidden&&(t.key==="projects"||!t.key&&(t.text||"").toLowerCase()==="projects")){t.items=Array.isArray(t.items)?t.items.slice():[],t.items.push(...n);return}}function le(e,n){const t=de.includes(n.tone)?n.tone:"info",o=n.label||String(n.count);n.details?I.set(e,n.details):I.delete(e);const s=!n.inventory&&j.some(r=>r.url===e&&!r.inventory)?" data-live":"";return`<span class="sidebar-badge sidebar-badge--${t}" data-count-for="${m(e)}"${s} data-badge-label="${m(o)}" aria-label="${m(o)}">${m(String(n.count))}</span>`}function ce(e){for(const n of e.querySelectorAll("details")){const t=n.querySelector(":scope > summary");if(!t)continue;let o=0,s=!1;const r=[];for(const l of n.querySelectorAll(":scope > .sidebar-children .sidebar-badge[data-live]")){const f=Number(l.textContent)||0;f&&(o+=f,s||(s=l.classList.contains("sidebar-badge--danger")),r.push({text:l.closest("a")?.querySelector(".sidebar-text")?.textContent.trim()??"",meta:l.dataset.badgeLabel,tone:l.classList.contains("sidebar-badge--danger")?"danger":void 0}))}const u=`folder:${n.dataset.stateKey||t.textContent.trim()}`;let i=t.querySelector(":scope > .sidebar-badge--sum");if(!o){i?.remove(),I.delete(u);continue}i||(i=document.createElement("span"),t.querySelector(".sidebar-text")?.after(i));const a=t.querySelector(".sidebar-text")?.textContent.trim()||"This folder",d=r.map(l=>`${l.text}: ${l.meta}`).join(" \xB7 ");i.className=`sidebar-badge sidebar-badge--sum sidebar-badge--${s?"danger":"info"}`,i.dataset.countFor=u,i.dataset.badgeLabel=d,i.setAttribute("aria-label",d),i.textContent=String(o),I.set(u,{title:a,items:r})}}const I=new Map;function ct(e,n){if(!e.url||!n)return"";const t=n[e.url];return!t||!(t.count>0)&&!t.showZero?"":le(e.url,t)}const de=["info","attention","danger","live"],dt={"#/pages":["page","pages"],"#/media":["file in the media library","files in the media library"],"#/menus":["menu","menus"],"#/context-menus":["context menu","context menus"],"#/theme":["element override in the theme","element overrides in the theme"],"#/collections":["collection","collections"],"#/forms":["form","forms"],"#/views":["view","views"],"#/actions":["action","actions"],"#/blocks":["block","blocks"],"#/components":["component","components"],"#/users":["user","users"],"#/plugins":["plugin installed","plugins installed"],"#/system/notifications":["unread notification","unread notifications"]};function K(e,{fallbackLabel:n="",tone:t="info"}={}){const o=Number(typeof e=="object"&&e!==null?e.count:e);if(!Number.isFinite(o)||o<0)return null;const s=typeof e?.label=="string"&&e.label||(n?`${o} - ${n}`:String(o)),r={count:Math.round(o),label:s,tone:de.includes(e?.tone)?e.tone:t};e?.details&&typeof e.details=="object"&&(r.details=e.details),e?.inventory===!0&&(r.inventory=!0),e?.showZero===!0&&(r.showZero=!0);const u=Be(e?.notify);return u&&(r.notify=u),r}function ue(e,n,t=null,{inFrequent:o=!1}={}){if(e&&e.type==="separator")return'<hr class="sidebar-divider">';if(e&&e.type==="theme-switcher")return"";if(e&&e.type==="spacer"){const b=["xs","sm","md","lg","xl","flex"].includes(e.size)?e.size:"md";return`<div class="sidebar-spacer sidebar-spacer--${m(b)}" aria-hidden="true"></div>`}const s=String(e.text||"?").trim().charAt(0).toUpperCase()||"?",r=e.icon?`<span data-icon="${m(e.icon)}"></span>`:`<span class="sidebar-initial" aria-hidden="true">${m(s)}</span>`,u=m(e.text||""),i=e.url?m(e.url):"",a=Array.isArray(e.items)&&e.items.length>0,d=e.colour?te(e.colour):"",l=Ne(e),f=[l.hover&&` data-menu-item-hover="${m(l.hover)}"`,l.active&&` data-menu-item-active="${m(l.active)}"`].filter(Boolean).join(""),h=[d&&`color:${m(d)}`,l.accent&&`--dm-menu-highlight:${m(l.accent)}`].filter(Boolean).join(";"),v=h?` style="${h}"`:"",q=e.url?st(e.url,e.text||"",{inFrequent:o}):"",C=q?` title="${m(q)}"`:"";let F="";if(e.badge&&e.badge.text!=null&&e.badge.text!==""){const b=e.badge.variant?te(e.badge.variant):"";F=`<span class="dm-menu-badge"${b?` style="background:${m(b)};color:var(--dm-text-inverse,#fff)"`:""}>${m(String(e.badge.text))}</span>`}if(e.frequent&&e.empty){const b=ne(e,t),A=S.get(b)!==!1;return`<details data-state-key="${m(b)}"${A?" open":""} data-frequent data-frequent-empty>
2
2
  <summary${v}>${r} <span class="sidebar-text">${u}</span></summary>
3
3
  <div class="sidebar-children"><p class="sidebar-frequent-empty">Right-click any Tool and choose <strong>Add to Frequent</strong> to keep it here.</p></div>
4
- </details>`}if(a){const b=ne(e,t),A=S.get(b)!==!1,B=e.items.map(I=>ue(I,n,b,{inFrequent:!!e.frequent})).join(""),L=e.frequent?' data-frequent title="Your Frequent Tools - right-click any Tool to add or remove it"':"";return`<details data-state-key="${m(b)}"${A?" open":""}${L}>
5
- <summary${v}${q}>${r} <span class="sidebar-text">${u}</span>${F}</summary>
4
+ </details>`}if(a){const b=ne(e,t),A=S.get(b)!==!1,B=e.items.map(P=>ue(P,n,b,{inFrequent:!!e.frequent})).join(""),L=e.frequent?' data-frequent title="Your Frequent Tools - right-click any Tool to add or remove it"':"";return`<details data-state-key="${m(b)}"${A?" open":""}${L}>
5
+ <summary${v}${C}>${r} <span class="sidebar-text">${u}</span>${F}</summary>
6
6
  <div class="sidebar-children">${B}</div>
7
- </details>`}return`<a href="${i}" class="sidebar-link" data-url="${i}"${v}${f}${q}>${r} <span class="sidebar-text">${u}</span>${rt(e,n)}${F}</a>`}async function ct(e=[],n=[],t=null){const o=y=>y.then(C=>Array.isArray(C)?C.length:Array.isArray(C?.entries)?C.entries.length:0).catch(()=>0),s=fe(e,t),r=new Set(s.map(y=>y.url)),u={pages:"#/pages",media:"#/media",menus:"#/menus","context-menus":"#/context-menus",theme:"#/theme",collections:"#/collections",forms:"#/forms",views:"#/views",actions:"#/actions",blocks:"#/blocks",components:"#/components",users:"#/users",plugins:"#/plugins",notifications:"#/system/notifications"},i=(y,C)=>W(n,y)&&!r.has(u[y])?C():Promise.resolve(0),[a,d,l,f,h,v,k,q,F,b,A,B,L,I]=await Promise.all([i("pages",()=>o(g.pages.list())),i("media",()=>o(g.media.list())),i("menus",()=>o(g.menus.list())),i("context-menus",()=>o(g.contextMenus.list())),i("theme",()=>g.theme.get().then(y=>(y?.overrides||[]).length).catch(()=>0)),i("collections",()=>o(g.collections.list())),i("forms",()=>o(g.forms.list())),i("views",()=>o(g.views.list())),i("actions",()=>o(g.actions.list())),i("blocks",()=>o(g.blocks.list())),i("components",()=>o(g.components.list())),i("users",()=>o(g.users.list())),i("plugins",()=>o(g.plugins.list())),i("notifications",()=>g.system?.notifications?.unreadCount?.().then(y=>y?.count??0).catch(()=>0)??Promise.resolve(0))]),P=await pe(s),U={"#/pages":a,"#/media":d,"#/menus":l,"#/context-menus":f,"#/theme":h,"#/collections":v,"#/forms":k,"#/views":q,"#/actions":F,"#/blocks":b,"#/components":A,"#/users":B,"#/plugins":L,"#/system/notifications":I},z={};for(const[y,C]of Object.entries(U)){if(r.has(y))continue;const[G,Y]=lt[y]??["item","items"],O=D(C);O&&(z[y]={...O,label:`${O.count} ${O.count===1?G:Y}`})}return{...z,...P}}let j=[];const dt="dm:sidebar-count",ut=6e4,ft=qe(4);function fe(e=[],n=null){const t=[],o=s=>{if(s&&!(n&&typeof s.url=="string"&&s.url.startsWith("#/")&&!Le(n,s.url.slice(1)))){s.url&&typeof s.countUrl=="string"&&s.countUrl&&t.push({url:s.url,countUrl:s.countUrl,text:s.text||"",countLabel:s.countLabel||"",inventory:s.inventory===!0});for(const r of[...s.children||[],...s.items||[]])o(r)}};for(const s of e??[])o(s?.item??s);return t}async function me(e,{priority:n=!1}={}){try{const t=new Date,o=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,s=e.countUrl+(e.countUrl.includes("?")?"&":"?")+`today=${o}`,r=w()?.id,u=await ft(()=>!ke()||w()?.id!==r?null:H.get(s,{priority:"low"}),{key:JSON.stringify([r,s]),priority:n});return D(u,{fallbackLabel:e.countLabel||e.text})}catch{return null}}function V(e,n,t){Fe(n,t),t?.notify&&je(w()?.id??null,n,t.notify);const o=[...e.querySelectorAll("a.sidebar-link")].filter(s=>s.dataset.url===n);if(o.length){for(const s of o){const r=s.querySelector(".sidebar-badge[data-count-for]");if(!t||!(t.count>0)&&!t.showZero)r?.remove();else{const u=document.createRange();u.selectNodeContents(s);const i=u.createContextualFragment(le(n,t)).firstElementChild;r?r.replaceWith(i):s.querySelector(".sidebar-text")?.after(i)}}X.set(n,t),ce(e)}}const X=new Map;async function pe(e){const n=await Ce(e,{legacy:async t=>{const o=await Promise.all(t.map(async s=>[s.url,await me(s)]));return Object.fromEntries(o)}});return Object.fromEntries(e.map(t=>[t.url,n[t.url]==null?null:D(n[t.url],{fallbackLabel:t.countLabel||t.text})]))}async function Z(e,n=null){const t=w()?.id,o=j;try{const s=n?{[n]:await me(j.find(r=>r.url===n),{priority:!0})}:await pe(j);if(w()?.id!==t||j!==o)return;for(const[r,u]of Object.entries(s)){const i=X.get(r);JSON.stringify(i??null)!==JSON.stringify(u)&&V(e,r,u)}}catch{}}function mt(e){e.dataset.liveCounts||(e.dataset.liveCounts="1",window.addEventListener(dt,n=>{const t=n.detail||{};if(t.url)if(t.count!==void 0){const o=j.find(s=>s.url===t.url);V(e,t.url,D(t,{fallbackLabel:o?.countLabel||o?.text||""}))}else Z(e,t.url)}),setInterval(()=>{!document.hidden&&document.body.contains(e)&&Z(e)},ut),document.addEventListener("visibilitychange",()=>{document.hidden||Z(e)}),pt(e))}function he(e,n,t){const o=(u,i,a)=>{const d=document.createElement(u);return i&&(d.className=i),a!=null&&(d.textContent=String(a)),d};if(!t){e.textContent=n;return}e.appendChild(o("strong","dm-badge-pop-title",t.title||n)),(t.rows?.length||!t.items?.length)&&e.appendChild(o("p","dm-badge-pop-sub",n));const s=Array.isArray(t.rows)?t.rows.slice(0,6):[];if(s.length){const u=o("dl","dm-badge-pop-rows");for(const i of s)u.appendChild(o("dt",null,i.label)),u.appendChild(o("dd",i.tone==="danger"?"is-danger":null,i.value));e.appendChild(u)}const r=Array.isArray(t.items)?t.items.slice(0,6):[];if(r.length){const u=o("ul","dm-badge-pop-items");for(const i of r){const a=o("li",i.tone==="danger"?"is-danger":null);a.appendChild(o("span","dm-badge-pop-text",i.text)),i.meta&&a.appendChild(o("span","dm-badge-pop-meta",i.meta)),u.appendChild(a)}e.appendChild(u)}else t.empty&&e.appendChild(o("p","dm-badge-pop-empty",t.empty))}function pt(e){let n=null,t=null;const o=()=>e.classList.contains("is-collapsed"),s=()=>{clearTimeout(t),n?.remove(),n=null},r=(d,l)=>{s(),t=setTimeout(()=>{n=document.createElement("div"),n.className="dm-help-pop dm-badge-pop",n.setAttribute("role","tooltip"),l(n),document.body.appendChild(n);const f=d.getBoundingClientRect(),h=n.getBoundingClientRect(),v=Math.min(f.right+10,innerWidth-h.width-8);n.style.left=`${Math.max(8,v)}px`,n.style.top=`${Math.max(8,Math.min(f.top+f.height/2-h.height/2,innerHeight-h.height-8))}px`},150)},u=d=>{const l=d?.dataset.badgeLabel;if(!l)return s();r(d,f=>he(f,l,R.get(d.dataset.countFor)))},i=d=>{const l=d.querySelector(":scope > .sidebar-text")?.textContent.trim()||"",f=d.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");r(d,h=>{const v=f&&R.get(f.dataset.countFor);if(v)return he(h,f.dataset.badgeLabel,{...v,title:v.title||l});if(!f){h.textContent=l;return}const k=document.createElement("strong");k.className="dm-badge-pop-title",k.textContent=l;const q=document.createElement("p");q.className="dm-badge-pop-sub",q.textContent=f.dataset.badgeLabel,h.append(k,q)})},a=d=>{const l=d.closest?.("a.sidebar-link, summary");return l&&e.contains(l)?l:null};e.addEventListener("mouseover",d=>{if(o()){const f=a(d.target);f&&!f.contains(d.relatedTarget)&&i(f);return}const l=d.target.closest?.(".sidebar-badge[data-badge-label]");l&&u(l)}),e.addEventListener("mouseout",d=>{if(o()){const l=a(d.target);l&&!l.contains(d.relatedTarget)&&s();return}d.target.closest?.(".sidebar-badge[data-badge-label]")&&s()}),e.addEventListener("focusin",d=>{const l=d.target.closest?.("a, summary");if(o()&&l&&e.contains(l)&&l.querySelector(":scope > .sidebar-text"))return i(l);const f=l?.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");f?u(f):s()}),e.addEventListener("focusout",s),e.addEventListener("click",s),window.addEventListener("scroll",s,!0),window.addEventListener("hashchange",s)}async function ht(e=[],n=null){if(n?.title||n?.enabled===!1)return n;if(!W(e,"settings"))return{title:"Domma CMS"};try{const t=await g.settings.get();return{...t?.adminBrand,title:t?.adminBrand?.title||t?.title||"Domma CMS"}}catch{return{title:"Domma CMS"}}}export async function renderAdminSidebar({mount:e,permissions:n,adminScope:t=null,brand:o=null}){const s=$(e).get(0);if(!s)return;const r=Qe(g,w()).catch(()=>{}),u=Promise.resolve().then(()=>H.get("/api/sidebar/registered-items")).catch(()=>[]),i=it(n);let a,d=null,l=null,f=null,h=null,v=null;try{const c=await g.get("/sidebar/menu");a=Array.isArray(c?.items)?c.items:null,d=c?.variant||null,l=c?.position||null,f=c?.style||null,h=c?.float||null,v=c?.highlight||null}catch{a=null}(!a||!a.some(c=>c&&(!c.hidden||c.restricted)))&&(console.warn("[admin-sidebar] No admin-sidebar menu found; using fallback tree"),a=ot.slice());let k=[];try{k=await u||[]}catch{}a=Re(a,se),a=Te(a,k.filter(c=>(c?.item??c)?.url!==se)),a=Ne(a),a=Ie(a,[He()]);const q=await i;q.length&&at(a,q),a=_e(a,n,t),a=Pe(a),await r;const F=Xe(a,K(w()),{hidden:Ze(w())});F&&(a=[F,...a]),nt(a);const b=k.filter(c=>W(n,c?.item?.permission));j=fe(b,t);const A=Ae({user:w(),permissions:n,adminScope:t,registered:b,tree:a,actions:{linkItems:ye,folderItems:ve},fetcher:()=>ct(b,n,t)}),B=A.counts,L=await ht(n,o),I=d?` dm-admin-sidebar--${m(d)}`:"";function P(c,x="px"){if(c==null)return c;const p=String(c).trim();return/^\d+(\.\d+)?$/.test(p)?`${p}${x}`:p}let U="";if(f){const c=[];f.fontFamily&&c.push(`font-family: ${f.fontFamily}, sans-serif`),f.fontSize&&c.push(`font-size: ${P(f.fontSize)}`),f.fontWeight&&c.push(`font-weight: ${f.fontWeight}`),f.letterSpacing&&c.push(`letter-spacing: ${P(f.letterSpacing,"em")}`);const x=[];if(c.length&&x.push(`#admin-sidebar .dm-admin-sidebar, #admin-sidebar .dm-admin-sidebar .sidebar-link, #admin-sidebar .dm-admin-sidebar summary, #admin-sidebar .dm-admin-sidebar .sidebar-text { ${c.join("; ")} }`),f.iconSize){const p=P(f.iconSize);x.push(`#admin-sidebar .dm-admin-sidebar [data-icon], #admin-sidebar .dm-admin-sidebar [data-icon] svg { width: ${p} !important; height: ${p} !important; }`)}x.length&&(U=`<style data-admin-sidebar-style>${x.join(" ")}</style>`)}const z=ze(n)?Ue():"",y=String(L.logo||"").trim(),C=/^(?:\/(?!\/)|https?:\/\/)/i.test(y)?y:"",G=C?`<img src="${m(C)}" alt="" style="width:28px;height:28px;object-fit:contain;flex-shrink:0;">`:`<span data-icon="${m(L.icon||"layout")}"></span>`,O=`<div class="dm-admin-sidebar-header">${L.enabled===!1?"":`${G}<span class="dm-admin-sidebar-title">${m(L.title)}</span>`}${z}${De()}</div>`,xe=a.some(c=>c&&c.type==="spacer"&&c.size==="flex")?" dm-admin-sidebar--has-flex-spacer":"",$e=`${U}<nav class="dm-admin-sidebar${I}${xe}">${O}${a.map(c=>ue(c,B)).join("")}</nav>`,Q=document.createRange();Q.selectNodeContents(s);const we=Q.createContextualFragment($e);s.replaceChildren(we),Domma.icons.scan(s),s.querySelector(".dm-admin-sidebar-arrange")?.addEventListener("click",()=>We(s));for(const c of j)X.set(c.url,B[c.url]??null);ce(s),mt(s),A.refresh.then(c=>{if(!(!A.isActive()||!s.isConnected))for(const[x,p]of Object.entries(c))V(s,x,p)}),s.removeAttribute("data-menu-hover"),s.removeAttribute("data-menu-active"),s.style.removeProperty("--dm-menu-highlight"),Oe(s,{highlight:v});const T=document.querySelector(".dashboard-wrapper");["position","top","bottom","left","right","zIndex","maxHeight","transform"].forEach(c=>{s.style[c]=""}),s.classList.remove("dm-menu-floating"),T&&(T.style.paddingLeft="",T.style.paddingRight=""),s.__dmGutter=()=>{if(l!=="floating"||!T)return;const c=h&&h.anchor||"TL",x=Number.isFinite(Number(h?.offsetX))?Number(h.offsetX):16,p=s.classList.contains("is-collapsed")?Ke:parseInt(s.style.width,10)||s.getBoundingClientRect().width||260,N=Math.round(p+x*2)+"px";c==="R"||c==="TR"||c==="BR"?T.style.paddingRight=N:T.style.paddingLeft=N},l==="floating"&&Be(s,{position:"floating",float:h||{}}),s.querySelectorAll("details").forEach(c=>{c.addEventListener("toggle",function(){const x=this.getAttribute("data-state-key");x&&S.set(x,this.open);const p=this.querySelector(":scope > .sidebar-children");if(p)if(this.open){const N=p.scrollHeight;p.style.maxHeight="0",requestAnimationFrame(()=>{p.style.maxHeight=N+"px",p.addEventListener("transitionend",function Se(){p.style.maxHeight="none",p.removeEventListener("transitionend",Se)})})}else{const N=p.scrollHeight;p.style.maxHeight=N+"px",requestAnimationFrame(()=>{p.style.maxHeight="0"})}})}),Ge(s),bt(s),s.dataset.routeWired||(s.dataset.routeWired="1",M.subscribe("router:afterChange",()=>s.__dmSetActive?.()));function ee(){const c=/^#\/(dashboards|my-dashboard)\b/.test(location.hash)?"#/":location.hash||"#/";$(s).find(".sidebar-link").removeClass("active"),$(s).find(`.sidebar-link[data-url="${c}"]`).addClass("active")}ee(),s.__dmSetActive=ee}function ge(){try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}}function J(e){return`${location.origin}${location.pathname}${e}`}function _(e,n){const t=w(),o=e(K(t));if(!et(t,o)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}o.length&&ae(t,!1),be(t),n&&E.toast(n,{type:"success",duration:2500}),ge()}function be(e){Ye(g,e).catch(()=>E.toast("Frequent is saved in this browser only - the server could not keep it.",{type:"warning"}))}function gt(e){if(!ae(w(),e)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}be(w()),E.toast(e?"Frequent hidden. Add a Tool to it from its right-click menu to bring it back.":"Frequent shown.",{type:"success",duration:3500}),ge()}function ye(e){const n=e.dataset.url;if(!n)return[];const t=e.querySelector(".sidebar-text")?.textContent.trim()||n,o=K(w()),s=o.includes(n),r=!!e.closest("[data-frequent]"),u=o.indexOf(n),i=!s&&o.length>=oe;return[{header:t},{label:"Open",icon:"arrow-right",...re(n)&&{shortcut:st(re(n))},action:()=>{location.hash=n}},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(J(n),"_blank","noopener")},{type:"divider"},s?{label:"Remove from Frequent",icon:"star",action:()=>_(a=>Je(a,n),`${t} removed from Frequent.`)}:{label:i?`Frequent is full (${oe})`:"Add to Frequent",icon:"star",disabled:i,action:()=>_(a=>Ve(a,n),`${t} added to Frequent.`)},...r?[{label:"Move up",icon:"arrow-up",disabled:u<=0,action:()=>_(a=>ie(a,n,-1))},{label:"Move down",icon:"arrow-down",disabled:u<0||u>=o.length-1,action:()=>_(a=>ie(a,n,1))}]:[],{type:"divider"},{label:"Copy link",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(J(n)),E.toast("Link copied.",{type:"success",duration:2e3})}catch{E.toast(J(n),{type:"info",duration:8e3})}}}]}function ve(e,n,t={}){const o=e.closest("details, [data-frequent]"),s=t.isOpen||(()=>!!o?.open),r=t.setOpen||(a=>{o&&(o.open=a)}),u=e.querySelector(".sidebar-text")?.textContent.trim()||"Folder",i=t.setAll||(a=>n.querySelectorAll("details").forEach(d=>{d.open!==a&&(d.open=a)}));return[{header:u},{label:s()?"Close":"Open",icon:s()?"chevron-up":"chevron-down",action:()=>r(!s())},...t.singleBranch?[]:[{label:"Open every folder",icon:"chevrons-down",action:()=>i(!0)}],{label:t.singleBranch?"Close all menus":"Close every folder",icon:"chevrons-up",action:()=>i(!1)},...o?.hasAttribute("data-frequent-empty")?[{type:"divider"},{label:"Hide Frequent until I add a Tool",icon:"eye-off",action:()=>gt(!0)}]:o?.hasAttribute("data-frequent")?[{type:"divider"},{label:"Clear Frequent",icon:"x",action:()=>_(()=>[],"Frequent cleared.")}]:[]]}function bt(e){e.dataset.ctxWired||typeof E>"u"||!E.contextMenu||(e.dataset.ctxWired="1",E.contextMenu(e,{match:"a.sidebar-link, details > summary",inherit:!1,density:"compact",items:n=>n.matches("summary")?ve(n,e):ye(n)}))}
7
+ </details>`}return`<a href="${i}" class="sidebar-link" data-url="${i}"${v}${f}${C}>${r} <span class="sidebar-text">${u}</span>${ct(e,n)}${F}</a>`}async function ut(e=[],n=[],t=null){const o=y=>y.then(x=>Array.isArray(x)?x.length:Array.isArray(x?.entries)?x.entries.length:0).catch(()=>0),s=fe(e,t),r=new Set(s.map(y=>y.url)),u={pages:"#/pages",media:"#/media",menus:"#/menus","context-menus":"#/context-menus",theme:"#/theme",collections:"#/collections",forms:"#/forms",views:"#/views",actions:"#/actions",blocks:"#/blocks",components:"#/components",users:"#/users",plugins:"#/plugins",notifications:"#/system/notifications"},i=(y,x)=>G(n,y)&&!r.has(u[y])?x():Promise.resolve(0),[a,d,l,f,h,v,q,C,F,b,A,B,L,P]=await Promise.all([i("pages",()=>o(g.pages.list())),i("media",()=>o(g.media.list())),i("menus",()=>o(g.menus.list())),i("context-menus",()=>o(g.contextMenus.list())),i("theme",()=>g.theme.get().then(y=>(y?.overrides||[]).length).catch(()=>0)),i("collections",()=>o(g.collections.list())),i("forms",()=>o(g.forms.list())),i("views",()=>o(g.views.list())),i("actions",()=>o(g.actions.list())),i("blocks",()=>o(g.blocks.list())),i("components",()=>o(g.components.list())),i("users",()=>o(g.users.list())),i("plugins",()=>o(g.plugins.list())),i("notifications",()=>g.system?.notifications?.unreadCount?.().then(y=>y?.count??0).catch(()=>0)??Promise.resolve(0))]),_=await pe(s),z={"#/pages":a,"#/media":d,"#/menus":l,"#/context-menus":f,"#/theme":h,"#/collections":v,"#/forms":q,"#/views":C,"#/actions":F,"#/blocks":b,"#/components":A,"#/users":B,"#/plugins":L,"#/system/notifications":P},D={};for(const[y,x]of Object.entries(z)){if(r.has(y))continue;const[W,O]=dt[y]??["item","items"],T=K(x);T&&(D[y]={...T,label:`${T.count} ${T.count===1?W:O}`})}return{...D,..._}}let j=[];const ft="dm:sidebar-count",mt=6e4,pt=Ae(4);function fe(e=[],n=null){const t=[],o=s=>{if(s&&!(n&&typeof s.url=="string"&&s.url.startsWith("#/")&&!je(n,s.url.slice(1)))){s.url&&typeof s.countUrl=="string"&&s.countUrl&&t.push({url:s.url,countUrl:s.countUrl,text:s.text||"",countLabel:s.countLabel||"",inventory:s.inventory===!0});for(const r of[...s.children||[],...s.items||[]])o(r)}};for(const s of e??[])o(s?.item??s);return t}async function me(e,{priority:n=!1}={}){try{const t=new Date,o=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,s=e.countUrl+(e.countUrl.includes("?")?"&":"?")+`today=${o}`,r=k()?.id,u=await pt(()=>!Ce()||k()?.id!==r?null:H.get(s,{priority:"low"}),{key:JSON.stringify([r,s]),priority:n});return K(u,{fallbackLabel:e.countLabel||e.text})}catch{return null}}function X(e,n,t){Ee(n,t),t?.notify&&Oe(k()?.id??null,n,t.notify);const o=[...e.querySelectorAll("a.sidebar-link")].filter(s=>s.dataset.url===n);if(o.length){for(const s of o){const r=s.querySelector(".sidebar-badge[data-count-for]");if(!t||!(t.count>0)&&!t.showZero)r?.remove();else{const u=document.createRange();u.selectNodeContents(s);const i=u.createContextualFragment(le(n,t)).firstElementChild;r?r.replaceWith(i):s.querySelector(".sidebar-text")?.after(i)}}Z.set(n,t),ce(e)}}const Z=new Map;async function pe(e){const n=await Le(e,{legacy:async t=>{const o=await Promise.all(t.map(async s=>[s.url,await me(s)]));return Object.fromEntries(o)}});return Object.fromEntries(e.map(t=>[t.url,n[t.url]==null?null:K(n[t.url],{fallbackLabel:t.countLabel||t.text})]))}async function J(e,n=null){const t=k()?.id,o=j;try{const s=n?{[n]:await me(j.find(r=>r.url===n),{priority:!0})}:await pe(j);if(k()?.id!==t||j!==o)return;for(const[r,u]of Object.entries(s)){const i=Z.get(r);JSON.stringify(i??null)!==JSON.stringify(u)&&X(e,r,u)}}catch{}}function ht(e){e.dataset.liveCounts||(e.dataset.liveCounts="1",window.addEventListener(ft,n=>{const t=n.detail||{};if(t.url)if(t.count!==void 0){const o=j.find(s=>s.url===t.url);X(e,t.url,K(t,{fallbackLabel:o?.countLabel||o?.text||""}))}else J(e,t.url)}),setInterval(()=>{!document.hidden&&document.body.contains(e)&&J(e)},mt),document.addEventListener("visibilitychange",()=>{document.hidden||J(e)}),gt(e))}function he(e,n,t){const o=(u,i,a)=>{const d=document.createElement(u);return i&&(d.className=i),a!=null&&(d.textContent=String(a)),d};if(!t){e.textContent=n;return}e.appendChild(o("strong","dm-badge-pop-title",t.title||n)),(t.rows?.length||!t.items?.length)&&e.appendChild(o("p","dm-badge-pop-sub",n));const s=Array.isArray(t.rows)?t.rows.slice(0,6):[];if(s.length){const u=o("dl","dm-badge-pop-rows");for(const i of s)u.appendChild(o("dt",null,i.label)),u.appendChild(o("dd",i.tone==="danger"?"is-danger":null,i.value));e.appendChild(u)}const r=Array.isArray(t.items)?t.items.slice(0,6):[];if(r.length){const u=o("ul","dm-badge-pop-items");for(const i of r){const a=o("li",i.tone==="danger"?"is-danger":null);a.appendChild(o("span","dm-badge-pop-text",i.text)),i.meta&&a.appendChild(o("span","dm-badge-pop-meta",i.meta)),u.appendChild(a)}e.appendChild(u)}else t.empty&&e.appendChild(o("p","dm-badge-pop-empty",t.empty))}function gt(e){let n=null,t=null;const o=()=>e.classList.contains("is-collapsed"),s=()=>{clearTimeout(t),n?.remove(),n=null},r=(d,l)=>{s(),t=setTimeout(()=>{n=document.createElement("div"),n.className="dm-help-pop dm-badge-pop",n.setAttribute("role","tooltip"),l(n),document.body.appendChild(n);const f=d.getBoundingClientRect(),h=n.getBoundingClientRect(),v=Math.min(f.right+10,innerWidth-h.width-8);n.style.left=`${Math.max(8,v)}px`,n.style.top=`${Math.max(8,Math.min(f.top+f.height/2-h.height/2,innerHeight-h.height-8))}px`},150)},u=d=>{const l=d?.dataset.badgeLabel;if(!l)return s();r(d,f=>he(f,l,I.get(d.dataset.countFor)))},i=d=>{const l=d.querySelector(":scope > .sidebar-text")?.textContent.trim()||"",f=d.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");r(d,h=>{const v=f&&I.get(f.dataset.countFor);if(v)return he(h,f.dataset.badgeLabel,{...v,title:v.title||l});if(!f){h.textContent=l;return}const q=document.createElement("strong");q.className="dm-badge-pop-title",q.textContent=l;const C=document.createElement("p");C.className="dm-badge-pop-sub",C.textContent=f.dataset.badgeLabel,h.append(q,C)})},a=d=>{const l=d.closest?.("a.sidebar-link, summary");return l&&e.contains(l)?l:null};e.addEventListener("mouseover",d=>{if(o()){const f=a(d.target);f&&!f.contains(d.relatedTarget)&&i(f);return}const l=d.target.closest?.(".sidebar-badge[data-badge-label]");l&&u(l)}),e.addEventListener("mouseout",d=>{if(o()){const l=a(d.target);l&&!l.contains(d.relatedTarget)&&s();return}d.target.closest?.(".sidebar-badge[data-badge-label]")&&s()}),e.addEventListener("focusin",d=>{const l=d.target.closest?.("a, summary");if(o()&&l&&e.contains(l)&&l.querySelector(":scope > .sidebar-text"))return i(l);const f=l?.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");f?u(f):s()}),e.addEventListener("focusout",s),e.addEventListener("click",s),window.addEventListener("scroll",s,!0),window.addEventListener("hashchange",s)}async function bt(e=[],n=null){if(n?.title||n?.enabled===!1)return n;if(!G(e,"settings"))return{title:"Domma CMS"};try{const t=await g.settings.get();return{...t?.adminBrand,title:t?.adminBrand?.title||t?.title||"Domma CMS"}}catch{return{title:"Domma CMS"}}}export async function renderAdminSidebar({mount:e,permissions:n,adminScope:t=null,brand:o=null}){const s=$(e).get(0);if(!s)return;const r=tt(g,k()).catch(()=>{}),u=Promise.resolve().then(()=>H.get("/api/sidebar/registered-items")).catch(()=>[]),i=rt(n);let a,d=null,l=null,f=null,h=null,v=null;try{const c=await g.get("/sidebar/menu");a=Array.isArray(c?.items)?c.items:null,d=c?.variant||null,l=c?.position||null,f=c?.style||null,h=c?.float||null,v=c?.highlight||null}catch{a=null}(!a||!a.some(c=>c&&(!c.hidden||c.restricted)))&&(console.warn("[admin-sidebar] No admin-sidebar menu found; using fallback tree"),a=at.slice());let q=[];try{q=await u||[]}catch{}a=Pe(a,se),a=He(a,q.filter(c=>(c?.item??c)?.url!==se)),a=Re(a),a=_e(a,[Ie()]);const C=await i;C.length&&lt(a,C),a=ze(a,n,t),a=Ue(a),await r;const F=Je(a,V(k()),{hidden:Ye(k())});F&&(a=[F,...a]),ot(a);const b=q.filter(c=>G(n,c?.item?.permission));j=fe(b,t);const A=Fe({user:k(),permissions:n,adminScope:t,registered:b,tree:a,actions:{linkItems:ye,folderItems:ve},fetcher:()=>ut(b,n,t)}),B=A.counts,L=await bt(n,o),P=d?` dm-admin-sidebar--${m(d)}`:"";function _(c,w="px"){if(c==null)return c;const p=String(c).trim();return/^\d+(\.\d+)?$/.test(p)?`${p}${w}`:p}let z="";if(f){const c=[];f.fontFamily&&c.push(`font-family: ${f.fontFamily}, sans-serif`),f.fontSize&&c.push(`font-size: ${_(f.fontSize)}`),f.fontWeight&&c.push(`font-weight: ${f.fontWeight}`),f.letterSpacing&&c.push(`letter-spacing: ${_(f.letterSpacing,"em")}`);const w=[];if(c.length&&w.push(`#admin-sidebar .dm-admin-sidebar, #admin-sidebar .dm-admin-sidebar .sidebar-link, #admin-sidebar .dm-admin-sidebar summary, #admin-sidebar .dm-admin-sidebar .sidebar-text { ${c.join("; ")} }`),f.iconSize){const p=_(f.iconSize);w.push(`#admin-sidebar .dm-admin-sidebar [data-icon], #admin-sidebar .dm-admin-sidebar [data-icon] svg { width: ${p} !important; height: ${p} !important; }`)}w.length&&(z=`<style data-admin-sidebar-style>${w.join(" ")}</style>`)}const D=We(n)?De():"",y=String(L.logo||"").trim(),x=/^(?:\/(?!\/)|https?:\/\/)/i.test(y)?y:"",W=String(L.logoDark||"").trim(),O=/^(?:\/(?!\/)|https?:\/\/)/i.test(W)?W:"",T=x||O?`<img src="${m(x||O)}"${x?` data-logo-light="${m(x)}"`:""}${O?` data-logo-dark="${m(O)}"`:""} alt="" style="width:28px;height:28px;object-fit:contain;flex-shrink:0;">`:`<span data-icon="${m(L.icon||"layout")}"></span>`,xe=`<div class="dm-admin-sidebar-header">${L.enabled===!1?"":`${T}<span class="dm-admin-sidebar-title">${m(L.title)}</span>`}${D}${Ke()}</div>`,$e=a.some(c=>c&&c.type==="spacer"&&c.size==="flex")?" dm-admin-sidebar--has-flex-spacer":"",we=`${z}<nav class="dm-admin-sidebar${P}${$e}">${xe}${a.map(c=>ue(c,B)).join("")}</nav>`,Q=document.createRange();Q.selectNodeContents(s);const ke=Q.createContextualFragment(we);s.replaceChildren(ke),qe(s),Domma.icons.scan(s),s.querySelector(".dm-admin-sidebar-arrange")?.addEventListener("click",()=>Ge(s));for(const c of j)Z.set(c.url,B[c.url]??null);ce(s),ht(s),A.refresh.then(c=>{if(!(!A.isActive()||!s.isConnected))for(const[w,p]of Object.entries(c))X(s,w,p)}),s.removeAttribute("data-menu-hover"),s.removeAttribute("data-menu-active"),s.style.removeProperty("--dm-menu-highlight"),Me(s,{highlight:v});const N=document.querySelector(".dashboard-wrapper");["position","top","bottom","left","right","zIndex","maxHeight","transform"].forEach(c=>{s.style[c]=""}),s.classList.remove("dm-menu-floating"),N&&(N.style.paddingLeft="",N.style.paddingRight=""),s.__dmGutter=()=>{if(l!=="floating"||!N)return;const c=h&&h.anchor||"TL",w=Number.isFinite(Number(h?.offsetX))?Number(h.offsetX):16,p=s.classList.contains("is-collapsed")?Xe:parseInt(s.style.width,10)||s.getBoundingClientRect().width||260,R=Math.round(p+w*2)+"px";c==="R"||c==="TR"||c==="BR"?N.style.paddingRight=R:N.style.paddingLeft=R},l==="floating"&&Te(s,{position:"floating",float:h||{}}),s.querySelectorAll("details").forEach(c=>{c.addEventListener("toggle",function(){const w=this.getAttribute("data-state-key");w&&S.set(w,this.open);const p=this.querySelector(":scope > .sidebar-children");if(p)if(this.open){const R=p.scrollHeight;p.style.maxHeight="0",requestAnimationFrame(()=>{p.style.maxHeight=R+"px",p.addEventListener("transitionend",function Se(){p.style.maxHeight="none",p.removeEventListener("transitionend",Se)})})}else{const R=p.scrollHeight;p.style.maxHeight=R+"px",requestAnimationFrame(()=>{p.style.maxHeight="0"})}})}),Ve(s),vt(s),s.dataset.routeWired||(s.dataset.routeWired="1",M.subscribe("router:afterChange",()=>s.__dmSetActive?.()));function ee(){const c=/^#\/(dashboards|my-dashboard)\b/.test(location.hash)?"#/":location.hash||"#/";$(s).find(".sidebar-link").removeClass("active"),$(s).find(`.sidebar-link[data-url="${c}"]`).addClass("active")}ee(),s.__dmSetActive=ee}function ge(){try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}}function Y(e){return`${location.origin}${location.pathname}${e}`}function U(e,n){const t=k(),o=e(V(t));if(!nt(t,o)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}o.length&&ae(t,!1),be(t),n&&E.toast(n,{type:"success",duration:2500}),ge()}function be(e){et(g,e).catch(()=>E.toast("Frequent is saved in this browser only - the server could not keep it.",{type:"warning"}))}function yt(e){if(!ae(k(),e)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}be(k()),E.toast(e?"Frequent hidden. Add a Tool to it from its right-click menu to bring it back.":"Frequent shown.",{type:"success",duration:3500}),ge()}function ye(e){const n=e.dataset.url;if(!n)return[];const t=e.querySelector(".sidebar-text")?.textContent.trim()||n,o=V(k()),s=o.includes(n),r=!!e.closest("[data-frequent]"),u=o.indexOf(n),i=!s&&o.length>=oe;return[{header:t},{label:"Open",icon:"arrow-right",...re(n)&&{shortcut:it(re(n))},action:()=>{location.hash=n}},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(Y(n),"_blank","noopener")},{type:"divider"},s?{label:"Remove from Frequent",icon:"star",action:()=>U(a=>Qe(a,n),`${t} removed from Frequent.`)}:{label:i?`Frequent is full (${oe})`:"Add to Frequent",icon:"star",disabled:i,action:()=>U(a=>Ze(a,n),`${t} added to Frequent.`)},...r?[{label:"Move up",icon:"arrow-up",disabled:u<=0,action:()=>U(a=>ie(a,n,-1))},{label:"Move down",icon:"arrow-down",disabled:u<0||u>=o.length-1,action:()=>U(a=>ie(a,n,1))}]:[],{type:"divider"},{label:"Copy link",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(Y(n)),E.toast("Link copied.",{type:"success",duration:2e3})}catch{E.toast(Y(n),{type:"info",duration:8e3})}}}]}function ve(e,n,t={}){const o=e.closest("details, [data-frequent]"),s=t.isOpen||(()=>!!o?.open),r=t.setOpen||(a=>{o&&(o.open=a)}),u=e.querySelector(".sidebar-text")?.textContent.trim()||"Folder",i=t.setAll||(a=>n.querySelectorAll("details").forEach(d=>{d.open!==a&&(d.open=a)}));return[{header:u},{label:s()?"Close":"Open",icon:s()?"chevron-up":"chevron-down",action:()=>r(!s())},...t.singleBranch?[]:[{label:"Open every folder",icon:"chevrons-down",action:()=>i(!0)}],{label:t.singleBranch?"Close all menus":"Close every folder",icon:"chevrons-up",action:()=>i(!1)},...o?.hasAttribute("data-frequent-empty")?[{type:"divider"},{label:"Hide Frequent until I add a Tool",icon:"eye-off",action:()=>yt(!0)}]:o?.hasAttribute("data-frequent")?[{type:"divider"},{label:"Clear Frequent",icon:"x",action:()=>U(()=>[],"Frequent cleared.")}]:[]]}function vt(e){e.dataset.ctxWired||typeof E>"u"||!E.contextMenu||(e.dataset.ctxWired="1",E.contextMenu(e,{match:"a.sidebar-link, details > summary",inherit:!1,density:"compact",items:n=>n.matches("summary")?ve(n,e):ye(n)}))}
@@ -1,3 +1,3 @@
1
- export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass"],branding:["brandEnabled","brandText","brandLogo","brandIcon","brandUrl","adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandIcon"],favicon:["favicon"],footer:["footerCopyright","footerLayout","footerBlurb","footerBlocks","footerClass","footerSocialClass","footerLook","footerCtaText","footerCtaHighlight","footerCtaUrl","footerCtaSub","footerWatermark","footerStatus","footerFacts","footerTagline","footerEmail","footerAddress","footerGradFrom","footerGradTo","socialTwitter","socialFacebook","socialInstagram","socialLinkedin","socialGithub","socialYoutube"],email:["smtpHost","smtpPort","smtpUser","smtpPass","smtpSecure","smtpInsecureTLS","smtpFromAddress","smtpFromName"],pageNavigation:["bttEnabled","bttSmooth","bttLabel","bttThreshold","bttPosition","bttOffset","bttBottomOffset","gtbEnabled","gtbSmooth","gtbLabel","gtbThreshold","gtbPosition","gtbOffset","gtbBottomOffset"],cookies:["ccEnabled","ccMessage","ccAcceptAll","ccRejectAll","ccCustomize","ccSavePrefs","ccPrivacyText","ccPrivacyUrl","ccCookieText","ccCookieUrl","ccPosition","ccLayout","ccTheme","ccShowFunctional","ccShowAnalytics","ccShowMarketing","ccVersion","ccSettingsLink","ccSettingsLinkText"],breadcrumbs:["bcEnabled","bcHomeLabel","bcPosition","bcOffsetX","bcOffsetY"],motion:["mtEnabled","mtLabel","mtDefault","mtControl","mtPlacement","mtTriggerStyle","mtPosition","mtOffsetX","mtOffsetY","mtIconSize","mtIconRadius","mtClass"]},SECRET_FIELDS=["smtpPass"],BREADCRUMB_POSITIONS=["TL","TR","BL","BR"],MOTION_PLACEMENTS=["footer","floating","navbar"],MOTION_LABEL="Reduce motion";const d=["system","off","on"],c=(t,r,n,o)=>{const a=Number.parseInt(t,10);return Number.isFinite(a)?Math.min(o,Math.max(n,a)):r};export function motionFromSettings(t={}){const r=t.motion&&typeof t.motion=="object"?t.motion:{},n=t.footer||{},o=m=>r[m]!==void 0&&r[m]!==null,a=o("default")?r.default:n.motionDefault,i=o("control")?r.control:n.motionControl,l=c(r.iconSize,52,32,96);return{mtEnabled:(o("enabled")?r.enabled:n.showMotionToggle)!==!1,mtLabel:typeof r.label=="string"&&r.label.trim()?r.label.trim():MOTION_LABEL,mtDefault:d.includes(a)?a:"system",mtControl:i==="checkbox"?"checkbox":"switch",mtPlacement:MOTION_PLACEMENTS.includes(r.placement)?r.placement:"footer",mtTriggerStyle:r.triggerStyle==="icon-text"?"icon-text":"icon",mtPosition:BREADCRUMB_POSITIONS.includes(r.position)?r.position:"BL",mtOffsetX:e(c(r.offsetX,32,0,500)),mtOffsetY:e(c(r.offsetY,32,0,500)),mtIconSize:e(l),mtIconRadius:e(c(r.iconRadius,26,0,Math.floor(l/2))),mtClass:e(r.class)}}export function motionFromForm(t){const r=c(t.mtIconSize,52,32,96);return{enabled:t.mtEnabled===!0,default:d.includes(t.mtDefault)?t.mtDefault:"system",placement:MOTION_PLACEMENTS.includes(t.mtPlacement)?t.mtPlacement:"footer",control:t.mtControl==="checkbox"?"checkbox":"switch",triggerStyle:t.mtTriggerStyle==="icon-text"?"icon-text":"icon",label:e(t.mtLabel).trim().replace(/\s+/g," ").slice(0,40)||MOTION_LABEL,position:BREADCRUMB_POSITIONS.includes(t.mtPosition)?t.mtPosition:"BL",offsetX:c(t.mtOffsetX,32,0,500),offsetY:c(t.mtOffsetY,32,0,500),iconSize:r,iconRadius:c(t.mtIconRadius,26,0,Math.floor(r/2)),class:e(t.mtClass).trim()}}export function footerBlockNames(t){return[...new Set(String(t??"").split(/[\s,]+/).map(r=>r.trim().toLowerCase()).filter(Boolean))]}export function gaIdError(t){const r=e(t).trim();return!r||/^G-[A-Z0-9]{4,20}$/i.test(r)?"":"A measurement ID looks like G-XXXXXXXXXX (Google Analytics > Admin > Data streams)."}export const FOOTER_LAYOUTS=["auto","columns","row"],FOOTER_LOOKS=["","showcase"],FOOTER_FACTS_MAX=4;const p=/^(\/|#|https?:\/\/|mailto:)/,g=/^#[0-9a-f]{6}$/i;export function footerShowcaseErrors(t){const r=[],n=e(t.footerCtaUrl).trim();n&&!p.test(n)&&r.push("The footer call to action link must start with /, #, https:// or mailto: (Footer tool).");for(const[o,a]of[["from",t.footerGradFrom],["to",t.footerGradTo]]){const i=e(a).trim();i&&!g.test(i)&&r.push(`The footer gradient "${o}" colour must look like #f26b3a (Footer tool).`)}return r}const e=(t,r="")=>t==null?r:String(t),s=(t,r)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?n:r};export function homeValue(t){return/^\/[A-Za-z0-9\-_/]*$/.test(t||"")&&String(t).replace(/\/+$/,"")||"/"}export function formFromSettings(t={}){const r=t.backToTop||{},n=t.goToBottom||{},o=t.cookieConsent||{},a=t.breadcrumbs||{};return{title:e(t.title),tagline:e(t.tagline),siteUrl:e(t.baseUrl),adminHome:homeValue(t.adminHome),spacerSize:e(t.layoutOptions?.spacerSize??40),bodyClass:e(t.bodyClass),brandEnabled:t.brand?.enabled!==!1,brandText:e(t.brand?.text),brandLogo:e(t.brand?.logo),brandIcon:e(t.brand?.icon),brandUrl:e(t.brand?.url,"/"),favicon:e(t.favicon),adminBrandEnabled:t.adminBrand?.enabled!==!1,adminBrandTitle:e(t.adminBrand?.title),adminBrandLogo:e(t.adminBrand?.logo),adminBrandIcon:e(t.adminBrand?.icon),footerCopyright:e(t.footer?.copyright),footerLayout:FOOTER_LAYOUTS.includes(t.footer?.layout)?t.footer.layout:"auto",footerBlurb:e(t.footer?.blurb),footerBlocks:Array.isArray(t.footer?.blocks)?t.footer.blocks.filter(i=>typeof i=="string").join(", "):"",footerClass:e(t.footer?.class),footerSocialClass:e(t.footer?.socialClass),footerLook:FOOTER_LOOKS.includes(t.footer?.look)?t.footer.look:"",footerCtaText:e(t.footer?.cta?.text),footerCtaHighlight:e(t.footer?.cta?.highlight),footerCtaUrl:e(t.footer?.cta?.url),footerCtaSub:e(t.footer?.cta?.sub),footerWatermark:e(t.footer?.watermark),footerStatus:e(t.footer?.status),footerFacts:Array.isArray(t.footer?.facts)?t.footer.facts.filter(i=>typeof i=="string").join(`
2
- `):"",footerTagline:e(t.footer?.tagline),footerEmail:e(t.footer?.email),footerAddress:e(t.footer?.address),footerGradFrom:e(t.footer?.gradient?.from),footerGradTo:e(t.footer?.gradient?.to),socialTwitter:e(t.social?.twitter),socialFacebook:e(t.social?.facebook),socialInstagram:e(t.social?.instagram),socialLinkedin:e(t.social?.linkedin),socialGithub:e(t.social?.github),socialYoutube:e(t.social?.youtube),smtpHost:e(t.smtp?.host),smtpPort:e(t.smtp?.port||587),smtpUser:e(t.smtp?.user),smtpPass:"",smtpSecure:t.smtp?.secure===!0,smtpInsecureTLS:t.smtp?.allowInsecureTLS===!0,smtpFromAddress:e(t.smtp?.fromAddress),smtpFromName:e(t.smtp?.fromName),bttEnabled:r.enabled!==!1,bttSmooth:r.smooth!==!1,bttLabel:e(r.label),bttThreshold:e(r.scrollThreshold??300),bttPosition:e(r.position,"bottom-right"),bttOffset:e(r.offset??32),bttBottomOffset:e(r.bottomOffset??r.offset??32),gtbEnabled:n.enabled===!0,gtbSmooth:n.smooth!==!1,gtbLabel:e(n.label),gtbThreshold:e(n.scrollThreshold??300),gtbPosition:e(n.position,"bottom-right"),gtbOffset:e(n.offset??32),gtbBottomOffset:e(n.bottomOffset??n.offset??32),ccEnabled:o.enabled!==!1,ccMessage:e(o.message),ccAcceptAll:e(o.acceptAllText,"Accept All"),ccRejectAll:e(o.rejectAllText,"Reject All"),ccCustomize:e(o.customizeText,"Customize"),ccSavePrefs:e(o.savePreferencesText,"Save Preferences"),ccPrivacyText:e(o.privacyPolicyText,"Privacy Policy"),ccPrivacyUrl:e(o.privacyPolicyUrl),ccCookieText:e(o.cookiePolicyText,"Cookie Policy"),ccCookieUrl:e(o.cookiePolicyUrl),ccPosition:e(o.position,"bottom"),ccLayout:e(o.layout,"bar"),ccTheme:e(o.theme,"dark"),ccShowFunctional:o.showFunctional!==!1,ccShowAnalytics:o.showAnalytics!==!1,ccShowMarketing:o.showMarketing!==!1,ccVersion:e(o.consentVersion,"1.0"),ccSettingsLink:o.showSettingsLink!==!1,ccSettingsLinkText:e(o.settingsLinkText,"Cookie settings"),bcEnabled:a.enabled===!0,bcHomeLabel:e(a.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(a.position)?a.position:"TL",bcOffsetX:e(a.offsetX??8),bcOffsetY:e(a.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,r={},{adminHomeReady:n=!0}={}){const o=i=>e(i).trim(),a=motionFromForm(t);return{title:o(t.title),tagline:o(t.tagline),baseUrl:o(t.siteUrl).replace(/\/+$/,""),...n&&{adminHome:o(t.adminHome)||"/"},layoutOptions:{spacerSize:s(t.spacerSize,40)||40},bodyClass:o(t.bodyClass),brand:{...r.brand,enabled:t.brandEnabled!==!1,text:o(t.brandText),logo:o(t.brandLogo),icon:o(t.brandIcon),url:o(t.brandUrl)||"/"},favicon:o(t.favicon),adminBrand:{...r.adminBrand,enabled:t.adminBrandEnabled!==!1,title:o(t.adminBrandTitle),logo:o(t.adminBrandLogo),icon:o(t.adminBrandIcon)},footer:{copyright:o(t.footerCopyright),layout:FOOTER_LAYOUTS.includes(t.footerLayout)?t.footerLayout:"auto",blurb:o(t.footerBlurb),blocks:footerBlockNames(t.footerBlocks),links:r.footer?.links||[],showMotionToggle:a.enabled,motionDefault:a.default,motionControl:a.control,class:o(t.footerClass),socialClass:o(t.footerSocialClass),look:FOOTER_LOOKS.includes(t.footerLook)?t.footerLook:"",cta:{text:o(t.footerCtaText),highlight:o(t.footerCtaHighlight),url:o(t.footerCtaUrl),sub:o(t.footerCtaSub)},watermark:o(t.footerWatermark),status:o(t.footerStatus),facts:String(t.footerFacts??"").split(`
1
+ export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass"],branding:["brandEnabled","brandText","brandLogo","brandIcon","brandUrl","adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"],favicon:["favicon"],footer:["footerCopyright","footerLayout","footerBlurb","footerBlocks","footerClass","footerSocialClass","footerLook","footerCtaText","footerCtaHighlight","footerCtaUrl","footerCtaSub","footerWatermark","footerStatus","footerFacts","footerTagline","footerEmail","footerAddress","footerGradFrom","footerGradTo","socialTwitter","socialFacebook","socialInstagram","socialLinkedin","socialGithub","socialYoutube"],email:["smtpHost","smtpPort","smtpUser","smtpPass","smtpSecure","smtpInsecureTLS","smtpFromAddress","smtpFromName"],pageNavigation:["bttEnabled","bttSmooth","bttLabel","bttThreshold","bttPosition","bttOffset","bttBottomOffset","gtbEnabled","gtbSmooth","gtbLabel","gtbThreshold","gtbPosition","gtbOffset","gtbBottomOffset"],cookies:["ccEnabled","ccMessage","ccAcceptAll","ccRejectAll","ccCustomize","ccSavePrefs","ccPrivacyText","ccPrivacyUrl","ccCookieText","ccCookieUrl","ccPosition","ccLayout","ccTheme","ccShowFunctional","ccShowAnalytics","ccShowMarketing","ccVersion","ccSettingsLink","ccSettingsLinkText"],breadcrumbs:["bcEnabled","bcHomeLabel","bcPosition","bcOffsetX","bcOffsetY"],motion:["mtEnabled","mtLabel","mtDefault","mtControl","mtPlacement","mtTriggerStyle","mtPosition","mtOffsetX","mtOffsetY","mtIconSize","mtIconRadius","mtClass"]},SECRET_FIELDS=["smtpPass"],BREADCRUMB_POSITIONS=["TL","TR","BL","BR"],MOTION_PLACEMENTS=["footer","floating","navbar"],MOTION_LABEL="Reduce motion";const d=["system","off","on"],c=(t,r,n,o)=>{const a=Number.parseInt(t,10);return Number.isFinite(a)?Math.min(o,Math.max(n,a)):r};export function motionFromSettings(t={}){const r=t.motion&&typeof t.motion=="object"?t.motion:{},n=t.footer||{},o=m=>r[m]!==void 0&&r[m]!==null,a=o("default")?r.default:n.motionDefault,i=o("control")?r.control:n.motionControl,l=c(r.iconSize,52,32,96);return{mtEnabled:(o("enabled")?r.enabled:n.showMotionToggle)!==!1,mtLabel:typeof r.label=="string"&&r.label.trim()?r.label.trim():MOTION_LABEL,mtDefault:d.includes(a)?a:"system",mtControl:i==="checkbox"?"checkbox":"switch",mtPlacement:MOTION_PLACEMENTS.includes(r.placement)?r.placement:"footer",mtTriggerStyle:r.triggerStyle==="icon-text"?"icon-text":"icon",mtPosition:BREADCRUMB_POSITIONS.includes(r.position)?r.position:"BL",mtOffsetX:e(c(r.offsetX,32,0,500)),mtOffsetY:e(c(r.offsetY,32,0,500)),mtIconSize:e(l),mtIconRadius:e(c(r.iconRadius,26,0,Math.floor(l/2))),mtClass:e(r.class)}}export function motionFromForm(t){const r=c(t.mtIconSize,52,32,96);return{enabled:t.mtEnabled===!0,default:d.includes(t.mtDefault)?t.mtDefault:"system",placement:MOTION_PLACEMENTS.includes(t.mtPlacement)?t.mtPlacement:"footer",control:t.mtControl==="checkbox"?"checkbox":"switch",triggerStyle:t.mtTriggerStyle==="icon-text"?"icon-text":"icon",label:e(t.mtLabel).trim().replace(/\s+/g," ").slice(0,40)||MOTION_LABEL,position:BREADCRUMB_POSITIONS.includes(t.mtPosition)?t.mtPosition:"BL",offsetX:c(t.mtOffsetX,32,0,500),offsetY:c(t.mtOffsetY,32,0,500),iconSize:r,iconRadius:c(t.mtIconRadius,26,0,Math.floor(r/2)),class:e(t.mtClass).trim()}}export function footerBlockNames(t){return[...new Set(String(t??"").split(/[\s,]+/).map(r=>r.trim().toLowerCase()).filter(Boolean))]}export function gaIdError(t){const r=e(t).trim();return!r||/^G-[A-Z0-9]{4,20}$/i.test(r)?"":"A measurement ID looks like G-XXXXXXXXXX (Google Analytics > Admin > Data streams)."}export const FOOTER_LAYOUTS=["auto","columns","row"],FOOTER_LOOKS=["","showcase"],FOOTER_FACTS_MAX=4;const p=/^(\/|#|https?:\/\/|mailto:)/,g=/^#[0-9a-f]{6}$/i;export function footerShowcaseErrors(t){const r=[],n=e(t.footerCtaUrl).trim();n&&!p.test(n)&&r.push("The footer call to action link must start with /, #, https:// or mailto: (Footer tool).");for(const[o,a]of[["from",t.footerGradFrom],["to",t.footerGradTo]]){const i=e(a).trim();i&&!g.test(i)&&r.push(`The footer gradient "${o}" colour must look like #f26b3a (Footer tool).`)}return r}const e=(t,r="")=>t==null?r:String(t),s=(t,r)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?n:r};export function homeValue(t){return/^\/[A-Za-z0-9\-_/]*$/.test(t||"")&&String(t).replace(/\/+$/,"")||"/"}export function formFromSettings(t={}){const r=t.backToTop||{},n=t.goToBottom||{},o=t.cookieConsent||{},a=t.breadcrumbs||{};return{title:e(t.title),tagline:e(t.tagline),siteUrl:e(t.baseUrl),adminHome:homeValue(t.adminHome),spacerSize:e(t.layoutOptions?.spacerSize??40),bodyClass:e(t.bodyClass),brandEnabled:t.brand?.enabled!==!1,brandText:e(t.brand?.text),brandLogo:e(t.brand?.logo),brandIcon:e(t.brand?.icon),brandUrl:e(t.brand?.url,"/"),favicon:e(t.favicon),adminBrandEnabled:t.adminBrand?.enabled!==!1,adminBrandTitle:e(t.adminBrand?.title),adminBrandLogo:e(t.adminBrand?.logo),adminBrandLogoDark:e(t.adminBrand?.logoDark),adminBrandIcon:e(t.adminBrand?.icon),footerCopyright:e(t.footer?.copyright),footerLayout:FOOTER_LAYOUTS.includes(t.footer?.layout)?t.footer.layout:"auto",footerBlurb:e(t.footer?.blurb),footerBlocks:Array.isArray(t.footer?.blocks)?t.footer.blocks.filter(i=>typeof i=="string").join(", "):"",footerClass:e(t.footer?.class),footerSocialClass:e(t.footer?.socialClass),footerLook:FOOTER_LOOKS.includes(t.footer?.look)?t.footer.look:"",footerCtaText:e(t.footer?.cta?.text),footerCtaHighlight:e(t.footer?.cta?.highlight),footerCtaUrl:e(t.footer?.cta?.url),footerCtaSub:e(t.footer?.cta?.sub),footerWatermark:e(t.footer?.watermark),footerStatus:e(t.footer?.status),footerFacts:Array.isArray(t.footer?.facts)?t.footer.facts.filter(i=>typeof i=="string").join(`
2
+ `):"",footerTagline:e(t.footer?.tagline),footerEmail:e(t.footer?.email),footerAddress:e(t.footer?.address),footerGradFrom:e(t.footer?.gradient?.from),footerGradTo:e(t.footer?.gradient?.to),socialTwitter:e(t.social?.twitter),socialFacebook:e(t.social?.facebook),socialInstagram:e(t.social?.instagram),socialLinkedin:e(t.social?.linkedin),socialGithub:e(t.social?.github),socialYoutube:e(t.social?.youtube),smtpHost:e(t.smtp?.host),smtpPort:e(t.smtp?.port||587),smtpUser:e(t.smtp?.user),smtpPass:"",smtpSecure:t.smtp?.secure===!0,smtpInsecureTLS:t.smtp?.allowInsecureTLS===!0,smtpFromAddress:e(t.smtp?.fromAddress),smtpFromName:e(t.smtp?.fromName),bttEnabled:r.enabled!==!1,bttSmooth:r.smooth!==!1,bttLabel:e(r.label),bttThreshold:e(r.scrollThreshold??300),bttPosition:e(r.position,"bottom-right"),bttOffset:e(r.offset??32),bttBottomOffset:e(r.bottomOffset??r.offset??32),gtbEnabled:n.enabled===!0,gtbSmooth:n.smooth!==!1,gtbLabel:e(n.label),gtbThreshold:e(n.scrollThreshold??300),gtbPosition:e(n.position,"bottom-right"),gtbOffset:e(n.offset??32),gtbBottomOffset:e(n.bottomOffset??n.offset??32),ccEnabled:o.enabled!==!1,ccMessage:e(o.message),ccAcceptAll:e(o.acceptAllText,"Accept All"),ccRejectAll:e(o.rejectAllText,"Reject All"),ccCustomize:e(o.customizeText,"Customize"),ccSavePrefs:e(o.savePreferencesText,"Save Preferences"),ccPrivacyText:e(o.privacyPolicyText,"Privacy Policy"),ccPrivacyUrl:e(o.privacyPolicyUrl),ccCookieText:e(o.cookiePolicyText,"Cookie Policy"),ccCookieUrl:e(o.cookiePolicyUrl),ccPosition:e(o.position,"bottom"),ccLayout:e(o.layout,"bar"),ccTheme:e(o.theme,"dark"),ccShowFunctional:o.showFunctional!==!1,ccShowAnalytics:o.showAnalytics!==!1,ccShowMarketing:o.showMarketing!==!1,ccVersion:e(o.consentVersion,"1.0"),ccSettingsLink:o.showSettingsLink!==!1,ccSettingsLinkText:e(o.settingsLinkText,"Cookie settings"),bcEnabled:a.enabled===!0,bcHomeLabel:e(a.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(a.position)?a.position:"TL",bcOffsetX:e(a.offsetX??8),bcOffsetY:e(a.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,r={},{adminHomeReady:n=!0}={}){const o=i=>e(i).trim(),a=motionFromForm(t);return{title:o(t.title),tagline:o(t.tagline),baseUrl:o(t.siteUrl).replace(/\/+$/,""),...n&&{adminHome:o(t.adminHome)||"/"},layoutOptions:{spacerSize:s(t.spacerSize,40)||40},bodyClass:o(t.bodyClass),brand:{...r.brand,enabled:t.brandEnabled!==!1,text:o(t.brandText),logo:o(t.brandLogo),icon:o(t.brandIcon),url:o(t.brandUrl)||"/"},favicon:o(t.favicon),adminBrand:{...r.adminBrand,enabled:t.adminBrandEnabled!==!1,title:o(t.adminBrandTitle),logo:o(t.adminBrandLogo),logoDark:o(t.adminBrandLogoDark),icon:o(t.adminBrandIcon)},footer:{copyright:o(t.footerCopyright),layout:FOOTER_LAYOUTS.includes(t.footerLayout)?t.footerLayout:"auto",blurb:o(t.footerBlurb),blocks:footerBlockNames(t.footerBlocks),links:r.footer?.links||[],showMotionToggle:a.enabled,motionDefault:a.default,motionControl:a.control,class:o(t.footerClass),socialClass:o(t.footerSocialClass),look:FOOTER_LOOKS.includes(t.footerLook)?t.footerLook:"",cta:{text:o(t.footerCtaText),highlight:o(t.footerCtaHighlight),url:o(t.footerCtaUrl),sub:o(t.footerCtaSub)},watermark:o(t.footerWatermark),status:o(t.footerStatus),facts:String(t.footerFacts??"").split(`
3
3
  `).map(i=>i.trim()).filter(Boolean).slice(0,FOOTER_FACTS_MAX),tagline:o(t.footerTagline),email:o(t.footerEmail),address:o(t.footerAddress),gradient:{from:o(t.footerGradFrom),to:o(t.footerGradTo)}},social:{twitter:o(t.socialTwitter),facebook:o(t.socialFacebook),instagram:o(t.socialInstagram),linkedin:o(t.socialLinkedin),github:o(t.socialGithub),youtube:o(t.socialYoutube)},smtp:{host:o(t.smtpHost),port:s(t.smtpPort,587)||587,user:o(t.smtpUser),pass:e(t.smtpPass),secure:t.smtpSecure===!0,allowInsecureTLS:t.smtpInsecureTLS===!0,fromAddress:o(t.smtpFromAddress),fromName:o(t.smtpFromName)},backToTop:{enabled:t.bttEnabled===!0,scrollThreshold:s(t.bttThreshold,300),position:e(t.bttPosition)||"bottom-right",offset:s(t.bttOffset,32),bottomOffset:s(t.bttBottomOffset,32),label:o(t.bttLabel),smooth:t.bttSmooth===!0},goToBottom:{enabled:t.gtbEnabled===!0,scrollThreshold:s(t.gtbThreshold,300),position:e(t.gtbPosition)||"bottom-right",offset:s(t.gtbOffset,32),bottomOffset:s(t.gtbBottomOffset,32),label:o(t.gtbLabel),smooth:t.gtbSmooth===!0},cookieConsent:{enabled:t.ccEnabled===!0,message:o(t.ccMessage),acceptAllText:o(t.ccAcceptAll),rejectAllText:o(t.ccRejectAll),customizeText:o(t.ccCustomize),savePreferencesText:o(t.ccSavePrefs),privacyPolicyText:o(t.ccPrivacyText),privacyPolicyUrl:o(t.ccPrivacyUrl),cookiePolicyText:o(t.ccCookieText),cookiePolicyUrl:o(t.ccCookieUrl),position:e(t.ccPosition)||"bottom",layout:e(t.ccLayout)||"bar",theme:e(t.ccTheme)||"dark",showFunctional:t.ccShowFunctional===!0,showAnalytics:t.ccShowAnalytics===!0,showMarketing:t.ccShowMarketing===!0,consentVersion:o(t.ccVersion)||"1.0",showSettingsLink:t.ccSettingsLink===!0,settingsLinkText:o(t.ccSettingsLinkText)||"Cookie settings"},breadcrumbs:{enabled:t.bcEnabled===!0,homeLabel:o(t.bcHomeLabel)||"Home",position:BREADCRUMB_POSITIONS.includes(t.bcPosition)?t.bcPosition:"TL",offsetX:s(t.bcOffsetX,8),offsetY:s(t.bcOffsetY,8)},motion:a}}export function siteUrlError(t){const r=e(t).trim().replace(/\/+$/,"");return r?/^https?:\/\//i.test(r)?/^https?:\/\/([a-z0-9.\-]+|\[[0-9a-f:.]+\])(:\d{1,5})?$/i.test(r)?"":"Just the address, like https://example.com - no page path after it.":"Start with https:// (or http://).":""}const b=t=>typeof t=="boolean"?t:e(t);export function snapshot(t){return JSON.stringify(Object.keys(t).sort().map(r=>[r,b(t[r])]))}export function changedTabs(t,r){const n=[];for(const[o,a]of Object.entries(TAB_FIELDS))a.some(i=>b(t[i])!==b(r[i]))&&n.push(o);return n}export function draftOf(t){return Object.fromEntries(Object.entries(t).filter(([r])=>!SECRET_FIELDS.includes(r)))}const h={footerMotionToggle:"mtEnabled",footerMotionDefault:"mtDefault",footerMotionControl:"mtControl"};export function formFromDraft(t,r={}){const n={...r};for(const[a,i]of Object.entries(h))a in n&&!(i in n)&&(n[i]=n[a]),delete n[a];const o={...t};for(const[a,i]of Object.entries(n))a in o&&!SECRET_FIELDS.includes(a)&&(o[a]=i);return o}export function settingsProblems(t,r={}){const n=[];return e(t.smtpHost).trim()?e(t.smtpFromAddress).trim()||n.push({tone:"warn",tab:"email",text:"No From address - mail has no sender and many servers refuse it."}):n.push({tone:"danger",tab:"email",text:"No SMTP host - mail goes to a throwaway test inbox and reaches no one (password resets, form notifications)."}),(t.ccEnabled===!0||e(r.googleAnalytics?.measurementId).trim())&&!e(t.ccPrivacyUrl).trim()&&n.push({tone:"warn",tab:"cookies",text:"The cookie banner is on but links to no privacy policy."}),n}export function describeCacheKey(t){const r=/^page:(.*?):m\d+:role([^:]*):/.exec(String(t||""));return r?{path:r[1]||"/",role:r[2]||"anon",page:!0}:{path:String(t||""),role:"",page:!1}}export function expiresIn(t,r=Date.now()){if(t==null)return"no expiry";const n=t-r;return n<=0?"expired":n<6e4?`${Math.round(n/1e3)}s`:n<36e5?`${Math.round(n/6e4)}m`:`${Math.round(n/36e5)}h`}export function footerForm(t={}){const r=formFromSettings(t);return Object.fromEntries(TAB_FIELDS.footer.map(n=>[n,r[n]]))}export function footerPayload(t){const{footer:r,social:n}=payloadFromForm(t);return delete r.links,delete r.showMotionToggle,delete r.motionDefault,delete r.motionControl,{footer:r,social:n}}export function siteSettingsForm(t={}){return Object.fromEntries(Object.entries(formFromSettings(t)).filter(([r])=>!TAB_FIELDS.footer.includes(r)&&!u.includes(r)))}export function siteSettingsPayload(...t){const{footer:r,social:n,favicon:o,backToTop:a,goToBottom:i,breadcrumbs:l,motion:m,...f}=payloadFromForm(...t);return f}export const APPEARANCE_TABS=["favicon","pageNavigation","breadcrumbs","motion","search"];const u=APPEARANCE_TABS.flatMap(t=>TAB_FIELDS[t]||[]);export function appearanceForm(t={}){const r=formFromSettings(t);return Object.fromEntries(u.map(n=>[n,r[n]]))}export function appearancePayload(t){const{favicon:r,backToTop:n,goToBottom:o,breadcrumbs:a,motion:i}=payloadFromForm(t);return{favicon:r,backToTop:n,goToBottom:o,breadcrumbs:a,motion:i}}
@@ -0,0 +1 @@
1
+ export function isDarkAdminTheme(){if(typeof document>"u")return!1;const e=getComputedStyle(document.body),n=e.getPropertyValue("--dm-background").trim()||e.backgroundColor,t=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});if(!t)return!1;t.fillStyle=n,t.fillRect(0,0,1,1);const[o,r,a]=t.getImageData(0,0,1,1).data,l=[o,r,a].map(i=>{const s=i/255;return s<=.04045?s/12.92:((s+.055)/1.055)**2.4});return .2126*l[0]+.7152*l[1]+.0722*l[2]<.5}export function syncThemeAwareLogos(e=typeof document>"u"?null:document){if(!e)return;const n=[];if(e.matches?.("img[data-logo-light], img[data-logo-dark]")&&n.push(e),n.push(...e.querySelectorAll?.("img[data-logo-light], img[data-logo-dark]")||[]),!n.length)return;let c=!1;try{c=isDarkAdminTheme()}catch{}for(const t of n){const o=t.dataset.logoLight||"",r=t.dataset.logoDark||"",a=c?r||o:o||r;a&&t.getAttribute("src")!==a&&t.setAttribute("src",a)}}
@@ -119,10 +119,16 @@
119
119
  <button type="button" class="btn btn-sm btn-ghost" data-on-click="clearBrandImage('adminBrandLogo')">Remove</button>
120
120
  <img data-bind-src="adminBrandLogo.value" data-bind-hidden="!adminBrandLogo.value" alt="Admin logo image preview" style="display:block;max-width:180px;max-height:80px;object-fit:contain;margin-top:.75rem;">
121
121
  </div>
122
+ <div><label class="form-label" for="stx-adminBrandLogoDark">Admin logo for dark themes</label>
123
+ <input id="stx-adminBrandLogoDark" type="text" class="form-input" placeholder="Optional - uses the main logo when empty" data-model="adminBrandLogoDark.value">
124
+ <button type="button" class="btn btn-sm btn-ghost" data-on-click="pickBrandImage('adminBrandLogoDark')">Choose or upload image</button>
125
+ <button type="button" class="btn btn-sm btn-ghost" data-on-click="clearBrandImage('adminBrandLogoDark')">Remove</button>
126
+ <img data-bind-src="adminBrandLogoDark.value" data-bind-hidden="!adminBrandLogoDark.value" alt="Dark theme admin logo preview" style="display:block;max-width:180px;max-height:80px;object-fit:contain;margin-top:.75rem;background:#1f2430;padding:.25rem;border-radius:4px;">
127
+ </div>
122
128
  <div><label class="form-label" for="stx-adminBrandIcon">Admin icon</label>
123
129
  <div data-brand-icon="adminBrandIcon"></div>
124
130
  </div>
125
- </div><p class="text-muted">The logo takes priority over the icon. Leave both empty to use the default icon.</p></div>
131
+ </div><p class="text-muted">The logo takes priority over the icon. The optional dark theme logo is used when the admin theme has a dark background. Leave both empty to use the default icon.</p></div>
126
132
  </div>
127
133
  </div>
128
134
 
@@ -1,4 +1,4 @@
1
- import{api as B,apiRequest as k}from"../api.js";import{placeTools as Le}from"../lib/sidebar-grouping.js";import{addBannerAction as me}from"../lib/plugin-chrome.js";import{helpPopovers as Re}from"../lib/help-popover.js";import{openMenuAt as G,sidebarCount as fe}from"../lib/tool-kit.js";import{changedTabs as Ie,describeCacheKey as J,draftOf as Ae,expiresIn as Pe,formFromDraft as $e,siteSettingsForm as Be,homeValue as De,siteSettingsPayload as He,siteUrlError as he,settingsProblems as je,snapshot as ve,TAB_FIELDS as qe}from"../lib/site-settings-arrange.js";import{pickMedia as Ue}from"../lib/media-picker.js";import{makeIconInput as _e}from"../lib/shortcode-modal.js";import{fmtDateTime as Ke}from"../lib/dates.js";const Q=/^\/settings(\?.*)?$/,be="#/settings",g="settings.draft",Fe=`
1
+ import{api as D,apiRequest as k}from"../api.js";import{placeTools as Oe}from"../lib/sidebar-grouping.js";import{addBannerAction as me}from"../lib/plugin-chrome.js";import{helpPopovers as Re}from"../lib/help-popover.js";import{openMenuAt as G,sidebarCount as fe}from"../lib/tool-kit.js";import{changedTabs as Ie,describeCacheKey as J,draftOf as Ae,expiresIn as Pe,formFromDraft as Be,siteSettingsForm as De,homeValue as $e,siteSettingsPayload as He,siteUrlError as he,settingsProblems as je,snapshot as ve,TAB_FIELDS as qe}from"../lib/site-settings-arrange.js";import{pickMedia as Ue}from"../lib/media-picker.js";import{makeIconInput as _e}from"../lib/shortcode-modal.js";import{fmtDateTime as Ke}from"../lib/dates.js";const Q=/^\/settings(\?.*)?$/,be="#/settings",g="settings.draft",Fe=`
2
2
  <div class="stx-problem">
3
3
  <span class="stx-chip" data-bind-class="tone === 'danger' ? 'is-bad' : 'is-warn'">{{label}}</span>
4
4
  <span>{{text}}</span>
@@ -8,4 +8,4 @@ import{api as B,apiRequest as k}from"../api.js";import{placeTools as Le}from"../
8
8
  <span class="stx-main"><strong>{{path}}</strong><small>{{meta}}</small></span>
9
9
  <span class="stx-chip">{{expires}}</span>
10
10
  <button type="button" class="stx-kebab" aria-label="Actions for {{path}}" title="Actions">\u22EE</button>
11
- </div>`,D=["general","branding","email","cookies","cache"];async function Ne(c,l){const[r,w]=await Promise.all([H.get("/api/sidebar/menu").catch(()=>({items:[]})),H.get("/api/sidebar/registered-items").catch(()=>[])]),n=new Map([["/","Dashboard (built in)"]]),i=(v,u)=>{for(const o of v||[]){if(!o||o.hidden||o.restricted)continue;const m=typeof o.url=="string"?o.url:"";m.startsWith("#/")&&m.length>2&&!n.has(m.slice(1))&&n.set(m.slice(1),`${u?`${u} \u203A `:""}${o.text||m}`),i(o.items,o.url?u:o.text||u)}};i(Le(r?.items||[],w||[]),""),n.has(l)||n.set(l,`${l} (not in the sidebar)`),c.replaceChildren();for(const[v,u]of n){const o=document.createElement("option");o.value=v,o.textContent=u,c.appendChild(o)}}let f=null,ye=!1;function Ve(){ye||!window.R?.use||(ye=!0,R.use((c,l,r)=>!(Q.test(l?.path||"")&&!Q.test(c?.path||""))||!f?.dirty()?r():E.confirm("You have unsaved settings. Leave anyway? They are kept as a draft for your next visit (not the SMTP password).").then(n=>{n?r():history.replaceState(null,"","#/settings")})),M.subscribe("router:afterChange",({to:c}={})=>{if(f&&!Q.test(c?.path||"")){const l=f;f=null,l.dispose()}}))}export const settingsView={templateUrl:"/admin/js/templates/settings.html",async onMount(c){if(Ve(),f){const e=f;f=null,e.dispose()}const l=[],r=e=>(l.push(e),e);let w=!1;const n=c.get(0).querySelector(".stx")||c.get(0),i=()=>!w&&n.isConnected,v=E.loader(c.get(0),{type:"dots"});let u;try{u=await B.settings.get()}catch(e){v.destroy(),E.toast(`Could not load the settings: ${e.message||e}`,{type:"error"});return}if(v.destroy(),!n.isConnected)return;const o=M.observable(u||{}),m=Be(u||{}),a={};for(const[e,t]of Object.entries(m))a[e]=M.observable(t);const j=()=>Object.fromEntries(Object.keys(a).map(e=>[e,a[e].value])),X=()=>Object.fromEntries(Object.keys(a).map(e=>[e,a[e].peek()])),b=M.observable(m),q=M.computed(()=>ve(b.value)),C=M.computed(()=>ve(j())!==q.value),x=M.observable(!1),T=M.observable(""),Z=M.observable(!1);B.plugins.policy().then(e=>{i()&&(Z.value=e?.signedOnly===!1)}).catch(()=>{});const U=M.observable(!1),ee=M.computed(()=>{const e=new Set(Ie(j(),b.value));return Object.fromEntries(Object.keys(qe).map(t=>[t,e.has(t)]))}),_=M.observable([]);r(M.effect(()=>{_.value=je(j(),o.value).map(e=>({...e,label:e.tone==="danger"?"Mail":"Check"}))}));const te=M.observable(""),O=M.observable(!1),L=M.observable(""),A=M.observable(""),p=M.observable(null),K=M.observable([]),F=M.observable(""),z=M.observable(!0),N=M.observable(""),se=M.observable([]);r(M.effect(()=>{const e=F.value.trim().toLowerCase(),t=Date.now();se.value=[...K.value].reverse().filter(s=>!e||String(s.key).toLowerCase().includes(e)||(s.tags||[]).some(d=>String(d).toLowerCase().includes(e))).map(s=>{const d=J(s.key);return{id:s.key,path:d.path,meta:[d.page?`as ${d.role}`:"not a page",(s.tags||[]).join(", ")].filter(Boolean).join(" \xB7 "),expires:Pe(s.expiresAt,t)}})}));const ge={...a,saving:x,dirty:C,tabs:ee,problems:_,testTo:te,testing:O,testResult:L,testTone:A,cacheQuery:F,cacheLoading:z,cacheError:N,cacheRows:se,errorText:T,problemsText:M.computed(()=>_.value.length?"yes":""),siteUrlError:M.computed(()=>he(a.siteUrl.value)),noSmtp:M.computed(()=>!String(a.smtpHost.value||"").trim()),mayAllowInsecureTLS:Z,dirtyEmail:M.computed(()=>ee.value.email),cacheOn:M.computed(()=>p.value?.enabled===!0),cacheState:M.computed(()=>{const e=p.value;return e?e.enabled?`On (${e.driver})`:"Off":"Status unknown"}),cacheSize:M.computed(()=>{const e=p.value;return e?.enabled&&e.size!==null&&e.size!==void 0?`${e.size}${e.maxItems?` of ${e.maxItems}`:""} entries`:""}),cacheHits:M.computed(()=>{const e=p.value?.hitRate;return e==null?"":`${Math.round(e*100)}% served from the cache`}),cacheToggleText:M.computed(()=>p.value?.enabled?"Turn off":"Turn on"),cacheEmpty:M.computed(()=>F.value.trim()?"Nothing matches.":p.value?.enabled?"The cache is empty - pages are cached as visitors open them.":"The cache is off.")};async function V(){if(x.peek())return;const e=X(),t=b.peek(),s=he(e.siteUrl);if(s){E.toast(`Site URL: ${s}`,{type:"error"});return}x.value=!0,T.value="";const d=String(e.title).trim()!==String(t.title).trim();try{await B.settings.save(He(e,o.peek(),{adminHomeReady:U.peek()}));const $=await B.settings.get().catch(()=>null);if(!i())return;$&&(o.value=$);const Oe={...e,smtpPass:""};a.smtpPass.value="",b.value=Oe;try{S.remove?S.remove(g):S.set(g,null)}catch{}document.dispatchEvent(new CustomEvent("dm:admin-home-changed")),(d||["adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandIcon"].some(pe=>e[pe]!==t[pe]))&&document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild")),fe(be),E.toast("Settings saved.",{type:"success"})}catch($){T.value=$.message||"Could not save the settings.",E.toast("Settings not saved - see the message at the top.",{type:"error"})}finally{x.value=!1}}async function we(){await E.confirm("Throw away your unsaved settings?")&&(ae(b.peek()),T.value="")}function ae(e){for(const[t,s]of Object.entries(e))a[t]&&(a[t].value=s)}async function ke(){if(!O.peek()){O.value=!0,A.value="",L.value="Sending\u2026";try{const e=await k("/settings/test-email",{method:"POST",body:JSON.stringify({to:te.peek().trim()||void 0})});if(!i())return;L.value=e?.message||"Test email sent.",A.value="is-ok"}catch(e){if(!i())return;L.value=e.message||"Could not send the test email.",A.value="is-bad"}finally{O.value=!1}}}async function P(){z.value=!0;try{const[e,t]=await Promise.all([k("/cache/status").catch(()=>null),k("/cache/keys")]);if(!i())return;p.value=e,K.value=Array.isArray(t?.entries)?t.entries:[],N.value=""}catch(e){if(!i())return;N.value=`Could not read the cache: ${e.message||e}`}finally{z.value=!1}}async function Ee(){if(await E.confirm("Clear the whole response cache? The next visitor to each page renders it afresh.")){try{await k("/cache/clear",{method:"POST"}),E.toast("Cache cleared.",{type:"success"})}catch(e){E.toast(e.message||"Could not clear the cache.",{type:"error"})}i()&&await P()}}async function Se(){const e=p.peek()?.enabled===!0;if(!(e&&!await E.confirm("Turn the response cache off? Every visit will render its page afresh until it is turned back on. The choice is saved (config/cache.json)."))){try{p.value=await k("/cache/toggle",{method:"POST",body:JSON.stringify({enabled:!e})}),E.toast(e?"Cache turned off.":"Cache turned on.",{type:"success"}),fe(be)}catch(t){E.toast(t.message||"Could not change the cache.",{type:"error"})}i()&&await P()}}const ne=e=>K.peek().find(t=>t.key===e);function Me(e){const t=ne(e);if(!t)return[];const s=J(t.key);return[{header:s.path},{label:"Open the page",icon:"external-link",disabled:!s.page,action:()=>window.open(s.path,"_blank","noopener")},{label:"Copy key",icon:"copy",action:async()=>{try{await navigator.clipboard.writeText(t.key),E.toast("Key copied.",{type:"success"})}catch{E.toast("Could not copy - your browser blocked the clipboard.",{type:"warning"})}}},...s.page?[{label:"Copy address",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(new URL(s.path,location.origin).href),E.toast("Address copied.",{type:"success"})}catch{E.toast("Could not copy - your browser blocked the clipboard.",{type:"warning"})}}}]:[]]}n.querySelector(".stx-problems").innerHTML=Fe;const y=n.querySelector(".stx-list");y.innerHTML=ze;const W=E.tabs(n.querySelector(".stx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),oe=new URLSearchParams(location.hash.split("?")[1]||"").get("tab");D.includes(oe)&&W.activate(D.indexOf(oe));const Ce=M.applyBindings(ge,n,{methods:{save:V,discard:we,sendTest:ke,refreshCache:P,clearCache:Ee,toggleCache:Se,pickBrandImage:async e=>{const t=await Ue({title:"Choose a branding image",current:a[e].peek()});t&&i()&&(a[e].value=t)},clearBrandImage:e=>{a[e].value=""},goTab:e=>{const t=D.indexOf(e);t>=0&&W.activate(t)}}});r(()=>Ce.dispose());for(const e of n.querySelectorAll("[data-brand-icon]")){const t=e.dataset.brandIcon,s=_e("Choose an icon",a[t].peek());s.input.id=`stx-${t}`,s.input.classList.add("form-input");const d=()=>{a[t].value=s.input.value};s.input.addEventListener("input",d),r(()=>s.input.removeEventListener("input",d)),r(M.effect(()=>{s.input.value=a[t].value})),e.appendChild(s.el)}r(Re(n,{position:"bottom"}));const xe=e=>{const t=e.target.closest("[data-go]");if(!t)return;const s=D.indexOf(t.dataset.go);s>=0&&W.activate(s)};n.querySelector(".stx-problems").addEventListener("click",xe);const Y=n.querySelector("#stx-admin-home");Ne(Y,De(a.adminHome.peek())).then(()=>{i()&&(Y.value=a.adminHome.peek(),U.value=!0)}).catch(()=>{});const Te=E.contextMenu(y,{cursor:"glyph",match:".stx-row",inherit:!1,density:"compact",items:e=>Me(e.dataset.id)});r(()=>Te?.destroy?.());const re=e=>{const t=ne(e.dataset.id),s=t&&J(t.key);s?.page?window.open(s.path,"_blank","noopener"):G(e)},ie=e=>{const t=e.target.closest(".stx-row");if(!t)return;const s=e.target.closest(".stx-kebab");if(s){G(s);return}re(t)},ce=e=>{const t=e.target.closest(".stx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),G(t)):e.key==="Enter"&&e.target===t&&re(t))};y.addEventListener("click",ie),y.addEventListener("keydown",ce),r(()=>{y.removeEventListener("click",ie),y.removeEventListener("keydown",ce)}),me(c,{id:"settings-view-site",icon:"external-link",title:"View site",onClick:()=>window.open("/","_blank","noopener")}),me(c,{id:"settings-save",icon:"save",title:"Save (Ctrl+S)",onClick:()=>V()});const le=e=>{!(e.ctrlKey||e.metaKey)||e.key!=="s"||(e.preventDefault(),e.stopImmediatePropagation(),V())};document.addEventListener("keydown",le,!0),r(()=>document.removeEventListener("keydown",le,!0));const ue=()=>{if(C.peek())try{S.set(g,{form:Ae(X()),base:q.peek(),at:new Date().toISOString()})}catch{}},de=e=>{C.peek()&&(ue(),e.preventDefault(),e.returnValue="")};window.addEventListener("beforeunload",de),r(()=>window.removeEventListener("beforeunload",de)),f={dirty:()=>C.peek(),dispose(){w=!0,ue(),l.splice(0).reverse().forEach(e=>{try{e()}catch{}})}},I.scan(n),P();let h=null;try{h=S.get(g)}catch{}if(h?.form){try{S.remove?S.remove(g):S.set(g,null)}catch{}const e=h.base&&h.base!==q.peek(),t=h.at?` (${Ke(h.at)})`:"",s=e?`You left unsaved settings${t}, but the saved settings have changed since. Restore your version anyway?`:`You left unsaved settings${t}. Restore them?`;await E.confirm(s)&&i()&&(ae($e(b.peek(),h.form)),U.peek()&&(Y.value=a.adminHome.peek()))}}};
11
+ </div>`,$=["general","branding","email","cookies","cache"];async function Ne(c,l){const[r,w]=await Promise.all([H.get("/api/sidebar/menu").catch(()=>({items:[]})),H.get("/api/sidebar/registered-items").catch(()=>[])]),n=new Map([["/","Dashboard (built in)"]]),i=(v,u)=>{for(const o of v||[]){if(!o||o.hidden||o.restricted)continue;const m=typeof o.url=="string"?o.url:"";m.startsWith("#/")&&m.length>2&&!n.has(m.slice(1))&&n.set(m.slice(1),`${u?`${u} \u203A `:""}${o.text||m}`),i(o.items,o.url?u:o.text||u)}};i(Oe(r?.items||[],w||[]),""),n.has(l)||n.set(l,`${l} (not in the sidebar)`),c.replaceChildren();for(const[v,u]of n){const o=document.createElement("option");o.value=v,o.textContent=u,c.appendChild(o)}}let f=null,ye=!1;function Ve(){ye||!window.R?.use||(ye=!0,R.use((c,l,r)=>!(Q.test(l?.path||"")&&!Q.test(c?.path||""))||!f?.dirty()?r():E.confirm("You have unsaved settings. Leave anyway? They are kept as a draft for your next visit (not the SMTP password).").then(n=>{n?r():history.replaceState(null,"","#/settings")})),M.subscribe("router:afterChange",({to:c}={})=>{if(f&&!Q.test(c?.path||"")){const l=f;f=null,l.dispose()}}))}export const settingsView={templateUrl:"/admin/js/templates/settings.html",async onMount(c){if(Ve(),f){const e=f;f=null,e.dispose()}const l=[],r=e=>(l.push(e),e);let w=!1;const n=c.get(0).querySelector(".stx")||c.get(0),i=()=>!w&&n.isConnected,v=E.loader(c.get(0),{type:"dots"});let u;try{u=await D.settings.get()}catch(e){v.destroy(),E.toast(`Could not load the settings: ${e.message||e}`,{type:"error"});return}if(v.destroy(),!n.isConnected)return;const o=M.observable(u||{}),m=De(u||{}),s={};for(const[e,t]of Object.entries(m))s[e]=M.observable(t);const j=()=>Object.fromEntries(Object.keys(s).map(e=>[e,s[e].value])),X=()=>Object.fromEntries(Object.keys(s).map(e=>[e,s[e].peek()])),b=M.observable(m),q=M.computed(()=>ve(b.value)),C=M.computed(()=>ve(j())!==q.value),x=M.observable(!1),T=M.observable(""),Z=M.observable(!1);D.plugins.policy().then(e=>{i()&&(Z.value=e?.signedOnly===!1)}).catch(()=>{});const U=M.observable(!1),ee=M.computed(()=>{const e=new Set(Ie(j(),b.value));return Object.fromEntries(Object.keys(qe).map(t=>[t,e.has(t)]))}),_=M.observable([]);r(M.effect(()=>{_.value=je(j(),o.value).map(e=>({...e,label:e.tone==="danger"?"Mail":"Check"}))}));const te=M.observable(""),L=M.observable(!1),O=M.observable(""),A=M.observable(""),p=M.observable(null),K=M.observable([]),F=M.observable(""),z=M.observable(!0),N=M.observable(""),ae=M.observable([]);r(M.effect(()=>{const e=F.value.trim().toLowerCase(),t=Date.now();ae.value=[...K.value].reverse().filter(a=>!e||String(a.key).toLowerCase().includes(e)||(a.tags||[]).some(d=>String(d).toLowerCase().includes(e))).map(a=>{const d=J(a.key);return{id:a.key,path:d.path,meta:[d.page?`as ${d.role}`:"not a page",(a.tags||[]).join(", ")].filter(Boolean).join(" \xB7 "),expires:Pe(a.expiresAt,t)}})}));const ge={...s,saving:x,dirty:C,tabs:ee,problems:_,testTo:te,testing:L,testResult:O,testTone:A,cacheQuery:F,cacheLoading:z,cacheError:N,cacheRows:ae,errorText:T,problemsText:M.computed(()=>_.value.length?"yes":""),siteUrlError:M.computed(()=>he(s.siteUrl.value)),noSmtp:M.computed(()=>!String(s.smtpHost.value||"").trim()),mayAllowInsecureTLS:Z,dirtyEmail:M.computed(()=>ee.value.email),cacheOn:M.computed(()=>p.value?.enabled===!0),cacheState:M.computed(()=>{const e=p.value;return e?e.enabled?`On (${e.driver})`:"Off":"Status unknown"}),cacheSize:M.computed(()=>{const e=p.value;return e?.enabled&&e.size!==null&&e.size!==void 0?`${e.size}${e.maxItems?` of ${e.maxItems}`:""} entries`:""}),cacheHits:M.computed(()=>{const e=p.value?.hitRate;return e==null?"":`${Math.round(e*100)}% served from the cache`}),cacheToggleText:M.computed(()=>p.value?.enabled?"Turn off":"Turn on"),cacheEmpty:M.computed(()=>F.value.trim()?"Nothing matches.":p.value?.enabled?"The cache is empty - pages are cached as visitors open them.":"The cache is off.")};async function V(){if(x.peek())return;const e=X(),t=b.peek(),a=he(e.siteUrl);if(a){E.toast(`Site URL: ${a}`,{type:"error"});return}x.value=!0,T.value="";const d=String(e.title).trim()!==String(t.title).trim();try{await D.settings.save(He(e,o.peek(),{adminHomeReady:U.peek()}));const B=await D.settings.get().catch(()=>null);if(!i())return;B&&(o.value=B);const Le={...e,smtpPass:""};s.smtpPass.value="",b.value=Le;try{S.remove?S.remove(g):S.set(g,null)}catch{}document.dispatchEvent(new CustomEvent("dm:admin-home-changed")),(d||["adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"].some(pe=>e[pe]!==t[pe]))&&document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild")),fe(be),E.toast("Settings saved.",{type:"success"})}catch(B){T.value=B.message||"Could not save the settings.",E.toast("Settings not saved - see the message at the top.",{type:"error"})}finally{x.value=!1}}async function we(){await E.confirm("Throw away your unsaved settings?")&&(se(b.peek()),T.value="")}function se(e){for(const[t,a]of Object.entries(e))s[t]&&(s[t].value=a)}async function ke(){if(!L.peek()){L.value=!0,A.value="",O.value="Sending\u2026";try{const e=await k("/settings/test-email",{method:"POST",body:JSON.stringify({to:te.peek().trim()||void 0})});if(!i())return;O.value=e?.message||"Test email sent.",A.value="is-ok"}catch(e){if(!i())return;O.value=e.message||"Could not send the test email.",A.value="is-bad"}finally{L.value=!1}}}async function P(){z.value=!0;try{const[e,t]=await Promise.all([k("/cache/status").catch(()=>null),k("/cache/keys")]);if(!i())return;p.value=e,K.value=Array.isArray(t?.entries)?t.entries:[],N.value=""}catch(e){if(!i())return;N.value=`Could not read the cache: ${e.message||e}`}finally{z.value=!1}}async function Ee(){if(await E.confirm("Clear the whole response cache? The next visitor to each page renders it afresh.")){try{await k("/cache/clear",{method:"POST"}),E.toast("Cache cleared.",{type:"success"})}catch(e){E.toast(e.message||"Could not clear the cache.",{type:"error"})}i()&&await P()}}async function Se(){const e=p.peek()?.enabled===!0;if(!(e&&!await E.confirm("Turn the response cache off? Every visit will render its page afresh until it is turned back on. The choice is saved (config/cache.json)."))){try{p.value=await k("/cache/toggle",{method:"POST",body:JSON.stringify({enabled:!e})}),E.toast(e?"Cache turned off.":"Cache turned on.",{type:"success"}),fe(be)}catch(t){E.toast(t.message||"Could not change the cache.",{type:"error"})}i()&&await P()}}const ne=e=>K.peek().find(t=>t.key===e);function Me(e){const t=ne(e);if(!t)return[];const a=J(t.key);return[{header:a.path},{label:"Open the page",icon:"external-link",disabled:!a.page,action:()=>window.open(a.path,"_blank","noopener")},{label:"Copy key",icon:"copy",action:async()=>{try{await navigator.clipboard.writeText(t.key),E.toast("Key copied.",{type:"success"})}catch{E.toast("Could not copy - your browser blocked the clipboard.",{type:"warning"})}}},...a.page?[{label:"Copy address",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(new URL(a.path,location.origin).href),E.toast("Address copied.",{type:"success"})}catch{E.toast("Could not copy - your browser blocked the clipboard.",{type:"warning"})}}}]:[]]}n.querySelector(".stx-problems").innerHTML=Fe;const y=n.querySelector(".stx-list");y.innerHTML=ze;const W=E.tabs(n.querySelector(".stx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),oe=new URLSearchParams(location.hash.split("?")[1]||"").get("tab");$.includes(oe)&&W.activate($.indexOf(oe));const Ce=M.applyBindings(ge,n,{methods:{save:V,discard:we,sendTest:ke,refreshCache:P,clearCache:Ee,toggleCache:Se,pickBrandImage:async e=>{const t=await Ue({title:"Choose a branding image",current:s[e].peek()});t&&i()&&(s[e].value=t)},clearBrandImage:e=>{s[e].value=""},goTab:e=>{const t=$.indexOf(e);t>=0&&W.activate(t)}}});r(()=>Ce.dispose());for(const e of n.querySelectorAll("[data-brand-icon]")){const t=e.dataset.brandIcon,a=_e("Choose an icon",s[t].peek());a.input.id=`stx-${t}`,a.input.classList.add("form-input");const d=()=>{s[t].value=a.input.value};a.input.addEventListener("input",d),r(()=>a.input.removeEventListener("input",d)),r(M.effect(()=>{a.input.value=s[t].value})),e.appendChild(a.el)}r(Re(n,{position:"bottom"}));const xe=e=>{const t=e.target.closest("[data-go]");if(!t)return;const a=$.indexOf(t.dataset.go);a>=0&&W.activate(a)};n.querySelector(".stx-problems").addEventListener("click",xe);const Y=n.querySelector("#stx-admin-home");Ne(Y,$e(s.adminHome.peek())).then(()=>{i()&&(Y.value=s.adminHome.peek(),U.value=!0)}).catch(()=>{});const Te=E.contextMenu(y,{cursor:"glyph",match:".stx-row",inherit:!1,density:"compact",items:e=>Me(e.dataset.id)});r(()=>Te?.destroy?.());const re=e=>{const t=ne(e.dataset.id),a=t&&J(t.key);a?.page?window.open(a.path,"_blank","noopener"):G(e)},ie=e=>{const t=e.target.closest(".stx-row");if(!t)return;const a=e.target.closest(".stx-kebab");if(a){G(a);return}re(t)},ce=e=>{const t=e.target.closest(".stx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),G(t)):e.key==="Enter"&&e.target===t&&re(t))};y.addEventListener("click",ie),y.addEventListener("keydown",ce),r(()=>{y.removeEventListener("click",ie),y.removeEventListener("keydown",ce)}),me(c,{id:"settings-view-site",icon:"external-link",title:"View site",onClick:()=>window.open("/","_blank","noopener")}),me(c,{id:"settings-save",icon:"save",title:"Save (Ctrl+S)",onClick:()=>V()});const le=e=>{!(e.ctrlKey||e.metaKey)||e.key!=="s"||(e.preventDefault(),e.stopImmediatePropagation(),V())};document.addEventListener("keydown",le,!0),r(()=>document.removeEventListener("keydown",le,!0));const ue=()=>{if(C.peek())try{S.set(g,{form:Ae(X()),base:q.peek(),at:new Date().toISOString()})}catch{}},de=e=>{C.peek()&&(ue(),e.preventDefault(),e.returnValue="")};window.addEventListener("beforeunload",de),r(()=>window.removeEventListener("beforeunload",de)),f={dirty:()=>C.peek(),dispose(){w=!0,ue(),l.splice(0).reverse().forEach(e=>{try{e()}catch{}})}},I.scan(n),P();let h=null;try{h=S.get(g)}catch{}if(h?.form){try{S.remove?S.remove(g):S.set(g,null)}catch{}const e=h.base&&h.base!==q.peek(),t=h.at?` (${Ke(h.at)})`:"",a=e?`You left unsaved settings${t}, but the saved settings have changed since. Restore your version anyway?`:`You left unsaved settings${t}. Restore them?`;await E.confirm(a)&&i()&&(se(Be(b.peek(),h.form)),U.peek()&&(Y.value=s.adminHome.peek()))}}};
@@ -959,6 +959,19 @@ shortcode preview.
959
959
 
960
960
  ---
961
961
 
962
+
963
+ ### `[map]`
964
+
965
+ A responsive Google Map of one place. Give `pin` (latitude, longitude), `lat` + `lon`, an `address` or a `postcode`.
966
+
967
+ ```text
968
+ [map postcode="SW1A 2AA" zoom="15" caption="Visit us" /]
969
+ [map pin="51.5034,-0.1276" zoom="14" title="Office" ratio="4:3" width="640" align="center" /]
970
+ ```
971
+
972
+ `zoom` is 1-20 (default 14); `ratio` is 16:9 (default), 4:3, 1:1 or 21:9; `width` in px or %; `align` left, center or
973
+ right; `caption` (or `title`) is shown under the map. Malformed coordinates show a notice instead of a map. Google's
974
+ embed host is always allowed to frame, so no `config/embeds.json` entry is needed.
962
975
  ### `[form]`
963
976
 
964
977
  Self-closing. Embeds a CMS-managed form by slug. Forms are configured under **Forms** in the sidebar.
@@ -1,6 +1,6 @@
1
1
  # Domma block library
2
2
 
3
- Seventeen free, editable Custom Blocks come with every Domma CMS site. There is
3
+ Twenty-one free, editable Custom Blocks come with every Domma CMS site. There is
4
4
  no extra licence or plugin to install. Search for `domma-block-` in **Blocks**
5
5
  or in the editor's **Add block** menu. Each block includes its own scoped CSS,
6
6
  a copyable example and documented parameters.
@@ -25,6 +25,10 @@ a copyable example and documented parameters.
25
25
  | `domma-block-team-card` | A team member photo, role and short introduction. |
26
26
  | `domma-block-image` | An uncropped image with an optional caption. |
27
27
  | `domma-block-logos` | A responsive row of up to four organisation logos. |
28
+ | `domma-block-feature-card` | Feature card with an icon, description and optional link. |
29
+ | `domma-block-comparison-card` | Comparison card with two labelled choices. |
30
+ | `domma-block-image-card` | Image card with a heading, description and optional link. |
31
+ | `domma-block-cta-card` | Compact call-to-action card with a heading and link. |
28
32
 
29
33
  ## Make it yours
30
34
 
@@ -180,6 +184,38 @@ A responsive row of up to four organisation logos.
180
184
  [domma-block-logos header="Who we work with" image1="/media/partner-logo.svg" alt1="Partner name" /]
181
185
  ```
182
186
 
187
+ ### domma-block-feature-card
188
+
189
+ Feature card with an icon, description and optional link.
190
+
191
+ ```text
192
+ [domma-block-feature-card header="Everything in one place" icon="grid" blurb="Explore the features included with your site." link="/features" label="See the features" /]
193
+ ```
194
+
195
+ ### domma-block-comparison-card
196
+
197
+ Comparison card with two labelled choices.
198
+
199
+ ```text
200
+ [domma-block-comparison-card header="Find your fit" icon="layers" first_label="Choose a hosted builder" first="For a quick template website." second_label="Choose a CMS" second="For more control over your content." /]
201
+ ```
202
+
203
+ ### domma-block-image-card
204
+
205
+ Image card with a heading, description and optional link.
206
+
207
+ ```text
208
+ [domma-block-image-card header="Our work" blurb="Take a closer look at a recent project." image="/media/project.jpg" alt="A recent project" link="/showcase" label="View the project" /]
209
+ ```
210
+
211
+ ### domma-block-cta-card
212
+
213
+ Compact call-to-action card with a heading and link.
214
+
215
+ ```text
216
+ [domma-block-cta-card header="Let us help" icon="mail" blurb="Tell us what you have in mind." link="/contact" label="Get in touch" /]
217
+ ```
218
+
183
219
  ## Blocks in headers, footers and menus
184
220
 
185
221
  The running CMS already supports custom blocks in **Site Settings > Footer**.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -100,5 +100,29 @@
100
100
  "category": "cards",
101
101
  "description": "A softly rounded card with a raised rim and inset panel.",
102
102
  "example": "[domma-block-cushion-card heading=\"Make yourself at home\" /]"
103
+ },
104
+ {
105
+ "name": "domma-block-feature-card",
106
+ "category": "cards",
107
+ "description": "Feature card with an icon, description and optional link.",
108
+ "example": "[domma-block-feature-card header=\"Everything in one place\" icon=\"grid\" blurb=\"Explore the features included with your site.\" link=\"/features\" label=\"See the features\" /]"
109
+ },
110
+ {
111
+ "name": "domma-block-comparison-card",
112
+ "category": "cards",
113
+ "description": "Comparison card with two labelled choices.",
114
+ "example": "[domma-block-comparison-card header=\"Find your fit\" icon=\"layers\" first_label=\"Choose a hosted builder\" first=\"For a quick template website.\" second_label=\"Choose a CMS\" second=\"For more control over your content.\" /]"
115
+ },
116
+ {
117
+ "name": "domma-block-image-card",
118
+ "category": "cards",
119
+ "description": "Image card with a heading, description and optional link.",
120
+ "example": "[domma-block-image-card header=\"Our work\" blurb=\"Take a closer look at a recent project.\" image=\"/media/project.jpg\" alt=\"A recent project\" link=\"/showcase\" label=\"View the project\" /]"
121
+ },
122
+ {
123
+ "name": "domma-block-cta-card",
124
+ "category": "cards",
125
+ "description": "Compact call-to-action card with a heading and link.",
126
+ "example": "[domma-block-cta-card header=\"Let us help\" icon=\"mail\" blurb=\"Tell us what you have in mind.\" link=\"/contact\" label=\"Get in touch\" /]"
103
127
  }
104
128
  ]
@@ -0,0 +1,20 @@
1
+ /* Shared default card proportions; colour is opt-in and intentionally light. */
2
+ .db-card { --db-accent: var(--dm-primary, #486b82); box-sizing: border-box; height: 100%; display: flex; flex-direction: column; gap: .9rem; padding: 1.5rem; border: 1px solid var(--dm-border, #d5e0e5); border-radius: var(--dm-radius-lg, .75rem); background: var(--dm-card-bg, #fff); color: var(--dm-text, #152832); overflow-wrap: anywhere; }
3
+ .db-card[data-tone="blue"] { --db-accent: #547d99; }
4
+ .db-card[data-tone="teal"] { --db-accent: #50857b; }
5
+ .db-card[data-tone="violet"] { --db-accent: #837298; }
6
+ .db-card[data-tone="warm"] { --db-accent: #a37b59; }
7
+ .db-card:is([data-tone="blue"], [data-tone="teal"], [data-tone="violet"], [data-tone="warm"]) { background: color-mix(in srgb, var(--db-accent) 4%, var(--dm-card-bg, #fff)); border-color: color-mix(in srgb, var(--db-accent) 22%, var(--dm-border, #d5e0e5)); }
8
+ .db-card .db-card-icon { box-sizing: border-box; width: 2.5rem; height: 2.5rem; padding: .55rem; border-radius: .6rem; background: color-mix(in srgb, var(--db-accent) 10%, var(--dm-card-bg, #fff)); color: var(--db-accent); }
9
+ .db-card-icon[data-icon=""] { display: none; }
10
+ .db-card h3 { margin: 0; font-size: 1.2rem; font-weight: 650; line-height: 1.35; color: inherit; }
11
+ .db-card p { margin: 0; color: var(--dm-text-secondary, #465865); font-size: 1rem; line-height: 1.65; white-space: pre-line; }
12
+ .db-card p:empty { display: none; }
13
+ .db-card-choice { display: grid; gap: .35rem; }
14
+ .db-card-choice strong { font-size: .9rem; font-weight: 600; }
15
+ .db-card-choice + .db-card-choice { padding-top: .9rem; border-top: 1px solid var(--dm-border, #d5e0e5); }
16
+ .db-card .db-card-link { margin-top: auto; padding-top: .25rem; color: var(--dm-primary, #486b82); font-weight: 600; text-underline-offset: .2em; }
17
+ .db-card-link[href=""], .db-card-link:empty { display: none; }
18
+ .db-card-link:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
19
+ .db-card-image { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--dm-radius-md, .5rem); }
20
+ .db-card-image[src=""] { display: none; }
@@ -0,0 +1,18 @@
1
+ <!--
2
+ domma-block-comparison-card - Comparison card with two labelled choices.
3
+
4
+ Parameters:
5
+ header - Card heading
6
+ icon - Optional Domma icon name
7
+ tone - Optional subtle accent: blue, teal, violet or warm; omitted is neutral
8
+ link - Optional link destination
9
+ label - Optional link text
10
+ first_label - First choice label
11
+ first - First choice description as plain text
12
+ second_label - Second choice label
13
+ second - Second choice description as plain text
14
+
15
+ Example:
16
+ [domma-block-comparison-card header="Find your fit" icon="layers" first_label="Choose a hosted builder" first="For a quick template website." second_label="Choose a CMS" second="For more control over your content." /]
17
+ -->
18
+ <article class="db-card" data-tone="{{tone}}"><span class="db-card-icon" data-icon="{{icon}}"></span><h3>{{header}}</h3><div class="db-card-choice"><strong>{{first_label}}</strong><p>{{first}}</p></div><div class="db-card-choice"><strong>{{second_label}}</strong><p>{{second}}</p></div><a class="db-card-link" href="{{link}}">{{label}}</a></article>
@@ -0,0 +1,7 @@
1
+ {
2
+ "bundled": true,
3
+ "adminTags": [
4
+ "domma-blocks",
5
+ "cards"
6
+ ]
7
+ }
@@ -0,0 +1,20 @@
1
+ /* Shared default card proportions; colour is opt-in and intentionally light. */
2
+ .db-card { --db-accent: var(--dm-primary, #486b82); box-sizing: border-box; height: 100%; display: flex; flex-direction: column; gap: .9rem; padding: 1.5rem; border: 1px solid var(--dm-border, #d5e0e5); border-radius: var(--dm-radius-lg, .75rem); background: var(--dm-card-bg, #fff); color: var(--dm-text, #152832); overflow-wrap: anywhere; }
3
+ .db-card[data-tone="blue"] { --db-accent: #547d99; }
4
+ .db-card[data-tone="teal"] { --db-accent: #50857b; }
5
+ .db-card[data-tone="violet"] { --db-accent: #837298; }
6
+ .db-card[data-tone="warm"] { --db-accent: #a37b59; }
7
+ .db-card:is([data-tone="blue"], [data-tone="teal"], [data-tone="violet"], [data-tone="warm"]) { background: color-mix(in srgb, var(--db-accent) 4%, var(--dm-card-bg, #fff)); border-color: color-mix(in srgb, var(--db-accent) 22%, var(--dm-border, #d5e0e5)); }
8
+ .db-card .db-card-icon { box-sizing: border-box; width: 2.5rem; height: 2.5rem; padding: .55rem; border-radius: .6rem; background: color-mix(in srgb, var(--db-accent) 10%, var(--dm-card-bg, #fff)); color: var(--db-accent); }
9
+ .db-card-icon[data-icon=""] { display: none; }
10
+ .db-card h3 { margin: 0; font-size: 1.2rem; font-weight: 650; line-height: 1.35; color: inherit; }
11
+ .db-card p { margin: 0; color: var(--dm-text-secondary, #465865); font-size: 1rem; line-height: 1.65; white-space: pre-line; }
12
+ .db-card p:empty { display: none; }
13
+ .db-card-choice { display: grid; gap: .35rem; }
14
+ .db-card-choice strong { font-size: .9rem; font-weight: 600; }
15
+ .db-card-choice + .db-card-choice { padding-top: .9rem; border-top: 1px solid var(--dm-border, #d5e0e5); }
16
+ .db-card .db-card-link { margin-top: auto; padding-top: .25rem; color: var(--dm-primary, #486b82); font-weight: 600; text-underline-offset: .2em; }
17
+ .db-card-link[href=""], .db-card-link:empty { display: none; }
18
+ .db-card-link:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
19
+ .db-card-image { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--dm-radius-md, .5rem); }
20
+ .db-card-image[src=""] { display: none; }
@@ -0,0 +1,15 @@
1
+ <!--
2
+ domma-block-cta-card - Compact call-to-action card with a heading and link.
3
+
4
+ Parameters:
5
+ header - Card heading
6
+ icon - Optional Domma icon name
7
+ tone - Optional subtle accent: blue, teal, violet or warm; omitted is neutral
8
+ link - Optional link destination
9
+ label - Optional link text
10
+ blurb - Short invitation as plain text
11
+
12
+ Example:
13
+ [domma-block-cta-card header="Let us help" icon="mail" blurb="Tell us what you have in mind." link="/contact" label="Get in touch" /]
14
+ -->
15
+ <article class="db-card" data-tone="{{tone}}"><span class="db-card-icon" data-icon="{{icon}}"></span><h3>{{header}}</h3><p>{{blurb}}</p><a class="db-card-link" href="{{link}}">{{label}}</a></article>
@@ -0,0 +1,7 @@
1
+ {
2
+ "bundled": true,
3
+ "adminTags": [
4
+ "domma-blocks",
5
+ "cards"
6
+ ]
7
+ }
@@ -0,0 +1,20 @@
1
+ /* Shared default card proportions; colour is opt-in and intentionally light. */
2
+ .db-card { --db-accent: var(--dm-primary, #486b82); box-sizing: border-box; height: 100%; display: flex; flex-direction: column; gap: .9rem; padding: 1.5rem; border: 1px solid var(--dm-border, #d5e0e5); border-radius: var(--dm-radius-lg, .75rem); background: var(--dm-card-bg, #fff); color: var(--dm-text, #152832); overflow-wrap: anywhere; }
3
+ .db-card[data-tone="blue"] { --db-accent: #547d99; }
4
+ .db-card[data-tone="teal"] { --db-accent: #50857b; }
5
+ .db-card[data-tone="violet"] { --db-accent: #837298; }
6
+ .db-card[data-tone="warm"] { --db-accent: #a37b59; }
7
+ .db-card:is([data-tone="blue"], [data-tone="teal"], [data-tone="violet"], [data-tone="warm"]) { background: color-mix(in srgb, var(--db-accent) 4%, var(--dm-card-bg, #fff)); border-color: color-mix(in srgb, var(--db-accent) 22%, var(--dm-border, #d5e0e5)); }
8
+ .db-card .db-card-icon { box-sizing: border-box; width: 2.5rem; height: 2.5rem; padding: .55rem; border-radius: .6rem; background: color-mix(in srgb, var(--db-accent) 10%, var(--dm-card-bg, #fff)); color: var(--db-accent); }
9
+ .db-card-icon[data-icon=""] { display: none; }
10
+ .db-card h3 { margin: 0; font-size: 1.2rem; font-weight: 650; line-height: 1.35; color: inherit; }
11
+ .db-card p { margin: 0; color: var(--dm-text-secondary, #465865); font-size: 1rem; line-height: 1.65; white-space: pre-line; }
12
+ .db-card p:empty { display: none; }
13
+ .db-card-choice { display: grid; gap: .35rem; }
14
+ .db-card-choice strong { font-size: .9rem; font-weight: 600; }
15
+ .db-card-choice + .db-card-choice { padding-top: .9rem; border-top: 1px solid var(--dm-border, #d5e0e5); }
16
+ .db-card .db-card-link { margin-top: auto; padding-top: .25rem; color: var(--dm-primary, #486b82); font-weight: 600; text-underline-offset: .2em; }
17
+ .db-card-link[href=""], .db-card-link:empty { display: none; }
18
+ .db-card-link:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
19
+ .db-card-image { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--dm-radius-md, .5rem); }
20
+ .db-card-image[src=""] { display: none; }
@@ -0,0 +1,15 @@
1
+ <!--
2
+ domma-block-feature-card - Feature card with an icon, description and optional link.
3
+
4
+ Parameters:
5
+ header - Card heading
6
+ icon - Optional Domma icon name
7
+ tone - Optional subtle accent: blue, teal, violet or warm; omitted is neutral
8
+ link - Optional link destination
9
+ label - Optional link text
10
+ blurb - Description as plain text
11
+
12
+ Example:
13
+ [domma-block-feature-card header="Everything in one place" icon="grid" blurb="Explore the features included with your site." link="/features" label="See the features" /]
14
+ -->
15
+ <article class="db-card" data-tone="{{tone}}"><span class="db-card-icon" data-icon="{{icon}}"></span><h3>{{header}}</h3><p>{{blurb}}</p><a class="db-card-link" href="{{link}}">{{label}}</a></article>
@@ -0,0 +1,7 @@
1
+ {
2
+ "bundled": true,
3
+ "adminTags": [
4
+ "domma-blocks",
5
+ "cards"
6
+ ]
7
+ }
@@ -0,0 +1,20 @@
1
+ /* Shared default card proportions; colour is opt-in and intentionally light. */
2
+ .db-card { --db-accent: var(--dm-primary, #486b82); box-sizing: border-box; height: 100%; display: flex; flex-direction: column; gap: .9rem; padding: 1.5rem; border: 1px solid var(--dm-border, #d5e0e5); border-radius: var(--dm-radius-lg, .75rem); background: var(--dm-card-bg, #fff); color: var(--dm-text, #152832); overflow-wrap: anywhere; }
3
+ .db-card[data-tone="blue"] { --db-accent: #547d99; }
4
+ .db-card[data-tone="teal"] { --db-accent: #50857b; }
5
+ .db-card[data-tone="violet"] { --db-accent: #837298; }
6
+ .db-card[data-tone="warm"] { --db-accent: #a37b59; }
7
+ .db-card:is([data-tone="blue"], [data-tone="teal"], [data-tone="violet"], [data-tone="warm"]) { background: color-mix(in srgb, var(--db-accent) 4%, var(--dm-card-bg, #fff)); border-color: color-mix(in srgb, var(--db-accent) 22%, var(--dm-border, #d5e0e5)); }
8
+ .db-card .db-card-icon { box-sizing: border-box; width: 2.5rem; height: 2.5rem; padding: .55rem; border-radius: .6rem; background: color-mix(in srgb, var(--db-accent) 10%, var(--dm-card-bg, #fff)); color: var(--db-accent); }
9
+ .db-card-icon[data-icon=""] { display: none; }
10
+ .db-card h3 { margin: 0; font-size: 1.2rem; font-weight: 650; line-height: 1.35; color: inherit; }
11
+ .db-card p { margin: 0; color: var(--dm-text-secondary, #465865); font-size: 1rem; line-height: 1.65; white-space: pre-line; }
12
+ .db-card p:empty { display: none; }
13
+ .db-card-choice { display: grid; gap: .35rem; }
14
+ .db-card-choice strong { font-size: .9rem; font-weight: 600; }
15
+ .db-card-choice + .db-card-choice { padding-top: .9rem; border-top: 1px solid var(--dm-border, #d5e0e5); }
16
+ .db-card .db-card-link { margin-top: auto; padding-top: .25rem; color: var(--dm-primary, #486b82); font-weight: 600; text-underline-offset: .2em; }
17
+ .db-card-link[href=""], .db-card-link:empty { display: none; }
18
+ .db-card-link:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
19
+ .db-card-image { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--dm-radius-md, .5rem); }
20
+ .db-card-image[src=""] { display: none; }
@@ -0,0 +1,17 @@
1
+ <!--
2
+ domma-block-image-card - Image card with a heading, description and optional link.
3
+
4
+ Parameters:
5
+ header - Card heading
6
+ icon - Optional Domma icon name
7
+ tone - Optional subtle accent: blue, teal, violet or warm; omitted is neutral
8
+ link - Optional link destination
9
+ label - Optional link text
10
+ blurb - Description as plain text
11
+ image - Image address from your Media library
12
+ alt - Image description
13
+
14
+ Example:
15
+ [domma-block-image-card header="Our work" blurb="Take a closer look at a recent project." image="/media/project.jpg" alt="A recent project" link="/showcase" label="View the project" /]
16
+ -->
17
+ <article class="db-card" data-tone="{{tone}}"><img class="db-card-image" src="{{image}}" alt="{{alt}}" loading="lazy" decoding="async"><span class="db-card-icon" data-icon="{{icon}}"></span><h3>{{header}}</h3><p>{{blurb}}</p><a class="db-card-link" href="{{link}}">{{label}}</a></article>
@@ -0,0 +1,7 @@
1
+ {
2
+ "bundled": true,
3
+ "adminTags": [
4
+ "domma-blocks",
5
+ "cards"
6
+ ]
7
+ }
@@ -16,18 +16,21 @@ export const DEFAULT_ADMIN_TITLE = 'Domma CMS';
16
16
 
17
17
  /**
18
18
  * @param {object} [site] - config/site.json
19
- * @returns {{title: string, logo: string, icon: string}}
19
+ * @returns {{title: string, logo: string, logoDark: string, icon: string}}
20
20
  */
21
21
  export function adminBrandFor(site = {}) {
22
22
  const own = site?.adminBrand && typeof site.adminBrand === 'object' ? site.adminBrand : {};
23
23
  // Whitespace collapsed: a title reads back that way from the browser tab.
24
24
  const str = (v) => (typeof v === 'string' ? v.replace(/[ \t\n\f\r]+/g, ' ').trim() : '');
25
25
  const logo = str(own.logo);
26
+ const logoDark = str(own.logoDark);
26
27
  return {
27
28
  enabled: own.enabled !== false,
28
29
  title: (str(own.title) || str(site?.title) || DEFAULT_ADMIN_TITLE).slice(0, 120),
29
30
  // Same rule as the sidebar header: a site path or an http(s) address, nothing else.
30
31
  logo: /^(?:\/(?!\/)|https?:\/\/)/i.test(logo) ? logo : '',
32
+ // Optional: the logo for a dark admin theme (lib/theme-aware-logo.js picks one by the theme's background).
33
+ logoDark: /^(?:\/(?!\/)|https?:\/\/)/i.test(logoDark) ? logoDark : '',
31
34
  icon: /^[a-z0-9-]{1,40}$/.test(str(own.icon)) ? str(own.icon) : ''
32
35
  };
33
36
  }
@@ -15,7 +15,7 @@
15
15
  */
16
16
  /** The players [embed] always uses. */
17
17
  // youtube.com too: the HTML sanitiser lets its iframes through, so the policy must agree.
18
- export const ALWAYS_FRAMED = ['https://www.youtube-nocookie.com', 'https://www.youtube.com', 'https://youtube.com', 'https://player.vimeo.com'];
18
+ export const ALWAYS_FRAMED = ['https://www.youtube-nocookie.com', 'https://www.youtube.com', 'https://youtube.com', 'https://player.vimeo.com', 'https://www.google.com'];
19
19
 
20
20
  /** A bare hostname, or nothing: a host in embeds.json must never smuggle in a scheme, path or wildcard. */
21
21
  const HOST_RE = /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
@@ -39,7 +39,7 @@ const BLOCKS_DIR = path.resolve(__dirname_md, '../../content/blocks');
39
39
  export const BUILTIN_SHORTCODES = new Set([
40
40
  'block', 'collection', 'view', 'dconfig', 'component', 'tabs', 'tab',
41
41
  'accordion', 'item', 'carousel', 'slide', 'countdown', 'timeline',
42
- 'event', 'listgroup', 'spacer', 'center', 'icon', 'demo', 'embed', 'image', 'form', 'hero', 'table', 'badge',
42
+ 'event', 'listgroup', 'spacer', 'center', 'icon', 'demo', 'embed', 'map', 'image', 'form', 'hero', 'table', 'badge',
43
43
  'text', 'button', 'link', 'cta', 'grid', 'row', 'col', 'card', 'box',
44
44
  'banner', 'slideover', 'menu',
45
45
  // effects
@@ -2111,7 +2111,9 @@ async function processPluginShortcodes(markdown) {
2111
2111
 
2112
2112
  const {scrubbed, restore} = scrubCodeRegions(markdown);
2113
2113
  let result = scrubbed;
2114
- const context = {parseShortcodeAttrs, scrubCodeRegions, marked, processCardBlocks, processGridBlocks, escapeAttr};
2114
+ // renderMap tells a plugin with its own [map] (Blog Pro: OpenStreetMap by lat/lon) that the CMS has one too, so it can
2115
+ // hand back the tags it cannot draw (an address, a postcode) for processMapBlocks.
2116
+ const context = {parseShortcodeAttrs, scrubCodeRegions, marked, processCardBlocks, processGridBlocks, escapeAttr, renderMap};
2115
2117
 
2116
2118
  async function replaceAsync(input, regex, mapMatch) {
2117
2119
  const matches = [];
@@ -2135,13 +2137,14 @@ async function processPluginShortcodes(markdown) {
2135
2137
  // Self-closing: [name attrs /]
2136
2138
  result = await replaceAsync(
2137
2139
  result,
2138
- new RegExp(`\\[${name}([^\\]]*)\\s*\\/\\]`, 'gi'),
2140
+ // The name must end there: [map] is not [map-guess].
2141
+ new RegExp(`\\[${name}(?=[\\s/\\]])([^\\]]*)\\s*\\/\\]`, 'gi'),
2139
2142
  (_, attrStr) => handler(attrStr, null, context)
2140
2143
  );
2141
2144
  // Wrapping: [name attrs]...[/name]
2142
2145
  result = await replaceAsync(
2143
2146
  result,
2144
- new RegExp(`\\[${name}([^\\]]*)\\]([\\s\\S]*?)\\[\\/${name}\\]`, 'gi'),
2147
+ new RegExp(`\\[${name}(?=[\\s/\\]])([^\\]]*)\\]([\\s\\S]*?)\\[\\/${name}\\]`, 'gi'),
2145
2148
  (_, attrStr, body) => handler(attrStr, body, context)
2146
2149
  );
2147
2150
  }
@@ -4485,6 +4488,61 @@ function processEmbedBlocks(markdown) {
4485
4488
  ));
4486
4489
  }
4487
4490
 
4491
+ // ─── [map] - responsive Google Maps location embed ─────────────────────────
4492
+
4493
+ /** Build a safe map iframe from a location, postcode, or coordinate pin. */
4494
+ export function renderMap(attrs = {}) {
4495
+ const pin = typeof attrs.pin === 'string' ? attrs.pin.trim() : '';
4496
+ const lat = typeof attrs.lat === 'string' ? attrs.lat.trim() : '';
4497
+ const lonRaw = attrs.lon ?? attrs.lng;
4498
+ const lon = typeof lonRaw === 'string' ? lonRaw.trim() : '';
4499
+ const coordinates = pin || (lat && lon ? `${lat},${lon}` : '');
4500
+ const address = typeof attrs.address === 'string' ? attrs.address.trim() : '';
4501
+ const postcode = typeof attrs.postcode === 'string' ? attrs.postcode.trim() : '';
4502
+ const query = coordinates || address || postcode;
4503
+ if (!query || query.length > 500 || /[\u0000-\u001f]/.test(query)) {
4504
+ return _embedBlocked('Add a valid map pin, address, or postcode.');
4505
+ }
4506
+ if (coordinates && !/^[-+]?\d{1,3}(?:\.\d+)?\s*,\s*[-+]?\d{1,3}(?:\.\d+)?$/.test(coordinates)) {
4507
+ return _embedBlocked('Map pins must be latitude, longitude coordinates.');
4508
+ }
4509
+ if (coordinates) {
4510
+ const [latitude, longitude] = coordinates.split(',').map(Number);
4511
+ if (!Number.isFinite(latitude) || !Number.isFinite(longitude) || Math.abs(latitude) > 90 || Math.abs(longitude) > 180) {
4512
+ return _embedBlocked('Map pin coordinates are outside the valid range.');
4513
+ }
4514
+ }
4515
+ const parsedZoom = Number.parseInt(attrs.zoom, 10);
4516
+ const zoom = Number.isFinite(parsedZoom) ? Math.max(1, Math.min(20, parsedZoom)) : 14;
4517
+ // Use the direct embed endpoint. The /maps?q=... URL redirects here, and
4518
+ // Google marks that redirect SAMEORIGIN, which browsers can block in iframes.
4519
+ const encodedQuery = encodeURIComponent(query).replace(/%20/g, '+');
4520
+ const src = `https://www.google.com/maps/embed?origin=mfe&pb=!1m3!2m1!1s${encodedQuery}!6i${zoom}`;
4521
+ const ratio = _embedRatio(attrs.ratio);
4522
+ const titleText = String(attrs.title || address || postcode || 'Map');
4523
+ const title = escapeAttr(titleText);
4524
+ const styles = ['margin:1.5rem 0'];
4525
+ if (attrs.width) {
4526
+ const w = /^\d+%$/.test(attrs.width) ? attrs.width : `${parseInt(attrs.width, 10) || 0}px`;
4527
+ if (w !== '0px') styles.push(`max-width:${w}`);
4528
+ }
4529
+ const align = String(attrs.align || '').toLowerCase();
4530
+ if (align === 'center') styles.push('margin-left:auto', 'margin-right:auto');
4531
+ else if (align === 'right') styles.push('margin-left:auto');
4532
+ const caption = attrs.caption || attrs.title;
4533
+ return `<figure class="dm-map" style="${styles.join(';')}"><div class="dm-map-frame" style="position:relative;width:100%;aspect-ratio:${ratio}">`
4534
+ + `<iframe src="${escapeAttr(src)}" title="${title}" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"`
4535
+ + ` style="position:absolute;inset:0;width:100%;height:100%;border:0" allowfullscreen></iframe></div>`
4536
+ + (caption ? `<figcaption class="dm-embed-caption">${escapeAttr(caption)}</figcaption>` : '')
4537
+ + '</figure>';
4538
+ }
4539
+
4540
+ function processMapBlocks(markdown) {
4541
+ const {scrubbed, restore} = scrubCodeRegions(markdown);
4542
+ return restore(scrubbed.replace(/\[map(?=[\s/\]])([^\]]*?)\/?\]/gi,
4543
+ (_, attrStr) => '\n' + renderMap(parseShortcodeAttrs(attrStr || '')) + '\n'));
4544
+ }
4545
+
4488
4546
  // ─── [image] - a picture with options, optionally zoomable ─────────────────
4489
4547
 
4490
4548
  const IMAGE_ALIGNS = ['left', 'center', 'right', 'float-left', 'float-right'];
@@ -5231,7 +5289,7 @@ export function sanitizePageHtml(html) {
5231
5289
  // host allow-list).
5232
5290
  allowedIframeHostnames: [
5233
5291
  'www.youtube-nocookie.com', 'www.youtube.com', 'youtube.com',
5234
- 'player.vimeo.com',
5292
+ 'player.vimeo.com', 'www.google.com',
5235
5293
  ...getEmbedAllowedHosts(),
5236
5294
  ],
5237
5295
  // sanitize-html drops a RELATIVE iframe src whenever allowedIframeHostnames
@@ -5361,7 +5419,8 @@ export async function parseMarkdown(raw, opts = {}) {
5361
5419
  const withIcon = processIconBlocks(withCenter);
5362
5420
  const withDemo = processDemoBlocks(withIcon);
5363
5421
  const withEmbed = processImageBlocks(processEmbedBlocks(withDemo));
5364
- const withForm = await processFormBlocks(withEmbed, tagSet);
5422
+ const withMap = processMapBlocks(withEmbed);
5423
+ const withForm = await processFormBlocks(withMap, tagSet);
5365
5424
  const withHero = processHeroBlocks(withForm);
5366
5425
  const withTable = processTableBlocks(withHero);
5367
5426
  const withBadge = processBadgeBlocks(withTable);
@@ -13,7 +13,7 @@ import fs from 'fs/promises';
13
13
  import path from 'path';
14
14
 
15
15
  /** As FREQUENT_MAX in admin/js/lib/sidebar-frequent.js. */
16
- export const FREQUENT_MAX = 12;
16
+ export const FREQUENT_MAX = 16;
17
17
  const URL_MAX = 500;
18
18
  const USER_ID_RE = /^[A-Za-z0-9_-]{1,80}$/;
19
19