domma-cms 1.67.2 → 1.69.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.
Files changed (85) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/CLAUDE.md +2 -0
  3. package/admin/js/lib/layouts-arrange.js +1 -1
  4. package/admin/js/lib/rich-field.js +9 -2
  5. package/admin/js/lib/seo-defaults.js +1 -1
  6. package/admin/js/templates/docs/api-content.html +3 -2
  7. package/admin/js/templates/docs/api-layouts.html +1 -1
  8. package/admin/js/templates/docs/usage-navigation.html +2 -1
  9. package/admin/js/templates/docs/usage-pages.html +3 -1
  10. package/admin/js/templates/docs/usage-search-engines.html +3 -0
  11. package/admin/js/templates/page-editor.html +3 -3
  12. package/admin/js/views/form-editor.js +5 -5
  13. package/admin/js/views/layouts.js +7 -7
  14. package/admin/js/views/menu-editor.js +20 -20
  15. package/admin/js/views/page-editor.js +9 -9
  16. package/admin/js/views/seo.js +31 -30
  17. package/docs/DommaFeatures.md +6 -2
  18. package/docs/api-reference.md +7 -3
  19. package/docs/guides/multi-page-forms.md +1 -1
  20. package/docs/markdown-shortcodes.md +1 -1
  21. package/docs/plugin-development.md +20 -0
  22. package/package.json +1 -1
  23. package/plugins/blog/CHANGELOG.md +3 -0
  24. package/plugins/blog/CLAUDE.md +15 -0
  25. package/plugins/blog/admin/views/categories.js +5 -2
  26. package/plugins/blog/admin/views/kit.js +19 -0
  27. package/plugins/blog/docs/guide.md +2 -0
  28. package/plugins/blog/plugin.js +18 -2
  29. package/plugins/blog/plugin.json +6 -6
  30. package/plugins/blog/plugin.public.js +16 -2
  31. package/plugins/blog/public/blog.css +3 -0
  32. package/plugins/blog/tests/public.test.js +29 -2
  33. package/plugins/feedback/CLAUDE.md +22 -0
  34. package/plugins/feedback/admin/css/index.css +2 -0
  35. package/plugins/feedback/admin/views/inbox.js +5 -2
  36. package/plugins/feedback/admin/views/send.js +12 -5
  37. package/plugins/feedback/docs/guide.md +3 -2
  38. package/plugins/feedback/lib/sender.js +1 -1
  39. package/plugins/feedback/lib/shape.js +72 -11
  40. package/plugins/feedback/plugin.js +3 -3
  41. package/plugins/feedback/plugin.json +3 -2
  42. package/plugins/feedback/tests/api.test.js +47 -1
  43. package/plugins/feedback/tests/shape.test.js +87 -1
  44. package/plugins/free-tier.lock.json +43 -42
  45. package/plugins/shopping-cart/CHANGELOG.md +20 -0
  46. package/plugins/shopping-cart/CLAUDE.md +38 -1
  47. package/plugins/shopping-cart/admin/css/index.css +4 -0
  48. package/plugins/shopping-cart/admin/lib/kit.js +1 -0
  49. package/plugins/shopping-cart/admin/views/products.js +95 -3
  50. package/plugins/shopping-cart/admin/views/shop.js +2 -1
  51. package/plugins/shopping-cart/docs/guide.md +6 -1
  52. package/plugins/shopping-cart/inject/body.html +2 -2
  53. package/plugins/shopping-cart/lib/description.js +173 -0
  54. package/plugins/shopping-cart/lib/render.js +3 -2
  55. package/plugins/shopping-cart/lib/shop.js +4 -1
  56. package/plugins/shopping-cart/plugin.js +17 -2
  57. package/plugins/shopping-cart/plugin.json +3 -2
  58. package/plugins/shopping-cart/plugin.public.js +6 -9
  59. package/plugins/shopping-cart/public/lib/products.js +40 -3
  60. package/plugins/shopping-cart/public/shop.css +1 -0
  61. package/plugins/shopping-cart/tests/pure.test.js +26 -1
  62. package/plugins/shopping-cart/tests/seo.test.js +174 -0
  63. package/public/js/collection-browser.js +1 -1
  64. package/public/js/menu-cards.mjs +4 -4
  65. package/public/js/menu-look.mjs +1 -1
  66. package/public/js/rich-text.mjs +4 -4
  67. package/public/js/site.js +1 -1
  68. package/server/routes/api/collections.js +26 -12
  69. package/server/routes/api/forms.js +5 -3
  70. package/server/routes/api/layouts.js +8 -4
  71. package/server/routes/api/seo.js +10 -4
  72. package/server/services/adapters/FileAdapter.js +4 -3
  73. package/server/services/adapters/MongoAdapter.js +4 -2
  74. package/server/services/content.js +23 -0
  75. package/server/services/contentApi.js +27 -4
  76. package/server/services/filterEngine.js +33 -0
  77. package/server/services/forms.js +58 -2
  78. package/server/services/health.js +3 -1
  79. package/server/services/markdown.js +288 -38
  80. package/server/services/menus.js +56 -6
  81. package/server/services/renderer.js +28 -4
  82. package/server/services/richText.js +56 -3
  83. package/server/services/search.js +5 -2
  84. package/server/services/sitemap.js +5 -3
  85. package/server/templates/page.html +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.69.0] - 2026-11-15
4
+
5
+ ### Security
6
+
7
+ - **Filtered block displays are cleaned before they are drawn.** When a visitor searches, sorts or pages a `[collection display="block"]`, the browser fetches the redrawn entries from `POST /api/collections/render-fragment` and puts them into the page. That answer was not sanitised, so HTML stored in an entry and printed through a `{{{field}}}` placeholder (or a handler written in the block itself) reached the page with its scripts and event handlers. It is now cleaned the same way as the page and as `scope="mine"` displays.
8
+ - **A read limited to some fields is limited everywhere.** A collection whose public read lists certain fields (`api.read.fields`) returned only those, but could still be filtered, searched and sorted on the others, through `GET /api/collections/<slug>/public`, `/api/v1/<slug>` and `render-fragment` (which could also be asked to draw them). Which rows came back, and in what order, gave the hidden values away, and `resolveRefs` returned a hidden reference field's id and label. A filter, search or sort on a field that is not listed is now ignored on all three, `_refs` is cut to the list, and `render-fragment` draws only the listed fields.
9
+ - **No event handler on a component tag.** The page sanitiser let every attribute through on a registered `<dm-…>` component tag, `onfocus` and the rest included, so HTML in an entry could run a script through one. Event handler attributes are now removed from every tag.
10
+ - **A `<style>` that holds markup is removed.** A `<style>` element whose text contains something that could open a tag is dropped whole; some browsers read such an element differently from the sanitiser. A block's CSS file is unaffected (`width < 600px` in a media query stays as written). A `<style>` written straight into a page or a block's HTML with an SVG `data:` address in it must write `<` as `%3C`.
11
+ - **Entry HTML cannot pass itself off as part of the site.** HTML stored in an entry and shown as HTML (a `{{{field}}}` placeholder, or a body field in the accordion, timeline, carousel and list group displays) is now content only: it loses its `data-` attributes (all but `data-icon` and `data-copy`, which only decorate), `<style>` elements and component tags. `data-` attributes are what the site's scripts act on, and a `<div>` dressed as a collection table ran a script on the page. Text, links, pictures and embeds in the entry read as before. A `{{{field}}}` alone on its line between blank lines is read as Markdown, as before, and one inside the template's HTML is read as HTML.
12
+ - **A value inside an attribute stays inside it.** A value from an entry could close the attribute it was written into and add others, most simply through a blank line followed by a Markdown link. This is closed where a display writes a value itself (a file field's link, a carousel picture, a timeline date) and in block templates: a placeholder inside an attribute value (`<a href="{{{url}}}">`, `title="{{name}}"`) or inside one of the template's own shortcode tags (`[button href="{{url}}"]`) stays in that value; one between a tag's attributes (`<input {{checked}}>`) may write attributes but no `data-` name; one inside a name (`<h{{level}}>`) may write name characters only. A value given by a page author to `[block]` is unchanged, including one that stands for a whole attribute (`<div {{{style}}}>`).
13
+ - **A form's reference options are words.** A form field that offers another collection's entries wrote each entry's title into the page as HTML; angle brackets in one are now shown as look-alike characters.
14
+ - **File and reference links in a searchable display** open only web, mail, phone and on-site addresses.
15
+ - **A collection table's column titles are words.** The browser wrote a sortable column's title as HTML; angle brackets in one are now shown as look-alike characters. An Action's name is also encoded before it is used in a request.
16
+
17
+ ### Fixed
18
+
19
+ - **A code span in a `[card]` attribute** (``title="Run `npm test`"``) printed an internal marker instead of the words. It now prints the words, as text.
20
+ - **Known edge:** a `[banner]` with one stray backtick in its title and another in its body on the same line is no longer drawn, as with every other container. Pair the backticks or remove one.
21
+ - **A `[banner]` in a code example** (a code span or a fenced block) was drawn as a banner. It is now shown as written.
22
+
23
+ ## [1.68.0] - 2026-11-15
24
+
25
+ ### Added
26
+
27
+ - **More descriptions with formatting.** The same small rich text editor (bold, italic, underline, lists, links) is now on a page's Description and SEO Description, the SEO Tool's Description for an address and its Default meta description, a layout's Description, a menu item's Description (the caption in card dropdowns), and a form's Step Description and each chooser option's Description. Text written before stays exactly as it was until someone edits it.
28
+ - **Where the formatting shows.** A card dropdown's caption shows bold, italic and underline. A wizard step's description shows those and links. Everything read by a machine gets the words only: the meta description, share cards, structured data, `/llms.txt`, search results and the health check. A chooser option's description is kept with its formatting but shown as plain words for now, because the chooser draws text only.
29
+ - **Counted on the words.** The SEO length meters and the 160 character limit on a menu item's caption count what a reader sees, not the formatting.
30
+ - **Content API:** a page's `description` is still plain text; `descriptionHtml` beside it carries the formatting as safe HTML.
31
+ - **For Tool authors:** `richDescription(textarea, {compact: true})` for a description inside a row of other inputs (a line tall, its toolbar opens under the text while it has the focus); `richTextLine()` for one uncut line of plain text; `renderRichTextPhrasing()` for a description drawn inside a paragraph, link or button. See "Rich text Description fields" in `docs/plugin-development.md`.
32
+
33
+ ### Changed
34
+
35
+ - **Built-in Tools updated:** Blog 1.11.0, Feedback 1.3.0 and Shopping Cart 1.8.0, with rich text Descriptions.
36
+
37
+ ### Fixed
38
+
39
+ - **Clicking into a rich text Description field that sits inside a label** could open the label's help popover instead of placing the cursor.
40
+ - **A wizard step's description can no longer carry scripts or images.** It was written into the page as typed. It is now cleaned to bold, italic, underline and links wherever a form is drawn; simple formatting typed by hand still works.
41
+
3
42
  ## [1.67.2] - 2026-11-15
4
43
 
5
44
  ### Fixed
package/CLAUDE.md CHANGED
@@ -761,6 +761,8 @@ and blocks under `pages`.
761
761
  "new" mode and Save creates a duplicate instead of updating - which is how the Context Menu editor
762
762
  shipped in 0.56.0 with a dead preview and an edit screen that never loaded anything.
763
763
 
764
+ 14. **Rich text Descriptions** (`admin/js/lib/rich-field.js`, `server/services/richText.js`, `public/js/rich-text.mjs`; "Rich text Description fields" in `docs/plugin-development.md`): a description is ONE string, plain or rich (`isRichText` = starts with a block element). Save with `cleanRichText`; into a page with `renderRichText`; inside a `<p>`, link or button with `renderRichTextPhrasing` (inline only); everything that is not HTML with `richTextLine` / `richTextToPlain` / `richTextSummary`, and count characters on `richTextLine(v).length`. Rich in core: collections, actions, views, menus, projects, forms, pages (`description`, `seo.description` - cleaned in `createPage`/`updatePage`), SEO overrides and `site.seo.defaultDescription`, layouts, menu ITEM captions, form step and chooser option descriptions. Traps: (a) every SEO output goes through `plainSeoDescriptions()` in `renderer.js` after the `seo:meta` transforms - a new tag or JSON-LD block built elsewhere must use `richTextLine`; (b) the navbar's card caption is drawn in the browser, so the server sends `descriptionHtml` (made only in `resolveMenuDecorations`, stripped from saved and served items otherwise) and `menu-cards.mjs` rebuilds it from an allow-list - never `innerHTML` a menu value; (c) Domma's wizard writes a step description as HTML and its chooser writes an option description as text, so `publicFormDescriptions()` (forms.js) gives the first as cleaned inline HTML and the second as words on BOTH public paths (`[form]` embed, `GET /forms/:slug/public`), and the editor's preview mirrors it; (d) an empty editor's first line has no `<p>` - `asBlocks()` wraps it before it is stored, do not read the editor's own HTML; (e) inside a dense row use `{compact: true}`, whose toolbar opens UNDER the text so nothing moves between mouse down and up.
765
+
764
766
  ## Docs
765
767
 
766
768
  - `docs/getting-started.md` - Installation, first run, setup wizard
@@ -1 +1 @@
1
- export const WIDTHS=["narrow","normal","wide","full"],WIDTH_LABELS={narrow:"Narrow",normal:"Normal",wide:"Wide",full:"Full width"},WIDTH_HINTS={narrow:"768px - a reading column",normal:"1100px",wide:"75% of the window, up to 2000px",full:"edge to edge"},WIDTH_SHARE={narrow:"40%",normal:"62%",wide:"82%",full:"100%"},FILTERS=["all","builtin","custom"];const b=/^[a-zA-Z0-9#(),.\s%/-]+$/;export function layoutKey(e){return String(e??"").toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}const g=(e,t,l=`${t}s`)=>`${e} ${e===1?t:l}`;export function chromeText(e){const t=[e.navbar!==!1&&"navbar",e.footer!==!1&&"footer",e.sidebar===!0&&"page contents"].filter(Boolean);return t.length?t.join(", "):"no navbar or footer"}export function arrangeLayouts(e,t={},{filter:l="all",query:o=""}={}){const i=String(o).trim().toLowerCase(),n=Object.entries(e||{}).map(([r,s])=>({...s,key:r})),a=n.filter(r=>r.builtin),c=n.filter(r=>!r.builtin).sort((r,s)=>String(r.label||r.key).localeCompare(String(s.label||s.key)));return[...a,...c].filter(r=>l==="builtin"?r.builtin:l==="custom"?!r.builtin:!0).filter(r=>!i||[r.key,r.label,r.description,r.class].some(s=>String(s||"").toLowerCase().includes(i))).map(r=>layoutRow(r,(t.byKey||{})[r.key]||[]))}export function layoutRow(e,t=[]){const l=WIDTHS.includes(e.width)?e.width:"normal";return{key:e.key,label:e.label||e.key,meta:[e.key,e.description,chromeText(e)].filter(Boolean).join(" \xB7 "),builtin:e.builtin===!0,widthLabel:WIDTH_LABELS[l],used:t.length,usedText:t.length?g(t.length,"page"):"Unused",usedTone:t.length?"is-info":"is-muted",hasNav:e.navbar!==!1,hasFoot:e.footer!==!1,hasSide:e.sidebar===!0,sideRight:e.sidebar===!0&&e.sidebarSide==="right",share:WIDTH_SHARE[l],bg:e.bgColor&&b.test(e.bgColor)?e.bgColor:""}}export function formFromPreset(e={}){return{label:e.label||"",description:e.description||"",width:WIDTHS.includes(e.width)?e.width:"normal",navbar:e.navbar!==!1,footer:e.footer!==!1,sidebar:e.sidebar===!0,sidebarSide:e.sidebarSide==="right"?"right":"left",useBg:!!e.bgColor,bgColor:e.bgColor&&/^#[0-9a-f]{6}$/i.test(e.bgColor)?e.bgColor:e.bgColor||"#ffffff",bgImage:e.bgImage||"",cssClass:e.class||"",...contentsForm(e.contents)}}export function contentsForm(e={}){return{cWidth:e.width!=null?String(e.width):"",cSticky:e.sticky!==!1,cScrollSpy:e.scrollSpy!==!1,cFloating:e.floating===!0,cFloatAnchor:e.floatAnchor||"TR",cMovable:e.movable===!0,cCollapsible:e.collapsible===!0,cCollapsed:e.collapsed===!0,cAutohide:e.autohide===!0,cHeadings:e.headings||"auto",cNumbered:e.numbered===!0,cTitle:e.title||"",cExclude:e.exclude||"",cHover:e.hover||"",cSelected:e.selected||"",cAccent:e.accent||"",cFont:e.font||"",cFontSize:e.fontSize||"",cFontWeight:e.fontWeight||""}}export function contentsFromForm(e={}){const t={},l=parseInt(e.cWidth,10);Number.isFinite(l)&&(t.width=l),e.cSticky===!1&&(t.sticky=!1),e.cScrollSpy===!1&&(t.scrollSpy=!1),e.cFloating===!0?(t.floating=!0,t.floatAnchor=e.cFloatAnchor||"TR",e.cMovable===!0&&(t.movable=!0)):e.cAutohide===!0?t.autohide=!0:e.cCollapsible===!0&&(t.collapsible=!0,e.cCollapsed===!0&&(t.collapsed=!0)),e.cHeadings&&e.cHeadings!=="auto"&&(t.headings=e.cHeadings),e.cNumbered===!0&&(t.numbered=!0);for(const[o,i]of[["title","cTitle"],["exclude","cExclude"],["hover","cHover"],["selected","cSelected"],["accent","cAccent"],["font","cFont"],["fontSize","cFontSize"],["fontWeight","cFontWeight"]]){const n=String(e[i]??"").trim();n&&(t[o]=n)}return t}export function checkLayout(e,{isNew:t,taken:l=[]}={}){const o=e||{},i={},n=String(o.label??"").trim(),a=t?layoutKey(n):"";n?n.length>60?i.label="Up to 60 characters.":t&&!a?i.label="Needs at least one letter or number.":t&&l.includes(a)&&(i.label=`"${a}" is already a layout - choose another name.`):i.label="A layout needs a name.";const c=o.useBg?String(o.bgColor||"").trim():"";c&&!b.test(c)&&(i.bgColor="Not a colour the server accepts.");const r=String(o.bgImage??"").trim(),s=String(o.cssClass??"").trim();/[^a-zA-Z0-9\s_-]/.test(s)&&(i.cssClass="Letters, numbers, spaces, hyphens and underscores only.");const u=String(o.cWidth??"").trim();u&&!(Number(u)>=160&&Number(u)<=480)&&(i.cWidth="From 160 to 480 px, or blank for the usual 260.");const d=o.sidebar===!0?contentsFromForm(o):{},f={label:n,description:String(o.description??"").trim().slice(0,200),width:WIDTHS.includes(o.width)?o.width:"normal",navbar:o.navbar!==!1,footer:o.footer!==!1,sidebar:o.sidebar===!0,sidebarSide:o.sidebarSide==="right"?"right":"left",bgColor:c,bgImage:r,class:s,...Object.keys(d).length&&{contents:d}};return{errors:i,payload:f,key:a}}export function checkOptions(e){const t={},l=String(e?.spacerSize??"").trim(),o=Number(l);(l===""||!Number.isInteger(o)||o<0||o>500)&&(t.spacerSize="A whole number of pixels, 0 to 500.");const i=String(e?.spacerClass??"").trim();return/[^a-zA-Z0-9\s_-]/.test(i)&&(t.spacerClass="Letters, numbers, spaces, hyphens and underscores only."),{errors:t,payload:{spacerSize:Number.isInteger(o)?o:8,spacerClass:i}}}
1
+ import{richTextToPlain as g,richTextSummary as h}from"../../../public/js/rich-text.mjs";export const WIDTHS=["narrow","normal","wide","full"],WIDTH_LABELS={narrow:"Narrow",normal:"Normal",wide:"Wide",full:"Full width"},WIDTH_HINTS={narrow:"768px - a reading column",normal:"1100px",wide:"75% of the window, up to 2000px",full:"edge to edge"},WIDTH_SHARE={narrow:"40%",normal:"62%",wide:"82%",full:"100%"},FILTERS=["all","builtin","custom"];const b=/^[a-zA-Z0-9#(),.\s%/-]+$/;export function layoutKey(e){return String(e??"").toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}const m=(e,t,l=`${t}s`)=>`${e} ${e===1?t:l}`;export function chromeText(e){const t=[e.navbar!==!1&&"navbar",e.footer!==!1&&"footer",e.sidebar===!0&&"page contents"].filter(Boolean);return t.length?t.join(", "):"no navbar or footer"}export function arrangeLayouts(e,t={},{filter:l="all",query:r=""}={}){const i=String(r).trim().toLowerCase(),n=Object.entries(e||{}).map(([o,s])=>({...s,key:o})),a=n.filter(o=>o.builtin),c=n.filter(o=>!o.builtin).sort((o,s)=>String(o.label||o.key).localeCompare(String(s.label||s.key)));return[...a,...c].filter(o=>l==="builtin"?o.builtin:l==="custom"?!o.builtin:!0).filter(o=>!i||[o.key,o.label,g(o.description),o.class].some(s=>String(s||"").toLowerCase().includes(i))).map(o=>layoutRow(o,(t.byKey||{})[o.key]||[]))}export function layoutRow(e,t=[]){const l=WIDTHS.includes(e.width)?e.width:"normal";return{key:e.key,label:e.label||e.key,meta:[e.key,h(e.description,140),chromeText(e)].filter(Boolean).join(" \xB7 "),builtin:e.builtin===!0,widthLabel:WIDTH_LABELS[l],used:t.length,usedText:t.length?m(t.length,"page"):"Unused",usedTone:t.length?"is-info":"is-muted",hasNav:e.navbar!==!1,hasFoot:e.footer!==!1,hasSide:e.sidebar===!0,sideRight:e.sidebar===!0&&e.sidebarSide==="right",share:WIDTH_SHARE[l],bg:e.bgColor&&b.test(e.bgColor)?e.bgColor:""}}export function formFromPreset(e={}){return{label:e.label||"",description:e.description||"",width:WIDTHS.includes(e.width)?e.width:"normal",navbar:e.navbar!==!1,footer:e.footer!==!1,sidebar:e.sidebar===!0,sidebarSide:e.sidebarSide==="right"?"right":"left",useBg:!!e.bgColor,bgColor:e.bgColor&&/^#[0-9a-f]{6}$/i.test(e.bgColor)?e.bgColor:e.bgColor||"#ffffff",bgImage:e.bgImage||"",cssClass:e.class||"",...contentsForm(e.contents)}}export function contentsForm(e={}){return{cWidth:e.width!=null?String(e.width):"",cSticky:e.sticky!==!1,cScrollSpy:e.scrollSpy!==!1,cFloating:e.floating===!0,cFloatAnchor:e.floatAnchor||"TR",cMovable:e.movable===!0,cCollapsible:e.collapsible===!0,cCollapsed:e.collapsed===!0,cAutohide:e.autohide===!0,cHeadings:e.headings||"auto",cNumbered:e.numbered===!0,cTitle:e.title||"",cExclude:e.exclude||"",cHover:e.hover||"",cSelected:e.selected||"",cAccent:e.accent||"",cFont:e.font||"",cFontSize:e.fontSize||"",cFontWeight:e.fontWeight||""}}export function contentsFromForm(e={}){const t={},l=parseInt(e.cWidth,10);Number.isFinite(l)&&(t.width=l),e.cSticky===!1&&(t.sticky=!1),e.cScrollSpy===!1&&(t.scrollSpy=!1),e.cFloating===!0?(t.floating=!0,t.floatAnchor=e.cFloatAnchor||"TR",e.cMovable===!0&&(t.movable=!0)):e.cAutohide===!0?t.autohide=!0:e.cCollapsible===!0&&(t.collapsible=!0,e.cCollapsed===!0&&(t.collapsed=!0)),e.cHeadings&&e.cHeadings!=="auto"&&(t.headings=e.cHeadings),e.cNumbered===!0&&(t.numbered=!0);for(const[r,i]of[["title","cTitle"],["exclude","cExclude"],["hover","cHover"],["selected","cSelected"],["accent","cAccent"],["font","cFont"],["fontSize","cFontSize"],["fontWeight","cFontWeight"]]){const n=String(e[i]??"").trim();n&&(t[r]=n)}return t}export function checkLayout(e,{isNew:t,taken:l=[]}={}){const r=e||{},i={},n=String(r.label??"").trim(),a=t?layoutKey(n):"";n?n.length>60?i.label="Up to 60 characters.":t&&!a?i.label="Needs at least one letter or number.":t&&l.includes(a)&&(i.label=`"${a}" is already a layout - choose another name.`):i.label="A layout needs a name.";const c=r.useBg?String(r.bgColor||"").trim():"";c&&!b.test(c)&&(i.bgColor="Not a colour the server accepts.");const o=String(r.bgImage??"").trim(),s=String(r.cssClass??"").trim();/[^a-zA-Z0-9\s_-]/.test(s)&&(i.cssClass="Letters, numbers, spaces, hyphens and underscores only.");const u=String(r.cWidth??"").trim();u&&!(Number(u)>=160&&Number(u)<=480)&&(i.cWidth="From 160 to 480 px, or blank for the usual 260.");const d=r.sidebar===!0?contentsFromForm(r):{},f={label:n,description:String(r.description??"").trim(),width:WIDTHS.includes(r.width)?r.width:"normal",navbar:r.navbar!==!1,footer:r.footer!==!1,sidebar:r.sidebar===!0,sidebarSide:r.sidebarSide==="right"?"right":"left",bgColor:c,bgImage:o,class:s,...Object.keys(d).length&&{contents:d}};return{errors:i,payload:f,key:a}}export function checkOptions(e){const t={},l=String(e?.spacerSize??"").trim(),r=Number(l);(l===""||!Number.isInteger(r)||r<0||r>500)&&(t.spacerSize="A whole number of pixels, 0 to 500.");const i=String(e?.spacerClass??"").trim();return/[^a-zA-Z0-9\s_-]/.test(i)&&(t.spacerClass="Letters, numbers, spaces, hyphens and underscores only."),{errors:t,payload:{spacerSize:Number.isInteger(r)?r:8,spacerClass:i}}}
@@ -1,9 +1,16 @@
1
- import{isRichText as m,plainToRichHtml as D,richTextToPlain as d,richTextSummary as L}from"../../../public/js/rich-text.mjs";export{m as isRichText,d as richTextToPlain,L as richTextSummary};const O=[["bold","italic","underline"],["ul","ol"],["link"],["undo","redo"]],v={ALLOWED_TAGS:["p","br","strong","b","em","i","u","s","ul","ol","li","a","h2","h3","h4","blockquote","code"],ALLOWED_ATTR:["href","target","rel"],ALLOW_DATA_ATTR:!1},y="rich-description-css",C=`
1
+ import{isRichText as m,plainToRichHtml as v,richTextToPlain as p,richTextSummary as _,richTextLine as T,escapeHtml as w}from"../../../public/js/rich-text.mjs";export{m as isRichText,p as richTextToPlain,_ as richTextSummary,T as richTextLine};const P=[["bold","italic","underline"],["ul","ol"],["link"],["undo","redo"]],C={ALLOWED_TAGS:["p","br","strong","b","em","i","u","s","ul","ol","li","a","h2","h3","h4","blockquote","code"],ALLOWED_ATTR:["href","target","rel"],ALLOW_DATA_ATTR:!1},A="rich-description-css",M=`
2
2
  .rich-description{display:none}
3
3
  .rich-description-editor .dm-editor-body,.rich-description-editor .dm-editor-content{min-height:var(--rich-description-min,6rem)}
4
4
  .rich-description-editor .dm-editor-content{padding:.6rem .75rem}
5
+ .rich-description-compact .dm-editor-toolbar,.rich-description-compact .dm-editor-footer{display:none}
6
+ .rich-description-compact:focus-within .dm-editor-toolbar{display:flex}
7
+ .rich-description-compact .dm-editor-content{padding:.4rem .6rem;font-size:var(--dm-font-size-sm)}
8
+ .rich-description-compact .dm-editor-content>:first-child{margin-top:0}
9
+ .rich-description-compact .dm-editor-content>:last-child{margin-bottom:0}
10
+ .rich-description-compact .dm-editor-toolbar{order:2;border-bottom:0;border-top:1px solid var(--dm-border);padding:.25rem .4rem;gap:.25rem}
11
+ .rich-description-compact .dm-editor-toolbar-btn{width:26px;height:26px}
5
12
  .rich-text>:first-child{margin-top:0}
6
13
  .rich-text>:last-child{margin-bottom:0}
7
14
  .rich-text p,.rich-text ul,.rich-text ol,.rich-text blockquote{margin:0 0 .5em}
8
15
  .rich-text ul,.rich-text ol{padding-left:1.25em}
9
- `;function x(){if(document.getElementById(y))return;const t=document.createElement("style");t.id=y,t.textContent=C,document.head.appendChild(t)}const l=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value"),T=t=>m(t)?t:D(t),P=/^(P|UL|OL|H[1-6]|BLOCKQUOTE|DIV)$/;export function asBlocks(t){const c=new DOMParser().parseFromString(`<body>${t??""}</body>`,"text/html"),n=c.createElement("div");let e=null;for(const r of[...c.body.childNodes]){if(r.nodeType===1&&P.test(r.tagName)){if(e=null,r.tagName==="DIV"){const i=c.createElement("p");i.append(...r.childNodes),n.append(i)}else n.append(r);continue}!e&&r.nodeType===3&&!r.textContent.trim()||(e||(e=c.createElement("p"),n.append(e)),e.append(r))}return n.innerHTML}const w=t=>!!d(T(t)).replace(/^- ?$/gm,"").trim();export function richDescription(t,{minHeight:c=88,placeholder:n}={}){const e=typeof t=="string"?document.querySelector(t):t?.get?.(0)??t,r={rich:!1,get:()=>e?.value??"",getText:()=>d(e?.value??""),set:o=>{e&&(e.value=o??"")},focus:()=>e?.focus(),destroy:()=>{}};if(!(e instanceof HTMLTextAreaElement)||e._richDescription||typeof globalThis.E?.editor!="function")return e?._richDescription??r;const i=document.createElement("div");i.className="rich-description",e.after(i);let h,p=!1,u=null;const E=o=>{l.get.call(e)!==o&&(l.set.call(e,o),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))},f=o=>{const s=T(o);if(s!==u){p=!0;try{h.setValue(s)}finally{p=!1}u=s}};try{h=globalThis.E.editor(i,{mode:"rich",minHeight:c,imagePaste:!1,toolbar:O,placeholder:n??e.getAttribute("placeholder")??"",onChange:o=>{if(p)return;const s=typeof o=="string"?o:h.getValue();u=s,E(w(s)?asBlocks(s):"")}})}catch{return i.remove(),r}const a=i.nextElementSibling?.querySelector("[contenteditable]")?i.nextElementSibling:i;x(),a.classList.add("rich-description-editor"),a.style.minHeight="",a.style.setProperty("--rich-description-min",`${c}px`);const g=a.querySelector("[contenteditable]"),S=e.id?document.querySelector(`label[for="${CSS.escape(e.id)}"]`):e.closest("label"),A=e.getAttribute("aria-label")||S?.childNodes[0]?.textContent?.trim()||"Description";g?.setAttribute("aria-label",A),e.removeAttribute("maxlength"),e.hidden=!0,f(l.get.call(e)),Object.defineProperty(e,"value",{configurable:!0,get:()=>l.get.call(e),set:o=>{l.set.call(e,o??""),f(l.get.call(e))}});const b={rich:!0,get:()=>l.get.call(e),getText:()=>d(l.get.call(e)),set:o=>{e.value=o??""},focus:()=>g?.focus(),destroy:()=>{delete e.value,delete e._richDescription;try{h.destroy?.()}catch{}a!==i&&a.remove(),i.remove(),e.hidden=!1}};return e._richDescription=b,b}export function showRichText(t,c){const n=t?.get?.(0)??t;if(!n)return;const e=typeof c=="string"?c:"";if(!m(e)||!globalThis.DOMPurify){n.textContent=d(e),n.style.whiteSpace="pre-line";return}n.style.whiteSpace="",x();const r=new DOMParser().parseFromString(globalThis.DOMPurify.sanitize(e,v),"text/html");for(const i of r.body.querySelectorAll("a"))i.setAttribute("rel","noopener noreferrer");n.classList.add("rich-text"),n.replaceChildren(...r.body.childNodes)}
16
+ `;function L(){if(document.getElementById(A))return;const t=document.createElement("style");t.id=A,t.textContent=M,document.head.appendChild(t)}const a=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value"),E=t=>m(t)?t:v(t),N=/^(P|UL|OL|H[1-6]|BLOCKQUOTE|DIV)$/;export function asBlocks(t){const n=new DOMParser().parseFromString(`<body>${t??""}</body>`,"text/html"),i=n.createElement("div");let r=null;for(const e of[...n.body.childNodes]){if(e.nodeType===1&&N.test(e.tagName)){if(r=null,e.tagName==="DIV"){const l=n.createElement("p");l.append(...e.childNodes),i.append(l)}else i.append(e);continue}!r&&e.nodeType===3&&!e.textContent.trim()||(r||(r=n.createElement("p"),i.append(r)),r.append(e))}return i.innerHTML}const q=t=>!!p(E(t)).replace(/^- ?$/gm,"").trim();export function richDescription(t,{compact:n=!1,minHeight:i=n?40:88,placeholder:r}={}){const e=typeof t=="string"?document.querySelector(t):t?.get?.(0)??t,l={rich:!1,get:()=>e?.value??"",getText:()=>p(e?.value??""),set:o=>{e&&(e.value=o??"")},focus:()=>e?.focus(),destroy:()=>{}};if(!(e instanceof HTMLTextAreaElement)||e._richDescription||typeof globalThis.E?.editor!="function")return e?._richDescription??l;const c=document.createElement("div");c.className="rich-description",e.after(c);let h,u=!1,f=null;const D=o=>{a.get.call(e)!==o&&(a.set.call(e,o),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))},b=o=>{const d=E(o);if(d!==f){u=!0;try{h.setValue(d)}finally{u=!1}f=d}};try{h=globalThis.E.editor(c,{mode:"rich",minHeight:i,imagePaste:!1,toolbar:P,placeholder:r??e.getAttribute("placeholder")??"",onChange:o=>{if(u)return;const d=typeof o=="string"?o:h.getValue(),x=q(d)?asBlocks(d):"";f=x||d,D(x)}})}catch{return c.remove(),l}const s=c.nextElementSibling?.querySelector("[contenteditable]")?c.nextElementSibling:c;L(),s.classList.add("rich-description-editor"),n&&s.classList.add("rich-description-compact"),s.style.minHeight="",s.style.setProperty("--rich-description-min",`${i}px`);const g=s.querySelector("[contenteditable]");s.addEventListener("click",o=>{s.closest("label")&&!o.target.closest("button, a, input, select, textarea")&&o.preventDefault()});const S=e.id?document.querySelector(`label[for="${CSS.escape(e.id)}"]`):e.closest("label"),O=e.getAttribute("aria-label")||S?.childNodes[0]?.textContent?.trim()||"Description";g?.setAttribute("aria-label",O),e.removeAttribute("maxlength"),e.hidden=!0,b(a.get.call(e)),Object.defineProperty(e,"value",{configurable:!0,get:()=>a.get.call(e),set:o=>{a.set.call(e,o??""),b(a.get.call(e))}});const y={rich:!0,get:()=>a.get.call(e),getText:()=>p(a.get.call(e)),set:o=>{e.value=o??""},focus:()=>g?.focus(),destroy:()=>{delete e.value,delete e._richDescription;try{h.destroy?.()}catch{}s!==c&&s.remove(),c.remove(),e.hidden=!1}};return e._richDescription=y,y}export function showRichText(t,n){const i=t?.get?.(0)??t;if(!i)return;const r=typeof n=="string"?n:"";if(!m(r)||!globalThis.DOMPurify){i.textContent=p(r),i.style.whiteSpace="pre-line";return}i.style.whiteSpace="",L();const e=new DOMParser().parseFromString(globalThis.DOMPurify.sanitize(r,C),"text/html");for(const l of e.body.querySelectorAll("a"))l.setAttribute("rel","noopener noreferrer");i.classList.add("rich-text"),i.replaceChildren(...e.body.childNodes)}export function richTextInlineHtml(t,{links:n=!0,legacyHtml:i=!1}={}){const r=typeof t=="string"?t.trim():"";if(!r)return"";const e=m(r);if(!globalThis.DOMPurify||!e&&!i)return w(T(r));const l=r.replace(/<li(\s[^<>]*)?>/gi,"- ").replace(/<\/(p|h[1-6]|blockquote|li|ul|ol|div)>/gi,"<br>");return globalThis.DOMPurify.sanitize(l,{ALLOWED_TAGS:["strong","b","em","i","u","s","code","br",...n?["a"]:[]],ALLOWED_ATTR:n?["href","target","rel"]:[],ALLOW_DATA_ATTR:!1}).replace(/(\s*<br\s*\/?>\s*){2,}/g,"<br>").replace(/^(\s|<br\s*\/?>)+|(\s|<br\s*\/?>)+$/g,"")}
@@ -1 +1 @@
1
- const a=(e,t)=>String(e??"").trim().slice(0,t);export function seoDefaults(e={}){const t=e.seo||{};return{defaultTitle:String(t.defaultTitle??""),titleSeparator:String(t.titleSeparator??" | "),defaultDescription:String(t.defaultDescription??""),defaultImage:String(t.defaultImage??"")}}export function checkSeoDefaults(e){if(!e||typeof e!="object"||Array.isArray(e))return{error:"SEO defaults must be an object."};const t={defaultTitle:a(e.defaultTitle,200),titleSeparator:String(e.titleSeparator??" | ").slice(0,20)||" | ",defaultDescription:a(e.defaultDescription,400),defaultImage:a(e.defaultImage,500)};return t.defaultImage&&!/^(https?:\/\/[^\s]+|\/(?!\/)[^\s\\]*)$/i.test(t.defaultImage)?{error:"The default share image needs a /media/ path or a full web address."}:{defaults:t}}
1
+ export const DEFAULT_DESCRIPTION_MAX=2e3;const a=(e,t)=>String(e??"").trim().slice(0,t);export function seoDefaults(e={}){const t=e.seo||{};return{defaultTitle:String(t.defaultTitle??""),titleSeparator:String(t.titleSeparator??" | "),defaultDescription:String(t.defaultDescription??""),defaultImage:String(t.defaultImage??"")}}export function checkSeoDefaults(e){if(!e||typeof e!="object"||Array.isArray(e))return{error:"SEO defaults must be an object."};const t={defaultTitle:a(e.defaultTitle,200),titleSeparator:String(e.titleSeparator??" | ").slice(0,20)||" | ",defaultDescription:a(e.defaultDescription,2e3),defaultImage:a(e.defaultImage,500)};return t.defaultImage&&!/^(https?:\/\/[^\s]+|\/(?!\/)[^\s\\]*)$/i.test(t.defaultImage)?{error:"The default share image needs a /media/ path or a full web address."}:{defaults:t}}
@@ -115,8 +115,8 @@
115
115
  <pre class="code-block"><code class="language-json">GET /api/content/v1/pages/about?format=html (html | markdown | both)
116
116
 
117
117
  {
118
- "urlPath": "/about", "title": "About", "description": "…", "tags": ["company"],
119
- "category": "general", "layout": "default", "createdAt": "…", "updatedAt": "…",
118
+ "urlPath": "/about", "title": "About", "description": "…", "descriptionHtml": "&lt;p&gt;…&lt;/p&gt;",
119
+ "tags": ["company"], "category": "general", "layout": "default", "createdAt": "…", "updatedAt": "…",
120
120
  "seo": { "title": "…", "description": "…", "image": "…" },
121
121
  "html": "&lt;section&gt;…&lt;/section&gt;",
122
122
  "requires": { "domma": true, "components": ["tabs", "effects"] },
@@ -126,6 +126,7 @@
126
126
  <li><code>html</code> is the page body (no navbar or footer), shortcodes already rendered. <code>markdown</code> is the source, shortcodes included. A format the site does not offer answers <code>400</code>.</li>
127
127
  <li><code>requires</code> names the Domma behaviour the HTML relies on - tabs, accordions, carousels, countdowns, tooltips, reveals, effects, forms and custom components. Without Domma's CSS and JS those parts do nothing.</li>
128
128
  <li>Only the front matter keys shown are returned - never your own custom keys.</li>
129
+ <li><code>description</code> is always plain text on one line. <code>descriptionHtml</code> is the same words as safe HTML, with the formatting of a description written in the rich text editor; it is left out when a page has no description. <code>seo.description</code> is plain text.</li>
129
130
  <li><code>perViewer: true</code> - the body was rendered for this caller and must not be shared between users.</li>
130
131
  <li>Drafts: in role mode only, <code>?preview=1</code> from someone with <code>pages.read</code> returns unpublished pages, never cached.</li>
131
132
  </ul>
@@ -89,7 +89,7 @@
89
89
  <thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead>
90
90
  <tbody>
91
91
  <tr><td><code>label</code></td><td>string</td><td>Required. Up to 60 characters</td></tr>
92
- <tr><td><code>description</code></td><td>string</td><td>Up to 200 characters</td></tr>
92
+ <tr><td><code>description</code></td><td>string</td><td>Plain text, or rich text as the admin's editor writes it (cleaned on save; up to 2,000 characters with its formatting)</td></tr>
93
93
  <tr><td><code>navbar</code>, <code>footer</code></td><td>boolean</td><td>Show them (default true)</td></tr>
94
94
  <tr><td><code>sidebar</code></td><td>boolean</td><td>Show a sidebar (default false)</td></tr>
95
95
  <tr><td><code>width</code></td><td>string</td><td><code>narrow</code>, <code>normal</code> (default),
@@ -107,7 +107,8 @@
107
107
  floating Search button in the bottom corners.</li>
108
108
  <li><strong>Dropdown style: Cards</strong> - each dropdown opens as a large rounded card under its
109
109
  item, with a little pointer. Every sub-item gets a coloured tile round its icon and a line of
110
- description, laid out in columns. A sub-item with sub-items of its own becomes a column with a
110
+ description, laid out in columns. The description can have bold, italic and underline; it is
111
+ limited to 160 characters of words. A sub-item with sub-items of its own becomes a column with a
111
112
  small heading.</li>
112
113
  <li><strong>Icon tiles</strong> - Rainbow gives each entry the next colour along; Theme colour
113
114
  and Neutral use one colour; No tiles shows the plain icon. An item's own Tile colour always wins.</li>
@@ -61,7 +61,9 @@ theme: ocean-light # optional per-page theme
61
61
  # Page heading
62
62
  Your Markdown content goes here.</code></pre>
63
63
  <p>The editor's <strong>Page Details</strong> tab sets all of these, and the
64
- <strong>SEO</strong> tab sets the page's search title and description.</p>
64
+ <strong>SEO</strong> tab sets the page's search title and description. Both descriptions
65
+ can have bold, italic, lists and links; a description typed straight into the front matter
66
+ is plain text and stays that way.</p>
65
67
 
66
68
  <h3>Drafts and previews</h3>
67
69
  <p>A page with <code>status: draft</code> answers 404 to visitors. Signed in with permission to
@@ -40,6 +40,9 @@
40
40
  posts), each with its title, full address and description, under your site's name and
41
41
  description. It is the format AI assistants look for. Write a description for each page in the
42
42
  page editor's <strong>SEO</strong> tab and it appears here too.</p>
43
+ <p>The description boxes let you use bold, lists and links. Search engines, share cards and
44
+ <code>/llms.txt</code> carry the words only, so the formatting is for your own reading - and the
45
+ length meters in <strong>Tools &gt; SEO</strong> count the words, not the formatting.</p>
43
46
  <p>It is on by default. Switch it off in <strong>Tools &gt; SEO &gt; Settings</strong> ("Publish
44
47
  /llms.txt for AI assistants"). While "Ask every search engine to stay away" is on, it is
45
48
  withdrawn as well.</p>
@@ -327,7 +327,7 @@
327
327
  </div>
328
328
  <div class="pe-field">
329
329
  <label class="form-label" for="field-description">Description</label>
330
- <input id="field-description" type="text" data-model="description.value" class="form-input" placeholder="Short description">
330
+ <textarea id="field-description" rows="2" data-model="description.value" class="form-input" placeholder="Short description"></textarea>
331
331
  </div>
332
332
  <div class="pe-field-row">
333
333
  <div class="pe-field">
@@ -403,8 +403,8 @@
403
403
  <input id="field-seo-title" type="text" data-model="seoTitle.value" class="form-input" placeholder="Overrides default title">
404
404
  </div>
405
405
  <div class="pe-field">
406
- <label class="form-label" for="field-seo-desc">SEO Description <span data-help="The summary search engines show under the title. Blank uses the page description."></span></label>
407
- <input id="field-seo-desc" type="text" data-model="seoDesc.value" class="form-input" placeholder="Overrides default description">
406
+ <label class="form-label" for="field-seo-desc">SEO Description <span data-help="The summary search engines show under the title. Blank uses the site's default description. Search engines and share cards show the words only - formatting is not carried over."></span></label>
407
+ <textarea id="field-seo-desc" rows="2" data-model="seoDesc.value" class="form-input" placeholder="Overrides default description"></textarea>
408
408
  </div>
409
409
  <div class="pe-field">
410
410
  <label class="form-label" for="field-seo-schema">Structured data (JSON-LD) <span data-help-title="Structured data" data-help="Schema.org JSON-LD for this page - a SoftwareApplication, an Organization, an Article, a FAQ… Search engines read it for rich results. Pick an example to start from, then fill it in. One object, or a list of them; each needs an &quot;@type&quot;. It goes into the page's head as a script of type application/ld+json, after the WebPage and breadcrumb blocks every page already gets."></span></label>