domma-cms 1.80.0 → 1.82.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.
- package/CHANGELOG.md +20 -0
- package/admin/css/site-settings.css +1 -1
- package/admin/js/lib/site-settings-arrange.js +3 -3
- package/admin/js/templates/docs/usage-site-settings.html +47 -3
- package/admin/js/templates/settings.html +98 -8
- package/admin/js/views/settings.js +3 -3
- package/docs/DommaFeatures.md +51 -2
- package/docs/plans/2026-11-19-brand-kit-design.md +1 -1
- package/docs/plugin-development.md +6 -0
- package/package.json +1 -1
- package/plugins/_lib/telegram/bot.js +120 -0
- package/plugins/free-tier.lock.json +34 -9
- package/plugins/telegram/CHANGELOG.md +5 -0
- package/plugins/telegram/CLAUDE.md +77 -0
- package/plugins/telegram/admin/css/index.css +68 -0
- package/plugins/telegram/admin/lib/arrange.js +103 -0
- package/plugins/telegram/admin/lib/kit.js +153 -0
- package/plugins/telegram/admin/templates/telegram.html +1 -0
- package/plugins/telegram/admin/views/chats.js +223 -0
- package/plugins/telegram/admin/views/connection.js +90 -0
- package/plugins/telegram/admin/views/telegram.js +89 -0
- package/plugins/telegram/admin/views/test.js +84 -0
- package/plugins/telegram/config.js +21 -0
- package/plugins/telegram/docs/guide.md +87 -0
- package/plugins/telegram/lib/messages.js +176 -0
- package/plugins/telegram/lib/queue.js +72 -0
- package/plugins/telegram/plugin.js +490 -0
- package/plugins/telegram/plugin.json +71 -0
- package/plugins/telegram/tests/api.test.js +381 -0
- package/plugins/telegram/tests/arrange.test.js +41 -0
- package/plugins/telegram/tests/messages.test.js +110 -0
- package/plugins/telegram/tests/queue.test.js +47 -0
- package/plugins/theme-roller/CLAUDE.md +9 -0
- package/plugins/theme-roller/admin/lib/themes.js +49 -0
- package/plugins/theme-roller/admin/templates/theme-roller.html +2 -0
- package/plugins/theme-roller/admin/views/theme-roller-view.js +25 -2
- package/plugins/theme-roller/docs/guide.md +1 -0
- package/plugins/theme-roller/plugin.json +1 -1
- package/plugins/theme-roller/tests/themes.test.js +20 -0
- package/public/js/site.js +1 -1
- package/server/routes/api/brand-kit.js +55 -0
- package/server/routes/api/settings.js +17 -1
- package/server/routes/favicon.js +10 -6
- package/server/server.js +2 -0
- package/server/services/adminBrand.js +8 -3
- package/server/services/brandKit.js +330 -0
- package/server/services/chat/launcher-bridge.js +2 -1
- package/server/services/emailBrand.js +31 -13
- package/server/services/launchers.js +5 -1
- package/server/services/notify.js +20 -2
- package/server/services/plugins.js +3 -0
- package/server/services/renderer.js +7 -5
- package/server/templates/page.html +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.82.0] - 2026-11-20
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **The Brand Kit fills the gaps on the website and in the admin.** Once a site has saved its Brand Kit (Site Settings > Branding), it is used wherever the site's own settings are empty: the browser icon (the Kit's square mark, else its logo; the letter icon takes its accent colour), a navbar brand with no name, logo or icon (the Kit's logo, else its name), the admin name and logos and the sign-in screen, chat launchers with no colour or picture of their own (its accent, and its mark unless the chat has a character), and og:site_name. Nothing you have set changes, and a site that never saved a Kit renders exactly as before. The theme is never changed. `GET /api/brand-kit` now says whether the Kit has been `saved`.
|
|
8
|
+
- **Theme Roller** 1.4.0: "New theme from Brand Kit" starts a new theme from the Kit's accent, colours and fonts. It never changes an existing theme.
|
|
9
|
+
|
|
10
|
+
## [1.81.0] - 2026-11-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Telegram** (free Tool, 0.1.0): your own Telegram bot sends the team the site's alerts and form submissions. Telegram Pro (two-way customer chat) is in the marketplace.
|
|
15
|
+
- **Plugins can hear every notification.** `notify()` now emits `notification:raised` with the stored entry, for a new notification and for a repeat that grew worse, so a Tool can pass notifications on (the Telegram Tool sends them to a team chat). Nothing else about notifications changes.
|
|
16
|
+
- **`plugins/_lib/telegram/bot.js`**: the shared Telegram Bot API helpers (call with a timeout, token shape, HTML escaping, sendMessage, one-time codes, command parsing, a test transport), lifted from Takeaway for the Telegram Tools.
|
|
17
|
+
|
|
18
|
+
- **Brand Kit** (Site Settings > Branding): one place for your business's name, registered name, logos (with a dark-background version and a square mark), accent and up to four brand colours, heading and body fonts, contact details (email, phone, address, website, company and VAT numbers), a footer line and small print. Empty fields use what the site already has, so nothing changes until you fill it in. It never changes your theme.
|
|
19
|
+
- Every automated email now reads the Kit: name, logo, accent, fonts, contact email and footer line, plus your registered name, company and VAT numbers and address, and any small print, at the bottom. An SVG logo now shows in email too, as a PNG copy (needs the Site URL). SMTP > Email identity becomes email-only overrides on top of the Kit.
|
|
20
|
+
- `GET /api/brand-kit` (public: the brand as the site presents it) and `GET /api/brand-kit/logo.png`; plugins read the Kit with `hooks.brandKit()`.
|
|
21
|
+
- Needs attention: an SVG logo with no Site URL (emails would show the name instead).
|
|
22
|
+
|
|
3
23
|
## [1.80.0] - 2026-11-19
|
|
4
24
|
|
|
5
25
|
### Added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.stx{display:flex;flex-direction:column;gap:.75rem}.stx [hidden]{display:none!important}.stx-alert{margin:0;display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;padding:.6rem .8rem;border-radius:var(--dm-radius-md);color:var(--dm-text)}.stx-alert.is-dirty{background:color-mix(in srgb,var(--dm-primary) 12%,transparent)}.stx-alert.is-warn{background:color-mix(in srgb,var(--dm-warning) 16%,transparent)}.stx-alert.is-bad{background:color-mix(in srgb,var(--dm-danger) 14%,transparent)}.stx-spacer{flex:1}.stx-alert.is-dirty>span:nth-child(2){flex:1 1 18rem;min-width:0}.stx-tabs .tab-item{display:inline-flex;align-items:center;gap:.35rem}.stx-dot{display:inline-block;width:.45rem;height:.45rem;border-radius:50%;background:var(--dm-primary)}.stx-dot.is-bad{background:var(--dm-danger)}.stx-card{border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);padding:.75rem .9rem;display:flex;flex-direction:column;gap:.65rem;margin-top:.75rem}.stx-card-title{display:flex;align-items:center;gap:.4rem;font-weight:600;flex-wrap:wrap}.stx-card-title .btn{display:inline-flex;align-items:center;gap:.3rem;font-weight:500}.stx-card-columns{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:1rem;align-items:start}.stx-card-columns>.stx-card{min-width:0}.stx-scroll-icon{display:inline-flex;padding:.35rem;border-radius:50%;background:var(--dm-surface-raised)}@media(max-width:900px){.stx-card-columns{grid-template-columns:minmax(0,1fr)}}.stx-grid{display:grid;grid-template-columns:1fr 1fr;gap:.75rem 1rem}.stx-wide{grid-column:1 / -1}.stx-pair{display:grid;grid-template-columns:1fr 1fr;gap:.75rem}.stx .form-label{display:flex;align-items:center;gap:.3rem}.stx-setting{display:flex;align-items:center;justify-content:space-between;gap:.75rem}.stx-setting .form-label{margin:0}.stx-hint{display:block;color:var(--dm-text-muted);font-size:var(--dm-text-xs);margin-top:.25rem}.stx-muted{color:var(--dm-text-muted);font-weight:400}.stx-note{margin:0;color:var(--dm-text-muted);font-size:var(--dm-text-sm)}.stx-note.is-bad{color:var(--dm-danger)}.stx-moved{flex-direction:row;align-items:center;gap:.75rem;background:var(--dm-surface-raised)}.stx-moved-text{flex:1;display:flex;flex-direction:column}.stx-moved-text small{color:var(--dm-text-muted)}.stx-problems{display:flex;flex-direction:column;gap:.35rem}.stx-problem{display:flex;align-items:center;gap:.6rem;font-size:var(--dm-text-sm)}.stx-problem button{margin-left:auto}.stx-inline{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}.stx-inline .btn{display:inline-flex;align-items:center;gap:.3rem}.stx-test-to{max-width:18rem}.stx-result{font-size:var(--dm-text-sm)}.stx-result.is-ok{color:var(--dm-success)}.stx-result.is-bad{color:var(--dm-danger)}.stx-corners{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);overflow:hidden;width:fit-content}.stx-corners button{border:0;background:none;color:var(--dm-text);padding:.45rem .8rem;cursor:pointer;font:inherit;font-size:var(--dm-text-sm)}.stx-corners button:nth-child(odd){border-right:1px solid var(--dm-border)}.stx-corners button:nth-child(-n+2){border-bottom:1px solid var(--dm-border)}.stx-corners button:hover{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent))}.stx-corners button.is-on{background:var(--dm-primary);color:var(--dm-primary-text)}.stx-segments{display:inline-flex;flex-wrap:wrap;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);overflow:hidden}.stx-segments button{border:0;background:none;color:var(--dm-text);padding:.45rem .8rem;cursor:pointer;font:inherit;font-size:var(--dm-text-sm)}.stx-segments button+button{border-left:1px solid var(--dm-border)}.stx-segments button:hover{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent))}.stx-segments button.is-on{background:var(--dm-primary);color:var(--dm-primary-text)}.stx-readout{color:var(--dm-text-muted);font-weight:400;font-variant-numeric:tabular-nums}.stx-pair input[type=range]{width:100%}.stx-inline-link{background:none;border:0;padding:0;font:inherit;color:var(--dm-primary);text-decoration:underline;cursor:pointer}.stx-chips{display:flex;gap:.35rem;flex-wrap:wrap}.stx-chip{display:inline-flex;align-items:center;font-size:var(--dm-text-xs);font-weight:600;padding:.1rem .5rem;border-radius:999px;white-space:nowrap;background:color-mix(in srgb,var(--dm-text) 10%,transparent);color:var(--dm-text-muted)}.stx-chip.is-ok{background:color-mix(in srgb,var(--dm-success) 16%,transparent);color:var(--dm-success)}.stx-chip.is-warn{background:color-mix(in srgb,var(--dm-warning) 18%,transparent);color:var(--dm-warning)}.stx-chip.is-bad{background:color-mix(in srgb,var(--dm-danger) 16%,transparent);color:var(--dm-danger)}.stx-count{opacity:.65;font-size:var(--dm-text-xs);font-weight:500}.stx-search{max-width:14rem;font-weight:400}.stx-list{display:flex;flex-direction:column}.stx-row{display:flex;align-items:center;gap:.75rem;padding:.45rem .3rem;border-bottom:1px solid var(--dm-border);cursor:pointer}.stx-row:last-child{border-bottom:0}.stx-row:hover,.stx-row:focus-visible{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent));outline:none}.stx-main{flex:1;min-width:0;display:flex;flex-direction:column}.stx-main strong,.stx-main small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.stx-main strong{font-family:var(--dm-font-mono, monospace);font-size:var(--dm-text-sm);font-weight:600}.stx-main small{color:var(--dm-text-muted);font-size:var(--dm-text-xs)}.stx-kebab{border:0;background:none;cursor:pointer;font-size:var(--dm-text-lg);color:var(--dm-text-muted);border-radius:var(--dm-radius-sm);padding:0 .3rem}.stx-kebab:hover{color:var(--dm-primary)}@media(max-width:720px){.stx-grid,.stx-pair{grid-template-columns:1fr}}
|
|
1
|
+
.stx{display:flex;flex-direction:column;gap:.75rem}.stx [hidden]{display:none!important}.stx-alert{margin:0;display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;padding:.6rem .8rem;border-radius:var(--dm-radius-md);color:var(--dm-text)}.stx-alert.is-dirty{background:color-mix(in srgb,var(--dm-primary) 12%,transparent)}.stx-alert.is-warn{background:color-mix(in srgb,var(--dm-warning) 16%,transparent)}.stx-alert.is-bad{background:color-mix(in srgb,var(--dm-danger) 14%,transparent)}.stx-spacer{flex:1}.stx-alert.is-dirty>span:nth-child(2){flex:1 1 18rem;min-width:0}.stx-tabs .tab-item{display:inline-flex;align-items:center;gap:.35rem}.stx-dot{display:inline-block;width:.45rem;height:.45rem;border-radius:50%;background:var(--dm-primary)}.stx-dot.is-bad{background:var(--dm-danger)}.stx-card{border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);padding:.75rem .9rem;display:flex;flex-direction:column;gap:.65rem;margin-top:.75rem}.stx-card-title{display:flex;align-items:center;gap:.4rem;font-weight:600;flex-wrap:wrap}.stx-card-title .btn{display:inline-flex;align-items:center;gap:.3rem;font-weight:500}.stx-card-columns{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:1rem;align-items:start}.stx-card-columns>.stx-card{min-width:0}.stx-scroll-icon{display:inline-flex;padding:.35rem;border-radius:50%;background:var(--dm-surface-raised)}@media(max-width:900px){.stx-card-columns{grid-template-columns:minmax(0,1fr)}}.stx-grid{display:grid;grid-template-columns:1fr 1fr;gap:.75rem 1rem}.stx-wide{grid-column:1 / -1}.stx-pair{display:grid;grid-template-columns:1fr 1fr;gap:.75rem}.stx .form-label{display:flex;align-items:center;gap:.3rem}.stx-setting{display:flex;align-items:center;justify-content:space-between;gap:.75rem}.stx-setting .form-label{margin:0}.stx-hint{display:block;color:var(--dm-text-muted);font-size:var(--dm-text-xs);margin-top:.25rem}.stx-muted{color:var(--dm-text-muted);font-weight:400}.stx-note{margin:0;color:var(--dm-text-muted);font-size:var(--dm-text-sm)}.stx-note.is-bad{color:var(--dm-danger)}.stx-moved{flex-direction:row;align-items:center;gap:.75rem;background:var(--dm-surface-raised)}.stx-moved-text{flex:1;display:flex;flex-direction:column}.stx-moved-text small{color:var(--dm-text-muted)}.stx-problems{display:flex;flex-direction:column;gap:.35rem}.stx-problem{display:flex;align-items:center;gap:.6rem;font-size:var(--dm-text-sm)}.stx-problem button{margin-left:auto}.stx-inline{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}.stx-inline .btn{display:inline-flex;align-items:center;gap:.3rem}.stx-test-to{max-width:18rem}.stx-result{font-size:var(--dm-text-sm)}.stx-result.is-ok{color:var(--dm-success)}.stx-result.is-bad{color:var(--dm-danger)}.stx-corners{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);overflow:hidden;width:fit-content}.stx-corners button{border:0;background:none;color:var(--dm-text);padding:.45rem .8rem;cursor:pointer;font:inherit;font-size:var(--dm-text-sm)}.stx-corners button:nth-child(odd){border-right:1px solid var(--dm-border)}.stx-corners button:nth-child(-n+2){border-bottom:1px solid var(--dm-border)}.stx-corners button:hover{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent))}.stx-corners button.is-on{background:var(--dm-primary);color:var(--dm-primary-text)}.stx-segments{display:inline-flex;flex-wrap:wrap;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);overflow:hidden}.stx-segments button{border:0;background:none;color:var(--dm-text);padding:.45rem .8rem;cursor:pointer;font:inherit;font-size:var(--dm-text-sm)}.stx-segments button+button{border-left:1px solid var(--dm-border)}.stx-segments button:hover{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent))}.stx-segments button.is-on{background:var(--dm-primary);color:var(--dm-primary-text)}.stx-readout{color:var(--dm-text-muted);font-weight:400;font-variant-numeric:tabular-nums}.stx-pair input[type=range]{width:100%}.stx-inline-link{background:none;border:0;padding:0;font:inherit;color:var(--dm-primary);text-decoration:underline;cursor:pointer}.stx-chips{display:flex;gap:.35rem;flex-wrap:wrap}.stx-chip{display:inline-flex;align-items:center;font-size:var(--dm-text-xs);font-weight:600;padding:.1rem .5rem;border-radius:999px;white-space:nowrap;background:color-mix(in srgb,var(--dm-text) 10%,transparent);color:var(--dm-text-muted)}.stx-chip.is-ok{background:color-mix(in srgb,var(--dm-success) 16%,transparent);color:var(--dm-success)}.stx-chip.is-warn{background:color-mix(in srgb,var(--dm-warning) 18%,transparent);color:var(--dm-warning)}.stx-chip.is-bad{background:color-mix(in srgb,var(--dm-danger) 16%,transparent);color:var(--dm-danger)}.stx-count{opacity:.65;font-size:var(--dm-text-xs);font-weight:500}.stx-search{max-width:14rem;font-weight:400}.stx-list{display:flex;flex-direction:column}.stx-row{display:flex;align-items:center;gap:.75rem;padding:.45rem .3rem;border-bottom:1px solid var(--dm-border);cursor:pointer}.stx-row:last-child{border-bottom:0}.stx-row:hover,.stx-row:focus-visible{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent));outline:none}.stx-main{flex:1;min-width:0;display:flex;flex-direction:column}.stx-main strong,.stx-main small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.stx-main strong{font-family:var(--dm-font-mono, monospace);font-size:var(--dm-text-sm);font-weight:600}.stx-main small{color:var(--dm-text-muted);font-size:var(--dm-text-xs)}.stx-kebab{border:0;background:none;cursor:pointer;font-size:var(--dm-text-lg);color:var(--dm-text-muted);border-radius:var(--dm-radius-sm);padding:0 .3rem}.stx-kebab:hover{color:var(--dm-primary)}@media(max-width:720px){.stx-grid,.stx-pair{grid-template-columns:1fr}}.stx-subhead{margin:1.1rem 0 .5rem;font-size:.8rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--dm-text-muted, #64748b)}#stx-brand-kit .stx-inline{margin-bottom:.4rem;flex-wrap:nowrap}#stx-brand-kit .stx-inline input:first-child{flex:2 1 0;min-width:0}#stx-brand-kit .stx-inline input:last-child{flex:1 1 0;min-width:0;font-family:var(--dm-font-mono, monospace)}
|
|
@@ -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:["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,
|
|
2
|
-
`):"",footerTagline:
|
|
3
|
-
`).map(
|
|
1
|
+
export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass","charactersEnabled","charactersAnimated","charactersLaunchers","charactersChats","charactersBuilders","charactersDot","charactersDaisy","mapLookups"],branding:["kitName","kitLegalName","kitShortName","kitLogo","kitLogoDark","kitMark","kitAccent","kitColour1Name","kitColour1Hex","kitColour2Name","kitColour2Hex","kitColour3Name","kitColour3Hex","kitColour4Name","kitColour4Hex","kitFontHeading","kitFontBody","kitEmail","kitPhone","kitAddress","kitWebsite","kitCompanyNumber","kitVatNumber","kitFooterLine","kitSmallPrint","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,e,a,r)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?Math.min(r,Math.max(a,n)):e};export function motionFromSettings(t={}){const e=t.motion&&typeof t.motion=="object"?t.motion:{},a=t.footer||{},r=m=>e[m]!==void 0&&e[m]!==null,n=r("default")?e.default:a.motionDefault,i=r("control")?e.control:a.motionControl,l=c(e.iconSize,52,32,96);return{mtEnabled:(r("enabled")?e.enabled:a.showMotionToggle)!==!1,mtLabel:typeof e.label=="string"&&e.label.trim()?e.label.trim():MOTION_LABEL,mtDefault:b.includes(n)?n:"system",mtControl:i==="checkbox"?"checkbox":"switch",mtPlacement:MOTION_PLACEMENTS.includes(e.placement)?e.placement:"footer",mtTriggerStyle:e.triggerStyle==="icon-text"?"icon-text":"icon",mtPosition:BREADCRUMB_POSITIONS.includes(e.position)?e.position:"BL",mtOffsetX:o(c(e.offsetX,32,0,500)),mtOffsetY:o(c(e.offsetY,32,0,500)),mtIconSize:o(l),mtIconRadius:o(c(e.iconRadius,26,0,Math.floor(l/2))),mtClass:o(e.class)}}export function motionFromForm(t){const e=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:o(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:e,iconRadius:c(t.mtIconRadius,26,0,Math.floor(e/2)),class:o(t.mtClass).trim()}}export function footerBlockNames(t){return[...new Set(String(t??"").split(/[\s,]+/).map(e=>e.trim().toLowerCase()).filter(Boolean))]}export function gaIdError(t){const e=o(t).trim();return!e||/^G-[A-Z0-9]{4,20}$/i.test(e)?"":"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 h=/^(\/|#|https?:\/\/|mailto:)/,p=/^#[0-9a-f]{6}$/i;export function footerShowcaseErrors(t){const e=[],a=o(t.footerCtaUrl).trim();a&&!h.test(a)&&e.push("The footer call to action link must start with /, #, https:// or mailto: (Footer tool).");for(const[r,n]of[["from",t.footerGradFrom],["to",t.footerGradTo]]){const i=o(n).trim();i&&!p.test(i)&&e.push(`The footer gradient "${r}" colour must look like #f26b3a (Footer tool).`)}return e}const o=(t,e="")=>t==null?e:String(t),s=(t,e)=>{const a=Number.parseInt(t,10);return Number.isFinite(a)?a:e};export function homeValue(t){return/^\/[A-Za-z0-9\-_/]*$/.test(t||"")&&String(t).replace(/\/+$/,"")||"/"}export function formFromSettings(t={}){const e=t.backToTop||{},a=t.goToBottom||{},r=t.cookieConsent||{},n=t.breadcrumbs||{};return{title:o(t.title),tagline:o(t.tagline),siteUrl:o(t.baseUrl),adminHome:homeValue(t.adminHome),spacerSize:o(t.layoutOptions?.spacerSize??40),bodyClass:o(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,kitName:o(t.brandKit?.name),kitLegalName:o(t.brandKit?.legalName),kitShortName:o(t.brandKit?.shortName),kitLogo:o(t.brandKit?.logo),kitLogoDark:o(t.brandKit?.logoDark),kitMark:o(t.brandKit?.mark),kitAccent:o(t.brandKit?.accent),...Object.fromEntries([1,2,3,4].flatMap(i=>[[`kitColour${i}Name`,o(t.brandKit?.colours?.[i-1]?.name)],[`kitColour${i}Hex`,o(t.brandKit?.colours?.[i-1]?.hex)]])),kitFontHeading:o(t.brandKit?.fonts?.heading),kitFontBody:o(t.brandKit?.fonts?.body),kitEmail:o(t.brandKit?.contact?.email),kitPhone:o(t.brandKit?.contact?.phone),kitAddress:o(t.brandKit?.contact?.address),kitWebsite:o(t.brandKit?.contact?.website),kitCompanyNumber:o(t.brandKit?.contact?.companyNumber),kitVatNumber:o(t.brandKit?.contact?.vatNumber),kitFooterLine:o(t.brandKit?.footerLine),kitSmallPrint:o(t.brandKit?.smallPrint),brandEnabled:t.brand?.enabled!==!1,brandText:o(t.brand?.text),brandLogo:o(t.brand?.logo),brandIcon:o(t.brand?.icon),brandUrl:o(t.brand?.url,"/"),favicon:o(t.favicon),adminBrandEnabled:t.adminBrand?.enabled!==!1,adminBrandTitle:o(t.adminBrand?.title),adminBrandLogo:o(t.adminBrand?.logo),adminBrandLogoDark:o(t.adminBrand?.logoDark),adminBrandIcon:o(t.adminBrand?.icon),footerCopyright:o(t.footer?.copyright),footerLayout:FOOTER_LAYOUTS.includes(t.footer?.layout)?t.footer.layout:"auto",footerBlurb:o(t.footer?.blurb),footerBlocks:Array.isArray(t.footer?.blocks)?t.footer.blocks.filter(i=>typeof i=="string").join(", "):"",footerClass:o(t.footer?.class),footerSocialClass:o(t.footer?.socialClass),footerLook:FOOTER_LOOKS.includes(t.footer?.look)?t.footer.look:"",footerCtaText:o(t.footer?.cta?.text),footerCtaHighlight:o(t.footer?.cta?.highlight),footerCtaUrl:o(t.footer?.cta?.url),footerCtaSub:o(t.footer?.cta?.sub),footerWatermark:o(t.footer?.watermark),footerStatus:o(t.footer?.status),footerFacts:Array.isArray(t.footer?.facts)?t.footer.facts.filter(i=>typeof i=="string").join(`
|
|
2
|
+
`):"",footerTagline:o(t.footer?.tagline),footerEmail:o(t.footer?.email),footerAddress:o(t.footer?.address),footerGradFrom:o(t.footer?.gradient?.from),footerGradTo:o(t.footer?.gradient?.to),socialTwitter:o(t.social?.twitter),socialFacebook:o(t.social?.facebook),socialInstagram:o(t.social?.instagram),socialLinkedin:o(t.social?.linkedin),socialGithub:o(t.social?.github),socialYoutube:o(t.social?.youtube),emailBrandName:o(t.emailBrand?.name),emailBrandLogo:o(t.emailBrand?.logo),emailBrandAccent:o(t.emailBrand?.accent),emailBrandSupport:o(t.emailBrand?.supportEmail),emailBrandFooter:o(t.emailBrand?.footer),smtpHost:o(t.smtp?.host),smtpPort:o(t.smtp?.port||587),smtpUser:o(t.smtp?.user),smtpPass:"",smtpSecure:t.smtp?.secure===!0,smtpInsecureTLS:t.smtp?.allowInsecureTLS===!0,smtpFromAddress:o(t.smtp?.fromAddress),smtpFromName:o(t.smtp?.fromName),bttEnabled:e.enabled!==!1,bttSmooth:e.smooth!==!1,bttLabel:o(e.label),bttThreshold:o(e.scrollThreshold??300),bttPosition:o(e.position,"bottom-right"),bttOffset:o(e.offset??32),bttBottomOffset:o(e.bottomOffset??e.offset??32),gtbEnabled:a.enabled===!0,gtbSmooth:a.smooth!==!1,gtbLabel:o(a.label),gtbThreshold:o(a.scrollThreshold??300),gtbPosition:o(a.position,"bottom-right"),gtbOffset:o(a.offset??32),gtbBottomOffset:o(a.bottomOffset??a.offset??32),ccEnabled:r.enabled!==!1,ccMessage:o(r.message),ccAcceptAll:o(r.acceptAllText,"Accept All"),ccRejectAll:o(r.rejectAllText,"Reject All"),ccCustomize:o(r.customizeText,"Customize"),ccSavePrefs:o(r.savePreferencesText,"Save Preferences"),ccPrivacyText:o(r.privacyPolicyText,"Privacy Policy"),ccPrivacyUrl:o(r.privacyPolicyUrl),ccCookieText:o(r.cookiePolicyText,"Cookie Policy"),ccCookieUrl:o(r.cookiePolicyUrl),ccPosition:o(r.position,"bottom"),ccLayout:o(r.layout,"bar"),ccTheme:o(r.theme,"dark"),ccShowFunctional:r.showFunctional!==!1,ccShowAnalytics:r.showAnalytics!==!1,ccShowMarketing:r.showMarketing!==!1,ccVersion:o(r.consentVersion,"1.0"),ccSettingsLink:r.showSettingsLink!==!1,ccSettingsLinkText:o(r.settingsLinkText,"Cookie settings"),bcEnabled:n.enabled===!0,bcHomeLabel:o(n.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(n.position)?n.position:"TL",bcOffsetX:o(n.offsetX??8),bcOffsetY:o(n.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,e={},{adminHomeReady:a=!0}={}){const r=i=>o(i).trim(),n=motionFromForm(t);return{title:r(t.title),tagline:r(t.tagline),baseUrl:r(t.siteUrl).replace(/\/+$/,""),...a&&{adminHome:r(t.adminHome)||"/"},layoutOptions:{spacerSize:s(t.spacerSize,40)||40},bodyClass:r(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},brandKit:brandKitFromForm(t),brand:{...e.brand,enabled:t.brandEnabled!==!1,text:r(t.brandText),logo:r(t.brandLogo),icon:r(t.brandIcon),url:r(t.brandUrl)||"/"},favicon:r(t.favicon),adminBrand:{...e.adminBrand,enabled:t.adminBrandEnabled!==!1,title:r(t.adminBrandTitle),logo:r(t.adminBrandLogo),logoDark:r(t.adminBrandLogoDark),icon:r(t.adminBrandIcon)},footer:{copyright:r(t.footerCopyright),layout:FOOTER_LAYOUTS.includes(t.footerLayout)?t.footerLayout:"auto",blurb:r(t.footerBlurb),blocks:footerBlockNames(t.footerBlocks),links:e.footer?.links||[],showMotionToggle:n.enabled,motionDefault:n.default,motionControl:n.control,class:r(t.footerClass),socialClass:r(t.footerSocialClass),look:FOOTER_LOOKS.includes(t.footerLook)?t.footerLook:"",cta:{text:r(t.footerCtaText),highlight:r(t.footerCtaHighlight),url:r(t.footerCtaUrl),sub:r(t.footerCtaSub)},watermark:r(t.footerWatermark),status:r(t.footerStatus),facts:String(t.footerFacts??"").split(`
|
|
3
|
+
`).map(i=>i.trim()).filter(Boolean).slice(0,FOOTER_FACTS_MAX),tagline:r(t.footerTagline),email:r(t.footerEmail),address:r(t.footerAddress),gradient:{from:r(t.footerGradFrom),to:r(t.footerGradTo)}},social:{twitter:r(t.socialTwitter),facebook:r(t.socialFacebook),instagram:r(t.socialInstagram),linkedin:r(t.socialLinkedin),github:r(t.socialGithub),youtube:r(t.socialYoutube)},emailBrand:{...e.emailBrand,name:r(t.emailBrandName),logo:r(t.emailBrandLogo),accent:r(t.emailBrandAccent),supportEmail:r(t.emailBrandSupport),footer:r(t.emailBrandFooter)},smtp:{host:r(t.smtpHost),port:s(t.smtpPort,587)||587,user:r(t.smtpUser),pass:o(t.smtpPass),secure:t.smtpSecure===!0,allowInsecureTLS:t.smtpInsecureTLS===!0,fromAddress:r(t.smtpFromAddress),fromName:r(t.smtpFromName)},backToTop:{enabled:t.bttEnabled===!0,scrollThreshold:s(t.bttThreshold,300),position:o(t.bttPosition)||"bottom-right",offset:s(t.bttOffset,32),bottomOffset:s(t.bttBottomOffset,32),label:r(t.bttLabel),smooth:t.bttSmooth===!0},goToBottom:{enabled:t.gtbEnabled===!0,scrollThreshold:s(t.gtbThreshold,300),position:o(t.gtbPosition)||"bottom-right",offset:s(t.gtbOffset,32),bottomOffset:s(t.gtbBottomOffset,32),label:r(t.gtbLabel),smooth:t.gtbSmooth===!0},cookieConsent:{enabled:t.ccEnabled===!0,message:r(t.ccMessage),acceptAllText:r(t.ccAcceptAll),rejectAllText:r(t.ccRejectAll),customizeText:r(t.ccCustomize),savePreferencesText:r(t.ccSavePrefs),privacyPolicyText:r(t.ccPrivacyText),privacyPolicyUrl:r(t.ccPrivacyUrl),cookiePolicyText:r(t.ccCookieText),cookiePolicyUrl:r(t.ccCookieUrl),position:o(t.ccPosition)||"bottom",layout:o(t.ccLayout)||"bar",theme:o(t.ccTheme)||"dark",showFunctional:t.ccShowFunctional===!0,showAnalytics:t.ccShowAnalytics===!0,showMarketing:t.ccShowMarketing===!0,consentVersion:r(t.ccVersion)||"1.0",showSettingsLink:t.ccSettingsLink===!0,settingsLinkText:r(t.ccSettingsLinkText)||"Cookie settings"},breadcrumbs:{enabled:t.bcEnabled===!0,homeLabel:r(t.bcHomeLabel)||"Home",position:BREADCRUMB_POSITIONS.includes(t.bcPosition)?t.bcPosition:"TL",offsetX:s(t.bcOffsetX,8),offsetY:s(t.bcOffsetY,8)},motion:n}}export function siteUrlError(t){const e=o(t).trim().replace(/\/+$/,"");return e?/^https?:\/\//i.test(e)?/^https?:\/\/([a-z0-9.\-]+|\[[0-9a-f:.]+\])(:\d{1,5})?$/i.test(e)?"":"Just the address, like https://example.com - no page path after it.":"Start with https:// (or http://).":""}const d=t=>typeof t=="boolean"?t:o(t);export function snapshot(t){return JSON.stringify(Object.keys(t).sort().map(e=>[e,d(t[e])]))}export function changedTabs(t,e){const a=[];for(const[r,n]of Object.entries(TAB_FIELDS))n.some(i=>d(t[i])!==d(e[i]))&&a.push(r);return a}export function draftOf(t){return Object.fromEntries(Object.entries(t).filter(([e])=>!SECRET_FIELDS.includes(e)))}const g={footerMotionToggle:"mtEnabled",footerMotionDefault:"mtDefault",footerMotionControl:"mtControl"};export function formFromDraft(t,e={}){const a={...e};for(const[n,i]of Object.entries(g))n in a&&!(i in a)&&(a[i]=a[n]),delete a[n];const r={...t};for(const[n,i]of Object.entries(a))n in r&&!SECRET_FIELDS.includes(n)&&(r[n]=i);return r}export function settingsProblems(t,e={}){const a=[];o(t.smtpHost).trim()?o(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)."});const r=[t.kitLogo,t.brandLogo,e.logo].map(n=>o(n).trim()).find(n=>/^\/(?!\/)|^https:\/\//.test(n))||"";return/\.svg(?:[?#]|$)/i.test(r)&&!o(t.siteUrl).trim()&&!/^https?:\/\//.test(o(e.url))&&a.push({tone:"warn",tab:"branding",text:"Your logo is an SVG and there is no Site URL - emails cannot show it and use your name instead. Set the Site URL on the General tab."}),(t.ccEnabled===!0||o(e.googleAnalytics?.measurementId).trim())&&!o(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 e=/^page:(.*?):m\d+:role([^:]*):/.exec(String(t||""));return e?{path:e[1]||"/",role:e[2]||"anon",page:!0}:{path:String(t||""),role:"",page:!1}}export function expiresIn(t,e=Date.now()){if(t==null)return"no expiry";const a=t-e;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 e=formFromSettings(t);return Object.fromEntries(TAB_FIELDS.footer.map(a=>[a,e[a]]))}export function footerPayload(t){const{footer:e,social:a}=payloadFromForm(t);return delete e.links,delete e.showMotionToggle,delete e.motionDefault,delete e.motionControl,{footer:e,social:a}}export function brandKitFromForm(t){const e=a=>o(a).trim();return{name:e(t.kitName),legalName:e(t.kitLegalName),shortName:e(t.kitShortName),logo:e(t.kitLogo),logoDark:e(t.kitLogoDark),mark:e(t.kitMark),accent:e(t.kitAccent).toLowerCase(),colours:[1,2,3,4].map(a=>({name:e(t[`kitColour${a}Name`]),hex:e(t[`kitColour${a}Hex`]).toLowerCase()})).filter(a=>a.name||a.hex),fonts:{heading:e(t.kitFontHeading),body:e(t.kitFontBody)},contact:{email:e(t.kitEmail),phone:e(t.kitPhone),address:o(t.kitAddress).trim(),website:e(t.kitWebsite),companyNumber:e(t.kitCompanyNumber),vatNumber:e(t.kitVatNumber)},footerLine:e(t.kitFooterLine),smallPrint:o(t.kitSmallPrint).trim()}}export function brandKitFormError(t){const e=o(t.kitEmail).trim();if(e&&!/^[^\s@<>"]+@[^\s@<>"]+\.[^\s@<>"]+$/.test(e))return"The contact email is not an email address.";const a=o(t.kitWebsite).trim();if(a){let n=!1;try{const i=new URL(/^https?:\/\//i.test(a)?a:`https://${a}`);n=["http:","https:"].includes(i.protocol)&&!i.username&&!i.password&&i.hostname.includes(".")}catch{}if(!n)return"The website must be an address such as https://example.com."}const r=n=>o(n).trim()&&!/^#[\da-f]{6}$/i.test(o(n).trim());if(r(t.kitAccent))return"The accent colour must be a six-digit colour, such as #2563eb.";for(const n of[1,2,3,4]){const i=o(t[`kitColour${n}Name`]).trim();if(r(t[`kitColour${n}Hex`])||i&&!o(t[`kitColour${n}Hex`]).trim())return`${i||`Colour ${n}`} needs a six-digit colour, such as #0f766e.`}return""}export function siteSettingsForm(t={}){return Object.fromEntries(Object.entries(formFromSettings(t)).filter(([e])=>!TAB_FIELDS.footer.includes(e)&&!u.includes(e)))}export function siteSettingsPayload(...t){const{footer:e,social:a,favicon:r,backToTop:n,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 e=formFromSettings(t);return Object.fromEntries(u.map(a=>[a,e[a]]))}export function appearancePayload(t){const{favicon:e,backToTop:a,goToBottom:r,breadcrumbs:n,motion:i}=payloadFromForm(t);return{favicon:e,backToTop:a,goToBottom:r,breadcrumbs:n,motion:i}}
|
|
@@ -37,7 +37,9 @@
|
|
|
37
37
|
</tr>
|
|
38
38
|
<tr>
|
|
39
39
|
<td>Branding</td>
|
|
40
|
-
<td>The
|
|
40
|
+
<td>The <strong>Brand Kit</strong> - your business's name, logos, colours, fonts and
|
|
41
|
+
contact details, used by every automated email (see <a href="#brand-kit">Brand Kit</a>
|
|
42
|
+
below) - then the public site's brand (name, logo or icon, link) and the admin's own. The
|
|
41
43
|
<strong>Admin name</strong> is shown in the admin's top bar, its sidebar and the
|
|
42
44
|
browser tab, for everyone who signs in; empty, it uses the site title. The admin logo
|
|
43
45
|
takes priority over the admin icon.</td>
|
|
@@ -69,14 +71,56 @@
|
|
|
69
71
|
</tbody>
|
|
70
72
|
</table>
|
|
71
73
|
|
|
74
|
+
<h3 id="brand-kit">Brand Kit</h3>
|
|
75
|
+
<p>The Brand Kit, at the top of the <strong>Branding</strong> tab, keeps your brand in one place so
|
|
76
|
+
you only change it once. Today every automated email uses it; more of Domma will follow.
|
|
77
|
+
Anything you leave empty uses what the site already has, so nothing changes until you fill it
|
|
78
|
+
in. The Kit never changes your theme.</p>
|
|
79
|
+
<ul>
|
|
80
|
+
<li><strong>Names</strong> - your business name (at the top of every email), a short name, and
|
|
81
|
+
your registered name. With a company or VAT number, emails show the registered name in
|
|
82
|
+
their small print - UK companies must.</li>
|
|
83
|
+
<li><strong>Logos</strong> - your logo, a version for dark backgrounds and a square mark. An SVG
|
|
84
|
+
logo is fine: emails get a PNG copy made from it, which needs the <strong>Site URL</strong>
|
|
85
|
+
on the General tab.</li>
|
|
86
|
+
<li><strong>Colours</strong> - the accent (the line along the top of emails and their buttons)
|
|
87
|
+
and up to four more named colours.</li>
|
|
88
|
+
<li><strong>Type</strong> - a heading font and a body font. Web fonts come from Google Fonts;
|
|
89
|
+
a mail program that cannot load one uses a similar safe font.</li>
|
|
90
|
+
<li><strong>Contact and small print</strong> - contact email, phone, website, address, company
|
|
91
|
+
and VAT numbers, a footer line and any legal small print. Social links come from the
|
|
92
|
+
Footer tool.</li>
|
|
93
|
+
</ul>
|
|
94
|
+
<p>Save, then open <strong>SMTP > Email preview gallery</strong> to see your emails in the
|
|
95
|
+
Kit.</p>
|
|
96
|
+
<p>Once saved, the Kit also fills in what you have left empty elsewhere. Anything you have set
|
|
97
|
+
yourself stays as it is:</p>
|
|
98
|
+
<ul>
|
|
99
|
+
<li><strong>Browser icon</strong> - with no favicon and no brand logo, the Kit's square mark
|
|
100
|
+
(else its logo). With none of those, the letter icon takes the Kit's accent colour.</li>
|
|
101
|
+
<li><strong>Navbar brand</strong> - when the Public site brand has no name, logo or icon, the
|
|
102
|
+
navbar shows the Kit's logo (or, without one, its name).</li>
|
|
103
|
+
<li><strong>Admin and sign-in</strong> - an empty Admin name uses the Kit's name (else the
|
|
104
|
+
site title), and empty admin logos use the Kit's logo and dark logo, on the sign-in screen
|
|
105
|
+
too.</li>
|
|
106
|
+
<li><strong>Chat launchers</strong> - a chat with no colour of its own takes the Kit's accent,
|
|
107
|
+
and one with no picture (and no character) shows the Kit's square mark.</li>
|
|
108
|
+
<li><strong>Sharing</strong> - links shared on social media name the site by the Kit's
|
|
109
|
+
business name.</li>
|
|
110
|
+
</ul>
|
|
111
|
+
<p>The Kit never changes your theme. To make a theme in its colours, open the Theme Roller and
|
|
112
|
+
choose <strong>New theme from Brand Kit</strong>: it makes a new theme for you to look at,
|
|
113
|
+
and nothing changes until you use it.</p>
|
|
114
|
+
|
|
72
115
|
<h3 id="email-identity">Email identity</h3>
|
|
73
116
|
<p>Every email the site sends by itself - account invitations and password resets, form
|
|
74
117
|
notifications, booking and order emails, invoices, survey invitations, Tool notifications and
|
|
75
118
|
more - goes out in one tidy layout: your name and logo at the top, a short label saying what
|
|
76
119
|
kind of email it is, buttons in your colour, and a footer with your support address and a link
|
|
77
120
|
to your site. Each one also has a plain-text version for mail programs that want it.</p>
|
|
78
|
-
<p>It uses your
|
|
79
|
-
fill in <strong>Site Settings > SMTP > Email identity</strong
|
|
121
|
+
<p>It uses your <a href="#brand-kit">Brand Kit</a>. To make email look different from the rest
|
|
122
|
+
of your brand, fill in <strong>Site Settings > SMTP > Email identity</strong> - anything
|
|
123
|
+
set here wins, for email only:</p>
|
|
80
124
|
<ul>
|
|
81
125
|
<li><strong>Email brand name</strong> - the name at the top and in the footer (empty: the site
|
|
82
126
|
name).</li>
|
|
@@ -115,13 +115,103 @@
|
|
|
115
115
|
|
|
116
116
|
<!-- Branding -->
|
|
117
117
|
<div class="tab-panel">
|
|
118
|
+
<div class="stx-card dm-settings-section" id="stx-brand-kit"><div class="stx-card-title dm-settings-section-title"><span data-icon="briefcase" data-icon-size="16" aria-hidden="true"></span>Brand Kit
|
|
119
|
+
<span data-help-title="Brand Kit" data-help="One brand for the whole site. Your emails use it now, and more of Domma will follow. Anything left empty uses what the site already has - the brand name, logo and contact details below and in the Footer tool. Changing the Kit never changes your theme."></span></div>
|
|
120
|
+
<p class="text-muted">Your business's name, logo, colours, fonts and contact details, in one place. Every automated email uses them. Once saved, they also fill whatever you leave empty below and elsewhere: the browser icon, a blank navbar brand, the admin's name and logo (and the sign-in screen), and chat launchers' colour and picture. Your theme is never changed. Leave a Kit field empty to use what the site already has.</p>
|
|
121
|
+
<h4 class="stx-subhead">Names</h4>
|
|
122
|
+
<div class="stx-grid">
|
|
123
|
+
<div><label class="form-label" for="stx-kitName">Business name
|
|
124
|
+
<span data-help="The name your customers know you by. Shown at the top of every email. Empty: the brand name below, else the site title."></span></label>
|
|
125
|
+
<input id="stx-kitName" type="text" class="form-input" placeholder="Uses the brand name or site title" data-model="kitName.value"></div>
|
|
126
|
+
<div><label class="form-label" for="stx-kitShortName">Short name
|
|
127
|
+
<span data-help="A shorter form for small spaces, such as Acme for Acme Tools Ltd."></span></label>
|
|
128
|
+
<input id="stx-kitShortName" type="text" class="form-input" placeholder="Uses the business name" data-model="kitShortName.value"></div>
|
|
129
|
+
<div><label class="form-label" for="stx-kitLegalName">Registered name
|
|
130
|
+
<span data-help="Your registered company name. With a company number or VAT number, emails show it in their small print - UK companies must show it."></span></label>
|
|
131
|
+
<input id="stx-kitLegalName" type="text" class="form-input" placeholder="Acme Tools Ltd" data-model="kitLegalName.value"></div>
|
|
132
|
+
</div>
|
|
133
|
+
<h4 class="stx-subhead">Logos</h4>
|
|
134
|
+
<div class="stx-grid">
|
|
135
|
+
<div><label class="form-label" for="stx-kitLogo">Logo
|
|
136
|
+
<span data-help="Your main logo. An SVG logo works: emails get a PNG copy made from it (this needs the Site URL on the General tab)."></span></label>
|
|
137
|
+
<input id="stx-kitLogo" type="text" class="form-input" placeholder="Uses the public site logo" data-model="kitLogo.value">
|
|
138
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="pickBrandImage('kitLogo')">Choose or upload image</button>
|
|
139
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="clearBrandImage('kitLogo')">Remove</button>
|
|
140
|
+
<img data-bind-src="kitLogo.value" data-bind-hidden="!kitLogo.value" alt="Logo preview" style="display:block;max-width:180px;max-height:80px;object-fit:contain;margin-top:.75rem;">
|
|
141
|
+
</div>
|
|
142
|
+
<div><label class="form-label" for="stx-kitLogoDark">Logo for dark backgrounds
|
|
143
|
+
<span data-help="A version of the logo that reads well on a dark background."></span></label>
|
|
144
|
+
<input id="stx-kitLogoDark" type="text" class="form-input" placeholder="Optional" data-model="kitLogoDark.value">
|
|
145
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="pickBrandImage('kitLogoDark')">Choose or upload image</button>
|
|
146
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="clearBrandImage('kitLogoDark')">Remove</button>
|
|
147
|
+
<img data-bind-src="kitLogoDark.value" data-bind-hidden="!kitLogoDark.value" alt="Logo for dark backgrounds preview" style="display:block;max-width:180px;max-height:80px;object-fit:contain;margin-top:.75rem;background:#1f2937;padding:6px;border-radius:6px;">
|
|
148
|
+
</div>
|
|
149
|
+
<div><label class="form-label" for="stx-kitMark">Square mark
|
|
150
|
+
<span data-help="A square version - just the symbol - for small places such as avatars."></span></label>
|
|
151
|
+
<input id="stx-kitMark" type="text" class="form-input" placeholder="Optional" data-model="kitMark.value">
|
|
152
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="pickBrandImage('kitMark')">Choose or upload image</button>
|
|
153
|
+
<button type="button" class="btn btn-sm btn-ghost" data-on-click="clearBrandImage('kitMark')">Remove</button>
|
|
154
|
+
<img data-bind-src="kitMark.value" data-bind-hidden="!kitMark.value" alt="Square mark preview" style="display:block;max-width:180px;max-height:80px;object-fit:contain;margin-top:.75rem;">
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
<h4 class="stx-subhead">Colours</h4>
|
|
158
|
+
<div class="stx-grid">
|
|
159
|
+
<div><label class="form-label" for="stx-kitAccent">Accent colour
|
|
160
|
+
<span data-help="The colour of the line along the top of emails and of their buttons, as six digits such as #2563eb. Button text turns black or white to stay readable. It does not change your theme."></span></label>
|
|
161
|
+
<input id="stx-kitAccent" type="text" class="form-input" placeholder="#2563eb" data-model="kitAccent.value"></div>
|
|
162
|
+
<div class="stx-wide"><label class="form-label">Other brand colours
|
|
163
|
+
<span data-help="Up to four more of your brand's colours, each with a name, for Tools that use them. They do not change your theme."></span></label>
|
|
164
|
+
<div class="stx-inline"><input id="stx-kitColour1Name" type="text" class="form-input" aria-label="Colour 1 name" placeholder="Name, such as Sea green" data-model="kitColour1Name.value"><input id="stx-kitColour1Hex" type="text" class="form-input" aria-label="Colour 1" placeholder="#0f766e" pattern="#[0-9a-fA-F]{6}" data-model="kitColour1Hex.value"></div>
|
|
165
|
+
<div class="stx-inline"><input id="stx-kitColour2Name" type="text" class="form-input" aria-label="Colour 2 name" placeholder="Name, such as Sea green" data-model="kitColour2Name.value"><input id="stx-kitColour2Hex" type="text" class="form-input" aria-label="Colour 2" placeholder="#0f766e" pattern="#[0-9a-fA-F]{6}" data-model="kitColour2Hex.value"></div>
|
|
166
|
+
<div class="stx-inline"><input id="stx-kitColour3Name" type="text" class="form-input" aria-label="Colour 3 name" placeholder="Name, such as Sea green" data-model="kitColour3Name.value"><input id="stx-kitColour3Hex" type="text" class="form-input" aria-label="Colour 3" placeholder="#0f766e" pattern="#[0-9a-fA-F]{6}" data-model="kitColour3Hex.value"></div>
|
|
167
|
+
<div class="stx-inline"><input id="stx-kitColour4Name" type="text" class="form-input" aria-label="Colour 4 name" placeholder="Name, such as Sea green" data-model="kitColour4Name.value"><input id="stx-kitColour4Hex" type="text" class="form-input" aria-label="Colour 4" placeholder="#0f766e" pattern="#[0-9a-fA-F]{6}" data-model="kitColour4Hex.value"></div>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
<h4 class="stx-subhead">Type</h4>
|
|
171
|
+
<div class="stx-grid">
|
|
172
|
+
<div><label class="form-label" for="stx-kitFontHeading">Heading font
|
|
173
|
+
<span data-help="For headings, such as an email's title. Web fonts come from Google Fonts; mail programs that cannot load one use a similar safe font."></span></label>
|
|
174
|
+
<select id="stx-kitFontHeading" class="form-select" data-model="kitFontHeading.value"><option value="">Site default</option><option value="arial">Arial</option><option value="helvetica">Helvetica</option><option value="verdana">Verdana</option><option value="tahoma">Tahoma</option><option value="trebuchet">Trebuchet MS</option><option value="georgia">Georgia</option><option value="times">Times New Roman</option><option value="inter">Inter</option><option value="roboto">Roboto</option><option value="open-sans">Open Sans</option><option value="lato">Lato</option><option value="montserrat">Montserrat</option><option value="poppins">Poppins</option><option value="nunito">Nunito</option><option value="merriweather">Merriweather</option><option value="playfair-display">Playfair Display</option><option value="source-serif">Source Serif 4</option></select></div>
|
|
175
|
+
<div><label class="form-label" for="stx-kitFontBody">Body font
|
|
176
|
+
<span data-help="For the words of an email and its footer."></span></label>
|
|
177
|
+
<select id="stx-kitFontBody" class="form-select" data-model="kitFontBody.value"><option value="">Site default</option><option value="arial">Arial</option><option value="helvetica">Helvetica</option><option value="verdana">Verdana</option><option value="tahoma">Tahoma</option><option value="trebuchet">Trebuchet MS</option><option value="georgia">Georgia</option><option value="times">Times New Roman</option><option value="inter">Inter</option><option value="roboto">Roboto</option><option value="open-sans">Open Sans</option><option value="lato">Lato</option><option value="montserrat">Montserrat</option><option value="poppins">Poppins</option><option value="nunito">Nunito</option><option value="merriweather">Merriweather</option><option value="playfair-display">Playfair Display</option><option value="source-serif">Source Serif 4</option></select></div>
|
|
178
|
+
</div>
|
|
179
|
+
<h4 class="stx-subhead">Contact and small print</h4>
|
|
180
|
+
<div class="stx-grid">
|
|
181
|
+
<div><label class="form-label" for="stx-kitEmail">Contact email
|
|
182
|
+
<span data-help="Where customers can write to you. Shown in the footer of every email."></span></label>
|
|
183
|
+
<input id="stx-kitEmail" type="email" class="form-input" placeholder="Uses the site contact email" data-model="kitEmail.value"></div>
|
|
184
|
+
<div><label class="form-label" for="stx-kitPhone">Phone
|
|
185
|
+
<span data-help="Your public phone number."></span></label>
|
|
186
|
+
<input id="stx-kitPhone" type="tel" class="form-input" placeholder="0113 496 0000" data-model="kitPhone.value"></div>
|
|
187
|
+
<div><label class="form-label" for="stx-kitWebsite">Website
|
|
188
|
+
<span data-help="Your website address, if it is not this site."></span></label>
|
|
189
|
+
<input id="stx-kitWebsite" type="url" class="form-input" placeholder="Uses the Site URL" data-model="kitWebsite.value"></div>
|
|
190
|
+
<div><label class="form-label" for="stx-kitCompanyNumber">Company number
|
|
191
|
+
<span data-help="Your registered company number, shown in email small print with the registered name."></span></label>
|
|
192
|
+
<input id="stx-kitCompanyNumber" type="text" class="form-input" placeholder="01234567" data-model="kitCompanyNumber.value"></div>
|
|
193
|
+
<div><label class="form-label" for="stx-kitVatNumber">VAT number
|
|
194
|
+
<span data-help="Your VAT registration number, if you have one."></span></label>
|
|
195
|
+
<input id="stx-kitVatNumber" type="text" class="form-input" placeholder="GB123456789" data-model="kitVatNumber.value"></div>
|
|
196
|
+
<div class="stx-wide"><label class="form-label" for="stx-kitAddress">Address
|
|
197
|
+
<span data-help="Your registered or trading address."></span></label>
|
|
198
|
+
<textarea id="stx-kitAddress" class="form-input" rows="2" placeholder="Uses the address in the Footer tool" data-model="kitAddress.value"></textarea></div>
|
|
199
|
+
<div class="stx-wide"><label class="form-label" for="stx-kitFooterLine">Footer line
|
|
200
|
+
<span data-help="One line shown in the footer of every email, under your name."></span></label>
|
|
201
|
+
<input id="stx-kitFooterLine" type="text" class="form-input" placeholder="A short sign-off or line of contact details" data-model="kitFooterLine.value"></div>
|
|
202
|
+
<div class="stx-wide"><label class="form-label" for="stx-kitSmallPrint">Small print
|
|
203
|
+
<span data-help="Any legal wording your emails must carry. Shown in small type at the very bottom."></span></label>
|
|
204
|
+
<textarea id="stx-kitSmallPrint" class="form-input" rows="2" placeholder="Optional legal text" data-model="kitSmallPrint.value"></textarea></div>
|
|
205
|
+
</div>
|
|
206
|
+
<p class="text-muted">To start a theme in these colours, open the Theme Roller and choose New theme from Brand Kit. Social links come from the <a href="#/footer">Footer tool</a>. Email-only changes - a different name or logo just for email - go under the SMTP tab's Email identity.</p>
|
|
207
|
+
</div>
|
|
118
208
|
<div class="stx-card-columns">
|
|
119
209
|
<div class="stx-card dm-settings-section"><div class="stx-card-title dm-settings-section-title"><span data-icon="globe" data-icon-size="16" aria-hidden="true"></span>Public site</div><div class="stx-grid">
|
|
120
210
|
<div class="stx-setting stx-wide"><label class="form-label" for="stx-brand-enabled">Show public site branding
|
|
121
211
|
<span data-help="Shows the name and mark in the navbar and footer. Off hides them and keeps the saved values for next time."></span></label>
|
|
122
212
|
<input id="stx-brand-enabled" type="checkbox" class="form-switch" data-model="brandEnabled.value"></div>
|
|
123
213
|
<div><label class="form-label" for="stx-brandText">Brand name</label>
|
|
124
|
-
<input id="stx-brandText" type="text" class="form-input" placeholder="My Site" data-model="brandText.value">
|
|
214
|
+
<input id="stx-brandText" type="text" class="form-input" placeholder="My Site - with logo and icon empty, the Brand Kit's name" data-model="brandText.value">
|
|
125
215
|
</div>
|
|
126
216
|
<div><label class="form-label" for="stx-brandUrl">Brand link</label>
|
|
127
217
|
<input id="stx-brandUrl" type="text" class="form-input" placeholder="/" data-model="brandUrl.value">
|
|
@@ -136,14 +226,14 @@
|
|
|
136
226
|
<div data-brand-icon="brandIcon"></div>
|
|
137
227
|
</div>
|
|
138
228
|
|
|
139
|
-
</div><p class="text-muted">The logo takes priority over the icon. Set the browser icon in <a href="#/appearance?tab=favicon">Appearance > Favicon</a
|
|
229
|
+
</div><p class="text-muted">The logo takes priority over the icon. With name, logo and icon all empty, the navbar shows the Brand Kit's logo (else its name). Set the browser icon in <a href="#/appearance?tab=favicon">Appearance > Favicon</a> - without one, the Brand Kit's square mark or logo is used.</p></div>
|
|
140
230
|
<div class="stx-card dm-settings-section"><div class="stx-card-title dm-settings-section-title"><span data-icon="layout" data-icon-size="16" aria-hidden="true"></span>Admin
|
|
141
|
-
<span data-help-title="Admin name and mark" data-help="The name and logo or icon at the top of the admin - in the top bar, the sidebar and the browser tab - for everyone who signs in. Leave the name empty to use the site title."></span></div><div class="stx-grid">
|
|
231
|
+
<span data-help-title="Admin name and mark" data-help="The name and logo or icon at the top of the admin - in the top bar, the sidebar and the browser tab - for everyone who signs in. Leave the name empty to use the Brand Kit's name (else the site title); leave the logos empty to use the Brand Kit's."></span></div><div class="stx-grid">
|
|
142
232
|
<div class="stx-setting stx-wide"><label class="form-label" for="stx-admin-brand-enabled">Show admin branding
|
|
143
233
|
<span data-help="Shows the name and mark in the admin top bar and sidebar, and the name in browser tab titles. Off hides them and keeps the saved values."></span></label>
|
|
144
234
|
<input id="stx-admin-brand-enabled" type="checkbox" class="form-switch" data-model="adminBrandEnabled.value"></div>
|
|
145
235
|
<div><label class="form-label" for="stx-adminBrandTitle">Admin name</label>
|
|
146
|
-
<input id="stx-adminBrandTitle" type="text" class="form-input" placeholder="Uses the site title
|
|
236
|
+
<input id="stx-adminBrandTitle" type="text" class="form-input" placeholder="Uses the Brand Kit's name, else the site title" data-model="adminBrandTitle.value">
|
|
147
237
|
</div>
|
|
148
238
|
<div><label class="form-label" for="stx-adminBrandLogo">Admin logo image</label>
|
|
149
239
|
<input id="stx-adminBrandLogo" type="text" class="form-input" placeholder="/media/logo.png" data-model="adminBrandLogo.value">
|
|
@@ -168,12 +258,12 @@
|
|
|
168
258
|
<div class="tab-panel">
|
|
169
259
|
<div class="stx-card dm-settings-section">
|
|
170
260
|
<div class="stx-card-title dm-settings-section-title">Email identity</div>
|
|
171
|
-
<p class="text-muted">Automated emails
|
|
261
|
+
<p class="text-muted">Automated emails use your <a href="#/settings?tab=branding">Brand Kit</a> on the Branding tab. Fill these only when email should look different. Use a PNG or JPEG logo here; save before sending a test.</p>
|
|
172
262
|
<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="
|
|
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="
|
|
263
|
+
<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="Uses the Brand Kit"></div>
|
|
264
|
+
<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="Uses the Brand Kit 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
265
|
<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="
|
|
266
|
+
<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="Uses the Brand Kit contact email"></div>
|
|
177
267
|
<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
268
|
</div>
|
|
179
269
|
</div>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{api as
|
|
1
|
+
import{api as q,apiRequest as v}from"../api.js";import{placeTools as qe,WITHHELD_URL as $e}from"../lib/sidebar-grouping.js";import{addBannerAction as he}from"../lib/plugin-chrome.js";import{helpPopovers as De}from"../lib/help-popover.js";import{openMenuAt as G,sidebarCount as ve}from"../lib/tool-kit.js";import{brandKitFormError as be,brandKitFromForm as He,changedTabs as je,describeCacheKey as Q,draftOf as Ke,expiresIn as Ue,formFromDraft as Fe,siteSettingsForm as _e,homeValue as We,siteSettingsPayload as ye,siteUrlError as ge,settingsProblems as Ne,snapshot as we,TAB_FIELDS as ze}from"../lib/site-settings-arrange.js";import{pickMedia as Ve}from"../lib/media-picker.js";import{makeIconInput as Ye}from"../lib/shortcode-modal.js";import{fmtDateTime as Je}from"../lib/dates.js";const X=/^\/settings(\?.*)?$/,ke="#/settings",g="settings.draft",Ge=`
|
|
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>`,
|
|
6
|
+
</div>`,Qe=`
|
|
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>`,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()))}}};
|
|
11
|
+
</div>`,$=["general","branding","email","cookies","cache"];async function Xe(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($e)||(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,Ee=!1;function Ze(){Ee||!window.R?.use||(Ee=!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(Ze(),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 q.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=_e(p||{}),s={};for(const[e,t]of Object.entries(r))s[e]=M.observable(t);const D=()=>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),K=M.computed(()=>we(b.value)),x=M.computed(()=>we(D())!==K.value),C=M.observable(!1),T=M.observable(""),Z=M.observable(!1);q.plugins.policy().then(e=>{o()&&(Z.value=e?.signedOnly===!1)}).catch(()=>{});const U=M.observable(!1),ee=M.computed(()=>{const e=new Set(je(D(),b.value));return Object.fromEntries(Object.keys(ze).map(t=>[t,e.has(t)]))}),F=M.observable([]);i(M.effect(()=>{F.value=Ne(D(),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),_=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=[..._.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:Ue(a.expiresAt,t)}})}));const se=M.observable(!1);v("/ai-assist").catch(()=>null).then(e=>{o()&&(se.value=e?.on===!0)});const Se={...s,saving:C,dirty:x,tabs:ee,problems:F,testTo:te,testing:O,testResult:L,testTone:A,aiAssistOn:se,cacheQuery:W,cacheLoading:N,cacheError:z,cacheRows:ae,errorText:T,problemsText:M.computed(()=>F.value.length?"yes":""),siteUrlError:M.computed(()=>ge(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=ge(e.siteUrl);if(a){E.toast(`Site URL: ${a}`,{type:"error"});return}const c=be(e);if(c){E.toast(`Brand Kit: ${c}`,{type:"error"});return}C.value=!0,T.value="";const Be=String(e.title).trim()!==String(t.title).trim();try{await q.settings.save(ye(e,u.peek(),{adminHomeReady:U.peek()})),window.dispatchEvent(new Event("admin-assistant:settings"));const P=await q.settings.get().catch(()=>null);if(!o())return;P&&(u.value=P);const Pe={...e,smtpPass:""};s.smtpPass.value="",b.value=Pe;try{S.remove?S.remove(g):S.set(g,null)}catch{}document.dispatchEvent(new CustomEvent("dm:admin-home-changed")),(Be||["adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"].some(fe=>e[fe]!==t[fe]))&&document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild")),ve(ke),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 xe(){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 Me(){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 Ce(){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:ye(t,u.peek()).emailBrand,...!be(t)&&{brandKit:He(t)}})});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 B(){N.value=!0;try{const[e,t]=await Promise.all([v("/cache/status").catch(()=>null),v("/cache/keys")]);if(!o())return;m.value=e,_.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 Te(){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 B()}}async function Oe(){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(ke)}catch(t){E.toast(t.message||"Could not change the cache.",{type:"error"})}o()&&await B()}}const re=e=>_.peek().find(t=>t.key===e);function Le(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=Ge;const y=n.querySelector(".stx-list");y.innerHTML=Qe;const Y=E.tabs(n.querySelector(".stx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),ie=new URLSearchParams(location.hash.split("?")[1]||"").get("tab");$.includes(ie)&&Y.activate($.indexOf(ie));const Re=M.applyBindings(Se,n,{methods:{save:V,discard:xe,sendTest:Me,previewEmail:Ce,refreshCache:B,clearCache:Te,toggleCache:Oe,pickBrandImage:async e=>{const t=await Ve({title:"Choose a branding image",current:s[e].peek()});t&&o()&&(s[e].value=t)},clearBrandImage:e=>{s[e].value=""},goTab:e=>{const t=$.indexOf(e);t>=0&&Y.activate(t)}}});i(()=>Re.dispose());for(const e of n.querySelectorAll("[data-brand-icon]")){const t=e.dataset.brandIcon,a=Ye("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(De(n,{position:"bottom"}));const Ie=e=>{const t=e.target.closest("[data-go]");if(!t)return;const a=$.indexOf(t.dataset.go);a>=0&&Y.activate(a)};n.querySelector(".stx-problems").addEventListener("click",Ie);const J=n.querySelector("#stx-admin-home");Xe(J,We(s.adminHome.peek())).then(()=>{o()&&(J.value=s.adminHome.peek(),U.value=!0)}).catch(()=>{});const Ae=E.contextMenu(y,{cursor:"glyph",match:".stx-row",inherit:!1,density:"compact",items:e=>Le(e.dataset.id)});i(()=>Ae?.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:Ke(j()),base:K.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),B();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!==K.peek(),t=h.at?` (${Je(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(Fe(b.peek(),h.form)),U.peek()&&(J.value=s.adminHome.peek()))}}};
|