domma-cms 1.6.60 → 1.7.1

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 (168) hide show
  1. package/CHANGELOG.md +4349 -0
  2. package/README.md +1 -1
  3. package/admin/dist/domma/domma-tools.css +3 -3
  4. package/admin/dist/domma/domma-tools.min.js +3 -3
  5. package/admin/js/lib/effect-defs.js +1 -1
  6. package/admin/js/lib/effects-builder.js +2 -2
  7. package/admin/js/lib/mail-compose.js +1 -0
  8. package/admin/js/lib/page-editor-reference.js +5 -5
  9. package/admin/js/lib/shortcode-tags.js +1 -1
  10. package/admin/js/templates/call-new.html +1 -1
  11. package/admin/js/templates/docs/usage-shortcodes.html +39 -0
  12. package/admin/js/views/call-new.js +1 -1
  13. package/admin/js/views/contacts.js +15 -15
  14. package/admin/js/views/form-submissions.js +2 -2
  15. package/docs/DommaFeatures.md +3005 -0
  16. package/docs/MultiTenant.md +176 -0
  17. package/docs/api-reference.md +1667 -0
  18. package/docs/cache.md +96 -0
  19. package/docs/configuration.md +1811 -0
  20. package/docs/editions-and-licences.md +190 -0
  21. package/docs/getting-started.md +201 -0
  22. package/docs/guides/form-triggers.md +260 -0
  23. package/docs/guides/mongodb-storage-adapter.md +282 -0
  24. package/docs/guides/multi-page-forms.md +121 -0
  25. package/docs/images/scribe-composer.png +0 -0
  26. package/docs/markdown-shortcodes.md +1738 -0
  27. package/docs/pentest-report-2026-04-03.md +181 -0
  28. package/docs/plans/2026-02-28-admin-topbar-login-forms.md +349 -0
  29. package/docs/plans/2026-02-28-domma-ui-polish.md +286 -0
  30. package/docs/plans/2026-02-28-reset-seed-fresh-commands.md +520 -0
  31. package/docs/plans/2026-03-02-cookie-consent-design.md +86 -0
  32. package/docs/plans/2026-03-02-cookie-consent-plugin.md +453 -0
  33. package/docs/plans/2026-03-02-tooltip-sweep-and-back-to-top-plugin-design.md +126 -0
  34. package/docs/plans/2026-03-02-tooltip-sweep-back-to-top.md +427 -0
  35. package/docs/plans/2026-03-05-cookie-consent-btt-core.md +115 -0
  36. package/docs/plans/2026-03-05-custom-css-migrate-to-core-design.md +35 -0
  37. package/docs/plans/2026-03-05-custom-css-migrate-to-core.md +352 -0
  38. package/docs/plans/2026-03-05-scribe-script-shortcode.md +373 -0
  39. package/docs/plans/2026-03-05-user-types-design.md +139 -0
  40. package/docs/plans/2026-03-05-user-types-implementation.md +1035 -0
  41. package/docs/plans/2026-03-09-page-editor-view-cta-inserts-design.md +78 -0
  42. package/docs/plans/2026-03-09-page-editor-view-cta-inserts.md +388 -0
  43. package/docs/plans/2026-03-09-pro-documentation-design.md +80 -0
  44. package/docs/plans/2026-03-09-pro-documentation.md +1017 -0
  45. package/docs/plans/2026-06-10-core-project-design.md +240 -0
  46. package/docs/plugin-development.md +827 -0
  47. package/docs/recruitment-recipe.md +501 -0
  48. package/docs/scaffolding.md +312 -0
  49. package/docs/screenshots/calculator-floating.png +0 -0
  50. package/docs/screenshots/calculator-standard.png +0 -0
  51. package/docs/screenshots/email-settings.png +0 -0
  52. package/docs/screenshots/messages-count.png +0 -0
  53. package/docs/structure/user-types.md +107 -0
  54. package/docs/superpowers/plans/2026-05-25-admin-sidebar-via-menus.md +1112 -0
  55. package/docs/superpowers/plans/2026-06-08-navbar-mobile-drawer-and-menu-enrichment.md +1161 -0
  56. package/docs/superpowers/plans/2026-06-25-domma-docs-project.md +695 -0
  57. package/docs/superpowers/plans/2026-06-26-surveys-HANDOFF.md +68 -0
  58. package/docs/superpowers/plans/2026-06-26-surveys-pro-plugin.md +1902 -0
  59. package/docs/superpowers/plans/2026-08-19-collection-context-sort-export.md +1577 -0
  60. package/docs/superpowers/plans/2026-10-09-content-api.md +1192 -0
  61. package/docs/superpowers/specs/2026-03-12-form-followup-actions-design.md +152 -0
  62. package/docs/superpowers/specs/2026-03-12-page-editor-form-insert-and-per-page-theme-design.md +115 -0
  63. package/docs/superpowers/specs/2026-03-17-nav-hidden-items-design.md +85 -0
  64. package/docs/superpowers/specs/2026-03-19-accordion-insert-design.md +175 -0
  65. package/docs/superpowers/specs/2026-03-25-static-block-shortcode-design.md +153 -0
  66. package/docs/superpowers/specs/2026-03-25-text-shortcode-design.md +168 -0
  67. package/docs/superpowers/specs/2026-04-05-card-builder-design.md +315 -0
  68. package/docs/superpowers/specs/2026-04-06-insert-builders-design.md +278 -0
  69. package/docs/superpowers/specs/2026-04-06-layouts-design.md +226 -0
  70. package/docs/superpowers/specs/2026-04-07-blog-plugin-design.md +300 -0
  71. package/docs/superpowers/specs/2026-04-07-calendar-plugin-design.md +538 -0
  72. package/docs/superpowers/specs/2026-04-17-components-area-design.md +368 -0
  73. package/docs/superpowers/specs/2026-05-02-effects-slideover-overhaul-design.md +193 -0
  74. package/docs/superpowers/specs/2026-05-06-dashboard-rebuild-design.md +257 -0
  75. package/docs/superpowers/specs/2026-05-24-menus-design.md +466 -0
  76. package/docs/superpowers/specs/2026-05-25-admin-sidebar-via-menus-design.md +358 -0
  77. package/docs/superpowers/specs/2026-05-25-projects-design.md +380 -0
  78. package/docs/superpowers/specs/2026-06-08-navbar-mobile-drawer-and-menu-enrichment-design.md +292 -0
  79. package/docs/superpowers/specs/2026-06-08-sidebar-tools-plugins-folders-design.md +59 -0
  80. package/docs/superpowers/specs/2026-06-25-domma-docs-project-design.md +192 -0
  81. package/docs/superpowers/specs/2026-06-26-domma-charts-upstream-proposal.md +44 -0
  82. package/docs/superpowers/specs/2026-06-26-manager-scheduler-upstream-proposal.md +46 -0
  83. package/docs/superpowers/specs/2026-06-26-surveys-pro-plugin-design.md +206 -0
  84. package/docs/superpowers/specs/2026-07-02-shortcode-context-menu-design.md +96 -0
  85. package/docs/superpowers/specs/2026-08-19-collection-context-sort-export-design.md +330 -0
  86. package/docs/superpowers/specs/2026-09-22-dcms-marketplace-design.md +1150 -0
  87. package/docs/superpowers/specs/2026-10-09-content-api-design.md +325 -0
  88. package/docs/superpowers/specs/plans/2026-03-12-form-followup-actions.md +624 -0
  89. package/docs/superpowers/specs/plans/2026-03-12-page-editor-form-insert-and-per-page-theme.md +125 -0
  90. package/docs/superpowers/specs/plans/2026-03-17-nav-hidden-items.md +578 -0
  91. package/docs/superpowers/specs/plans/2026-03-19-accordion-insert.md +635 -0
  92. package/docs/superpowers/specs/plans/2026-03-25-text-shortcode.md +545 -0
  93. package/docs/superpowers/specs/plans/2026-04-05-card-builder.md +1970 -0
  94. package/docs/superpowers/specs/plans/2026-04-06-insert-builders.md +1049 -0
  95. package/docs/superpowers/specs/plans/2026-04-06-layouts.md +1015 -0
  96. package/docs/superpowers/specs/plans/2026-04-07-calendar-plugin.md +1526 -0
  97. package/docs/superpowers/specs/plans/2026-04-08-plugin-monetisation-split.md +242 -0
  98. package/docs/superpowers/specs/plans/2026-04-17-components-area.md +2038 -0
  99. package/docs/superpowers/specs/plans/2026-05-02-effects-slideover-overhaul.md +2335 -0
  100. package/docs/superpowers/specs/plans/2026-05-06-dashboard-rebuild.md +1999 -0
  101. package/docs/superpowers/specs/plans/2026-05-17-cache-system.md +1436 -0
  102. package/docs/superpowers/specs/plans/2026-05-24-menus.md +3096 -0
  103. package/docs/superpowers/specs/plans/2026-05-25-projects.md +2869 -0
  104. package/docs/superpowers/specs/plans/2026-09-22-marketplace-step2-consolidation.md +505 -0
  105. package/docs/superpowers/specs/plans/2026-09-22-marketplace-step3-catalogue-and-key.md +154 -0
  106. package/docs/superpowers/specs/plans/2026-09-22-tools-promotion.md +260 -0
  107. package/docs/theming.md +320 -0
  108. package/package.json +2 -2
  109. package/plugins/_lib/admin/mail/compose-window.js +3 -1
  110. package/plugins/_lib/admin/mail/identity.js +18 -3
  111. package/plugins/_lib/admin/mail/reader-view.js +32 -3
  112. package/plugins/blog/CLAUDE.md +4 -0
  113. package/plugins/blog/admin/lib/email.js +191 -0
  114. package/plugins/blog/admin/views/comments.js +3 -1
  115. package/plugins/blog/plugin.json +2 -2
  116. package/plugins/blog/plugin.public.js +1 -1
  117. package/plugins/blog/tests/email.test.js +69 -0
  118. package/plugins/booking/CLAUDE.md +4 -0
  119. package/plugins/booking/admin/lib/email.js +191 -0
  120. package/plugins/booking/admin/views/panels.js +7 -3
  121. package/plugins/booking/plugin.json +1 -1
  122. package/plugins/booking/tests/email.test.js +69 -0
  123. package/plugins/free-tier.lock.json +27 -19
  124. package/plugins/shopping-cart/CLAUDE.md +4 -0
  125. package/plugins/shopping-cart/admin/lib/email.js +191 -0
  126. package/plugins/shopping-cart/admin/views/orders.js +11 -3
  127. package/plugins/shopping-cart/plugin.json +2 -2
  128. package/plugins/shopping-cart/tests/email.test.js +69 -0
  129. package/plugins/support/CLAUDE.md +4 -0
  130. package/plugins/support/admin/lib/email.js +191 -0
  131. package/plugins/support/admin/views/desk.js +4 -1
  132. package/plugins/support/admin/views/inbox.js +6 -2
  133. package/plugins/support/plugin.json +2 -2
  134. package/plugins/support/tests/email.test.js +69 -0
  135. package/public/js/celebrations/core/canvas.js +1 -1
  136. package/public/js/celebrations/index.js +1 -1
  137. package/public/js/celebrations/licenses/ABeeZee-Regular-OFL.txt +93 -0
  138. package/public/js/celebrations/licenses/Allura-Regular-OFL.txt +93 -0
  139. package/public/js/celebrations/message-attrs.mjs +1 -0
  140. package/public/js/celebrations/themes/anniversary.js +1 -0
  141. package/public/js/celebrations/themes/autumn.js +1 -0
  142. package/public/js/celebrations/themes/birthday.js +1 -0
  143. package/public/js/celebrations/themes/butterfly-flight.js +1 -0
  144. package/public/js/celebrations/themes/calendar.js +1 -0
  145. package/public/js/celebrations/themes/chinese-new-year-dates.js +1 -0
  146. package/public/js/celebrations/themes/chinese-new-year.js +1 -0
  147. package/public/js/celebrations/themes/christmas.js +1 -1
  148. package/public/js/celebrations/themes/easter.js +1 -0
  149. package/public/js/celebrations/themes/garden-drawing.js +1 -0
  150. package/public/js/celebrations/themes/garden.js +1 -0
  151. package/public/js/celebrations/themes/graduation.js +1 -0
  152. package/public/js/celebrations/themes/greeting.js +1 -0
  153. package/public/js/celebrations/themes/make-it-rain.js +1 -0
  154. package/public/js/celebrations/themes/money-rain.js +1 -0
  155. package/public/js/celebrations/themes/new-year.js +1 -0
  156. package/public/js/celebrations/themes/occasion-drawing.js +1 -0
  157. package/public/js/celebrations/themes/occasions.js +1 -0
  158. package/public/js/celebrations/themes/rain-control.js +1 -0
  159. package/public/js/celebrations/themes/sparkler-font-data.js +1 -0
  160. package/public/js/celebrations/themes/sparkler-font.js +1 -0
  161. package/public/js/celebrations/themes/sparkler-writing.js +1 -0
  162. package/public/js/celebrations/themes/summer-garden.js +1 -0
  163. package/public/js/celebrations/themes/winter.js +1 -0
  164. package/public/js/celebrations/trait-data.mjs +1 -1
  165. package/public/js/effects.js +1 -1
  166. package/scripts/build.js +4 -0
  167. package/server/services/markdown.js +5 -2
  168. package/server/templates/page.html +1 -1
@@ -0,0 +1,69 @@
1
+ /**
2
+ * admin/lib/email.js - the mailto: fallback and link reading (node has no
3
+ * /admin/js/lib/mail-compose.js, so emailTo() here is the older-core path).
4
+ */
5
+ import {test} from 'node:test';
6
+ import assert from 'node:assert/strict';
7
+ import {emailTo, looksLikeAddress, mailtoHref, parseMailto} from '../admin/lib/email.js';
8
+
9
+ test('mailtoHref: one person in To, subject and body encoded, @ readable', () => {
10
+ assert.equal(mailtoHref({to: [{name: 'Ann', address: 'ann+x@example.test'}], subject: 'Hi & bye', body: 'Line 1\nLine 2'}),
11
+ 'mailto:ann%2Bx@example.test?subject=Hi%20%26%20bye&body=Line%201%0ALine%202');
12
+ });
13
+
14
+ test('mailtoHref: several people in Bcc, strings and contacts alike', () => {
15
+ assert.equal(mailtoHref({bcc: ['a@x.test', {email: 'b@x.test'}], subject: 'S'}), 'mailto:?bcc=a@x.test,b@x.test&subject=S');
16
+ });
17
+
18
+ test('parseMailto reads back what mailtoHref writes, and plain links', () => {
19
+ const r = parseMailto(mailtoHref({to: 'a@x.test', cc: ['c@x.test'], bcc: ['b@x.test', 'd@x.test'], subject: 'Hi + there', body: 'Join: https://x.test/?a=1&b=2'}));
20
+ assert.deepEqual(r, {to: ['a@x.test'], cc: ['c@x.test'], bcc: ['b@x.test', 'd@x.test'], subject: 'Hi + there', body: 'Join: https://x.test/?a=1&b=2'});
21
+ assert.deepEqual(parseMailto('mailto:ann@example.test'), {to: ['ann@example.test'], cc: [], bcc: [], subject: '', body: ''});
22
+ assert.equal(parseMailto('https://example.test'), null);
23
+ });
24
+
25
+ test('emailTo on a core without mail-compose.js keeps the old mailto:', async () => {
26
+ const saved = globalThis.location;
27
+ globalThis.location = {href: '', hash: ''};
28
+ try {
29
+ assert.equal(await emailTo({to: [{name: 'Ann', address: 'ann@example.test'}], subject: 'Hello'}), 'mailto');
30
+ assert.equal(globalThis.location.href, 'mailto:ann@example.test?subject=Hello');
31
+ assert.equal(globalThis.location.hash, '');
32
+ } finally {
33
+ globalThis.location = saved;
34
+ }
35
+ });
36
+
37
+ test('fallback hardening: bad addresses dropped, repeats once, subject one line, text capped', () => {
38
+ for (const bad of ['a b@x.test', 'a@x.test\r\nBcc: c@x.test', '<a@x.test>', 'a@x.test,b@x.test', 'a@x.test?body=hi', 'nobody']) assert.equal(looksLikeAddress(bad), false, bad);
39
+ const href = mailtoHref({to: ['A@x.test', 'a@x.test', 'a b@x.test', 'me@x.test?body=evil'], subject: 'Hi\r\nBcc: c@x.test', body: 'x'.repeat(3000)});
40
+ assert.ok(href.startsWith('mailto:A@x.test?subject=Hi%20Bcc%3A%20c%40x.test&body='), href);
41
+ assert.equal(decodeURIComponent(href.split('body=')[1]).length, 2000);
42
+ });
43
+
44
+ test('parseMailto ignores the query when the address part is not an address', () => {
45
+ // An address stored as "me@x.com?body=..." and encoded into a link.
46
+ assert.deepEqual(parseMailto(`mailto:${encodeURIComponent('me@x.test?body=Pay now')}`), {to: [], cc: [], bcc: [], subject: '', body: ''});
47
+ assert.deepEqual(parseMailto('mailto:me@x.test%0D%0Abcc:z@x.test?subject=Hi&bcc=y@x.test'), {to: [], cc: [], bcc: [], subject: '', body: ''});
48
+ assert.deepEqual(parseMailto('mailto:?subject=Join&body=link').subject, 'Join');
49
+ });
50
+
51
+ test('emailTo on an old core: a mailto over 1800 characters is not opened - the addresses are copied', async () => {
52
+ const saved = {location: globalThis.location, E: globalThis.E, nav: Object.getOwnPropertyDescriptor(globalThis, 'navigator')};
53
+ let copied = '';
54
+ const toasts = [];
55
+ globalThis.location = {href: '', hash: ''};
56
+ globalThis.E = {toast: (m) => toasts.push(m)};
57
+ Object.defineProperty(globalThis, 'navigator', {value: {clipboard: {writeText: async (t) => { copied = t; }}}, configurable: true});
58
+ try {
59
+ const bcc = Array.from({length: 120}, (_, i) => `person${i}@example.test`);
60
+ assert.equal(await emailTo({bcc, subject: 'News'}), 'copied');
61
+ assert.equal(globalThis.location.href, '');
62
+ assert.equal(copied, bcc.join(', '));
63
+ assert.match(toasts[0], /120 addresses are copied.*Not carried over: the subject/);
64
+ } finally {
65
+ globalThis.location = saved.location;
66
+ globalThis.E = saved.E;
67
+ if (saved.nav) Object.defineProperty(globalThis, 'navigator', saved.nav); else delete globalThis.navigator;
68
+ }
69
+ });
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "note": "Written by `make sync-free-tier` in dcms-marketplace. Do not edit these plugins here - edit them there and sync.",
3
- "source": "dcms-marketplace@72b2ff0",
3
+ "source": "dcms-marketplace@ddb1e0c",
4
4
  "plugins": {
5
5
  "blog": {
6
- "version": "1.10.0",
6
+ "version": "1.10.1",
7
7
  "files": {
8
- "CLAUDE.md": "67bea3889545180a0f385a42f8392453f89c8568d59303f3afb23804edbcf078",
8
+ "CLAUDE.md": "357072eb15b3c2b04b25a18ed44b3d569e1bbdf927118d5b472a9b952c3778d0",
9
9
  "admin/css/index.css": "8d6dfd2bfadf0bbe8efbd52ef9b397ca9d36ca699c80e260aec11f677c77a248",
10
10
  "admin/lib/drafts.js": "60446f6bf93b790f07041fbb95dac30b12cd0ebc3caa71d15f2a7dc16c661b0d",
11
+ "admin/lib/email.js": "89b9a96251b4ba7323376b6a59b9b31c52387ab7fad02cddef57e7629ea5e119",
11
12
  "admin/templates/blog.html": "1632dc30cbdd39dad3939a6b137c52fcc76fbd3ea52bd5f5574d8a4d915aac0b",
12
13
  "admin/templates/categories.html": "d87d20704fb661d50276a4a1447d350656aee808bcf36af73e33bc4e2ccca464",
13
14
  "admin/templates/comments.html": "70893fe44a60de42c7977a91edc87c86cbc065d68c2f80d0b5fbe7fb83176ebc",
@@ -15,7 +16,7 @@
15
16
  "admin/templates/settings.html": "e0730cd57435e592034328a699198d5e1326084767156bfc2289852f5f1a45af",
16
17
  "admin/views/blog.js": "959a2e9e22ba3e9ab19932cdf34002ec6bc592ac83a65febf08f5626e39765ba",
17
18
  "admin/views/categories.js": "92946bba9740e5f3ce6770bf283d5db5f061353cf7afa10ecf1dac38ead7d837",
18
- "admin/views/comments.js": "e122a8a4120203535bd8345263cb4d511e8e4750e0b68b83fe0e722c3b096244",
19
+ "admin/views/comments.js": "ead4477f75c751cc1940ce2e5d272f6498c4940a34f69b3e896c47c7c9c4e263",
19
20
  "admin/views/kit.js": "a7d705de235bd7f125e5ff0607134863c1e67112f3b5876ed97dbbdded202dbc",
20
21
  "admin/views/post-editor.js": "a522f6f9692180e207b64b932d1ed999578dc6b14a2011dc9a74c4ab7f489d12",
21
22
  "admin/views/settings-cog.js": "307efc93835863dd8511f8fb17a224cf45a77532c90b854a86d2cd1d4e5f9f18",
@@ -52,8 +53,8 @@
52
53
  "lib/render.js": "0e97c6a950bc962c8d8ea4b2f21d06cb73fbcdc738d8942d6935d01309a29b1d",
53
54
  "lib/samples.js": "e8cdb77ce22e43937707f6854d3a5cb722437dc584e22ac7b24480bef686cf85",
54
55
  "plugin.js": "74b791100e3382fe62faf78e135df07f1ebafb4b52269890dac357ded7e54832",
55
- "plugin.json": "37dda4ee698f50eb444422fbd7454e91db195ce6b635b19b7946aa4f0b14565e",
56
- "plugin.public.js": "081ca0ef3e91fa5712392b332f19f17f45bd9ef741f1372c8a583c28bfa7f535",
56
+ "plugin.json": "d4e9376ee0fe982317d421e50d670d883d4f914406c77689ed56aa82195fa0f3",
57
+ "plugin.public.js": "0718b1610cebbdcca43012c9c4b67774c1baca2d4ccdcec4ddbd991458951cd8",
57
58
  "public/blog.css": "fd733e6b624190da1e70dc1b6613e2376efd7f7570a28fab311d81006d03d960",
58
59
  "public/blog.js": "d01c72a9834dcc7c5241923371f2b164ac30d20ac9f1a5c5dc5b71fa3cb09f08",
59
60
  "public/samples/aurora.svg": "feb29e2b46465913fc29de9eda221b00b1541f1fa3ea7120f0c1d1cd11a9a4f6",
@@ -70,6 +71,7 @@
70
71
  "tests/cache.test.js": "f823d9ff65c5b5594a8e3d1d3b598cc3524f10885ddf34017cf0a9364878a98f",
71
72
  "tests/comment-notices.test.js": "34026cc9a2a4746cf87bc41df8be849fadaa43091a72ac2aa1d06c1f437bf618",
72
73
  "tests/drafts.test.js": "7d4c86f13b61a99bab3ef17448f4c633b401c1cd79a41d346fe59288042c437f",
74
+ "tests/email.test.js": "2190b6dd7cc9afad99d2170f002343fe3dad306aa14ac718428e5df0be54ded1",
73
75
  "tests/layouts.test.js": "554cff8194bd650cfb5f2a83c1f51c25f427c07f7dbfdc2ad9ad69bb38fca6a0",
74
76
  "tests/nav-link.test.js": "d36e33ad7483abca27ae6e2098ad2f75bafa18d91f3beba70372ebe6b9b88994",
75
77
  "tests/notices.test.js": "2b02aa84e780dc4c82e6c503fc8fe17c64a63bee0709627866ef97c99cb4e131",
@@ -77,20 +79,21 @@
77
79
  }
78
80
  },
79
81
  "booking": {
80
- "version": "1.7.0",
82
+ "version": "1.7.1",
81
83
  "files": {
82
- "CLAUDE.md": "afca62bf08d8dca02402c784d33e3882a480f09c8a11e60f54ad20d1424f748d",
84
+ "CLAUDE.md": "d65d0008f84d42f71167d24477dd9dcdb78c31bd6fd146ad8ac60f06989f745f",
83
85
  "admin/css/index.css": "4f7731921c0c5038cb1566a6ab2d43ffc35bf9b161e58f87a0cff423e81b47fa",
84
86
  "admin/lib/details.js": "8b37536bfa9ccfcc5265cc957ba8266d3f5f777133e7c0946ae49540f1c80e3c",
85
87
  "admin/lib/diary-layout.js": "d0e36674ff454e5217b02c3ef3b820e4dece97a62df618a6052016dfeefab1c9",
86
88
  "admin/lib/drafts.js": "90d6c8403ef7c6a01569ad925939ce7634ab0853f7e3097d522c1e850636d6b1",
89
+ "admin/lib/email.js": "46e3e24b6be5a4667054a31dc0e73641f763d189129c93457900273ee4c8d5a8",
87
90
  "admin/lib/extension-sections.js": "0588ad47660e511b0dd8077bb9c3999c775d97597333a75e87ee12d915bbf00b",
88
91
  "admin/lib/kit.js": "403e792195e95770f6304bafab14ff13295c2bcc68cccda27e019a6739d0e888",
89
92
  "admin/templates/booking.html": "20b9a3bfe3e5d5bbee613f29be99551b12790fb38f80d119585360cc38e9ec57",
90
93
  "admin/views/booking.js": "939bf77016880ee091a9ee6cd6633cac0014801426b4c5bff9863d63aecd87a6",
91
94
  "admin/views/bookings.js": "bbe1068448e78134a5102ad9d7af16892f75a4449f150e92e649e66e7232e56b",
92
95
  "admin/views/diary.js": "bea962e57fc3be6ed07f5c6588889fffb106bc251193c0c48743f1f2442a6eef",
93
- "admin/views/panels.js": "313bf09704e9fbed379c6f7a4ffb000c53460b9747311310482514c0c6d680c1",
96
+ "admin/views/panels.js": "cf6abeb6fc5f37aa3a30eec98d3b90ece5adab9436a8479899216043b28be07c",
94
97
  "admin/views/people.js": "55cc6d07b98ed305d577772b921eb8d09b564b099cb8d35441c1b39631e4764a",
95
98
  "admin/views/services.js": "32a2539391d06ec576c0af6d7aef1bbf71e22d6335c3654acb80491e56f19f41",
96
99
  "admin/views/settings.js": "7af543fa0e2772025c436b60b9a49282baa45f8af42e6d202096b9fcbc6336c2",
@@ -105,7 +108,7 @@
105
108
  "lib/mail.js": "cad8f409df62d6e42f0f4024ec364bbe018a62b842fa3f7c38786fd4e7f92408",
106
109
  "lib/store.js": "7aa7967e4694e5a3b85378f60302e5a47394b1d90c7dd86e09578156f1c13e03",
107
110
  "plugin.js": "4a303855a5a7f746e07e45a937dfeac8984dc9254c2f9b1a60b6f6306912ed84",
108
- "plugin.json": "d05342466f1f48d18e2a1bf8452a2609de69f9c470d523985bd24ef518eb2ab7",
111
+ "plugin.json": "38a463f7c9c73de1419bb256d86b320abfd92b04eb5638716edcbd76702f1939",
109
112
  "plugin.public.js": "4d5b4e8ad6943182ee3b6c6e6f6762a2d3f676d8d7ee363fcb07bd47d3d6532e",
110
113
  "public/booking.css": "8b88989fdd04e50efc1688a2f32fe2e422299d7d13b81bb8fce0cc162fa99df6",
111
114
  "public/booking.js": "7dfc3d205696967013886567f67a867443c2e370bac29019d69911d695fdbade",
@@ -117,6 +120,7 @@
117
120
  "tests/admin-diary.test.js": "6bd117af798e748234c94e4e66339ff1ec3bba9633790a2a5fd291f64c30e484",
118
121
  "tests/admin-drafts.test.js": "c9e857b2326965b3dbb34e344282d874348f84b5cd9338ced2ca2c7a07713a25",
119
122
  "tests/api.test.js": "efb3767f7efde08c11c8edcb5753889773b421188798f725aff0e4e533860aff",
123
+ "tests/email.test.js": "2190b6dd7cc9afad99d2170f002343fe3dad306aa14ac718428e5df0be54ded1",
120
124
  "tests/public.test.js": "0b7b626d60df5a3d73d7c0077b73f59b62a9fded98ce84a8d93cd32cd0333159",
121
125
  "tests/pure.test.js": "8ba0c8f76b4c9efcc422f39ff29509612544d81f760025a4b9a5594af14e7bcf"
122
126
  }
@@ -189,15 +193,16 @@
189
193
  }
190
194
  },
191
195
  "shopping-cart": {
192
- "version": "1.7.0",
196
+ "version": "1.7.1",
193
197
  "files": {
194
- "CLAUDE.md": "52ee2002bf60f1a1164c52be5040351a593f38ef8366e5258032b07b10739af0",
198
+ "CLAUDE.md": "632cfa9f526394a20046f8a0817289ea6c6bd20508b385d0baf50cc9d118c394",
195
199
  "admin/css/index.css": "cdd7790511deef162ad30e299b4512d289583e978ba3b87d65945cdf1da3cdda",
196
200
  "admin/lib/chart.js": "b01ce5cfac773c8df8efccab50b67d3dfa99fbead0037d817553db4a6688d4d6",
197
201
  "admin/lib/drafts.js": "9e71b939f6c98d5c25875f35b02c367a5e89e0d2c6d084d6a4de0c71128930a2",
202
+ "admin/lib/email.js": "9f842932c8de39ac6878463bd49c443df82ecf64872dad48ff5362d6b61c1e2c",
198
203
  "admin/lib/kit.js": "94e5b5d979ded3318df2d0291bc9aeeb44af945aa0e84e68f9af10f5a53ae458",
199
204
  "admin/templates/shop.html": "c5bb03f1f7cbabfbd8202f3533783eb1848103755b1ba25fdcf1fd8e9478cb8e",
200
- "admin/views/orders.js": "8c4b3e03e91a2caa4b9a5143b4ecafd1870da27888755b4205efb1e8d8bee59e",
205
+ "admin/views/orders.js": "3bf34dc8efaf4b044e92e494b95471a256988655a60c81a4ec1e6def3766f701",
201
206
  "admin/views/overview.js": "02241e75976cfa759d6ba738dd13ca0bd2bcb760d66a5f184becc2e472807efc",
202
207
  "admin/views/products.js": "b35893d85b92db0048459431258f2a235b1f0824b3601bebc5e5d94fdcc0d10f",
203
208
  "admin/views/sales.js": "001c08963e26df72f43d2357bbcc5a0f54f74f9d22bca319c23a28a50f40c124",
@@ -220,7 +225,7 @@
220
225
  "lib/shop.js": "baa5dfc4e410210e8ba13678997ee5752eb2ebe72fc4d3e449465d29b60b458d",
221
226
  "lib/summary.js": "cdb13ce3d1799d429059fa03f179281711dc00427ccf2eb6b8f8aa52fef26295",
222
227
  "plugin.js": "824dba8336846d443b2427ed9a5adeba11740570566fc6e89257f9847a488632",
223
- "plugin.json": "03a80c969e7e7acb0a07c37da23fb2867e56b109d506235254d60c270d45da94",
228
+ "plugin.json": "2d9faac96c212946d911fa1bb031969721a3169aac69cc453ac318e2fd1cf3b4",
224
229
  "plugin.public.js": "2f92e8340c9da653401c11dd99dab033dc6772d63fa2114489192c48e9e0be00",
225
230
  "public/account.js": "5f644016c098c7879c59948d662f5997cb61680996204ecb7897baab8945d434",
226
231
  "public/cart.js": "7338141392ec653ff616eb75688d2a2ad08cff8427d7020d381f540be0037b73",
@@ -247,22 +252,24 @@
247
252
  "tests/api.test.js": "15c71751a3d31171707cbb3119d21b85c1c59fb7a67272b318dd4655809ac8d2",
248
253
  "tests/commission.test.js": "fbc4cf83e0ed6446a09e57e4ff37a9608c81947c633c78ac6049eb0aedf6cb58",
249
254
  "tests/drafts.test.js": "2dec0cfeadd6df1d3b90f3fd8bce1f33762811eb6e94cd7325bcb8ec31edac42",
255
+ "tests/email.test.js": "2190b6dd7cc9afad99d2170f002343fe3dad306aa14ac718428e5df0be54ded1",
250
256
  "tests/pure.test.js": "59a351c813784e8131b96a118c79de2e3858a2fba0fc5c0a6baed79e28cafda8",
251
257
  "tests/refunds.test.js": "0ae06afca3cf9fd1fe89f1fbc63b3676216c79e174dbcb83788180c01d078366",
252
258
  "tests/sales.test.js": "9025bc608b04bcc14f5bb2c98b4f7c35de99f3ddab4ffa59772d045795bf2cb7"
253
259
  }
254
260
  },
255
261
  "support": {
256
- "version": "1.2.0",
262
+ "version": "1.2.1",
257
263
  "files": {
258
- "CLAUDE.md": "99e2856a5d57486c876126b9fb8249ff44c2ac5af1a8b471c0bbf8b888102e2a",
264
+ "CLAUDE.md": "68f5c1cda64b87f6b1c9a20e874cf884c36f6cb4aec1611a546586b80bbc579d",
259
265
  "admin/css/index.css": "e7fefb4e6d58010d8fd4c6acdf4e9597506a11a25f0fd4a450377551723ae89e",
260
266
  "admin/lib/drafts.js": "fe60c4792d34f4f92b19908ab9d030704992e463a26c0bdd6aac0284ec643d1a",
267
+ "admin/lib/email.js": "a159b09c00af6056363209b5373612957e3b9f9eb530e53a7e4ae1e5bbd194f5",
261
268
  "admin/lib/kit.js": "1208f0b2df2bb4e4d9366fda4c62464e783a10cb9e3477335c54cd14ca2da407",
262
269
  "admin/lib/settings.js": "293196cded3dbc72a092869e870a75ca587560bf76ffca3c5ab9b90c1fa09b33",
263
270
  "admin/templates/support.html": "2bb69d0443a367a402e6160fe68f4af3e8983b578cfff9575b4df9a534fcb480",
264
- "admin/views/desk.js": "5da6fa6a48cd2bbf628b7effcd72e1006338938d001cd4432eae9ccbb8fe7782",
265
- "admin/views/inbox.js": "dea7954f982317288f9517840f6cf85728e5e011bd708c4448984766f6f8b45d",
271
+ "admin/views/desk.js": "8c4ac9ee5db56942d08ebc91f138a935640849ac091188f4e86c40c7a48f9156",
272
+ "admin/views/inbox.js": "4703df468537bc752ace5046df1f3ba22e21336d277116980dd4f5f985015d8a",
266
273
  "admin/views/support.js": "0319c9150f76edc5456cc66145ce00ef082710a6c0aa3c6febba19a98f546ec9",
267
274
  "collections/support-tickets.json": "55a0856bacd66c2e8f1e3c85bdf3638e5ff826560943cda854a8f2d336a88905",
268
275
  "config.js": "eb7ccc1169fa8b2be52a213536825492fedaec5fa73fd749cba9f498dd54b503",
@@ -274,9 +281,10 @@
274
281
  "lib/sender.js": "2b308422ac60a8a2801570e06319d5972797a601640c67beee95ccab9ac64092",
275
282
  "lib/shape.js": "d60b48410aa5582ea80451c3d831686b0e29525a958733a8bc9dfaae8eca94d2",
276
283
  "plugin.js": "91fff8d66bf5fa0fa4502bb177460ae234f0ed0494a4fbe6dd94d63e2f88b571",
277
- "plugin.json": "e6e7eb5058e247be225ced7d09463e6c8c66af6904b042df726b10f6bd148b2a",
284
+ "plugin.json": "13318ff0bb1a5b5ad14dbab79a287991976d8502f2f4f9a898786c22dfb174eb",
278
285
  "tests/api.test.js": "1af65f0cba8a83c080a6e3e65544abc86fc43c8e25ca05c7f3e1ab4e3f7ac5a2",
279
286
  "tests/drafts.test.js": "08d3920cf77b61fc92cb7785853afd8a5ff55c8851c1a7237a34464fd82e842e",
287
+ "tests/email.test.js": "2190b6dd7cc9afad99d2170f002343fe3dad306aa14ac718428e5df0be54ded1",
280
288
  "tests/settings.test.js": "434acbfd940eef800b1166a9aaf36363351af5652fcfb06527b8498866b7b964",
281
289
  "tests/shape.test.js": "7866c6c1d140716bf0817449937d6d711d7c3b97be1db1e1eb33bde341e36296"
282
290
  }
@@ -263,3 +263,7 @@ amount is all that is left), a Refund button. Never put form fields in `E.confir
263
263
  destructive.
264
264
  - Fulfil and Refund panels are in `actionPanels`, closed by the screen teardown; their saves refuse once it has gone.
265
265
  - The accounts test sets a Site URL in `config/site.json` and restores it (`/account/register` needs a link base).
266
+
267
+ ## 1.7.1
268
+
269
+ - **Email (openEmail).** Email actions go through `admin/lib/email.js`: `emailTo()` for menu actions (several people always in Bcc), `routeMailLinks(root)` for visible `mailto:` links. Core's `/admin/js/lib/mail-compose.js` (CMS 1.6.61+) opens Email Pro's compose window when the user has a mailbox there; older cores keep a cleaned, capped `mailto:` (over 1800 chars the addresses are copied instead). Stored addresses are encoded into links, or shown as text when invalid. Never set `location.href = 'mailto:…'` directly.
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Email someone from this Tool: Email Pro's compose window when the user can
3
+ * send from it, otherwise the device's mail program through `mailto:`.
4
+ *
5
+ * Core makes the choice (`/admin/js/lib/mail-compose.js`, CMS 1.6.61+). It is
6
+ * imported at RUN time, never statically, so this Tool still loads on an older
7
+ * core - where every action keeps the plain `mailto:` it always had.
8
+ *
9
+ * `emailTo()` is for menu actions; `routeMailLinks()` is for a visible
10
+ * `<a href="mailto:…">` - the link stays a link (copy, hover, middle-click all
11
+ * still work) and a plain click goes the same way as the menu action.
12
+ *
13
+ * @module shopping-cart/admin/lib/email
14
+ */
15
+
16
+ const CORE = '/admin/js/lib/mail-compose.js';
17
+ let core = null;
18
+
19
+ /** The core module, or null on a core without it. Asked once. */
20
+ const loadCore = () => (core ??= import(CORE).catch(() => null));
21
+
22
+ /** Longest subject or body carried (as core's). */
23
+ const MAX_TEXT = 2000;
24
+ /** Longest mailto: handed to the device - mail programs cut or refuse longer ones. */
25
+ const MAX_MAILTO = 1800;
26
+
27
+ /**
28
+ * Something that can only be an email address: one @, no spaces or line
29
+ * breaks, nothing that would start another recipient or a query.
30
+ *
31
+ * @param {*} value
32
+ * @returns {boolean}
33
+ */
34
+ export function looksLikeAddress(value) {
35
+ return typeof value === 'string' && /^[^\s@<>,;"?&]+@[^\s@<>,;"?&]+$/.test(value);
36
+ }
37
+
38
+ /** Valid addresses only, once each (ignoring case), from a string, `{address}`/`{email}`, or a list. */
39
+ function addressesOf(list) {
40
+ const seen = new Set();
41
+ return (Array.isArray(list) ? list : list == null ? [] : [list])
42
+ .map(x => String(typeof x === 'string' ? x : (x?.address ?? x?.email ?? '')).trim())
43
+ .filter(a => looksLikeAddress(a) && !seen.has(a.toLowerCase()) && seen.add(a.toLowerCase()));
44
+ }
45
+
46
+ /** Trim and cap; a subject loses its line breaks (they would be a header). */
47
+ function cleanText(value, {oneLine = false} = {}) {
48
+ let text = String(value ?? '');
49
+ if (oneLine) text = text.replace(/[\r\n]+/g, ' ');
50
+ return text.slice(0, MAX_TEXT).trim();
51
+ }
52
+
53
+ /**
54
+ * The request as a `mailto:` link (the fallback on an older core).
55
+ *
56
+ * @param {{to?: *, cc?: *, bcc?: *, subject?: string, body?: string}} request
57
+ * @returns {string}
58
+ */
59
+ export function mailtoHref({to, cc, bcc, subject, body} = {}) {
60
+ const enc = (list) => addressesOf(list).map(a => encodeURIComponent(a).replace(/%40/g, '@')).join(',');
61
+ const s = cleanText(subject, {oneLine: true});
62
+ const b = cleanText(body);
63
+ const query = [];
64
+ if (enc(cc)) query.push(`cc=${enc(cc)}`);
65
+ if (enc(bcc)) query.push(`bcc=${enc(bcc)}`);
66
+ if (s) query.push(`subject=${encodeURIComponent(s)}`);
67
+ if (b) query.push(`body=${encodeURIComponent(b)}`);
68
+ return `mailto:${enc(to)}${query.length ? `?${query.join('&')}` : ''}`;
69
+ }
70
+
71
+ /** Copy text: the clipboard, else the old copy command, else a box to copy it from by hand. */
72
+ async function copyText(text) {
73
+ try {
74
+ await navigator.clipboard.writeText(text);
75
+ return true;
76
+ } catch { /* next */ }
77
+ const box = document.createElement('textarea');
78
+ box.className = 'form-input';
79
+ box.readOnly = true;
80
+ box.rows = 6;
81
+ box.value = text;
82
+ try {
83
+ box.style.position = 'fixed';
84
+ box.style.opacity = '0';
85
+ document.body.appendChild(box);
86
+ box.select();
87
+ if (document.execCommand('copy')) return true;
88
+ } catch { /* next */ } finally {
89
+ box.remove();
90
+ box.style.position = '';
91
+ box.style.opacity = '';
92
+ }
93
+ const modal = E.modal({title: 'Copy the addresses', size: 'medium', buttons: [{id: 'close', text: 'Close', variant: 'secondary'}]});
94
+ modal.element.appendChild(box); // light DOM: setContent would strip the textarea
95
+ modal.open();
96
+ box.select();
97
+ return false;
98
+ }
99
+
100
+ /**
101
+ * Hand the request to the device's mail program - unless the link would be
102
+ * too long for it, when the addresses are copied instead and the toast says
103
+ * what did not go.
104
+ */
105
+ async function openMailto(request) {
106
+ const href = mailtoHref(request);
107
+ if (href.length <= MAX_MAILTO) {
108
+ location.href = href;
109
+ return 'mailto';
110
+ }
111
+ const all = addressesOf([...addressesOf(request.to), ...addressesOf(request.cc), ...addressesOf(request.bcc)]);
112
+ const copied = all.length ? await copyText(all.join(', ')) : false;
113
+ const lost = [cleanText(request.subject) && 'the subject', cleanText(request.body) && 'the message'].filter(Boolean);
114
+ E.toast(`Too long for your mail program to open. ${all.length
115
+ ? `${copied ? 'The' : 'Copy the'} ${all.length} address${all.length === 1 ? '' : 'es'}${copied ? ' are copied' : ''} - paste them into Bcc of a new email.` : ''}${lost.length ? ` Not carried over: ${lost.join(' and ')}.` : ''}`,
116
+ {type: 'warning', duration: 9000});
117
+ return 'copied';
118
+ }
119
+
120
+ const decode = (s) => { try { return decodeURIComponent(s); } catch { return s; } };
121
+
122
+ /**
123
+ * A `mailto:` link read back into a request (what a visible link carries).
124
+ * When the address part holds anything that is not an address, the query
125
+ * is ignored: an address stored as `me@x.com?body=…` must not prefill a message.
126
+ *
127
+ * @param {string} href
128
+ * @returns {null|{to: string[], cc: string[], bcc: string[], subject: string, body: string}}
129
+ */
130
+ export function parseMailto(href) {
131
+ const m = String(href ?? '').match(/^mailto:([^?]*)(?:\?(.*))?$/i);
132
+ if (!m) return null;
133
+ const split = (s) => decode(s || '').split(/[,;]/).map(x => x.trim()).filter(Boolean);
134
+ const named = split(m[1]);
135
+ const out = {to: addressesOf(named), cc: [], bcc: [], subject: '', body: ''};
136
+ if (named.some(a => !looksLikeAddress(a))) return out;
137
+ for (const pair of (m[2] || '').split('&')) {
138
+ const i = pair.indexOf('=');
139
+ if (i < 1) continue;
140
+ const key = pair.slice(0, i).toLowerCase();
141
+ const value = pair.slice(i + 1);
142
+ if (key === 'to') out.to = addressesOf([...out.to, ...split(value)]);
143
+ else if (key === 'cc' || key === 'bcc') out[key] = addressesOf([...out[key], ...split(value)]);
144
+ else if (key === 'subject') out.subject = cleanText(decode(value), {oneLine: true});
145
+ else if (key === 'body') out.body = cleanText(decode(value));
146
+ }
147
+ return out;
148
+ }
149
+
150
+ /**
151
+ * Email someone. Recipients are `{name, address}`, `{name, email}` or bare
152
+ * addresses; several people belong in `bcc`, so nobody sees the others.
153
+ * With nobody to address (a link to pass on) compose still opens, To empty.
154
+ *
155
+ * @param {{to?: *, cc?: *, bcc?: *, subject?: string, body?: string}} request
156
+ * @returns {Promise<'compose'|'mailto'|'copied'|'none'>}
157
+ */
158
+ export async function emailTo(request = {}) {
159
+ const mail = await loadCore();
160
+ if (!mail) return openMailto(request);
161
+ const r = mail.composeRequest(request);
162
+ if (r.to.length || r.cc.length || r.bcc.length) return mail.openEmail(r);
163
+ if (await mail.emailReady()) {
164
+ location.hash = mail.composeHash(r);
165
+ return 'compose';
166
+ }
167
+ location.href = mail.mailtoHref(r);
168
+ return 'mailto';
169
+ }
170
+
171
+ /**
172
+ * Send plain clicks on the `mailto:` links inside `root` through `emailTo()`.
173
+ * A modified click (new tab/window) or one already handled is left alone.
174
+ *
175
+ * @param {Element} root
176
+ * @returns {() => void} removes the listener
177
+ */
178
+ export function routeMailLinks(root) {
179
+ if (!root) return () => {};
180
+ const onClick = (e) => {
181
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
182
+ const a = e.target?.closest?.('a[href^="mailto:" i]');
183
+ if (!a || !root.contains(a)) return;
184
+ const request = parseMailto(a.getAttribute('href'));
185
+ if (!request) return;
186
+ e.preventDefault();
187
+ emailTo(request);
188
+ };
189
+ root.addEventListener('click', onClick);
190
+ return () => root.removeEventListener('click', onClick);
191
+ }
@@ -11,6 +11,7 @@
11
11
 
12
12
  import {api, claims, copy, deferItems, entriesOf, esc, fmtDate, fmtDateTime, money, moneyIn, moneyOut, mountPanels, openPanel, refreshBadge, store, when, wireRows} from '../lib/kit.js';
13
13
  import {NEXT, STATUS_LABEL, STATUS_TONE, addressLines, orderLabel} from '/plugins/shopping-cart/public/lib/orders.js';
14
+ import {emailTo, looksLikeAddress, routeMailLinks} from '../lib/email.js';
14
15
 
15
16
  const FILTERS = [
16
17
  {key: 'open', label: 'To do', match: (s) => s === 'paid' || s === 'awaiting'},
@@ -347,7 +348,7 @@ ${(d.lines || []).map(l => `<tr><td class="q">${l.qty}</td><td>${esc(l.name)}${l
347
348
  {type: 'divider'},
348
349
  {label: 'Packing slip', icon: 'printer', action: () => packingSlip(o)},
349
350
  {label: 'Copy receipt link', icon: 'link', action: () => copy(receiptUrl(o), 'Receipt link copied')},
350
- {label: 'Email the shopper', icon: 'mail', action: () => { location.href = `mailto:${encodeURIComponent(o.data.email)}?subject=${encodeURIComponent(`Your order ${orderLabel(o.data)}`)}`; }},
351
+ {label: 'Email the shopper', icon: 'mail', action: () => emailTo({to: [{name: o.data.customer?.name, address: o.data.email}], subject: `Your order ${orderLabel(o.data)}`})},
351
352
  ...(['pending', 'cancelled', 'awaiting'].includes(o.data.status) ? [{type: 'divider'}, {label: 'Delete…', icon: 'trash', danger: true, action: () => remove(o)}] : [])
352
353
  ];
353
354
  }
@@ -398,6 +399,7 @@ ${(d.lines || []).map(l => `<tr><td class="q">${l.qty}</td><td>${esc(l.name)}${l
398
399
  }
399
400
  };
400
401
  let extPanels = null;
402
+ let unrouteMail = () => {};
401
403
  const ext = Object.entries(d.ext || {}).flatMap(([owner, facts]) => Object.entries(facts || {}).map(([k, v]) => ({owner, k, v})))
402
404
  .filter(x => ['string', 'number', 'boolean'].includes(typeof x.v));
403
405
  const addr = addressLines(d.address);
@@ -420,7 +422,7 @@ ${(d.lines || []).map(l => `<tr><td class="q">${l.qty}</td><td>${esc(l.name)}${l
420
422
  <div class="is-total"><dt>Total</dt><dd>${esc(money(d.total))}</dd></div>
421
423
  </dl>
422
424
  <div class="shp-order-cols">
423
- <section><h4>Shopper</h4><p><strong>${esc(d.customer?.name || '')}</strong><br><a href="mailto:${esc(d.email)}">${esc(d.email)}</a>${d.customer?.phone ? `<br><a href="tel:${esc(d.customer.phone)}">${esc(d.customer.phone)}</a>` : ''}</p></section>
425
+ <section><h4>Shopper</h4><p><strong>${esc(d.customer?.name || '')}</strong><br>${looksLikeAddress(d.email) ? `<a href="mailto:${esc(encodeURIComponent(d.email))}">${esc(d.email)}</a>` : esc(d.email || '')}${d.customer?.phone ? `<br><a href="tel:${esc(d.customer.phone)}">${esc(d.customer.phone)}</a>` : ''}</p></section>
424
426
  <section><h4>${d.delivery === 'collect' ? 'Collecting' : d.requiresShipping ? 'Deliver to' : 'Delivery'}</h4>
425
427
  <p>${d.delivery === 'collect' ? esc(settings.collectionLabel || 'In person') : addr.length ? addr.map(esc).join('<br>') : 'Nothing to ship.'}</p>
426
428
  ${d.tracking ? `<p class="shp-muted">${esc([d.tracking.carrier, d.tracking.number].filter(Boolean).join(' · '))}${d.tracking.url ? ` · <a href="${esc(d.tracking.url)}" target="_blank" rel="noopener">track</a>` : ''}</p>` : ''}</section>
@@ -443,8 +445,14 @@ ${(d.lines || []).map(l => `<tr><td class="q">${l.qty}</td><td>${esc(l.name)}${l
443
445
  size: 'lg',
444
446
  model: {staffNote, status},
445
447
  html,
446
- before: (el) => { const n = el.querySelector('.shp-callout p'); if (n) n.textContent = d.note; },
448
+ before: (el) => {
449
+ const n = el.querySelector('.shp-callout p');
450
+ if (n) n.textContent = d.note;
451
+ // The shopper's address stays a link; a click goes to Email Pro's compose when it can.
452
+ unrouteMail = routeMailLinks(el);
453
+ },
447
454
  cleanup: () => {
455
+ unrouteMail();
448
456
  if (panels.get(o.id) === panel) panels.delete(o.id);
449
457
  release();
450
458
  extPanels?.destroy();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shopping-cart",
3
3
  "displayName": "Shopping Cart",
4
- "version": "1.7.0",
4
+ "version": "1.7.1",
5
5
  "tier": "free",
6
6
  "description": "Sell from your site: products with options, stock and pictures, a storefront and a cart that follows shoppers from page to page, and checkout with Stripe, PayPal or payment offline. Orders to fulfil in the sidebar, refunds from the order.",
7
7
  "author": "Domma CMS",
@@ -45,7 +45,7 @@
45
45
  ],
46
46
  "views": {
47
47
  "plugin-shopping-cart": {
48
- "entry": "shopping-cart/admin/views/shop.js?v=1.7.0",
48
+ "entry": "shopping-cart/admin/views/shop.js?v=1.7.1",
49
49
  "exportName": "shopView"
50
50
  }
51
51
  }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * admin/lib/email.js - the mailto: fallback and link reading (node has no
3
+ * /admin/js/lib/mail-compose.js, so emailTo() here is the older-core path).
4
+ */
5
+ import {test} from 'node:test';
6
+ import assert from 'node:assert/strict';
7
+ import {emailTo, looksLikeAddress, mailtoHref, parseMailto} from '../admin/lib/email.js';
8
+
9
+ test('mailtoHref: one person in To, subject and body encoded, @ readable', () => {
10
+ assert.equal(mailtoHref({to: [{name: 'Ann', address: 'ann+x@example.test'}], subject: 'Hi & bye', body: 'Line 1\nLine 2'}),
11
+ 'mailto:ann%2Bx@example.test?subject=Hi%20%26%20bye&body=Line%201%0ALine%202');
12
+ });
13
+
14
+ test('mailtoHref: several people in Bcc, strings and contacts alike', () => {
15
+ assert.equal(mailtoHref({bcc: ['a@x.test', {email: 'b@x.test'}], subject: 'S'}), 'mailto:?bcc=a@x.test,b@x.test&subject=S');
16
+ });
17
+
18
+ test('parseMailto reads back what mailtoHref writes, and plain links', () => {
19
+ const r = parseMailto(mailtoHref({to: 'a@x.test', cc: ['c@x.test'], bcc: ['b@x.test', 'd@x.test'], subject: 'Hi + there', body: 'Join: https://x.test/?a=1&b=2'}));
20
+ assert.deepEqual(r, {to: ['a@x.test'], cc: ['c@x.test'], bcc: ['b@x.test', 'd@x.test'], subject: 'Hi + there', body: 'Join: https://x.test/?a=1&b=2'});
21
+ assert.deepEqual(parseMailto('mailto:ann@example.test'), {to: ['ann@example.test'], cc: [], bcc: [], subject: '', body: ''});
22
+ assert.equal(parseMailto('https://example.test'), null);
23
+ });
24
+
25
+ test('emailTo on a core without mail-compose.js keeps the old mailto:', async () => {
26
+ const saved = globalThis.location;
27
+ globalThis.location = {href: '', hash: ''};
28
+ try {
29
+ assert.equal(await emailTo({to: [{name: 'Ann', address: 'ann@example.test'}], subject: 'Hello'}), 'mailto');
30
+ assert.equal(globalThis.location.href, 'mailto:ann@example.test?subject=Hello');
31
+ assert.equal(globalThis.location.hash, '');
32
+ } finally {
33
+ globalThis.location = saved;
34
+ }
35
+ });
36
+
37
+ test('fallback hardening: bad addresses dropped, repeats once, subject one line, text capped', () => {
38
+ for (const bad of ['a b@x.test', 'a@x.test\r\nBcc: c@x.test', '<a@x.test>', 'a@x.test,b@x.test', 'a@x.test?body=hi', 'nobody']) assert.equal(looksLikeAddress(bad), false, bad);
39
+ const href = mailtoHref({to: ['A@x.test', 'a@x.test', 'a b@x.test', 'me@x.test?body=evil'], subject: 'Hi\r\nBcc: c@x.test', body: 'x'.repeat(3000)});
40
+ assert.ok(href.startsWith('mailto:A@x.test?subject=Hi%20Bcc%3A%20c%40x.test&body='), href);
41
+ assert.equal(decodeURIComponent(href.split('body=')[1]).length, 2000);
42
+ });
43
+
44
+ test('parseMailto ignores the query when the address part is not an address', () => {
45
+ // An address stored as "me@x.com?body=..." and encoded into a link.
46
+ assert.deepEqual(parseMailto(`mailto:${encodeURIComponent('me@x.test?body=Pay now')}`), {to: [], cc: [], bcc: [], subject: '', body: ''});
47
+ assert.deepEqual(parseMailto('mailto:me@x.test%0D%0Abcc:z@x.test?subject=Hi&bcc=y@x.test'), {to: [], cc: [], bcc: [], subject: '', body: ''});
48
+ assert.deepEqual(parseMailto('mailto:?subject=Join&body=link').subject, 'Join');
49
+ });
50
+
51
+ test('emailTo on an old core: a mailto over 1800 characters is not opened - the addresses are copied', async () => {
52
+ const saved = {location: globalThis.location, E: globalThis.E, nav: Object.getOwnPropertyDescriptor(globalThis, 'navigator')};
53
+ let copied = '';
54
+ const toasts = [];
55
+ globalThis.location = {href: '', hash: ''};
56
+ globalThis.E = {toast: (m) => toasts.push(m)};
57
+ Object.defineProperty(globalThis, 'navigator', {value: {clipboard: {writeText: async (t) => { copied = t; }}}, configurable: true});
58
+ try {
59
+ const bcc = Array.from({length: 120}, (_, i) => `person${i}@example.test`);
60
+ assert.equal(await emailTo({bcc, subject: 'News'}), 'copied');
61
+ assert.equal(globalThis.location.href, '');
62
+ assert.equal(copied, bcc.join(', '));
63
+ assert.match(toasts[0], /120 addresses are copied.*Not carried over: the subject/);
64
+ } finally {
65
+ globalThis.location = saved.location;
66
+ globalThis.E = saved.E;
67
+ if (saved.nav) Object.defineProperty(globalThis, 'navigator', saved.nav); else delete globalThis.navigator;
68
+ }
69
+ });
@@ -154,3 +154,7 @@ removes the rest. Found on the dcm click-through.
154
154
  keydown while the opening Enter is still bubbling and would read it as OK = Throw away.
155
155
  - Opening a request: only a 404 counts as deleted; any other failure toasts and keeps the draft. The desk's file picker
156
156
  has `drop(ids)` - remove only the attachments that went with the message.
157
+
158
+ ## 1.2.1
159
+
160
+ - **Email (openEmail).** Email actions go through `admin/lib/email.js`: `emailTo()` for menu actions (several people always in Bcc), `routeMailLinks(root)` for visible `mailto:` links. Core's `/admin/js/lib/mail-compose.js` (CMS 1.6.61+) opens Email Pro's compose window when the user has a mailbox there; older cores keep a cleaned, capped `mailto:` (over 1800 chars the addresses are copied instead). Stored addresses are encoded into links, or shown as text when invalid. Never set `location.href = 'mailto:…'` directly.