domma-cms 1.71.0 → 1.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/admin/js/lib/sidebar-frequent.js +1 -1
  3. package/admin/js/templates/docs/usage-tools.html +1 -1
  4. package/docs/DommaFeatures.md +47 -12
  5. package/package.json +1 -1
  6. package/plugins/_lib/admin/mail/body-menu.js +1 -1
  7. package/plugins/_lib/admin/mail/cms-host.js +1 -1
  8. package/plugins/_lib/admin/mail/compose-window.js +76 -3
  9. package/plugins/_lib/admin/mail/contacts.js +1 -1
  10. package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
  11. package/plugins/_lib/admin/mail/drag-drop.js +1 -1
  12. package/plugins/_lib/admin/mail/folder-tree.js +1 -1
  13. package/plugins/_lib/admin/mail/font-controls.js +1 -1
  14. package/plugins/_lib/admin/mail/fonts.js +1 -1
  15. package/plugins/_lib/admin/mail/host-context.js +1 -1
  16. package/plugins/_lib/admin/mail/identity.js +1 -1
  17. package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
  18. package/plugins/_lib/admin/mail/keyboard.js +1 -1
  19. package/plugins/_lib/admin/mail/mail.html +1 -1
  20. package/plugins/_lib/admin/mail/message-actions.js +1 -1
  21. package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
  22. package/plugins/_lib/admin/mail/panes.js +1 -1
  23. package/plugins/_lib/admin/mail/reader-kit.js +1 -1
  24. package/plugins/_lib/admin/mail/reader-runtime.js +11 -2
  25. package/plugins/_lib/admin/mail/reader-view.js +1 -1
  26. package/plugins/_lib/admin/mail/resizable.js +1 -1
  27. package/plugins/_lib/admin/mail/restore-spam.js +1 -1
  28. package/plugins/_lib/admin/mail/rules.js +1 -1
  29. package/plugins/_lib/admin/mail/scheduling.js +1 -1
  30. package/plugins/_lib/admin/mail/section-kit.js +1 -1
  31. package/plugins/_lib/admin/mail/security-note.js +1 -1
  32. package/plugins/_lib/admin/mail/settings-section.js +1 -1
  33. package/plugins/_lib/admin/mail/templates.js +1 -1
  34. package/plugins/_lib/admin/mail/threads.js +1 -1
  35. package/plugins/_lib/admin/mail/vacation.js +1 -1
  36. package/plugins/_lib/admin/mail/when-closed.js +1 -1
  37. package/plugins/_lib/admin/ui/dates.js +1 -1
  38. package/plugins/_lib/admin/ui/resizable.js +1 -1
  39. package/plugins/_lib/admin/ui/rich-field.js +291 -0
  40. package/plugins/_lib/domma-mail.lock.json +83 -80
  41. package/plugins/_lib/mail/accountFileStore.js +1 -1
  42. package/plugins/_lib/mail/accountRepository.js +1 -1
  43. package/plugins/_lib/mail/accountRoutes.js +1 -1
  44. package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
  45. package/plugins/_lib/mail/bodyTokens.js +1 -1
  46. package/plugins/_lib/mail/compose.js +1 -1
  47. package/plugins/_lib/mail/defaults.js +1 -1
  48. package/plugins/_lib/mail/envelope.js +1 -1
  49. package/plugins/_lib/mail/folderActions.js +1 -1
  50. package/plugins/_lib/mail/folderRuntime.js +1 -1
  51. package/plugins/_lib/mail/folders.js +1 -1
  52. package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
  53. package/plugins/_lib/mail/mbox.js +1 -1
  54. package/plugins/_lib/mail/message-action.js +1 -1
  55. package/plugins/_lib/mail/messageSecurity.js +1 -1
  56. package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
  57. package/plugins/_lib/mail/networkAddresses.js +1 -1
  58. package/plugins/_lib/mail/networkPolicy.js +1 -1
  59. package/plugins/_lib/mail/oauthAccounts.js +1 -1
  60. package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
  61. package/plugins/_lib/mail/oauthRuntime.js +1 -1
  62. package/plugins/_lib/mail/pollSchedule.js +1 -1
  63. package/plugins/_lib/mail/poller.js +1 -1
  64. package/plugins/_lib/mail/pollerRuntime.js +1 -1
  65. package/plugins/_lib/mail/priority.js +1 -1
  66. package/plugins/_lib/mail/publicMailbox.js +1 -1
  67. package/plugins/_lib/mail/readRuntime.js +1 -1
  68. package/plugins/_lib/mail/render.js +1 -1
  69. package/plugins/_lib/mail/ruleRunner.js +1 -1
  70. package/plugins/_lib/mail/schedulerRuntime.js +1 -1
  71. package/plugins/_lib/mail/secretProvider.js +1 -1
  72. package/plugins/_lib/mail/secretbox.js +1 -1
  73. package/plugins/_lib/mail/senderAuth.js +1 -1
  74. package/plugins/_lib/mail/sieve.js +1 -1
  75. package/plugins/_lib/mail/smtpService.js +1 -1
  76. package/plugins/_lib/mail/snoozeRuntime.js +1 -1
  77. package/plugins/_lib/mail/store.js +1 -1
  78. package/plugins/_lib/mail/subscriptions.js +1 -1
  79. package/plugins/_lib/mail/syncPlan.js +1 -1
  80. package/plugins/_lib/mail/syncRuntime.js +1 -1
  81. package/plugins/_lib/mail/syncSelection.js +1 -1
  82. package/plugins/_lib/mail/unreadBadge.js +1 -1
  83. package/plugins/_lib/mail/unsubscribe.js +1 -1
  84. package/plugins/_lib/mail/vacationRuntime.js +1 -1
  85. package/plugins/_lib/mail/write.js +1 -1
  86. package/plugins/_lib/public/rich-text.mjs +104 -0
  87. package/plugins/_lib/rich-text.js +153 -0
  88. package/server/services/sidebarFrequent.js +1 -1
  89. package/server/services/wpImport/redirects.js +7 -2
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/accountFileStore.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/accountFileStore.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {randomUUID} from 'node:crypto';
4
4
  import fs from 'node:fs/promises';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/accountRepository.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/accountRepository.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  export const POLL_INTERVALS = Object.freeze([3, 5, 10, 15]);
4
4
  import {randomUUID} from 'node:crypto';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/accountRoutes.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/accountRoutes.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {MailKeyError} from './secretProvider.js';
4
4
 
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/bodyTokenProvider.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/bodyTokenProvider.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {createHmac, timingSafeEqual} from 'node:crypto';
4
4
 
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/bodyTokens.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/bodyTokens.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** CMS compatibility entry point for the existing iframe grant API. */
4
4
  import {resolveKeySource} from './secretbox.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/compose.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/compose.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Turning a message into a reply, and a reply into something sendable.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/defaults.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/defaults.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Reading defaults, shared by every edition.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/envelope.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/envelope.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The shape the mirror holds one message in.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/folderActions.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/folderActions.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Whole-folder operations use a snapshot of UIDs, never the visible page or a moving '*'. */
4
4
  import {moveBulk, setFlagsBulk} from './write.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/folderRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/folderRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Portable folder operations. Hosts supply ownership, serialization and metadata updates. */
4
4
  import {validateFolderName, buildFolderPath, renameTarget, canModifyFolder, descendantsOf, moveTarget, resolveSubscriptions} from './folders.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/folders.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/folders.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {resolveSubscriptions} from './subscriptions.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/imapPoolRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/imapPoolRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * IMAP connection pool for the Mail Reader plugin.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/mbox.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/mbox.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Exporting a folder as mbox.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/message-action.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/message-action.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Remember replies and forwards on the original message after delivery. */
4
4
  export const SOURCE_HEADER = 'X-Domma-Message-Source';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/messageSecurity.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/messageSecurity.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {createMessageSecurity} from './messageSecurityProvider.js';
4
4
  export const {setMessageSecurity, canProtect, protectRaw, protectDraftRaw, unwrapRaw, parseReadable} = createMessageSecurity();
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/messageSecurityProvider.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/messageSecurityProvider.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Where signing and encryption plug into the mail core.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/networkAddresses.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/networkAddresses.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Address classification from the CMS outbound policy, MIT licensed. */
4
4
  import net from 'node:net';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/networkPolicy.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/networkPolicy.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import dns from 'node:dns/promises';
4
4
  import net from 'node:net';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/oauthAccounts.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/oauthAccounts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {randomUUID} from 'node:crypto';
4
4
  import {MailKeyError} from './secretProvider.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/oauthRouteRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/oauthRouteRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The OAuth2 sign-in routes for mailboxes: Connect, the provider's callback,
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/oauthRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/oauthRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * OAuth2 sign-in for mailboxes (XOAUTH2) - Microsoft 365 / Outlook.com and Gmail.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/pollSchedule.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/pollSchedule.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Deciding which mailboxes are due a poll.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/poller.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/poller.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Compatibility entry point for the shared mail poller. */
4
4
  export {createPoller} from './pollerRuntime.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/pollerRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/pollerRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The background poller.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/priority.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/priority.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * How urgent a sender said a message was.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/publicMailbox.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/publicMailbox.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Standalone mailbox summary. Explicit fields keep credentials out of responses. */
4
4
  export function publicMailbox(account) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/readRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/readRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {registerAccountRoutes} from './accountRoutes.js';
4
4
  import {ENVELOPE_QUERY, hasAttachment, parseHeaderBlock} from './envelope.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/render.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/render.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Message rendering for the Mail Reader plugin.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/ruleRunner.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/ruleRunner.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Carrying out what the rules decided.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/schedulerRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/schedulerRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The worker behind "send later", "undo send" and "snooze".
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/secretProvider.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/secretProvider.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {createCipheriv, createDecipheriv, createHash, randomBytes, scryptSync} from 'node:crypto';
4
4
  import fs from 'node:fs';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/secretbox.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/secretbox.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** CMS compatibility entry point. Standalone hosts create their own secret box. */
4
4
  import path from 'node:path';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/senderAuth.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/senderAuth.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Did this message really come from the address in its From line?
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/sieve.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/sieve.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** ManageSieve (RFC 5804). One bounded, TLS-verified session per operation. */
4
4
  import net from 'node:net';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/smtpService.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/smtpService.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Sending, and keeping a copy where the rest of your clients will find it.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/snoozeRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/snoozeRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {safeWritePool, moveMessage} from './write.js';
4
4
 
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/store.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/store.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The synchronised message store.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/subscriptions.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/subscriptions.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  export function resolveSubscriptions(boxes) {
4
4
  const list = boxes ?? [];
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/syncPlan.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/syncPlan.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Deciding what a folder sync needs to do.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/syncRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/syncRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {missingUids, planFolderSync} from './syncPlan.js';
4
4
  import {resolveSyncFolders} from './syncSelection.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/syncSelection.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/syncSelection.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Which folders a mailbox keeps mirrored.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/unreadBadge.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/unreadBadge.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The free reader's sidebar badge - unread mail in each mailbox's INBOX.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/unsubscribe.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/unsubscribe.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Getting off a mailing list.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/vacationRuntime.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/vacationRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {randomUUID} from 'node:crypto';
4
4
  import {autoReplyHeaders, isActive, normaliseVacation, replySubject, shouldAutoReply, replyHistory} from '../admin/mail/vacation.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.29.1, packages/core/src/mail/write.js.
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/mail/write.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Changing mail, rather than reading it.
@@ -0,0 +1,104 @@
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/public/rich-text.mjs.
2
+ // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
+ /**
4
+ * Rich text in a Description field - the pure part, shared by the server, the
5
+ * admin and public scripts.
6
+ *
7
+ * A description is stored in ONE string, as it always was. Text typed before
8
+ * descriptions were rich (or sent by an API client) is plain; text from the
9
+ * rich editor is HTML that starts with a block element. `isRichText` tells
10
+ * them apart by that start and nothing else, so plain text that merely
11
+ * mentions a tag ("use <b> for bold") stays plain and is escaped wherever it
12
+ * is shown.
13
+ *
14
+ * Nothing here makes HTML safe to show. The server cleans a rich description
15
+ * when it is saved and again when it is rendered (`server/services/richText.js`);
16
+ * the admin shows one through DOMPurify (`admin/js/lib/rich-field.js`).
17
+ *
18
+ * @module public/js/rich-text
19
+ */
20
+
21
+ /** A value that starts with one of the editor's block elements is rich. */
22
+ const RICH_START = /^\s*<(p|ul|ol|h[2-4]|blockquote)(\s[^<>]*)?>/i;
23
+
24
+ /**
25
+ * @param {*} value
26
+ * @returns {boolean}
27
+ */
28
+ export function isRichText(value) {
29
+ return typeof value === 'string' && RICH_START.test(value);
30
+ }
31
+
32
+ /**
33
+ * @param {*} value
34
+ * @returns {string}
35
+ */
36
+ export function escapeHtml(value) {
37
+ return String(value ?? '').replace(/[&<>"']/g, c => ({'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;'}[c]));
38
+ }
39
+
40
+ /**
41
+ * Plain text as the paragraphs it reads as: a blank line starts a paragraph,
42
+ * a single line break stays a line break. Escaped.
43
+ *
44
+ * @param {*} text
45
+ * @returns {string} '' for nothing
46
+ */
47
+ export function plainToRichHtml(text) {
48
+ return String(text ?? '').replace(/\r\n?/g, '\n').split(/\n{2,}/)
49
+ .map(block => block.trim()).filter(Boolean)
50
+ .map(block => `<p>${escapeHtml(block).replace(/\n/g, '<br>')}</p>`).join('');
51
+ }
52
+
53
+ const ENTITIES = {amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' '};
54
+
55
+ /**
56
+ * A description as plain text, whichever way it is stored: for a list row, a
57
+ * search, a meta description, an email or a file. Paragraphs become blank
58
+ * lines, list items "- " lines.
59
+ *
60
+ * @param {*} value
61
+ * @returns {string}
62
+ */
63
+ export function richTextToPlain(value) {
64
+ const raw = String(value ?? '');
65
+ if (!isRichText(raw)) return raw.trim();
66
+ return raw
67
+ .replace(/<br\s*\/?>/gi, '\n')
68
+ .replace(/<li(\s[^<>]*)?>/gi, '- ')
69
+ .replace(/<\/(p|h[1-6]|blockquote|ul|ol)>/gi, '\n\n')
70
+ .replace(/<\/li>/gi, '\n')
71
+ .replace(/<[^<>]*>/g, '')
72
+ .replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (whole, name) => {
73
+ if (name[0] !== '#') return ENTITIES[name.toLowerCase()] ?? whole;
74
+ const code = name[1].toLowerCase() === 'x' ? Number.parseInt(name.slice(2), 16) : Number.parseInt(name.slice(1), 10);
75
+ return Number.isFinite(code) && code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : whole;
76
+ })
77
+ .replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
78
+ }
79
+
80
+ /**
81
+ * A description as one line of plain text, not cut: for a meta description, a
82
+ * JSON-LD value, an llms.txt line or anything that counts its characters. A
83
+ * plain value is returned as stored (trimmed), so text saved before
84
+ * descriptions were rich reads exactly as it did.
85
+ *
86
+ * @param {*} value
87
+ * @returns {string}
88
+ */
89
+ export function richTextLine(value) {
90
+ if (!isRichText(value)) return String(value ?? '').trim();
91
+ return richTextToPlain(value).replace(/\s+/g, ' ').trim();
92
+ }
93
+
94
+ /**
95
+ * A description on one line, cut to fit - for a list row or a meta description.
96
+ *
97
+ * @param {*} value
98
+ * @param {number} [max]
99
+ * @returns {string}
100
+ */
101
+ export function richTextSummary(value, max = 160) {
102
+ const line = richTextToPlain(value).replace(/\s+/g, ' ').trim();
103
+ return line.length > max ? `${line.slice(0, max - 1).trimEnd()}…` : line;
104
+ }
@@ -0,0 +1,153 @@
1
+ // Source: @domma-mail/core 0.31.0, packages/core/src/rich-text.js.
2
+ // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
+ /**
4
+ * Rich text Description fields - cleaning what is saved and what is shown.
5
+ *
6
+ * See `public/js/rich-text.mjs` for how a description is stored (one string,
7
+ * plain or rich) and told apart. This is the half that needs a sanitiser:
8
+ *
9
+ * - `cleanRichText(value)` on SAVE. A rich value is reduced to the small set
10
+ * of elements the editor makes; a plain one is kept as typed.
11
+ * - `renderRichText(value)` wherever a description goes into a page or an
12
+ * HTML email. A rich value is cleaned again (what is stored may predate a
13
+ * rule, or have been written around the API); a plain one is escaped into
14
+ * paragraphs. Its result is always safe to put in a page.
15
+ * - `renderRichTextPhrasing(value)` where a description is drawn INSIDE a
16
+ * line of text (a `<p>`, a link, a button): the same words with only inline
17
+ * formatting, so it cannot break the element it sits in.
18
+ * - `richTextToPlain` / `richTextSummary` / `richTextLine` (re-exported) for
19
+ * everything that is not HTML: meta descriptions, plain emails, CSV, ICS,
20
+ * search, JSON-LD.
21
+ *
22
+ * Deliberately far stricter than `sanitizePageHtml`: a description is a few
23
+ * formatted paragraphs, not a page. No images, classes, styles or embeds.
24
+ *
25
+ * @module server/services/richText
26
+ */
27
+ import sanitizeHtml from 'sanitize-html';
28
+ import {isRichText, plainToRichHtml, richTextToPlain, richTextSummary, richTextLine as plainLine, escapeHtml} from './public/rich-text.mjs';
29
+
30
+ export {isRichText, plainToRichHtml, richTextToPlain, richTextSummary};
31
+
32
+ /** How long a description may be unless the caller says otherwise. */
33
+ export const RICH_TEXT_MAX = 20000;
34
+
35
+ const OPTIONS = {
36
+ allowedTags: ['p', 'br', 'strong', 'b', 'em', 'i', 'u', 's', 'ul', 'ol', 'li', 'a', 'h2', 'h3', 'h4', 'blockquote', 'code'],
37
+ allowedAttributes: {a: ['href', 'target', 'rel']},
38
+ allowedSchemes: ['http', 'https', 'mailto', 'tel'],
39
+ allowProtocolRelative: false,
40
+ // The editor makes divs and spans (a pasted line, a font change); their text is kept.
41
+ transformTags: {
42
+ div: 'p',
43
+ a: (tagName, attribs) => ({tagName, attribs: {
44
+ ...(attribs.href ? {href: attribs.href} : {}),
45
+ ...(attribs.target === '_blank' ? {target: '_blank'} : {}),
46
+ rel: 'noopener noreferrer'
47
+ }})
48
+ },
49
+ // A link with nowhere to go is its text.
50
+ exclusiveFilter: frame => frame.tag === 'a' && !frame.attribs.href && !frame.text.trim()
51
+ };
52
+
53
+ /**
54
+ * @param {string} html
55
+ * @returns {string} cleaned, starting with a block element; '' when it says nothing
56
+ */
57
+ function clean(html) {
58
+ // As the editor writes a line break, so an unedited description reads back the same.
59
+ let out = sanitizeHtml(html, OPTIONS).replace(/<br \/>/g, '<br>').trim();
60
+ // An empty list item reads as its bullet alone: that is still nothing.
61
+ if (!richTextToPlain(isRichText(out) ? out : `<p>${out}</p>`).replace(/^- ?$/gm, '').trim()) return '';
62
+ if (!isRichText(out)) out = `<p>${out}</p>`;
63
+ return out;
64
+ }
65
+
66
+ /**
67
+ * A description as it should be stored.
68
+ *
69
+ * @param {*} value - from a request body
70
+ * @param {{max?: number}} [options] - the longest it may be, markup included
71
+ * @returns {string}
72
+ */
73
+ export function cleanRichText(value, {max = RICH_TEXT_MAX} = {}) {
74
+ if (typeof value !== 'string') return '';
75
+ // eslint-disable-next-line no-control-regex
76
+ const raw = value.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, '');
77
+ if (!isRichText(raw)) return raw.trim().slice(0, max);
78
+ const out = clean(raw);
79
+ // Cut, then cleaned again so no element is left open.
80
+ return out.length > max ? clean(out.slice(0, max)) : out;
81
+ }
82
+
83
+ /**
84
+ * A description as HTML that is safe to put in a page.
85
+ *
86
+ * @param {*} value - as stored
87
+ * @returns {string} '' for nothing
88
+ */
89
+ export function renderRichText(value) {
90
+ if (typeof value !== 'string' || !value.trim()) return '';
91
+ return isRichText(value) ? clean(value) : plainToRichHtml(value);
92
+ }
93
+
94
+ /**
95
+ * The same, for one line of plain text shown inline (a list row, a title
96
+ * attribute): always escaped text, never markup.
97
+ *
98
+ * @param {*} value
99
+ * @param {number} [max]
100
+ * @returns {string}
101
+ */
102
+ export function renderRichTextInline(value, max = 160) {
103
+ return escapeHtml(richTextSummary(value, max));
104
+ }
105
+
106
+ /**
107
+ * A description as one line of plain text, not cut: for a meta description, a
108
+ * JSON-LD value, an llms.txt line, a search result. A rich value is cleaned
109
+ * first - what is stored may have been written by hand, and the text inside a
110
+ * `<script>` is not one of its words. A plain value is returned as stored
111
+ * (trimmed).
112
+ *
113
+ * @param {*} value - as stored
114
+ * @returns {string}
115
+ */
116
+ export function richTextLine(value) {
117
+ return plainLine(isRichText(value) ? clean(value) : value);
118
+ }
119
+
120
+ /** What may sit inside a line of text: no blocks, no lists. */
121
+ const PHRASING_TAGS = ['strong', 'b', 'em', 'i', 'u', 's', 'code', 'br'];
122
+
123
+ /**
124
+ * A description as HTML that is safe to put INSIDE a line of text - a `<p>`,
125
+ * a link, a button, a caption - where a paragraph or a list would break the
126
+ * element around it. Paragraphs and list items become line breaks (a list
127
+ * item starts "- "), headings and quotes lose their element and keep their
128
+ * words, and only inline formatting is left.
129
+ *
130
+ * A rich value is cleaned first. A plain value is escaped, unless `legacyHtml`
131
+ * is set: for a field whose plain text was drawn as HTML before it was rich,
132
+ * so inline markup somebody typed by hand keeps working and anything else in
133
+ * it (scripts, images, event handlers) is dropped.
134
+ *
135
+ * @param {*} value - as stored
136
+ * @param {{links?: boolean, legacyHtml?: boolean}} [options] - `links: false`
137
+ * where the text sits inside a link already
138
+ * @returns {string} '' for nothing
139
+ */
140
+ export function renderRichTextPhrasing(value, {links = true, legacyHtml = false} = {}) {
141
+ if (typeof value !== 'string' || !value.trim()) return '';
142
+ const rich = isRichText(value);
143
+ if (!rich && !legacyHtml) return escapeHtml(value.trim()).replace(/\r\n?|\n/g, '<br>');
144
+ const flat = (rich ? clean(value) : value.trim())
145
+ .replace(/<li(\s[^<>]*)?>/gi, '- ')
146
+ .replace(/<\/(p|h[1-6]|blockquote|li|ul|ol|div)>/gi, '<br>');
147
+ const out = sanitizeHtml(flat, {
148
+ ...OPTIONS,
149
+ allowedTags: links ? [...PHRASING_TAGS, 'a'] : PHRASING_TAGS,
150
+ transformTags: {a: OPTIONS.transformTags.a}
151
+ });
152
+ return out.replace(/<br \/>/g, '<br>').replace(/(\s*<br>\s*){2,}/g, '<br>').replace(/^(\s|<br>)+|(\s|<br>)+$/g, '');
153
+ }
@@ -13,7 +13,7 @@ import fs from 'fs/promises';
13
13
  import path from 'path';
14
14
 
15
15
  /** As FREQUENT_MAX in admin/js/lib/sidebar-frequent.js. */
16
- export const FREQUENT_MAX = 16;
16
+ export const FREQUENT_MAX = 24;
17
17
  const URL_MAX = 500;
18
18
  const USER_ID_RE = /^[A-Za-z0-9_-]{1,80}$/;
19
19