domma-cms 1.7.0 → 1.7.2
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 +9 -0
- package/CLAUDE.md +30 -0
- package/admin/js/app.js +2 -2
- package/admin/js/lib/mail-compose.js +1 -0
- package/admin/js/lib/wordpress-import-arrange.js +1 -0
- package/admin/js/templates/call-new.html +1 -1
- package/admin/js/templates/docs/usage-tools.html +13 -1
- package/admin/js/templates/wordpress-import.html +223 -0
- package/admin/js/views/call-new.js +1 -1
- package/admin/js/views/contacts.js +15 -15
- package/admin/js/views/form-submissions.js +2 -2
- package/admin/js/views/index.js +1 -1
- package/admin/js/views/wordpress-import.js +38 -0
- package/package.json +1 -1
- package/plugins/_lib/admin/mail/compose-window.js +3 -1
- package/plugins/_lib/admin/mail/identity.js +18 -3
- package/plugins/_lib/admin/mail/reader-view.js +32 -3
- package/plugins/blog/CLAUDE.md +4 -0
- package/plugins/blog/admin/lib/email.js +191 -0
- package/plugins/blog/admin/views/comments.js +3 -1
- package/plugins/blog/plugin.json +2 -2
- package/plugins/blog/plugin.public.js +1 -1
- package/plugins/blog/tests/email.test.js +69 -0
- package/plugins/booking/CLAUDE.md +4 -0
- package/plugins/booking/admin/lib/email.js +191 -0
- package/plugins/booking/admin/views/panels.js +7 -3
- package/plugins/booking/plugin.json +1 -1
- package/plugins/booking/tests/email.test.js +69 -0
- package/plugins/free-tier.lock.json +27 -19
- package/plugins/shopping-cart/CLAUDE.md +4 -0
- package/plugins/shopping-cart/admin/lib/email.js +191 -0
- package/plugins/shopping-cart/admin/views/orders.js +11 -3
- package/plugins/shopping-cart/plugin.json +2 -2
- package/plugins/shopping-cart/tests/email.test.js +69 -0
- package/plugins/support/CLAUDE.md +4 -0
- package/plugins/support/admin/lib/email.js +191 -0
- package/plugins/support/admin/views/desk.js +4 -1
- package/plugins/support/admin/views/inbox.js +6 -2
- package/plugins/support/plugin.json +2 -2
- package/plugins/support/tests/email.test.js +69 -0
- package/server/routes/api/wordpress-import.js +220 -0
- package/server/server.js +12 -0
- package/server/services/hooks.js +1 -1
- package/server/services/permissionRegistry.js +10 -0
- package/server/services/roles.js +1 -1
- package/server/services/tools.js +2 -1
- package/server/services/wpImport/convert.js +491 -0
- package/server/services/wpImport/fetch.js +264 -0
- package/server/services/wpImport/index.js +832 -0
- package/server/services/wpImport/plan.js +549 -0
- package/server/services/wpImport/store.js +242 -0
- package/server/services/wpImport/wxr.js +167 -0
- package/server/services/wpImport/xml.js +261 -0
- package/server/services/wpImport/zip.js +142 -0
|
@@ -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@
|
|
3
|
+
"source": "dcms-marketplace@ddb1e0c",
|
|
4
4
|
"plugins": {
|
|
5
5
|
"blog": {
|
|
6
|
-
"version": "1.10.
|
|
6
|
+
"version": "1.10.1",
|
|
7
7
|
"files": {
|
|
8
|
-
"CLAUDE.md": "
|
|
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": "
|
|
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": "
|
|
56
|
-
"plugin.public.js": "
|
|
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.
|
|
82
|
+
"version": "1.7.1",
|
|
81
83
|
"files": {
|
|
82
|
-
"CLAUDE.md": "
|
|
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": "
|
|
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": "
|
|
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.
|
|
196
|
+
"version": "1.7.1",
|
|
193
197
|
"files": {
|
|
194
|
-
"CLAUDE.md": "
|
|
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": "
|
|
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": "
|
|
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.
|
|
262
|
+
"version": "1.2.1",
|
|
257
263
|
"files": {
|
|
258
|
-
"CLAUDE.md": "
|
|
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": "
|
|
265
|
-
"admin/views/inbox.js": "
|
|
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": "
|
|
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: () => {
|
|
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
|
|
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) => {
|
|
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.
|
|
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.
|
|
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.
|