domma-cms 1.79.0 → 1.81.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 +24 -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 +29 -3
- package/admin/js/templates/settings.html +94 -4
- 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/admin/mail/attach-arrange.js +132 -5
- package/plugins/_lib/admin/mail/body-menu.js +1 -1
- package/plugins/_lib/admin/mail/cms-attach.js +79 -7
- package/plugins/_lib/admin/mail/cms-host.js +1 -1
- package/plugins/_lib/admin/mail/compose-window.js +15 -5
- package/plugins/_lib/admin/mail/contacts.js +1 -1
- package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
- package/plugins/_lib/admin/mail/drag-drop.js +33 -1
- package/plugins/_lib/admin/mail/folder-tree.js +1 -1
- package/plugins/_lib/admin/mail/font-controls.js +1 -1
- package/plugins/_lib/admin/mail/fonts.js +1 -1
- package/plugins/_lib/admin/mail/host-context.js +1 -1
- package/plugins/_lib/admin/mail/identity.js +1 -1
- package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
- package/plugins/_lib/admin/mail/keyboard.js +1 -1
- package/plugins/_lib/admin/mail/mail.html +1 -1
- package/plugins/_lib/admin/mail/message-actions.js +1 -1
- package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
- package/plugins/_lib/admin/mail/panes.js +1 -1
- package/plugins/_lib/admin/mail/reader-kit.js +1 -1
- package/plugins/_lib/admin/mail/reader-runtime.js +119 -63
- package/plugins/_lib/admin/mail/reader-view.js +1 -1
- package/plugins/_lib/admin/mail/resizable.js +1 -1
- package/plugins/_lib/admin/mail/restore-spam.js +1 -1
- package/plugins/_lib/admin/mail/rules.js +1 -1
- package/plugins/_lib/admin/mail/scheduling.js +1 -1
- package/plugins/_lib/admin/mail/section-kit.js +1 -1
- package/plugins/_lib/admin/mail/security-note.js +1 -1
- package/plugins/_lib/admin/mail/settings-section.js +6 -3
- package/plugins/_lib/admin/mail/templates.js +1 -1
- package/plugins/_lib/admin/mail/threads.js +1 -1
- package/plugins/_lib/admin/mail/vacation.js +1 -1
- package/plugins/_lib/admin/mail/when-closed.js +1 -1
- package/plugins/_lib/admin/ui/dates.js +1 -1
- package/plugins/_lib/admin/ui/resizable.js +1 -1
- package/plugins/_lib/admin/ui/rich-field.js +1 -1
- package/plugins/_lib/domma-mail.lock.json +85 -85
- package/plugins/_lib/mail/accountFileStore.js +1 -1
- package/plugins/_lib/mail/accountRepository.js +41 -2
- package/plugins/_lib/mail/accountRoutes.js +1 -1
- package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
- package/plugins/_lib/mail/bodyTokens.js +1 -1
- package/plugins/_lib/mail/compose.js +1 -1
- package/plugins/_lib/mail/defaults.js +1 -1
- package/plugins/_lib/mail/envelope.js +1 -1
- package/plugins/_lib/mail/folderActions.js +1 -1
- package/plugins/_lib/mail/folderRuntime.js +1 -1
- package/plugins/_lib/mail/folders.js +1 -1
- package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
- package/plugins/_lib/mail/mbox.js +1 -1
- package/plugins/_lib/mail/message-action.js +1 -1
- package/plugins/_lib/mail/messageSecurity.js +1 -1
- package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
- package/plugins/_lib/mail/networkAddresses.js +1 -1
- package/plugins/_lib/mail/networkPolicy.js +1 -1
- package/plugins/_lib/mail/oauthAccounts.js +1 -1
- package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
- package/plugins/_lib/mail/oauthRuntime.js +1 -1
- package/plugins/_lib/mail/pollSchedule.js +1 -1
- package/plugins/_lib/mail/poller.js +1 -1
- package/plugins/_lib/mail/pollerRuntime.js +1 -1
- package/plugins/_lib/mail/priority.js +1 -1
- package/plugins/_lib/mail/publicMailbox.js +1 -1
- package/plugins/_lib/mail/readRuntime.js +1 -1
- package/plugins/_lib/mail/render.js +1 -1
- package/plugins/_lib/mail/ruleRunner.js +1 -1
- package/plugins/_lib/mail/schedulerRuntime.js +1 -1
- package/plugins/_lib/mail/secretProvider.js +1 -1
- package/plugins/_lib/mail/secretbox.js +1 -1
- package/plugins/_lib/mail/senderAuth.js +1 -1
- package/plugins/_lib/mail/sieve.js +1 -1
- package/plugins/_lib/mail/smtpService.js +1 -1
- package/plugins/_lib/mail/snoozeRuntime.js +1 -1
- package/plugins/_lib/mail/store.js +1 -1
- package/plugins/_lib/mail/subscriptions.js +1 -1
- package/plugins/_lib/mail/syncPlan.js +1 -1
- package/plugins/_lib/mail/syncRuntime.js +1 -1
- package/plugins/_lib/mail/syncSelection.js +1 -1
- package/plugins/_lib/mail/unreadBadge.js +1 -1
- package/plugins/_lib/mail/unsubscribe.js +1 -1
- package/plugins/_lib/mail/vacationRuntime.js +1 -1
- package/plugins/_lib/mail/write.js +1 -1
- package/plugins/_lib/public/rich-text.mjs +1 -1
- package/plugins/_lib/rich-text.js +1 -1
- package/plugins/_lib/telegram/bot.js +120 -0
- package/plugins/free-tier.lock.json +26 -1
- 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/server/routes/api/brand-kit.js +55 -0
- package/server/routes/api/settings.js +17 -1
- package/server/server.js +2 -0
- package/server/services/brandKit.js +268 -0
- package/server/services/emailBrand.js +31 -13
- package/server/services/notify.js +20 -2
- package/server/services/plugins.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.81.0] - 2026-11-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **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.
|
|
8
|
+
- **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.
|
|
9
|
+
- **`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.
|
|
10
|
+
|
|
11
|
+
- **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.
|
|
12
|
+
- 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.
|
|
13
|
+
- `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()`.
|
|
14
|
+
- Needs attention: an SVG logo with no Site URL (emails would show the name instead).
|
|
15
|
+
|
|
16
|
+
## [1.80.0] - 2026-11-19
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **Email: send File Store files as links** (Domma Mail core 0.38.0). In the compose window's File Store chooser, Send as links makes a File Store Pro share link per file (7, 30 or 90 days, no password) and writes it into the message instead of attaching. Needs File Store Pro and its Share links permission. Links are listed and can be revoked under Links in the File Store.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- **Email: bulk actions refresh the list.** Mark read/unread, Star, Spam and Delete on a selection reload the counts and the list, keeping the same search, page and view; Undo does the same. Actions on search results across folders go to each message's own folder.
|
|
25
|
+
- Mail settings and the account store take Domma Mail core 0.38.0 (Composing preferences groundwork).
|
|
26
|
+
|
|
3
27
|
## [1.79.0] - 2026-11-19
|
|
4
28
|
|
|
5
29
|
### 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,38 @@
|
|
|
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
|
+
|
|
72
97
|
<h3 id="email-identity">Email identity</h3>
|
|
73
98
|
<p>Every email the site sends by itself - account invitations and password resets, form
|
|
74
99
|
notifications, booking and order emails, invoices, survey invitations, Tool notifications and
|
|
75
100
|
more - goes out in one tidy layout: your name and logo at the top, a short label saying what
|
|
76
101
|
kind of email it is, buttons in your colour, and a footer with your support address and a link
|
|
77
102
|
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
|
|
103
|
+
<p>It uses your <a href="#brand-kit">Brand Kit</a>. To make email look different from the rest
|
|
104
|
+
of your brand, fill in <strong>Site Settings > SMTP > Email identity</strong> - anything
|
|
105
|
+
set here wins, for email only:</p>
|
|
80
106
|
<ul>
|
|
81
107
|
<li><strong>Email brand name</strong> - the name at the top and in the footer (empty: the site
|
|
82
108
|
name).</li>
|
|
@@ -115,6 +115,96 @@
|
|
|
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. Leave a 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">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
|
|
@@ -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()))}}};
|
package/docs/DommaFeatures.md
CHANGED
|
@@ -79,6 +79,8 @@ Code was treated as the truth. Where docs disagree with it, the disagreement is
|
|
|
79
79
|
| `support` | free | 1.3.0 | Help from Domma in the admin: Domma's email, phone and hours always to hand, and a request as a conversation with the Domma team, urgent ones first. On the Domma server, AI Assist summarises a request, suggests a reply and groups waiting requests into themes. |
|
|
80
80
|
| `surveys` | paid | 1.19.2 | Targeted surveys over the Forms engine: shared audiences and Contacts groups, tokenised invites, reminders, NPS, star, smiley and number scales, quiz mode with scores, closing rules, and Results with charts, filters, Live refresh, a printable PDF report and (with AI Assist) themed summaries of free-text answers. |
|
|
81
81
|
| `sweepstake` | paid (giftable) | 1.0.0 | Office, pub and club sweepstakes for any event: picks, entry fee and prizes, entrants by name with paid ticks, and one recorded, repeatable draw revealed live on the page, then who has what and the money. |
|
|
82
|
+
| `telegram` | free | 0.1.0 | Your own Telegram bot sends the team the site's alerts and form submissions - to a group or one person's chat, each chat choosing which alerts (how serious, from which Tools) and which forms, with the answers or the title and a link only. |
|
|
83
|
+
| `telegram-pro` | paid | 0.1.0 | Two-way customer chat on Telegram: an Inbox in the admin with an unread badge, an optional staff group where a reply to a copied message answers the customer, a "Message us on Telegram" button, /stop and a retention period. Needs the free Telegram Tool. |
|
|
82
84
|
| `theme-roller` | paid | 1.3.0 | Make your own themes: start from any built-in theme, change its colours, fonts, spacing and borders with a live preview, and save it. Saved themes join the built-in ones everywhere a theme is chosen - the site, the admin, day and night, a region of a page. Needs Domma CMS 0.73 or later to use them. |
|
|
83
85
|
| `timeline` | paid (giftable) | 1.1.0 | Put events in date order: all at once (Sort) or one at a time into a growing timeline with lives (Place). Years, months or full dates, BC too; dates stay on the server until a card is placed. Shortcode `[timeline-game]`. |
|
|
84
86
|
| `treasure-hunt` | paid (giftable) | 1.1.0 | Hide 2-30 tokens across your pages and send visitors looking for them, in any order or one clue at a time. A progress chip follows players from page to page; finishers get a prize message and a code (one for all, or a unique code each). First-to-finish or fastest leaderboard. |
|
|
@@ -1143,6 +1145,8 @@ Where: `server/services/presetCollections.js` (`PRESETS`, `seedAll()`), `server/
|
|
|
1143
1145
|
Where: `POST /api/system/notifications` (`MANAGER_SECRET`, `server/middleware/managerAuth.js`).
|
|
1144
1146
|
- **Plugin API** - Plugins can raise notifications, resolve them and register their own sources through hooks: `notify()`, `resolveNotification()` and `registerNotificationSource()`, with `every: boot | 15m | hourly | daily` (daily runs at 08:00).
|
|
1145
1147
|
Since: 0.80.0.
|
|
1148
|
+
- **`notification:raised` event** - Every stored notification (and a repeat that grew worse) is emitted on the hook bus with the stored entry, so a Tool can pass it on; the Telegram Tool sends them to linked chats by severity and source, never personal ones.
|
|
1149
|
+
Where: `server/services/notify.js` - Unreleased.
|
|
1146
1150
|
|
|
1147
1151
|
### In-admin documentation
|
|
1148
1152
|
|
|
@@ -1453,7 +1457,9 @@ The four Tools below were plugins until 0.67.0 and are now part of the CMS. They
|
|
|
1453
1457
|
Where: `server/services/publicCors.js`.
|
|
1454
1458
|
- **Email service** - A Nodemailer transport built from the SMTP settings in `site.json`, used for form emails, password resets and notices. With no SMTP host set, mail goes to a throwaway Ethereal test inbox, which reports success but delivers to nobody. The CMS makes this visible in Settings, in health checks and with an "Email not set up" notification. New sites ship with an SMTP host, defaulting to a local mail server on port 25 or taken from the environment.
|
|
1455
1459
|
Where: `server/services/email.js`, `bin/lib/smtp-defaults.js`, `POST /api/settings/test-email` - Since: 0.55.0.
|
|
1456
|
-
- **
|
|
1460
|
+
- **Brand Kit** - one site-wide brand under **Site Settings > Branding > Brand Kit** (`site.json` `brandKit`): business name, short name and registered name; logo, logo for dark backgrounds and a square mark (Media or https); accent colour and up to four named brand colours; heading and body fonts (safe fonts and Google fonts with safe fallbacks); contact email, phone, address, website, company number and VAT number; a footer line and small print. Every empty field falls back to what the site already had (`brand.text`/`title`, `brand.logo`/`logo`, `contactEmail`/footer email, the footer address, `baseUrl`), so sites look the same until the Kit is filled in - no migration. The Kit never changes the theme (its colours are not theme tokens). Automated emails read it (below); plugins read it with `hooks.brandKit()` (resolved, fallbacks applied); anyone can read the public parts at `GET /api/brand-kit` (absolute addresses, never SMTP or private settings). An SVG logo gets a PNG copy for mail programs at `GET /api/brand-kit/logo.png` (sharp, 480x192 max, cached; needs the Site URL - Needs attention says so otherwise). Next phases (Email Pro "Site" branding, website defaults, Tools, the Manager): `docs/plans/2026-11-19-brand-kit-design.md`.
|
|
1461
|
+
Where: `server/services/brandKit.js`, `server/routes/api/brand-kit.js`, `brandKitFromForm()` in `admin/js/lib/site-settings-arrange.js` - Since: unreleased.
|
|
1462
|
+
- **One email look for every automated email** - Account invitations, password resets and security alerts, form notifications, automations, call invites, bookings and calendar mail, order and account emails from the Shop, invoices and quotes, Support, Docs and signing, Waypoint, Job Board, Surveys, Onboard, Campaigns layouts, Ecards, prize and game emails, SEO reports and Wiki updates all go out in one shared, mobile-friendly frame: the site's name and logo at the top, a label for the kind of email (Your account, Bookings, Your order...), an accent line and buttons in the site's colour, and a footer with the support address and a link to the site. Every email keeps a full plain-text version. It reads the **Brand Kit** (Site Settings > Branding; the footer also carries the registered name, company and VAT numbers, address and small print, and the Kit's fonts); **Site Settings > SMTP > Email identity** overrides it for email only - brand name, logo (PNG or JPEG; an SVG site logo falls back to the name), accent colour, support email and a footer line. The **Email preview gallery** beside it shows each kind with sample data and can send a test. Mail people write themselves (Email, Campaigns content) is never wrapped; an email already in one of Email Pro's brandings (an invoice sent in a brand) is not framed twice.
|
|
1457
1463
|
Where: `server/services/emailBrand.js` (`brandEmail`, `emailBrand`, `EMAIL_FAMILIES`), `sendEmail(transport, {branding: {family}})` in `server/services/email.js`, `server/services/emailExamples.js`, Settings > SMTP - Since: 1.78.0.
|
|
1458
1464
|
|
|
1459
1465
|
---
|
|
@@ -1707,7 +1713,7 @@ Handed to `plugin.js` as `options.hooks` (bound to the plugin's name where it ma
|
|
|
1707
1713
|
|
|
1708
1714
|
Also exported from `server/services/hooks.js` but **not** handed over in `options.hooks`: `hideSidebarUrl(url)`, `unregisterCalendarSource`, `unregisterRelatedItems`, `unregisterSitemapSource`.
|
|
1709
1715
|
|
|
1710
|
-
**Events on the bus:** `content:pageCreated`, `content:pageUpdated`, `content:pageDeleted`, `content:pageRenamed`, `content:pageViewed`, `content:mediaUploaded`, `content:mediaDeleted`, `collection:entryCreated`, `collection:entryUpdated`, `collection:entryDeleted`, `form:submitted`, `user:loggedIn`, `user:deleted`, `contact:deleted`, `note:deleted`, `auth:loginSucceeded`, `auth:loginFailed`, `auth:loggedOut`, `auth:rateLimited`, `auth:passwordChanged`, `auth:resetRequested`, `auth:resetIssued`, and `audit` (every successful POST/PUT/PATCH/DELETE under `/api/` by a signed-in user - `{actor, action, route, target, fields, status, ip}`; core stores nothing, Security Pro keeps the trail).
|
|
1716
|
+
**Events on the bus:** `content:pageCreated`, `content:pageUpdated`, `content:pageDeleted`, `content:pageRenamed`, `content:pageViewed`, `content:mediaUploaded`, `content:mediaDeleted`, `collection:entryCreated`, `collection:entryUpdated`, `collection:entryDeleted`, `form:submitted`, `notification:raised` (the stored notification entry, for a new one or a repeat that grew worse; unreleased), `user:loggedIn`, `user:deleted`, `contact:deleted`, `note:deleted`, `auth:loginSucceeded`, `auth:loginFailed`, `auth:loggedOut`, `auth:rateLimited`, `auth:passwordChanged`, `auth:resetRequested`, `auth:resetIssued`, and `audit` (every successful POST/PUT/PATCH/DELETE under `/api/` by a signed-in user - `{actor, action, route, target, fields, status, ip}`; core stores nothing, Security Pro keeps the trail).
|
|
1711
1717
|
|
|
1712
1718
|
```js
|
|
1713
1719
|
export default async function plugin(fastify, options) {
|
|
@@ -1733,6 +1739,7 @@ Not a plugin (skipped by discovery); ships in the npm package so plugins built a
|
|
|
1733
1739
|
- **`dataStore.js`** - `createStore(absPath)` → `read`, `write` (atomic via `.tmp` + rename), `readArray`, `appendItem` (uuid id), `updateItem`, `deleteItem`. For plugin-local JSON that does not need the collections API; single-process safe only.
|
|
1734
1740
|
- **`schemaSync.js`** - `syncPluginSchemas(collectionsDir, {getCollection, updateCollection}, log)` adds fields a plugin's shipped schema has gained to already-installed collections (additive only, idempotent). Fixes "new field reaches fresh installs only".
|
|
1735
1741
|
- **`admin/ui/help.js` + `help.css`** - Declarative inline help: `data-help="..."` on any element, then `scanHelp(container)`; also `helpTip`, `helpIcon`, `openHelpPanel({title, intro, sections})` for longer help.
|
|
1742
|
+
- **`telegram/bot.js`** - The Telegram Bot API over fetch for the Telegram Tools: `call` (8 s timeout, never throws), `sendMessage`, `tokenShape`, `esc`, `clip`, `randomCode`, `parseCommand`, `sameSecret` (timing-safe), `chatName`, `setTelegram` for tests. Unreleased.
|
|
1736
1743
|
- **`admin/ui/dates.js`** - `toDate`, `fmtDate`, `fmtTime`, `fmtDateTime` (dd/mm/yyyy, 24-hour; `{utc: true}` option), usable in the browser and on the server, so plugins read dates the way core does. Needs core 0.93.0.
|
|
1737
1744
|
- **`admin/ui/resizable.js`** - `makeResizable(slideover, {storageKey, defaultWidth, handleClass})`: drag handle on a slideover's leading edge, width remembered per panel (defers to the admin's central handle when present).
|
|
1738
1745
|
- **`mail/` + `admin/mail/`** - The complete IMAP/SMTP mail core shared by Mail Reader (free) and Email Pro (paid): accounts with AES-256-GCM sealed passwords or a Microsoft/Google OAuth2 sign-in (`oauth.js`, `oauthRoutes.js`, `admin/mail/oauth-panel.js`; routes registered by Email Pro only), connection pool, sync, rules, send-later, snooze, templates, vacation replies, mbox export, three-pane reader, compose window, and `section-kit.js` (small DOM builders: `box`, `heading`, `note`, `formIn`, `itemCard`, `button`, `actionBar`, `richEditor`, `select`, `empty`). Mail Reader's `plugin.js` is 48 lines over it.
|
|
@@ -2541,6 +2548,39 @@ Targeted surveys on top of the Forms engine. Pick any form, choose an audience f
|
|
|
2541
2548
|
|
|
2542
2549
|
**Where:** Admin sidebar Outreach > "Surveys" (`#/plugins/surveys`); banner actions Audience and New survey.
|
|
2543
2550
|
|
|
2551
|
+
### Telegram (`telegram`)
|
|
2552
|
+
|
|
2553
|
+
Tier: free (ships in the engine) · Version: 0.1.0 (unreleased) · Requires: `plugins/_lib/telegram/bot.js` and, for alerts, the core `notification:raised` event (both in the next CMS release) · No MongoDB
|
|
2554
|
+
|
|
2555
|
+
The site's own Telegram bot sends the team its alerts and form submissions. Each linked chat - a team group or one person's private chat with the bot - has its own routing.
|
|
2556
|
+
|
|
2557
|
+
**Features**
|
|
2558
|
+
- Connection tab: paste the @BotFather token; the Tool checks it (getMe), refuses a bot whose webhook already points elsewhere (Takeaway, another site: "make a second bot"), sets the webhook to `/api/plugins/telegram/webhook` with its own secret, https only. The token, secret and link code are never sent to a browser. Disconnect deletes the webhook and forgets the chats.
|
|
2559
|
+
- Chats tab: Link a chat makes a one-time code (16 characters, 15 minutes, one chat, burnt after 5 wrong tries); `/link <code>` in the chat links it. Rows: click or Enter for "What it gets", right-click, kebab or Shift+F10 for Send a test, Pause/Resume, Unlink (the chat is told). `/unlink` in a linked chat does the same. A group that becomes a supergroup stays linked.
|
|
2560
|
+
- Routing per chat: alerts on/off, severities (default Warning and Critical), every Tool or chosen sources (a Tool or one of its sources); forms on/off, every form or chosen ones, and "the answers" (default) or "title and link only". Unsaved changes ask before discarding and are kept as a draft when the screen is left.
|
|
2561
|
+
- Never sent: notifications with a personal audience (`audience.userIds`, such as to-do reminders); form fields of type password, file, image or hidden, layout fields, fields named like password/secret/token, file values, and any posted key the form does not define. A deleted form sends title and link only.
|
|
2562
|
+
- Test tab: a hello, a sample alert, a sample form entry (as that chat would get it), or a real notification raised in the bell from the "Telegram test alerts" source.
|
|
2563
|
+
- A per-chat queue: about one message a second, Telegram's 429 waited out once, 50 waiting at most; a failure never stops the form or the notification and shows on the chat and the badge.
|
|
2564
|
+
- Sidebar badge: linked chats as a calm total; red when Telegram reports it cannot reach the site, the webhook points elsewhere, or a chat could not be sent to.
|
|
2565
|
+
- Registry `globalThis[Symbol.for('domma.telegram')]` for Telegram Pro: every update the Tool does not answer itself is offered to `onMessage` handlers.
|
|
2566
|
+
|
|
2567
|
+
**Where:** Admin sidebar "Telegram" (`#/plugins/telegram`, `/chats`, `/test`); permission `telegram` (read / manage). Guide in Documentation > Plugins.
|
|
2568
|
+
|
|
2569
|
+
### Telegram Pro (`telegram-pro`)
|
|
2570
|
+
|
|
2571
|
+
Tier: paid (closed source) · Version: 0.1.0 (unreleased) · Requires: `telegram` · No MongoDB
|
|
2572
|
+
|
|
2573
|
+
Two-way chat with customers through the same bot.
|
|
2574
|
+
|
|
2575
|
+
**Features**
|
|
2576
|
+
- A customer's private message to the bot becomes a conversation (collection `telegram-conversations`, API off): name and username from Telegram, the `/start` tag they came with, text messages (a photo or file is kept as "[photo]", "[file]" and never downloaded), unread count.
|
|
2577
|
+
- Inbox (`#/plugins/telegram-pro`, `/<id>`): list on the left with search and unread dots, thread on the right with a reply box (Ctrl+Enter); rows have Open, Mark as read/unread, Delete (manage); refreshes every 10 s (thread 5 s); a typed reply is kept per conversation in the browser. Sidebar badge: unread conversations. A notification for each new conversation (the customer's name only, never their words).
|
|
2578
|
+
- Staff chat (settings cog): a group linked in Telegram › Chats gets a copy of each customer message; a staff member's Telegram reply to the copy goes to the customer and is kept as theirs. Answers from the admin are echoed there, and replying to the echo works too. Linked chats are never treated as customers.
|
|
2579
|
+
- `/stop` deletes the customer's conversation at once; a conversation quiet for the retention (90 days by default, 1 to 3650) is deleted by an hourly sweep.
|
|
2580
|
+
- `[telegram text="Message us on Telegram" tag="pricing" /]` - a t.me button with an optional start tag; nothing is shown while the bot is not connected.
|
|
2581
|
+
|
|
2582
|
+
**Where:** Admin sidebar "Telegram chats"; permission `telegram-pro` (read / reply / manage).
|
|
2583
|
+
|
|
2544
2584
|
### Theme Roller (`theme-roller`)
|
|
2545
2585
|
|
|
2546
2586
|
Tier: paid (closed source) · Version: 1.1.3 · Requires: Domma CMS 0.73+ (`hooks.registerThemes`; stated in the description, not as a field) · Uses: nothing declared · No MongoDB
|
|
@@ -3128,6 +3168,15 @@ Later changes to these features are in the CHANGELOG (for example 0.92.1: row-le
|
|
|
3128
3168
|
- Embedding a survey on a page with `[survey]`.
|
|
3129
3169
|
- Summarising free-text answers into themes with AI Assist, and reading the answers before acting on them.
|
|
3130
3170
|
|
|
3171
|
+
### Telegram (`telegram`)
|
|
3172
|
+
|
|
3173
|
+
- Your site's alerts on your phone: make a bot with @BotFather, connect it, link the team's group with /link, and choose Warning and Critical.
|
|
3174
|
+
- Never miss an enquiry: send one form's submissions to the sales chat with the answers, and another to a private chat as title and link only.
|
|
3175
|
+
|
|
3176
|
+
### Telegram Pro (`telegram-pro`)
|
|
3177
|
+
|
|
3178
|
+
- Answer customers from your team's Telegram group: choose the staff chat, add a [telegram] button with a tag to the pricing page, and reply to the copies.
|
|
3179
|
+
|
|
3131
3180
|
### Theme Roller (`theme-roller`)
|
|
3132
3181
|
|
|
3133
3182
|
- Creating a brand theme from a built-in theme and using it on the site.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Brand Kit - one site-wide brand (design, not built)
|
|
2
2
|
|
|
3
|
-
Status: agreed design, 2026-11-19 (decisions below).
|
|
3
|
+
Status: agreed design, 2026-11-19 (decisions below). Phase 1 built (feat/brand-kit); phases 2-5 not started.
|
|
4
4
|
|
|
5
5
|
## The problem
|
|
6
6
|
|