domma-cms 1.67.2 → 1.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/CLAUDE.md +2 -0
- package/admin/js/lib/layouts-arrange.js +1 -1
- package/admin/js/lib/rich-field.js +9 -2
- package/admin/js/lib/seo-defaults.js +1 -1
- package/admin/js/templates/docs/api-content.html +3 -2
- package/admin/js/templates/docs/api-layouts.html +1 -1
- package/admin/js/templates/docs/usage-navigation.html +2 -1
- package/admin/js/templates/docs/usage-pages.html +3 -1
- package/admin/js/templates/docs/usage-search-engines.html +3 -0
- package/admin/js/templates/page-editor.html +3 -3
- package/admin/js/views/form-editor.js +5 -5
- package/admin/js/views/layouts.js +7 -7
- package/admin/js/views/menu-editor.js +20 -20
- package/admin/js/views/page-editor.js +9 -9
- package/admin/js/views/seo.js +31 -30
- package/docs/DommaFeatures.md +6 -2
- package/docs/api-reference.md +7 -3
- package/docs/guides/multi-page-forms.md +1 -1
- package/docs/plugin-development.md +20 -0
- package/package.json +1 -1
- package/plugins/blog/CHANGELOG.md +3 -0
- package/plugins/blog/CLAUDE.md +15 -0
- package/plugins/blog/admin/views/categories.js +5 -2
- package/plugins/blog/admin/views/kit.js +19 -0
- package/plugins/blog/docs/guide.md +2 -0
- package/plugins/blog/plugin.js +18 -2
- package/plugins/blog/plugin.json +6 -6
- package/plugins/blog/plugin.public.js +16 -2
- package/plugins/blog/public/blog.css +3 -0
- package/plugins/blog/tests/public.test.js +29 -2
- package/plugins/feedback/CLAUDE.md +22 -0
- package/plugins/feedback/admin/css/index.css +2 -0
- package/plugins/feedback/admin/views/inbox.js +5 -2
- package/plugins/feedback/admin/views/send.js +12 -5
- package/plugins/feedback/docs/guide.md +3 -2
- package/plugins/feedback/lib/sender.js +1 -1
- package/plugins/feedback/lib/shape.js +72 -11
- package/plugins/feedback/plugin.js +3 -3
- package/plugins/feedback/plugin.json +3 -2
- package/plugins/feedback/tests/api.test.js +47 -1
- package/plugins/feedback/tests/shape.test.js +87 -1
- package/plugins/free-tier.lock.json +43 -42
- package/plugins/shopping-cart/CHANGELOG.md +20 -0
- package/plugins/shopping-cart/CLAUDE.md +38 -1
- package/plugins/shopping-cart/admin/css/index.css +4 -0
- package/plugins/shopping-cart/admin/lib/kit.js +1 -0
- package/plugins/shopping-cart/admin/views/products.js +95 -3
- package/plugins/shopping-cart/admin/views/shop.js +2 -1
- package/plugins/shopping-cart/docs/guide.md +6 -1
- package/plugins/shopping-cart/inject/body.html +2 -2
- package/plugins/shopping-cart/lib/description.js +173 -0
- package/plugins/shopping-cart/lib/render.js +3 -2
- package/plugins/shopping-cart/lib/shop.js +4 -1
- package/plugins/shopping-cart/plugin.js +17 -2
- package/plugins/shopping-cart/plugin.json +3 -2
- package/plugins/shopping-cart/plugin.public.js +6 -9
- package/plugins/shopping-cart/public/lib/products.js +40 -3
- package/plugins/shopping-cart/public/shop.css +1 -0
- package/plugins/shopping-cart/tests/pure.test.js +26 -1
- package/plugins/shopping-cart/tests/seo.test.js +174 -0
- package/public/js/menu-cards.mjs +4 -4
- package/public/js/menu-look.mjs +1 -1
- package/public/js/rich-text.mjs +4 -4
- package/public/js/site.js +1 -1
- package/server/routes/api/forms.js +5 -3
- package/server/routes/api/layouts.js +8 -4
- package/server/routes/api/seo.js +10 -4
- package/server/services/content.js +23 -0
- package/server/services/contentApi.js +27 -4
- package/server/services/forms.js +58 -2
- package/server/services/health.js +3 -1
- package/server/services/markdown.js +2 -2
- package/server/services/menus.js +56 -6
- package/server/services/renderer.js +28 -4
- package/server/services/richText.js +56 -3
- package/server/services/search.js +5 -2
- package/server/services/sitemap.js +5 -3
- package/server/templates/page.html +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {test} from 'node:test';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
3
|
import {
|
|
4
|
-
buildPayload, cleanSubmission, cleanUpdate, createThrottle, issueDescription, receivedReport, senderView, statusFromIssue
|
|
4
|
+
buildPayload, cleanDescription, cleanSubmission, cleanUpdate, createThrottle, descriptionSummary, issueDescription, receivedReport, senderView, statusFromIssue,
|
|
5
|
+
wireDescription, LIMITS, PAYLOAD_MAX_BYTES, RICH_DESCRIPTION_MAX
|
|
5
6
|
} from '../lib/shape.js';
|
|
6
7
|
import {createOutbox as createFbOutbox, droppedByManager, mergeReports} from '../lib/sender.js';
|
|
7
8
|
|
|
@@ -171,3 +172,88 @@ test('a report deleted on the manager is forgotten by the site (its text, then i
|
|
|
171
172
|
rmSync(dir, {recursive: true, force: true});
|
|
172
173
|
}
|
|
173
174
|
});
|
|
175
|
+
|
|
176
|
+
// ---- The description as rich text ----
|
|
177
|
+
|
|
178
|
+
const RICH = '<p>Saving <strong>loses</strong> my text.</p><ul><li>Open a page</li><li>Press Save</li></ul>';
|
|
179
|
+
const HOSTILE = '<p>Hello <b>there</b></p><script>alert(1)</script><img src=x onerror=alert(1)><p onclick="steal()"><a href="javascript:alert(1)">click</a> <a href="https://ok.example" onmouseover="x()">ok</a></p><iframe src="https://evil.example"></iframe>';
|
|
180
|
+
const HOSTILE_CLEAN = '<p>Hello <b>there</b></p><p><a rel="noopener noreferrer">click</a> <a href="https://ok.example" rel="noopener noreferrer">ok</a></p>';
|
|
181
|
+
|
|
182
|
+
test('a rich description is cleaned on the way in; a plain one is kept as typed; it is still required', () => {
|
|
183
|
+
assert.equal(cleanSubmission({title: 't', description: RICH}).report.description, RICH);
|
|
184
|
+
assert.equal(cleanSubmission({title: 't', description: HOSTILE}).report.description, HOSTILE_CLEAN);
|
|
185
|
+
assert.equal(cleanSubmission({title: 't', description: ' Typed before:\r\nuse <b> & co '}).report.description, 'Typed before:\nuse <b> & co');
|
|
186
|
+
for (const empty of ['', ' ', '<p></p>', '<p><br></p>', '<ul><li></li></ul>', '<p> </p>', '<script>alert(1)</script>'.replace(/^/, '<p>') + '</p>', null, {a: 1}]) {
|
|
187
|
+
assert.equal(cleanSubmission({title: 't', description: empty}).error, 'Say a little more in the description.', JSON.stringify(empty));
|
|
188
|
+
}
|
|
189
|
+
// Limits: 8,000 for plain text as before; rich text has room for its markup; control characters never count.
|
|
190
|
+
assert.equal(cleanSubmission({title: 't', description: 'x'.repeat(9000)}).report.description.length, LIMITS.description);
|
|
191
|
+
const long = cleanSubmission({title: 't', description: `<p>${'word '.repeat(5000)}</p>`}).report.description;
|
|
192
|
+
assert.ok(long.length <= RICH_DESCRIPTION_MAX + '</p>'.length && long.endsWith('</p>'));
|
|
193
|
+
assert.equal(cleanSubmission({title: 't', description: `<p>${'\u0001'.repeat(20000)}real</p>`}).report.description, '<p>real</p>');
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('between a site and the manager the description is plain text, with the formatting beside it', () => {
|
|
197
|
+
assert.deepEqual(wireDescription(RICH), {description: 'Saving loses my text.\n\n- Open a page\n- Press Save', descriptionHtml: RICH});
|
|
198
|
+
assert.deepEqual(wireDescription('Plain <b>words</b>'), {description: 'Plain <b>words</b>', descriptionHtml: ''});
|
|
199
|
+
assert.deepEqual(wireDescription(undefined), {description: '', descriptionHtml: ''});
|
|
200
|
+
assert.equal(wireDescription('<p>Saving <b>loses</b>\u00a0my text</p>').description, 'Saving loses my text', 'a non-breaking space is a space');
|
|
201
|
+
// A stored value that was never cleaned is cleaned before it travels.
|
|
202
|
+
assert.equal(wireDescription('<p>ok</p><script>alert(2)</script>').descriptionHtml, '<p>ok</p>');
|
|
203
|
+
|
|
204
|
+
// Site -> manager: what the form gave, as the payload carries it.
|
|
205
|
+
const {report} = cleanSubmission({type: 'bug', title: 'Save', description: HOSTILE});
|
|
206
|
+
const payload = buildPayload({report, user: {id: 'u1', name: 'Sam'}, ref: 'r1'});
|
|
207
|
+
assert.equal(payload.description, 'Hello there\n\nclick ok');
|
|
208
|
+
assert.ok(!/[<>]/.test(payload.description), 'an older manager shows words, never tags');
|
|
209
|
+
assert.equal(payload.descriptionHtml, HOSTILE_CLEAN);
|
|
210
|
+
assert.equal('descriptionHtml' in buildPayload({report: cleanSubmission({title: 't', description: 'plain'}).report, ref: 'r2'}), false);
|
|
211
|
+
|
|
212
|
+
// The manager stores ONE string: the formatting when it came, the words otherwise.
|
|
213
|
+
assert.equal(receivedReport(payload, 'acme').data.description, HOSTILE_CLEAN);
|
|
214
|
+
assert.equal('descriptionHtml' in receivedReport(payload, 'acme').data, false);
|
|
215
|
+
assert.equal(receivedReport({title: 't', description: 'from an older site'}, 'acme').data.description, 'from an older site');
|
|
216
|
+
// Formatting a site made up is cleaned like any other; formatting that says nothing gives way to the words.
|
|
217
|
+
assert.equal(receivedReport({title: 't', description: 'words', descriptionHtml: '<p>x</p><script>alert(1)</script>'}, 'acme').data.description, '<p>x</p>');
|
|
218
|
+
assert.equal(receivedReport({title: 't', description: 'words', descriptionHtml: '<p><br></p>'}, 'acme').data.description, 'words');
|
|
219
|
+
assert.equal(receivedReport({title: 't', description: 'words', descriptionHtml: 'not rich <script>x</script>'}, 'acme').data.description, 'words');
|
|
220
|
+
assert.equal(receivedReport({title: 't', description: 'words', descriptionHtml: {evil: 1}}, 'acme').data.description, 'words');
|
|
221
|
+
assert.equal(cleanDescription({description: 7}), '7');
|
|
222
|
+
|
|
223
|
+
// Manager -> site: the same two fields, so an older site shows words.
|
|
224
|
+
const view = senderView({id: 'e1', data: receivedReport(payload, 'acme').data});
|
|
225
|
+
assert.equal(view.description, 'Hello there\n\nclick ok');
|
|
226
|
+
assert.equal(view.descriptionHtml, HOSTILE_CLEAN);
|
|
227
|
+
assert.equal(senderView({id: 'e2', data: {description: 'plain', status: 'new'}}).descriptionHtml, '');
|
|
228
|
+
// What is still waiting in the outbox shows the same way.
|
|
229
|
+
const [waiting] = mergeReports([{ref: 'r1', state: 'waiting', payload, createdAt: '2026-11-15T10:00:00Z'}], null);
|
|
230
|
+
assert.equal(waiting.description, payload.description);
|
|
231
|
+
assert.equal(waiting.descriptionHtml, HOSTILE_CLEAN);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test('a report too heavy to carry its formatting under the manager\'s 32 KB limit goes as plain text', () => {
|
|
235
|
+
const {report} = cleanSubmission({title: 't', description: `<p>${'日本語 '.repeat(3500)}</p>`});
|
|
236
|
+
const payload = buildPayload({report, user: {id: 'u1', name: 'Sam'}, ref: 'r1'});
|
|
237
|
+
assert.equal('descriptionHtml' in payload, false);
|
|
238
|
+
assert.ok(payload.description.startsWith('日本語'));
|
|
239
|
+
assert.ok(Buffer.byteLength(JSON.stringify(payload)) < 32 * 1024);
|
|
240
|
+
// An ordinary long report keeps its formatting and still fits.
|
|
241
|
+
const ok = buildPayload({report: cleanSubmission({title: 't', description: `<p>${'word '.repeat(1500)}</p>`}).report, ref: 'r2'});
|
|
242
|
+
assert.ok(ok.descriptionHtml.startsWith('<p>word'));
|
|
243
|
+
assert.ok(Buffer.byteLength(JSON.stringify(ok)) <= PAYLOAD_MAX_BYTES);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('a notice and a Waypoint issue take a rich report the right way', () => {
|
|
247
|
+
assert.equal(descriptionSummary(RICH, 300), 'Saving loses my text. - Open a page - Press Save');
|
|
248
|
+
assert.equal(descriptionSummary(`<p>${'word '.repeat(200)}</p>`, 300).length, 300);
|
|
249
|
+
assert.equal(descriptionSummary('plain\ntext'), 'plain text');
|
|
250
|
+
const d = {description: RICH, userName: 'Sam <b>', site: 'Acme & Co', cmsVersion: '1.67.0', where: '#/pages', severity: 'major', attachments: [{name: 'a.png'}]};
|
|
251
|
+
// A Waypoint that stores rich text gets the formatting, with the facts as an escaped paragraph.
|
|
252
|
+
assert.equal(issueDescription(d, {rich: true}),
|
|
253
|
+
`${RICH}<p>From Sam <b> on Acme & Co<br>Domma CMS 1.67.0<br>Where: #/pages<br>Severity: major<br>Attachments (in the Feedback inbox): a.png</p>`);
|
|
254
|
+
// An older Waypoint gets the words, as before.
|
|
255
|
+
assert.equal(issueDescription(d), 'Saving loses my text.\n\n- Open a page\n- Press Save\n\n---\nFrom Sam <b> on Acme & Co\nDomma CMS 1.67.0\nWhere: #/pages\nSeverity: major\nAttachments (in the Feedback inbox): a.png');
|
|
256
|
+
// A plain report is text either way, exactly as it was.
|
|
257
|
+
assert.equal(issueDescription({description: 'It broke', userName: 'Sam', site: 'Acme'}, {rich: true}), 'It broke\n\n---\nFrom Sam on Acme');
|
|
258
|
+
assert.equal(issueDescription({description: '<p>x</p><script>alert(1)</script>', userName: 'Sam', site: 'Acme'}, {rich: true}), '<p>x</p><p>From Sam on Acme</p>');
|
|
259
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
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@1f9ef795",
|
|
4
4
|
"plugins": {
|
|
5
5
|
"blog": {
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.11.0",
|
|
7
7
|
"files": {
|
|
8
|
-
"CHANGELOG.md": "
|
|
9
|
-
"CLAUDE.md": "
|
|
8
|
+
"CHANGELOG.md": "5bbeec18ad95b4e5b476ec22522bafb878fc282e7a56eeaab102646510f97f2a",
|
|
9
|
+
"CLAUDE.md": "69c8694e797328088159fb31854dccf29d33fdf69bda2e41fa685a96826ee32a",
|
|
10
10
|
"admin/css/index.css": "8d6dfd2bfadf0bbe8efbd52ef9b397ca9d36ca699c80e260aec11f677c77a248",
|
|
11
11
|
"admin/lib/drafts.js": "60446f6bf93b790f07041fbb95dac30b12cd0ebc3caa71d15f2a7dc16c661b0d",
|
|
12
12
|
"admin/lib/email.js": "89b9a96251b4ba7323376b6a59b9b31c52387ab7fad02cddef57e7629ea5e119",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"admin/templates/post-editor.html": "24212ae8aa3de55443637a65af83dfe9eeba577090cc3110c09ddc87aaec8c31",
|
|
17
17
|
"admin/templates/settings.html": "e0730cd57435e592034328a699198d5e1326084767156bfc2289852f5f1a45af",
|
|
18
18
|
"admin/views/blog.js": "959a2e9e22ba3e9ab19932cdf34002ec6bc592ac83a65febf08f5626e39765ba",
|
|
19
|
-
"admin/views/categories.js": "
|
|
19
|
+
"admin/views/categories.js": "0cc927ec48a3a8140e56a38ccaffcf83c76c6c6cab18c6388c187d42b0b4e877",
|
|
20
20
|
"admin/views/comments.js": "ead4477f75c751cc1940ce2e5d272f6498c4940a34f69b3e896c47c7c9c4e263",
|
|
21
|
-
"admin/views/kit.js": "
|
|
21
|
+
"admin/views/kit.js": "f140934adda40b9c81bcd4bf9bd538f69dc665fa69ad05331d49840e1da2a757",
|
|
22
22
|
"admin/views/post-editor.js": "8bc81317decd579be5f110a3f21a44ecb9ee66c5f6b110f7900f4462da3a1959",
|
|
23
23
|
"admin/views/settings-cog.js": "307efc93835863dd8511f8fb17a224cf45a77532c90b854a86d2cd1d4e5f9f18",
|
|
24
24
|
"admin/views/settings.js": "256729c7fc2c7cc30541b19afd2efb335a8ac2cc8bdf15202a360c9b7c07c1e4",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"collections/comments/schema.json": "29cbd289cbfcfc4158c9357a218db4ce06eddc3370bfbf9afb7d7f52065a849e",
|
|
45
45
|
"collections/posts/schema.json": "19a5a770d3eefea73f4117454bd1312a7a7e3d727cfcdfde141139fbc81cabd7",
|
|
46
46
|
"config.js": "ee67396262762f5c31269d258affd75f7392a3e364f72f7792c2f1cdafd94bba",
|
|
47
|
-
"docs/guide.md": "
|
|
47
|
+
"docs/guide.md": "55ee9a74d110de21a2154e354d8b53fa72c746fde367d7e3b6a6194d3fcd2bcd",
|
|
48
48
|
"lib/access.js": "af47440c7233a56000641a3231d7e9ff81b12f40dfb9528aa6dd4e2dd9bca8df",
|
|
49
49
|
"lib/cache.js": "5623745e580e0d5ea4ca48ee528427a6efabafec777f8607154dcb662f9147eb",
|
|
50
50
|
"lib/layouts.js": "dbb6ae9e514ccaf600a732702925b905131dea166d90fe759a62b6652e78e1de",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"lib/page.js": "02ef5b0e5aadfe5a8a5de4b7471518b24193b1dad2bda23bea06c6cc1e4743e7",
|
|
54
54
|
"lib/render.js": "0e97c6a950bc962c8d8ea4b2f21d06cb73fbcdc738d8942d6935d01309a29b1d",
|
|
55
55
|
"lib/samples.js": "e8cdb77ce22e43937707f6854d3a5cb722437dc584e22ac7b24480bef686cf85",
|
|
56
|
-
"plugin.js": "
|
|
57
|
-
"plugin.json": "
|
|
58
|
-
"plugin.public.js": "
|
|
59
|
-
"public/blog.css": "
|
|
56
|
+
"plugin.js": "12c0cd42994b47b1acecf7fd15f8d806ffc1fb54d39bdd6be829a024e5875b5f",
|
|
57
|
+
"plugin.json": "fad8c936d20e7e19ad191dc3e20fb7591b403a494c5b55fe4c18eb93f74e6987",
|
|
58
|
+
"plugin.public.js": "2d7cb907a659191fc173c83d8c35a3f491a95e8f2b9af381455c5044664c01f3",
|
|
59
|
+
"public/blog.css": "f70b717863178c0fdf2bb18d280b2bce36e788aec6e673c08f88174b4511fcb7",
|
|
60
60
|
"public/blog.js": "d01c72a9834dcc7c5241923371f2b164ac30d20ac9f1a5c5dc5b71fa3cb09f08",
|
|
61
61
|
"public/samples/aurora.svg": "feb29e2b46465913fc29de9eda221b00b1541f1fa3ea7120f0c1d1cd11a9a4f6",
|
|
62
62
|
"public/samples/dusk.svg": "92469dcfe2e78ed9bfa6ddeb9f9c4726ec64e04c6e9b40260523a825b582b580",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"tests/nav-link.test.js": "d36e33ad7483abca27ae6e2098ad2f75bafa18d91f3beba70372ebe6b9b88994",
|
|
78
78
|
"tests/notices.test.js": "2b02aa84e780dc4c82e6c503fc8fe17c64a63bee0709627866ef97c99cb4e131",
|
|
79
79
|
"tests/preview-sandbox.test.js": "fba7f5a640832a8b3f1fe8aa05b8dcb7349134f93dc6b385e33af2939bbb8919",
|
|
80
|
-
"tests/public.test.js": "
|
|
80
|
+
"tests/public.test.js": "5c64fb098a6bd029ee57713a2cdfb81887368241aeeccbc2cbcb557243690370"
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"docs": {
|
|
@@ -126,31 +126,31 @@
|
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"feedback": {
|
|
129
|
-
"version": "1.
|
|
129
|
+
"version": "1.3.0",
|
|
130
130
|
"files": {
|
|
131
|
-
"CLAUDE.md": "
|
|
132
|
-
"admin/css/index.css": "
|
|
131
|
+
"CLAUDE.md": "c66927f2ffc2e1066cb96773740a6d360e481395358e470ae9d310b7a9914ca7",
|
|
132
|
+
"admin/css/index.css": "d042301c02280f0f8fad2776062b16a7f288d2c5b3a8af408236aeac858bdc74",
|
|
133
133
|
"admin/lib/drafts.js": "3ccf8c255e72d62edf31692bc1bd464cea43ae9f135de23ce2caaedd0502eea2",
|
|
134
134
|
"admin/lib/kit.js": "f4ec5b7e9147f7ca9f2b775d0f973390015920b7af9eebe0735509a631cac064",
|
|
135
135
|
"admin/lib/settings.js": "973c1934c2241336d6ec25d98f9fd96077faf28ccab553f2c8507f404b4f8975",
|
|
136
136
|
"admin/templates/feedback.html": "a366dce78f6c3e84a7cb0ac63eba53e1980a4eb44154496a0536f5214c5bb36f",
|
|
137
137
|
"admin/views/feedback.js": "bcb86953504804fb8e6937dfe132dd342ece73daafa9987074e304bac5d76261",
|
|
138
|
-
"admin/views/inbox.js": "
|
|
139
|
-
"admin/views/send.js": "
|
|
138
|
+
"admin/views/inbox.js": "f58ca81656b81e81d23fd92bf708b7f2776118daeeaacfca299aeb9c9afd98de",
|
|
139
|
+
"admin/views/send.js": "8079dda2dfae377b96774ecc085f6da0060b1d2189141de1cc7a59f52c7ed7c6",
|
|
140
140
|
"collections/feedback-reports.json": "a072291b52463f7785a77f5f77d36b8238ba8f89cfc2672c6642eccdb3144486",
|
|
141
141
|
"config.js": "29d9999d1028c2c11931f67fb9abdf35132430b7cf58c161681e734c0b45143a",
|
|
142
|
-
"docs/guide.md": "
|
|
142
|
+
"docs/guide.md": "69b5850b9b659c6551be4cfb4d437ced62c1a6b4d69566bc6a58245cb696c991",
|
|
143
143
|
"lib/attachments.js": "b23bda973c2e7723bc485c5f2840868363a3ac4e65c153cb5abd5a3c41dba3ad",
|
|
144
144
|
"lib/cache.js": "6db2859c21a3dddcc2ec34e8380dd672fc99a6cb0d76a2b05b68086503f4ccce",
|
|
145
145
|
"lib/receiver.js": "98aeea6712ba6aa576919520a86451f7f223e5154416a225a848e0c875923c8d",
|
|
146
|
-
"lib/sender.js": "
|
|
147
|
-
"lib/shape.js": "
|
|
148
|
-
"plugin.js": "
|
|
149
|
-
"plugin.json": "
|
|
150
|
-
"tests/api.test.js": "
|
|
146
|
+
"lib/sender.js": "4c4730f8bcaf85be5bee1787b7548a79c5b351dfe19253443dd430791efd86e8",
|
|
147
|
+
"lib/shape.js": "640422f392b243f5a0f94c5acdfae55f615a5a383ec036499739c3ae70f21282",
|
|
148
|
+
"plugin.js": "e18cecceef926aed618151e7635698aa6141667d78a1043cbf96cca820f4240c",
|
|
149
|
+
"plugin.json": "5e1eb3521041113026f4fea629a03236cdf4f834016e450f3d01feb35dbc90ce",
|
|
150
|
+
"tests/api.test.js": "f9dca5d83f2b61b5f02f75a776aa28e6d27caa912ca2f03f4f55ead63549a690",
|
|
151
151
|
"tests/drafts.test.js": "b9bac3c1c7f3841229bdfe5294bfda78064f0f2d170b6db1ba39e7666531ac1f",
|
|
152
152
|
"tests/settings.test.js": "3a50ac89a9d114c8466fc043a66f0f1bf373e7a7ad6dba45a995468c3332b374",
|
|
153
|
-
"tests/shape.test.js": "
|
|
153
|
+
"tests/shape.test.js": "17079edaa09ec85d5052885d03e41917f232f0b50fc02c8d7801144203af4b56"
|
|
154
154
|
}
|
|
155
155
|
},
|
|
156
156
|
"garage": {
|
|
@@ -236,46 +236,47 @@
|
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
"shopping-cart": {
|
|
239
|
-
"version": "1.
|
|
239
|
+
"version": "1.8.0",
|
|
240
240
|
"files": {
|
|
241
|
-
"CHANGELOG.md": "
|
|
242
|
-
"CLAUDE.md": "
|
|
243
|
-
"admin/css/index.css": "
|
|
241
|
+
"CHANGELOG.md": "ff7a4dd729a654cac1fc2f5505a44cb4556a29b4051b3668536f9d4fb45bdc50",
|
|
242
|
+
"CLAUDE.md": "a80eb3fb8bacb7a98e754491de2adba3b8552bdcc9dec6ecc97714f86a4788a1",
|
|
243
|
+
"admin/css/index.css": "b3e9e0c351d88a9aab2947f12c7530c70a4254017f5c87032fe66652853eb2db",
|
|
244
244
|
"admin/lib/chart.js": "b01ce5cfac773c8df8efccab50b67d3dfa99fbead0037d817553db4a6688d4d6",
|
|
245
245
|
"admin/lib/drafts.js": "9e71b939f6c98d5c25875f35b02c367a5e89e0d2c6d084d6a4de0c71128930a2",
|
|
246
246
|
"admin/lib/email.js": "9f842932c8de39ac6878463bd49c443df82ecf64872dad48ff5362d6b61c1e2c",
|
|
247
|
-
"admin/lib/kit.js": "
|
|
247
|
+
"admin/lib/kit.js": "6900a612691428daed70fad4bd43225fa4b5b1505755d239ac03b57ddb9454c9",
|
|
248
248
|
"admin/templates/shop.html": "c5bb03f1f7cbabfbd8202f3533783eb1848103755b1ba25fdcf1fd8e9478cb8e",
|
|
249
249
|
"admin/views/orders.js": "11a4f9d1db5b6c849b136d97b97e44821bcac21b617281dda58809b442c8645e",
|
|
250
250
|
"admin/views/overview.js": "02241e75976cfa759d6ba738dd13ca0bd2bcb760d66a5f184becc2e472807efc",
|
|
251
|
-
"admin/views/products.js": "
|
|
251
|
+
"admin/views/products.js": "5d9eaff229a02463cdad74d4893ac0da304e7df988f1314ec1195c8470c75b86",
|
|
252
252
|
"admin/views/sales.js": "001c08963e26df72f43d2357bbcc5a0f54f74f9d22bca319c23a28a50f40c124",
|
|
253
253
|
"admin/views/settings.js": "5bec0fc307abe935858e24697acb5cfae7f4dcac945afc1f6185da982c121e22",
|
|
254
|
-
"admin/views/shop.js": "
|
|
254
|
+
"admin/views/shop.js": "c3cbc5f452a6c7ab4902793da49f2c834912c8ee192d1bdfe09b2687a511e2bc",
|
|
255
255
|
"collections/shop-orders.json": "0bca8eef2d5f9108651f73d273480265c167dc983aa115ce59613d13015ca255",
|
|
256
256
|
"collections/shop-products.json": "4d4613ecec7b8a5a0744c4f0a57b17a4429b461e060206a4bbdea5ad7c8c75dc",
|
|
257
257
|
"config.js": "31b336560d21a802d799ed487d5c3116de898446ba3521068b10d192f4ebbb2d",
|
|
258
|
-
"docs/guide.md": "
|
|
259
|
-
"inject/body.html": "
|
|
258
|
+
"docs/guide.md": "664da6180b7e2d8ed804f1a2bb3ef1bb8fdc19e61cb3abff126201d7c13cf112",
|
|
259
|
+
"inject/body.html": "fe3810d85d355b402ccc368eddc0a8641b7edf1a5d9e20b9830d05268eecae67",
|
|
260
260
|
"lib/accounts.js": "5115cec6a145da18c106dfdbf5fd0b2a1bad0c68e8fac4ef623287e85db75e5c",
|
|
261
261
|
"lib/commission.js": "5b10475d98cff2aaf4c76b9950f8d698d6262e36754a8963669690a8e3e9bd52",
|
|
262
|
+
"lib/description.js": "3f7a771ee14bd94764e68a918cf26a84bf03b1fa3b56b0b3dfe5a18eee09496e",
|
|
262
263
|
"lib/extensions.js": "73d3515b52c066e3e616c425d91a7a48a6aab153e7d14ae7278b38ee32649352",
|
|
263
264
|
"lib/payments.js": "d2a39bf42373c78c716c1a35f606f9cce1901d0dab5f6bd00bebde9b35f0328c",
|
|
264
265
|
"lib/pricing.js": "5644f2dd55fc3cfd7f40b0169dea5fb547e8b302239b8c17f23cfa177e42eab5",
|
|
265
266
|
"lib/refunds.js": "73db567d97d40f68806c0d8dcb7235a12f5f86662739febf4b2229695ace40e4",
|
|
266
|
-
"lib/render.js": "
|
|
267
|
+
"lib/render.js": "5bc432e92c8b58661148c79c50ae5f41ebc1ece25ca11722dc5700f19e440f77",
|
|
267
268
|
"lib/sales.js": "bc6c39d70c2ce83f4109474071e6b048dc6554c4b11ac03dbeccbdfdb5881368",
|
|
268
269
|
"lib/samples.js": "912b3d5bd543dffa5f870caf3c2b873f642fd55e3ebf3f97e1b31eeaaac77d3b",
|
|
269
|
-
"lib/shop.js": "
|
|
270
|
+
"lib/shop.js": "651406068e09745c446705fd93c3a09140e2105ee36d771a429cc2104088c7a6",
|
|
270
271
|
"lib/summary.js": "ff947ccf0f63cc3095946612460f3ea7ff742803395802179b3ccd66fe961dfa",
|
|
271
|
-
"plugin.js": "
|
|
272
|
-
"plugin.json": "
|
|
273
|
-
"plugin.public.js": "
|
|
272
|
+
"plugin.js": "083a91cca04f26434a1114fe775b555dd87e241120ade0a7edd741e2518a356f",
|
|
273
|
+
"plugin.json": "0c7c2639e743be4580364341be316b6a3d496503369dee8b6b213c0faf5770eb",
|
|
274
|
+
"plugin.public.js": "77a8ae4f74f3b04b5a7727feb37b2c59f931e564dbb2a8af29b525a2ec8ca2f4",
|
|
274
275
|
"public/account.js": "5f644016c098c7879c59948d662f5997cb61680996204ecb7897baab8945d434",
|
|
275
276
|
"public/cart.js": "01492eb04b13bd347dc7721fb002644b499dadee1777a9b67e5d0fe9a1ad6698",
|
|
276
277
|
"public/lib/money.js": "d22b2b6f80dde6f7887b69e24188c05ea93c02217aba639b5331aa3bd616f4fc",
|
|
277
278
|
"public/lib/orders.js": "fab6c3ae3cdb35f37d338bfd9ce921ac98629dedb8249e814804309865e06c64",
|
|
278
|
-
"public/lib/products.js": "
|
|
279
|
+
"public/lib/products.js": "82f0ef4551a2aad3200215821e016b1f6722d93e439ead943888f0b5357715ac",
|
|
279
280
|
"public/lib/session.js": "4f71e98818a52cf2321c8dc57e33e5591deb04ebb2c0bea19dd6758827719a08",
|
|
280
281
|
"public/samples/candle-2.svg": "aca5691b9168467caf6feb7622ab154ee92504be8b887ac6c818db22476e7bed",
|
|
281
282
|
"public/samples/candle.svg": "ef75e95a53ce13e88928004c6f1290c45a1094765e2ba741ae1fc55d404b881f",
|
|
@@ -289,7 +290,7 @@
|
|
|
289
290
|
"public/samples/tee.svg": "287a82d7fc00acb1543b3209927ae20dcbe3d4b2a2b3de03574ab0c463385f3c",
|
|
290
291
|
"public/samples/tote-2.svg": "9c7f41cc57866e71973e413a6c87f46be48f7488d3490ceea58e24559c334813",
|
|
291
292
|
"public/samples/tote.svg": "01de817a32c8d3d8ea47ff491049f439ca3e4d4fce943dbdc62a4187139e016c",
|
|
292
|
-
"public/shop.css": "
|
|
293
|
+
"public/shop.css": "47cdad469d0f42e0b5b8b0d4c1223f49f1fa320e41d1003d779d1235c9632477",
|
|
293
294
|
"roles/shop-customer.json": "3f3366c536c9fbf2b2ce146bb3090b008d5fbfe22752e764eb8e5a1de9cd611c",
|
|
294
295
|
"templates/shop.html": "4649e57d23458833a157799dc80141824eb0f658d96734bd1859c68e0ba9a8b9",
|
|
295
296
|
"tests/account-scope.test.js": "2efe258126fabcc9dabdfb325f776b290a9cfbc04467958ea984bd4bcb7fcd4d",
|
|
@@ -299,10 +300,10 @@
|
|
|
299
300
|
"tests/commission.test.js": "fbc4cf83e0ed6446a09e57e4ff37a9608c81947c633c78ac6049eb0aedf6cb58",
|
|
300
301
|
"tests/drafts.test.js": "2dec0cfeadd6df1d3b90f3fd8bce1f33762811eb6e94cd7325bcb8ec31edac42",
|
|
301
302
|
"tests/email.test.js": "2190b6dd7cc9afad99d2170f002343fe3dad306aa14ac718428e5df0be54ded1",
|
|
302
|
-
"tests/pure.test.js": "
|
|
303
|
+
"tests/pure.test.js": "68992aa23303a6b5cea4dc8364fe324c2de59c5b20acbb2315b3b51130980a24",
|
|
303
304
|
"tests/refunds.test.js": "0ae06afca3cf9fd1fe89f1fbc63b3676216c79e174dbcb83788180c01d078366",
|
|
304
305
|
"tests/sales.test.js": "9025bc608b04bcc14f5bb2c98b4f7c35de99f3ddab4ffa59772d045795bf2cb7",
|
|
305
|
-
"tests/seo.test.js": "
|
|
306
|
+
"tests/seo.test.js": "8a93fc110a4fb75141f2e6899ea52543a14ff01dda26e630ab0769b629b2c102"
|
|
306
307
|
}
|
|
307
308
|
},
|
|
308
309
|
"support": {
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.8.0] - 2026-11-15
|
|
4
|
+
- A product's **Description** is a rich text editor: paragraphs, bold, italics, underline, lists and links. What it
|
|
5
|
+
saves is rich text, cleaned on save and again on the product page.
|
|
6
|
+
- **Shortcodes do not run in a rich text description** - they show as the words in their brackets. The field's help
|
|
7
|
+
and the guide say so.
|
|
8
|
+
- Only a description that is exactly what the editor and the cleaner store counts as rich text. Old Markdown that
|
|
9
|
+
begins with HTML (a `<p class="...">`, a paragraph followed by a shortcode, a picture) is still Markdown.
|
|
10
|
+
- A description written before (Markdown, with or without shortcodes) is not converted: it is stored and rendered
|
|
11
|
+
exactly as before until someone edits it in the editor. Saving the product without touching the description, a
|
|
12
|
+
quick edit from the list and a copy all leave it as it is.
|
|
13
|
+
- Opening an old description shows it as formatted text. If it has shortcodes or pictures, a note under the editor
|
|
14
|
+
warns before the first edit that changing it saves it as formatted text without them, and after an edit
|
|
15
|
+
**Keep it as it was** puts the original back.
|
|
16
|
+
- The search-engine description (used when Summary is empty) and `GET /catalogue` give a rich description as plain
|
|
17
|
+
words.
|
|
18
|
+
- Descriptions may be up to 30,000 characters (it was 20,000), because rich text counts its markup.
|
|
19
|
+
- New route `POST /products/description` (manage): a Markdown description as the editor shows it, and what an edit
|
|
20
|
+
would lose. Nothing is saved by it.
|
|
21
|
+
- Requires CMS 1.67.0 or later (the shared rich text editor): `minCmsVersion` added to the manifest.
|
|
22
|
+
|
|
3
23
|
## [1.7.5] - 2026-11-08
|
|
4
24
|
- Customer accounts work again: a signed-in customer at `<shop>/account` saw the sign-in form come back, because `GET /account` answered 403 "Your account cannot use Shopping Cart". Core's plugin scope (CMS 0.86.0+) refuses the plugin's signed-in routes to a role confined to other admin screens, and `shop-customer` is confined to My Profile - so accounts never worked on any CMS that shipped them (1.6.35 to 1.47.2). The three `/account` routes now take core's own sign-in check (`accountAuth`, or `auth.authenticateSelf` when the CMS passes one); every admin route keeps the scoped one, so a customer is still refused the Shop's admin APIs (`tests/account-scope.test.js`, against the real sign-in and scope).
|
|
5
25
|
- Checkout's button and the line under it follow the payment method picked: Pay offline says "Place order" and shows the shop's offline instructions, not "Pay £…" and the card-page line; PayPal says "Pay £… with PayPal"; card keeps "Pay £…" (`payWording` in public/lib/orders.js).
|
|
@@ -40,7 +40,8 @@ shopper resubmits with `accept`, and when `expectTotal` differs from what it wou
|
|
|
40
40
|
- `lib/shop.js` - collections I/O, live settings (masking, cleaning), order numbers, `markPaid` / `moveOrder` /
|
|
41
41
|
refunds with stock, all order writes serialised by `withLock`. `shelfNow`/`settingsNow` for the shortcodes.
|
|
42
42
|
- `lib/payments.js` - Stripe and PayPal over fetch (no SDK). `stripeVerify` checks webhook signatures.
|
|
43
|
-
- `lib/render.js` - the storefront's HTML (server-rendered; everything escaped; descriptions
|
|
43
|
+
- `lib/render.js` - the storefront's HTML (server-rendered; everything escaped; descriptions arrive rendered, from lib/description.js).
|
|
44
|
+
- `lib/description.js` - a product description is rich text OR Markdown; see "Descriptions" at the end of this file.
|
|
44
45
|
- `lib/summary.js` - Overview figures and the badge. `lib/samples.js` + `public/samples/*.svg` - sample products.
|
|
45
46
|
- `public/cart.js`, `public/shop.css` - the browser half, injected on every page (`inject/body.html`).
|
|
46
47
|
- `templates/shop.html` - the fragment every storefront page renders in (`renderBlogPage`).
|
|
@@ -285,3 +286,39 @@ amount is all that is left), a Refund button. Never put form fields in `E.confir
|
|
|
285
286
|
`hooks.sitemapChanged()`.
|
|
286
287
|
- `metaDescription`: the Introduction / product summary (else its description as text), else a line from the site's
|
|
287
288
|
name and the first products. Test: `tests/seo.test.js`.
|
|
289
|
+
|
|
290
|
+
## Descriptions: rich text from the editor, Markdown as it always was (unreleased, CMS 1.67.0+)
|
|
291
|
+
|
|
292
|
+
`description` is ONE string, never migrated. **`isRichDescription()` in lib/description.js is the one place that
|
|
293
|
+
decides which it is** - page, meta description, catalogue and the editor's convert-on-open all ask it. It is stricter
|
|
294
|
+
than core's `isRichText`: the value must start with a block, be exactly what `cleanRichText` would store (cleaning it
|
|
295
|
+
changes nothing) and have nothing outside its top-level blocks. So old Markdown that merely BEGINS with HTML
|
|
296
|
+
(`<p class="lead">`, a `<p>` followed by a shortcode line, an `<img>`) stays Markdown. The admin cannot run the
|
|
297
|
+
cleaner, so the editor asks the server (`POST /products/description` answers `rich`).
|
|
298
|
+
|
|
299
|
+
- **Saving never rewrites what is there**: `cleanDescription(value, {stored})` keeps a description that comes back
|
|
300
|
+
exactly as the product has it (the form's untouched value, a quick edit, a copy). Only a DIFFERENT value that starts
|
|
301
|
+
with a block is taken as the editor's and cleaned; if anything outside a block survives the cleaner it is rebuilt
|
|
302
|
+
as paragraphs, so a value from the editor is always rich text by the strict test.
|
|
303
|
+
- **Rich text** (saved from the product editor): `cleanRichText` on save (`lib/description.js cleanDescription`, handed
|
|
304
|
+
to the pure `cleanProduct` as `opts.cleanDescription` by `lib/shop.js saveProduct` - public/lib cannot import a
|
|
305
|
+
sanitiser; the admin's as-you-type check runs without it and only reads errors). On the page:
|
|
306
|
+
`inertShortcodes(renderRichText(v))`. **Shortcodes never run in rich text** - the help text, the guide and the
|
|
307
|
+
editor's warning all say so; do not "fix" that by sending rich text through parseMarkdown.
|
|
308
|
+
- **Markdown** (anything else - typed before the editor, or sent by an API client): stored as typed (trimmed, control
|
|
309
|
+
characters out, `DESCRIPTION_MAX` 30000) and rendered by `parseMarkdown` exactly as before, shortcodes included.
|
|
310
|
+
- `descriptionText` is the meta description's source (Summary empty): `richTextToPlain` or the old Markdown strip.
|
|
311
|
+
`GET /catalogue` gives a rich description as `richTextToPlain` (plugin.js, not `publicProduct`, which stays pure).
|
|
312
|
+
- **The editor** (`wireDescription` in admin/views/products.js): `#sp-desc` is NOT `data-model`-bound. The form's
|
|
313
|
+
`description` observable keeps the stored value and only follows the editor after a real edit (the textarea's
|
|
314
|
+
`input` event, which core's `richDescription` fires only for the person's own changes) - so opening and saving a
|
|
315
|
+
product leaves a Markdown description byte for byte. For a Markdown value it asks `POST /products/description`
|
|
316
|
+
(`descriptionForEditor`): the Markdown rendered with its brackets made inert and cut down to rich text, plus
|
|
317
|
+
`shortcodes` (the live render differs from the inert one) and `pictures`. With either, a note under the editor warns
|
|
318
|
+
BEFORE the first edit; after one it says what will be lost and offers "Keep it as it was".
|
|
319
|
+
- `editorHtml()` (public/lib/products.js, pure, tested; redundant once core's rich-field.js stores every line in a
|
|
320
|
+
block - domma-cms PR #458 - but harmless): the first line typed into an EMPTY editor is bare text, later
|
|
321
|
+
lines `<div>` - not rich by core's test, so it would be stored as Markdown and a shortcode typed there would run.
|
|
322
|
+
The editor's value always goes through it. (Invoices carries the same helper; `plugins/_lib` is the engine's.)
|
|
323
|
+
- Shopping Cart Pro does not read a product's `description` anywhere (grep it again before assuming so in future).
|
|
324
|
+
- `admin/views/shop.js` `V` and the manifest's `shop.js?v=` are a cache stamp (a date), not the Tool's version.
|
|
@@ -222,6 +222,10 @@ a.shp-tile:hover { border-color: var(--dm-primary); }
|
|
|
222
222
|
.shp-order a { color: var(--dm-primary); }
|
|
223
223
|
.shp-callout { border-left: 3px solid var(--dm-warning); background: color-mix(in srgb, var(--dm-warning) 9%, transparent); padding: .6rem .8rem; border-radius: var(--dm-radius-sm); }
|
|
224
224
|
.shp-callout p { white-space: pre-wrap; margin-top: .25rem; }
|
|
225
|
+
/* Under the Description editor: what changing a Markdown description would lose. */
|
|
226
|
+
.shp-desc-note { margin-top: .5rem; font-size: var(--dm-text-sm); }
|
|
227
|
+
.shp-desc-note[hidden], .shp-desc-note [hidden] { display: none !important; }
|
|
228
|
+
.shp-desc-note .shp-link { margin-left: .35rem; }
|
|
225
229
|
.shp-refunds { border-left-color: var(--dm-danger); background: color-mix(in srgb, var(--dm-danger) 8%, transparent); }
|
|
226
230
|
.shp-refunds ul { margin: .35rem 0 0; padding-left: 1.1rem; font-size: var(--dm-text-sm); color: var(--dm-text-muted); }
|
|
227
231
|
.shp-refunds code { font-size: var(--dm-text-xs); }
|
|
@@ -69,6 +69,7 @@ export const api = {
|
|
|
69
69
|
update: (id, d) => H.put(`${BASE}/products/${seg(id)}`, d),
|
|
70
70
|
patch: (id, d) => H.patch(`${BASE}/products/${seg(id)}`, d),
|
|
71
71
|
duplicate: (id) => H.post(`${BASE}/products/${seg(id)}/duplicate`, {}),
|
|
72
|
+
describe: (description) => H.post(`${BASE}/products/description`, {description}),
|
|
72
73
|
remove: (id) => H.delete(`${BASE}/products/${seg(id)}`),
|
|
73
74
|
samples: () => H.post(`${BASE}/samples`, {live: true})
|
|
74
75
|
},
|
|
@@ -20,7 +20,92 @@
|
|
|
20
20
|
import {api, ask, claims, entriesOf, soon, esc, getCurrency, money, moneyIn, moneyOut, mountPanels, openPanel, refreshBadge, store, wireRows} from '../lib/kit.js';
|
|
21
21
|
import {NEW_KEY, PRODUCT_DRAFTS_KEY, adoptAsNew, draftDiffers, draftKey, draftValues, productDraftQuestion, readMap, replaceNewDraftQuestion,
|
|
22
22
|
stableJson, withDraft} from '../lib/drafts.js';
|
|
23
|
-
import {STATUS_LABEL, cleanProduct, optionsText, priceRange, slugify, totalStock} from '/plugins/shopping-cart/public/lib/products.js';
|
|
23
|
+
import {STATUS_LABEL, cleanProduct, editorHtml, optionsText, priceRange, slugify, totalStock} from '/plugins/shopping-cart/public/lib/products.js';
|
|
24
|
+
import {richDescription} from '/admin/js/lib/rich-field.js';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The product editor's Description: a rich text editor over the form's `description` value.
|
|
28
|
+
*
|
|
29
|
+
* What is stored is one string. A description saved from this editor is rich text. One typed before the editor
|
|
30
|
+
* existed is Markdown (perhaps with shortcodes) and STAYS Markdown, rendered as it always was, until somebody
|
|
31
|
+
* changes it here - so the textarea is not bound to the form: the form's value only follows the editor once the
|
|
32
|
+
* person has really edited it. Until then the editor shows the Markdown as the formatting it renders to (asked
|
|
33
|
+
* of the server, which also says what an edit would lose), and saving the product leaves the description alone.
|
|
34
|
+
*
|
|
35
|
+
* Shortcodes do not run in rich text. A description that has them gets a warning under the editor before the
|
|
36
|
+
* first edit, and after it a way back to the description as it was.
|
|
37
|
+
*
|
|
38
|
+
* @param {Element} root the editor panel
|
|
39
|
+
* @param {object} description the form's observable
|
|
40
|
+
* @param {Function} alive () => boolean - the panel is still open
|
|
41
|
+
* @returns {{destroy: () => void}}
|
|
42
|
+
*/
|
|
43
|
+
function wireDescription(root, description, alive) {
|
|
44
|
+
const area = root.querySelector('#sp-desc');
|
|
45
|
+
const note = root.querySelector('[data-part="desc-note"]');
|
|
46
|
+
const noteText = note.querySelector('[data-part="desc-note-text"]');
|
|
47
|
+
const keepBtn = note.querySelector('[data-part="desc-keep"]');
|
|
48
|
+
const opened = description.peek() || '';
|
|
49
|
+
// The description as it was opened, once the server has said it is Markdown: while it can still be kept as it is.
|
|
50
|
+
// (Only the server can tell: rich text is what its cleaner leaves unchanged - lib/description.js isRichDescription.)
|
|
51
|
+
let original = '';
|
|
52
|
+
let shown = ''; // the Markdown as the editor shows it (rich text), once the server has answered
|
|
53
|
+
let loses = null; // {shortcodes, pictures} - what an edit would lose
|
|
54
|
+
let edited = false;
|
|
55
|
+
|
|
56
|
+
area.value = opened;
|
|
57
|
+
const editor = richDescription(area, {minHeight: 150});
|
|
58
|
+
|
|
59
|
+
const lost = () => [loses?.shortcodes ? 'shortcodes' : '', loses?.pictures ? 'pictures' : ''].filter(Boolean).join(' and ');
|
|
60
|
+
const refreshNote = () => {
|
|
61
|
+
const what = lost();
|
|
62
|
+
note.hidden = !(original && what);
|
|
63
|
+
if (note.hidden) return;
|
|
64
|
+
noteText.textContent = edited
|
|
65
|
+
? `You have changed this description, so it will be saved as formatted text without its ${what}. Shortcodes show as the words in their brackets and no longer do anything.`
|
|
66
|
+
: `This description has ${what} in it. They keep working for as long as you leave it as it is. If you change it here it is saved as formatted text: shortcodes stop working and show as the words in their brackets${loses.pictures ? ', and pictures are left out' : ''}.`;
|
|
67
|
+
keepBtn.hidden = !edited;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onInput = () => {
|
|
71
|
+
// Without the editor (an older admin) the box is the Markdown box it always was.
|
|
72
|
+
if (!editor.rich) { description.value = area.value; return; }
|
|
73
|
+
edited = true;
|
|
74
|
+
// As rich text even when the browser left the first line typed into an empty editor as bare text.
|
|
75
|
+
description.value = editorHtml(area.value);
|
|
76
|
+
refreshNote();
|
|
77
|
+
};
|
|
78
|
+
area.addEventListener('input', onInput);
|
|
79
|
+
|
|
80
|
+
const keep = () => {
|
|
81
|
+
edited = false;
|
|
82
|
+
description.value = original;
|
|
83
|
+
area.value = shown || original;
|
|
84
|
+
refreshNote();
|
|
85
|
+
editor.focus();
|
|
86
|
+
};
|
|
87
|
+
keepBtn.addEventListener('click', keep);
|
|
88
|
+
|
|
89
|
+
if (opened && editor.rich) {
|
|
90
|
+
api.products.describe(opened).then((r) => {
|
|
91
|
+
if (!alive() || !r || r.rich) return;
|
|
92
|
+
original = opened;
|
|
93
|
+
loses = {shortcodes: Boolean(r.shortcodes), pictures: Boolean(r.pictures)};
|
|
94
|
+
shown = typeof r.html === 'string' ? r.html : '';
|
|
95
|
+
// Only while it is still as it was opened: never over what the person has typed meanwhile.
|
|
96
|
+
if (!edited && shown) area.value = shown;
|
|
97
|
+
refreshNote();
|
|
98
|
+
}).catch(() => { /* shown as the text it is; saving still leaves it alone until it is edited */ });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
destroy() {
|
|
103
|
+
area.removeEventListener('input', onInput);
|
|
104
|
+
keepBtn.removeEventListener('click', keep);
|
|
105
|
+
editor.destroy();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
24
109
|
|
|
25
110
|
const FILTERS = [
|
|
26
111
|
{key: 'all', label: 'All', match: (p) => p.status !== 'archived'},
|
|
@@ -445,8 +530,12 @@ export async function mount(root, ctx) {
|
|
|
445
530
|
<input id="sp-summary" class="form-input" data-model="summary.value" maxlength="300">
|
|
446
531
|
</div>
|
|
447
532
|
<div class="shp-wide">
|
|
448
|
-
<label class="form-label" for="sp-desc">Description <span data-help="The full story, under the Add to basket button
|
|
449
|
-
<textarea id="sp-desc" class="form-input
|
|
533
|
+
<label class="form-label" for="sp-desc">Description <span data-help="The full story, under the Add to basket button: paragraphs, bold, italics, lists and links. Shortcodes do not work here - put those on a page, or leave a description that already has them as it is."></span></label>
|
|
534
|
+
<textarea id="sp-desc" class="form-input" rows="6"></textarea>
|
|
535
|
+
<div class="shp-callout shp-desc-note" data-part="desc-note" role="status" hidden>
|
|
536
|
+
<span data-part="desc-note-text"></span>
|
|
537
|
+
<button type="button" class="shp-link" data-part="desc-keep" hidden>Keep it as it was</button>
|
|
538
|
+
</div>
|
|
450
539
|
</div>
|
|
451
540
|
<div>
|
|
452
541
|
<label class="form-label" for="sp-cat">Category <span data-help="Shoppers filter the shop by category. Type a new one or pick one you have used."></span></label>
|
|
@@ -574,6 +663,7 @@ export async function mount(root, ctx) {
|
|
|
574
663
|
};
|
|
575
664
|
|
|
576
665
|
const menus = [];
|
|
666
|
+
let descField = null;
|
|
577
667
|
panel = await openPanel({
|
|
578
668
|
title: had ? p.name : 'New product',
|
|
579
669
|
size: 'lg',
|
|
@@ -594,6 +684,7 @@ export async function mount(root, ctx) {
|
|
|
594
684
|
release();
|
|
595
685
|
stopSlug?.();
|
|
596
686
|
stopDraft?.();
|
|
687
|
+
descField?.destroy();
|
|
597
688
|
ext.destroy();
|
|
598
689
|
menus.forEach(m => { try { m?.destroy?.(); } catch { /* gone */ } });
|
|
599
690
|
},
|
|
@@ -637,6 +728,7 @@ export async function mount(root, ctx) {
|
|
|
637
728
|
// The screen went while the panel was opening: its teardown has already run, so close it here.
|
|
638
729
|
if (!here()) { panel.close(true); return true; }
|
|
639
730
|
const el = panel.panel;
|
|
731
|
+
descField = wireDescription(el, f.description, () => panel.isOpen() && here());
|
|
640
732
|
ext = await mountPanels(el.querySelector('.shp-actions'), {on: 'product', ctx, info: {
|
|
641
733
|
product: had ? {id: had.id, data: had.data} : null,
|
|
642
734
|
// Options as they are in the form; one added since the last save has no id yet.
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
import {api, claims, loadKit, setCurrency, store} from '../lib/kit.js';
|
|
16
16
|
|
|
17
17
|
const ROUTE = /^#\/plugins\/shopping-cart(\/|$)/;
|
|
18
|
-
|
|
18
|
+
// A cache stamp for the tab modules, not the Tool's version: change it when one of them changes.
|
|
19
|
+
const V = '2026-11-15';
|
|
19
20
|
const TABS = [
|
|
20
21
|
{key: 'overview', label: 'Overview', icon: 'bar-chart', module: `/plugins/shopping-cart/admin/views/overview.js?v=${V}`},
|
|
21
22
|
{key: 'orders', label: 'Orders', icon: 'receipt', module: `/plugins/shopping-cart/admin/views/orders.js?v=${V}`},
|
|
@@ -105,7 +105,12 @@ The product form:
|
|
|
105
105
|
|
|
106
106
|
- **Name**, **Address** (the last part of the product's web address), **Pictures** (from Media; the first is shown on the card, the second on hover; drag to reorder).
|
|
107
107
|
- **Price** and **Was** (an earlier, higher price, shown struck through with a Sale flag).
|
|
108
|
-
- **Summary** (on the card and the top of the product page)
|
|
108
|
+
- **Summary** (on the card and the top of the product page).
|
|
109
|
+
- **Description**: the full story, under the Add to basket button. It is a formatted text editor: paragraphs, bold, italics, underline, bullet and numbered lists and links.
|
|
110
|
+
- **Shortcodes do not work in the Description.** If you type one, shoppers see the words in the brackets. To use shortcodes with a product, put them on a page and use `[shop-product]` or `[buy-button]` there.
|
|
111
|
+
- A description written before the editor was added (in Markdown, perhaps with shortcodes or pictures) keeps working exactly as it did for as long as you leave it alone. Saving other changes to the product does not touch it.
|
|
112
|
+
- When you open such a description the editor shows it as formatted text. If it has shortcodes or pictures, a note under the editor tells you before you change anything: once you edit it, it is saved as formatted text, the shortcodes stop working (they show as the words in their brackets) and the pictures are left out. **Keep it as it was** puts the original back at any time before you save.
|
|
113
|
+
- Pictures belong in the product's **Pictures**, not in the Description.
|
|
109
114
|
- **Category**, **Tags** (comma-separated), **Status** (On sale, Draft - hidden, Archived) and **Featured** (shown first, with a Featured flag).
|
|
110
115
|
- **Options & stock** - tick **Count stock** to track stock; it then sells out at 0. Add options with **Add an option**, each with a name, price (empty uses the product's price), SKU and stock. **Options are** names them (for example Size).
|
|
111
116
|
- **Delivery & tax** - untick **Needs delivering** for downloads, services and tickets (no delivery charge, no address asked). **Weight (g)** and **Tax class** are used by Shopping Cart Pro.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<link rel="stylesheet" href="/plugins/shopping-cart/public/shop.css?v=1.
|
|
2
|
-
<script type="module" src="/plugins/shopping-cart/public/cart.js?v=1.
|
|
1
|
+
<link rel="stylesheet" href="/plugins/shopping-cart/public/shop.css?v=1.8.0">
|
|
2
|
+
<script type="module" src="/plugins/shopping-cart/public/cart.js?v=1.8.0"></script>
|