domma-cms 1.62.2 → 1.64.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 +17 -0
- package/CLAUDE.md +6 -1
- package/admin/css/admin.css +1 -1
- package/admin/js/lib/background-builder.js +24 -0
- package/admin/js/lib/card-builder.js +2 -2
- package/admin/js/lib/code-format.js +1 -1
- package/admin/js/lib/page-editor-reference.js +13 -3
- package/admin/js/lib/shortcode-form.js +3 -3
- package/admin/js/lib/shortcode-registry.js +7 -5
- package/admin/js/lib/shortcode-tags.js +1 -1
- package/admin/js/lib/theme-settings-arrange.js +1 -1
- package/admin/js/templates/docs/usage-shortcodes.html +5 -1
- package/admin/js/templates/theme.html +7 -0
- package/admin/js/views/theme.js +4 -4
- package/docs/markdown-shortcodes.md +55 -3
- package/docs/screenshots/background-designer.png +0 -0
- package/docs/screenshots/background-nested-layout-desktop.png +0 -0
- package/docs/screenshots/background-nested-layout-mobile.png +0 -0
- package/docs/screenshots/card-body-alignment.png +0 -0
- package/docs/screenshots/card-nested-grid.png +0 -0
- package/docs/theming.md +17 -0
- package/package.json +1 -1
- package/public/css/site.css +1 -1
- package/public/js/background-style.mjs +1 -0
- package/public/js/site.js +1 -1
- package/server/services/block-slots.js +1 -1
- package/server/services/content.js +5 -5
- package/server/services/markdown.js +153 -128
- package/server/services/renderer.js +5 -3
- package/server/services/themeSettings.js +4 -0
- package/server/templates/page.html +2 -2
|
@@ -3,6 +3,7 @@ import {decodeMessageAttribute} from '../../public/js/celebrations/message-attrs
|
|
|
3
3
|
* Markdown Service
|
|
4
4
|
* Parses frontmatter with gray-matter and renders Markdown to HTML with marked.
|
|
5
5
|
*/
|
|
6
|
+
import {normaliseBackground, backgroundStyle} from '../../public/js/background-style.mjs';
|
|
6
7
|
import {cssClasses} from '../../public/js/css-classes.mjs';
|
|
7
8
|
import matter from 'gray-matter';
|
|
8
9
|
import {marked} from 'marked';
|
|
@@ -41,7 +42,7 @@ export const BUILTIN_SHORTCODES = new Set([
|
|
|
41
42
|
'accordion', 'item', 'carousel', 'slide', 'countdown', 'timeline',
|
|
42
43
|
'event', 'listgroup', 'spacer', 'center', 'icon', 'demo', 'embed', 'map', 'image', 'form', 'hero', 'table', 'badge',
|
|
43
44
|
'text', 'button', 'link', 'cta', 'grid', 'row', 'col', 'card', 'box',
|
|
44
|
-
'banner', 'slideover', 'menu',
|
|
45
|
+
'banner', 'slideover', 'menu', 'background',
|
|
45
46
|
// effects
|
|
46
47
|
'counter', 'celebrate', 'firework', 'fireworks', 'scribe',
|
|
47
48
|
'reveal', 'breathe', 'pulse', 'shake', 'scramble', 'ripple', 'twinkle',
|
|
@@ -1993,7 +1994,7 @@ let scrubCallId = 0;
|
|
|
1993
1994
|
* (a nested list, code) keeps the difference. The indent is only ever for the reader.
|
|
1994
1995
|
*/
|
|
1995
1996
|
export const SHORT_TAG_CONTAINERS = Object.freeze([
|
|
1996
|
-
'grid', 'row', 'col', 'card', 'box', 'header', 'footer', 'tabs', 'tab', 'accordion', 'item', 'carousel', 'slide',
|
|
1997
|
+
'background', 'grid', 'row', 'col', 'card', 'box', 'header', 'footer', 'tabs', 'tab', 'accordion', 'item', 'carousel', 'slide',
|
|
1997
1998
|
'timeline', 'event', 'hero', 'banner', 'slideover', 'center', 'listgroup', 'table', 'dconfig', 'reveal', 'animate',
|
|
1998
1999
|
'pulse', 'shake', 'scramble', 'ripple', 'breathe', 'ambient', 'twinkle', 'fireworks', 'scribe', 'wait', 'render', 'redraw'
|
|
1999
2000
|
]);
|
|
@@ -2454,81 +2455,82 @@ function responsiveGridCols(cols) {
|
|
|
2454
2455
|
return map[String(cols)] ?? [`grid-cols-${classToken(cols)}`];
|
|
2455
2456
|
}
|
|
2456
2457
|
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
return `<div class="${classes.join(' ')}"${id}${reveal}${revealMode}${revealAnimation}${revealDuration}${revealStagger}${revealDelay}${revealDirection}${revealReplay}${tilt}>${inner}</div>\n`;
|
|
2506
|
-
}
|
|
2507
|
-
);
|
|
2508
|
-
|
|
2509
|
-
// Pass 3: [grid cols="N" gap="N"]...[/grid] → <div class="grid grid-cols-1 grid-cols-md-N ...">
|
|
2510
|
-
// responsive="false" disables the mobile-first stacking behaviour
|
|
2511
|
-
result = result.replace(
|
|
2512
|
-
/\[grid([^\]]*)\]([\s\S]*?)\[\/grid\]/gi,
|
|
2513
|
-
(_, attrStr, inner) => {
|
|
2514
|
-
const attrs = parseShortcodeAttrs(attrStr);
|
|
2515
|
-
const classes = ['grid'];
|
|
2516
|
-
if (attrs.cols) {
|
|
2517
|
-
if (attrs.responsive === 'false') {
|
|
2518
|
-
classes.push(`grid-cols-${classToken(attrs.cols)}`);
|
|
2519
|
-
} else {
|
|
2520
|
-
classes.push(...responsiveGridCols(attrs.cols));
|
|
2458
|
+
// Parse balanced containers from the outside, restoring code before entering each child store.
|
|
2459
|
+
function processGridBlocks(markdown, depth = 0) {
|
|
2460
|
+
if (depth >= 64) return markdown;
|
|
2461
|
+
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
2462
|
+
const renderers = {
|
|
2463
|
+
background: (attrStr, inner) => {
|
|
2464
|
+
const css = backgroundStyle(parseShortcodeAttrs(attrStr));
|
|
2465
|
+
const body = markedBody(processCardBlocks(processInlineShortcodes(inner.trim())));
|
|
2466
|
+
return `<section class="cms-background"${css ? ` style="${escapeAttr(css)}"` : ''}>${body}</section>\n`;
|
|
2467
|
+
},
|
|
2468
|
+
col: (attrStr, body) => {
|
|
2469
|
+
const attrs = parseShortcodeAttrs(attrStr);
|
|
2470
|
+
const injected = extractInjectedEffects(attrs, ['reveal', 'breathe', 'animate', 'ripple']);
|
|
2471
|
+
const baseCls = attrs.span ? `col-span-${classToken(attrs.span)}` : 'col';
|
|
2472
|
+
// Explicit alignment takes precedence over the shorthand flags.
|
|
2473
|
+
const alignment = typeof attrs.align === 'string'
|
|
2474
|
+
? attrs.align.trim().toLowerCase()
|
|
2475
|
+
: ['center', 'centre', 'left', 'right'].find(value => attrs[value] === true);
|
|
2476
|
+
const align = alignment === 'centre' ? 'center' : alignment;
|
|
2477
|
+
const alignClasses = ['left', 'center', 'right'].includes(align) ? [`text-${align}`] : [];
|
|
2478
|
+
const classes = [baseCls, ...alignClasses, ...injected.effectClasses];
|
|
2479
|
+
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2480
|
+
return `<div class="${classes.join(' ')}"${id}${injected.effectDataAttrs}>${markedBody(processCardBlocks(processInlineShortcodes(body.trim())))}</div>`;
|
|
2481
|
+
},
|
|
2482
|
+
row: (attrStr, inner) => {
|
|
2483
|
+
const attrs = parseShortcodeAttrs(attrStr);
|
|
2484
|
+
const classes = ['row'];
|
|
2485
|
+
if (attrs.gap) classes.push(`gap-${classToken(attrs.gap)}`);
|
|
2486
|
+
if (attrs.class) classes.push(escapeAttr(attrs.class));
|
|
2487
|
+
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2488
|
+
const reveal = attrs.reveal !== undefined ? ' data-reveal="true"' : '';
|
|
2489
|
+
const revealMode = attrs['reveal-mode'] ? ` data-reveal-mode="${escapeAttr(attrs['reveal-mode'])}"` : '';
|
|
2490
|
+
const revealAnimation = attrs['reveal-animation'] ? ` data-reveal-animation="${escapeAttr(attrs['reveal-animation'])}"` : '';
|
|
2491
|
+
const revealDuration = attrs['reveal-duration'] ? ` data-reveal-duration="${escapeAttr(attrs['reveal-duration'])}"` : '';
|
|
2492
|
+
const revealStagger = attrs['reveal-stagger'] ? ` data-reveal-stagger="${escapeAttr(attrs['reveal-stagger'])}"` : '';
|
|
2493
|
+
const revealDelay = attrs['reveal-delay'] ? ` data-reveal-delay="${escapeAttr(attrs['reveal-delay'])}"` : '';
|
|
2494
|
+
const revealDirection = attrs['reveal-direction'] ? ` data-reveal-direction="${escapeAttr(attrs['reveal-direction'])}"` : '';
|
|
2495
|
+
const revealReplay = isTruthyAttr(attrs['reveal-replay']) ? ' data-reveal-replay="true"' : '';
|
|
2496
|
+
const tilt = isTruthyAttr(attrs.tilt) ? ' data-tilt="true"' : '';
|
|
2497
|
+
return `<div class="${classes.join(' ')}"${id}${reveal}${revealMode}${revealAnimation}${revealDuration}${revealStagger}${revealDelay}${revealDirection}${revealReplay}${tilt}>${markedBody(processCardBlocks(processInlineShortcodes(inner.trim())))}</div>\n`;
|
|
2498
|
+
},
|
|
2499
|
+
grid: (attrStr, inner) => {
|
|
2500
|
+
const attrs = parseShortcodeAttrs(attrStr);
|
|
2501
|
+
const classes = ['grid'];
|
|
2502
|
+
if (attrs.cols) {
|
|
2503
|
+
classes.push(...(attrs.responsive === 'false'
|
|
2504
|
+
? [`grid-cols-${classToken(attrs.cols)}`]
|
|
2505
|
+
: responsiveGridCols(attrs.cols)));
|
|
2521
2506
|
}
|
|
2507
|
+
if (attrs.gap) classes.push(`gap-${classToken(attrs.gap)}`);
|
|
2508
|
+
if (attrs.class) classes.push(escapeAttr(attrs.class));
|
|
2509
|
+
if (attrs.fullwidth === 'true') classes.push('grid-breakout');
|
|
2510
|
+
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2511
|
+
return `<div class="${classes.join(' ')}"${id}>${markedBody(processCardBlocks(processInlineShortcodes(inner.trim())))}</div>\n`;
|
|
2522
2512
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2513
|
+
};
|
|
2514
|
+
let result = scrubbed;
|
|
2515
|
+
for (const range of pairedRanges(scrubbed, new Set(['grid', 'row', 'col', 'background'])).reverse()) {
|
|
2516
|
+
const inner = processGridBlocks(restore(scrubbed.slice(range.bodyStart, range.bodyEnd)), depth + 1);
|
|
2517
|
+
const html = renderers[range.name](range.attrs, inner);
|
|
2518
|
+
result = result.slice(0, range.start) + html + result.slice(range.end);
|
|
2528
2519
|
}
|
|
2529
|
-
|
|
2520
|
+
return restore(result);
|
|
2521
|
+
}
|
|
2530
2522
|
|
|
2531
|
-
|
|
2523
|
+
/** Extract page-level singleton tags before any container can render or escape them. */
|
|
2524
|
+
function extractPageBackground(markdown) {
|
|
2525
|
+
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
2526
|
+
const sections = pairedRanges(scrubbed, new Set(['background']));
|
|
2527
|
+
let background = null;
|
|
2528
|
+
const output = scrubbed.replace(/\[background(?=[\s/\]])((?:"[^"]*"|'[^']*'|[^\]"'])*?)\]/gi, (tag, attrs, offset) => {
|
|
2529
|
+
if (sections.some(range => offset >= range.start && offset < range.end)) return tag;
|
|
2530
|
+
background = normaliseBackground(parseShortcodeAttrs(attrs.replace(/\/\s*$/, ''))) || background;
|
|
2531
|
+
return '';
|
|
2532
|
+
});
|
|
2533
|
+
return {output: restore(output), background};
|
|
2532
2534
|
}
|
|
2533
2535
|
|
|
2534
2536
|
/**
|
|
@@ -2702,7 +2704,9 @@ function cardVariantClasses(attrs) {
|
|
|
2702
2704
|
const rounded = typeof attrs.rounded === 'string' ? attrs.rounded.trim() : '';
|
|
2703
2705
|
if (['none', 'xs', 'sm', 'lg', 'full'].includes(rounded)) classes.push(`card-rounded-${rounded}`);
|
|
2704
2706
|
const textAlign = typeof attrs['text-align'] === 'string' ? attrs['text-align'].trim() : '';
|
|
2705
|
-
if (['center', 'right'].includes(textAlign)) classes.push(`card-align-${textAlign}`);
|
|
2707
|
+
if (['left', 'center', 'right'].includes(textAlign)) classes.push(`card-align-${textAlign}`);
|
|
2708
|
+
const bodyAlign = typeof attrs['body-align'] === 'string' ? attrs['body-align'].trim().toLowerCase() : '';
|
|
2709
|
+
if (['left', 'center', 'right'].includes(bodyAlign)) classes.push(`card-body-align-${bodyAlign}`);
|
|
2706
2710
|
const padding = typeof attrs.padding === 'string' ? attrs.padding.trim() : '';
|
|
2707
2711
|
if (['compact', 'spacious'].includes(padding)) classes.push(`card-pad-${padding}`);
|
|
2708
2712
|
// span="2".."6" or "full": how many columns the card takes in a [grid].
|
|
@@ -3418,10 +3422,9 @@ function processInlineShortcodes(markdown) {
|
|
|
3418
3422
|
* works the same. A header is never drawn: title, subtitle, icon, image and
|
|
3419
3423
|
* layout are dropped.
|
|
3420
3424
|
*
|
|
3421
|
-
*
|
|
3422
|
-
* (every container renders its nested body through processCardBlocks)
|
|
3423
|
-
*
|
|
3424
|
-
* [box] inside a [card] both work. Like [card], a [box] cannot hold another [box].
|
|
3425
|
+
* Rendered by processCardBlocks, so it reaches every place a card does
|
|
3426
|
+
* (every container renders its nested body through processCardBlocks). Cards
|
|
3427
|
+
* and boxes can nest, including another container of the same kind.
|
|
3425
3428
|
*
|
|
3426
3429
|
* Colour follows the theme: a bare box is drawn from the theme's card tokens
|
|
3427
3430
|
* (Domma's .card), and `color="primary|secondary|success|info|warning|danger"`
|
|
@@ -3432,37 +3435,30 @@ function processInlineShortcodes(markdown) {
|
|
|
3432
3435
|
* a valid one replaces `variant` (their colours would clash).
|
|
3433
3436
|
* `variant="primary"` gives the primary border, as on a classic [card].
|
|
3434
3437
|
*
|
|
3435
|
-
* @param {
|
|
3438
|
+
* @param {object} attrs
|
|
3439
|
+
* @param {string} body
|
|
3436
3440
|
* @returns {string}
|
|
3437
3441
|
*/
|
|
3438
|
-
function
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
}
|
|
3459
|
-
attrs.class = ['dm-box', ...extra, typeof attrs.class === 'string' ? attrs.class.trim() : ''].filter(Boolean).join(' ');
|
|
3460
|
-
const html = LAYOUT_RENDERERS['no-header-footer'](attrs, processCardBlocks(restore(body)));
|
|
3461
|
-
// cardRoot writes no style attribute, so the custom colour goes on
|
|
3462
|
-
// the first tag (the box root) here.
|
|
3463
|
-
return tone?.style ? html.replace(/^<div /, `<div style="${tone.style}" `) : html;
|
|
3464
|
-
}
|
|
3465
|
-
));
|
|
3442
|
+
function renderBox(attrs, body) {
|
|
3443
|
+
for (const k of ['title', 'subtitle', 'icon', 'icon-layout', 'icon-size', 'icon-align', 'image', 'layout']) delete attrs[k];
|
|
3444
|
+
if (!('shadow' in attrs)) attrs.shadow = 'none';
|
|
3445
|
+
if (!('rounded' in attrs)) attrs.rounded = 'xs';
|
|
3446
|
+
const tone = boxTone(attrs.color ?? attrs.colour);
|
|
3447
|
+
const extra = [];
|
|
3448
|
+
// A colour replaces the variant's own colours: the two together
|
|
3449
|
+
// would pair one's background with the other's text.
|
|
3450
|
+
if (tone) {
|
|
3451
|
+
delete attrs.variant;
|
|
3452
|
+
delete attrs.gradient;
|
|
3453
|
+
extra.push(...tone.classes);
|
|
3454
|
+
} else if (typeof attrs.variant === 'string' && attrs.variant.trim() === 'primary') {
|
|
3455
|
+
extra.push('card-primary');
|
|
3456
|
+
}
|
|
3457
|
+
attrs.class = ['dm-box', ...extra, typeof attrs.class === 'string' ? attrs.class.trim() : ''].filter(Boolean).join(' ');
|
|
3458
|
+
const html = LAYOUT_RENDERERS['no-header-footer'](attrs, body);
|
|
3459
|
+
// cardRoot writes no style attribute, so the custom colour goes on
|
|
3460
|
+
// the first tag (the box root) here.
|
|
3461
|
+
return tone?.style ? html.replace(/^<div /, `<div style="${tone.style}" `) : html;
|
|
3466
3462
|
}
|
|
3467
3463
|
|
|
3468
3464
|
/** Theme colours a [box] can be tinted with - each maps to the --dm-<name> token. */
|
|
@@ -3510,27 +3506,55 @@ function readableOn(hex) {
|
|
|
3510
3506
|
return darkText >= whiteText ? `#${dark}` : '#ffffff';
|
|
3511
3507
|
}
|
|
3512
3508
|
|
|
3509
|
+
/** Balanced card/box pairs, retaining the legacy parser's tolerance of stray quotes. */
|
|
3510
|
+
function cardContainerRanges(text) {
|
|
3511
|
+
const stack = [], pairs = [];
|
|
3512
|
+
// Prefer complete quoted values (which may contain ]). If the author has
|
|
3513
|
+
// left a quote unmatched, still consume the tag and let the attribute
|
|
3514
|
+
// parser and escaping handle its values, as the old card parser did.
|
|
3515
|
+
const tags = /\[(\/)?(card|box)(?=[\s\]])((?:"[^"]*"|'[^']*'|[^\]"'])*|[^\]]*)\]/gi;
|
|
3516
|
+
for (const match of text.matchAll(tags)) {
|
|
3517
|
+
const name = match[2].toLowerCase();
|
|
3518
|
+
if (!match[1]) {
|
|
3519
|
+
stack.push({name, start: match.index, bodyStart: match.index + match[0].length, attrs: match[3]});
|
|
3520
|
+
continue;
|
|
3521
|
+
}
|
|
3522
|
+
const at = stack.findLastIndex(open => open.name === name);
|
|
3523
|
+
if (at < 0) continue;
|
|
3524
|
+
const open = stack[at];
|
|
3525
|
+
stack.length = at;
|
|
3526
|
+
pairs.push({...open, bodyEnd: match.index, end: match.index + match[0].length});
|
|
3527
|
+
}
|
|
3528
|
+
return pairs.filter(p => !pairs.some(q => q.start < p.start && q.end >= p.end));
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3513
3531
|
function processCardBlocks(markdown) {
|
|
3514
|
-
markdown = processBoxBlocks(markdown);
|
|
3515
3532
|
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3533
|
+
const held = new Map();
|
|
3534
|
+
const nonce = randomUUID();
|
|
3535
|
+
// Keep rendered children opaque while the parent extracts its own header,
|
|
3536
|
+
// footer and layout sub-tags, and while marked parses its Markdown body.
|
|
3537
|
+
const render = (source, nested = false) => {
|
|
3538
|
+
let output = source;
|
|
3539
|
+
for (const range of cardContainerRanges(source).reverse()) {
|
|
3540
|
+
const attrs = parseShortcodeAttrs(range.attrs);
|
|
3520
3541
|
const layout = typeof attrs.layout === 'string' ? attrs.layout.trim() : '';
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
const
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3542
|
+
const rawBody = source.slice(range.bodyStart, range.bodyEnd);
|
|
3543
|
+
const body = restore(range.name === 'card' && layout === 'code-snippet'
|
|
3544
|
+
? rawBody : render(rawBody, true));
|
|
3545
|
+
const renderer = LAYOUT_RENDERERS[layout] || renderLegacyCard;
|
|
3546
|
+
const html = range.name === 'box'
|
|
3547
|
+
? renderBox(attrs, body)
|
|
3548
|
+
: renderer(attrs, body, marked, escapeAttr);
|
|
3549
|
+
const token = `<!--cms-card-${nonce}-${held.size}-->`;
|
|
3550
|
+
held.set(token, html);
|
|
3551
|
+
const gap = nested ? '\n\n' : '';
|
|
3552
|
+
output = output.slice(0, range.start) + gap + token + gap + output.slice(range.end);
|
|
3553
|
+
}
|
|
3554
|
+
return output;
|
|
3555
|
+
};
|
|
3556
|
+
const expand = text => text.replace(new RegExp(`<!--cms-card-${nonce}-\\d+-->`, 'g'), token => expand(held.get(token)));
|
|
3557
|
+
return expand(restore(render(scrubbed)));
|
|
3534
3558
|
}
|
|
3535
3559
|
|
|
3536
3560
|
/**
|
|
@@ -5449,7 +5473,7 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5449
5473
|
// → dconfig → effects → plugin shortcodes → tabs → accordion → carousel → countdown → timeline
|
|
5450
5474
|
// → listgroup → spacer → center → icon → demo → embed → image → form → hero → table
|
|
5451
5475
|
// → badge → text → button → link → cta → grid → card (+ box) → banner → slideover
|
|
5452
|
-
// → marked → sanitize → afterParse
|
|
5476
|
+
// → background → marked → sanitize → afterParse
|
|
5453
5477
|
// Comments must be removed before shortcodes are expanded. Protect code
|
|
5454
5478
|
// examples first; four-space-indented lines remain Markdown code too.
|
|
5455
5479
|
const comments = scrubCodeRegions(content, true);
|
|
@@ -5461,7 +5485,8 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5461
5485
|
...(opts.expiry || {}), urlPath: opts.urlPath || '/', parseAttrs: parseShortcodeAttrs
|
|
5462
5486
|
});
|
|
5463
5487
|
const visible = expirySafe.restore(expiry.markdown);
|
|
5464
|
-
const
|
|
5488
|
+
const withBackground = extractPageBackground(visible);
|
|
5489
|
+
const preprocessed = opts[SLOT_FRAGMENT] ? withBackground.output : applyTransforms('markdown:beforeParse', withBackground.output);
|
|
5465
5490
|
const tagSet = new Set();
|
|
5466
5491
|
const flags = {perViewer: false, hasExpiry:expiry.hasExpiry};
|
|
5467
5492
|
const slotComponents = new Set();
|
|
@@ -5516,7 +5541,7 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5516
5541
|
const filteredUsed = [...usedComponents].filter(name => allowed.has(name));
|
|
5517
5542
|
|
|
5518
5543
|
// `content` is the body as written: the editor loads it from here, and the nesting indent is the person's.
|
|
5519
|
-
return {data, content: written, html, usedComponents: filteredUsed, tags: [...tagSet], perViewer: flags.perViewer, hasExpiry:flags.hasExpiry};
|
|
5544
|
+
return {data, content: written, html, background: withBackground.background, usedComponents: filteredUsed, tags: [...tagSet], perViewer: flags.perViewer, hasExpiry:flags.hasExpiry};
|
|
5520
5545
|
}
|
|
5521
5546
|
|
|
5522
5547
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {pageBackgroundStyleTag} from '../../public/js/background-style.mjs';
|
|
1
2
|
/**
|
|
2
3
|
* Renderer Service
|
|
3
4
|
* Assembles the full HTML page shell from the template + page data + site config.
|
|
@@ -672,7 +673,7 @@ export async function renderPage(page, opts = {}) {
|
|
|
672
673
|
// generated, custom.css is hand-written, and the hand-written one stays
|
|
673
674
|
// the last word.
|
|
674
675
|
headInjectLate: [injection.headLate, searchAssets.headTag, motionAssets.headTag, embed ? '' : switcherAssets.headTag,
|
|
675
|
-
launcherAssets.headTag, embed ? EMBED_HEAD_TAG : '', themeView.customThemeStyleTag, themeView.overrideStyleTag, customCssTag, navbarStyleTag]
|
|
676
|
+
launcherAssets.headTag, embed ? EMBED_HEAD_TAG : '', themeView.customThemeStyleTag, themeView.overrideStyleTag, themeView.backgroundStyleTag, customCssTag, navbarStyleTag]
|
|
676
677
|
.filter(Boolean).join('\n'),
|
|
677
678
|
bodyEndInject: [
|
|
678
679
|
// Draft banner - first, so it is the topmost fixed element and a
|
|
@@ -1189,7 +1190,8 @@ async function buildThemeView(page = {}) {
|
|
|
1189
1190
|
fontStyleTag: fontOverride ? `<style>${fontOverride}</style>` : '',
|
|
1190
1191
|
// Only the custom themes this page can show: its own, and day/night's.
|
|
1191
1192
|
customThemeStyleTag: buildCustomThemeStyleTag([activeTheme, autoTheme?.dayTheme, autoTheme?.nightTheme]),
|
|
1192
|
-
overrideStyleTag: buildOverrideStyleTag(cfg)
|
|
1193
|
+
overrideStyleTag: buildOverrideStyleTag(cfg),
|
|
1194
|
+
backgroundStyleTag: pageBackgroundStyleTag(page.background || cfg.background)
|
|
1193
1195
|
};
|
|
1194
1196
|
}
|
|
1195
1197
|
|
|
@@ -1455,7 +1457,7 @@ export async function renderBlogPage(templatePath, data = {}, seoMeta = {}) {
|
|
|
1455
1457
|
// Theme overrides land BEFORE content/custom.css: the overrides are
|
|
1456
1458
|
// generated, custom.css is hand-written, and the hand-written one stays
|
|
1457
1459
|
// the last word.
|
|
1458
|
-
headInjectLate: [bare ? '' : injection.headLate, searchAssets.headTag, motionAssets.headTag, switcherAssets.headTag, launcherAssets.headTag, themeView.customThemeStyleTag, themeView.overrideStyleTag, customCssTag, navbarStyleTag]
|
|
1460
|
+
headInjectLate: [bare ? '' : injection.headLate, searchAssets.headTag, motionAssets.headTag, switcherAssets.headTag, launcherAssets.headTag, themeView.customThemeStyleTag, themeView.overrideStyleTag, themeView.backgroundStyleTag, customCssTag, navbarStyleTag]
|
|
1459
1461
|
.filter(Boolean).join('\n'),
|
|
1460
1462
|
bodyEndInject: [
|
|
1461
1463
|
overlayMenus,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {normaliseBackground} from '../../public/js/background-style.mjs';
|
|
1
2
|
/**
|
|
2
3
|
* Theme settings - config/theme.json.
|
|
3
4
|
*
|
|
@@ -109,6 +110,7 @@ export function defaultThemeConfig() {
|
|
|
109
110
|
lightTheme: 'charcoal-light',
|
|
110
111
|
darkTheme: 'charcoal-dark'
|
|
111
112
|
},
|
|
113
|
+
background: null,
|
|
112
114
|
overrides: []
|
|
113
115
|
};
|
|
114
116
|
}
|
|
@@ -412,6 +414,7 @@ function definedOnly(obj) {
|
|
|
412
414
|
function mergeDefaults(raw) {
|
|
413
415
|
const d = defaultThemeConfig();
|
|
414
416
|
const cfg = {...d, ...definedOnly(raw)};
|
|
417
|
+
cfg.background = normaliseBackground(raw?.background);
|
|
415
418
|
cfg.autoTheme = {...d.autoTheme, ...definedOnly(raw?.autoTheme)};
|
|
416
419
|
cfg.font = {...d.font, ...definedOnly(raw?.font)};
|
|
417
420
|
cfg.switcher = {...d.switcher, ...definedOnly(raw?.switcher)};
|
|
@@ -649,6 +652,7 @@ export function validateThemeConfig(input, {remembered = [], currentSwitcher = {
|
|
|
649
652
|
const errors = [];
|
|
650
653
|
if (!input || typeof input !== 'object') return ['Theme config must be an object'];
|
|
651
654
|
|
|
655
|
+
if (input.background != null && !normaliseBackground(input.background)) errors.push('Choose a valid background type, preset or colour');
|
|
652
656
|
const builtins = listThemeIds();
|
|
653
657
|
// Custom themes (a plugin's) are chosen like any other - except by the
|
|
654
658
|
// public switcher below, which switches through Domma's engine. One the
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<link rel="stylesheet" href="/dist/domma/themes/domma-themes.css">
|
|
26
26
|
|
|
27
27
|
<!-- Site CSS -->
|
|
28
|
-
<link rel="stylesheet" href="/public/css/site.css?v=
|
|
28
|
+
<link rel="stylesheet" href="/public/css/site.css?v=20261112-backgrounds">
|
|
29
29
|
<link rel="stylesheet" href="/public/css/forms.css?v=20261031-forms-reduce-motion">
|
|
30
30
|
<!-- Menu item hover / current-page effects. Loaded after site.css so a
|
|
31
31
|
menu's own highlight wins over the blanket link styling there. -->
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
<script src="/public/js/form-logic-engine.js?v=20261031-forms-reduce-motion" defer></script>
|
|
190
190
|
|
|
191
191
|
<!-- Site initialisation -->
|
|
192
|
-
<script src="/public/js/site.js?v=
|
|
192
|
+
<script src="/public/js/site.js?v=20261112-card-body-align" type="module"></script>
|
|
193
193
|
<script src="/public/js/collection-context.js?v=20261010-utf8-payloads" type="module"></script>
|
|
194
194
|
{{ctxMenusModule}}
|
|
195
195
|
<!-- [image zoom] pictures' full-size view - only on a page that has one -->
|