domma-cms 1.30.1 → 1.32.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 (50) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CLAUDE.md +36 -1
  3. package/admin/js/api.js +1 -1
  4. package/admin/js/lib/block-packs.js +26 -0
  5. package/admin/js/lib/block-tags.js +6 -1
  6. package/admin/js/lib/blocks-arrange.js +1 -1
  7. package/admin/js/lib/collection-editor-arrange.js +1 -1
  8. package/admin/js/lib/collection-entries-arrange.js +1 -1
  9. package/admin/js/lib/collections-arrange.js +1 -1
  10. package/admin/js/lib/list-tags-arrange.js +1 -1
  11. package/admin/js/lib/list-tags.js +9 -7
  12. package/admin/js/lib/pages-arrange.js +1 -1
  13. package/admin/js/lib/shortcode-context-menu.js +1 -1
  14. package/admin/js/lib/shortcode-form.js +7 -4
  15. package/admin/js/templates/blocks.html +5 -3
  16. package/admin/js/templates/collections.html +12 -2
  17. package/admin/js/templates/docs/usage-blocks.html +28 -1
  18. package/admin/js/templates/pages.html +5 -3
  19. package/admin/js/views/blocks.js +5 -4
  20. package/admin/js/views/collection-editor.js +10 -4
  21. package/admin/js/views/collection-entries.js +2 -2
  22. package/admin/js/views/collections.js +6 -5
  23. package/admin/js/views/page-editor.js +1 -1
  24. package/admin/js/views/pages.js +4 -4
  25. package/docs/DommaFeatures.md +156 -5
  26. package/docs/api-reference.md +8 -6
  27. package/docs/markdown-shortcodes.md +22 -1
  28. package/docs/starter-blocks.md +70 -1
  29. package/package.json +1 -1
  30. package/public/css/site.css +1 -1
  31. package/public/js/collection-browser.js +1 -1
  32. package/server/blocks/catalog.json +6 -0
  33. package/server/blocks/domma-block-cushion-card.css +30 -0
  34. package/server/blocks/domma-block-cushion-card.html +11 -0
  35. package/server/blocks/domma-block-cushion-card.meta.json +7 -0
  36. package/server/routes/api/block-packs.js +55 -0
  37. package/server/routes/api/blocks.js +16 -2
  38. package/server/routes/api/collections.js +9 -1
  39. package/server/routes/api/list-tags.js +35 -10
  40. package/server/routes/api/pages.js +16 -2
  41. package/server/services/block-pack-assets.js +6 -0
  42. package/server/services/block-packs.js +291 -0
  43. package/server/services/block-slots.js +43 -0
  44. package/server/services/block-write-lock.js +44 -0
  45. package/server/services/blocks.js +18 -3
  46. package/server/services/collections.js +6 -0
  47. package/server/services/listTags.js +243 -47
  48. package/server/services/markdown.js +105 -8
  49. package/server/services/starter-block-packs.js +22 -0
  50. package/server/templates/page.html +2 -2
@@ -1,4 +1,4 @@
1
- import{apiRequest as C}from"../api.js";import{addBannerAction as Pe}from"../lib/plugin-chrome.js";import{SHAPES as ge,whileLoading as be}from"../lib/loading.js";import{helpPopovers as he}from"../lib/help-popover.js";import{onceClosed as Fe,openMenuAt as ye,sidebarCount as we,viewLifetime as Ke}from"../lib/tool-kit.js";import{FILTERS as Je,arrangeCollections as He,checkNewCollection as Ye,collectionRow as ke,connectionRows as T,connectionsFromRows as b,kindCounts as _e,maskUri as ze,newConnectionRow as Ge,parseConnectionsJson as j}from"../lib/collections-arrange.js";const z=/^#\/(collections|projects\/[^/?#]+\/collections)\/?(\?.*)?$/,Ee="#/collections",A="collections.draft",G="collections.filter",Ve=`
1
+ import{api as Te,apiRequest as N}from"../api.js";import{activeNote as Ce,askManualTagName as nt,manualNames as ot,openTagSettings as at,same as lt,sharedTagFilter as st,tagCounts as ct,tagMenuItems as it,tagsOf as rt}from"../lib/list-tags.js";import{addBannerAction as Se}from"../lib/plugin-chrome.js";import{SHAPES as Le,whileLoading as Ne}from"../lib/loading.js";import{helpPopovers as $e}from"../lib/help-popover.js";import{onceClosed as dt,openMenuAt as Re,sidebarCount as De,viewLifetime as ut}from"../lib/tool-kit.js";import{FILTERS as pt,arrangeCollections as Ie,checkNewCollection as vt,collectionRow as je,connectionRows as R,connectionsFromRows as h,kindCounts as gt,maskUri as ft,newConnectionRow as mt,parseConnectionsJson as F}from"../lib/collections-arrange.js";const te=/^#\/(collections|projects\/[^/?#]+\/collections)\/?(\?.*)?$/,Ae="#/collections",K="collections.draft",ne="collections.filter",bt=`
2
2
  <div class="clx-row" data-slug="{{slug}}" tabindex="0" data-bind-class="builtin && 'is-builtin'">
3
3
  <span class="clx-icon" aria-hidden="true"><span data-icon="database" data-icon-size="16"></span></span>
4
4
  <span class="clx-main"><strong>{{title}}</strong><small>{{meta}}</small></span>
@@ -6,17 +6,18 @@ import{apiRequest as C}from"../api.js";import{addBannerAction as Pe}from"../lib/
6
6
  <span class="clx-chip is-ok" data-bind-hidden="!mongo" title="{{mongoTitle}}">MongoDB</span>
7
7
  <span class="clx-chip" data-bind-hidden="!builtin" title="Part of the CMS - cannot be deleted">Built in</span>
8
8
  <span class="clx-chip is-info" data-bind-hidden="!bundled" title="Seeded on fresh installs">Bundled</span>
9
- <span class="clx-chip is-warn" data-bind-hidden="!plugin" title="{{pluginTitle}}">{{plugin}}</span>
9
+ <span class="clx-chip is-tag" data-bind-hidden="!listTags" title="Tags">{{listTags}}</span>
10
+ <span class="clx-chip is-tool" data-bind-hidden="!toolTag" title="Tool tag - added by the {{toolTag}} Tool, which manages this collection"><span data-icon="package" data-icon-size="11"></span>{{toolTag}}</span>
10
11
  </span>
11
12
  <span class="clx-num" title="Entries">{{entriesText}}</span>
12
13
  <button type="button" class="clx-kebab" aria-label="Actions for {{title}}" title="Actions">\u22EE</button>
13
- </div>`,We=`
14
+ </div>`,ht=`
14
15
  <div class="clx-conn" data-id="{{id}}">
15
16
  <label>Name<input type="text" class="form-input" data-f="name" value="{{name}}" placeholder="default"></label>
16
17
  <label>URI<input type="text" class="form-input font-mono" data-f="uri" value="{{uri}}" placeholder="mongodb://localhost:27017" autocomplete="off"></label>
17
18
  <label>Database<input type="text" class="form-input" data-f="database" value="{{database}}" placeholder="mydb"></label>
18
19
  <button type="button" class="btn btn-sm btn-ghost" data-act="remove" title="Remove this connection" aria-label="Remove {{name}}"><span data-icon="trash" data-icon-size="14"></span></button>
19
- </div>`,L=v=>String(v??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Qe(v){const l=document.createElement("template");return l.innerHTML=v.trim(),l.content.firstElementChild}const s=Ke(z);let B=null,xe=!1;export const collectionsView={templateUrl:"/admin/js/templates/collections.html",async onMount(v){s.reset();const l=v.get(0).querySelector(".clx")||v.get(0),x=()=>z.test(location.hash)&&l.isConnected,p=M.observable([]),V=M.observable(!0),O=M.observable(""),W=location.hash.match(/^#\/projects\/([^/?#]+)\/collections/),c=M.observable(W?decodeURIComponent(W[1]):"");let Q="all";try{Q=Je.includes(S.get(G))?S.get(G):"all"}catch{}const m=M.observable(Q),X=M.observable("");s.add(M.effect(()=>{const e=m.value;try{S.set(G,e)}catch{}}));const $=M.observable([]);s.add(M.effect(()=>{$.value=He(p.value,{filter:m.value,query:X.value,project:c.value||null}).map(ke)}));const U=M.computed(()=>_e(p.value,{project:c.value||null})),Me=M.computed(()=>{const e=$.value.reduce((t,n)=>t+n.entries,0);return`${e.toLocaleString("en-GB")} entr${e===1?"y":"ies"} shown`}),Ce=M.computed(()=>U.value.all?"No collections match.":c.value?"Nothing filed under this project yet - New collection makes one here.":"No collections yet - New collection in the banner makes one."),Se=M.computed(()=>{const e=p.value.length-U.value.all;return`Showing only collections in the ${c.value} project${e?` - ${e} more elsewhere.`:"."}`}),Te=e=>p.peek().find(t=>t.slug===e);async function Z(){try{const e=await be(l.querySelector(".dm-loading-slot"),C("/collections",{method:"GET"}),ge.rows);if(!x())return;p.value=Array.isArray(e)?e:[],O.value=""}catch(e){O.value=`Could not load the collections: ${e.message||e}`}finally{V.value=!1}}const R=e=>{location.hash=e},q=e=>R(`#/collections/${encodeURIComponent(e)}/entries`);async function Le(e){const t=L(e.title||e.slug),n=e.plugin?`"${t}" belongs to the <strong>${L(e.plugin)}</strong> plugin - deleting it may stop that plugin working. Delete it and all ${Number(e.entryCount)||0} entries anyway?`:`Delete "${t}" and all ${Number(e.entryCount)||0} of its entries? This cannot be undone.`;if(await E.confirm(n))try{await C(`/collections/${encodeURIComponent(e.slug)}`,{method:"DELETE"}),E.toast(`Deleted "${e.title||e.slug}".`,{type:"success"}),we(Ee),x()&&await Z()}catch(o){E.toast(`Not deleted: ${o.message||o}`,{type:"error"})}}async function $e(e){try{await navigator.clipboard.writeText(e.slug),E.toast(`Copied "${e.slug}".`,{type:"success",duration:2e3})}catch{E.toast(`The slug is ${e.slug}`,{type:"info"})}}const P=new Set;let h=null;function ee(e=null){const t=M.observable(e?.title??""),n=M.observable(!1),o=M.computed(()=>Ye(t.value,p.value.map(i=>i.slug))),pe={title:t,saving:n,slugText:M.computed(()=>o.value.slug?`Its slug will be "${o.value.slug}" - the address in the API and in shortcodes.`:""),error:M.computed(()=>o.value.error),cannot:M.computed(()=>n.value||!t.value.trim()||!!o.value.error),projectText:c.value?`It will be filed under the ${c.value} project.`:""},fe=()=>!!t.peek().trim()&&!D,r=E.slideover({title:"New collection",size:"sm",position:"right"}),k=Qe(`
20
+ </div>`,D=g=>String(g??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function yt(g){const s=document.createElement("template");return s.innerHTML=g.trim(),s.content.firstElementChild}const l=ut(te);let J=null,Be=!1;export const collectionsView={templateUrl:"/admin/js/templates/collections.html",async onMount(g){l.reset();const s=g.get(0).querySelector(".clx")||g.get(0),y=()=>te.test(location.hash)&&s.isConnected,c=M.observable([]),oe=M.observable(!0),z=M.observable(""),ae=location.hash.match(/^#\/projects\/([^/?#]+)\/collections/),i=M.observable(ae?decodeURIComponent(ae[1]):"");let le="all";try{le=pt.includes(S.get(ne))?S.get(ne):"all"}catch{}const f=M.observable(le),H=M.observable("");l.add(M.effect(()=>{const e=f.value;try{S.set(ne,e)}catch{}}));const se=st(null),w=se.tag;l.add(se.dispose);const $=M.observable([]),k=M.observable({}),j=M.observable([]);l.add(M.effect(()=>{j.value=Ie(c.value,{filter:f.value,query:H.value,project:i.value||null,tag:w.value,tools:k.value})}));const A=M.observable([]);l.add(M.effect(()=>{const e=k.value;A.value=j.value.map(t=>je(t,e))}));const B=M.computed(()=>gt(c.value,{project:i.value||null})),Oe=M.computed(()=>Ie(c.value,{project:i.value||null})),Y=M.computed(()=>ct($.value,Oe.value,k.value)),Ue=M.computed(()=>Ce(w.value,j.value.length,"collections")),ce=M.computed(()=>!!w.value&&B.value.all>0&&!j.value.length),qe=M.computed(()=>{const e=A.value.reduce((t,n)=>t+n.entries,0);return`${e.toLocaleString("en-GB")} entr${e===1?"y":"ies"} shown`}),Pe=M.computed(()=>ce.value&&!H.value.trim()&&f.value==="all"?Ce(w.value,0,"collections"):B.value.all?"No collections match.":i.value?"Nothing filed under this project yet - New collection makes one here.":"No collections yet - New collection in the banner makes one."),Fe=M.computed(()=>{const e=c.value.length-B.value.all;return`Showing only collections in the ${i.value} project${e?` - ${e} more elsewhere.`:"."}`}),Ke=e=>c.peek().find(t=>t.slug===e);async function ie(){try{const e=await Ne(s.querySelector(".dm-loading-slot"),N("/collections",{method:"GET"}),Le.rows);if(!y())return;c.value=Array.isArray(e)?e:[],z.value="",await re()}catch(e){z.value=`Could not load the collections: ${e.message||e}`}finally{oe.value=!1}}async function re(){try{const e=await Te.listTags.load("collections");if(!y())return;k.value=e.tools,$.value=e.tags}catch{}}async function de(e,t){try{const n=await Te.listTags.changeItem("collections",e.slug,t);c.value=c.peek().map(d=>d.slug===e.slug?{...d,adminTags:n}:d);const o=n.filter(d=>!$.peek().some(q=>lt(q.name,d)));o.length&&($.value=[...$.peek(),...o.map(d=>({name:d}))])}catch(n){E.toast(`Tags not saved: ${n.message||n}`,{type:"error"})}}const Je=()=>at({kind:"collections",noun:"collections",title:"Collections settings - tags",tags:Y,tools:k,active:w,reload:async()=>{const e=await N("/collections",{method:"GET"});c.value=Array.isArray(e)?e:[],await re()}}),O=e=>{location.hash=e},_=e=>O(`#/collections/${encodeURIComponent(e)}/entries`);async function ze(e){const t=D(e.title||e.slug),n=e.plugin?`"${t}" belongs to the <strong>${D(e.plugin)}</strong> plugin - deleting it may stop that plugin working. Delete it and all ${Number(e.entryCount)||0} entries anyway?`:`Delete "${t}" and all ${Number(e.entryCount)||0} of its entries? This cannot be undone.`;if(await E.confirm(n))try{await N(`/collections/${encodeURIComponent(e.slug)}`,{method:"DELETE"}),E.toast(`Deleted "${e.title||e.slug}".`,{type:"success"}),De(Ae),y()&&await ie()}catch(o){E.toast(`Not deleted: ${o.message||o}`,{type:"error"})}}async function He(e){try{await navigator.clipboard.writeText(e.slug),E.toast(`Copied "${e.slug}".`,{type:"success",duration:2e3})}catch{E.toast(`The slug is ${e.slug}`,{type:"info"})}}const G=new Set;let x=null;function ue(e=null){const t=M.observable(e?.title??""),n=M.observable(!1),o=M.computed(()=>vt(t.value,c.value.map(r=>r.slug))),d={title:t,saving:n,slugText:M.computed(()=>o.value.slug?`Its slug will be "${o.value.slug}" - the address in the API and in shortcodes.`:""),error:M.computed(()=>o.value.error),cannot:M.computed(()=>n.value||!t.value.trim()||!!o.value.error),projectText:i.value?`It will be filed under the ${i.value} project.`:""},q=()=>!!t.peek().trim()&&!P,u=E.slideover({title:"New collection",size:"sm",position:"right"}),L=yt(`
20
21
  <div class="clx-form">
21
22
  <div>
22
23
  <label class="form-label" for="clx-new-title">Title <span class="text-danger">*</span>
@@ -33,4 +34,4 @@ import{apiRequest as C}from"../api.js";import{addBannerAction as Pe}from"../lib/
33
34
  <button type="button" class="btn btn-sm btn-primary" data-on-click="create" data-bind-disabled="cannot.value">
34
35
  <span data-icon="plus" data-icon-size="13"></span> Create</button>
35
36
  </div>
36
- </div>`);async function ve(){if(!pe.cannot.peek()){n.value=!0;try{const i={title:t.peek().trim(),...c.value&&c.value!=="core"&&{meta:{project:c.value}}},_=await C("/collections",{method:"POST",body:JSON.stringify(i)});D=!0,r.close(),we(Ee),R(`#/collections/edit/${encodeURIComponent(_.slug)}`)}catch(i){E.toast(`Not created: ${i.message||i}`,{type:"error"})}finally{n.value=!1}}}r.element.appendChild(k);const Be=he(k),Oe=M.applyBindings(pe,k,{methods:{create:ve,cancel:()=>r.close()}}),Ue=i=>{i.key==="Enter"&&i.target.id==="clx-new-title"&&(i.preventDefault(),ve())};k.addEventListener("keydown",Ue);const me={dirty:fe,values:()=>({title:t.peek()})};h=me,P.add(r),Fe(r,()=>{Oe.dispose(),Be(),P.delete(r),h===me&&(h=null)});const qe=r.close.bind(r);let D=!1,Y=!1;r.close=async i=>{if(!D&&i!==!0&&fe()){if(Y)return;Y=!0;const _=await E.confirm("Discard the collection you started?");if(Y=!1,!_)return}return D=!0,qe()},I.scan(k),r.open(),k.querySelector("#clx-new-title")?.focus()}const y=M.observable(!1),te=M.observable(!0),a=M.observable([]),g=M.observable(!1),f=M.observable("{}"),d=M.observable(""),F=M.observable(!1);let K="{}";const J=M.observable(0),H=M.computed(()=>{J.value,a.value,f.value,g.value;const e=g.peek()?j(f.peek()).config??f.peek():b(a.peek()).config;return JSON.stringify(e)!==K});async function Re(){try{const e=await be(l.querySelector(".clx-conn-loading"),C("/collections/connections",{method:"GET"}),{...ge.rows,count:2});if(!x())return;y.value=!0,K=JSON.stringify(b(T(e)).config),a.value=T(B??e),B&&(xe||E.toast("Your unsaved connection changes are back - Save to keep them.",{type:"info",duration:6e3}),B=null)}catch{y.value=!1}finally{te.value=!1}}let ne=!1;s.add(M.effect(()=>{const e=g.value;if(e!==ne){if(e)f.value=JSON.stringify(b(a.peek()).config,null,2),d.value="";else{const{error:t,config:n}=j(f.peek());if(t){d.value=`${t} Fix it before switching back.`,queueMicrotask(()=>{g.value=!0});return}a.value=T(n),d.value=""}ne=e}}));async function oe(){let e;if(g.peek()){const t=j(f.peek());if(t.error){d.value=t.error;return}e=t.config;const n=b(T(e));if(n.errors.length){d.value=n.errors.join(" ");return}}else{const t=b(a.peek());if(t.errors.length){d.value=t.errors.join(" ");return}e=t.config}F.value=!0;try{await C("/collections/connections",{method:"PUT",body:JSON.stringify(e)}),K=JSON.stringify(b(T(e)).config),J.value++,d.value="",E.toast("Connections saved. Collections already on MongoDB pick up a changed connection when the server restarts.",{type:"success",duration:6e3})}catch(t){d.value=`Not saved: ${t.message||t}`}finally{F.value=!1}}async function Ne(e){const t=a.peek().find(o=>o.id===e);if(!t)return;const n=p.peek().filter(o=>o.storage?.adapter==="mongodb"&&(o.storage.connection||"default")===t.name);n.length&&!await E.confirm(`${n.length} collection${n.length===1?" uses":"s use"} "${L(t.name)}" (${n.map(o=>L(o.slug)).join(", ")}). Remove it anyway? Nothing changes until you Save.`)||(a.value=a.peek().filter(o=>o.id!==e))}function De(e){const t=Te(e);if(!t)return[];const n=ke(t);return[{header:t.title||t.slug},{label:"Open entries",icon:"database",action:()=>q(t.slug)},{label:"Edit fields & settings",icon:"edit-3",action:()=>R(`#/collections/edit/${encodeURIComponent(t.slug)}`)},...n.hasForm?[{label:"Open its form",icon:"layout",action:()=>R(`#/forms/edit/${encodeURIComponent(t.slug)}`)}]:[],{type:"divider"},{label:"Copy slug",icon:"copy",action:()=>$e(t)},...n.canDelete?[{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>Le(t)}]:[]]}const w=l.querySelector(".clx-list");w.innerHTML=Ve;const u=l.querySelector(".clx-conns");u.innerHTML=We;const Ie=E.tabs(l.querySelector(".clx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),je=M.applyBindings({collections:p,loading:V,loadError:O,project:c,filter:m,query:X,rows:$,kinds:U,totalText:Me,emptyText:Ce,scopeText:Se,canConnect:y,connLoading:te,connRows:a,raw:g,rawText:f,connError:d,savingConn:F,connDirty:H},l,{methods:{showAll:()=>{m.value="all"},showOwn:()=>{m.value="own"},showBuiltin:()=>{m.value="builtin"},showPlugin:()=>{m.value="plugin"},addConnection:()=>{a.value=[...a.peek(),Ge(a.peek())]},saveConnections:oe}});s.add(()=>je.dispose()),s.add(he(l,{position:"bottom"})),s.add(M.effect(()=>{$.value,a.value,requestAnimationFrame(()=>{l.isConnected&&I.scan(l)})}));const ae=e=>{const t=e.target.dataset.f,n=a.peek().find(o=>o.id===e.target.closest("[data-id]")?.dataset.id);!t||!n||(n[t]=e.target.value,J.value++)},le=e=>{const t=e.target.closest('[data-act="remove"]');t&&Ne(t.closest("[data-id]")?.dataset.id)};u.addEventListener("input",ae),u.addEventListener("click",le),s.add(()=>{u.removeEventListener("input",ae),u.removeEventListener("click",le)});const se=e=>{e.target.dataset.f==="uri"&&(e.target.title="")},ie=e=>{e.target.dataset.f==="uri"&&(e.target.title=ze(e.target.value))};u.addEventListener("focusin",se),u.addEventListener("focusout",ie),s.add(()=>{u.removeEventListener("focusin",se),u.removeEventListener("focusout",ie)});const Ae=E.contextMenu(w,{cursor:"glyph",match:".clx-row",inherit:!1,density:"compact",items:e=>De(e.dataset.slug)});s.add(()=>Ae?.destroy?.());const ce=e=>{const t=e.target.closest(".clx-row");if(!t)return;const n=e.target.closest(".clx-kebab");if(n){ye(n);return}q(t.dataset.slug)},re=e=>{const t=e.target.closest(".clx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),ye(t)):e.key==="Enter"&&e.target===t&&q(t.dataset.slug))};w.addEventListener("click",ce),w.addEventListener("keydown",re),s.add(()=>{w.removeEventListener("click",ce),w.removeEventListener("keydown",re)});const de=e=>{(e.ctrlKey||e.metaKey)&&e.key==="s"&&Ie.getActive?.()===1&&y.peek()&&(e.preventDefault(),oe())};document.addEventListener("keydown",de),s.add(()=>document.removeEventListener("keydown",de)),Pe(v,{id:"collections-new",icon:"plus",title:"New collection",onClick:()=>ee()});const ue=e=>{(h?.dirty()||y.peek()&&H.peek())&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",ue),s.add(()=>window.removeEventListener("beforeunload",ue)),s.add(()=>{if(h?.dirty())try{S.set(A,{values:h.values(),project:c.peek(),at:new Date().toISOString()})}catch{}y.peek()&&H.peek()&&(B=g.peek()?j(f.peek()).config??null:b(a.peek()).config,xe=z.test(location.hash)),[...P].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(l),await Promise.all([Z(),Re()]),!x())return;let N=null;try{N=S.get(A)}catch{}if(N?.values?.title){try{S.remove?S.remove(A):S.set(A,null)}catch{}await E.confirm(`You started a collection called "${L(N.values.title)}" and left it. Pick up where you left off?`)&&x()&&ee(N.values)}}};
37
+ </div>`);async function xe(){if(!d.cannot.peek()){n.value=!0;try{const r={title:t.peek().trim(),...i.value&&i.value!=="core"&&{meta:{project:i.value}}},ee=await N("/collections",{method:"POST",body:JSON.stringify(r)});P=!0,u.close(),De(Ae),O(`#/collections/edit/${encodeURIComponent(ee.slug)}`)}catch(r){E.toast(`Not created: ${r.message||r}`,{type:"error"})}finally{n.value=!1}}}u.element.appendChild(L);const Xe=$e(L),Ze=M.applyBindings(d,L,{methods:{create:xe,cancel:()=>u.close()}}),et=r=>{r.key==="Enter"&&r.target.id==="clx-new-title"&&(r.preventDefault(),xe())};L.addEventListener("keydown",et);const Me={dirty:q,values:()=>({title:t.peek()})};x=Me,G.add(u),dt(u,()=>{Ze.dispose(),Xe(),G.delete(u),x===Me&&(x=null)});const tt=u.close.bind(u);let P=!1,Z=!1;u.close=async r=>{if(!P&&r!==!0&&q()){if(Z)return;Z=!0;const ee=await E.confirm("Discard the collection you started?");if(Z=!1,!ee)return}return P=!0,tt()},I.scan(L),u.open(),L.querySelector("#clx-new-title")?.focus()}const T=M.observable(!1),pe=M.observable(!0),a=M.observable([]),b=M.observable(!1),m=M.observable("{}"),p=M.observable(""),V=M.observable(!1);let W="{}";const Q=M.observable(0),X=M.computed(()=>{Q.value,a.value,m.value,b.value;const e=b.peek()?F(m.peek()).config??m.peek():h(a.peek()).config;return JSON.stringify(e)!==W});async function Ye(){try{const e=await Ne(s.querySelector(".clx-conn-loading"),N("/collections/connections",{method:"GET"}),{...Le.rows,count:2});if(!y())return;T.value=!0,W=JSON.stringify(h(R(e)).config),a.value=R(J??e),J&&(Be||E.toast("Your unsaved connection changes are back - Save to keep them.",{type:"info",duration:6e3}),J=null)}catch{T.value=!1}finally{pe.value=!1}}let ve=!1;l.add(M.effect(()=>{const e=b.value;if(e!==ve){if(e)m.value=JSON.stringify(h(a.peek()).config,null,2),p.value="";else{const{error:t,config:n}=F(m.peek());if(t){p.value=`${t} Fix it before switching back.`,queueMicrotask(()=>{b.value=!0});return}a.value=R(n),p.value=""}ve=e}}));async function ge(){let e;if(b.peek()){const t=F(m.peek());if(t.error){p.value=t.error;return}e=t.config;const n=h(R(e));if(n.errors.length){p.value=n.errors.join(" ");return}}else{const t=h(a.peek());if(t.errors.length){p.value=t.errors.join(" ");return}e=t.config}V.value=!0;try{await N("/collections/connections",{method:"PUT",body:JSON.stringify(e)}),W=JSON.stringify(h(R(e)).config),Q.value++,p.value="",E.toast("Connections saved. Collections already on MongoDB pick up a changed connection when the server restarts.",{type:"success",duration:6e3})}catch(t){p.value=`Not saved: ${t.message||t}`}finally{V.value=!1}}async function _e(e){const t=a.peek().find(o=>o.id===e);if(!t)return;const n=c.peek().filter(o=>o.storage?.adapter==="mongodb"&&(o.storage.connection||"default")===t.name);n.length&&!await E.confirm(`${n.length} collection${n.length===1?" uses":"s use"} "${D(t.name)}" (${n.map(o=>D(o.slug)).join(", ")}). Remove it anyway? Nothing changes until you Save.`)||(a.value=a.peek().filter(o=>o.id!==e))}function Ge(e){const t=Ke(e);if(!t)return[];const n=je(t);return[{header:t.title||t.slug},{label:"Open entries",icon:"database",action:()=>_(t.slug)},{label:"Edit fields & settings",icon:"edit-3",action:()=>O(`#/collections/edit/${encodeURIComponent(t.slug)}`)},...n.hasForm?[{label:"Open its form",icon:"layout",action:()=>O(`#/forms/edit/${encodeURIComponent(t.slug)}`)}]:[],{type:"divider"},{label:"Copy slug",icon:"copy",action:()=>He(t)},{type:"divider"},...it({all:ot(Y.peek()),current:rt(t),change:o=>de(t,o),newTag:async()=>{const o=await nt(Y.peek(),k.peek());o&&await de(t,{add:[o]})}}),...n.canDelete?[{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>ze(t)}]:[]]}const C=s.querySelector(".clx-list");C.innerHTML=bt;const v=s.querySelector(".clx-conns");v.innerHTML=ht;const Ve=E.tabs(s.querySelector(".clx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),We=M.applyBindings({collections:c,loading:oe,loadError:z,project:i,filter:f,query:H,rows:A,kinds:B,totalText:qe,emptyText:Pe,scopeText:Fe,tagNote:Ue,tagEmpty:ce,canConnect:T,connLoading:pe,connRows:a,raw:b,rawText:m,connError:p,savingConn:V,connDirty:X},s,{methods:{showAllTags:()=>{w.value=""},showAll:()=>{f.value="all"},showOwn:()=>{f.value="own"},showBuiltin:()=>{f.value="builtin"},showPlugin:()=>{f.value="plugin"},addConnection:()=>{a.value=[...a.peek(),mt(a.peek())]},saveConnections:ge}});l.add(()=>We.dispose()),l.add($e(s,{position:"bottom"})),l.add(M.effect(()=>{A.value,a.value,requestAnimationFrame(()=>{s.isConnected&&I.scan(s)})}));const fe=e=>{const t=e.target.dataset.f,n=a.peek().find(o=>o.id===e.target.closest("[data-id]")?.dataset.id);!t||!n||(n[t]=e.target.value,Q.value++)},me=e=>{const t=e.target.closest('[data-act="remove"]');t&&_e(t.closest("[data-id]")?.dataset.id)};v.addEventListener("input",fe),v.addEventListener("click",me),l.add(()=>{v.removeEventListener("input",fe),v.removeEventListener("click",me)});const be=e=>{e.target.dataset.f==="uri"&&(e.target.title="")},he=e=>{e.target.dataset.f==="uri"&&(e.target.title=ft(e.target.value))};v.addEventListener("focusin",be),v.addEventListener("focusout",he),l.add(()=>{v.removeEventListener("focusin",be),v.removeEventListener("focusout",he)});const Qe=E.contextMenu(C,{cursor:"glyph",match:".clx-row",inherit:!1,density:"compact",items:e=>Ge(e.dataset.slug)});l.add(()=>Qe?.destroy?.());const ye=e=>{const t=e.target.closest(".clx-row");if(!t)return;const n=e.target.closest(".clx-kebab");if(n){Re(n);return}_(t.dataset.slug)},we=e=>{const t=e.target.closest(".clx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),Re(t)):e.key==="Enter"&&e.target===t&&_(t.dataset.slug))};C.addEventListener("click",ye),C.addEventListener("keydown",we),l.add(()=>{C.removeEventListener("click",ye),C.removeEventListener("keydown",we)});const ke=e=>{(e.ctrlKey||e.metaKey)&&e.key==="s"&&Ve.getActive?.()===1&&T.peek()&&(e.preventDefault(),ge())};document.addEventListener("keydown",ke),l.add(()=>document.removeEventListener("keydown",ke)),Se(g,{id:"collections-settings",icon:"settings",title:"Collections settings - tags",onClick:Je}),Se(g,{id:"collections-new",icon:"plus",title:"New collection",onClick:()=>ue()});const Ee=e=>{(x?.dirty()||T.peek()&&X.peek())&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",Ee),l.add(()=>window.removeEventListener("beforeunload",Ee)),l.add(()=>{if(x?.dirty())try{S.set(K,{values:x.values(),project:i.peek(),at:new Date().toISOString()})}catch{}T.peek()&&X.peek()&&(J=b.peek()?F(m.peek()).config??null:h(a.peek()).config,Be=te.test(location.hash)),[...G].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(s),await Promise.all([ie(),Ye()]),!y())return;let U=null;try{U=S.get(K)}catch{}if(U?.values?.title){try{S.remove?S.remove(K):S.set(K,null)}catch{}await E.confirm(`You started a collection called "${D(U.values.title)}" and left it. Pick up where you left off?`)&&y()&&ue(U.values)}}};
@@ -124,7 +124,7 @@ The quick brown fox - 0O 1lI {} [] () =&gt; ==
124
124
  .pe-new [hidden] { display: none !important; }
125
125
  .pe-new-err { display: block; margin-top: .3rem; color: var(--dm-danger); font-size: var(--dm-text-xs); }
126
126
  .pe-new-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
127
- </style>`;function fs({kind:d,projects:b,taken:v,project:l="",name:k="",check:u,create:w,register:h=()=>{}}){return new Promise(P=>{const I=E.slideover({title:d==="block"?"New block":"New component",size:"sm",position:"right"});h(()=>{try{I.close()}catch{}});const i=bt(`<div>${$r}</div>`);for(const D of b)i.querySelector("#pe-new-project").append(new Option(D.name||D.slug,D.slug));const A={name:M.observable(k),project:M.observable(l),busy:M.observable(!1),hint:M.observable(d==="block"?"A block is a reusable piece of HTML with {{placeholders}}, used on pages with its short tag or by a collection display. Its name is its tag - fixed once created.":"A component is a custom element - <dm-name> - with a template, props, a script and a style. Its name is its tag - fixed once created."),placeholder:M.observable(d==="block"?"e.g. team-card":"e.g. pricing-table")};A.error=M.computed(()=>A.name.value.trim()?u(A.name.value.trim(),v):""),A.canCreate=M.computed(()=>!A.busy.value&&!!A.name.value.trim()&&!u(A.name.value.trim(),v));let q="";A.create=async()=>{const D=A.name.peek().trim();if(!(!D||A.error.peek()||A.busy.peek())){A.busy.value=!0;try{await w(D,A.project.peek()),q=D,I.close()}catch(ne){E.toast(`Not created: ${ne.message||ne}`,{type:"error"})}finally{A.busy.value=!1}}},A.cancel=()=>I.close(),A.key=D=>{D.key==="Enter"&&(D.preventDefault(),A.create())};const G=M.applyBindings(A,i);Ht(I,()=>{G.dispose(),P(q)}),I.element.appendChild(i),i.querySelector("#pe-new-project").value=l,I.open(),setTimeout(()=>{const D=i.querySelector("#pe-new-name");D?.focus(),D?.select()},100)})}let F=null,bs=!1;function Lr(){bs||!window.R?.use||(bs=!0,_n(),R.use((d,b,v)=>{if(F&&!F.alive()){const u=F;F=null,u.dispose()}const l=b?.path||"",k=d?.path||"";if(!F||!$a.test(l))return v();if($a.test(k)){const u=Zo(k);if(u){F.open(u,k);return}return v()}return F.dirty()?E.confirm("You have unsaved changes. Leave anyway? They are kept as drafts for your next visit.").then(u=>{u?(F?.keepDraft(),v()):F&&history.replaceState({pe:1},"","#"+F.address)}):v()}),M.subscribe("router:afterChange",({to:d}={})=>{if(F&&!$a.test(d?.path||"")){const b=F;F=null,b.dispose()}}))}const vs="editor_prefs";function Pe(){return S.get(vs)||{viewMode:"split",fullscreen:!1}}let Nr=null;const Dr=()=>Nr??(Nr=g.pages.dommaCatalogue().then(d=>(Pn(d),xn()))),Ir=d=>{try{return document.createDocumentFragment().querySelector(d),!0}catch{return!1}},Br=()=>{try{return Pe()||{}}catch{return{}}};function Ue(d,b){const v=Pe();v[d]=b,S.set(vs,v)}const gs="editor-workspace.tabs",hs="editor-workspace.folded",vt="editor-workspace.css",jr="/__block-preview",Fr=d=>d.replace(/<\/head>/i,"<style>body.dm-cloaked{opacity:1 !important;transition:none !important}</style></head>");function zr(d,b,v=()=>{}){let l=0;try{l=d.contentWindow.scrollY||0}catch{}d.addEventListener("load",()=>{try{d.contentWindow.scrollTo(0,l)}catch{}v()},{once:!0}),d.srcdoc=b}const qr=["urlPath","title","description","layout","status","sortOrder","category","visibility","project","theme","seoTitle","seoDesc","seoSchema","dconfig"],Hr=["showInNav","sidebar","breadcrumbs","bundled"],ys=()=>({urlPath:"",title:"",description:"",layout:"",status:"draft",sortOrder:"99",showInNav:!1,sidebar:!1,breadcrumbs:!0,bundled:!1,tags:[],adminTags:[],category:"",visibility:"public",project:"",theme:"",seoTitle:"",seoDesc:"",seoSchema:"",dconfig:"",body:"",css:null});export const pageEditorView={templateUrl:"/admin/js/templates/page-editor.html",async onMount(d){if(Lr(),F){const e=F;F=null,e.dispose()}const b=window.location.hash.replace(/^#/,""),v=[],l=e=>(v.push(e),e);let k=()=>!1,u=()=>{},w=()=>{};const h=d.get(0),P=h.querySelector("#pe-workspace"),I={address:b,alive:()=>P?.isConnected===!0,dirty:()=>k(),keepDraft:()=>u(),open:(e,t)=>w(e,t),dispose:()=>{v.splice(0).forEach(e=>{try{e()}catch{}})}};F=I;const i=()=>F===I&&I.alive();if(Br().closeSidebar===!0){const e=document.querySelector("#admin-sidebar");e&&!Qo(e)&&!window.matchMedia("(max-width: 768px)").matches&&(es(e,!0,!1),l(()=>{e.isConnected&&Qo(e)&&es(e,!1,!1)}))}const A=E.loader(h,{type:"dots"});let[q,G,D,ne,gt,Yt,ht,T]=await Promise.all([g.layouts.get().catch(()=>({})),g.settings.get().catch(()=>({})),g.pages.list().catch(()=>[]),g.projects.list().catch(()=>[]),g.pages.tags().catch(()=>[]),g.listTags.list("pages").then(e=>e.map(t=>t.name)).catch(()=>[]),g.get("/blocks?usage=1").catch(()=>g.blocks.list()).catch(()=>[]),g.components.list().catch(()=>[])]);if(!i()){A.destroy();return}A.destroy();const C=e=>h.querySelector(e);if(D=Array.isArray(D)?D:[],hn(C("#field-theme"),{includeDefault:!0}),await Jr(C("#field-visibility")),!i())return;const me=Object.keys(q||{});Kr(C("#field-layout"),q,me[0]||"default");const Ve=e=>me.includes(e)?e:me[0]||e||"default";for(const e of ne)for(const t of["#field-project","#block-project","#comp-project"])C(t).append(new Option(e.name||e.slug,e.slug));let U=Array.isArray(ht)?ht:[],fe=ts(U);const yt=new Map(U.map(e=>[e.name,e.updatedAt])),Ke=new Map(U.map(e=>[e.name,e.usage])),be=new Set(U.map(e=>e.name)),Va=async()=>{const e=await g.get("/blocks?usage=1").catch(()=>null);if(!(!i()||!Array.isArray(e))){U=e,fe=ts(U);for(const t of U)be.add(t.name),Ke.set(t.name,t.usage),yt.has(t.name)||yt.set(t.name,t.updatedAt)}},Gt=Array.isArray(G?.footer?.blocks)?G.footer.blocks.filter(e=>typeof e=="string"):[];let Je=Array.isArray(T)?T.filter(e=>typeof e?.name=="string"):[];const re=new Set(Je.map(e=>e.name)),Ka=async()=>{const e=await g.components.list().catch(()=>null);if(!(!i()||!Array.isArray(e))){Je=e.filter(t=>typeof t?.name=="string");for(const t of Je)re.add(t.name)}},Q=Pe(),p={urlPath:M.observable(""),title:M.observable(""),description:M.observable(""),layout:M.observable(Ve("default")),status:M.observable("draft"),sortOrder:M.observable("99"),showInNav:M.observable(!1),sidebar:M.observable(!1),breadcrumbs:M.observable(!0),bundled:M.observable(!1),tags:M.observable([]),adminTags:M.observable([]),category:M.observable(""),visibility:M.observable("public"),project:M.observable(""),theme:M.observable(""),seoTitle:M.observable(""),seoDesc:M.observable(""),seoSchema:M.observable(""),dconfig:M.observable(""),css:M.observable(""),cssOpened:M.observable(!1)},a={bodyRev:M.observable(0),base:M.observable(""),saving:M.observable(!1),viewMode:M.observable(Fa(Q.viewMode)),fullscreen:M.observable(!!Q.fullscreen),explorerOn:M.observable(Q.explorer??!window.matchMedia("(max-width: 1024px)").matches),dockOn:M.observable(!!Q.dock),dockTab:M.observable("details"),seoSchemaNote:M.observable(""),catalogue:M.observable(null),cssMode:M.observable(!1),folded:M.observable(!1),previewStatus:M.observable("Showing unsaved changes"),liveWidth:M.observable("full"),versions:M.observable([]),histLoading:M.observable(!1),histError:M.observable(""),compare:M.observable(null),imageHosts:M.observable([]),imagePolicyReady:M.observable(!1),imageCanAllow:M.observable(!1),imageError:M.observable(""),imageScanning:M.observable(!1),imageAllowing:M.observable(""),imageScanned:M.observable(!1),imageReload:M.observable(!1),imageBlocked:M.observable(0),heldNote:M.observable(""),tabs:M.observable([]),active:M.observable(""),curId:M.observable(null),blockTab:M.observable(""),blockPart:M.observable("html"),blockReady:M.observable(!1),blockNote:M.observable(""),blockUses:M.observable(""),blockProject:M.observable(""),blockBundled:M.observable(!1),blockWhere:M.observable(""),compTab:M.observable(""),compPart:M.observable("template"),compReady:M.observable(!1),compNote:M.observable(""),compReadOnly:M.observable(!1),compState:M.observable(""),compErrors:M.observable(""),compProject:M.observable(""),compBundled:M.observable(!1),blockRev:M.observable(0),compRev:M.observable(0),docRev:M.observable(0),filter:M.observable(""),secHere:M.observable(Q.secHere!==!1),secPages:M.observable(Q.secPages!==!1),secBlocks:M.observable(Q.secBlocks!==!1),secComps:M.observable(Q.secComps!==!1),thisPage:M.observable([]),pageRows:M.observable([]),blockRows:M.observable([]),compRows:M.observable([])},_=C("#markdown-editor"),ve=C("#css-editor"),ks=Go(_),ws=Go(ve);l(()=>ks.destroy()),l(()=>ws.destroy());const le=document.createElement("div");le.className="editor-line-numbers editor-line-numbers--foldable",_.parentElement.insertBefore(le,_);const We=ps(_,"md"),Xt=ps(ve,"css");l(()=>{We.destroy(),Xt.destroy()});const Ja=()=>{We.paint(),Xt.paint()},ee=yn(_,le,{onFoldChange:()=>We.paint()});let kt=!1;ee.setGuard(e=>{kt=e});const wt=()=>ee.getUnfoldedContent(),Zt=()=>{ee.unfoldAll(),a.folded.value=!1,We.paint()},Ss=e=>{if(e?.kind==="page")Zt(),_e(_,"md");else if(e?.kind==="block")oe&&_e(oe.textarea,"html"),pe&&_e(pe.textarea,"css");else if(e?.kind==="component"){if(N.get(e.id)?.readOnly)return;for(const[o,s]of Object.entries({template:"html",props:"json",script:"js",style:"css"}))se[o]&&_e(se[o].textarea,s)}},Wa=e=>{e.error?E.toast(e.error,{type:"warning"}):E.toast(e.unchanged?"Already tidy":"Formatted",{type:"info",duration:900})},Ya=M.observable(_t(Q.type)),Ga=M.observable(Jt(Q.code));l(M.effect(()=>{const e=Ga.value;Er(e),C("#editor-body")?.style.setProperty("--pe-tab",String(e.size))})),l(M.effect(()=>{const e=Ya.value,t=C("#editor-body");if(t){ms(e.font);for(const[o,s]of Object.entries(Yo(e)))t.style.setProperty(o,s);t.classList.toggle("pe-nowrap",!e.wrap),_.wrap=e.wrap?"soft":"off",ve.wrap=e.wrap?"soft":"off",requestAnimationFrame(()=>{i()&&Ja()})}}));let Xa=null;l(()=>{try{Xa?.close()}catch{}});const V=()=>(a.bodyRev.value,{urlPath:p.urlPath.value.trim(),title:p.title.value,description:p.description.value,layout:p.layout.value,status:p.status.value,sortOrder:p.sortOrder.value,showInNav:p.showInNav.value,sidebar:p.sidebar.value,breadcrumbs:p.breadcrumbs.value,bundled:p.bundled.value,tags:p.tags.value,adminTags:p.adminTags.value,category:p.category.value,visibility:p.visibility.value,project:p.project.value,theme:p.theme.value,seoTitle:p.seoTitle.value,seoDesc:p.seoDesc.value,seoSchema:p.seoSchema.value,dconfig:p.dconfig.value,body:wt(),css:null}),Za=()=>M.untracked?M.untracked(V):V(),te=M.observable(""),St=()=>p.cssOpened.peek()&&p.css.peek()!==te.peek(),K=new Map;let m=null;const L=new Map,N=new Map;let O=[];const ie=e=>ja(e.form)!==e.base,ge=()=>[...L.entries()].filter(([,e])=>ie(e)).map(([e])=>e),he=e=>!e.readOnly&&Ha({name:e.name,...e.form})!==e.base,Ye=()=>[...N.values()].filter(he).map(e=>e.name),Qt=()=>Y(Za())!==a.base.peek(),ea=e=>e.loaded&&(e===m?Qt():Y(e.state)!==e.base),Oe=()=>[...K.values()].filter(ea),Ms=M.computed(()=>Y(V())!==a.base.value),Es=M.computed(()=>p.cssOpened.value&&p.css.value!==te.value),Ts=M.computed(()=>(a.blockRev.value,a.compRev.value,a.docRev.value,Y(V())!==a.base.value||p.cssOpened.value&&p.css.value!==te.value||Oe().some(e=>e!==m)||ge().length>0||Ye().length>0)),Cs=M.computed(()=>{a.blockRev.value,a.compRev.value;const e=j(a.active.value);if(e?.kind==="block"){const t=L.get(e.id);return!!(t&&ie(t))}if(e?.kind==="component"){const t=N.get(e.id);return!!(t&&he(t))}return Y(V())!==a.base.value||p.cssOpened.value&&p.css.value!==te.value}),xs=M.computed(()=>a.curId.value!==null),Qa=M.computed(()=>j(a.active.value)?.kind||""),eo=M.computed(()=>!!a.curId.value&&j(a.active.value)?.kind==="page"),Ps=M.computed(()=>p.urlPath.value.trim()||a.curId.value||""),Os=M.computed(()=>La({urlPath:p.urlPath.value,dconfig:p.dconfig.value})[0]?.text||""),Rs=M.computed(()=>(a.bodyRev.value,a.catalogue.value?Cn({dconfig:p.dconfig.value,body:wt()},a.catalogue.value,{isSelector:Ir}).map((e,t)=>({key:`${t}:${e}`,text:e})):[]));Dr().then(e=>{a.catalogue.value=e});const As=M.computed(()=>{a.docRev.value;const e=j(a.active.value);return e?e.kind==="block"?a.blockUses.value:e.kind==="component"?rr({name:e.id,readOnly:a.compReadOnly.value,state:a.compReady.value?a.compState.value:""}):pr({urlPath:p.urlPath.value,status:p.status.value,isEdit:!!a.curId.value}):""}),to=M.computed(()=>a.compTab.value?"component":a.blockTab.value?"block":a.curId.value!==null?"page":""),$s=M.computed(()=>a.blockTab.value?`[${a.blockTab.value} /]`:""),Ls=M.computed(()=>({compiling:"Compiling\u2026",ok:"Compiles",error:"Does not compile"})[a.compState.value]||""),Ns=M.computed(()=>a.compTab.value?`<dm-${a.compTab.value}>`:""),Ds=M.computed(()=>a.versions.value.some(e=>e.checked.value)),Is=M.computed(()=>a.versions.value.length>0&&a.versions.value.every(e=>e.checked.value)),Bs=M.computed(()=>{const e=a.versions.value.filter(t=>t.checked.value).length;return e>0&&e<a.versions.value.length});k=()=>Oe().length>0||ge().length>0||Ye().length>0||St();const Mt=(e,t,o)=>({title:String(e.title||"").trim()||"Untitled",description:String(e.description||"").trim(),layout:e.layout,status:e.status,sortOrder:parseInt(String(e.sortOrder),10)||99,showInNav:!!e.showInNav,sidebar:!!e.sidebar,...e.breadcrumbs?{}:{breadcrumbs:!1},...e.bundled?{bundled:!0}:{},tags:Array.isArray(e.tags)?e.tags:[],...t?.isEdit&&JSON.stringify(e.adminTags)===t.savedAdminTags?{}:{adminTags:Array.isArray(e.adminTags)?e.adminTags:[]},category:String(e.category||"").trim()||null,visibility:e.visibility||"public",project:e.project||"",seo:{title:String(e.seoTitle||"").trim(),description:String(e.seoDesc||"").trim(),...ao(e)?{schema:ao(e)}:t?.isEdit?{schema:null}:{}},dconfig:o,...e.theme?{theme:e.theme}:{}}),ao=e=>Aa(e.seoSchema).value,Et=e=>{const t=String(e.dconfig||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}},oo=()=>p.urlPath.peek().trim()||m?.id||"/";let Tt=[],so=[];const Ct=e=>Tt.includes(e)||Gt.includes(e);let Re=new Set;const Ge=()=>{const e=[...new Set([...Tt,...Gt,...L.keys()])],t=Hn(e.filter(s=>!L.has(s)),yt);Re=new Set(Object.keys(t));const o=Re.size?`Preview shows unsaved changes to ${[...Re].join(", ")}`:"";return o!==a.heldNote.peek()&&(a.heldNote.value=o),Zn(t,[...L.entries()].map(([s,r])=>({name:s,content:r.form.content,css:r.form.css,dirty:ie(r)})))};let ta="";const js=()=>{ro();const e=ta;if(e){ta="";try{Ae.contentDocument?.querySelector(`[data-block="${CSS.escape(e)}"]`)?.scrollIntoView({block:"center"})}catch{}}};let aa=[],Xe="";const xt=e=>{Xe=e;const t=new DOMParser().parseFromString(e,"text/html");if(p.cssOpened.peek()){const o=t.createElement("style");o.textContent=p.css.peek(),t.head.appendChild(o)}a.imageHosts.value=zn(qn(t),window.location.origin,aa),a.imageBlocked.value=a.imageHosts.peek().filter(o=>!o.allowed).length,a.imageScanned.value=!0};l(M.effect(()=>{a.curId.value,a.blockTab.value,a.compTab.value,Xe="",a.imageHosts.value=[],a.imageScanned.value=!1,a.imageBlocked.value=0}));const no=async()=>{const e=await g.get("/pages/_image-hosts");i()&&(aa=e.hosts,a.imageCanAllow.value=e.canAllow,a.imagePolicyReady.value=!0,Xe&&xt(Xe))};no().catch(e=>{i()&&(a.imageError.value="Could not read image permissions: "+e.message)});const Fs=async()=>{const e=m;a.imageScanning.value=!0,a.imageError.value="";try{if(await no(),!m)throw new Error("Open a page to scan its images.");const t=V(),{html:o}=await g.pages.previewFull(oo(),Mt(t,m,Et(t)),t.body,Ge());i()&&m===e&&xt(o)}catch(t){i()&&(a.imageError.value="Could not scan images: "+t.message)}finally{i()&&(a.imageScanning.value=!1)}},zs=async e=>{if(!a.imageAllowing.peek()){a.imageAllowing.value=e,a.imageError.value="";try{const{hosts:t}=await g.post("/pages/_image-hosts",{host:e});if(!i())return;aa=t,xt(Xe),a.imageReload.value=!0,E.toast("Images from "+e+" are now allowed site-wide.",{type:"success"})}catch(t){i()&&(a.imageError.value="Could not allow images: "+t.message)}finally{i()&&(a.imageAllowing.value="")}}},Ae=C("#markdown-preview");g.settings.getCustomCss().then(({css:e})=>{if(!i())return;te.value=e||"";let t=null;try{t=S.get(vt)}catch{}typeof t=="string"&&t!==te.peek()?(uo(),p.css.value=t,E.toast("Your unsaved custom CSS is back - the CSS button shows it.",{type:"info"})):p.cssOpened.peek()||(p.css.value=te.peek()),W(vt)}).catch(()=>{});const ro=()=>{const e=Ae?.contentDocument;if(!e?.head)return;const t=p.cssOpened.peek()?p.css.peek():"";if(!t)return;let o=e.getElementById("preview-custom-css");o||(o=e.createElement("style"),o.id="preview-custom-css",e.head.appendChild(o)),o.textContent=t};let oa=null,sa=0;const J=(e=!1)=>{clearTimeout(oa),oa=setTimeout(async()=>{if(!Ae||a.viewMode.peek()==="write"||!a.active.peek()||a.compTab.peek())return;const t=++sa,o=a.blockTab.peek();a.previewStatus.value="Rendering\u2026";try{let s;if(o&&(!m||!Ct(o)))({html:s}=await g.pages.previewFull(jr,{title:o,layout:"blank",breadcrumbs:!1},ar(o,Xs(o)),Ge()));else if(m){const r=V();({html:s}=await g.pages.previewFull(oo(),Mt(r,m,Et(r)),r.body,Ge()))}else{Ae.srcdoc="";return}if(!i()||t!==sa)return;xt(s),zr(Ae,Xn(Fr(s),o),js),a.previewStatus.value="Showing unsaved changes"}catch(s){if(!i()||t!==sa)return;a.previewStatus.value="Preview failed - "+(s?.message||"unknown error"),Ae.srcdoc='<!doctype html><meta charset="utf-8"><body style="font:14px system-ui;padding:1rem;color:#b91c1c;">Preview failed: '+String(s?.message||"unknown error").replace(/[<&]/g,r=>r==="<"?"&lt;":"&amp;")+"</body>"}},e?0:500)};l(()=>clearTimeout(oa));const na=un(d.find("#markdown-editor"),d.find("#editor-toolbar"),{spacerDefault:G?.layoutOptions?.spacerSize??40,beforeFormat:()=>Zt()});fn(_,{blocks:()=>fe,openBlock:e=>Ie(e)});const Ze=h.querySelector(".editor-toolbar-right");Ze.querySelectorAll(".editor-view-btn[data-mode]").forEach(e=>{const t=e.getAttribute("data-mode");e.classList.remove("active"),e.setAttribute("data-bind-class",`viewMode.value === '${t}' && 'active'`),e.setAttribute("data-on-click",`setMode('${t}')`)}),C("#fullscreen-btn")?.setAttribute("data-on-click","toggleFullscreen");const qs=bt(`
127
+ </style>`;function fs({kind:d,projects:b,taken:v,project:l="",name:k="",check:u,create:w,register:h=()=>{}}){return new Promise(P=>{const I=E.slideover({title:d==="block"?"New block":"New component",size:"sm",position:"right"});h(()=>{try{I.close()}catch{}});const i=bt(`<div>${$r}</div>`);for(const D of b)i.querySelector("#pe-new-project").append(new Option(D.name||D.slug,D.slug));const A={name:M.observable(k),project:M.observable(l),busy:M.observable(!1),hint:M.observable(d==="block"?"A block is a reusable piece of HTML with {{placeholders}}, used on pages with its short tag or by a collection display. Its name is its tag - fixed once created.":"A component is a custom element - <dm-name> - with a template, props, a script and a style. Its name is its tag - fixed once created."),placeholder:M.observable(d==="block"?"e.g. team-card":"e.g. pricing-table")};A.error=M.computed(()=>A.name.value.trim()?u(A.name.value.trim(),v):""),A.canCreate=M.computed(()=>!A.busy.value&&!!A.name.value.trim()&&!u(A.name.value.trim(),v));let q="";A.create=async()=>{const D=A.name.peek().trim();if(!(!D||A.error.peek()||A.busy.peek())){A.busy.value=!0;try{await w(D,A.project.peek()),q=D,I.close()}catch(ne){E.toast(`Not created: ${ne.message||ne}`,{type:"error"})}finally{A.busy.value=!1}}},A.cancel=()=>I.close(),A.key=D=>{D.key==="Enter"&&(D.preventDefault(),A.create())};const G=M.applyBindings(A,i);Ht(I,()=>{G.dispose(),P(q)}),I.element.appendChild(i),i.querySelector("#pe-new-project").value=l,I.open(),setTimeout(()=>{const D=i.querySelector("#pe-new-name");D?.focus(),D?.select()},100)})}let F=null,bs=!1;function Lr(){bs||!window.R?.use||(bs=!0,_n(),R.use((d,b,v)=>{if(F&&!F.alive()){const u=F;F=null,u.dispose()}const l=b?.path||"",k=d?.path||"";if(!F||!$a.test(l))return v();if($a.test(k)){const u=Zo(k);if(u){F.open(u,k);return}return v()}return F.dirty()?E.confirm("You have unsaved changes. Leave anyway? They are kept as drafts for your next visit.").then(u=>{u?(F?.keepDraft(),v()):F&&history.replaceState({pe:1},"","#"+F.address)}):v()}),M.subscribe("router:afterChange",({to:d}={})=>{if(F&&!$a.test(d?.path||"")){const b=F;F=null,b.dispose()}}))}const vs="editor_prefs";function Pe(){return S.get(vs)||{viewMode:"split",fullscreen:!1}}let Nr=null;const Dr=()=>Nr??(Nr=g.pages.dommaCatalogue().then(d=>(Pn(d),xn()))),Ir=d=>{try{return document.createDocumentFragment().querySelector(d),!0}catch{return!1}},Br=()=>{try{return Pe()||{}}catch{return{}}};function Ue(d,b){const v=Pe();v[d]=b,S.set(vs,v)}const gs="editor-workspace.tabs",hs="editor-workspace.folded",vt="editor-workspace.css",jr="/__block-preview",Fr=d=>d.replace(/<\/head>/i,"<style>body.dm-cloaked{opacity:1 !important;transition:none !important}</style></head>");function zr(d,b,v=()=>{}){let l=0;try{l=d.contentWindow.scrollY||0}catch{}d.addEventListener("load",()=>{try{d.contentWindow.scrollTo(0,l)}catch{}v()},{once:!0}),d.srcdoc=b}const qr=["urlPath","title","description","layout","status","sortOrder","category","visibility","project","theme","seoTitle","seoDesc","seoSchema","dconfig"],Hr=["showInNav","sidebar","breadcrumbs","bundled"],ys=()=>({urlPath:"",title:"",description:"",layout:"",status:"draft",sortOrder:"99",showInNav:!1,sidebar:!1,breadcrumbs:!0,bundled:!1,tags:[],adminTags:[],category:"",visibility:"public",project:"",theme:"",seoTitle:"",seoDesc:"",seoSchema:"",dconfig:"",body:"",css:null});export const pageEditorView={templateUrl:"/admin/js/templates/page-editor.html",async onMount(d){if(Lr(),F){const e=F;F=null,e.dispose()}const b=window.location.hash.replace(/^#/,""),v=[],l=e=>(v.push(e),e);let k=()=>!1,u=()=>{},w=()=>{};const h=d.get(0),P=h.querySelector("#pe-workspace"),I={address:b,alive:()=>P?.isConnected===!0,dirty:()=>k(),keepDraft:()=>u(),open:(e,t)=>w(e,t),dispose:()=>{v.splice(0).forEach(e=>{try{e()}catch{}})}};F=I;const i=()=>F===I&&I.alive();if(Br().closeSidebar===!0){const e=document.querySelector("#admin-sidebar");e&&!Qo(e)&&!window.matchMedia("(max-width: 768px)").matches&&(es(e,!0,!1),l(()=>{e.isConnected&&Qo(e)&&es(e,!1,!1)}))}const A=E.loader(h,{type:"dots"});let[q,G,D,ne,gt,Yt,ht,T]=await Promise.all([g.layouts.get().catch(()=>({})),g.settings.get().catch(()=>({})),g.pages.list().catch(()=>[]),g.projects.list().catch(()=>[]),g.pages.tags().catch(()=>[]),g.listTags.list("pages").then(e=>e.filter(t=>!t.tool).map(t=>t.name)).catch(()=>[]),g.get("/blocks?usage=1").catch(()=>g.blocks.list()).catch(()=>[]),g.components.list().catch(()=>[])]);if(!i()){A.destroy();return}A.destroy();const C=e=>h.querySelector(e);if(D=Array.isArray(D)?D:[],hn(C("#field-theme"),{includeDefault:!0}),await Jr(C("#field-visibility")),!i())return;const me=Object.keys(q||{});Kr(C("#field-layout"),q,me[0]||"default");const Ve=e=>me.includes(e)?e:me[0]||e||"default";for(const e of ne)for(const t of["#field-project","#block-project","#comp-project"])C(t).append(new Option(e.name||e.slug,e.slug));let U=Array.isArray(ht)?ht:[],fe=ts(U);const yt=new Map(U.map(e=>[e.name,e.updatedAt])),Ke=new Map(U.map(e=>[e.name,e.usage])),be=new Set(U.map(e=>e.name)),Va=async()=>{const e=await g.get("/blocks?usage=1").catch(()=>null);if(!(!i()||!Array.isArray(e))){U=e,fe=ts(U);for(const t of U)be.add(t.name),Ke.set(t.name,t.usage),yt.has(t.name)||yt.set(t.name,t.updatedAt)}},Gt=Array.isArray(G?.footer?.blocks)?G.footer.blocks.filter(e=>typeof e=="string"):[];let Je=Array.isArray(T)?T.filter(e=>typeof e?.name=="string"):[];const re=new Set(Je.map(e=>e.name)),Ka=async()=>{const e=await g.components.list().catch(()=>null);if(!(!i()||!Array.isArray(e))){Je=e.filter(t=>typeof t?.name=="string");for(const t of Je)re.add(t.name)}},Q=Pe(),p={urlPath:M.observable(""),title:M.observable(""),description:M.observable(""),layout:M.observable(Ve("default")),status:M.observable("draft"),sortOrder:M.observable("99"),showInNav:M.observable(!1),sidebar:M.observable(!1),breadcrumbs:M.observable(!0),bundled:M.observable(!1),tags:M.observable([]),adminTags:M.observable([]),category:M.observable(""),visibility:M.observable("public"),project:M.observable(""),theme:M.observable(""),seoTitle:M.observable(""),seoDesc:M.observable(""),seoSchema:M.observable(""),dconfig:M.observable(""),css:M.observable(""),cssOpened:M.observable(!1)},a={bodyRev:M.observable(0),base:M.observable(""),saving:M.observable(!1),viewMode:M.observable(Fa(Q.viewMode)),fullscreen:M.observable(!!Q.fullscreen),explorerOn:M.observable(Q.explorer??!window.matchMedia("(max-width: 1024px)").matches),dockOn:M.observable(!!Q.dock),dockTab:M.observable("details"),seoSchemaNote:M.observable(""),catalogue:M.observable(null),cssMode:M.observable(!1),folded:M.observable(!1),previewStatus:M.observable("Showing unsaved changes"),liveWidth:M.observable("full"),versions:M.observable([]),histLoading:M.observable(!1),histError:M.observable(""),compare:M.observable(null),imageHosts:M.observable([]),imagePolicyReady:M.observable(!1),imageCanAllow:M.observable(!1),imageError:M.observable(""),imageScanning:M.observable(!1),imageAllowing:M.observable(""),imageScanned:M.observable(!1),imageReload:M.observable(!1),imageBlocked:M.observable(0),heldNote:M.observable(""),tabs:M.observable([]),active:M.observable(""),curId:M.observable(null),blockTab:M.observable(""),blockPart:M.observable("html"),blockReady:M.observable(!1),blockNote:M.observable(""),blockUses:M.observable(""),blockProject:M.observable(""),blockBundled:M.observable(!1),blockWhere:M.observable(""),compTab:M.observable(""),compPart:M.observable("template"),compReady:M.observable(!1),compNote:M.observable(""),compReadOnly:M.observable(!1),compState:M.observable(""),compErrors:M.observable(""),compProject:M.observable(""),compBundled:M.observable(!1),blockRev:M.observable(0),compRev:M.observable(0),docRev:M.observable(0),filter:M.observable(""),secHere:M.observable(Q.secHere!==!1),secPages:M.observable(Q.secPages!==!1),secBlocks:M.observable(Q.secBlocks!==!1),secComps:M.observable(Q.secComps!==!1),thisPage:M.observable([]),pageRows:M.observable([]),blockRows:M.observable([]),compRows:M.observable([])},_=C("#markdown-editor"),ve=C("#css-editor"),ks=Go(_),ws=Go(ve);l(()=>ks.destroy()),l(()=>ws.destroy());const le=document.createElement("div");le.className="editor-line-numbers editor-line-numbers--foldable",_.parentElement.insertBefore(le,_);const We=ps(_,"md"),Xt=ps(ve,"css");l(()=>{We.destroy(),Xt.destroy()});const Ja=()=>{We.paint(),Xt.paint()},ee=yn(_,le,{onFoldChange:()=>We.paint()});let kt=!1;ee.setGuard(e=>{kt=e});const wt=()=>ee.getUnfoldedContent(),Zt=()=>{ee.unfoldAll(),a.folded.value=!1,We.paint()},Ss=e=>{if(e?.kind==="page")Zt(),_e(_,"md");else if(e?.kind==="block")oe&&_e(oe.textarea,"html"),pe&&_e(pe.textarea,"css");else if(e?.kind==="component"){if(N.get(e.id)?.readOnly)return;for(const[o,s]of Object.entries({template:"html",props:"json",script:"js",style:"css"}))se[o]&&_e(se[o].textarea,s)}},Wa=e=>{e.error?E.toast(e.error,{type:"warning"}):E.toast(e.unchanged?"Already tidy":"Formatted",{type:"info",duration:900})},Ya=M.observable(_t(Q.type)),Ga=M.observable(Jt(Q.code));l(M.effect(()=>{const e=Ga.value;Er(e),C("#editor-body")?.style.setProperty("--pe-tab",String(e.size))})),l(M.effect(()=>{const e=Ya.value,t=C("#editor-body");if(t){ms(e.font);for(const[o,s]of Object.entries(Yo(e)))t.style.setProperty(o,s);t.classList.toggle("pe-nowrap",!e.wrap),_.wrap=e.wrap?"soft":"off",ve.wrap=e.wrap?"soft":"off",requestAnimationFrame(()=>{i()&&Ja()})}}));let Xa=null;l(()=>{try{Xa?.close()}catch{}});const V=()=>(a.bodyRev.value,{urlPath:p.urlPath.value.trim(),title:p.title.value,description:p.description.value,layout:p.layout.value,status:p.status.value,sortOrder:p.sortOrder.value,showInNav:p.showInNav.value,sidebar:p.sidebar.value,breadcrumbs:p.breadcrumbs.value,bundled:p.bundled.value,tags:p.tags.value,adminTags:p.adminTags.value,category:p.category.value,visibility:p.visibility.value,project:p.project.value,theme:p.theme.value,seoTitle:p.seoTitle.value,seoDesc:p.seoDesc.value,seoSchema:p.seoSchema.value,dconfig:p.dconfig.value,body:wt(),css:null}),Za=()=>M.untracked?M.untracked(V):V(),te=M.observable(""),St=()=>p.cssOpened.peek()&&p.css.peek()!==te.peek(),K=new Map;let m=null;const L=new Map,N=new Map;let O=[];const ie=e=>ja(e.form)!==e.base,ge=()=>[...L.entries()].filter(([,e])=>ie(e)).map(([e])=>e),he=e=>!e.readOnly&&Ha({name:e.name,...e.form})!==e.base,Ye=()=>[...N.values()].filter(he).map(e=>e.name),Qt=()=>Y(Za())!==a.base.peek(),ea=e=>e.loaded&&(e===m?Qt():Y(e.state)!==e.base),Oe=()=>[...K.values()].filter(ea),Ms=M.computed(()=>Y(V())!==a.base.value),Es=M.computed(()=>p.cssOpened.value&&p.css.value!==te.value),Ts=M.computed(()=>(a.blockRev.value,a.compRev.value,a.docRev.value,Y(V())!==a.base.value||p.cssOpened.value&&p.css.value!==te.value||Oe().some(e=>e!==m)||ge().length>0||Ye().length>0)),Cs=M.computed(()=>{a.blockRev.value,a.compRev.value;const e=j(a.active.value);if(e?.kind==="block"){const t=L.get(e.id);return!!(t&&ie(t))}if(e?.kind==="component"){const t=N.get(e.id);return!!(t&&he(t))}return Y(V())!==a.base.value||p.cssOpened.value&&p.css.value!==te.value}),xs=M.computed(()=>a.curId.value!==null),Qa=M.computed(()=>j(a.active.value)?.kind||""),eo=M.computed(()=>!!a.curId.value&&j(a.active.value)?.kind==="page"),Ps=M.computed(()=>p.urlPath.value.trim()||a.curId.value||""),Os=M.computed(()=>La({urlPath:p.urlPath.value,dconfig:p.dconfig.value})[0]?.text||""),Rs=M.computed(()=>(a.bodyRev.value,a.catalogue.value?Cn({dconfig:p.dconfig.value,body:wt()},a.catalogue.value,{isSelector:Ir}).map((e,t)=>({key:`${t}:${e}`,text:e})):[]));Dr().then(e=>{a.catalogue.value=e});const As=M.computed(()=>{a.docRev.value;const e=j(a.active.value);return e?e.kind==="block"?a.blockUses.value:e.kind==="component"?rr({name:e.id,readOnly:a.compReadOnly.value,state:a.compReady.value?a.compState.value:""}):pr({urlPath:p.urlPath.value,status:p.status.value,isEdit:!!a.curId.value}):""}),to=M.computed(()=>a.compTab.value?"component":a.blockTab.value?"block":a.curId.value!==null?"page":""),$s=M.computed(()=>a.blockTab.value?`[${a.blockTab.value} /]`:""),Ls=M.computed(()=>({compiling:"Compiling\u2026",ok:"Compiles",error:"Does not compile"})[a.compState.value]||""),Ns=M.computed(()=>a.compTab.value?`<dm-${a.compTab.value}>`:""),Ds=M.computed(()=>a.versions.value.some(e=>e.checked.value)),Is=M.computed(()=>a.versions.value.length>0&&a.versions.value.every(e=>e.checked.value)),Bs=M.computed(()=>{const e=a.versions.value.filter(t=>t.checked.value).length;return e>0&&e<a.versions.value.length});k=()=>Oe().length>0||ge().length>0||Ye().length>0||St();const Mt=(e,t,o)=>({title:String(e.title||"").trim()||"Untitled",description:String(e.description||"").trim(),layout:e.layout,status:e.status,sortOrder:parseInt(String(e.sortOrder),10)||99,showInNav:!!e.showInNav,sidebar:!!e.sidebar,...e.breadcrumbs?{}:{breadcrumbs:!1},...e.bundled?{bundled:!0}:{},tags:Array.isArray(e.tags)?e.tags:[],...t?.isEdit&&JSON.stringify(e.adminTags)===t.savedAdminTags?{}:{adminTags:Array.isArray(e.adminTags)?e.adminTags:[]},category:String(e.category||"").trim()||null,visibility:e.visibility||"public",project:e.project||"",seo:{title:String(e.seoTitle||"").trim(),description:String(e.seoDesc||"").trim(),...ao(e)?{schema:ao(e)}:t?.isEdit?{schema:null}:{}},dconfig:o,...e.theme?{theme:e.theme}:{}}),ao=e=>Aa(e.seoSchema).value,Et=e=>{const t=String(e.dconfig||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}},oo=()=>p.urlPath.peek().trim()||m?.id||"/";let Tt=[],so=[];const Ct=e=>Tt.includes(e)||Gt.includes(e);let Re=new Set;const Ge=()=>{const e=[...new Set([...Tt,...Gt,...L.keys()])],t=Hn(e.filter(s=>!L.has(s)),yt);Re=new Set(Object.keys(t));const o=Re.size?`Preview shows unsaved changes to ${[...Re].join(", ")}`:"";return o!==a.heldNote.peek()&&(a.heldNote.value=o),Zn(t,[...L.entries()].map(([s,r])=>({name:s,content:r.form.content,css:r.form.css,dirty:ie(r)})))};let ta="";const js=()=>{ro();const e=ta;if(e){ta="";try{Ae.contentDocument?.querySelector(`[data-block="${CSS.escape(e)}"]`)?.scrollIntoView({block:"center"})}catch{}}};let aa=[],Xe="";const xt=e=>{Xe=e;const t=new DOMParser().parseFromString(e,"text/html");if(p.cssOpened.peek()){const o=t.createElement("style");o.textContent=p.css.peek(),t.head.appendChild(o)}a.imageHosts.value=zn(qn(t),window.location.origin,aa),a.imageBlocked.value=a.imageHosts.peek().filter(o=>!o.allowed).length,a.imageScanned.value=!0};l(M.effect(()=>{a.curId.value,a.blockTab.value,a.compTab.value,Xe="",a.imageHosts.value=[],a.imageScanned.value=!1,a.imageBlocked.value=0}));const no=async()=>{const e=await g.get("/pages/_image-hosts");i()&&(aa=e.hosts,a.imageCanAllow.value=e.canAllow,a.imagePolicyReady.value=!0,Xe&&xt(Xe))};no().catch(e=>{i()&&(a.imageError.value="Could not read image permissions: "+e.message)});const Fs=async()=>{const e=m;a.imageScanning.value=!0,a.imageError.value="";try{if(await no(),!m)throw new Error("Open a page to scan its images.");const t=V(),{html:o}=await g.pages.previewFull(oo(),Mt(t,m,Et(t)),t.body,Ge());i()&&m===e&&xt(o)}catch(t){i()&&(a.imageError.value="Could not scan images: "+t.message)}finally{i()&&(a.imageScanning.value=!1)}},zs=async e=>{if(!a.imageAllowing.peek()){a.imageAllowing.value=e,a.imageError.value="";try{const{hosts:t}=await g.post("/pages/_image-hosts",{host:e});if(!i())return;aa=t,xt(Xe),a.imageReload.value=!0,E.toast("Images from "+e+" are now allowed site-wide.",{type:"success"})}catch(t){i()&&(a.imageError.value="Could not allow images: "+t.message)}finally{i()&&(a.imageAllowing.value="")}}},Ae=C("#markdown-preview");g.settings.getCustomCss().then(({css:e})=>{if(!i())return;te.value=e||"";let t=null;try{t=S.get(vt)}catch{}typeof t=="string"&&t!==te.peek()?(uo(),p.css.value=t,E.toast("Your unsaved custom CSS is back - the CSS button shows it.",{type:"info"})):p.cssOpened.peek()||(p.css.value=te.peek()),W(vt)}).catch(()=>{});const ro=()=>{const e=Ae?.contentDocument;if(!e?.head)return;const t=p.cssOpened.peek()?p.css.peek():"";if(!t)return;let o=e.getElementById("preview-custom-css");o||(o=e.createElement("style"),o.id="preview-custom-css",e.head.appendChild(o)),o.textContent=t};let oa=null,sa=0;const J=(e=!1)=>{clearTimeout(oa),oa=setTimeout(async()=>{if(!Ae||a.viewMode.peek()==="write"||!a.active.peek()||a.compTab.peek())return;const t=++sa,o=a.blockTab.peek();a.previewStatus.value="Rendering\u2026";try{let s;if(o&&(!m||!Ct(o)))({html:s}=await g.pages.previewFull(jr,{title:o,layout:"blank",breadcrumbs:!1},ar(o,Xs(o)),Ge()));else if(m){const r=V();({html:s}=await g.pages.previewFull(oo(),Mt(r,m,Et(r)),r.body,Ge()))}else{Ae.srcdoc="";return}if(!i()||t!==sa)return;xt(s),zr(Ae,Xn(Fr(s),o),js),a.previewStatus.value="Showing unsaved changes"}catch(s){if(!i()||t!==sa)return;a.previewStatus.value="Preview failed - "+(s?.message||"unknown error"),Ae.srcdoc='<!doctype html><meta charset="utf-8"><body style="font:14px system-ui;padding:1rem;color:#b91c1c;">Preview failed: '+String(s?.message||"unknown error").replace(/[<&]/g,r=>r==="<"?"&lt;":"&amp;")+"</body>"}},e?0:500)};l(()=>clearTimeout(oa));const na=un(d.find("#markdown-editor"),d.find("#editor-toolbar"),{spacerDefault:G?.layoutOptions?.spacerSize??40,beforeFormat:()=>Zt()});fn(_,{blocks:()=>fe,openBlock:e=>Ie(e)});const Ze=h.querySelector(".editor-toolbar-right");Ze.querySelectorAll(".editor-view-btn[data-mode]").forEach(e=>{const t=e.getAttribute("data-mode");e.classList.remove("active"),e.setAttribute("data-bind-class",`viewMode.value === '${t}' && 'active'`),e.setAttribute("data-on-click",`setMode('${t}')`)}),C("#fullscreen-btn")?.setAttribute("data-on-click","toggleFullscreen");const qs=bt(`
128
128
  <span class="pe-toolbar-extras" style="display:contents">
129
129
  <button type="button" class="editor-view-btn" data-tip="Edit Custom CSS" data-on-click="toggleCss"
130
130
  data-bind-class="cssMode.value && 'active'"><span>CSS</span></button>
@@ -1,4 +1,4 @@
1
- import{api as p}from"../api.js";import{SHAPES as Le,whileLoading as Ne}from"../lib/loading.js";import{addBannerAction as ne}from"../lib/plugin-chrome.js";import{helpPopovers as oe}from"../lib/help-popover.js";import{onceClosed as Re,openMenuAt as ie,settingsStore as je,sidebarCount as re,viewLifetime as Be}from"../lib/tool-kit.js";import{filterByProject as le,getProjectFromHash as Ke}from"../lib/project-context.js";import{arrangePages as qe,checkPrune as He,normaliseSettings as ce,pageRow as Ie,statusCounts as Ue,treeRows as _e}from"../lib/pages-arrange.js";import{UNTAGGED as Fe,activeNote as Oe,askTagName as Ve,openTagSettings as ze,same as de,tagCounts as Ge,tagMenuItems as We,tagsOf as Ye}from"../lib/list-tags.js";const pe=/^#\/(pages|projects\/[^/?#]+\/pages)\/?(\?.*)?$/,ue="#/pages",D="pages.prune.draft",Je=`
1
+ import{api as g}from"../api.js";import{SHAPES as je,whileLoading as Be}from"../lib/loading.js";import{addBannerAction as ie}from"../lib/plugin-chrome.js";import{helpPopovers as re}from"../lib/help-popover.js";import{onceClosed as qe,openMenuAt as ce,settingsStore as Ie,sidebarCount as de,viewLifetime as Ke}from"../lib/tool-kit.js";import{filterByProject as ue,getProjectFromHash as He}from"../lib/project-context.js";import{arrangePages as Fe,checkPrune as Ue,normaliseSettings as pe,pageRow as _e,statusCounts as Oe,treeRows as Ve}from"../lib/pages-arrange.js";import{activeNote as ge,askManualTagName as ze,manualNames as We,openTagSettings as Ye,same as Ge,sharedTagFilter as Je,tagCounts as Qe,tagMenuItems as Xe,tagsOf as Ze}from"../lib/list-tags.js";const he=/^#\/(pages|projects\/[^/?#]+\/pages)\/?(\?.*)?$/,ve="#/pages",L="pages.prune.draft",et=`
2
2
  <div class="pgx-row" data-path="{{urlPath}}" tabindex="0" data-bind-class="rowCls">
3
3
  <span class="pgx-main"><strong>{{title}}</strong><small>{{meta}} <span class="pgx-tags">{{tagsText}}</span></small></span>
4
4
  <span class="pgx-chips">
@@ -6,11 +6,11 @@ import{api as p}from"../api.js";import{SHAPES as Le,whileLoading as Ne}from"../l
6
6
  <span class="pgx-chip is-tag" data-bind-hidden="!listTags" title="Tags">{{listTags}}</span>
7
7
  <span class="pgx-chip is-info" data-bind-hidden="!project" title="Project">{{project}}</span>
8
8
  <span class="pgx-chip" data-bind-hidden="!bundled" title="Shipped with the CMS">Bundled</span>
9
- <span class="pgx-chip is-warn" data-bind-hidden="!plugin" title="Managed by this plugin">{{plugin}}</span>
9
+ <span class="pgx-chip is-tool" data-bind-hidden="!toolTag" title="Tool tag - added by the {{toolTag}} Tool, which manages this page"><span data-icon="package" data-icon-size="11"></span>{{toolTag}}</span>
10
10
  <span class="pgx-chip" data-bind-class="statusCls">{{statusText}}</span>
11
11
  </span>
12
12
  <button type="button" class="pgx-kebab" aria-label="Actions for {{title}}" title="Actions">\u22EE</button>
13
- </div>`,T=r=>String(r??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Qe(r){const l=document.createElement("template");return l.innerHTML=r.trim(),l.content.firstElementChild}const ge=je("pages.settings",ce),i=Be(pe),Xe=r=>`#/pages/edit${r}`;export const pagesView={templateUrl:"/admin/js/templates/pages.html",async onMount(r){i.reset();const l=r.get(0).querySelector(".pgx")||r.get(0),L=()=>pe.test(location.hash)&&l.isConnected,d=Ke(),x=ge.read(),o=M.observable([]),_=M.observable(0),F=M.observable(!0),N=M.observable(""),h=M.observable(x.status),R=M.observable(x.sort),b=M.observable(x.mode),O=M.observable(""),u=M.observable(x.tag),y=M.observable([]);i.add(M.effect(()=>ge.write(ce({status:h.value,sort:R.value,mode:b.value,tag:u.value}))));const C=M.observable([]);i.add(M.effect(()=>{C.value=qe(o.value,{status:h.value,query:O.value,sort:R.value,tag:u.value})}));const V=M.observable([]);i.add(M.effect(()=>{V.value=C.value.map(e=>Ie(e))}));const he=M.computed(()=>Ue(o.value)),me=M.computed(()=>o.value.length?"No pages match.":"No pages yet - New page in the banner makes one."),ve=M.computed(()=>{const e=_.value;return!d||!e?"":`Showing only pages in ${d}. ${e} other page${e===1?" is":"s are"} filed elsewhere.`}),j=M.computed(()=>Ge(y.value,o.value)),fe=M.computed(()=>Oe(u.value,C.value.length,"pages")),z=e=>o.peek().find(t=>t.urlPath===e);async function be(){try{const e=await Ne(l.querySelector(".dm-loading-slot"),p.pages.list(),Le.rows);if(!L())return;const t=Array.isArray(e)?e:[],a=d?le(t,d):t;_.value=t.length-a.length,o.value=a,N.value="",await G()}catch(e){N.value=`Could not load the pages: ${e.message||e}`}finally{F.value=!1}}async function G(){try{y.value=(await p.listTags.list("pages")).map(t=>t.name)}catch{}const e=u.peek();e&&e!==Fe&&!j.peek().some(t=>de(t.name,e))&&(u.value="")}async function W(e,t){try{const a=await p.listTags.changeItem("pages",e.urlPath,t);o.value=o.peek().map(s=>s.urlPath===e.urlPath?{...s,adminTags:a}:s),a.some(s=>!y.peek().some(v=>de(v,s)))&&(y.value=[...y.peek(),...a])}catch(a){E.toast(`Tags not saved: ${a.message||a}`,{type:"error"})}}async function ye(){const e=await p.pages.list(),t=Array.isArray(e)?e:[];o.value=d?le(t,d):t,await G()}const we=()=>ze({kind:"pages",noun:"pages",title:"Pages settings - tags",tags:j,active:u,reload:ye}),$=e=>{location.hash=Xe(e)},ke=()=>{location.hash=d?`#/pages/new?project=${encodeURIComponent(d)}`:"#/pages/new"};async function Pe(e){const t=e.plugin?`"${T(e.title||e.urlPath)}" is managed by the <strong>${T(e.plugin)}</strong> plugin - deleting it may stop that plugin working. Delete it anyway?`:`Delete the page at <strong>${T(e.urlPath)}</strong>? This cannot be undone.`;if(await E.confirm(t))try{await p.pages.delete(e.urlPath),E.toast("Page deleted.",{type:"success"}),o.value=o.peek().filter(a=>a.urlPath!==e.urlPath),re(ue)}catch(a){E.toast(`Not deleted: ${a.message||a}`,{type:"error"})}}async function Me(e){const t=new URL(e.urlPath,location.origin).href;try{await navigator.clipboard.writeText(t),E.toast("Address copied.",{type:"success",duration:2e3})}catch{E.toast(t,{type:"info",duration:8e3})}}async function B(e,t){if(e.status!==t)try{const a=await p.pages.get(e.urlPath);await p.pages.update(e.urlPath,{frontmatter:{status:t},body:a.content||""}),o.value=o.peek().map(s=>s.urlPath===e.urlPath?{...s,status:t}:s),E.toast(t==="published"?"Page published.":t==="review"?"Page moved to review.":"Page moved to drafts.",{type:"success"}),re(ue)}catch(a){E.toast(`Could not change page status: ${a.message||a}`,{type:"error"})}}let g=null;const K=new Set;let Y=!1;function J(e,t=null){const a=e.versionCount||0,s=M.observable(String(t?.keep??Math.min(5,a))),v=M.observable(!1),k=M.computed(()=>He(s.value,a)),ee={keep:s,saving:v,err:M.computed(()=>k.value.error),summary:M.computed(()=>{const n=k.value;return n.error?"":n.deletes?`Deletes the ${n.deletes} oldest, keeps the newest ${Math.min(n.keep,a)}.`:"Nothing to delete - that keeps them all."}),cannot:M.computed(()=>v.value||!!k.value.error||k.value.deletes===0),intro:`${e.title||e.urlPath} has ${a} saved revision${a===1?"":"s"} - earlier versions you can compare with and restore from the editor's History.`},Se=String(s.peek()),te=()=>String(s.peek())!==Se||!!t,c=E.slideover({title:`Trim revisions - ${T(e.title||e.urlPath)}`,size:"sm",position:"right"}),f=Qe(`
13
+ </div>`,C=r=>String(r??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function tt(r){const c=document.createElement("template");return c.innerHTML=r.trim(),c.content.firstElementChild}const me=Ie("pages.settings",pe),l=Ke(he),at=r=>`#/pages/edit${r}`;export const pagesView={templateUrl:"/admin/js/templates/pages.html",async onMount(r){l.reset();const c=r.get(0).querySelector(".pgx")||r.get(0),N=()=>he.test(location.hash)&&c.isConnected,u=He(),$=me.read(),s=M.observable([]),V=M.observable(0),z=M.observable(!0),R=M.observable(""),h=M.observable($.status),j=M.observable($.sort),w=M.observable($.mode),B=M.observable(""),W=Je($.tag),f=W.tag;l.add(W.dispose);const k=M.observable([]),b=M.observable({});l.add(M.effect(()=>me.write(pe({status:h.value,sort:j.value,mode:w.value}))));const P=M.observable([]);l.add(M.effect(()=>{P.value=Fe(s.value,{status:h.value,query:B.value,sort:j.value,tag:f.value,tools:b.value})}));const q=M.observable([]);l.add(M.effect(()=>{const e=b.value;q.value=P.value.map(t=>_e(t,Date.now(),e))}));const fe=M.computed(()=>Oe(s.value)),Y=M.computed(()=>!!f.value&&s.value.length>0&&!P.value.length),be=M.computed(()=>Y.value&&!B.value.trim()&&h.value==="all"?ge(f.value,0,"pages"):s.value.length?"No pages match.":"No pages yet - New page in the banner makes one."),ye=M.computed(()=>{const e=V.value;return!u||!e?"":`Showing only pages in ${u}. ${e} other page${e===1?" is":"s are"} filed elsewhere.`}),K=M.computed(()=>Qe(k.value,s.value,b.value)),we=M.computed(()=>ge(f.value,P.value.length,"pages")),G=e=>s.peek().find(t=>t.urlPath===e);async function ke(){try{const e=await Be(c.querySelector(".dm-loading-slot"),g.pages.list(),je.rows);if(!N())return;const t=Array.isArray(e)?e:[],a=u?ue(t,u):t;V.value=t.length-a.length,s.value=a,R.value="",await J()}catch(e){R.value=`Could not load the pages: ${e.message||e}`}finally{z.value=!1}}async function J(){try{const e=await g.listTags.load("pages");b.value=e.tools,k.value=e.tags}catch{}}async function Q(e,t){try{const a=await g.listTags.changeItem("pages",e.urlPath,t);s.value=s.peek().map(i=>i.urlPath===e.urlPath?{...i,adminTags:a}:i);const n=a.filter(i=>!k.peek().some(m=>Ge(m.name,i)));n.length&&(k.value=[...k.peek(),...n.map(i=>({name:i}))])}catch(a){E.toast(`Tags not saved: ${a.message||a}`,{type:"error"})}}async function Pe(){const e=await g.pages.list(),t=Array.isArray(e)?e:[];s.value=u?ue(t,u):t,await J()}const Me=()=>Ye({kind:"pages",noun:"pages",title:"Pages settings - tags",tags:K,tools:b,active:f,reload:Pe}),A=e=>{location.hash=at(e)},Ee=()=>{location.hash=u?`#/pages/new?project=${encodeURIComponent(u)}`:"#/pages/new"};async function Te(e){const t=e.plugin?`"${C(e.title||e.urlPath)}" is managed by the <strong>${C(e.plugin)}</strong> plugin - deleting it may stop that plugin working. Delete it anyway?`:`Delete the page at <strong>${C(e.urlPath)}</strong>? This cannot be undone.`;if(await E.confirm(t))try{await g.pages.delete(e.urlPath),E.toast("Page deleted.",{type:"success"}),s.value=s.peek().filter(a=>a.urlPath!==e.urlPath),de(ve)}catch(a){E.toast(`Not deleted: ${a.message||a}`,{type:"error"})}}async function xe(e){const t=new URL(e.urlPath,location.origin).href;try{await navigator.clipboard.writeText(t),E.toast("Address copied.",{type:"success",duration:2e3})}catch{E.toast(t,{type:"info",duration:8e3})}}async function H(e,t){if(e.status!==t)try{const a=await g.pages.get(e.urlPath);await g.pages.update(e.urlPath,{frontmatter:{status:t},body:a.content||""}),s.value=s.peek().map(n=>n.urlPath===e.urlPath?{...n,status:t}:n),E.toast(t==="published"?"Page published.":t==="review"?"Page moved to review.":"Page moved to drafts.",{type:"success"}),de(ve)}catch(a){E.toast(`Could not change page status: ${a.message||a}`,{type:"error"})}}let v=null;const F=new Set;let X=!1;function Z(e,t=null){const a=e.versionCount||0,n=M.observable(String(t?.keep??Math.min(5,a))),i=M.observable(!1),m=M.computed(()=>Ue(n.value,a)),se={keep:n,saving:i,err:M.computed(()=>m.value.error),summary:M.computed(()=>{const o=m.value;return o.error?"":o.deletes?`Deletes the ${o.deletes} oldest, keeps the newest ${Math.min(o.keep,a)}.`:"Nothing to delete - that keeps them all."}),cannot:M.computed(()=>i.value||!!m.value.error||m.value.deletes===0),intro:`${e.title||e.urlPath} has ${a} saved revision${a===1?"":"s"} - earlier versions you can compare with and restore from the editor's History.`},Ae=String(n.peek()),ne=()=>String(n.peek())!==Ae||!!t,d=E.slideover({title:`Trim revisions - ${C(e.title||e.urlPath)}`,size:"sm",position:"right"}),y=tt(`
14
14
  <div class="pgx-form">
15
15
  <p class="pgx-note" data-bind-text="intro"></p>
16
16
  <div>
@@ -26,4 +26,4 @@ import{api as p}from"../api.js";import{SHAPES as Le,whileLoading as Ne}from"../l
26
26
  <button type="button" class="btn btn-sm btn-danger" data-on-click="trim" data-bind-disabled="cannot.value">
27
27
  <span data-icon="archive" data-icon-size="13"></span> Trim</button>
28
28
  </div>
29
- </div>`);async function ae(){if(!ee.cannot.peek()){v.value=!0;try{const n=await p.versions.prune(e.urlPath,k.peek().keep);E.toast(`Removed ${n.deleted} revision${n.deleted===1?"":"s"}; kept ${n.kept}.`,{type:"success"}),o.value=o.peek().map(P=>P.urlPath===e.urlPath?{...P,versionCount:n.kept}:P),H=!0,c.close()}catch(n){E.toast(n.message||"Could not trim the revisions.",{type:"error"})}finally{v.value=!1}}}c.element.appendChild(f);const Ce=oe(f),$e=M.applyBindings(ee,f,{methods:{trim:ae,cancel:()=>c.close()}}),Ae=n=>{n.key==="Enter"&&n.target.id==="pgx-f-keep"&&(n.preventDefault(),ae())};f.addEventListener("keydown",Ae);const se={path:e.urlPath,dirty:te,values:()=>({keep:s.peek()})};g=se,K.add(c),Re(c,()=>{$e.dispose(),Ce(),K.delete(c),g===se&&(g=null)});const De=c.close.bind(c);let H=!1,U=!1;c.close=async n=>{if(!H&&n!==!0&&!Y&&te()){if(U)return;U=!0;const P=await E.confirm("Discard the change you have not applied?");if(U=!1,!P)return}return H=!0,De()},I.scan(f),c.open(),f.querySelector("#pgx-f-keep")?.select()}function Ee(e){const t=z(e);if(!t)return[];const a=t.versionCount||0;return[{header:t.title||t.urlPath},{label:"Edit",icon:"edit",action:()=>$(t.urlPath)},{label:t.status==="published"?"View on the site":"Preview (draft)",icon:"external-link",action:()=>window.open(t.urlPath,"_blank","noopener")},{label:"Copy address",icon:"copy",action:()=>Me(t)},{label:"Transition",icon:"circle",submenu:[{label:"Published",disabled:t.status==="published",action:()=>B(t,"published")},{label:"Draft",disabled:t.status==="draft",action:()=>B(t,"draft")},{label:"Review",disabled:t.status==="review",action:()=>B(t,"review")}]},{type:"divider"},...We({all:j.peek().map(s=>s.name),current:Ye(t),change:s=>W(t,s),newTag:async()=>{const s=await Ve();s&&await W(t,{add:[s]})}}),{type:"divider"},{label:a?`Trim revisions (${a})\u2026`:"No revisions to trim",icon:"archive",disabled:!a,action:()=>J(t)},{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>Pe(t)}]}const m=l.querySelector(".pgx-list");m.innerHTML=Je;const Te=M.applyBindings({pages:o,loading:F,loadError:N,status:h,sort:R,mode:b,query:O,rows:V,counts:he,emptyText:me,projectNote:ve,tagNote:fe},l,{methods:{showAllTags:()=>{u.value=""},showAll:()=>{h.value="all"},showPublished:()=>{h.value="published"},showDrafts:()=>{h.value="draft"},showList:()=>{b.value="list"},showTree:()=>{b.value="tree"}}});i.add(()=>Te.dispose()),i.add(oe(l,{position:"bottom"}));const q=l.querySelector(".pgx-tree");let A=null;i.add(M.effect(()=>{const e=b.value==="tree",t=e?_e(C.value):null;try{A?.destroy?.()}catch{}A=null,q.replaceChildren(),!(!e||!t.length)&&(A=E.treeView(q,{data:t,idKey:"id",parentKey:"parent_id",labelKey:"name",iconKey:"icon",expandedByDefault:!0,onSelect:a=>$(a)}),I.scan(q))})),i.add(()=>{try{A?.destroy?.()}catch{}});const xe=E.contextMenu(m,{cursor:"glyph",match:".pgx-row",inherit:!1,density:"compact",items:e=>Ee(e.dataset.path)});i.add(()=>xe?.destroy?.());const Q=e=>{const t=e.target.closest(".pgx-row");if(!t)return;const a=e.target.closest(".pgx-kebab");if(a){ie(a);return}$(t.dataset.path)},X=e=>{const t=e.target.closest(".pgx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),ie(t)):e.key==="Enter"&&e.target===t&&$(t.dataset.path))};m.addEventListener("click",Q),m.addEventListener("keydown",X),i.add(()=>{m.removeEventListener("click",Q),m.removeEventListener("keydown",X)}),ne(r,{id:"pages-settings",icon:"settings",title:"Pages settings - tags",onClick:we}),ne(r,{id:"pages-new",icon:"plus",title:"New page",onClick:ke});const Z=e=>{g?.dirty()&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",Z),i.add(()=>window.removeEventListener("beforeunload",Z)),i.add(()=>{if(g?.dirty())try{S.set(D,{path:g.path,values:g.values(),at:new Date().toISOString()})}catch{}Y=!0,[...K].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(l),await be(),!L())return;let w=null;try{w=S.get(D)}catch{}if(w?.path&&w.values){try{S.remove?S.remove(D):S.set(D,null)}catch{}const e=z(w.path);e&&(e.versionCount||0)>0&&await E.confirm(`You left trimming the revisions of "${T(e.title||e.urlPath)}" unfinished. Pick up where you left off?`)&&L()&&J(e,w.values)}}};
29
+ </div>`);async function oe(){if(!se.cannot.peek()){i.value=!0;try{const o=await g.versions.prune(e.urlPath,m.peek().keep);E.toast(`Removed ${o.deleted} revision${o.deleted===1?"":"s"}; kept ${o.kept}.`,{type:"success"}),s.value=s.peek().map(x=>x.urlPath===e.urlPath?{...x,versionCount:o.kept}:x),_=!0,d.close()}catch(o){E.toast(o.message||"Could not trim the revisions.",{type:"error"})}finally{i.value=!1}}}d.element.appendChild(y);const De=re(y),Le=M.applyBindings(se,y,{methods:{trim:oe,cancel:()=>d.close()}}),Ne=o=>{o.key==="Enter"&&o.target.id==="pgx-f-keep"&&(o.preventDefault(),oe())};y.addEventListener("keydown",Ne);const le={path:e.urlPath,dirty:ne,values:()=>({keep:n.peek()})};v=le,F.add(d),qe(d,()=>{Le.dispose(),De(),F.delete(d),v===le&&(v=null)});const Re=d.close.bind(d);let _=!1,O=!1;d.close=async o=>{if(!_&&o!==!0&&!X&&ne()){if(O)return;O=!0;const x=await E.confirm("Discard the change you have not applied?");if(O=!1,!x)return}return _=!0,Re()},I.scan(y),d.open(),y.querySelector("#pgx-f-keep")?.select()}function Se(e){const t=G(e);if(!t)return[];const a=t.versionCount||0;return[{header:t.title||t.urlPath},{label:"Edit",icon:"edit",action:()=>A(t.urlPath)},{label:t.status==="published"?"View on the site":"Preview (draft)",icon:"external-link",action:()=>window.open(t.urlPath,"_blank","noopener")},{label:"Copy address",icon:"copy",action:()=>xe(t)},{label:"Transition",icon:"circle",submenu:[{label:"Published",disabled:t.status==="published",action:()=>H(t,"published")},{label:"Draft",disabled:t.status==="draft",action:()=>H(t,"draft")},{label:"Review",disabled:t.status==="review",action:()=>H(t,"review")}]},{type:"divider"},...Xe({all:We(K.peek()),current:Ze(t),change:n=>Q(t,n),newTag:async()=>{const n=await ze(K.peek(),b.peek());n&&await Q(t,{add:[n]})}}),{type:"divider"},{label:a?`Trim revisions (${a})\u2026`:"No revisions to trim",icon:"archive",disabled:!a,action:()=>Z(t)},{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>Te(t)}]}const p=c.querySelector(".pgx-list");p.innerHTML=et;const Ce=M.applyBindings({pages:s,loading:z,loadError:R,status:h,sort:j,mode:w,query:B,rows:q,counts:fe,emptyText:be,projectNote:ye,tagNote:we,tagEmpty:Y},c,{methods:{showAllTags:()=>{f.value=""},showAll:()=>{h.value="all"},showPublished:()=>{h.value="published"},showDrafts:()=>{h.value="draft"},showList:()=>{w.value="list"},showTree:()=>{w.value="tree"}}});l.add(()=>Ce.dispose()),l.add(re(c,{position:"bottom"})),l.add(M.effect(()=>{q.value,requestAnimationFrame(()=>{p.isConnected&&I.scan(p)})}));const U=c.querySelector(".pgx-tree");let D=null;l.add(M.effect(()=>{const e=w.value==="tree",t=e?Ve(P.value):null;try{D?.destroy?.()}catch{}D=null,U.replaceChildren(),!(!e||!t.length)&&(D=E.treeView(U,{data:t,idKey:"id",parentKey:"parent_id",labelKey:"name",iconKey:"icon",expandedByDefault:!0,onSelect:a=>A(a)}),I.scan(U))})),l.add(()=>{try{D?.destroy?.()}catch{}});const $e=E.contextMenu(p,{cursor:"glyph",match:".pgx-row",inherit:!1,density:"compact",items:e=>Se(e.dataset.path)});l.add(()=>$e?.destroy?.());const ee=e=>{const t=e.target.closest(".pgx-row");if(!t)return;const a=e.target.closest(".pgx-kebab");if(a){ce(a);return}A(t.dataset.path)},te=e=>{const t=e.target.closest(".pgx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),ce(t)):e.key==="Enter"&&e.target===t&&A(t.dataset.path))};p.addEventListener("click",ee),p.addEventListener("keydown",te),l.add(()=>{p.removeEventListener("click",ee),p.removeEventListener("keydown",te)}),ie(r,{id:"pages-settings",icon:"settings",title:"Pages settings - tags",onClick:Me}),ie(r,{id:"pages-new",icon:"plus",title:"New page",onClick:Ee});const ae=e=>{v?.dirty()&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",ae),l.add(()=>window.removeEventListener("beforeunload",ae)),l.add(()=>{if(v?.dirty())try{S.set(L,{path:v.path,values:v.values(),at:new Date().toISOString()})}catch{}X=!0,[...F].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(c),await ke(),!N())return;let T=null;try{T=S.get(L)}catch{}if(T?.path&&T.values){try{S.remove?S.remove(L):S.set(L,null)}catch{}const e=G(T.path);e&&(e.versionCount||0)>0&&await E.confirm(`You left trimming the revisions of "${C(e.title||e.urlPath)}" unfinished. Pick up where you left off?`)&&N()&&Z(e,T.values)}}};
@@ -29,8 +29,11 @@ Code was treated as the truth. Where docs disagree with it, the disagreement is
29
29
 
30
30
  | Plugin | Tier | Version | In one line |
31
31
  |---|---|---|---|
32
+ | `advent-calendar` | paid (giftable) | 1.0.0 | A calendar of 1 to 31 doors, one opening each day: an advent calendar or a countdown to a launch or event. Behind each door a message, picture, link and a code (shared, unique from a list, or a single-use Shop code), never sent before its day; codes limited per visitor and per connection. |
33
+ | `anagram` | paid (giftable) | 1.0.0 | Word puzzles against the clock: unscramble the letters (any other real word of the same letters counts too) or climb a word ladder one letter at a time. Random rounds each go, or a daily set everyone shares. Skip and hints for a time penalty, leaderboards, personal best, Share, export and import. |
32
34
  | `analytics-pro` | paid | 2.3.4 | Visitors, visits and page views: where visitors came from (sources, campaigns, channels, country and city by GeoIP), IP addresses, each visit's pages in order, devices and browsers, busiest times and a live view. Cookieless. Several display styles, CSV/JSON export and a printable report. |
33
35
  | `backup-pro` | paid | 0.1.4 | A site's own view of the backups Domma keeps of it: how they stand, every backup, Back up now, restore of the whole site or chosen collections, pages or media after a safety backup, downloads without secrets, and Activity - every backup, restore and change, including Domma's own, named and never hidden. Needs a site run by Domma. |
36
+ | `bingo` | paid (giftable) | 1.0.0 | Bingo for quiz nights, events and classrooms: 75-ball, 90-ball tickets, or word and picture cards. A caller screen with auto-draw and a projector view, players on their phones with server-dealt cards, claims checked against the real calls, and printable numbered cards with a checker. |
34
37
  | `blog` | free | 1.9.6 | Public-facing blog with posts, categories and comments - layouts and listings built from editable blocks. |
35
38
  | `blog-pro` | paid | 0.7.0 | Several blogs on one site, each with its own address, look and settings - dozens of layouts, self-hosted fonts, colours, page transitions, author pages, and privacy-first media: videos, audio, galleries, link cards and maps. |
36
39
  | `booking` | free | 1.6.3 | Let people book appointments with you or your team, and rooms or equipment, from a booking page on your site (`/booking`, or the `[booking /]` shortcode). Opening hours, days off, buffers and notice; confirmation and reminder emails with a link to move or cancel; a Diary in the admin; an online booking's call chat kept on the booking, and Add people during its call. Book straight from a contact or an email; bookings show in the Calendar. |
@@ -38,7 +41,7 @@ Code was treated as the truth. Where docs disagree with it, the disagreement is
38
41
  | `calendar` | paid | 1.15.4 | Events calendar - month, day and list views, online meetings as a video call on your site (with the call's chat kept, and Add people during the call), call anyone now from a contact or an email, all-day and recurring events, sharing with people and roles, RSVPs and an iCal feed. |
39
42
  | `campaigns-pro` | paid | 1.6.0 | Marketing campaigns, one paid Tool: compose a message, send it to Contacts groups (read live when it sends) or an audience of its own (shared with Surveys), from the site's sending or your own Email mailbox (small lists), schedule sends, attach an offer that closes by a date or a claim limit. Opens and clicks (cookieless), links tagged for Analytics, a linked Shop discount code, send a survey as a campaign, follow-up sequences, resend to non-openers, A/B subject tests, and a version-1 stats feed other Tools read. |
40
43
  | `contacts-pro` | paid | 0.13.0 | Contacts, with more to them: send a campaign to a group or the selected contacts (with Campaigns Pro), your own custom fields, birthdays and ages with the ones coming up and a reminder in the sidebar, and groups with their own emblem and colours. Share a contact, several, or a whole group with people or roles - to view, or to edit. Call a contact now on a video call on your site. Works over the same contacts as the built-in Tool, so nothing moves and nothing is lost. |
41
- | `crossword` | paid (giftable) | 1.5.0 | Crosswords on your site: type the answers and clues and the grid lays itself out (live preview, Another layout). Players type a name and race the server's clock, checks and wrong guesses cost time, fastest solvers on a leaderboard. Hints for a time penalty, personal best and Share, animations, export and import. Test it from the Tool - a test go never reaches the board. Rotation (a new quiz every day or week from a queue, off by default) and fresh quizzes from Domma for review. |
44
+ | `crossword` | paid (giftable) | 1.5.1 | Crosswords on your site: type the answers and clues and the grid lays itself out (live preview, Another layout). Players type a name and race the server's clock, checks and wrong guesses cost time, fastest solvers on a leaderboard. Hints for a time penalty, personal best and Share, animations, export and import. Test it from the Tool - a test go never reaches the board. Rotation (a new quiz every day or week from a queue, off by default) and fresh quizzes from Domma for review. |
42
45
  | `daily-word` | paid (giftable) | 1.3.0 | One hidden word a day, the same for everyone: six guesses, each letter marked right place, in the word or not; real words only (a bundled dictionary, switchable), an archive of past days, streaks, Share as coloured squares, a calendar of what is coming. Fewest guesses tops the day's board, then the fastest. |
43
46
  | `data-transfer` | paid | 1.3.3 | Move collections between file and MongoDB storage, back them up and restore them (all or some, merged or replaced) - keeping every entry's id - and clone them (cloned entries get new ids, so references stay unambiguous). Every restore and transfer takes a safety snapshot first. |
44
47
  | `docs` | paid | 2.13.1 | Document editor: Home and editor screens, sharing with Viewers/Editors, public links, import/export, send to page/blog/email, edit lock, Trash, version history, templates. PDF documents (2.13): a PDF kept as it is, shown in the browser's viewer, searchable inside, versioned on replace. |
@@ -46,24 +49,39 @@ Code was treated as the truth. Where docs disagree with it, the disagreement is
46
49
  | `email-pro` | paid | 0.13.0 | Full mail (and Campaigns Pro's "send from my mailbox"): read, write, send and search, over a synchronised store. Search, threads, rules, scheduled sends, snooze and vacation replies need MongoDB; without it, reading, filing and sending still work. |
47
50
  | `feedback` | free | 1.1.4 | Tell Domma what is broken, missing or good - straight from your admin - and see what became of it: seen, planned, in progress, done, with Domma's reply. |
48
51
  | `garage` | paid | 1.4.3 | UK vehicle management with DVLA API lookup, save vehicles, and search history. |
52
+ | `group-four` | paid (giftable) | 1.0.0 | Sixteen tiles hide four groups of four: pick four, a wrong guess costs a mistake, a close call says so. Single puzzles or a daily set with streaks and an archive; the server holds the groups. |
53
+ | `hangman` | paid (giftable) | 1.0.0 | Guess the hidden word or phrase letter by letter before the drawing is finished - a stick figure, or balloons that pop for family sites. Random rounds or the same words for everyone each day; hints, leaderboards, personal best, Share, export and import. |
54
+ | `higher-lower` | paid (giftable) | 1.0.0 | Is the next one higher or lower? A deck of items with numbers (prices, years, counts, percents), filled by hand, pasted, from CSV or from the Shop's prices. The server reveals each number only after the guess; longest streak wins. |
49
55
  | `invoice` | paid | 1.7.1 | Invoices and quotes. Issuer profiles, receivers importable from Contacts, line items, optional VAT, payments, archiving, CSV/Excel export, and a print-ready invoice you can email or download as a PDF. Quotes with a validity date and an emailed accept link - the client accepts or declines online, and one click turns an accepted quote into a draft invoice. Self-billing too: invoices raised on a supplier's behalf, marked and numbered their own way, with agreement review reminders. |
56
+ | `jigsaw` | paid (giftable) | 1.0.1 | Any picture in Media becomes a jigsaw: Easy, Medium, Hard or your own size, classic or square pieces, optional turned pieces and a ghost picture. Drag, tap or use the keyboard; the server keeps the clock and where each piece goes. Fastest leaderboard, hints, export and import. |
50
57
  | `job-board` | paid | 2.0.0 | Job board with three kinds of account - companies, their agents and candidates - sign-up for each (companies when opened, approved by staff), credits that pay for publishing a role (Stripe, staff gifts, company-to-agent), IR35 on every contract, candidate bios, work history and preferences, agents onboarding and messaging their candidates, interviews, notes and reviews - every record scoped to who may see it. |
51
58
  | `mail-reader` | free | 1.2.7 | Read-only IMAP mailbox reader. Connects to a standard IMAP server and reads mail without ever writing to it. |
59
+ | `map-guess` | paid (giftable) | 1.0.0 | Drop a pin where each photo was taken: on the built-in world map or your own map picture (town, venue, campus) with a scale. Points by distance; every photo is stripped of GPS and other details, and answers stay on the server until the guess. |
60
+ | `memory-pairs` | paid (giftable) | 1.0.1 | Turn two cards over at a time to find the pairs: the same picture twice, a picture and its words, or two texts (term and meaning). 4 to 24 pairs, a fresh shuffle each go kept on the server. Fewest moves wins, then fastest; hints, personal best, Share, export and import. |
52
61
  | `messages` | paid | 1.7.2 | Internal user-to-user and group messaging with real-time delivery and video calls (what is typed in a call lands in the conversation; ring another team member into a call) - conversations you can archive, mark unread and search, drafts kept per conversation, attachments, and an unread badge in the sidebar. |
53
62
  | `mongodb-adapter` | paid | 1.0.2 | Provision a dedicated MongoDB database per site. Credentials are managed centrally by the manager. |
54
63
  | `onboard-pro` | paid | 1.0.1 | Onboarding journeys, one paid Tool: read/form/details/manual steps, a personal link per person, signature steps through Docs Pro, admin-approved account steps (never an administrator), due dates, automatic nudges and auto-enrolment from a contact group, countersigned steps, waive-with-a-reason, and a funnel showing where people stop. |
55
- | `quiz` | paid (giftable) | 1.5.0 | Timed quizzes on your site: one or several right answers, true or false, or a typed answer, marked by the server so answers never reach the browser early. Name-only players, leaderboards by day, week, month and all time. Hints for a time penalty, personal best and Share, animations, export and import. Test it from the Tool - a test go never reaches the board. Rotation (a new quiz every day or week from a queue, off by default) and fresh quizzes from Domma for review. |
64
+ | `personality-quiz` | paid (giftable) | 1.0.0 | "Which one are you?" quizzes with no wrong answers: 2-8 outcomes, each with a picture and a button to an offer or page. Optional lead capture (an email before the result, with consent, into Contacts if you like), a Leads screen with CSV, and stats on every answer. |
65
+ | `picture-reveal` | paid (giftable) | 1.0.0 | Guess the picture as it slowly appears - pixelated, blurred, zoomed in or under tiles. Fewer stages used, more points; forgiving answers. The server draws every stage, so the picture never reaches the browser before it is guessed. |
66
+ | `predictions` | paid (giftable) | 1.0.0 | A predictions league that runs for weeks: rounds of fixtures (predict the score) and questions (pick the answer). Predictions lock at kick-off; you enter results and the table works itself out, with movement arrows, jokers and optional approval for new members. |
67
+ | `prize-wheel` | paid (giftable) | 1.0.1 | Spin to win: a prize wheel or a scratch card with 3-12 prizes, each with its own chance and stock. Rewards are a message, a code, a unique code from your list, or a single-use Shop discount code from Shopping Cart Pro. Entry by email with consent, spins per person, a daily cap; the server picks every prize. |
68
+ | `quiz` | paid (giftable) | 1.6.1 | Timed quizzes on your site: one or several right answers, true or false, or a typed answer, marked by the server so answers never reach the browser early. Name-only players, leaderboards by day, week, month and all time. Hints for a time penalty, personal best and Share, animations, export and import. Test it from the Tool - a test go never reaches the board. Rotation (a new quiz every day or week from a queue, off by default) and fresh quizzes from Domma for review. |
69
+ | `scratch-card` | paid (giftable) | 1.0.0 | Instant-win scratch cards, the partner to Prize Wheel: prizes with odds and stock, codes (shared, unique, or single-use Shop codes), a reveal or match-three card, email and consent capture. The server draws at the deal; the result arrives as the card is scratched. |
56
70
  | `security` | free | 1.1.3 | Keeps a Domma CMS site safe: a health check of what is weak and how to fix it, sign-in lockout after repeated wrong passwords, password rules, a log of every sign-in, and blocking of the scanners that probe every site for WordPress, .env files and the like. |
57
71
  | `security-pro` | paid | 1.3.2 | Everything in Security, plus two-factor sign-in (authenticator apps, recovery codes, required per role), a firewall that bans scanners for longer each time they return, per-route rate limits, country rules for the admin, breached-password checks and every signed-in session in one place. |
58
72
  | `seo-pro` | paid | 0.6.2 | More for SEO: Google Search Console in the admin (with your own Google client) - searches, clicks, positions and where to win more; structured data for rich results (FAQ, how-to, product, event, local business); links worth adding between pages, pages competing for one search, readability, near duplicates and image checks; every title and description in one grid, and moving an old site's addresses across as redirects; a not-found log with one-click redirects; a scheduled check of every link; SEO history and notices. Adds to SEO, which is built into Domma CMS (0.90 and later). |
59
73
  | `sheets` | paid | 0.4.1 | A spreadsheet in your admin: workbooks with formulas, sorting and filters; import CSV, JSON or Excel, export CSV or Excel, print. Feed a sheet live from Contacts, collections, forms, Surveys, Campaigns, Analytics or the Shop - rows kept even if the source goes away. |
60
74
  | `shopping-cart` | free | 1.6.1 | Sell from your site: products with options, stock and pictures, a storefront and a cart that follows shoppers from page to page, and checkout with Stripe, PayPal or payment offline. Orders to fulfil in the sidebar, refunds from the order. |
61
- | `shopping-cart-pro` | paid | 0.2.2 | More for the Shop: discount codes, shipping zones with rates by weight or order value, tax by country and class, branded order emails from confirmation to dispatch, and Insights - takings by week, best sellers, repeat customers and abandoned checkouts you can nudge. Adds to the free Shopping Cart; a lapsed licence leaves the Cart and every order just as they were. |
75
+ | `shopping-cart-pro` | paid | 0.3.2 | More for the Shop: discount codes (other Tools such as Prize Wheel can make single-use ones), shipping zones with rates by weight or order value, tax by country and class, branded order emails from confirmation to dispatch, and Insights - takings by week, best sellers, repeat customers and abandoned checkouts you can nudge. Adds to the free Shopping Cart; a lapsed licence leaves the Cart and every order just as they were. |
76
+ | `sliding-puzzle` | paid (giftable) | 1.0.0 | The tile-sliding puzzle, 3x3 to 6x6, numbers or a Media picture. Same board for everyone, a new board each go, or a daily puzzle; every move checked by the server. Fewest moves or fastest time wins. |
62
77
  | `social-media-pro` | paid | 0.4.0 | How the site looks when it is shared, and posting it: share cards per page for Facebook, X, LinkedIn, WhatsApp and Slack with previews; a share image drawn for every page that has none, in the site's colours; share and follow buttons; posting to Bluesky, Mastodon and LinkedIn (through the site's own LinkedIn app, with a reminder before its 60-day sign-in runs out) - now, scheduled, or drafted automatically for every new blog post or page - with links tagged for Analytics and the posts on the Calendar; and LinkedIn conversions - chosen forms reported to LinkedIn's Conversions API when a visitor who accepted marketing cookies sends one. Sold with SEO Pro. |
63
78
  | `surveys` | paid | 1.5.1 | Targeted surveys over the Forms engine: shared audiences, tokenised invites, reminders, and per-survey statistics. |
79
+ | `sweepstake` | paid (giftable) | 1.0.0 | Office, pub and club sweepstakes for any event: picks, entry fee and prizes, entrants by name with paid ticks, and one recorded, repeatable draw revealed live on the page, then who has what and the money. |
64
80
  | `theme-roller` | paid | 1.1.3 | Make your own themes: start from any built-in theme, change its colours, fonts, spacing and borders with a live preview, and save it. Saved themes join the built-in ones everywhere a theme is chosen - the site, the admin, day and night, a region of a page. Needs Domma CMS 0.73 or later to use them. |
81
+ | `timeline` | paid (giftable) | 1.0.0 | Put events in date order: all at once (Sort) or one at a time into a growing timeline with lives (Place). Years, months or full dates, BC too; dates stay on the server until a card is placed. Shortcode `[timeline-game]`. |
82
+ | `treasure-hunt` | paid (giftable) | 1.0.1 | Hide 2-30 tokens across your pages and send visitors looking for them, in any order or one clue at a time. A progress chip follows players from page to page; finishers get a prize message and a code (one for all, or a unique code each). First-to-finish or fastest leaderboard. |
65
83
  | `waypoint-pro` | paid | 1.3.1 | Plan and track work: projects with their own workflows, issues on a board or in a list, a backlog planned into sprints with a burndown, and comments, mentions and watchers that tell the right people. |
66
- | `word-search` | paid (giftable) | 1.2.0 | Word searches on your site: type up to 40 words and the server lays out the letter grid (across, down, diagonal, backwards too if you like). Players drag, tap or use the keyboard to mark each word against the clock; wrong marks cost time, fastest full solve wins. Hints, personal best, Share, animations, export and import. |
84
+ | `word-search` | paid (giftable) | 1.2.1 | Word searches on your site: type up to 40 words and the server lays out the letter grid (across, down, diagonal, backwards too if you like). Players drag, tap or use the keyboard to mark each word against the clock; wrong marks cost time, fastest full solve wins. Hints, personal best, Share, animations, export and import. |
67
85
 
68
86
  Versions are read from `dcms-marketplace/plugins/*/plugin.json` (every plugin folder except `_lib`).
69
87
 
@@ -1460,7 +1478,7 @@ Domma CMS is extended by plugins: self-contained folders under `plugins/<slug>/`
1460
1478
  - **Current register (marketplace, 24 plugins)** - versions in the [catalogue table](#marketplace-catalogue).
1461
1479
  - Free (6, shipped with the engine): `blog`, `booking`, `feedback`, `mail-reader`, `security`, `shopping-cart`.
1462
1480
  - Paid (21): `analytics-pro`, `blog-pro`, `booking-pro`, `calendar`, `contacts-pro`, `data-transfer`, `docs`, `docs-pro`, `email-pro`, `garage`, `invoice`, `job-board`, `messages`, `mongodb-adapter`, `security-pro`, `seo-pro`, `shopping-cart-pro`, `social-media-pro`, `surveys`, `theme-roller`, `waypoint-pro`.
1463
- - Paid and giftable (4, the Games): `quiz`, `crossword`, `word-search`, `daily-word`.
1481
+ - Paid and giftable (22, the Games): `quiz`, `crossword`, `word-search`, `daily-word`, `personality-quiz`, `hangman`, `anagram`, `jigsaw`, `memory-pairs`, `treasure-hunt`, `prize-wheel`, `predictions`, `advent-calendar`, `scratch-card`, `timeline`, `picture-reveal`, `group-four`, `higher-lower`, `bingo`, `sliding-puzzle`, `map-guess`, `sweepstake`.
1464
1482
  - **Free-and-Pro pairs** - A Pro edition declares `supersedes` on its free sibling, so only one runs: Blog Pro → Blog, Email Pro → Mail Reader, Security Pro → Security, Contacts Pro → Contacts (built-in Tool takeover). Shopping Cart Pro and SEO Pro instead `requires` their free base (`shopping-cart`, the `seo` Tool).
1465
1483
  - **MongoDB-dependent plugins** - Email Pro ("Requires MongoDB" in its description), Data Transfer (moves collections between file and MongoDB storage) and MongoDB Adapter (managed-only: reads a `config/connections.json` the manager writes during provisioning). There is no manifest field for a Mongo requirement - it is stated only in the description text. Core already supports Mongo storage for free via `storage: {adapter: "mongodb"}` in a schema.
1466
1484
  - Where: design spec "Managed-only plugins"
@@ -2510,6 +2528,135 @@ All four share the engine's games library (`plugins/_lib/games`: plays, tokens,
2510
2528
  - **Rotation** (Quiz 1.5.0, Crossword 1.5.0, Word Search 1.2.0; engine 1.10.0) - **off by default**. A game can be **Queued** (never shown to the public until its turn). **Rotate** Off / Every day / Every week (a weekday), in a Rotation card above each list: at the site's midnight the next queued game opens and the last one rotation opened closes into an archive - still playable, its plays (`archive: true`) never on a board, place or goes-per-name. Idempotent: `lastRotatedDay` in the Tool's `data/rotation.json`, plus a check that no game was already opened by rotation that day, so a restart at 00:00:30 never rotates twice; a one-minute timer in the Tool, no cron. An empty queue leaves today's game up. Drag to reorder the queue; take one out. `[quiz rotate /]` (and `[crossword rotate]`, `[word-search rotate]`) shows today's game with the earlier ones below; `[<game>-leaderboard rotate /]` today's board. Notices `queue-low` (under three days queued) and `queue-empty`. Engine: `plugins/_lib/games/rotation.js` (pure rules + runner), `rotation-http.js` (`GET/PUT /rotation`, `PUT /queue`, `POST /approve`, `POST /unqueue`, `GET /content/status`, `GET /public/rotation`), `_lib/public/games/rotation.js`, `_lib/admin/games/rotation.js`; tests `tests/plugins/games-rotation.test.js`.
2511
2529
  - **Fresh games from Domma** (the Manager's Games content, off by default per site) - quizzes, crosswords and word searches written by Claude (Haiku) on the site's theme (or one picked at random each night when it has none) arrive through `POST /import` with `{source: 'domma-content', status}` as **drafts marked From Domma** (or queued, with the site's auto-publish), and the admins get a `content-ready` notice. The Rotation card's **Show only these** and **Approve all**; Approve / Take out of the queue in each row's menu. Daily Word 1.3.0: **Top up** on a word set (off by default) takes common words picked by the Manager (no Claude, never repeated within two years) into `pending` for **Approve all** / **Discard** in the editor or the list's menu (`POST /content/words`, `POST /sets/:id/pending`). Only while the Tool asks for it: Rotate on, or a set with Top up.
2512
2530
 
2531
+ ### More Games: Personality Quiz, Hangman, Anagram, Jigsaw, Memory Pairs, Treasure Hunt, Prize Wheel, Predictions
2532
+
2533
+ Tier: paid and giftable, closed source · Version: 1.0.0 each (2026-10-29) · Needs: Domma CMS 1.10.0 (the shared games library) · Sidebar: Tools > Games · Permissions: one each in the Games group (See / Manage). Each is its own Tool in `dcms-marketplace/plugins/<slug>/` with a user guide (`docs/guide.md`, in the admin Documentation), test plays from the Tool, export and import (`domma-<slug>` version 1, arriving as drafts), animations from `_lib/public/games/motion.*` (never under reduced motion) and all UI in domma-reactive. None joins `[games-leaderboards]` or rotation yet.
2534
+
2535
+ #### Personality Quiz (`personality-quiz`)
2536
+
2537
+ - "Which one are you?" quizzes with no wrong answers: 2-8 outcomes (description, picture, optional button to an offer or page) and single-choice questions whose answers give points to outcomes; ties go to the outcome higher in the list (drag to reorder).
2538
+ - The editor warns of an outcome no answer can reach; the server works out the result, and the points never reach the browser.
2539
+ - One question at a time with progress, Back and keys 1-8; name off, optional or required; Share gives the outcome title only.
2540
+ - Leads (per quiz, off by default): an email before the result, required or skippable, with a consent box worded Tool-wide (settings cog); consenting leads can go into Contacts. Leads screen with CSV; Stats with completion rate, outcome bars and each question's answer split.
2541
+ - `[personality-quiz id="..." /]`; notifications `new-lead` and `daily-summary` (both off by default); sidebar badge for new leads.
2542
+
2543
+ #### Hangman (`hangman`)
2544
+
2545
+ - Guess a hidden word or phrase letter by letter; spaces, hyphens and apostrophes are shown and never guessed. Words a go 1-20, wrong guesses 4-10, time limit, hints (one letter for a time penalty).
2546
+ - Random mode (the server draws each go's round) or Daily (the same words for everyone each day, one go per name per day; a played day's words cannot change).
2547
+ - The server holds the words: players get only blanks, and each word once it has ended. Board: words solved, then fewest wrong guesses, then time.
2548
+ - Drawing (settings cog): Classic stick figure, or Balloons that pop for family and children's sites.
2549
+ - `[hangman id="..." board="show|hide|only" /]`, `[hangman-leaderboard id="..." /]`; notices `top-score` (random games) and `running-low` (daily, 7 days or fewer left).
2550
+
2551
+ #### Anagram (`anagram`)
2552
+
2553
+ - Anagram rounds: the server scrambles each word (never the word itself, never a blocked word); any other real word of the same letters counts unless "Only the listed word counts" is on. Word list (ENABLE, 3-8 letters) on the server only.
2554
+ - Word ladders (3-6 letters): start to end one letter a step, each step a real word; every pair is measured on save and pairs with no ladder are refused. Score: rounds solved, then steps over the shortest, then time.
2555
+ - Random rounds each go, or daily (same rounds for everyone, one go a name a day, a board per day). Skip and hints with penalties, time limit, tap or type tiles, Shuffle.
2556
+ - `[anagram id="..." /]`, `[anagram-leaderboard id="..." /]`; notices `fastest` and `running-low`.
2557
+
2558
+ #### Jigsaw (`jigsaw`)
2559
+
2560
+ - Any picture in Media: Easy / Medium / Hard (rows and columns from the picture's shape) or 3x3 to 12x12; classic pieces (seeded tabs and blanks, New cuts) or square; optional turned pieces and a ghost picture. Live preview in the editor.
2561
+ - The server cuts each play's pieces into a shuffled, masked WebP sprite (sharp) under opaque ids, so a piece's place is revealed only once it is placed; drops are capped per piece.
2562
+ - Drag (mouse or touch), tap then tap, or keyboard (Tab, arrows, Enter, R); full screen; fits a 390px phone. Optional wrong-piece seconds, time limit, hints.
2563
+ - `[jigsaw id="..." /]`, `[jigsaw-leaderboard id="..." /]`; notices `fastest` and `picture-missing`.
2564
+
2565
+ #### Memory Pairs (`memory-pairs`)
2566
+
2567
+ - Pairs: the same picture twice, a picture and its words, or two texts; 4 to 24 pairs. Card backs in the site colour, a pattern or a picture.
2568
+ - The server deals a fresh shuffle per play and sends a card's face only when it is turned over; at most two unmatched cards are up. Fewest moves wins, then time.
2569
+ - 3D card flip (instant for reduced motion), keyboard and touch, hints (peek one pair), time limit.
2570
+ - `[memory-pairs id="..." /]`, `[memory-pairs-leaderboard id="..." /]`; notices `fastest` and `perfect` (off by default).
2571
+
2572
+ #### Treasure Hunt (`treasure-hunt`)
2573
+
2574
+ - 2-30 tokens, each with its own `[treasure-token hunt="..." token="..." /]` to paste into a page; the editor shows which pages and blocks hold each token and warns of any placed nowhere.
2575
+ - Any order, or in order (one clue at a time; a token found early says "not yet"). Tokens show only while the hunt is open or to a player of it; no public route lists them.
2576
+ - A progress chip follows players page to page (corner and on/off in the settings cog). Prize message, optional link, and a code: one for all or a unique code each from a pasted list, never handed out twice.
2577
+ - `[treasure-hunt hunt="..." /]`, `[treasure-hunt-leaderboard hunt="..." /]` (first to finish or fastest); finishers CSV; notices `finished` and `codes-low`.
2578
+
2579
+ #### Prize Wheel (`prize-wheel`)
2580
+
2581
+ - A wheel or a scratch card with 3-12 prizes, each with a chance, a stock and a reward: nothing, a message, a shared code, a unique code from a pasted list, or a single-use Shopping Cart Pro discount code (percent or amount, minimum spend, days it lasts) made through Cart Pro's codes door (0.3.2), so it works at checkout at once.
2582
+ - The server draws every prize (crypto random, weighted, stock and codes checked in one lock) before the wheel turns; a prize that has run out is never drawn.
2583
+ - Entry by email with consent (worded in the settings cog), optional name, spins per email a day or ever, a soft per-browser limit, a daily cap, opens and closes; winners can be emailed their code.
2584
+ - Entries screen (Cart Pro codes used or not, Redeemed ticks, CSV), test spins that use no stock. `[prize-wheel id="..." /]`; notices `winner` (off by default) and `stock-low`.
2585
+
2586
+ #### Predictions (`predictions`)
2587
+
2588
+ - A league of rounds: fixtures (predict the score) and questions (2-8 answers). Paste a week of fixtures at once ("Home v Away, 2026-11-01 15:00"). Predictions lock at kick-off or the round deadline, kept by the server; nobody sees anyone else's picks before then.
2589
+ - Members join with a unique name, optional email and a sign-in code shown once (and emailed) for other devices; optional approval. Only hashes of keys and codes are stored.
2590
+ - Results a round at a time; points and the table are worked out afresh from every result (exact score, right result, optional goal difference bonus, question points, jokers that double a round), with movement arrows. Void items.
2591
+ - `[predictions league="..." /]`, `[predictions-table league="..." round="..." /]`; badge for results waiting; notices `results-due` and `new-member`.
2592
+
2593
+ ### Ten more Games: Advent Calendar, Scratch Card, Timeline, Picture Reveal, Group Four, Higher or Lower, Bingo, Sliding Puzzle, Map Guess, Sweepstake
2594
+
2595
+ Tier: paid and giftable, closed source · Version: 1.0.0 each (2026-11-01) · Needs: Domma CMS 1.10.0 · Sidebar: Tools > Games · Permissions: one each in the Games group (See / Manage; anything that holds answers needs Manage). Built the same way as the eight before them: own Tool in `dcms-marketplace/plugins/<slug>/`, user guide in the admin Documentation, test plays, export and import (`domma-<slug>` version 1, as drafts, nothing derived carried over), motion from `_lib/public/games/motion.*`, domma-reactive throughout, goes-per-name checked and started in one turn per game and name. None joins `[games-leaderboards]` or rotation yet. The same release fixes Prize Wheel 1.0.1 (spins a day per connection, salted daily key, default 20) and Jigsaw 1.0.1 (the goes-per-name race).
2596
+
2597
+ #### Advent Calendar (`advent-calendar`)
2598
+
2599
+ - 1 to 31 doors, one opening each midnight (site time) from a start day: an advent calendar or a countdown. Doors in order or shuffled; classic doors, baubles or gift tags in theme colours; catch-up on or off; no name (a browser key) or a name first.
2600
+ - Behind a door: heading, Markdown message (cleaned on the server), Media picture, link, a link to another Game's page, and a code - shared, unique from a pasted list, or a single-use Shopping Cart Pro code (the door still opens without Cart Pro).
2601
+ - The server never sends a door before its day. One code per visitor per door, and at most N per connection per door per day (settings cog, default 3; only a salted hash is kept). The editor warns on code doors that ask for no name.
2602
+ - Admin: door-by-door editor with live preview, Preview as day N (records nothing, TEST codes), Opens (per door, codes given and left, CSV). `[advent-calendar id="..." /]`; notices `daily-summary` (off by default) and `codes-low`; badge: doors running low on codes.
2603
+
2604
+ #### Scratch Card (`scratch-card`)
2605
+
2606
+ - Prize Wheel's model as a card: prizes and "no win" rows with odds and stock; a message, shared code, unique code or single-use Cart Pro code; email, name and consent capture; limits per email, browser and day; winner emails.
2607
+ - Reveal a message, or match three of nine symbols (laid out on the server for the prize drawn; a losing grid never has three alike). Cover colour, finish, picture, words, reveal-at percentage; confetti on a win.
2608
+ - The server draws and takes the stock under the lock at the deal and sends only a key; the result goes out when scratching starts. Cards a day per connection (default 20). A Shop code made for a deal that then fails is taken back.
2609
+ - `[scratch-card id="..." /]`; notices `winner` (off by default) and `stock-low`; badge: prizes running low.
2610
+
2611
+ #### Timeline (`timeline`)
2612
+
2613
+ - Events with a title, a date (year, month and year, or full date; BC too), optional words and picture; paste "1969 - The first Moon landing" lines. Sort (every card at once; points for right places plus the longest run) or Place (one at a time; a wrong place costs a life).
2614
+ - The server deals N events a go in a fresh shuffle under random ids and keeps every date; each card carries its own copy of the event, so later edits never change old results. Show dates as placed (the result marks the player's own order right or wrong), at the end (the full answer), or never.
2615
+ - Drag by mouse or finger, or keyboard (Space, arrows, Space), announced. The editor warns when a picture's address looks like it holds a year.
2616
+ - `[timeline-game id="..." /]`, `[timeline-game-leaderboard id="..." /]` (plain `[timeline]` stays the CMS's own display); notices `top` and `perfect`.
2617
+
2618
+ #### Picture Reveal (`picture-reveal`)
2619
+
2620
+ - A round of up to 30 Media pictures, each with an answer and other accepted answers (case, accents, punctuation and a leading "the" ignored; typo setting). Pixelated, blurred, zoomed (with a focus point) or tiles; 2-8 stages, points by stage, time as tiebreak.
2621
+ - The server draws every stage with sharp onto a fixed 800x600 canvas, metadata stripped, through a per-play route; the whole picture only after it is guessed or given up. Each play keeps its own copy of its pictures and answers, so swapping pictures never reaches an old play.
2622
+ - `[picture-reveal id="..." /]`, `[picture-reveal-leaderboard id="..." /]`; notices `top-score` and `picture-missing`.
2623
+
2624
+ #### Group Four (`group-four`)
2625
+
2626
+ - Sixteen tiles, four groups of four, each with a name and a difficulty (Gentle, Steady, Tricky, Devious - renamable in the cog, theme colours). Mistakes allowed, a close-call hint, shuffle.
2627
+ - Single puzzles, or a daily set (same deal for everyone, streaks, archive, calendar for Manage, played days locked; each set's tile order comes from a secret key on the server). A failed single puzzle shows only the groups found.
2628
+ - `[group-four id="..." /]`, `[group-four-leaderboard id="..." /]`; notices `top-score` and `running-low`; Share as difficulty digits.
2629
+
2630
+ #### Higher or Lower (`higher-lower`)
2631
+
2632
+ - A deck of named numbers shown as pounds, a year (BC too), a count, a percent or plain, with words after; by hand, pasted lines, CSV in and out, or "Fill from the shop" (Shopping Cart products in pounds, read only).
2633
+ - The server deals each go and reveals a number only after the guess; pictures by random key. Lives 1-5, equal numbers rule, seconds per guess (the reveal pause is added to the next card's clock).
2634
+ - `[higher-lower id="..." /]`, `[higher-lower-leaderboard id="..." /]`; notice `best-streak`.
2635
+
2636
+ #### Bingo (`bingo`)
2637
+
2638
+ - 75-ball, 90-ball UK tickets, or word and picture cards (enough items that cards differ). Live: caller in the admin (draw, auto-draw, undo, new game, projector view), players join on phones and get a server-dealt card; line, two lines and full house claims checked against the real calls in arrival order. Calls are picked at the moment they are made.
2639
+ - Late joiners: calls made before a player joined are crossed through and never count for their claims, or late joining is refused (per game). A take-back bumps a revision so phones reload the calls. Prizes cannot change once calling has started.
2640
+ - Paper: up to 500 numbered unique cards, a print window and a card checker. `[bingo id="..." /]`, `[bingo-caller id="..." /]`; notice `claim`; badge: games being called (live dot).
2641
+
2642
+ #### Sliding Puzzle (`sliding-puzzle`)
2643
+
2644
+ - 3x3 to 6x6, numbers or a Media picture (corner numbers, Peek). Same board for everyone, a new board each go, or a daily puzzle from a secret on the server; always solvable, never nearly solved.
2645
+ - Every move is checked against the server's board; only a board the server solved finishes a play. Only plays on the current board count. Fewest moves then time, or the other way round.
2646
+ - `[sliding-puzzle id="..." /]`, `[sliding-puzzle-leaderboard id="..." /]`; notices `best` and `picture-missing`.
2647
+
2648
+ #### Map Guess (`map-guess`)
2649
+
2650
+ - Photos drawn from a pool; players drop a pin; up to 1,000 points a photo by distance (three curves). Built-in world map (Natural Earth, public domain; great-circle distance) or the admin's own map picture with a scale (typed or measured by two clicks; a positive scale is required).
2651
+ - Every photo and map is re-encoded with GPS and all metadata removed; photos live in the Tool (`data/images`, a content path) and reach the player only through the play. Answers never before the guess. Pan, pinch, wheel and keyboard.
2652
+ - `[map-guess id="..." /]`, `[map-guess-leaderboard id="..." /]`; notice `top-score`.
2653
+
2654
+ #### Sweepstake (`sweepstake`)
2655
+
2656
+ - Picks (paste or a ready-made list; group, odds, emoji or picture), entry fee and currency (shown, never taken), up to 10 prizes (% of pot, fixed, or not money). Entrants by name on the page (60 joins per 10 minutes per connection) or added by the organiser; paid ticks.
2657
+ - One draw by the server from a 32-byte random seed, recorded with the names as they were and repeatable; renames after the draw are shown publicly; resets need a reason and every earlier draw stays on the page. Uneven numbers: picks each, leftovers undrawn or dealt again, shared picks or a waiting list.
2658
+ - `[sweepstake id="..." /]`, `[sweepstake-table id="..." /]`; notices `draw-done`, `winner-set`, `ready-to-draw`; badge: unpaid entrants.
2659
+
2513
2660
  ### Other plugin directories
2514
2661
 
2515
2662
  No other directories exist in `dcms-marketplace/plugins/` beyond the plugins above and `_lib`. `_lib` is not a plugin (skipped by plugin discovery): it holds the shared mail core used by Mail Reader and Email Pro, plus shared `dataStore.js` and `schemaSync.js`.
@@ -2609,6 +2756,10 @@ Later changes to these features are in the CHANGELOG (for example 0.92.1: row-le
2609
2756
 
2610
2757
  ### Plugins & the Marketplace platform
2611
2758
 
2759
+ - A Halloween or Christmas page: a Treasure Hunt across five pages with a Prize Wheel at the end, and a Personality Quiz collecting leads.
2760
+ - A Christmas countdown: an Advent Calendar of 24 doors with a Shop code behind some, and a Scratch Card on the last day.
2761
+ - A quiz night: Bingo on the projector with `[bingo-caller]`, players on their phones, and a Sweepstake for the big match.
2762
+ - A football club's season: a Predictions league with a week of fixtures pasted in, and the table on the home page.
2612
2763
  - A games page: a Daily Word set with a month of answers, a Word Search and a Quiz on one page, with `[games-leaderboards]` below them; hints with a penalty, and moving a game to another site with Export and Import.
2613
2764
  - A page that never needs editing: queue a week of quizzes, switch Rotate on, put `[quiz rotate /]` on the page, and approve Domma's fresh quizzes as they arrive.
2614
2765
  - Gifting a Tool from the Manager: gift a Game for 30 days, extend it, make it for good, and end it.