domma-cms 1.77.0 → 1.78.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 (106) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/admin/js/lib/site-settings-arrange.js +3 -3
  3. package/admin/js/templates/settings.html +19 -0
  4. package/admin/js/views/settings.js +3 -3
  5. package/docs/screenshots/email-branding-gallery.png +0 -0
  6. package/docs/screenshots/email-branding-waypoint.png +0 -0
  7. package/package.json +1 -1
  8. package/plugins/_lib/admin/mail/body-menu.js +1 -1
  9. package/plugins/_lib/admin/mail/cms-host.js +1 -1
  10. package/plugins/_lib/admin/mail/compose-window.js +1 -1
  11. package/plugins/_lib/admin/mail/contacts.js +1 -1
  12. package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
  13. package/plugins/_lib/admin/mail/drag-drop.js +1 -1
  14. package/plugins/_lib/admin/mail/folder-tree.js +1 -1
  15. package/plugins/_lib/admin/mail/font-controls.js +1 -1
  16. package/plugins/_lib/admin/mail/fonts.js +1 -1
  17. package/plugins/_lib/admin/mail/host-context.js +1 -1
  18. package/plugins/_lib/admin/mail/identity.js +1 -1
  19. package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
  20. package/plugins/_lib/admin/mail/keyboard.js +1 -1
  21. package/plugins/_lib/admin/mail/mail.html +1 -1
  22. package/plugins/_lib/admin/mail/message-actions.js +1 -1
  23. package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
  24. package/plugins/_lib/admin/mail/panes.js +1 -1
  25. package/plugins/_lib/admin/mail/reader-kit.js +1 -1
  26. package/plugins/_lib/admin/mail/reader-runtime.js +1 -1
  27. package/plugins/_lib/admin/mail/reader-view.js +1 -1
  28. package/plugins/_lib/admin/mail/resizable.js +1 -1
  29. package/plugins/_lib/admin/mail/restore-spam.js +1 -1
  30. package/plugins/_lib/admin/mail/rules.js +1 -1
  31. package/plugins/_lib/admin/mail/scheduling.js +1 -1
  32. package/plugins/_lib/admin/mail/section-kit.js +1 -1
  33. package/plugins/_lib/admin/mail/security-note.js +1 -1
  34. package/plugins/_lib/admin/mail/settings-section.js +1 -1
  35. package/plugins/_lib/admin/mail/templates.js +1 -1
  36. package/plugins/_lib/admin/mail/threads.js +1 -1
  37. package/plugins/_lib/admin/mail/vacation.js +1 -1
  38. package/plugins/_lib/admin/mail/when-closed.js +1 -1
  39. package/plugins/_lib/admin/ui/dates.js +1 -1
  40. package/plugins/_lib/admin/ui/resizable.js +1 -1
  41. package/plugins/_lib/admin/ui/rich-field.js +1 -1
  42. package/plugins/_lib/domma-mail.lock.json +83 -83
  43. package/plugins/_lib/mail/accountFileStore.js +1 -1
  44. package/plugins/_lib/mail/accountRepository.js +1 -1
  45. package/plugins/_lib/mail/accountRoutes.js +1 -1
  46. package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
  47. package/plugins/_lib/mail/bodyTokens.js +1 -1
  48. package/plugins/_lib/mail/compose.js +1 -1
  49. package/plugins/_lib/mail/defaults.js +1 -1
  50. package/plugins/_lib/mail/envelope.js +1 -1
  51. package/plugins/_lib/mail/folderActions.js +1 -1
  52. package/plugins/_lib/mail/folderRuntime.js +1 -1
  53. package/plugins/_lib/mail/folders.js +1 -1
  54. package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
  55. package/plugins/_lib/mail/mbox.js +1 -1
  56. package/plugins/_lib/mail/message-action.js +1 -1
  57. package/plugins/_lib/mail/messageSecurity.js +1 -1
  58. package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
  59. package/plugins/_lib/mail/networkAddresses.js +1 -1
  60. package/plugins/_lib/mail/networkPolicy.js +1 -1
  61. package/plugins/_lib/mail/oauthAccounts.js +1 -1
  62. package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
  63. package/plugins/_lib/mail/oauthRuntime.js +1 -1
  64. package/plugins/_lib/mail/pollSchedule.js +1 -1
  65. package/plugins/_lib/mail/poller.js +1 -1
  66. package/plugins/_lib/mail/pollerRuntime.js +1 -1
  67. package/plugins/_lib/mail/priority.js +1 -1
  68. package/plugins/_lib/mail/publicMailbox.js +1 -1
  69. package/plugins/_lib/mail/readRuntime.js +1 -1
  70. package/plugins/_lib/mail/render.js +1 -1
  71. package/plugins/_lib/mail/ruleRunner.js +1 -1
  72. package/plugins/_lib/mail/schedulerRuntime.js +1 -1
  73. package/plugins/_lib/mail/secretProvider.js +1 -1
  74. package/plugins/_lib/mail/secretbox.js +1 -1
  75. package/plugins/_lib/mail/senderAuth.js +1 -1
  76. package/plugins/_lib/mail/sieve.js +1 -1
  77. package/plugins/_lib/mail/smtpService.js +1 -1
  78. package/plugins/_lib/mail/snoozeRuntime.js +1 -1
  79. package/plugins/_lib/mail/store.js +1 -1
  80. package/plugins/_lib/mail/subscriptions.js +1 -1
  81. package/plugins/_lib/mail/syncPlan.js +1 -1
  82. package/plugins/_lib/mail/syncRuntime.js +1 -1
  83. package/plugins/_lib/mail/syncSelection.js +1 -1
  84. package/plugins/_lib/mail/unreadBadge.js +1 -1
  85. package/plugins/_lib/mail/unsubscribe.js +1 -1
  86. package/plugins/_lib/mail/vacationRunner.js +14 -2
  87. package/plugins/_lib/mail/vacationRuntime.js +23 -5
  88. package/plugins/_lib/mail/write.js +1 -1
  89. package/plugins/_lib/outreach/sending.js +3 -1
  90. package/plugins/_lib/public/rich-text.mjs +1 -1
  91. package/plugins/_lib/rich-text.js +1 -1
  92. package/plugins/docs/CHANGELOG.md +5 -0
  93. package/plugins/docs/plugin.js +2 -2
  94. package/plugins/free-tier.lock.json +7 -7
  95. package/plugins/shopping-cart/CHANGELOG.md +5 -0
  96. package/plugins/shopping-cart/lib/accounts.js +1 -1
  97. package/plugins/support/CHANGELOG.md +5 -0
  98. package/plugins/support/lib/mail.js +2 -2
  99. package/server/routes/api/settings.js +28 -7
  100. package/server/services/actions.js +2 -1
  101. package/server/services/callInvites.js +1 -1
  102. package/server/services/email.js +10 -4
  103. package/server/services/emailBrand.js +126 -0
  104. package/server/services/emailExamples.js +37 -0
  105. package/server/services/instantCalls.js +1 -1
  106. package/server/services/passwordReset.js +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.78.0] - 2026-11-19
4
+
5
+ ### Added
6
+
7
+ - Shared site-branded automated emails with public identity inheritance, email-specific name/logo/colour/support/footer overrides, reusable detail and action blocks, and complete plain-text versions.
8
+ - Email families for the Manager's own mail: `gift`, `offer` and `licence`.
9
+ - Settings > SMTP includes a sample gallery and branded test sends for account invitations, Waypoint updates, bookings, orders, reports and campaigns.
10
+ - **Away replies in your Email branding** (Domma Mail core 0.35.0). With Email Pro, an automatic away reply goes out in the mailbox's brand (a rule for the sender, else the mailbox's identity brand, else the default), in the compact reply form. Without Email Pro, or if branding fails, it goes out plain as before. Mail engine: the shared responder's new `brand` hook (domma-mail core, unreleased).
11
+
12
+ ### Changed
13
+
14
+ - Account, form, call and automation emails and the bundled Docs, Support and Shop account emails opt into the shared presentation. Personal email remains unchanged.
15
+ - Outreach layouts retain custom content, recipient links and unsubscribe controls. Site logos in SVG format fall back to a text brand; a separate raster email logo can be selected.
16
+
3
17
  ## [1.77.0] - 2026-11-19
4
18
 
5
19
  ### Added
@@ -1,3 +1,3 @@
1
- export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass","charactersEnabled","charactersAnimated","charactersLaunchers","charactersChats","charactersBuilders","charactersDot","charactersDaisy","mapLookups"],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 b=["system","off","on"],i=(t,r,a,o)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?Math.min(o,Math.max(a,n)):r};export function motionFromSettings(t={}){const r=t.motion&&typeof t.motion=="object"?t.motion:{},a=t.footer||{},o=m=>r[m]!==void 0&&r[m]!==null,n=o("default")?r.default:a.motionDefault,s=o("control")?r.control:a.motionControl,l=i(r.iconSize,52,32,96);return{mtEnabled:(o("enabled")?r.enabled:a.showMotionToggle)!==!1,mtLabel:typeof r.label=="string"&&r.label.trim()?r.label.trim():MOTION_LABEL,mtDefault:b.includes(n)?n:"system",mtControl:s==="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(i(r.offsetX,32,0,500)),mtOffsetY:e(i(r.offsetY,32,0,500)),mtIconSize:e(l),mtIconRadius:e(i(r.iconRadius,26,0,Math.floor(l/2))),mtClass:e(r.class)}}export function motionFromForm(t){const r=i(t.mtIconSize,52,32,96);return{enabled:t.mtEnabled===!0,default:b.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:i(t.mtOffsetX,32,0,500),offsetY:i(t.mtOffsetY,32,0,500),iconSize:r,iconRadius:i(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:)/,h=/^#[0-9a-f]{6}$/i;export function footerShowcaseErrors(t){const r=[],a=e(t.footerCtaUrl).trim();a&&!p.test(a)&&r.push("The footer call to action link must start with /, #, https:// or mailto: (Footer tool).");for(const[o,n]of[["from",t.footerGradFrom],["to",t.footerGradTo]]){const s=e(n).trim();s&&!h.test(s)&&r.push(`The footer gradient "${o}" colour must look like #f26b3a (Footer tool).`)}return r}const e=(t,r="")=>t==null?r:String(t),c=(t,r)=>{const a=Number.parseInt(t,10);return Number.isFinite(a)?a:r};export function homeValue(t){return/^\/[A-Za-z0-9\-_/]*$/.test(t||"")&&String(t).replace(/\/+$/,"")||"/"}export function formFromSettings(t={}){const r=t.backToTop||{},a=t.goToBottom||{},o=t.cookieConsent||{},n=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),charactersEnabled:t.characters?.enabled!==!1,charactersAnimated:t.characters?.animated!==!1,charactersLaunchers:t.characters?.launchers!==!1,charactersChats:t.characters?.chats!==!1,charactersBuilders:t.characters?.builders!==!1,charactersDot:t.characters?.dot!==!1,charactersDaisy:t.characters?.daisy!==!1,mapLookups:t.maps?.lookupAddresses===!0,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(s=>typeof s=="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(s=>typeof s=="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:a.enabled===!0,gtbSmooth:a.smooth!==!1,gtbLabel:e(a.label),gtbThreshold:e(a.scrollThreshold??300),gtbPosition:e(a.position,"bottom-right"),gtbOffset:e(a.offset??32),gtbBottomOffset:e(a.bottomOffset??a.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:n.enabled===!0,bcHomeLabel:e(n.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(n.position)?n.position:"TL",bcOffsetX:e(n.offsetX??8),bcOffsetY:e(n.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,r={},{adminHomeReady:a=!0}={}){const o=s=>e(s).trim(),n=motionFromForm(t);return{title:o(t.title),tagline:o(t.tagline),baseUrl:o(t.siteUrl).replace(/\/+$/,""),...a&&{adminHome:o(t.adminHome)||"/"},layoutOptions:{spacerSize:c(t.spacerSize,40)||40},bodyClass:o(t.bodyClass),characters:{enabled:t.charactersEnabled!==!1,animated:t.charactersAnimated!==!1,launchers:t.charactersLaunchers!==!1,chats:t.charactersChats!==!1,builders:t.charactersBuilders!==!1,dot:t.charactersDot!==!1,daisy:t.charactersDaisy!==!1},maps:{lookupAddresses:t.mapLookups===!0},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:n.enabled,motionDefault:n.default,motionControl:n.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
- `).map(s=>s.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:c(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:c(t.bttThreshold,300),position:e(t.bttPosition)||"bottom-right",offset:c(t.bttOffset,32),bottomOffset:c(t.bttBottomOffset,32),label:o(t.bttLabel),smooth:t.bttSmooth===!0},goToBottom:{enabled:t.gtbEnabled===!0,scrollThreshold:c(t.gtbThreshold,300),position:e(t.gtbPosition)||"bottom-right",offset:c(t.gtbOffset,32),bottomOffset:c(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:c(t.bcOffsetX,8),offsetY:c(t.bcOffsetY,8)},motion:n}}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 d=t=>typeof t=="boolean"?t:e(t);export function snapshot(t){return JSON.stringify(Object.keys(t).sort().map(r=>[r,d(t[r])]))}export function changedTabs(t,r){const a=[];for(const[o,n]of Object.entries(TAB_FIELDS))n.some(s=>d(t[s])!==d(r[s]))&&a.push(o);return a}export function draftOf(t){return Object.fromEntries(Object.entries(t).filter(([r])=>!SECRET_FIELDS.includes(r)))}const g={footerMotionToggle:"mtEnabled",footerMotionDefault:"mtDefault",footerMotionControl:"mtControl"};export function formFromDraft(t,r={}){const a={...r};for(const[n,s]of Object.entries(g))n in a&&!(s in a)&&(a[s]=a[n]),delete a[n];const o={...t};for(const[n,s]of Object.entries(a))n in o&&!SECRET_FIELDS.includes(n)&&(o[n]=s);return o}export function settingsProblems(t,r={}){const a=[];return e(t.smtpHost).trim()?e(t.smtpFromAddress).trim()||a.push({tone:"warn",tab:"email",text:"No From address - mail has no sender and many servers refuse it."}):a.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()&&a.push({tone:"warn",tab:"cookies",text:"The cookie banner is on but links to no privacy policy."}),a}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 a=t-r;return a<=0?"expired":a<6e4?`${Math.round(a/1e3)}s`:a<36e5?`${Math.round(a/6e4)}m`:`${Math.round(a/36e5)}h`}export function footerForm(t={}){const r=formFromSettings(t);return Object.fromEntries(TAB_FIELDS.footer.map(a=>[a,r[a]]))}export function footerPayload(t){const{footer:r,social:a}=payloadFromForm(t);return delete r.links,delete r.showMotionToggle,delete r.motionDefault,delete r.motionControl,{footer:r,social:a}}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:a,favicon:o,backToTop:n,goToBottom:s,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(a=>[a,r[a]]))}export function appearancePayload(t){const{favicon:r,backToTop:a,goToBottom:o,breadcrumbs:n,motion:s}=payloadFromForm(t);return{favicon:r,backToTop:a,goToBottom:o,breadcrumbs:n,motion:s}}
1
+ export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass","charactersEnabled","charactersAnimated","charactersLaunchers","charactersChats","charactersBuilders","charactersDot","charactersDaisy","mapLookups"],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:["emailBrandName","emailBrandLogo","emailBrandAccent","emailBrandSupport","emailBrandFooter","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 b=["system","off","on"],c=(t,r,a,o)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?Math.min(o,Math.max(a,n)):r};export function motionFromSettings(t={}){const r=t.motion&&typeof t.motion=="object"?t.motion:{},a=t.footer||{},o=m=>r[m]!==void 0&&r[m]!==null,n=o("default")?r.default:a.motionDefault,s=o("control")?r.control:a.motionControl,l=c(r.iconSize,52,32,96);return{mtEnabled:(o("enabled")?r.enabled:a.showMotionToggle)!==!1,mtLabel:typeof r.label=="string"&&r.label.trim()?r.label.trim():MOTION_LABEL,mtDefault:b.includes(n)?n:"system",mtControl:s==="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:b.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:)/,h=/^#[0-9a-f]{6}$/i;export function footerShowcaseErrors(t){const r=[],a=e(t.footerCtaUrl).trim();a&&!p.test(a)&&r.push("The footer call to action link must start with /, #, https:// or mailto: (Footer tool).");for(const[o,n]of[["from",t.footerGradFrom],["to",t.footerGradTo]]){const s=e(n).trim();s&&!h.test(s)&&r.push(`The footer gradient "${o}" colour must look like #f26b3a (Footer tool).`)}return r}const e=(t,r="")=>t==null?r:String(t),i=(t,r)=>{const a=Number.parseInt(t,10);return Number.isFinite(a)?a:r};export function homeValue(t){return/^\/[A-Za-z0-9\-_/]*$/.test(t||"")&&String(t).replace(/\/+$/,"")||"/"}export function formFromSettings(t={}){const r=t.backToTop||{},a=t.goToBottom||{},o=t.cookieConsent||{},n=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),charactersEnabled:t.characters?.enabled!==!1,charactersAnimated:t.characters?.animated!==!1,charactersLaunchers:t.characters?.launchers!==!1,charactersChats:t.characters?.chats!==!1,charactersBuilders:t.characters?.builders!==!1,charactersDot:t.characters?.dot!==!1,charactersDaisy:t.characters?.daisy!==!1,mapLookups:t.maps?.lookupAddresses===!0,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(s=>typeof s=="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(s=>typeof s=="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),emailBrandName:e(t.emailBrand?.name),emailBrandLogo:e(t.emailBrand?.logo),emailBrandAccent:e(t.emailBrand?.accent),emailBrandSupport:e(t.emailBrand?.supportEmail),emailBrandFooter:e(t.emailBrand?.footer),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:a.enabled===!0,gtbSmooth:a.smooth!==!1,gtbLabel:e(a.label),gtbThreshold:e(a.scrollThreshold??300),gtbPosition:e(a.position,"bottom-right"),gtbOffset:e(a.offset??32),gtbBottomOffset:e(a.bottomOffset??a.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:n.enabled===!0,bcHomeLabel:e(n.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(n.position)?n.position:"TL",bcOffsetX:e(n.offsetX??8),bcOffsetY:e(n.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,r={},{adminHomeReady:a=!0}={}){const o=s=>e(s).trim(),n=motionFromForm(t);return{title:o(t.title),tagline:o(t.tagline),baseUrl:o(t.siteUrl).replace(/\/+$/,""),...a&&{adminHome:o(t.adminHome)||"/"},layoutOptions:{spacerSize:i(t.spacerSize,40)||40},bodyClass:o(t.bodyClass),characters:{enabled:t.charactersEnabled!==!1,animated:t.charactersAnimated!==!1,launchers:t.charactersLaunchers!==!1,chats:t.charactersChats!==!1,builders:t.charactersBuilders!==!1,dot:t.charactersDot!==!1,daisy:t.charactersDaisy!==!1},maps:{lookupAddresses:t.mapLookups===!0},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:n.enabled,motionDefault:n.default,motionControl:n.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
+ `).map(s=>s.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)},emailBrand:{...r.emailBrand,name:o(t.emailBrandName),logo:o(t.emailBrandLogo),accent:o(t.emailBrandAccent),supportEmail:o(t.emailBrandSupport),footer:o(t.emailBrandFooter)},smtp:{host:o(t.smtpHost),port:i(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:i(t.bttThreshold,300),position:e(t.bttPosition)||"bottom-right",offset:i(t.bttOffset,32),bottomOffset:i(t.bttBottomOffset,32),label:o(t.bttLabel),smooth:t.bttSmooth===!0},goToBottom:{enabled:t.gtbEnabled===!0,scrollThreshold:i(t.gtbThreshold,300),position:e(t.gtbPosition)||"bottom-right",offset:i(t.gtbOffset,32),bottomOffset:i(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:i(t.bcOffsetX,8),offsetY:i(t.bcOffsetY,8)},motion:n}}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 d=t=>typeof t=="boolean"?t:e(t);export function snapshot(t){return JSON.stringify(Object.keys(t).sort().map(r=>[r,d(t[r])]))}export function changedTabs(t,r){const a=[];for(const[o,n]of Object.entries(TAB_FIELDS))n.some(s=>d(t[s])!==d(r[s]))&&a.push(o);return a}export function draftOf(t){return Object.fromEntries(Object.entries(t).filter(([r])=>!SECRET_FIELDS.includes(r)))}const g={footerMotionToggle:"mtEnabled",footerMotionDefault:"mtDefault",footerMotionControl:"mtControl"};export function formFromDraft(t,r={}){const a={...r};for(const[n,s]of Object.entries(g))n in a&&!(s in a)&&(a[s]=a[n]),delete a[n];const o={...t};for(const[n,s]of Object.entries(a))n in o&&!SECRET_FIELDS.includes(n)&&(o[n]=s);return o}export function settingsProblems(t,r={}){const a=[];return e(t.smtpHost).trim()?e(t.smtpFromAddress).trim()||a.push({tone:"warn",tab:"email",text:"No From address - mail has no sender and many servers refuse it."}):a.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()&&a.push({tone:"warn",tab:"cookies",text:"The cookie banner is on but links to no privacy policy."}),a}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 a=t-r;return a<=0?"expired":a<6e4?`${Math.round(a/1e3)}s`:a<36e5?`${Math.round(a/6e4)}m`:`${Math.round(a/36e5)}h`}export function footerForm(t={}){const r=formFromSettings(t);return Object.fromEntries(TAB_FIELDS.footer.map(a=>[a,r[a]]))}export function footerPayload(t){const{footer:r,social:a}=payloadFromForm(t);return delete r.links,delete r.showMotionToggle,delete r.motionDefault,delete r.motionControl,{footer:r,social:a}}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:a,favicon:o,backToTop:n,goToBottom:s,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(a=>[a,r[a]]))}export function appearancePayload(t){const{favicon:r,backToTop:a,goToBottom:o,breadcrumbs:n,motion:s}=payloadFromForm(t);return{favicon:r,backToTop:a,goToBottom:o,breadcrumbs:n,motion:s}}
@@ -166,6 +166,25 @@
166
166
 
167
167
  <!-- SMTP -->
168
168
  <div class="tab-panel">
169
+ <div class="stx-card dm-settings-section">
170
+ <div class="stx-card-title dm-settings-section-title">Email identity</div>
171
+ <p class="text-muted">Automated emails inherit your public site name and logo. Use a PNG or JPEG logo for email; SVG site marks fall back to the brand name. Set overrides below when your email identity differs. Save before sending a test.</p>
172
+ <div class="stx-grid">
173
+ <div><label class="form-label" for="stx-email-brand-name">Email brand name</label><input id="stx-email-brand-name" class="form-input" data-model="emailBrandName.value" placeholder="Inherit site name"></div>
174
+ <div><label class="form-label" for="stx-email-brand-logo">Email logo</label><input id="stx-email-brand-logo" class="form-input" data-model="emailBrandLogo.value" placeholder="Inherit site logo"><button type="button" class="btn btn-sm btn-ghost" data-on-click="pickBrandImage('emailBrandLogo')">Choose image</button><button type="button" class="btn btn-sm btn-ghost" data-on-click="clearBrandImage('emailBrandLogo')">Use site logo</button></div>
175
+ <div><label class="form-label" for="stx-email-accent">Accent colour</label><input id="stx-email-accent" class="form-input" data-model="emailBrandAccent.value" placeholder="#2563eb" pattern="#[0-9a-fA-F]{6}"></div>
176
+ <div><label class="form-label" for="stx-email-support">Support email</label><input id="stx-email-support" type="email" class="form-input" data-model="emailBrandSupport.value" placeholder="Inherit site contact email"></div>
177
+ <div class="stx-wide"><label class="form-label" for="stx-email-footer">Email footer</label><textarea id="stx-email-footer" class="form-input" rows="2" maxlength="600" data-model="emailBrandFooter.value" placeholder="Your business contact details or a short sign-off"></textarea></div>
178
+ </div>
179
+ </div>
180
+ <div class="stx-card dm-settings-section">
181
+ <div class="stx-card-title dm-settings-section-title">Email preview gallery</div>
182
+ <p class="text-muted">Preview the shared layouts with sample data and your current email identity. Previewing sends nothing.</p>
183
+ <div class="stx-inline"><label for="stx-email-example">Example</label><select id="stx-email-example" class="form-select"><option value="test">SMTP and branding check</option><option value="account">Account invitation</option><option value="waypoint">Waypoint update</option><option value="booking">Booking confirmation</option><option value="shop">Order confirmation</option><option value="report">Digest and report</option><option value="campaign">Campaign and invitation</option></select><button type="button" class="btn btn-sm btn-outline" data-on-click="previewEmail">Preview</button></div>
184
+ <iframe id="stx-email-preview" title="Email layout preview" sandbox="" referrerpolicy="no-referrer" hidden style="width:100%;height:720px;border:1px solid #cbd5e1;border-radius:8px;margin-top:16px;background:#edf1f6;"></iframe>
185
+ <details><summary>Plain-text version</summary><pre id="stx-email-preview-text" style="white-space:pre-wrap;"></pre></details>
186
+ </div>
187
+
169
188
  <!-- Without a host the CMS falls back to an Ethereal test inbox, which ACCEPTS the mail and reports
170
189
  success - so nothing anywhere else looks wrong. Follows the field, not only the saved value. -->
171
190
  <p class="stx-alert is-warn" data-bind-hidden="!noSmtp.value">
@@ -1,11 +1,11 @@
1
- import{api as $,apiRequest as g}from"../api.js";import{placeTools as Re,WITHHELD_URL as Ie}from"../lib/sidebar-grouping.js";import{addBannerAction as fe}from"../lib/plugin-chrome.js";import{helpPopovers as Ae}from"../lib/help-popover.js";import{openMenuAt as G,sidebarCount as he}from"../lib/tool-kit.js";import{changedTabs as De,describeCacheKey as J,draftOf as He,expiresIn as Pe,formFromDraft as $e,siteSettingsForm as Be,homeValue as je,siteSettingsPayload as Ue,siteUrlError as ve,settingsProblems as qe,snapshot as be,TAB_FIELDS as _e}from"../lib/site-settings-arrange.js";import{pickMedia as Ke}from"../lib/media-picker.js";import{makeIconInput as Fe}from"../lib/shortcode-modal.js";import{fmtDateTime as We}from"../lib/dates.js";const Q=/^\/settings(\?.*)?$/,ge="#/settings",y="settings.draft",ze=`
1
+ import{api as P,apiRequest as v}from"../api.js";import{placeTools as qe,WITHHELD_URL as Be}from"../lib/sidebar-grouping.js";import{addBannerAction as he}from"../lib/plugin-chrome.js";import{helpPopovers as Pe}from"../lib/help-popover.js";import{openMenuAt as G,sidebarCount as ve}from"../lib/tool-kit.js";import{changedTabs as De,describeCacheKey as Q,draftOf as He,expiresIn as $e,formFromDraft as je,siteSettingsForm as Ue,homeValue as _e,siteSettingsPayload as be,siteUrlError as ye,settingsProblems as Ke,snapshot as ge,TAB_FIELDS as Fe}from"../lib/site-settings-arrange.js";import{pickMedia as We}from"../lib/media-picker.js";import{makeIconInput as Ne}from"../lib/shortcode-modal.js";import{fmtDateTime as ze}from"../lib/dates.js";const X=/^\/settings(\?.*)?$/,we="#/settings",g="settings.draft",Ve=`
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>
5
5
  <button type="button" class="btn btn-sm btn-ghost" data-go="{{tab}}">Go there</button>
6
- </div>`,Ne=`
6
+ </div>`,Ye=`
7
7
  <div class="stx-row" data-id="{{id}}" tabindex="0">
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>`,B=["general","branding","email","cookies","cache"];async function Ve(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=(p,u)=>{for(const o of p||[]){if(!o||o.hidden||o.restricted)continue;const a=typeof o.url=="string"?o.url:"";a.startsWith(Ie)||(a.startsWith("#/")&&a.length>2&&!n.has(a.slice(1))&&n.set(a.slice(1),`${u?`${u} \u203A `:""}${o.text||a}`),i(o.items,o.url?u:o.text||u))}},k=(w||[]).filter(p=>!/^~\d+$/.test(String(p?.item?.text||"")));i(Re(r?.items||[],k),""),n.has(l)||n.set(l,`${l} (not in the sidebar)`),c.replaceChildren();for(const[p,u]of n){const o=document.createElement("option");o.value=p,o.textContent=u,c.appendChild(o)}}let f=null,ye=!1;function Ye(){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(Ye(),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,k=E.loader(c.get(0),{type:"dots"});let p;try{p=await $.settings.get()}catch(e){k.destroy(),E.toast(`Could not load the settings: ${e.message||e}`,{type:"error"});return}if(k.destroy(),!n.isConnected)return;const u=M.observable(p||{}),o=Be(p||{}),a={};for(const[e,t]of Object.entries(o))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()])),v=M.observable(o),U=M.computed(()=>be(v.value)),x=M.computed(()=>be(j())!==U.value),C=M.observable(!1),T=M.observable(""),Z=M.observable(!1);$.plugins.policy().then(e=>{i()&&(Z.value=e?.signedOnly===!1)}).catch(()=>{});const q=M.observable(!1),ee=M.computed(()=>{const e=new Set(De(j(),v.value));return Object.fromEntries(Object.keys(_e).map(t=>[t,e.has(t)]))}),_=M.observable([]);r(M.effect(()=>{_.value=qe(j(),u.value).map(e=>({...e,label:e.tone==="danger"?"Mail":"Check"}))}));const te=M.observable(""),L=M.observable(!1),O=M.observable(""),A=M.observable(""),m=M.observable(null),K=M.observable([]),F=M.observable(""),W=M.observable(!0),z=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 ae=M.observable(!1);g("/ai-assist").catch(()=>null).then(e=>{i()&&(ae.value=e?.on===!0)});const we={...a,saving:C,dirty:x,tabs:ee,problems:_,testTo:te,testing:L,testResult:O,testTone:A,aiAssistOn:ae,cacheQuery:F,cacheLoading:W,cacheError:z,cacheRows:se,errorText:T,problemsText:M.computed(()=>_.value.length?"yes":""),siteUrlError:M.computed(()=>ve(a.siteUrl.value)),noSmtp:M.computed(()=>!String(a.smtpHost.value||"").trim()),mayAllowInsecureTLS:Z,dirtyEmail:M.computed(()=>ee.value.email),cacheOn:M.computed(()=>m.value?.enabled===!0),cacheState:M.computed(()=>{const e=m.value;return e?e.enabled?`On (${e.driver})`:"Off":"Status unknown"}),cacheSize:M.computed(()=>{const e=m.value;return e?.enabled&&e.size!==null&&e.size!==void 0?`${e.size}${e.maxItems?` of ${e.maxItems}`:""} entries`:""}),cacheHits:M.computed(()=>{const e=m.value?.hitRate;return e==null?"":`${Math.round(e*100)}% served from the cache`}),cacheToggleText:M.computed(()=>m.value?.enabled?"Turn off":"Turn on"),cacheEmpty:M.computed(()=>F.value.trim()?"Nothing matches.":m.value?.enabled?"The cache is empty - pages are cached as visitors open them.":"The cache is off.")};async function N(){if(C.peek())return;const e=X(),t=v.peek(),s=ve(e.siteUrl);if(s){E.toast(`Site URL: ${s}`,{type:"error"});return}C.value=!0,T.value="";const d=String(e.title).trim()!==String(t.title).trim();try{await $.settings.save(Ue(e,u.peek(),{adminHomeReady:q.peek()})),window.dispatchEvent(new Event("admin-assistant:settings"));const P=await $.settings.get().catch(()=>null);if(!i())return;P&&(u.value=P);const Oe={...e,smtpPass:""};a.smtpPass.value="",v.value=Oe;try{S.remove?S.remove(y):S.set(y,null)}catch{}document.dispatchEvent(new CustomEvent("dm:admin-home-changed")),(d||["adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"].some(me=>e[me]!==t[me]))&&document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild")),he(ge),E.toast("Settings saved.",{type:"success"})}catch(P){T.value=P.message||"Could not save the settings.",E.toast("Settings not saved - see the message at the top.",{type:"error"})}finally{C.value=!1}}async function ke(){await E.confirm("Throw away your unsaved settings?")&&(ne(v.peek()),T.value="")}function ne(e){for(const[t,s]of Object.entries(e))a[t]&&(a[t].value=s)}async function Ee(){if(!L.peek()){L.value=!0,A.value="",O.value="Sending\u2026";try{const e=await g("/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 D(){W.value=!0;try{const[e,t]=await Promise.all([g("/cache/status").catch(()=>null),g("/cache/keys")]);if(!i())return;m.value=e,K.value=Array.isArray(t?.entries)?t.entries:[],z.value=""}catch(e){if(!i())return;z.value=`Could not read the cache: ${e.message||e}`}finally{W.value=!1}}async function Se(){if(await E.confirm("Clear the whole response cache? The next visitor to each page renders it afresh.")){try{await g("/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 D()}}async function Me(){const e=m.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{m.value=await g("/cache/toggle",{method:"POST",body:JSON.stringify({enabled:!e})}),E.toast(e?"Cache turned off.":"Cache turned on.",{type:"success"}),he(ge)}catch(t){E.toast(t.message||"Could not change the cache.",{type:"error"})}i()&&await D()}}const oe=e=>K.peek().find(t=>t.key===e);function xe(e){const t=oe(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=ze;const b=n.querySelector(".stx-list");b.innerHTML=Ne;const V=E.tabs(n.querySelector(".stx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),re=new URLSearchParams(location.hash.split("?")[1]||"").get("tab");B.includes(re)&&V.activate(B.indexOf(re));const Ce=M.applyBindings(we,n,{methods:{save:N,discard:ke,sendTest:Ee,refreshCache:D,clearCache:Se,toggleCache:Me,pickBrandImage:async e=>{const t=await Ke({title:"Choose a branding image",current:a[e].peek()});t&&i()&&(a[e].value=t)},clearBrandImage:e=>{a[e].value=""},goTab:e=>{const t=B.indexOf(e);t>=0&&V.activate(t)}}});r(()=>Ce.dispose());for(const e of n.querySelectorAll("[data-brand-icon]")){const t=e.dataset.brandIcon,s=Fe("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(Ae(n,{position:"bottom"}));const Te=e=>{const t=e.target.closest("[data-go]");if(!t)return;const s=B.indexOf(t.dataset.go);s>=0&&V.activate(s)};n.querySelector(".stx-problems").addEventListener("click",Te);const Y=n.querySelector("#stx-admin-home");Ve(Y,je(a.adminHome.peek())).then(()=>{i()&&(Y.value=a.adminHome.peek(),q.value=!0)}).catch(()=>{});const Le=E.contextMenu(b,{cursor:"glyph",match:".stx-row",inherit:!1,density:"compact",items:e=>xe(e.dataset.id)});r(()=>Le?.destroy?.());const ie=e=>{const t=oe(e.dataset.id),s=t&&J(t.key);s?.page?window.open(s.path,"_blank","noopener"):G(e)},ce=e=>{const t=e.target.closest(".stx-row");if(!t)return;const s=e.target.closest(".stx-kebab");if(s){G(s);return}ie(t)},le=e=>{const t=e.target.closest(".stx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),G(t)):e.key==="Enter"&&e.target===t&&ie(t))};b.addEventListener("click",ce),b.addEventListener("keydown",le),r(()=>{b.removeEventListener("click",ce),b.removeEventListener("keydown",le)}),fe(c,{id:"settings-view-site",icon:"external-link",title:"View site",onClick:()=>window.open("/","_blank","noopener")}),fe(c,{id:"settings-save",icon:"save",title:"Save (Ctrl+S)",onClick:()=>N()});const ue=e=>{!(e.ctrlKey||e.metaKey)||e.key!=="s"||(e.preventDefault(),e.stopImmediatePropagation(),N())};document.addEventListener("keydown",ue,!0),r(()=>document.removeEventListener("keydown",ue,!0));const de=()=>{if(x.peek())try{S.set(y,{form:He(X()),base:U.peek(),at:new Date().toISOString()})}catch{}},pe=e=>{x.peek()&&(de(),e.preventDefault(),e.returnValue="")};window.addEventListener("beforeunload",pe),r(()=>window.removeEventListener("beforeunload",pe)),f={dirty:()=>x.peek(),dispose(){w=!0,de(),l.splice(0).reverse().forEach(e=>{try{e()}catch{}})}},I.scan(n),D();let h=null;try{h=S.get(y)}catch{}if(h?.form){try{S.remove?S.remove(y):S.set(y,null)}catch{}const e=h.base&&h.base!==U.peek(),t=h.at?` (${We(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()&&(ne($e(v.peek(),h.form)),q.peek()&&(Y.value=a.adminHome.peek()))}}};
11
+ </div>`,D=["general","branding","email","cookies","cache"];async function Je(l,d){const[i,w]=await Promise.all([H.get("/api/sidebar/menu").catch(()=>({items:[]})),H.get("/api/sidebar/registered-items").catch(()=>[])]),n=new Map([["/","Dashboard (built in)"]]),o=(p,u)=>{for(const r of p||[]){if(!r||r.hidden||r.restricted)continue;const s=typeof r.url=="string"?r.url:"";s.startsWith(Be)||(s.startsWith("#/")&&s.length>2&&!n.has(s.slice(1))&&n.set(s.slice(1),`${u?`${u} \u203A `:""}${r.text||s}`),o(r.items,r.url?u:r.text||u))}},k=(w||[]).filter(p=>!/^~\d+$/.test(String(p?.item?.text||"")));o(qe(i?.items||[],k),""),n.has(d)||n.set(d,`${d} (not in the sidebar)`),l.replaceChildren();for(const[p,u]of n){const r=document.createElement("option");r.value=p,r.textContent=u,l.appendChild(r)}}let f=null,ke=!1;function Ge(){ke||!window.R?.use||(ke=!0,R.use((l,d,i)=>!(X.test(d?.path||"")&&!X.test(l?.path||""))||!f?.dirty()?i():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?i():history.replaceState(null,"","#/settings")})),M.subscribe("router:afterChange",({to:l}={})=>{if(f&&!X.test(l?.path||"")){const d=f;f=null,d.dispose()}}))}export const settingsView={templateUrl:"/admin/js/templates/settings.html",async onMount(l){if(Ge(),f){const e=f;f=null,e.dispose()}const d=[],i=e=>(d.push(e),e);let w=!1;const n=l.get(0).querySelector(".stx")||l.get(0),o=()=>!w&&n.isConnected,k=E.loader(l.get(0),{type:"dots"});let p;try{p=await P.settings.get()}catch(e){k.destroy(),E.toast(`Could not load the settings: ${e.message||e}`,{type:"error"});return}if(k.destroy(),!n.isConnected)return;const u=M.observable(p||{}),r=Ue(p||{}),s={};for(const[e,t]of Object.entries(r))s[e]=M.observable(t);const $=()=>Object.fromEntries(Object.keys(s).map(e=>[e,s[e].value])),j=()=>Object.fromEntries(Object.keys(s).map(e=>[e,s[e].peek()])),b=M.observable(r),U=M.computed(()=>ge(b.value)),x=M.computed(()=>ge($())!==U.value),C=M.observable(!1),T=M.observable(""),Z=M.observable(!1);P.plugins.policy().then(e=>{o()&&(Z.value=e?.signedOnly===!1)}).catch(()=>{});const _=M.observable(!1),ee=M.computed(()=>{const e=new Set(De($(),b.value));return Object.fromEntries(Object.keys(Fe).map(t=>[t,e.has(t)]))}),K=M.observable([]);i(M.effect(()=>{K.value=Ke($(),u.value).map(e=>({...e,label:e.tone==="danger"?"Mail":"Check"}))}));const te=M.observable(""),O=M.observable(!1),L=M.observable(""),A=M.observable(""),m=M.observable(null),F=M.observable([]),W=M.observable(""),N=M.observable(!0),z=M.observable(""),ae=M.observable([]);i(M.effect(()=>{const e=W.value.trim().toLowerCase(),t=Date.now();ae.value=[...F.value].reverse().filter(a=>!e||String(a.key).toLowerCase().includes(e)||(a.tags||[]).some(c=>String(c).toLowerCase().includes(e))).map(a=>{const c=Q(a.key);return{id:a.key,path:c.path,meta:[c.page?`as ${c.role}`:"not a page",(a.tags||[]).join(", ")].filter(Boolean).join(" \xB7 "),expires:$e(a.expiresAt,t)}})}));const se=M.observable(!1);v("/ai-assist").catch(()=>null).then(e=>{o()&&(se.value=e?.on===!0)});const Ee={...s,saving:C,dirty:x,tabs:ee,problems:K,testTo:te,testing:O,testResult:L,testTone:A,aiAssistOn:se,cacheQuery:W,cacheLoading:N,cacheError:z,cacheRows:ae,errorText:T,problemsText:M.computed(()=>K.value.length?"yes":""),siteUrlError:M.computed(()=>ye(s.siteUrl.value)),noSmtp:M.computed(()=>!String(s.smtpHost.value||"").trim()),mayAllowInsecureTLS:Z,dirtyEmail:M.computed(()=>ee.value.email),cacheOn:M.computed(()=>m.value?.enabled===!0),cacheState:M.computed(()=>{const e=m.value;return e?e.enabled?`On (${e.driver})`:"Off":"Status unknown"}),cacheSize:M.computed(()=>{const e=m.value;return e?.enabled&&e.size!==null&&e.size!==void 0?`${e.size}${e.maxItems?` of ${e.maxItems}`:""} entries`:""}),cacheHits:M.computed(()=>{const e=m.value?.hitRate;return e==null?"":`${Math.round(e*100)}% served from the cache`}),cacheToggleText:M.computed(()=>m.value?.enabled?"Turn off":"Turn on"),cacheEmpty:M.computed(()=>W.value.trim()?"Nothing matches.":m.value?.enabled?"The cache is empty - pages are cached as visitors open them.":"The cache is off.")};async function V(){if(C.peek())return;const e=j(),t=b.peek(),a=ye(e.siteUrl);if(a){E.toast(`Site URL: ${a}`,{type:"error"});return}C.value=!0,T.value="";const c=String(e.title).trim()!==String(t.title).trim();try{await P.settings.save(be(e,u.peek(),{adminHomeReady:_.peek()})),window.dispatchEvent(new Event("admin-assistant:settings"));const B=await P.settings.get().catch(()=>null);if(!o())return;B&&(u.value=B);const Ae={...e,smtpPass:""};s.smtpPass.value="",b.value=Ae;try{S.remove?S.remove(g):S.set(g,null)}catch{}document.dispatchEvent(new CustomEvent("dm:admin-home-changed")),(c||["adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"].some(fe=>e[fe]!==t[fe]))&&document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild")),ve(we),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{C.value=!1}}async function Se(){await E.confirm("Throw away your unsaved settings?")&&(ne(b.peek()),T.value="")}function ne(e){for(const[t,a]of Object.entries(e))s[t]&&(s[t].value=a)}async function xe(){if(!O.peek()){O.value=!0,A.value="",L.value="Sending\u2026";try{const e=await v("/settings/test-email",{method:"POST",body:JSON.stringify({to:te.peek().trim()||void 0,example:n.querySelector("#stx-email-example").value})});if(!o())return;L.value=e?.message||"Test email sent.",A.value="is-ok"}catch(e){if(!o())return;L.value=e.message||"Could not send the test email.",A.value="is-bad"}finally{O.value=!1}}}let oe=0;async function Me(){const e=++oe;try{const t=j(),a=await v("/settings/email-preview",{method:"POST",body:JSON.stringify({example:n.querySelector("#stx-email-example").value,emailBrand:be(t,u.peek()).emailBrand})});if(!o()||e!==oe)return;const c=n.querySelector("#stx-email-preview");c.srcdoc=a.html,c.hidden=!1,n.querySelector("#stx-email-preview-text").textContent=a.text}catch(t){o()&&E.toast(t.message||"Could not preview the email.",{type:"error"})}}async function q(){N.value=!0;try{const[e,t]=await Promise.all([v("/cache/status").catch(()=>null),v("/cache/keys")]);if(!o())return;m.value=e,F.value=Array.isArray(t?.entries)?t.entries:[],z.value=""}catch(e){if(!o())return;z.value=`Could not read the cache: ${e.message||e}`}finally{N.value=!1}}async function Ce(){if(await E.confirm("Clear the whole response cache? The next visitor to each page renders it afresh.")){try{await v("/cache/clear",{method:"POST"}),E.toast("Cache cleared.",{type:"success"})}catch(e){E.toast(e.message||"Could not clear the cache.",{type:"error"})}o()&&await q()}}async function Te(){const e=m.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{m.value=await v("/cache/toggle",{method:"POST",body:JSON.stringify({enabled:!e})}),E.toast(e?"Cache turned off.":"Cache turned on.",{type:"success"}),ve(we)}catch(t){E.toast(t.message||"Could not change the cache.",{type:"error"})}o()&&await q()}}const re=e=>F.peek().find(t=>t.key===e);function Oe(e){const t=re(e);if(!t)return[];const a=Q(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=Ve;const y=n.querySelector(".stx-list");y.innerHTML=Ye;const Y=E.tabs(n.querySelector(".stx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),ie=new URLSearchParams(location.hash.split("?")[1]||"").get("tab");D.includes(ie)&&Y.activate(D.indexOf(ie));const Le=M.applyBindings(Ee,n,{methods:{save:V,discard:Se,sendTest:xe,previewEmail:Me,refreshCache:q,clearCache:Ce,toggleCache:Te,pickBrandImage:async e=>{const t=await We({title:"Choose a branding image",current:s[e].peek()});t&&o()&&(s[e].value=t)},clearBrandImage:e=>{s[e].value=""},goTab:e=>{const t=D.indexOf(e);t>=0&&Y.activate(t)}}});i(()=>Le.dispose());for(const e of n.querySelectorAll("[data-brand-icon]")){const t=e.dataset.brandIcon,a=Ne("Choose an icon",s[t].peek());a.input.id=`stx-${t}`,a.input.classList.add("form-input");const c=()=>{s[t].value=a.input.value};a.input.addEventListener("input",c),i(()=>a.input.removeEventListener("input",c)),i(M.effect(()=>{a.input.value=s[t].value})),e.appendChild(a.el)}i(Pe(n,{position:"bottom"}));const Re=e=>{const t=e.target.closest("[data-go]");if(!t)return;const a=D.indexOf(t.dataset.go);a>=0&&Y.activate(a)};n.querySelector(".stx-problems").addEventListener("click",Re);const J=n.querySelector("#stx-admin-home");Je(J,_e(s.adminHome.peek())).then(()=>{o()&&(J.value=s.adminHome.peek(),_.value=!0)}).catch(()=>{});const Ie=E.contextMenu(y,{cursor:"glyph",match:".stx-row",inherit:!1,density:"compact",items:e=>Oe(e.dataset.id)});i(()=>Ie?.destroy?.());const ce=e=>{const t=re(e.dataset.id),a=t&&Q(t.key);a?.page?window.open(a.path,"_blank","noopener"):G(e)},le=e=>{const t=e.target.closest(".stx-row");if(!t)return;const a=e.target.closest(".stx-kebab");if(a){G(a);return}ce(t)},ue=e=>{const t=e.target.closest(".stx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),G(t)):e.key==="Enter"&&e.target===t&&ce(t))};y.addEventListener("click",le),y.addEventListener("keydown",ue),i(()=>{y.removeEventListener("click",le),y.removeEventListener("keydown",ue)}),he(l,{id:"settings-view-site",icon:"external-link",title:"View site",onClick:()=>window.open("/","_blank","noopener")}),he(l,{id:"settings-save",icon:"save",title:"Save (Ctrl+S)",onClick:()=>V()});const de=e=>{!(e.ctrlKey||e.metaKey)||e.key!=="s"||(e.preventDefault(),e.stopImmediatePropagation(),V())};document.addEventListener("keydown",de,!0),i(()=>document.removeEventListener("keydown",de,!0));const pe=()=>{if(x.peek())try{S.set(g,{form:He(j()),base:U.peek(),at:new Date().toISOString()})}catch{}},me=e=>{x.peek()&&(pe(),e.preventDefault(),e.returnValue="")};window.addEventListener("beforeunload",me),i(()=>window.removeEventListener("beforeunload",me)),f={dirty:()=>x.peek(),dispose(){w=!0,pe(),d.splice(0).reverse().forEach(e=>{try{e()}catch{}})}},I.scan(n),q();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!==U.peek(),t=h.at?` (${ze(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)&&o()&&(ne(je(b.peek(),h.form)),_.peek()&&(J.value=s.adminHome.peek()))}}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.77.0",
3
+ "version": "1.78.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",
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/body-menu.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/body-menu.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The reading pane's right-click menu - the pure parts.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/cms-host.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/cms-host.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** The CMS shell boundary. Standalone never imports this adapter. */
4
4
  const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/compose-window.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/compose-window.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  const {createMailHost} = await import(new URL(`./host-context.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/contacts.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/contacts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Recipient suggestions from the host address book.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/diagnostics-section.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/diagnostics-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The settings section that answers "which build is this, and what went wrong".
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/drag-drop.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/drag-drop.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Drag identities include the mailbox and source folder: UIDs alone are not unique. */
4
4
  const PROTECTED_USES = new Set(['\\Inbox', '\\Sent', '\\Drafts', '\\Trash', '\\Junk', '\\Archive', '\\All', '\\Flagged']);
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/folder-tree.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/folder-tree.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Mail folder presentation, shared by the Mail Reader and Email Pro.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/font-controls.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/font-controls.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/fonts.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/fonts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The fonts and sizes the mail editor offers - pure, so both the compose
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/host-context.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/host-context.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Services supplied by the application that hosts the shared mail interface. */
4
4
  export function createMailApi({getToken, fetch: request = globalThis.fetch, onUnauthorized = () => {}}) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/identity.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/identity.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Who a mailbox sends as, and what it signs off with.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/image-senders-section.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/image-senders-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The settings section for senders whose images always load.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/keyboard.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/keyboard.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Keyboard navigation for the reader.
@@ -1,4 +1,4 @@
1
- <!-- Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/mail.html. -->
1
+ <!-- Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/mail.html. -->
2
2
  <div class="mail-layout">
3
3
 
4
4
  <!-- Folders -->
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/message-actions.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/message-actions.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * What other Tools add to a message's menu - Booking's "Book Sam...".
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/oauth-panel.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/oauth-panel.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * "Sign in with Microsoft / Google" for a mailbox - the part of the mailbox
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/panes.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/panes.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Pane sizing for the mail reader, shared by the Mail Reader and Email Pro.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/reader-kit.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/reader-kit.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The reader view's decisions that need no DOM - escaping, the mailbox form's
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/reader-runtime.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/reader-runtime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  const {createMailHost} = await import(new URL(`./host-context.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/reader-view.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/reader-view.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Existing CMS entry point for the shared mail view. */
4
4
  const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/resizable.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/resizable.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The mail reader's resizable slideovers.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/restore-spam.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/restore-spam.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Undo restores both junk status and the original folder, following each UID remap. */
4
4
  export async function restoreSpam({api, base, account, from, destination, uids, spam}) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/rules.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/rules.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Filing rules.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/scheduling.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/scheduling.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/section-kit.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/section-kit.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/security-note.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/security-note.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * What the reader says about a signed or encrypted (S/MIME) message.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/settings-section.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/settings-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Browser preferences for the shared mail reader. */
4
4
  export const READ_DELAY_KEY = 'domma-mail.mark-read-seconds';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/templates.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/templates.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/threads.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/threads.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Grouping messages into conversations.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/vacation.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/vacation.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The automatic reply, and everything that must stop it.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/mail/when-closed.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/mail/when-closed.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Run code when a Domma modal or slideover actually closes.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/ui/dates.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/ui/dates.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Dates as a plugin shows them to a person: dd/mm/yyyy, and dd/mm/yyyy HH:mm
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/ui/resizable.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/ui/resizable.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Making a slideover resizable.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.34.1, packages/core/src/admin/ui/rich-field.js.
1
+ // Source: @domma-mail/core 0.35.0, packages/core/src/admin/ui/rich-field.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * A Description field as a rich text editor, and a description shown in the admin.