domma-cms 1.24.0 → 1.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2665,6 +2665,57 @@ function cardIconHeaderAttrs(attrs) {
2665
2665
  return {cls: cls.length ? ` ${cls.join(' ')}` : '', style};
2666
2666
  }
2667
2667
 
2668
+ /**
2669
+ * An image on the classic card and the plain header/body layouts, with text over it:
2670
+ * image - the picture's address (an <img>, so the sanitiser checks it like any other)
2671
+ * image-position - header (default: a band above the title) | body (behind the body text)
2672
+ * image-height - the band's height, or the body's least height: 240 / 240px, 15rem, 2em, 40vh
2673
+ * image-alt - alt text; none = decorative
2674
+ * overlay - plain text over the image; an [overlay]…[/overlay] sub-tag in the body
2675
+ * takes Markdown and wins over the attribute
2676
+ * overlay-position - bottom (default) | top | center (centre)
2677
+ * The image-* layouts read `image` themselves and never come here.
2678
+ *
2679
+ * @param {object} attrs
2680
+ * @param {string} body - the card's raw body
2681
+ * @param {object} markedInstance
2682
+ * @returns {{body: string, media: string, wrapBody: (html: string) => string}}
2683
+ * body has the [overlay] sub-tag taken out; media goes straight after the card root;
2684
+ * wrapBody draws the card-body around the rendered body
2685
+ */
2686
+ function cardImageParts(attrs, body, markedInstance) {
2687
+ const plain = {body, media: '', wrapBody: html => `<div class="card-body">${html}</div>`};
2688
+ const src = typeof attrs.image === 'string' ? attrs.image.trim() : '';
2689
+ if (!src) return plain;
2690
+
2691
+ let overlayMd = null;
2692
+ const rest = body.replace(/\[overlay\]([\s\S]*?)\[\/overlay\]/i, (_, inner) => {
2693
+ overlayMd = inner.trim();
2694
+ return '';
2695
+ });
2696
+ const text = typeof attrs.overlay === 'string' ? attrs.overlay.trim() : '';
2697
+ const overlayHtml = overlayMd ? markedInstance.parse(overlayMd) : text ? `<p>${escapeAttr(text)}</p>` : '';
2698
+
2699
+ const pos = typeof attrs['overlay-position'] === 'string' ? attrs['overlay-position'].trim().toLowerCase() : '';
2700
+ const posKey = {top: 'top', center: 'center', centre: 'center', bottom: 'bottom'}[pos] || 'bottom';
2701
+ const rawH = typeof attrs['image-height'] === 'string' ? attrs['image-height'].trim().toLowerCase() : '';
2702
+ const m = rawH.match(/^(\d{1,4}(?:\.\d+)?)(px|rem|em|vh)?$/);
2703
+ const style = m && parseFloat(m[1]) > 0 ? ` style="--cms-card-image-h:${m[1]}${m[2] || 'px'}"` : '';
2704
+ const alt = typeof attrs['image-alt'] === 'string' ? attrs['image-alt'].trim() : '';
2705
+ const img = `<img class="card-media-img" src="${escapeAttr(src)}" alt="${escapeAttr(alt)}" loading="lazy">`;
2706
+
2707
+ if (String(attrs['image-position'] ?? '').trim().toLowerCase() === 'body') {
2708
+ const lead = overlayHtml ? `<div class="card-overlay-lead">${overlayHtml}</div>` : '';
2709
+ return {
2710
+ body: rest,
2711
+ media: '',
2712
+ wrapBody: html => `<div class="card-body card-body-image card-overlay-${posKey}"${style}>${img}<div class="card-overlay-content">${lead}${html}</div></div>`,
2713
+ };
2714
+ }
2715
+ const over = overlayHtml ? `<div class="card-overlay card-overlay-${posKey}">${overlayHtml}</div>` : '';
2716
+ return {...plain, body: rest, media: `<div class="card-media"${style}>${img}${over}</div>`};
2717
+ }
2718
+
2668
2719
  // ---------------------------------------------------------------------------
2669
2720
  // Card layout renderers registry (populated by layout-specific tasks)
2670
2721
  // ---------------------------------------------------------------------------
@@ -2672,31 +2723,35 @@ function cardIconHeaderAttrs(attrs) {
2672
2723
  const LAYOUT_RENDERERS = {};
2673
2724
 
2674
2725
  LAYOUT_RENDERERS['basic'] = (attrs, body) => {
2675
- const bodyHtml = marked.parse(body.trim());
2676
- return `${cardRoot(attrs)}<div class="card-body">${bodyHtml}</div>${cardFooterAttr(attrs)}</div>\n`;
2726
+ const im = cardImageParts(attrs, body, marked);
2727
+ const bodyHtml = marked.parse(im.body.trim());
2728
+ return `${cardRoot(attrs)}${im.media}${im.wrapBody(bodyHtml)}${cardFooterAttr(attrs)}</div>\n`;
2677
2729
  };
2678
2730
 
2679
2731
  LAYOUT_RENDERERS['header-body'] = (attrs, body) => {
2680
2732
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2681
2733
  const hdr = title ? `<div class="card-header"><div class="card-title">${escapeAttr(title)}</div></div>` : '';
2682
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2683
- return `${cardRoot(attrs)}${hdr}<div class="card-body">${bodyHtml}</div>${cardFooterAttr(attrs)}</div>\n`;
2734
+ const im = cardImageParts(attrs, body, marked);
2735
+ const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(im.body.trim())));
2736
+ return `${cardRoot(attrs)}${im.media}${hdr}${im.wrapBody(bodyHtml)}${cardFooterAttr(attrs)}</div>\n`;
2684
2737
  };
2685
2738
 
2686
2739
  LAYOUT_RENDERERS['header-body-footer'] = (attrs, body) => {
2687
2740
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2688
2741
  const footer = typeof attrs.footer === 'string' ? attrs.footer.trim() : '';
2689
2742
  const hdr = title ? `<div class="card-header"><div class="card-title">${escapeAttr(title)}</div></div>` : '';
2690
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2743
+ const im = cardImageParts(attrs, body, marked);
2744
+ const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(im.body.trim())));
2691
2745
  const ftr = footer ? `<div class="card-footer">${escapeAttr(footer)}</div>` : '';
2692
- return `${cardRoot(attrs)}${hdr}<div class="card-body">${bodyHtml}</div>${ftr}</div>\n`;
2746
+ return `${cardRoot(attrs)}${im.media}${hdr}${im.wrapBody(bodyHtml)}${ftr}</div>\n`;
2693
2747
  };
2694
2748
 
2695
2749
  LAYOUT_RENDERERS['no-header-footer'] = (attrs, body) => {
2696
2750
  const footer = typeof attrs.footer === 'string' ? attrs.footer.trim() : '';
2697
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2751
+ const im = cardImageParts(attrs, body, marked);
2752
+ const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(im.body.trim())));
2698
2753
  const ftr = footer ? `<div class="card-footer">${escapeAttr(footer)}</div>` : '';
2699
- return `${cardRoot(attrs)}<div class="card-body">${bodyHtml}</div>${ftr}</div>\n`;
2754
+ return `${cardRoot(attrs)}${im.media}${im.wrapBody(bodyHtml)}${ftr}</div>\n`;
2700
2755
  };
2701
2756
 
2702
2757
  LAYOUT_RENDERERS['icon-top'] = (attrs, body) => {
@@ -3141,12 +3196,13 @@ function renderLegacyCard(attrs, body, markedInstance, escAttr) {
3141
3196
  }
3142
3197
  }
3143
3198
 
3144
- const bodyHtml = `<div class="card-body">${markedInstance.parse(remaining.trim())}</div>`;
3199
+ const im = cardImageParts(attrs, remaining, markedInstance);
3200
+ const bodyHtml = im.wrapBody(markedInstance.parse(im.body.trim()));
3145
3201
  const footerHtml = footerContent !== null
3146
3202
  ? `<div class="card-footer">${markedInstance.parse(footerContent)}</div>`
3147
3203
  : footer ? `<div class="card-footer">${footer}</div>` : '';
3148
3204
 
3149
- return `<div class="${classes.join(' ')}"${coll}${id}${injected.effectDataAttrs}>${headerHtml}${bodyHtml}${footerHtml}</div>\n`;
3205
+ return `<div class="${classes.join(' ')}"${coll}${id}${injected.effectDataAttrs}>${im.media}${headerHtml}${bodyHtml}${footerHtml}</div>\n`;
3150
3206
  }
3151
3207
 
3152
3208
  // ---------------------------------------------------------------------------
@@ -25,12 +25,12 @@
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=20261029-caret-gap">
28
+ <link rel="stylesheet" href="/public/css/site.css?v=20261030-card-image">
29
29
  <link rel="stylesheet" href="/public/css/forms.css?v=20261025-dropzone-css">
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. -->
32
- <link rel="stylesheet" href="/public/css/menu-highlight.css?v=20261024-menu-highlight-fix">
33
- <link rel="stylesheet" href="/public/css/menu-cards.css?v=20261029-footer-bars">
32
+ <link rel="stylesheet" href="/public/css/menu-highlight.css?v=20261030-submenu-entrance">
33
+ <link rel="stylesheet" href="/public/css/menu-cards.css?v=20261030-submenu-entrance">
34
34
  <link rel="stylesheet" href="/public/css/footer-showcase.css?v=20261029-footer-showcase">
35
35
  <link rel="stylesheet" href="/public/css/page-motion.css?v=20261029-page-motion">
36
36