domma-cms 1.67.1 → 1.67.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.67.2] - 2026-11-15
4
+
5
+ ### Fixed
6
+
7
+ - **A description typed into an empty box keeps its formatting.** Text typed into an empty rich text Description (rather than added to an existing one) was saved in a form that was then shown with its tags visible, such as `<b>` around a bold word. It is now saved as proper paragraphs. A description saved that way since 1.67.0 needs opening, any small edit, and saving again.
8
+
3
9
  ## [1.67.1] - 2026-11-15
4
10
 
5
11
  ### Security
@@ -1,4 +1,4 @@
1
- import{isRichText as m,plainToRichHtml as v,richTextToPlain as d,richTextSummary as D}from"../../../public/js/rich-text.mjs";export{m as isRichText,d as richTextToPlain,D as richTextSummary};const L=[["bold","italic","underline"],["ul","ol"],["link"],["undo","redo"]],O={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",_=`
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=`
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}
@@ -6,4 +6,4 @@ import{isRichText as m,plainToRichHtml as v,richTextToPlain as d,richTextSummary
6
6
  .rich-text>:last-child{margin-bottom:0}
7
7
  .rich-text p,.rich-text ul,.rich-text ol,.rich-text blockquote{margin:0 0 .5em}
8
8
  .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=_,document.head.appendChild(t)}const n=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value"),T=t=>m(t)?t:v(t),w=t=>!!d(T(t)).replace(/^- ?$/gm,"").trim();export function richDescription(t,{minHeight:s=88,placeholder:o}={}){const e=typeof t=="string"?document.querySelector(t):t?.get?.(0)??t,a={rich:!1,get:()=>e?.value??"",getText:()=>d(e?.value??""),set:r=>{e&&(e.value=r??"")},focus:()=>e?.focus(),destroy:()=>{}};if(!(e instanceof HTMLTextAreaElement)||e._richDescription||typeof globalThis.E?.editor!="function")return e?._richDescription??a;const i=document.createElement("div");i.className="rich-description",e.after(i);let h,u=!1,p=null;const S=r=>{n.get.call(e)!==r&&(n.set.call(e,r),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))},f=r=>{const c=T(r);if(c!==p){u=!0;try{h.setValue(c)}finally{u=!1}p=c}};try{h=globalThis.E.editor(i,{mode:"rich",minHeight:s,imagePaste:!1,toolbar:L,placeholder:o??e.getAttribute("placeholder")??"",onChange:r=>{if(u)return;const c=typeof r=="string"?r:h.getValue();p=c,S(w(c)?c:"")}})}catch{return i.remove(),a}const l=i.nextElementSibling?.querySelector("[contenteditable]")?i.nextElementSibling:i;x(),l.classList.add("rich-description-editor"),l.style.minHeight="",l.style.setProperty("--rich-description-min",`${s}px`);const g=l.querySelector("[contenteditable]"),A=e.id?document.querySelector(`label[for="${CSS.escape(e.id)}"]`):e.closest("label"),E=e.getAttribute("aria-label")||A?.childNodes[0]?.textContent?.trim()||"Description";g?.setAttribute("aria-label",E),e.removeAttribute("maxlength"),e.hidden=!0,f(n.get.call(e)),Object.defineProperty(e,"value",{configurable:!0,get:()=>n.get.call(e),set:r=>{n.set.call(e,r??""),f(n.get.call(e))}});const b={rich:!0,get:()=>n.get.call(e),getText:()=>d(n.get.call(e)),set:r=>{e.value=r??""},focus:()=>g?.focus(),destroy:()=>{delete e.value,delete e._richDescription;try{h.destroy?.()}catch{}l!==i&&l.remove(),i.remove(),e.hidden=!1}};return e._richDescription=b,b}export function showRichText(t,s){const o=t?.get?.(0)??t;if(!o)return;const e=typeof s=="string"?s:"";if(!m(e)||!globalThis.DOMPurify){o.textContent=d(e),o.style.whiteSpace="pre-line";return}o.style.whiteSpace="",x();const a=new DOMParser().parseFromString(globalThis.DOMPurify.sanitize(e,O),"text/html");for(const i of a.body.querySelectorAll("a"))i.setAttribute("rel","noopener noreferrer");o.classList.add("rich-text"),o.replaceChildren(...a.body.childNodes)}
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)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.67.1",
3
+ "version": "1.67.2",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",