domma-cms 0.76.0 → 0.77.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 (88) hide show
  1. package/CLAUDE.md +1 -1
  2. package/admin/js/api.js +1 -1
  3. package/admin/js/app.js +2 -2
  4. package/admin/js/lib/action-editor-arrange.js +1 -0
  5. package/admin/js/lib/api-endpoint-editor-arrange.js +2 -0
  6. package/admin/js/lib/block-editor-arrange.js +2 -0
  7. package/admin/js/lib/collection-editor-arrange.js +3 -0
  8. package/admin/js/lib/collection-entries-arrange.js +1 -0
  9. package/admin/js/lib/component-editor-arrange.js +27 -0
  10. package/admin/js/lib/context-menu-editor-arrange.js +1 -0
  11. package/admin/js/lib/dashboard-arrange.js +1 -0
  12. package/admin/js/lib/form-editor-arrange.js +1 -0
  13. package/admin/js/lib/form-submissions-arrange.js +2 -0
  14. package/admin/js/lib/menu-editor-arrange.js +2 -0
  15. package/admin/js/lib/page-editor-arrange.js +1 -0
  16. package/admin/js/lib/plugin-code-arrange.js +1 -0
  17. package/admin/js/lib/project-page-arrange.js +1 -0
  18. package/admin/js/lib/role-editor-arrange.js +3 -0
  19. package/admin/js/lib/user-editor-arrange.js +1 -0
  20. package/admin/js/lib/view-editor-arrange.js +14 -0
  21. package/admin/js/templates/action-editor.html +223 -147
  22. package/admin/js/templates/api-endpoint-editor.html +172 -117
  23. package/admin/js/templates/block-editor.html +194 -203
  24. package/admin/js/templates/collection-editor.html +191 -113
  25. package/admin/js/templates/collection-entries.html +99 -36
  26. package/admin/js/templates/component-editor.html +128 -126
  27. package/admin/js/templates/context-menu-editor.html +208 -148
  28. package/admin/js/templates/dashboard.html +184 -22
  29. package/admin/js/templates/form-editor.html +41 -26
  30. package/admin/js/templates/form-submissions.html +78 -26
  31. package/admin/js/templates/menu-editor.html +57 -17
  32. package/admin/js/templates/menu-locations.html +54 -11
  33. package/admin/js/templates/page-editor.html +47 -26
  34. package/admin/js/templates/plugin-code.html +91 -73
  35. package/admin/js/templates/project-detail.html +83 -145
  36. package/admin/js/templates/project-settings.html +88 -53
  37. package/admin/js/templates/role-editor.html +158 -83
  38. package/admin/js/templates/user-editor.html +150 -14
  39. package/admin/js/templates/view-editor.html +203 -180
  40. package/admin/js/templates/view-preview.html +45 -45
  41. package/admin/js/views/action-editor.js +7 -1
  42. package/admin/js/views/api-endpoint-editor.js +2 -3
  43. package/admin/js/views/block-editor.js +14 -8
  44. package/admin/js/views/collection-editor.js +64 -5
  45. package/admin/js/views/collection-entries.js +50 -1
  46. package/admin/js/views/component-editor.js +2 -28
  47. package/admin/js/views/context-menu-editor.js +54 -55
  48. package/admin/js/views/dashboard.js +7 -1
  49. package/admin/js/views/form-editor.js +7 -7
  50. package/admin/js/views/form-submissions.js +11 -1
  51. package/admin/js/views/index.js +1 -1
  52. package/admin/js/views/login.js +2 -2
  53. package/admin/js/views/menu-editor.js +21 -43
  54. package/admin/js/views/menu-locations.js +16 -1
  55. package/admin/js/views/page-editor.js +26 -26
  56. package/admin/js/views/plugin-code.js +23 -4
  57. package/admin/js/views/project-detail.js +9 -1
  58. package/admin/js/views/project-settings.js +1 -1
  59. package/admin/js/views/role-editor.js +11 -3
  60. package/admin/js/views/user-editor.js +1 -1
  61. package/admin/js/views/view-editor.js +1 -1
  62. package/admin/js/views/view-preview.js +1 -1
  63. package/package.json +1 -1
  64. package/server/routes/api/dashboard.js +32 -4
  65. package/server/routes/api/forms.js +104 -13
  66. package/server/routes/api/users.js +12 -2
  67. package/server/routes/api/views.js +55 -1
  68. package/server/services/components.js +9 -0
  69. package/server/services/users.js +2 -2
  70. package/server/services/views.js +14 -0
  71. package/admin/js/templates/dashboard/activity-feed.html +0 -3
  72. package/admin/js/templates/dashboard/cache.html +0 -32
  73. package/admin/js/templates/dashboard/health-detail.html +0 -2
  74. package/admin/js/templates/dashboard/journeys.html +0 -17
  75. package/admin/js/templates/dashboard/kpi-strip.html +0 -34
  76. package/admin/js/templates/dashboard/spike-feed.html +0 -3
  77. package/admin/js/templates/dashboard/top-pages.html +0 -3
  78. package/admin/js/templates/dashboard/traffic-chart.html +0 -3
  79. package/admin/js/views/block-editor-enhance.js +0 -1
  80. package/admin/js/views/dashboard/lib/escape.js +0 -1
  81. package/admin/js/views/dashboard/widgets/activity-feed.js +0 -1
  82. package/admin/js/views/dashboard/widgets/cache.js +0 -1
  83. package/admin/js/views/dashboard/widgets/health-detail.js +0 -1
  84. package/admin/js/views/dashboard/widgets/journeys.js +0 -1
  85. package/admin/js/views/dashboard/widgets/kpi-strip.js +0 -1
  86. package/admin/js/views/dashboard/widgets/spike-feed.js +0 -6
  87. package/admin/js/views/dashboard/widgets/top-pages.js +0 -1
  88. package/admin/js/views/dashboard/widgets/traffic-chart.js +0 -1
@@ -1,18 +1,18 @@
1
- import{api as L}from"../api.js";import{CardBuilder as Re}from"../lib/card-builder.js";import{TimelineBuilder as Be}from"../lib/timeline-builder.js";import{attachEditorKeybindings as Ie,createToolbar as He,insertAtCursor as $e}from"../lib/markdown-toolbar.js";import{EffectsBuilder as Ue}from"../lib/effects-builder.js";import{attachContextMenu as qe}from"../lib/shortcode-context-menu.js";import{registerCustomInserters as Oe}from"../lib/shortcode-insert.js";import{populateThemeSelect as Ve}from"../lib/themes.js";import{createFoldingManager as We}from"../lib/editor-folding.js";import{openScribeComposer as Ye}from"../lib/scribe-composer.js";import{openCrudTutorial as Ge}from"../lib/crud-tutorial.js";function je(){const e=E.slideover({title:"Editor Reference",size:"md",position:"right"}),A="background:var(--dm-background-alt,#1a1a2e);padding:.2rem .4rem;border-radius:3px;font-size:.85em;font-family:monospace;",v="margin:1rem 0 .5rem;font-size:1rem;";function s(c){const r=document.createElement("code");return r.style.cssText=A,r.textContent=c,r}function b(c){const r=document.createElement("h3");return r.style.cssText=v,r.textContent=c,r}const V=document.createElement("div");V.style.cssText="padding:1rem;";const W=document.createElement("div");W.className="tabs";const Y=document.createElement("div");Y.className="tab-list",["Basics","Layout","Components","Data","Advanced"].forEach((c,r)=>{const n=document.createElement("button");n.className="tab-item"+(r===0?" active":""),n.textContent=c,Y.appendChild(n)});const i=document.createElement("div");i.className="tab-content";const P="display:flex;flex-direction:column;gap:1rem;",B=document.createElement("div");B.className="tab-panel active",B.style.cssText=P;const H=document.createElement("div");H.className="tab-panel",H.style.cssText=P;const z=document.createElement("div");z.className="tab-panel",z.style.cssText=P;const F=document.createElement("div");F.className="tab-panel",F.style.cssText=P;const Z=document.createElement("div");Z.className="tab-panel",Z.style.cssText=P,i.appendChild(B),i.appendChild(H),i.appendChild(z),i.appendChild(F),i.appendChild(Z),W.appendChild(Y),W.appendChild(i),V.appendChild(W);const K=document.createElement("div");K.appendChild(b("Markdown Basics"));const M=document.createElement("table");M.style.cssText="width:100%;border-collapse:collapse;font-size:.9em;";const g=document.createElement("thead"),C=document.createElement("tr");["Syntax","Result"].forEach(c=>{const r=document.createElement("th");r.style.cssText="text-align:left;padding:.4rem .5rem;border-bottom:1px solid var(--dm-border,#333);",r.textContent=c,C.appendChild(r)}),g.appendChild(C),M.appendChild(g);const q=document.createElement("tbody");[["**bold**","bold (rendered bold)"],["_italic_","italic (rendered italic)"],["## Heading","Heading (h2)"],["[text](url)","Link"],["![alt](url)","Image"],["- item","Bullet list"],["`code`","Inline code"],["---","Divider"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.35rem .5rem;vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.35rem .5rem;vertical-align:top;color:var(--dm-text-muted,#aaa);font-size:.85em;",o.textContent=r,n.appendChild(a),n.appendChild(o),q.appendChild(n)}),M.appendChild(q),K.appendChild(M),B.appendChild(K);const x=document.createElement("div");x.appendChild(b("Grid & Columns"));function f(c){const r=document.createElement("p");return r.style.cssText="margin:.3rem 0 .6rem;font-size:.82em;color:var(--dm-text-muted,#aaa);",r.textContent=c,r}function l(c,r,n){const a=document.createElement("p");a.style.cssText="margin:.75rem 0 .25rem;font-size:.85em;font-weight:600;",a.textContent=c;const o=document.createElement("div");o.style.cssText="position:relative;";const xe=document.createElement("pre");xe.style.cssText=A+"display:block;padding:.5rem 2rem .5rem .75rem;white-space:pre;overflow-x:auto;margin:0;",xe.textContent=r;const ee=document.createElement("button");ee.type="button",ee.title="Copy code",ee.style.cssText="position:absolute;top:.3rem;right:.3rem;background:none;border:none;cursor:pointer;opacity:.45;padding:.15rem;line-height:1;color:inherit;",ee.addEventListener("mouseenter",()=>{ee.style.opacity="1"}),ee.addEventListener("mouseleave",()=>{ee.style.opacity=".45"});const Pe=document.createElement("span");Pe.setAttribute("data-icon","copy"),ee.appendChild(Pe),ee.addEventListener("click",()=>{const ke=document.createElement("textarea");ke.value=r,ke.style.cssText="position:fixed;opacity:0;",document.body.appendChild(ke),ke.select(),document.execCommand("copy"),ke.remove(),E.toast("Copied!",{type:"success",duration:1200})}),o.appendChild(xe),o.appendChild(ee);const Se=document.createDocumentFragment();return Se.appendChild(a),Se.appendChild(o),n&&Se.appendChild(f(n)),Se}const w=document.createElement("table");w.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['cols="N"',"[grid] only","Number of columns (1-12)"],['gap="N"',"[grid], [row]","Gap between columns/rows (1-6)"],['span="N"',"[col] only","How many columns this cell spans"],['fullwidth="true"',"[grid] only","Break out of page container to span full viewport"],['class="x"',"all","Add extra CSS classes"]].forEach(([c,r,n])=>{const a=document.createElement("tr");[c,r,n].forEach((o,xe)=>{const ee=document.createElement("td");ee.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",xe===0?ee.appendChild(s(c)):(ee.style.color="var(--dm-text-muted,#aaa)",ee.textContent=o),a.appendChild(ee)}),w.appendChild(a)}),x.appendChild(w),x.appendChild(l("Equal columns",`[grid cols="3" gap="4"]
1
+ import{api as N}from"../api.js";import{CardBuilder as nt}from"../lib/card-builder.js";import{TimelineBuilder as ot}from"../lib/timeline-builder.js";import{attachEditorKeybindings as Ge,createToolbar as it,insertAtCursor as at}from"../lib/markdown-toolbar.js";import{EffectsBuilder as lt}from"../lib/effects-builder.js";import{attachContextMenu as rt}from"../lib/shortcode-context-menu.js";import{registerCustomInserters as dt}from"../lib/shortcode-insert.js";import{populateThemeSelect as st}from"../lib/themes.js";import{createFoldingManager as ct}from"../lib/editor-folding.js";import{openScribeComposer as pt}from"../lib/scribe-composer.js";import{openCrudTutorial as mt}from"../lib/crud-tutorial.js";import{addBannerAction as Ye}from"../lib/plugin-chrome.js";import{helpPopovers as ut}from"../lib/help-popover.js";import{openMenuAt as Ke}from"../lib/tool-kit.js";import{SCREEN as ht,bannerSection as ft,draftIsStale as gt,draftKey as bt,makeDraft as vt,problems as Je,readDraft as yt,snapshot as qe}from"../lib/page-editor-arrange.js";function Xe(){const e=E.slideover({title:"Editor Reference",size:"md",position:"right"}),T="background:var(--dm-background-alt);padding:.2rem .4rem;border-radius:3px;font-size:.85em;font-family:monospace;",A="margin:1rem 0 .5rem;font-size:1rem;";function p(c){const r=document.createElement("code");return r.style.cssText=T,r.textContent=c,r}function m(c){const r=document.createElement("h3");return r.style.cssText=A,r.textContent=c,r}const U=document.createElement("div");U.style.cssText="padding:1rem;";const V=document.createElement("div");V.className="tabs";const F=document.createElement("div");F.className="tab-list",["Basics","Layout","Components","Data","Advanced"].forEach((c,r)=>{const o=document.createElement("button");o.className="tab-item"+(r===0?" active":""),o.textContent=c,F.appendChild(o)});const u=document.createElement("div");u.className="tab-content";const v="display:flex;flex-direction:column;gap:1rem;",x=document.createElement("div");x.className="tab-panel active",x.style.cssText=v;const G=document.createElement("div");G.className="tab-panel",G.style.cssText=v;const P=document.createElement("div");P.className="tab-panel",P.style.cssText=v;const Y=document.createElement("div");Y.className="tab-panel",Y.style.cssText=v;const oe=document.createElement("div");oe.className="tab-panel",oe.style.cssText=v,u.appendChild(x),u.appendChild(G),u.appendChild(P),u.appendChild(Y),u.appendChild(oe),V.appendChild(F),V.appendChild(u),U.appendChild(V);const h=document.createElement("div");h.appendChild(m("Markdown Basics"));const ae=document.createElement("table");ae.style.cssText="width:100%;border-collapse:collapse;font-size:.9em;";const L=document.createElement("thead"),k=document.createElement("tr");["Syntax","Result"].forEach(c=>{const r=document.createElement("th");r.style.cssText="text-align:left;padding:.4rem .5rem;border-bottom:1px solid var(--dm-border);",r.textContent=c,k.appendChild(r)}),L.appendChild(k),ae.appendChild(L);const H=document.createElement("tbody");[["**bold**","bold (rendered bold)"],["_italic_","italic (rendered italic)"],["## Heading","Heading (h2)"],["[text](url)","Link"],["![alt](url)","Image"],["- item","Bullet list"],["`code`","Inline code"],["---","Divider"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.35rem .5rem;vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.35rem .5rem;vertical-align:top;color:var(--dm-text-muted);font-size:.85em;",n.textContent=r,o.appendChild(i),o.appendChild(n),H.appendChild(o)}),ae.appendChild(H),h.appendChild(ae),x.appendChild(h);const B=document.createElement("div");B.appendChild(m("Grid & Columns"));function f(c){const r=document.createElement("p");return r.style.cssText="margin:.3rem 0 .6rem;font-size:.82em;color:var(--dm-text-muted);",r.textContent=c,r}function l(c,r,o){const i=document.createElement("p");i.style.cssText="margin:.75rem 0 .25rem;font-size:.85em;font-weight:600;",i.textContent=c;const n=document.createElement("div");n.style.cssText="position:relative;";const Re=document.createElement("pre");Re.style.cssText=T+"display:block;padding:.5rem 2rem .5rem .75rem;white-space:pre;overflow-x:auto;margin:0;",Re.textContent=r;const Z=document.createElement("button");Z.type="button",Z.title="Copy code",Z.style.cssText="position:absolute;top:.3rem;right:.3rem;background:none;border:none;cursor:pointer;opacity:.45;padding:.15rem;line-height:1;color:inherit;",Z.addEventListener("mouseenter",()=>{Z.style.opacity="1"}),Z.addEventListener("mouseleave",()=>{Z.style.opacity=".45"});const Le=document.createElement("span");Le.setAttribute("data-icon","copy"),Z.appendChild(Le),Z.addEventListener("click",()=>{const a=document.createElement("textarea");a.value=r,a.style.cssText="position:fixed;opacity:0;",document.body.appendChild(a),a.select(),document.execCommand("copy"),a.remove(),E.toast("Copied!",{type:"success",duration:1200})}),n.appendChild(Re),n.appendChild(Z);const t=document.createDocumentFragment();return t.appendChild(i),t.appendChild(n),o&&t.appendChild(f(o)),t}const W=document.createElement("table");W.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['cols="N"',"[grid] only","Number of columns (1-12)"],['gap="N"',"[grid], [row]","Gap between columns/rows (1-6)"],['span="N"',"[col] only","How many columns this cell spans"],['fullwidth="true"',"[grid] only","Break out of page container to span full viewport"],['class="x"',"all","Add extra CSS classes"]].forEach(([c,r,o])=>{const i=document.createElement("tr");[c,r,o].forEach((n,Re)=>{const Z=document.createElement("td");Z.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",Re===0?Z.appendChild(p(c)):(Z.style.color="var(--dm-text-muted)",Z.textContent=n),i.appendChild(Z)}),W.appendChild(i)}),B.appendChild(W),B.appendChild(l("Equal columns",`[grid cols="3" gap="4"]
2
2
  [col]One[/col]
3
3
  [col]Two[/col]
4
4
  [col]Three[/col]
5
- [/grid]`,"cols sets the track count; each [col] fills one track.")),x.appendChild(l("Column spanning (12-col base)",`[grid cols="12" gap="3"]
5
+ [/grid]`,"cols sets the track count; each [col] fills one track.")),B.appendChild(l("Column spanning (12-col base)",`[grid cols="12" gap="3"]
6
6
  [col span="8"]Main content[/col]
7
7
  [col span="4"]Sidebar[/col]
8
- [/grid]`,"span values must add up to cols. Common splits: 8/4, 6/6, 9/3.")),x.appendChild(l("Row (flexbox, equal-width)",`[row gap="4"]
8
+ [/grid]`,"span values must add up to cols. Common splits: 8/4, 6/6, 9/3.")),B.appendChild(l("Row (flexbox, equal-width)",`[row gap="4"]
9
9
  [col]Left[/col]
10
10
  [col]Right[/col]
11
- [/row]`,"Use [row] when you want equal-width columns without specifying a count.")),x.appendChild(l("Row with staggered reveal",`[row reveal reveal-mode="stagger" reveal-animation="slide-up" reveal-duration="400" reveal-stagger="60" reveal-delay="0" reveal-direction="ltr"]
11
+ [/row]`,"Use [row] when you want equal-width columns without specifying a count.")),B.appendChild(l("Row with staggered reveal",`[row reveal reveal-mode="stagger" reveal-animation="slide-up" reveal-duration="400" reveal-stagger="60" reveal-delay="0" reveal-direction="ltr"]
12
12
  [col]First[/col]
13
13
  [col]Second[/col]
14
14
  [col]Third[/col]
15
- [/row]`,'Columns reveal one by one as the row scrolls into view. reveal-direction="rtl" reverses the order. Animations: slide-up, slide-down, slide-left, slide-right, fade, zoom, flip.')),x.appendChild(l("Card in a grid",`[grid cols="3" gap="4"]
15
+ [/row]`,'Columns reveal one by one as the row scrolls into view. reveal-direction="rtl" reverses the order. Animations: slide-up, slide-down, slide-left, slide-right, fade, zoom, flip.')),B.appendChild(l("Card in a grid",`[grid cols="3" gap="4"]
16
16
  [col]
17
17
  [card title="One"]Content[/card]
18
18
  [/col]
@@ -22,21 +22,21 @@ import{api as L}from"../api.js";import{CardBuilder as Re}from"../lib/card-builde
22
22
  [col]
23
23
  [card title="Three"]Content[/card]
24
24
  [/col]
25
- [/grid]`,null)),H.appendChild(x);const O=document.createElement("div");O.appendChild(b("Cards")),O.appendChild(l("Basic card",`[card title="Optional Title"]
25
+ [/grid]`,null)),G.appendChild(B);const q=document.createElement("div");q.appendChild(m("Cards")),q.appendChild(l("Basic card",`[card title="Optional Title"]
26
26
  Markdown **works** here.
27
- [/card]`,"Omit title for a card with no header.")),O.appendChild(l("Icon - inline (default)",`[card title="Feature" icon="star"]
27
+ [/card]`,"Omit title for a card with no header.")),q.appendChild(l("Icon - inline (default)",`[card title="Feature" icon="star"]
28
28
  Icon sits left of the title in a flex row.
29
- [/card]`,"icon accepts any Domma icon name. Default layout when icon is set.")),O.appendChild(l("Icon - stacked (centred)",`[card title="Feature" icon="star" icon-layout="stacked" hover]
29
+ [/card]`,"icon accepts any Domma icon name. Default layout when icon is set.")),q.appendChild(l("Icon - stacked (centred)",`[card title="Feature" icon="star" icon-layout="stacked" hover]
30
30
  Icon is centred above the title. Great for feature tiles.
31
- [/card]`,'icon-layout="stacked" centres the icon above the title. Combine with hover for a lift effect.')),O.appendChild(l("Icon with subtitle",`[card title="Feature" subtitle="Tagline here" icon="star" icon-layout="stacked"]
31
+ [/card]`,'icon-layout="stacked" centres the icon above the title. Combine with hover for a lift effect.')),q.appendChild(l("Icon with subtitle",`[card title="Feature" subtitle="Tagline here" icon="star" icon-layout="stacked"]
32
32
  Body content.
33
- [/card]`,"subtitle adds a secondary line beneath the title in both layouts.")),O.appendChild(l("Collapsible card",`[card title="Click to expand" collapsible="true"]
33
+ [/card]`,"subtitle adds a secondary line beneath the title in both layouts.")),q.appendChild(l("Collapsible card",`[card title="Click to expand" collapsible="true"]
34
34
  Hidden by default.
35
- [/card]`,null)),O.appendChild(l("Full attribute reference",`[card title="Title" subtitle="Sub" icon="star" icon-layout="stacked"
35
+ [/card]`,null)),q.appendChild(l("Full attribute reference",`[card title="Title" subtitle="Sub" icon="star" icon-layout="stacked"
36
36
  variant="primary" hover footer="Footer text"
37
37
  collapsible="true" class="extra" id="my-card"]
38
38
  Body content.
39
- [/card]`,'All attributes are optional. variant accepts "primary". icon-layout accepts "inline" (default) or "stacked".')),O.appendChild(l("Rich header / footer sub-tags",`[card]
39
+ [/card]`,'All attributes are optional. variant accepts "primary". icon-layout accepts "inline" (default) or "stacked".')),q.appendChild(l("Rich header / footer sub-tags",`[card]
40
40
  [header]
41
41
  ### Custom Title with **bold** and [a link](/about)
42
42
  [/header]
@@ -46,47 +46,47 @@ Body content here.
46
46
  [footer]
47
47
  [Read more](/about) | [icon name="arrow-right" /]
48
48
  [/footer]
49
- [/card]`,"Use [header] and [footer] sub-tags for Markdown-rendered header/footer regions. Sub-tags override the title/subtitle/icon and footer attributes when both are present.")),z.appendChild(O);const oe=document.createElement("div");oe.appendChild(b("Badge")),oe.appendChild(f("Inline badge/label elements. Self-closing renders an empty coloured dot."));const fe=document.createElement("table");fe.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['variant="..."',"primary (default), secondary, success, danger, warning, info, light, dark"],["pill","Flag: rounded pill shape (.badge-pill)"],["outline","Flag: outlined style (.badge-outline)"],['size="small|large"',"Reduced or enlarged badge"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),fe.appendChild(n)}),oe.appendChild(fe),oe.appendChild(l("Basic badge",'[badge variant="success"]New[/badge]',null)),oe.appendChild(l("Pill outline badge",'[badge variant="danger" outline pill]Deprecated[/badge]',null)),z.appendChild(oe);const y=document.createElement("div");y.appendChild(b("Button")),y.appendChild(f("Renders a styled anchor as a Domma button. Use the Insert \u2192 Button toolbar item for a guided dialog."));const N=document.createElement("table");N.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['href="..."',"Link destination (required)"],['label="..."',"Button text (self-closing form)"],['variant="..."',"primary (default), secondary, success, danger, warning, info, outline, ghost, link, outline-*"],['size="sm|lg"',"Button size modifier"],['icon="..."',"Domma icon name before the label"],['icon-after="..."',"Domma icon name after the label"],['target="..."','Link target, e.g. "_blank"'],['class="..."',"Extra CSS classes"],['id="..."',"Element id"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),N.appendChild(n)}),y.appendChild(N),y.appendChild(l("Primary button",'[button href="/contact" variant="primary"]Get in touch[/button]',null)),y.appendChild(l("Self-closing with icon",'[button href="/download" variant="success" icon="download" size="sm" label="Download" /]',null)),y.appendChild(l("Opens in new tab",'[button href="https://example.com" variant="outline" target="_blank"]Visit site[/button]',null)),z.appendChild(y);const X=document.createElement("div");X.appendChild(b("Link (shortcode)")),X.appendChild(f("Renders a plain anchor with optional icon, target, and class. Use Insert \u2192 Link for a guided dialog. For simple inline links, standard Markdown [text](url) is fine."));const ie=document.createElement("table");ie.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['href="..."',"Link destination (required)"],['label="..."',"Link text (self-closing form)"],['target="..."','Link target, e.g. "_blank"'],['class="..."',"CSS classes on the <a>"],['icon="..."',"Domma icon name before the text"],['icon-after="..."',"Domma icon name after the text"],['id="..."',"Element id"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),ie.appendChild(n)}),X.appendChild(ie),X.appendChild(l("External link in new tab",'[link href="https://example.com" target="_blank" icon-after="external-link"]Visit site[/link]',null)),X.appendChild(l("Self-closing with icon",'[link href="/about" icon="arrow-right" label="About us" /]',null)),z.appendChild(X);const le=document.createElement("div");le.appendChild(b("Spacer")),le.appendChild(f("Self-closing shortcode that inserts a fixed-height blank gap."));const ce=document.createElement("table");ce.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['size="N"',"Height in px (default: 8)"],['class="..."',"Extra CSS class on the spacer div"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),ce.appendChild(n)}),le.appendChild(ce),le.appendChild(l("32px gap",'[spacer size="32" /]',null)),H.appendChild(le);const de=document.createElement("div");de.appendChild(b("Icon")),de.appendChild(f("Self-closing shortcode that renders any Domma icon inline."));const pe=document.createElement("table");pe.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['name="..."',"Domma icon name (required). Also accepted as src=."],['size="N"',"Width and height in px"],['color="..."',"CSS colour applied via style"],['class="..."',"Extra CSS classes"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),pe.appendChild(n)}),de.appendChild(pe),de.appendChild(l("Coloured icon",'[icon name="star" size="24" color="#f5a623" /]',null)),z.appendChild(de);const G=document.createElement("div");G.appendChild(b("Center")),G.appendChild(f("Wraps content in a centred div. Works with any content including cards, grids, and text.")),G.appendChild(l("Example","[center]Centred content here[/center]",'Accepts an optional class="..." attribute for extra styling.')),H.appendChild(G);const te=document.createElement("div");te.appendChild(b("Hero")),te.appendChild(f("Full-width hero sections - no plugin required. Uses Domma's built-in Hero CSS component."));const j=document.createElement("table");j.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['title="..."',"Heading text"],['tagline="..."',"Subtitle text"],['size="sm|lg|full"',"Height variant (default: normal)"],['variant="dark|primary|gradient-blue|gradient-purple|gradient-sunset|gradient-ocean"',"Colour / gradient preset"],['image="url"',"Background image URL (adds cover mode)"],['overlay="light|dark|darker|gradient|gradient-reverse"',"Image overlay style"],['align="center|left"',"Content alignment (default: center)"],['fullwidth="true"',"Break out of the page container to span full viewport width"],['bg="..."',"Background colour CSS value"],["twinkle","Flag: adds particle overlay (requires Effects plugin)"],['twinkle-count="N"',"Number of particles"],['twinkle-colour="..."',"Particle colour CSS value"],["blobs","Flag: adds ambient blob background"],['blobs-type="..."',"Blob animation type (default: float-blobs)"],['class="..."',"Extra CSS classes"],['id="..."',"Element id"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),j.appendChild(n)}),te.appendChild(j),te.appendChild(l("Basic hero",'[hero title="Welcome" tagline="Build something great"][/hero]',null)),te.appendChild(l("Gradient with body content",`[hero title="Get Started" tagline="Everything you need." size="lg" variant="gradient-blue" align="center"]
49
+ [/card]`,"Use [header] and [footer] sub-tags for Markdown-rendered header/footer regions. Sub-tags override the title/subtitle/icon and footer attributes when both are present.")),P.appendChild(q);const z=document.createElement("div");z.appendChild(m("Badge")),z.appendChild(f("Inline badge/label elements. Self-closing renders an empty coloured dot."));const Ee=document.createElement("table");Ee.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['variant="..."',"primary (default), secondary, success, danger, warning, info, light, dark"],["pill","Flag: rounded pill shape (.badge-pill)"],["outline","Flag: outlined style (.badge-outline)"],['size="small|large"',"Reduced or enlarged badge"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),Ee.appendChild(o)}),z.appendChild(Ee),z.appendChild(l("Basic badge",'[badge variant="success"]New[/badge]',null)),z.appendChild(l("Pill outline badge",'[badge variant="danger" outline pill]Deprecated[/badge]',null)),P.appendChild(z);const j=document.createElement("div");j.appendChild(m("Button")),j.appendChild(f("Renders a styled anchor as a Domma button. Use the Insert \u2192 Button toolbar item for a guided dialog."));const ee=document.createElement("table");ee.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['href="..."',"Link destination (required)"],['label="..."',"Button text (self-closing form)"],['variant="..."',"primary (default), secondary, success, danger, warning, info, outline, ghost, link, outline-*"],['size="sm|lg"',"Button size modifier"],['icon="..."',"Domma icon name before the label"],['icon-after="..."',"Domma icon name after the label"],['target="..."','Link target, e.g. "_blank"'],['class="..."',"Extra CSS classes"],['id="..."',"Element id"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),ee.appendChild(o)}),j.appendChild(ee),j.appendChild(l("Primary button",'[button href="/contact" variant="primary"]Get in touch[/button]',null)),j.appendChild(l("Self-closing with icon",'[button href="/download" variant="success" icon="download" size="sm" label="Download" /]',null)),j.appendChild(l("Opens in new tab",'[button href="https://example.com" variant="outline" target="_blank"]Visit site[/button]',null)),P.appendChild(j);const d=document.createElement("div");d.appendChild(m("Link (shortcode)")),d.appendChild(f("Renders a plain anchor with optional icon, target, and class. Use Insert \u2192 Link for a guided dialog. For simple inline links, standard Markdown [text](url) is fine."));const s=document.createElement("table");s.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['href="..."',"Link destination (required)"],['label="..."',"Link text (self-closing form)"],['target="..."','Link target, e.g. "_blank"'],['class="..."',"CSS classes on the <a>"],['icon="..."',"Domma icon name before the text"],['icon-after="..."',"Domma icon name after the text"],['id="..."',"Element id"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),s.appendChild(o)}),d.appendChild(s),d.appendChild(l("External link in new tab",'[link href="https://example.com" target="_blank" icon-after="external-link"]Visit site[/link]',null)),d.appendChild(l("Self-closing with icon",'[link href="/about" icon="arrow-right" label="About us" /]',null)),P.appendChild(d);const K=document.createElement("div");K.appendChild(m("Spacer")),K.appendChild(f("Self-closing shortcode that inserts a fixed-height blank gap."));const ue=document.createElement("table");ue.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['size="N"',"Height in px (default: 8)"],['class="..."',"Extra CSS class on the spacer div"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),ue.appendChild(o)}),K.appendChild(ue),K.appendChild(l("32px gap",'[spacer size="32" /]',null)),G.appendChild(K);const re=document.createElement("div");re.appendChild(m("Icon")),re.appendChild(f("Self-closing shortcode that renders any Domma icon inline."));const ge=document.createElement("table");ge.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['name="..."',"Domma icon name (required). Also accepted as src=."],['size="N"',"Width and height in px"],['color="..."',"CSS colour applied via style"],['class="..."',"Extra CSS classes"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),ge.appendChild(o)}),re.appendChild(ge),re.appendChild(l("Coloured icon",'[icon name="star" size="24" color="#f5a623" /]',null)),P.appendChild(re);const be=document.createElement("div");be.appendChild(m("Center")),be.appendChild(f("Wraps content in a centred div. Works with any content including cards, grids, and text.")),be.appendChild(l("Example","[center]Centred content here[/center]",'Accepts an optional class="..." attribute for extra styling.')),G.appendChild(be);const le=document.createElement("div");le.appendChild(m("Hero")),le.appendChild(f("Full-width hero sections - no plugin required. Uses Domma's built-in Hero CSS component."));const pe=document.createElement("table");pe.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['title="..."',"Heading text"],['tagline="..."',"Subtitle text"],['size="sm|lg|full"',"Height variant (default: normal)"],['variant="dark|primary|gradient-blue|gradient-purple|gradient-sunset|gradient-ocean"',"Colour / gradient preset"],['image="url"',"Background image URL (adds cover mode)"],['overlay="light|dark|darker|gradient|gradient-reverse"',"Image overlay style"],['align="center|left"',"Content alignment (default: center)"],['fullwidth="true"',"Break out of the page container to span full viewport width"],['bg="..."',"Background colour CSS value"],["twinkle","Flag: adds particle overlay (requires Effects plugin)"],['twinkle-count="N"',"Number of particles"],['twinkle-colour="..."',"Particle colour CSS value"],["blobs","Flag: adds ambient blob background"],['blobs-type="..."',"Blob animation type (default: float-blobs)"],['class="..."',"Extra CSS classes"],['id="..."',"Element id"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),pe.appendChild(o)}),le.appendChild(pe),le.appendChild(l("Basic hero",'[hero title="Welcome" tagline="Build something great"][/hero]',null)),le.appendChild(l("Gradient with body content",`[hero title="Get Started" tagline="Everything you need." size="lg" variant="gradient-blue" align="center"]
50
50
  Some introductory **Markdown** content here.
51
- [/hero]`,null)),te.appendChild(l("Background image with overlay",'[hero title="Our Story" image="/media/hero.jpg" overlay="dark" size="full"][/hero]',"Combine image + overlay for text legibility over photos.")),H.appendChild(te);const U=document.createElement("div");U.appendChild(b("Interactive Components")),U.appendChild(f("Tabs, accordion, carousel, and countdown - no plugin required.")),U.appendChild(l("Tabs",`[tabs]
51
+ [/hero]`,null)),le.appendChild(l("Background image with overlay",'[hero title="Our Story" image="/media/hero.jpg" overlay="dark" size="full"][/hero]',"Combine image + overlay for text legibility over photos.")),G.appendChild(le);const te=document.createElement("div");te.appendChild(m("Interactive Components")),te.appendChild(f("Tabs, accordion, carousel, and countdown - no plugin required.")),te.appendChild(l("Tabs",`[tabs]
52
52
  [tab title="First"]Content **A**[/tab]
53
53
  [tab title="Second"]Content **B**[/tab]
54
- [/tabs]`,'Add style="pills" for pill-style navigation.')),U.appendChild(l("Accordion",`[accordion]
54
+ [/tabs]`,'Add style="pills" for pill-style navigation.')),te.appendChild(l("Accordion",`[accordion]
55
55
  [item title="Question 1"]Answer here.[/item]
56
56
  [item title="Question 2"]Answer here.[/item]
57
- [/accordion]`,'Add multiple="true" to allow several panels open at once.')),U.appendChild(l("Accordion - collection-bound",'[collection slug="faq" display="accordion" title-field="title" body-field="description" /]',"Renders collection entries as accordion items. Use Insert \u2192 Accordion for a guided dialog.")),U.appendChild(l("Carousel",`[carousel autoplay="true" interval="5000"]
57
+ [/accordion]`,'Add multiple="true" to allow several panels open at once.')),te.appendChild(l("Accordion - collection-bound",'[collection slug="faq" display="accordion" title-field="title" body-field="description" /]',"Renders collection entries as accordion items. Use Insert \u2192 Accordion for a guided dialog.")),te.appendChild(l("Carousel",`[carousel autoplay="true" interval="5000"]
58
58
  [slide title="Slide 1"]Description[/slide]
59
59
  [slide image="/media/photo.jpg" title="Slide 2"]Caption[/slide]
60
- [/carousel]`,'animation="slide|fade|crossfade" (default slide). Use Insert \u2192 Carousel for a guided dialog.')),U.appendChild(l("Carousel - fade / crossfade",`[carousel animation="crossfade" animation-duration="800" animation-easing="ease-in-out" autoplay="true"]
60
+ [/carousel]`,'animation="slide|fade|crossfade" (default slide). Use Insert \u2192 Carousel for a guided dialog.')),te.appendChild(l("Carousel - fade / crossfade",`[carousel animation="crossfade" animation-duration="800" animation-easing="ease-in-out" autoplay="true"]
61
61
  [slide image="/media/one.jpg" title="One"][/slide]
62
62
  [slide image="/media/two.jpg" title="Two"][/slide]
63
- [/carousel]`,"fade swaps opacity per slide; crossfade overlaps the two. animation-easing accepts any CSS timing function (ease, linear, cubic-bezier(...)).")),U.appendChild(l("Countdown (to date)",'[countdown to="2026-12-31" format="DD:HH:mm:ss" /]',null)),U.appendChild(l("Countdown (duration)",'[countdown duration="300" format="mm:ss" /]',"duration is in seconds. format options: mm:ss \xB7 HH:mm:ss \xB7 DD:HH:mm:ss")),z.appendChild(U);const ne=document.createElement("div");ne.appendChild(b("Timeline")),ne.appendChild(f("Renders a Domma Progression component with event items."));const _=document.createElement("table");_.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['layout="vertical|centred|horizontal"',"[timeline] - layout orientation (default: vertical)"],['theme="minimal|corporate|modern"',"[timeline] - visual theme (default: minimal)"],['mode="timeline|roadmap"',"[timeline] - display mode (default: timeline)"],['class="..."',"[timeline] - extra CSS classes"],['id="..."',"[timeline] - element id"],['title="..."',"[event] - event heading"],['date="..."',"[event] - display date string"],['status="planned|in-progress|completed|blocked"',"[event] - progress status"],['icon="..."',"[event] - Domma icon name"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),_.appendChild(n)}),ne.appendChild(_),ne.appendChild(l("Vertical timeline",`[timeline layout="vertical" theme="modern"]
63
+ [/carousel]`,"fade swaps opacity per slide; crossfade overlaps the two. animation-easing accepts any CSS timing function (ease, linear, cubic-bezier(...)).")),te.appendChild(l("Countdown (to date)",'[countdown to="2026-12-31" format="DD:HH:mm:ss" /]',null)),te.appendChild(l("Countdown (duration)",'[countdown duration="300" format="mm:ss" /]',"duration is in seconds. format options: mm:ss \xB7 HH:mm:ss \xB7 DD:HH:mm:ss")),P.appendChild(te);const he=document.createElement("div");he.appendChild(m("Timeline")),he.appendChild(f("Renders a Domma Progression component with event items."));const xe=document.createElement("table");xe.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['layout="vertical|centred|horizontal"',"[timeline] - layout orientation (default: vertical)"],['theme="minimal|corporate|modern"',"[timeline] - visual theme (default: minimal)"],['mode="timeline|roadmap"',"[timeline] - display mode (default: timeline)"],['class="..."',"[timeline] - extra CSS classes"],['id="..."',"[timeline] - element id"],['title="..."',"[event] - event heading"],['date="..."',"[event] - display date string"],['status="planned|in-progress|completed|blocked"',"[event] - progress status"],['icon="..."',"[event] - Domma icon name"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),xe.appendChild(o)}),he.appendChild(xe),he.appendChild(l("Vertical timeline",`[timeline layout="vertical" theme="modern"]
64
64
  [event title="Kickoff" date="Jan 2025" status="completed" icon="flag"]
65
65
  Project launched.
66
66
  [/event]
67
67
  [event title="Beta" date="Jun 2025" status="in-progress" icon="rocket"]
68
68
  In active development.
69
69
  [/event]
70
- [/timeline]`,null)),z.appendChild(ne);const me=document.createElement("div");me.appendChild(b("Embedding a Form"));const ve=document.createElement("table");ve.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['name="..."',"Form slug (required). Also accepted as slug=."],['class="..."',"Extra CSS classes on the wrapper div"],['id="..."',"id attribute on the wrapper div"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),ve.appendChild(n)}),me.appendChild(ve),me.appendChild(l("Basic",'[form name="contact" /]',"Forms are managed under Forms in the sidebar.")),me.appendChild(l("With wrapper styling",'[form name="newsletter" class="mt-4" id="newsletter-form" /]',null)),F.appendChild(me);const ue=document.createElement("div");ue.appendChild(b("Displaying a Collection"));const be=document.createElement("pre");be.style.cssText=A+"display:block;padding:.5rem .75rem;white-space:pre;overflow-x:auto;",be.textContent='[collection slug="enquiries" display="table" /]',ue.appendChild(be);const Ce=[["slug","Required. The collection slug."],["display","table (default), cards, or list."],["fields","Comma-separated field keys to show. Defaults to all."],["limit","Maximum number of entries to display."],["sort","Field key to sort by."],["order","asc or desc (default asc)."],["title-field","Field used as the card/list title (cards + list)."],["columns","Grid columns for cards display (2-4, default 3)."],["search","true/false - enable search in table mode (default true)."],["sortable","true/false - enable column sorting in table mode (default true)."],["exportable","true/false - show CSV export button in table mode (default false)."],["page-size","Rows per page in table mode (default 25)."],["empty","Text shown when there are no entries."],["cta","Action slug: enables per-entry CTA buttons."],["cta-label",'CTA button label (default: "Run").'],["cta-icon","CTA button icon name."],["cta-style","CTA button variant (default: primary)."],["cta-confirm","CTA confirmation prompt text."],["class","Extra CSS classes on the wrapper div."],["id","id attribute on the wrapper div."]],t=document.createElement("table");t.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",Ce.forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),t.appendChild(n)}),ue.appendChild(t),ue.appendChild(f("Table display uses Domma Table - search, sort, pagination, column selector, and CSV export are all built in. Cards and lists are static.")),F.appendChild(ue);const d=document.createElement("div");d.appendChild(b("View - Pro")),d.appendChild(f("Renders a Collection with full filtering, pagination, and display options. Requires a Pro MongoDB collection."));const u=document.createElement("table");u.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[["slug","Required. The collection slug."],["display","table (default), cards, or list."],["limit","Maximum number of entries to display."],["fields","Comma-separated field keys to show."],["title-field","Field used as the card/list title."],["columns","Grid columns for cards display (2-4, default 3)."],["empty","Text shown when there are no entries."],["class","Extra CSS classes on the wrapper div."],["id","id attribute on the wrapper div."]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),u.appendChild(n)}),d.appendChild(u),d.appendChild(l("Table display",'[view slug="products" display="table" limit="50" /]',null)),d.appendChild(l("Cards display",'[view slug="team" display="cards" columns="3" title-field="name" /]',null)),F.appendChild(d);const p=document.createElement("div");p.appendChild(b("CTA - Pro")),p.appendChild(f("Renders an action button that triggers a Pro Action against an entry. Requires the Pro Actions feature."));const h=document.createElement("table");h.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[["action","Required. The action slug."],["entry","Required. The entry id to act on."],["style","Button variant (default: primary)."],["icon","Domma icon name for the button."],["size","Button size (sm, lg)."],["confirm","Confirmation prompt text before running."],["label","Self-closing only: button label text."]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),h.appendChild(n)}),p.appendChild(h),p.appendChild(l("Wrapping form",'[cta action="approve" entry="abc123" style="success" confirm="Approve this entry?"]Approve[/cta]',null)),p.appendChild(l("Self-closing",'[cta action="archive" entry="abc123" icon="archive" label="Archive" /]',null)),F.appendChild(p);const m=document.createElement("div");m.appendChild(b("Effects")),m.appendChild(f("Shortcodes for scroll-triggered animations, counters, typewriter text, and more. Requires the Domma Effects plugin."));const k=[['[reveal animation="fade"]...[/reveal]',"Fade/slide/zoom on scroll"],["[breathe]...[/breathe]","Continuous gentle scale loop"],["[pulse]...[/pulse]","Repeating scale pulse"],["[shake]...[/shake]","One-shot shake"],['[scribe speed="50"]...[/scribe]',"Typewriter - simple mode (text typed letter by letter)"],['[scribe loop="true"][render]Text[/render][wait]1500[/wait][undo /][/scribe]',"Typewriter - script mode (sequenced render/wait/undo actions)"],["[scramble]...[/scramble]","Character-scramble reveal"],['[counter to="100" /]',"Animated number counter (self-closing)"],["[ripple]...[/ripple]","Click-triggered ripple"],['[twinkle count="50"]...[/twinkle]',"Particle/star overlay"],['[animate type="fade-in-up"]...[/animate]',"CSS-only animation (no plugin needed)"],['[ambient type="aurora"]...[/ambient]',"CSS-only animated background"],['[firework type="burst" colour="rainbow" /]',"CSS firework (self-closing)"],["[fireworks]...[/fireworks]","Fireworks display container"],['[celebrate theme="auto" /]',"Seasonal canvas celebration (auto-detects date)"],["[christmas /]","Christmas - snowflakes, trees, snowmen, sleigh"],["[halloween /]","Halloween - pumpkins, ghosts, bats, spiders"],["[st-patricks /]","St Patrick's Day - shamrocks, coins, rainbows, leprechaun"],["[valentines /]","Valentine's Day - hearts, roses"],["[guy-fawkes /]","Guy Fawkes - fireworks, sparkles"],["[st-andrews /]","St Andrew's Day - heather, thistles"],["[st-davids /]","St David's Day - daffodils, dragons"],["[st-georges /]","St George's Day - roses, flags"]],ae=document.createElement("table");ae.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",k.forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),ae.appendChild(n)}),m.appendChild(ae),m.appendChild(l("Scribe script - looping multi-phrase typewriter",`[scribe loop="true" loop-delay="2000" delete-speed="20"]
70
+ [/timeline]`,null)),P.appendChild(he);const ie=document.createElement("div");ie.appendChild(m("Embedding a Form"));const J=document.createElement("table");J.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['name="..."',"Form slug (required). Also accepted as slug=."],['class="..."',"Extra CSS classes on the wrapper div"],['id="..."',"id attribute on the wrapper div"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),J.appendChild(o)}),ie.appendChild(J),ie.appendChild(l("Basic",'[form name="contact" /]',"Forms are managed under Forms in the sidebar.")),ie.appendChild(l("With wrapper styling",'[form name="newsletter" class="mt-4" id="newsletter-form" /]',null)),Y.appendChild(ie);const Ne=document.createElement("div");Ne.appendChild(m("Displaying a Collection"));const fe=document.createElement("pre");fe.style.cssText=T+"display:block;padding:.5rem .75rem;white-space:pre;overflow-x:auto;",fe.textContent='[collection slug="enquiries" display="table" /]',Ne.appendChild(fe);const Oe=[["slug","Required. The collection slug."],["display","table (default), cards, or list."],["fields","Comma-separated field keys to show. Defaults to all."],["limit","Maximum number of entries to display."],["sort","Field key to sort by."],["order","asc or desc (default asc)."],["title-field","Field used as the card/list title (cards + list)."],["columns","Grid columns for cards display (2-4, default 3)."],["search","true/false - enable search in table mode (default true)."],["sortable","true/false - enable column sorting in table mode (default true)."],["exportable","true/false - show CSV export button in table mode (default false)."],["page-size","Rows per page in table mode (default 25)."],["empty","Text shown when there are no entries."],["cta","Action slug: enables per-entry CTA buttons."],["cta-label",'CTA button label (default: "Run").'],["cta-icon","CTA button icon name."],["cta-style","CTA button variant (default: primary)."],["cta-confirm","CTA confirmation prompt text."],["class","Extra CSS classes on the wrapper div."],["id","id attribute on the wrapper div."]],Me=document.createElement("table");Me.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",Oe.forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;width:35%;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),Me.appendChild(o)}),Ne.appendChild(Me),Ne.appendChild(f("Table display uses Domma Table - search, sort, pagination, column selector, and CSV export are all built in. Cards and lists are static.")),Y.appendChild(Ne);const _=document.createElement("div");_.appendChild(m("View - Pro")),_.appendChild(f("Renders a Collection with full filtering, pagination, and display options. Requires a Pro MongoDB collection."));const ke=document.createElement("table");ke.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[["slug","Required. The collection slug."],["display","table (default), cards, or list."],["limit","Maximum number of entries to display."],["fields","Comma-separated field keys to show."],["title-field","Field used as the card/list title."],["columns","Grid columns for cards display (2-4, default 3)."],["empty","Text shown when there are no entries."],["class","Extra CSS classes on the wrapper div."],["id","id attribute on the wrapper div."]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;width:35%;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),ke.appendChild(o)}),_.appendChild(ke),_.appendChild(l("Table display",'[view slug="products" display="table" limit="50" /]',null)),_.appendChild(l("Cards display",'[view slug="team" display="cards" columns="3" title-field="name" /]',null)),Y.appendChild(_);const Se=document.createElement("div");Se.appendChild(m("CTA - Pro")),Se.appendChild(f("Renders an action button that triggers a Pro Action against an entry. Requires the Pro Actions feature."));const Te=document.createElement("table");Te.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[["action","Required. The action slug."],["entry","Required. The entry id to act on."],["style","Button variant (default: primary)."],["icon","Domma icon name for the button."],["size","Button size (sm, lg)."],["confirm","Confirmation prompt text before running."],["label","Self-closing only: button label text."]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;width:35%;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),Te.appendChild(o)}),Se.appendChild(Te),Se.appendChild(l("Wrapping form",'[cta action="approve" entry="abc123" style="success" confirm="Approve this entry?"]Approve[/cta]',null)),Se.appendChild(l("Self-closing",'[cta action="archive" entry="abc123" icon="archive" label="Archive" /]',null)),Y.appendChild(Se);const ne=document.createElement("div");ne.appendChild(m("Effects")),ne.appendChild(f("Shortcodes for scroll-triggered animations, counters, typewriter text, and more. Requires the Domma Effects plugin."));const Ve=[['[reveal animation="fade"]...[/reveal]',"Fade/slide/zoom on scroll"],["[breathe]...[/breathe]","Continuous gentle scale loop"],["[pulse]...[/pulse]","Repeating scale pulse"],["[shake]...[/shake]","One-shot shake"],['[scribe speed="50"]...[/scribe]',"Typewriter - simple mode (text typed letter by letter)"],['[scribe loop="true"][render]Text[/render][wait]1500[/wait][undo /][/scribe]',"Typewriter - script mode (sequenced render/wait/undo actions)"],["[scramble]...[/scramble]","Character-scramble reveal"],['[counter to="100" /]',"Animated number counter (self-closing)"],["[ripple]...[/ripple]","Click-triggered ripple"],['[twinkle count="50"]...[/twinkle]',"Particle/star overlay"],['[animate type="fade-in-up"]...[/animate]',"CSS-only animation (no plugin needed)"],['[ambient type="aurora"]...[/ambient]',"CSS-only animated background"],['[firework type="burst" colour="rainbow" /]',"CSS firework (self-closing)"],["[fireworks]...[/fireworks]","Fireworks display container"],['[celebrate theme="auto" /]',"Seasonal canvas celebration (auto-detects date)"],["[christmas /]","Christmas - snowflakes, trees, snowmen, sleigh"],["[halloween /]","Halloween - pumpkins, ghosts, bats, spiders"],["[st-patricks /]","St Patrick's Day - shamrocks, coins, rainbows, leprechaun"],["[valentines /]","Valentine's Day - hearts, roses"],["[guy-fawkes /]","Guy Fawkes - fireworks, sparkles"],["[st-andrews /]","St Andrew's Day - heather, thistles"],["[st-davids /]","St David's Day - daffodils, dragons"],["[st-georges /]","St George's Day - roses, flags"]],ve=document.createElement("table");ve.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",Ve.forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),ve.appendChild(o)}),ne.appendChild(ve),ne.appendChild(l("Scribe script - looping multi-phrase typewriter",`[scribe loop="true" loop-delay="2000" delete-speed="20"]
71
71
  [render]We build things that matter.[/render]
72
72
  [wait]1200[/wait]
73
73
  [undo all="true" /]
74
74
  [render]We design for humans.[/render]
75
75
  [wait]1200[/wait]
76
76
  [undo all="true" /]
77
- [/scribe]`,'Use [render]...[/render] to type text, [wait]Ms[/wait] to pause, and [undo /] to delete. loop="true" replays the sequence. Only [render], [wait], and [undo] shortcodes are parsed - plain text between actions is ignored.')),m.appendChild(l("Christmas",'[christmas intensity="medium" snowmen="off" trees="off" wreaths="off" northStars="off" sleigh="off" train="off" elf="off" robin="off" firework="off" /]',"intensity: light | medium | heavy. Count-based (off disables entirely): snowmen, trees, wreaths, northStars. Probability-based specials (off prevents spawning): sleigh, train, elf, robin, firework. Snowflakes always fall.")),m.appendChild(l("Halloween",'[halloween intensity="medium" gravestones="off" jackOLanterns="off" spiders="off" scarecrows="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): gravestones, jackOLanterns, spiders, scarecrows, twinklingStars. Particles: bats, ghosts, pumpkins (always on). Fixed decorations: haunted-house, cauldron (always present).")),m.appendChild(l("St Patrick's Day",'[st-patricks intensity="medium" pots="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): pots (pots of gold), twinklingStars. Particles: shamrocks, clover petals, gold coins, sparkles (always on). Fixed decorations: rainbow, harp, moon. Leprechaun appears randomly - more likely at higher intensity.")),m.appendChild(l("Valentine's Day",'[valentines intensity="medium" garlands="off" butterflies="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): garlands (heart garlands), butterflies. Particles: hearts, rose petals, sparkles, lips (always on). Fixed decorations: envelopes (always present). Cupid appears randomly - more likely at higher intensity.")),m.appendChild(l("Guy Fawkes Night",'[guy-fawkes intensity="medium" bonfires="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): bonfires. Particles: embers, fireworks, sparks, rockets, bursts, trails (always on). Fixed decorations: guy-effigy, catherine-wheel, roman-candle, sparkler-bundle, moon. Starts at 25% particle density and builds up gradually.")),m.appendChild(l("St Andrew's Day",'[st-andrews intensity="medium" thistles="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): thistles, twinklingStars. Particles: heather petals, saltire sparkles (always on). Fixed decorations: bagpiper, saltire-flag, tartan-pattern, highland-scene (always present). Bagpiper probability increases with intensity.")),m.appendChild(l("St David's Day",'[st-davids intensity="medium" daffodilFields="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): daffodilFields, twinklingStars. Particles: daffodil petals, spring sparkles (always on). Fixed decorations: welsh-dragon, harp, leek-bundle, flag (always present). Flying dragon appears randomly - more likely at higher intensity.")),m.appendChild(l("St George's Day",'[st-georges intensity="medium" roses="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): roses (English roses), twinklingStars. Particles: rose petals, Tudor roses, oak leaves, sparkles (always on). Fixed decorations: st-georges-cross, dragon, shield, castle (always present). Knight appears randomly - more likely at higher intensity.")),m.appendChild(f("Enable the Domma Effects plugin to activate these shortcodes on your site.")),Z.appendChild(m);const se=document.createElement("div");se.appendChild(b("Tables")),se.appendChild(f("Wrap a standard Markdown (GFM) table with Domma CSS classes and responsive horizontal scrolling."));const he=document.createElement("table");he.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['striped="true"',"Alternate row background (.table-striped)"],['bordered="true"',"Borders on all cells (.table-bordered)"],['compact="true"',"Reduced cell padding (.table-compact)"],['caption="..."',"Caption text above the table"],['class="..."',"Extra CSS classes appended to .table"],['id="..."',"id attribute on the <table> element"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),he.appendChild(n)}),se.appendChild(he),se.appendChild(l("Striped + bordered table",`[table striped="true" bordered="true" caption="Product Pricing"]
77
+ [/scribe]`,'Use [render]...[/render] to type text, [wait]Ms[/wait] to pause, and [undo /] to delete. loop="true" replays the sequence. Only [render], [wait], and [undo] shortcodes are parsed - plain text between actions is ignored.')),ne.appendChild(l("Christmas",'[christmas intensity="medium" snowmen="off" trees="off" wreaths="off" northStars="off" sleigh="off" train="off" elf="off" robin="off" firework="off" /]',"intensity: light | medium | heavy. Count-based (off disables entirely): snowmen, trees, wreaths, northStars. Probability-based specials (off prevents spawning): sleigh, train, elf, robin, firework. Snowflakes always fall.")),ne.appendChild(l("Halloween",'[halloween intensity="medium" gravestones="off" jackOLanterns="off" spiders="off" scarecrows="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): gravestones, jackOLanterns, spiders, scarecrows, twinklingStars. Particles: bats, ghosts, pumpkins (always on). Fixed decorations: haunted-house, cauldron (always present).")),ne.appendChild(l("St Patrick's Day",'[st-patricks intensity="medium" pots="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): pots (pots of gold), twinklingStars. Particles: shamrocks, clover petals, gold coins, sparkles (always on). Fixed decorations: rainbow, harp, moon. Leprechaun appears randomly - more likely at higher intensity.")),ne.appendChild(l("Valentine's Day",'[valentines intensity="medium" garlands="off" butterflies="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): garlands (heart garlands), butterflies. Particles: hearts, rose petals, sparkles, lips (always on). Fixed decorations: envelopes (always present). Cupid appears randomly - more likely at higher intensity.")),ne.appendChild(l("Guy Fawkes Night",'[guy-fawkes intensity="medium" bonfires="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): bonfires. Particles: embers, fireworks, sparks, rockets, bursts, trails (always on). Fixed decorations: guy-effigy, catherine-wheel, roman-candle, sparkler-bundle, moon. Starts at 25% particle density and builds up gradually.")),ne.appendChild(l("St Andrew's Day",'[st-andrews intensity="medium" thistles="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): thistles, twinklingStars. Particles: heather petals, saltire sparkles (always on). Fixed decorations: bagpiper, saltire-flag, tartan-pattern, highland-scene (always present). Bagpiper probability increases with intensity.")),ne.appendChild(l("St David's Day",'[st-davids intensity="medium" daffodilFields="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): daffodilFields, twinklingStars. Particles: daffodil petals, spring sparkles (always on). Fixed decorations: welsh-dragon, harp, leek-bundle, flag (always present). Flying dragon appears randomly - more likely at higher intensity.")),ne.appendChild(l("St George's Day",'[st-georges intensity="medium" roses="off" twinklingStars="off" /]',"intensity: light | medium | heavy. Decoration toggles (off disables): roses (English roses), twinklingStars. Particles: rose petals, Tudor roses, oak leaves, sparkles (always on). Fixed decorations: st-georges-cross, dragon, shield, castle (always present). Knight appears randomly - more likely at higher intensity.")),ne.appendChild(f("Enable the Domma Effects plugin to activate these shortcodes on your site.")),oe.appendChild(ne);const X=document.createElement("div");X.appendChild(m("Tables")),X.appendChild(f("Wrap a standard Markdown (GFM) table with Domma CSS classes and responsive horizontal scrolling."));const Be=document.createElement("table");Be.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['striped="true"',"Alternate row background (.table-striped)"],['bordered="true"',"Borders on all cells (.table-bordered)"],['compact="true"',"Reduced cell padding (.table-compact)"],['caption="..."',"Caption text above the table"],['class="..."',"Extra CSS classes appended to .table"],['id="..."',"id attribute on the <table> element"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),Be.appendChild(o)}),X.appendChild(Be),X.appendChild(l("Striped + bordered table",`[table striped="true" bordered="true" caption="Product Pricing"]
78
78
  | Product | Price |
79
79
  | ------- | ----: |
80
80
  | Widget | $9.99 |
81
81
  | Gadget | $14.99 |
82
- [/table]`,"The inner content must be a valid GFM Markdown table. The shortcode adds Domma CSS classes and wraps in a responsive scroll container.")),z.appendChild(se);const T=document.createElement("div");T.appendChild(b("Slideover")),T.appendChild(f("A trigger button that opens a slide-in panel with Markdown content. No plugin required."));const re=document.createElement("table");re.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['title="..."',"Panel header text"],['trigger="..."','Button label (default: "Open")'],['size="sm|md|lg"',"Panel width (default: md)"],['position="right|left"',"Slide direction (default: right)"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),re.appendChild(n)}),T.appendChild(re),T.appendChild(l("Example",`[slideover title="More Info" trigger="Read more" size="md"]
82
+ [/table]`,"The inner content must be a valid GFM Markdown table. The shortcode adds Domma CSS classes and wraps in a responsive scroll container.")),P.appendChild(X);const de=document.createElement("div");de.appendChild(m("Slideover")),de.appendChild(f("A trigger button that opens a slide-in panel with Markdown content. No plugin required."));const Ie=document.createElement("table");Ie.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['title="..."',"Panel header text"],['trigger="..."','Button label (default: "Open")'],['size="sm|md|lg"',"Panel width (default: md)"],['position="right|left"',"Slide direction (default: right)"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),Ie.appendChild(o)}),de.appendChild(Ie),de.appendChild(l("Example",`[slideover title="More Info" trigger="Read more" size="md"]
83
83
  ## Details
84
84
  Markdown content here.
85
- [/slideover]`,"Nested [card] and [grid] shortcodes work inside the slideover body.")),z.appendChild(T);const Q=document.createElement("div");Q.appendChild(b("DConfig - Declarative Behaviour")),Q.appendChild(f("Define click handlers and class toggles without writing JavaScript. Use the DConfig section above or embed inline with [dconfig]...[/dconfig] in the content body. Inline shortcodes win on selector conflict.")),Q.appendChild(l("Toggle a class on click",'{ "#my-btn": { "events": { "click": { "target": "#panel", "toggleClass": "hidden" } } } }','Selector keys use standard CSS selectors. "target" is optional - defaults to the element itself.')),Q.appendChild(l("Inline shortcode syntax",`[dconfig]
85
+ [/slideover]`,"Nested [card] and [grid] shortcodes work inside the slideover body.")),P.appendChild(de);const ye=document.createElement("div");ye.appendChild(m("DConfig - Declarative Behaviour")),ye.appendChild(f("Define click handlers and class toggles without writing JavaScript. Use the DConfig section above or embed inline with [dconfig]...[/dconfig] in the content body. Inline shortcodes win on selector conflict.")),ye.appendChild(l("Toggle a class on click",'{ "#my-btn": { "events": { "click": { "target": "#panel", "toggleClass": "hidden" } } } }','Selector keys use standard CSS selectors. "target" is optional - defaults to the element itself.')),ye.appendChild(l("Inline shortcode syntax",`[dconfig]
86
86
  { "#my-btn": { "events": { "click": { "target": "#panel", "toggleClass": "hidden" } } } }
87
- [/dconfig]`,null)),Z.appendChild(Q);const J=document.createElement("div");J.appendChild(b("CSS Editor")),J.appendChild(f("The toolbar's </> button (left of the Split View icon) swaps the left pane between Markdown and Custom CSS. Edits are saved together with the page - one Save, one toast."));const we=document.createElement("table");we.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[["</> button","Toggle between Markdown editor and Custom CSS editor"],["Split / Write / Preview","Standard view mode buttons to the right of </>"],["Save","Saves both page content and CSS in a single operation"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),we.appendChild(n)}),J.appendChild(we),Z.appendChild(J);const ye=document.createElement("div");ye.appendChild(b("Colour Picker")),ye.appendChild(f("Insert \u2192 Colour Picker opens a centred colour picker. Pick a colour, then use Copy to copy the hex code to the clipboard or Insert to drop it at the cursor. Click outside the panel to dismiss.")),Z.appendChild(ye);const Ee=document.createElement("div");Ee.appendChild(b("Keyboard Shortcuts"));const Ae=document.createElement("table");Ae.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[["Ctrl + B","Bold selected text"],["Ctrl + I","Italic selected text"],["Ctrl + K","Insert link dialog"],["Tab","Indent 2 spaces at cursor"],["Shift + Tab","Dedent 2 spaces on current line"],["Ctrl + X","Cut current line (no selection) or cut selection"],["Ctrl + C","Copy current line (no selection) or copy selection"],["Ctrl + V","Paste from clipboard"],["Ctrl + Z","Undo"],["Ctrl + Y","Redo"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;white-space:nowrap;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),Ae.appendChild(n)}),Ee.appendChild(Ae),B.appendChild(Ee);const Te=document.createElement("div");Te.appendChild(b("Tips"));const De=document.createElement("table");De.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['class="text-center"',"Centre text and inline elements on any shortcode"],['class="mx-auto"',"Centre a block element horizontally"],["[center]...[/center]","Shorthand wrapper for centred content"]].forEach(([c,r])=>{const n=document.createElement("tr"),a=document.createElement("td");a.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",a.appendChild(s(c));const o=document.createElement("td");o.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",o.textContent=r,n.appendChild(a),n.appendChild(o),De.appendChild(n)}),Te.appendChild(De),Te.appendChild(f("Most shortcodes accept a class attribute for custom styling.")),B.appendChild(Te),e.setContent(V),e.open(),E.tabs(W),I.scan(V)}function _e(e,A){const v=e.find("#history-tab").get(0),s=e.find("#version-list").get(0),b=e.find("#version-compare").get(0),V=e.find("#version-compare-old").get(0),W=e.find("#version-compare-new").get(0),Y=e.find("#version-compare-label").get(0),i=e.find("#version-compare-back-btn").get(0),P=e.find("#version-restore-btn").get(0),B=e.find("#history-save-named-btn").get(0),H=e.find("#history-delete-selected-btn").get(0);let z=!1,F=null;function Z(){s.style.display="",b.style.display="none",F=null}function K(){s.style.display="none",b.style.display=""}async function M(){s.textContent="";const g=document.createElement("p");g.style.color="var(--dm-text-muted)",g.textContent="Loading\u2026",s.appendChild(g);let C;try{C=(await L.versions.list(A)).versions||[]}catch(y){s.textContent="";const N=document.createElement("p");N.style.color="var(--dm-danger,#e55)",N.textContent="Failed to load versions: "+y.message,s.appendChild(N);return}if(s.textContent="",H.style.display="none",!C.length){const y=document.createElement("p");y.style.color="var(--dm-text-muted)",y.textContent="No versions saved yet. Versions are created automatically on each save.",s.appendChild(y);return}const q=document.createElement("table");q.style.cssText="width:100%;border-collapse:collapse;font-size:.875rem;";const x=document.createElement("thead"),f=document.createElement("tr"),l=document.createElement("th");l.style.cssText="padding:.5rem .75rem;width:2rem;border-bottom:1px solid var(--dm-border);";const w=document.createElement("input");w.type="checkbox",w.setAttribute("aria-label","Select all versions"),l.appendChild(w),f.appendChild(l),["Date","Author","Type","Label","Actions"].forEach(y=>{const N=document.createElement("th");N.style.cssText="text-align:left;padding:.5rem .75rem;border-bottom:1px solid var(--dm-border);font-size:.8rem;color:var(--dm-text-muted);",N.textContent=y,f.appendChild(N)}),x.appendChild(f),q.appendChild(x);const O=[];function oe(){const y=O.some(X=>X.checked),N=O.length>0&&O.every(X=>X.checked);H.style.display=y?"":"none",w.checked=N,w.indeterminate=y&&!N}w.addEventListener("change",()=>{O.forEach(y=>{y.checked=w.checked}),oe()});const fe=document.createElement("tbody");C.forEach(y=>{const N=document.createElement("tr");N.style.borderBottom="1px solid var(--dm-border)";const X=document.createElement("td");X.style.padding=".5rem .75rem";const ie=document.createElement("input");ie.type="checkbox",ie.value=y.filename,ie.addEventListener("change",oe),X.appendChild(ie),O.push(ie);const le=document.createElement("td");le.style.padding=".5rem .75rem",le.textContent=D(y.createdAt).format("D MMM YYYY, HH:mm");const ce=document.createElement("td");ce.style.padding=".5rem .75rem",ce.textContent=y.author||"-";const de=document.createElement("td");de.style.padding=".5rem .75rem";const pe=document.createElement("span");pe.className="badge badge-"+(y.type==="manual"?"primary":"secondary"),pe.style.cssText="font-size:.75rem;padding:.2rem .5rem;border-radius:4px;",pe.textContent=y.type,de.appendChild(pe);const G=document.createElement("td");G.style.cssText="padding:.5rem .75rem;color:var(--dm-text-muted);",G.textContent=y.label||"-";const te=document.createElement("td");te.style.padding=".5rem .75rem";const j=document.createElement("button");j.className="btn btn-ghost btn-xs",j.style.marginRight=".4rem",j.title="Compare",j.innerHTML='<span data-icon="columns"></span>',j.addEventListener("click",async()=>{try{const ne=await L.versions.get(A,y.filename);V.textContent=ne.content,W.textContent=e.find("#markdown-editor").get(0).value,Y.textContent=D(y.createdAt).format("D MMM YYYY, HH:mm")+(y.label?` - ${y.label}`:""),F=y.filename,K()}catch(ne){E.toast("Failed to load version: "+ne.message,{type:"error"})}});const U=document.createElement("button");U.className="btn btn-ghost btn-xs",U.style.color="var(--dm-danger,#e55)",U.title="Delete",U.innerHTML='<span data-icon="trash"></span>',U.addEventListener("click",async()=>{if(await E.confirm("Delete this version? This cannot be undone."))try{await L.versions.delete(A,y.filename),E.toast("Version deleted.",{type:"success"}),await M()}catch(ne){E.toast("Failed to delete: "+ne.message,{type:"error"})}}),te.appendChild(j),te.appendChild(U),N.appendChild(X),N.appendChild(le),N.appendChild(ce),N.appendChild(de),N.appendChild(G),N.appendChild(te),fe.appendChild(N)}),q.appendChild(fe),s.appendChild(q),I.scan(s)}v.addEventListener("click",async()=>{z||(z=!0,await M())}),i.addEventListener("click",()=>{Z()}),P.addEventListener("click",async()=>{if(!(!F||!await E.confirm("Restore this version? The current page content will be overwritten (a pre-restore snapshot will be saved automatically).")))try{await L.versions.restore(A,F),E.toast("Page restored. Reloading editor\u2026",{type:"success"}),R.navigate("/pages"),setTimeout(()=>R.navigate(`/pages/edit${A}`),300)}catch(g){E.toast("Restore failed: "+g.message,{type:"error"})}}),H.addEventListener("click",async()=>{const g=[...s.querySelectorAll("tbody input[type=checkbox]:checked")].map(C=>C.value);if(!(!g.length||!await E.confirm(`Delete ${g.length} version${g.length>1?"s":""}? This cannot be undone.`)))try{await L.versions.bulkDelete(A,g),E.toast(`${g.length} version${g.length>1?"s":""} deleted.`,{type:"success"}),await M()}catch(C){E.toast("Delete failed: "+C.message,{type:"error"})}}),B.addEventListener("click",()=>{const g=E.slideover({title:"Save Named Version",size:"sm",position:"right"}),C=document.createElement("div");C.style.padding="1rem";const q=document.createElement("label");q.className="form-label",q.textContent="Version Label";const x=document.createElement("input");x.type="text",x.className="form-input",x.placeholder="e.g. Initial design, Before restructure",x.style.marginBottom=".75rem";const f=document.createElement("button");f.className="btn btn-primary",f.textContent="Save Version",f.addEventListener("click",async()=>{const l=x.value.trim();try{await L.versions.create(A,l||null),E.toast("Named version saved.",{type:"success"}),g.close(),z=!1,v.classList.contains("active")&&(z=!0,await M())}catch(w){E.toast("Failed to save version: "+w.message,{type:"error"})}}),C.appendChild(q),C.appendChild(x),C.appendChild(f),g.element.appendChild(C),g.open(),setTimeout(()=>x.focus(),100)})}function Je(e){try{return D(e).format("D MMM YYYY, HH:mm")}catch{return new Date(e).toLocaleString()}}async function Ke(e){const A=E.slideover({title:"Share preview link",size:"md",position:"right"}),v=document.createElement("div");v.style.padding="1rem";const s=document.createElement("p");s.className="form-hint",s.style.marginTop="0",s.textContent="Anyone with the link can view this page even while it is unpublished, without signing in. The link works for this page only, expires on its own, and can be revoked at any time.",v.appendChild(s);const b=document.createElement("label");b.className="form-label",b.textContent="Expires after";const V=document.createElement("select");V.className="form-select",[["1h","1 hour"],["24h","24 hours"],["7d","7 days"],["30d","30 days"]].forEach(([K,M])=>{const g=document.createElement("option");g.value=K,g.textContent=M,K==="7d"&&(g.selected=!0),V.appendChild(g)});const W=document.createElement("label");W.className="form-label",W.style.marginTop=".75rem",W.textContent="Note (optional)";const Y=document.createElement("input");Y.type="text",Y.className="form-input",Y.placeholder="e.g. For the client sign-off";const i=document.createElement("button");i.className="btn btn-primary",i.style.marginTop=".75rem",i.textContent="Create link";const P=document.createElement("div");P.style.marginTop=".75rem",P.style.display="none";const B=document.createElement("input");B.type="text",B.className="form-input",B.readOnly=!0,B.style.marginBottom=".4rem";const H=document.createElement("button");H.className="btn btn-secondary btn-sm",H.textContent="Copy link",H.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(B.value),E.toast("Link copied to clipboard.",{type:"success"})}catch{B.select(),E.toast("Press Ctrl+C to copy the selected link.",{type:"info"})}}),P.appendChild(B),P.appendChild(H),v.appendChild(b),v.appendChild(V),v.appendChild(W),v.appendChild(Y),v.appendChild(i),v.appendChild(P);const z=document.createElement("h4");z.style.cssText="margin:1.5rem 0 .5rem;font-size:.9rem;",z.textContent="Active links",v.appendChild(z);const F=document.createElement("div");v.appendChild(F);const Z=async()=>{F.textContent="";let K=[];try{K=await L.pages.previewLinks.list(e)}catch(g){const C=document.createElement("p");C.className="form-hint",C.textContent="Could not load existing links: "+(g.message||"unknown error"),F.appendChild(C);return}const M=K.filter(g=>!g.revokedAt&&!g.expired);if(!M.length){const g=document.createElement("p");g.className="form-hint",g.textContent="No active links for this page.",F.appendChild(g);return}M.forEach(g=>{const C=document.createElement("div");C.style.cssText="display:flex;align-items:center;gap:.6rem;padding:.5rem 0;border-bottom:1px solid var(--dm-border-light);";const q=document.createElement("div");q.style.cssText="flex:1 1 auto;min-width:0;font-size:.82rem;";const x=document.createElement("div");x.style.fontWeight="600",x.textContent=g.label||"Untitled link";const f=document.createElement("div");f.style.opacity=".7";const l=g.useCount===1?"1 view":`${g.useCount||0} views`;f.textContent=`Expires ${Je(g.expiresAt)} - ${l}`,q.appendChild(x),q.appendChild(f);const w=document.createElement("button");w.className="btn btn-ghost btn-sm",w.textContent="Revoke",w.addEventListener("click",async()=>{if(await E.confirm("Revoke this link? Anyone holding it loses access immediately."))try{await L.pages.previewLinks.revoke(g.id),E.toast("Link revoked.",{type:"success"}),await Z()}catch(oe){E.toast("Could not revoke: "+(oe.message||"unknown error"),{type:"error"})}}),C.appendChild(q),C.appendChild(w),F.appendChild(C)})};i.addEventListener("click",async()=>{i.disabled=!0,i.textContent="Creating\u2026";try{const K=await L.pages.previewLinks.create(e,V.value,Y.value.trim());B.value=K.url,P.style.display="",Y.value="",E.toast("Share link created.",{type:"success"}),await Z(),B.select()}catch(K){E.toast("Could not create link: "+(K.message||"unknown error"),{type:"error"})}finally{i.disabled=!1,i.textContent="Create link"}}),A.element.appendChild(v),A.open(),await Z()}let ge=!1,Le=null,Fe=!1;function Xe(e){return e.split(`
88
- `).map(A=>A.trimEnd()).join(`
87
+ [/dconfig]`,null)),oe.appendChild(ye);const Pe=document.createElement("div");Pe.appendChild(m("CSS Editor")),Pe.appendChild(f("The toolbar's </> button (left of the Split View icon) swaps the left pane between Markdown and Custom CSS. Edits are saved together with the page - one Save, one toast."));const Fe=document.createElement("table");Fe.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[["</> button","Toggle between Markdown editor and Custom CSS editor"],["Split / Write / Preview","Standard view mode buttons to the right of </>"],["Save","Saves both page content and CSS in a single operation"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),Fe.appendChild(o)}),Pe.appendChild(Fe),oe.appendChild(Pe);const Ce=document.createElement("div");Ce.appendChild(m("Colour Picker")),Ce.appendChild(f("Insert \u2192 Colour Picker opens a centred colour picker. Pick a colour, then use Copy to copy the hex code to the clipboard or Insert to drop it at the cursor. Click outside the panel to dismiss.")),oe.appendChild(Ce);const ze=document.createElement("div");ze.appendChild(m("Keyboard Shortcuts"));const $e=document.createElement("table");$e.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[["Ctrl + B","Bold selected text"],["Ctrl + I","Italic selected text"],["Ctrl + K","Insert link dialog"],["Tab","Indent 2 spaces at cursor"],["Shift + Tab","Dedent 2 spaces on current line"],["Ctrl + X","Cut current line (no selection) or cut selection"],["Ctrl + C","Copy current line (no selection) or copy selection"],["Ctrl + V","Paste from clipboard"],["Ctrl + Z","Undo"],["Ctrl + Y","Redo"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;white-space:nowrap;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),$e.appendChild(o)}),ze.appendChild($e),x.appendChild(ze);const De=document.createElement("div");De.appendChild(m("Tips"));const He=document.createElement("table");He.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['class="text-center"',"Centre text and inline elements on any shortcode"],['class="mx-auto"',"Centre a block element horizontally"],["[center]...[/center]","Shorthand wrapper for centred content"]].forEach(([c,r])=>{const o=document.createElement("tr"),i=document.createElement("td");i.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;",i.appendChild(p(c));const n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border);vertical-align:top;color:var(--dm-text-muted);",n.textContent=r,o.appendChild(i),o.appendChild(n),He.appendChild(o)}),De.appendChild(He),De.appendChild(f("Most shortcodes accept a class attribute for custom styling.")),x.appendChild(De),e.setContent(U),e.open(),E.tabs(V),I.scan(U)}function Ct(e,T){const A=e.find("#history-tab").get(0),p=e.find("#version-list").get(0),m=e.find("#version-compare").get(0),U=e.find("#version-compare-old").get(0),V=e.find("#version-compare-new").get(0),F=e.find("#version-compare-label").get(0),u=e.find("#version-compare-back-btn").get(0),v=e.find("#version-restore-btn").get(0),x=e.find("#history-save-named-btn").get(0),G=e.find("#history-delete-selected-btn").get(0);let P=!1,Y=null,oe=null;function h(){p.style.display="",m.style.display="none",Y=null}function ae(){p.style.display="none",m.style.display=""}async function L(){p.textContent="";const k=document.createElement("p");k.style.color="var(--dm-text-muted)",k.textContent="Loading\u2026",p.appendChild(k);let H;try{H=(await N.versions.list(T)).versions||[]}catch(d){p.textContent="";const s=document.createElement("p");s.style.color="var(--dm-danger)",s.textContent="Failed to load versions: "+d.message,p.appendChild(s);return}if(p.textContent="",G.style.display="none",!H.length){const d=document.createElement("p");d.style.color="var(--dm-text-muted)",d.textContent="No versions saved yet. Versions are created automatically on each save.",p.appendChild(d);return}const B=document.createElement("table");B.style.cssText="width:100%;border-collapse:collapse;font-size:.875rem;";const f=document.createElement("thead"),l=document.createElement("tr"),W=document.createElement("th");W.style.cssText="padding:.5rem .75rem;width:2rem;border-bottom:1px solid var(--dm-border);";const q=document.createElement("input");q.type="checkbox",q.setAttribute("aria-label","Select all versions"),W.appendChild(q),l.appendChild(W),["Date","Author","Type","Label","Actions"].forEach(d=>{const s=document.createElement("th");s.style.cssText="text-align:left;padding:.5rem .75rem;border-bottom:1px solid var(--dm-border);font-size:.8rem;color:var(--dm-text-muted);",s.textContent=d,l.appendChild(s)}),f.appendChild(l),B.appendChild(f);const z=[];function Ee(){const d=z.some(K=>K.checked),s=z.length>0&&z.every(K=>K.checked);G.style.display=d?"":"none",q.checked=s,q.indeterminate=d&&!s}q.addEventListener("change",()=>{z.forEach(d=>{d.checked=q.checked}),Ee()});const j=document.createElement("tbody"),ee=new Map;H.forEach(d=>{const s=document.createElement("tr");s.style.borderBottom="1px solid var(--dm-border)",s.dataset.file=d.filename,s.tabIndex=0,s.className="pe-version-row";const K=document.createElement("td");K.style.padding=".5rem .75rem";const ue=document.createElement("input");ue.type="checkbox",ue.value=d.filename,ue.addEventListener("change",Ee),K.appendChild(ue),z.push(ue);const re=document.createElement("td");re.style.padding=".5rem .75rem",re.textContent=D(d.createdAt).format("D MMM YYYY, HH:mm");const ge=document.createElement("td");ge.style.padding=".5rem .75rem",ge.textContent=d.author||"-";const be=document.createElement("td");be.style.padding=".5rem .75rem";const le=document.createElement("span");le.className="badge badge-"+(d.type==="manual"?"primary":"secondary"),le.style.cssText="font-size:.75rem;padding:.2rem .5rem;border-radius:4px;",le.textContent=d.type,be.appendChild(le);const pe=document.createElement("td");pe.style.cssText="padding:.5rem .75rem;color:var(--dm-text-muted);",pe.textContent=d.label||"-";const te=document.createElement("td");te.style.padding=".5rem .75rem";const he=async()=>{try{const J=await N.versions.get(T,d.filename);U.textContent=J.content,V.textContent=e.find("#markdown-editor").get(0).value,F.textContent=D(d.createdAt).format("D MMM YYYY, HH:mm")+(d.label?` - ${d.label}`:""),Y=d.filename,ae()}catch(J){E.toast("Failed to load version: "+J.message,{type:"error"})}},xe=async()=>{if(await E.confirm("Delete this version? This cannot be undone."))try{await N.versions.delete(T,d.filename),E.toast("Version deleted.",{type:"success"}),await L()}catch(J){E.toast("Failed to delete: "+J.message,{type:"error"})}};ee.set(d.filename,{version:d,compare:he,remove:xe,restore:()=>{Y=d.filename,v.click()}});const ie=document.createElement("button");ie.type="button",ie.className="pe-kebab",ie.title="Actions",ie.setAttribute("aria-label","Actions for this version"),ie.textContent="\u22EE",te.appendChild(ie),s.appendChild(K),s.appendChild(re),s.appendChild(ge),s.appendChild(be),s.appendChild(pe),s.appendChild(te),j.appendChild(s)}),B.appendChild(j),p.appendChild(B),I.scan(p);try{oe?.destroy?.()}catch{}oe=E.contextMenu(j,{cursor:"glyph",match:"tr[data-file]",inherit:!1,density:"compact",items:d=>{const s=ee.get(d.dataset.file);return s?[{header:D(s.version.createdAt).format("D MMM YYYY, HH:mm")+(s.version.label?` - ${s.version.label}`:"")},{label:"Compare with the editor",icon:"columns",action:()=>s.compare()},{label:"Restore this version\u2026",icon:"rotate-ccw",action:()=>s.restore()},{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>s.remove()}]:[]}}),j.addEventListener("click",d=>{const s=d.target.closest("tr[data-file]");if(!s||d.target.matches("input"))return;const K=d.target.closest(".pe-kebab");if(K){Ke(K);return}ee.get(s.dataset.file)?.compare()}),j.addEventListener("keydown",d=>{const s=d.target.closest("tr[data-file]");s&&(d.key==="F10"&&d.shiftKey?(d.preventDefault(),Ke(s)):d.key==="Enter"&&d.target===s&&ee.get(s.dataset.file)?.compare())})}A.addEventListener("click",async()=>{P||(P=!0,await L())}),u.addEventListener("click",()=>{h()}),v.addEventListener("click",async()=>{if(!(!Y||!await E.confirm("Restore this version? The current page content will be overwritten (a pre-restore snapshot will be saved automatically).")))try{await N.versions.restore(T,Y),E.toast("Page restored. Reloading editor\u2026",{type:"success"}),R.navigate("/pages"),setTimeout(()=>R.navigate(`/pages/edit${T}`),300)}catch(k){E.toast("Restore failed: "+k.message,{type:"error"})}}),G.addEventListener("click",async()=>{const k=[...p.querySelectorAll("tbody input[type=checkbox]:checked")].map(H=>H.value);if(!(!k.length||!await E.confirm(`Delete ${k.length} version${k.length>1?"s":""}? This cannot be undone.`)))try{await N.versions.bulkDelete(T,k),E.toast(`${k.length} version${k.length>1?"s":""} deleted.`,{type:"success"}),await L()}catch(H){E.toast("Delete failed: "+H.message,{type:"error"})}}),x.addEventListener("click",()=>{const k=E.slideover({title:"Save Named Version",size:"sm",position:"right"}),H=document.createElement("div");H.style.padding="1rem";const B=document.createElement("label");B.className="form-label",B.textContent="Version Label";const f=document.createElement("input");f.type="text",f.className="form-input",f.placeholder="e.g. Initial design, Before restructure",f.style.marginBottom=".75rem";const l=document.createElement("button");l.className="btn btn-primary",l.textContent="Save Version",l.addEventListener("click",async()=>{const W=f.value.trim();try{await N.versions.create(T,W||null),E.toast("Named version saved.",{type:"success"}),k.close(),P=!1,A.classList.contains("active")&&(P=!0,await L())}catch(q){E.toast("Failed to save version: "+q.message,{type:"error"})}}),H.appendChild(B),H.appendChild(f),H.appendChild(l),k.element.appendChild(H),k.open(),setTimeout(()=>f.focus(),100)})}function wt(e){try{return D(e).format("D MMM YYYY, HH:mm")}catch{return new Date(e).toLocaleString()}}async function Et(e){const T=E.slideover({title:"Share preview link",size:"md",position:"right"}),A=document.createElement("div");A.style.padding="1rem";const p=document.createElement("p");p.className="form-hint",p.style.marginTop="0",p.textContent="Anyone with the link can view this page even while it is unpublished, without signing in. The link works for this page only, expires on its own, and can be revoked at any time.",A.appendChild(p);const m=document.createElement("label");m.className="form-label",m.textContent="Expires after";const U=document.createElement("select");U.className="form-select",[["1h","1 hour"],["24h","24 hours"],["7d","7 days"],["30d","30 days"]].forEach(([h,ae])=>{const L=document.createElement("option");L.value=h,L.textContent=ae,h==="7d"&&(L.selected=!0),U.appendChild(L)});const V=document.createElement("label");V.className="form-label",V.style.marginTop=".75rem",V.textContent="Note (optional)";const F=document.createElement("input");F.type="text",F.className="form-input",F.placeholder="e.g. For the client sign-off";const u=document.createElement("button");u.className="btn btn-primary",u.style.marginTop=".75rem",u.textContent="Create link";const v=document.createElement("div");v.style.marginTop=".75rem",v.style.display="none";const x=document.createElement("input");x.type="text",x.className="form-input",x.readOnly=!0,x.style.marginBottom=".4rem";const G=document.createElement("button");G.className="btn btn-secondary btn-sm",G.textContent="Copy link",G.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(x.value),E.toast("Link copied to clipboard.",{type:"success"})}catch{x.select(),E.toast("Press Ctrl+C to copy the selected link.",{type:"info"})}}),v.appendChild(x),v.appendChild(G),A.appendChild(m),A.appendChild(U),A.appendChild(V),A.appendChild(F),A.appendChild(u),A.appendChild(v);const P=document.createElement("h4");P.style.cssText="margin:1.5rem 0 .5rem;font-size:.9rem;",P.textContent="Active links",A.appendChild(P);const Y=document.createElement("div");A.appendChild(Y);const oe=async()=>{Y.textContent="";let h=[];try{h=await N.pages.previewLinks.list(e)}catch(L){const k=document.createElement("p");k.className="form-hint",k.textContent="Could not load existing links: "+(L.message||"unknown error"),Y.appendChild(k);return}const ae=h.filter(L=>!L.revokedAt&&!L.expired);if(!ae.length){const L=document.createElement("p");L.className="form-hint",L.textContent="No active links for this page.",Y.appendChild(L);return}ae.forEach(L=>{const k=document.createElement("div");k.style.cssText="display:flex;align-items:center;gap:.6rem;padding:.5rem 0;border-bottom:1px solid var(--dm-border-light);";const H=document.createElement("div");H.style.cssText="flex:1 1 auto;min-width:0;font-size:.82rem;";const B=document.createElement("div");B.style.fontWeight="600",B.textContent=L.label||"Untitled link";const f=document.createElement("div");f.style.opacity=".7";const l=L.useCount===1?"1 view":`${L.useCount||0} views`;f.textContent=`Expires ${wt(L.expiresAt)} - ${l}`,H.appendChild(B),H.appendChild(f);const W=document.createElement("button");W.className="btn btn-ghost btn-sm",W.textContent="Revoke",W.addEventListener("click",async()=>{if(await E.confirm("Revoke this link? Anyone holding it loses access immediately."))try{await N.pages.previewLinks.revoke(L.id),E.toast("Link revoked.",{type:"success"}),await oe()}catch(z){E.toast("Could not revoke: "+(z.message||"unknown error"),{type:"error"})}}),k.appendChild(H),k.appendChild(W),Y.appendChild(k)})};u.addEventListener("click",async()=>{u.disabled=!0,u.textContent="Creating\u2026";try{const h=await N.pages.previewLinks.create(e,U.value,F.value.trim());x.value=h.url,v.style.display="",F.value="",E.toast("Share link created.",{type:"success"}),await oe(),x.select()}catch(h){E.toast("Could not create link: "+(h.message||"unknown error"),{type:"error"})}finally{u.disabled=!1,u.textContent="Create link"}}),T.element.appendChild(A),T.open(),await oe()}let ce=null,Ze=!1;function xt(){Ze||!window.R?.use||(Ze=!0,R.use((e,T,A)=>{const p=T?.path||"",m=e?.path||"";return!(ht.test(p)&&m!==p)||!ce||ce.path!==p||!ce.dirty()?A():E.confirm("You have unsaved changes to this page. Leave anyway? They are kept as a draft for your next visit.").then(V=>{V?(ce?.keepDraft(),A()):history.replaceState(null,"","#"+p)})}),M.subscribe("router:afterChange",({to:e}={})=>{if(ce&&(e?.path||"")!==ce.path){const T=ce;ce=null,T.dispose()}}))}function kt(e){return e.split(`
88
+ `).map(T=>T.trimEnd()).join(`
89
89
  `).replace(/\n{3,}/g,`
90
90
 
91
- `)}const Me="editor_prefs";function Ne(){return S.get(Me)||{viewMode:"split",fullscreen:!1}}function ze(e,A){const v=Ne();v[e]=A,S.set(Me,v)}export const pageEditorView={templateUrl:"/admin/js/templates/page-editor.html",async onMount(e){const A=window.location.hash.match(/#\/pages\/edit(\/.*)/),v=A?A[1]:null,s=!!v,b=E.loader(e.get(0),{type:"dots"}),V=[L.layouts.get().catch(()=>({})),L.settings.get().catch(()=>({}))];s&&(V.push(L.pages.get(v).catch(()=>null)),V.push(L.pages.list().catch(()=>[])));const[W,Y,i,P]=await Promise.all(V);b.destroy(),Ve(e.find("#field-theme").get(0),{includeDefault:!0}),await Ze(e.find("#field-visibility").get(0),i?.visibility);const B=Y?.layoutOptions?.spacerSize??40;if(s&&!i){E.toast("Page not found.",{type:"error"}),R.navigate("/pages");return}e.find("#editor-title").text(s?`Edit Page - ${i.title||v}`:"New Page"),s&&e.find("#page-url-path").val(v),i&&(e.find("#field-title").val(i.title||""),e.find("#field-description").val(i.description||""),e.find("#field-status").val(i.status||"draft"),e.find("#field-sort-order").val(i.sortOrder??99),e.find("#field-show-in-nav").prop("checked",!!i.showInNav),e.find("#field-sidebar").prop("checked",!!i.sidebar),e.find("#field-show-breadcrumbs").prop("checked",i.breadcrumbs!==!1),e.find("#field-bundled").prop("checked",!!i.bundled),e.find("#field-category").val(i.category||""),e.find("#field-visibility").val(i.visibility||"public"),e.find("#field-theme").val(i.theme||""),e.find("#field-seo-title").val(i.seo?.title||""),e.find("#field-seo-desc").val(i.seo?.description||""),i.dconfig&&e.find("#field-dconfig").val(JSON.stringify(i.dconfig,null,2)));{const t=e.find("#field-project").get(0);if(t){const d=await L.projects.list().catch(()=>[]);d.forEach(p=>{const h=document.createElement("option");h.value=p.slug,h.textContent=p.name||p.slug,t.appendChild(h)});let u="";if(!s){const{getProjectFromHash:p}=await import("../lib/project-context.js");u=p()||""}if(!u&&i)if(i.project===null)u="";else if(typeof i.project=="string"&&i.project)u=i.project;else{const p=s?v:"";if(p){let h="",m=-1;for(const k of d)k.rootUrl&&(p===k.rootUrl||p.startsWith(k.rootUrl+"/"))&&k.rootUrl.length>m&&(h=k.slug,m=k.rootUrl.length);u=h}}t.value=u}}const H=e.find("#quick-switch");s&&Array.isArray(P)&&P.length&&([...P].sort((t,d)=>(t.title||t.urlPath).localeCompare(d.title||d.urlPath)).forEach(t=>{const d=document.createElement("option");d.value=t.urlPath,d.textContent=`${t.title||"Untitled"} (${t.urlPath})`,t.urlPath===v&&(d.selected=!0),H.get(0).appendChild(d)}),H.css("display",""),H.on("change",function(){const t=this.value;t&&R.navigate("/pages/edit"+t)}));const z=await L.pages.tags().catch(()=>[]),F=e.find("#field-tags").get(0),Z=F?E.pillbox(F,{data:z,value:i?.tags||[],creatable:!0,searchable:!0,placeholder:"Add tag\u2026"}):null,K=e.find("#field-layout").empty();if(Object.entries(W).forEach(([t,d])=>{const u=(i?.layout||"default")===t?"selected":"";K.append(`<option value="${t}" ${u}>${d.label||t}</option>`)}),s){const t=e.find("#view-page-btn").get(0);t.href=v,t.style.display="";const d=e.find("#history-tab").get(0);d.style.display=""}e.find("#live-preview-tab").get(0).style.display="",E.tabs(e.find("#editor-meta-tabs").get(0)),s&&_e(e,v);const M=e.find("#markdown-editor"),g=e.find("#markdown-preview");i&&M.val(i.content||"");let C=!1,q="";L.settings.getCustomCss().then(({css:t})=>{q=t||""}).catch(()=>{});let x=!1;const f=M.get(0),l=document.createElement("div");l.className="editor-line-numbers editor-line-numbers--foldable",f.parentElement.insertBefore(l,f);const w=We(f,l,{onFoldChange:()=>{}});w.setGuard(t=>{x=t});function O(){const t=e.find("#css-editor").get(0);if(!t)return;const d=t.value.split(`
92
- `);for(;l.firstChild;)l.removeChild(l.firstChild);d.forEach((u,p)=>{const h=document.createElement("span");h.className="editor-line-number-row";const m=document.createElement("span");m.className="fold-toggle fold-toggle--empty";const k=document.createElement("span");k.className="editor-line-num",k.textContent=String(p+1),h.appendChild(m),h.appendChild(k),l.appendChild(h)}),l.scrollTop=t.scrollTop}{const t=e.find("#css-editor").get(0);t&&t.addEventListener("scroll",()=>{l.scrollTop=t.scrollTop})}const oe=()=>{w.refresh(),l.scrollTop=f.scrollTop};f.addEventListener("input",oe),f.addEventListener("scroll",()=>{l.scrollTop=f.scrollTop});let fe=null;const y=()=>g.get(0),N=t=>t.replace(/<\/head>/i,"<style>body.dm-cloaked{opacity:1 !important;transition:none !important}</style></head>"),X=()=>{const t=y(),d=t&&t.contentDocument;if(!d||!d.head)return;const u=C&&e.find("#css-editor").val()||"";if(!u)return;let p=d.getElementById("preview-custom-css");p||(p=d.createElement("style"),p.id="preview-custom-css",d.head.appendChild(p)),p.textContent=u},ie=()=>{clearTimeout(fe),fe=setTimeout(async()=>{const t=y();if(!t||e.find("#editor-body").hasClass("editor-mode-write"))return;const d=w.getUnfoldedContent();try{const u=(e.find("#field-dconfig").val()||"").trim();let p=null;if(u)try{p=JSON.parse(u)}catch{p=null}const h=(e.find("#page-url-path").val()||"").trim()||v||"/",{html:m}=await L.pages.previewFull(h,Ce(p),d),k=N(m);let ae=0;try{ae=t.contentWindow.scrollY||0}catch{}t.addEventListener("load",function se(){t.removeEventListener("load",se);try{t.contentWindow.scrollTo(0,ae)}catch{}X()},{once:!0}),t.srcdoc=k}catch(u){t.srcdoc='<!doctype html><meta charset="utf-8"><body style="font:14px system-ui;padding:1rem;color:#b91c1c;">Preview failed: '+String(u&&u.message||"unknown error").replace(/[<&]/g,p=>p==="<"?"&lt;":"&amp;")+"</body>"}},500)},le=He(M,e.find("#editor-toolbar"),{spacerDefault:B});qe(M.get(0));let ce=!1,de="split",pe=null;const G=document.createElement("button");G.className="editor-view-btn",G.type="button";const te=document.createElement("span");te.setAttribute("data-icon","css-code"),G.appendChild(te);const j=document.createElement("button");j.className="editor-view-btn",j.type="button";const U=document.createElement("span");U.setAttribute("data-icon","code"),j.appendChild(U);let ne=!1;const _=document.createElement("button");_.className="editor-view-btn",_.type="button",_.innerHTML='<span data-icon="chevrons-down" data-icon-size="10" style="display:inline-flex;align-items:center;vertical-align:middle;"></span>',_.style.cssText="font-size:9px;letter-spacing:-1px;";const me=e.find(".editor-toolbar-right").get(0);me.prepend(_),me.prepend(j),me.prepend(G),I.scan(G),I.scan(j),I.scan(_),E.tooltip(G,{content:"Edit Custom CSS",position:"top"}),E.tooltip(j,{content:"Format Markdown",position:"top"}),E.tooltip(_,{content:"Fold / unfold all shortcodes",position:"top"}),j.addEventListener("click",()=>{const t=M.get(0),d=t.selectionStart,u=Xe(w.getUnfoldedContent());w.unfoldAll(),x=!0,t.value=u,x=!1,t.selectionStart=t.selectionEnd=Math.min(d,u.length),t.dispatchEvent(new Event("input")),w.refresh(),E.toast("Markdown formatted.",{type:"success"})}),_.addEventListener("click",()=>{ne?(w.unfoldAll(),_.innerHTML='<span data-icon="chevrons-down" data-icon-size="10" style="display:inline-flex;align-items:center;vertical-align:middle;"></span>',I.scan(_),_.classList.remove("active")):(w.foldAll(),_.innerHTML='<span data-icon="chevrons-right" data-icon-size="10" style="display:inline-flex;align-items:center;vertical-align:middle;"></span>',I.scan(_),_.classList.add("active")),ne=!ne});const ve=document.createElement("span");ve.className="editor-toolbar-sep",me.insertBefore(ve,me.children[3]),G.addEventListener("click",()=>{ce=!ce;const t=e.find("#markdown-editor"),d=e.find("#css-editor"),u=e.find("#editor-body");if(ce){const p=e.find(".editor-view-btn[data-mode].active").get(0);de=p?p.getAttribute("data-mode"):"split",e.find(".editor-view-btn[data-mode]").removeClass("active"),e.find('.editor-view-btn[data-mode="split"]').addClass("active"),u.removeClass("editor-mode-write editor-mode-preview").addClass("editor-mode-split"),t.hide(),d.show(),C||(d.val(q),C=!0,Ie(d.get(0))),O(),G.classList.add("active")}else e.find(".editor-view-btn[data-mode]").removeClass("active"),e.find(`.editor-view-btn[data-mode="${de}"]`).addClass("active"),u.removeClass("editor-mode-split editor-mode-write editor-mode-preview").addClass(`editor-mode-${de}`),d.hide(),t.show(),w.refresh(),G.classList.remove("active")});const ue=Ne();ue.viewMode&&ue.viewMode!=="split"&&(e.find(".editor-view-btn[data-mode]").removeClass("active"),e.find(`.editor-view-btn[data-mode="${ue.viewMode}"]`).addClass("active"),e.find("#editor-body").removeClass("editor-mode-split editor-mode-write editor-mode-preview").addClass(`editor-mode-${ue.viewMode}`)),ue.fullscreen&&e.find(".editor-card").addClass("editor-fullscreen"),e.find("#css-editor").on("input",()=>{O(),clearTimeout(pe),pe=setTimeout(()=>{X()},400)}),Oe({image:async t=>{const d=(await L.media.list().catch(()=>[])).filter(h=>/\.(png|jpe?g|gif|webp|svg)$/i.test(h.name)),u=document.createElement("div");if(u.className="media-picker-grid",d.length)d.forEach(h=>{const m=document.createElement("div");m.className="media-picker-item",m.dataset.url=h.url;const k=document.createElement("img");k.src=h.url,k.alt=h.name;const ae=document.createElement("span");ae.textContent=h.name,m.appendChild(k),m.appendChild(ae),u.appendChild(m)});else{const h=document.createElement("p");h.className="text-muted p-3",h.textContent="No images uploaded yet.",u.appendChild(h)}const p=E.slideover({title:"Insert Image",size:"lg",position:"right",content:u});$(p.element).on("click",".media-picker-item",function(){const h=$(this).data("url"),m=$(this).find("span").text();$e(t,`![${m}](${h})`),p.close(),t.dispatchEvent(new Event("input",{bubbles:!0}))}),p.open()},scribe:t=>Ye(t),card:t=>Re.open(t,{onMediaBrowse:()=>L.media.list().catch(()=>[])}),timeline:t=>Be.open(t,{onPreview:async d=>{try{return await L.pages.preview(d)}catch{return null}},onListCollections:()=>L.collections.list().catch(()=>[]),onGetCollection:d=>L.collections.get(d).catch(()=>null)})}),le.onEffects(t=>Ue.open(t)),le.onHelp(()=>{je()}),le.onTutorial(t=>{Ge(t)}),e.find(".editor-view-btn").on("click",function(){const t=$(this).data("mode");t&&(e.find(".editor-view-btn").removeClass("active"),$(this).addClass("active"),e.find("#editor-body").removeClass("editor-mode-split editor-mode-write editor-mode-preview").addClass(`editor-mode-${t}`),ze("viewMode",t),t!=="write"&&ie())}),e.find("#fullscreen-btn").on("click",function(){e.find(".editor-card").toggleClass("editor-fullscreen"),ze("fullscreen",e.find(".editor-card").hasClass("editor-fullscreen"))}),ge=!1,e.find("#quick-switch").prop("disabled",!1),Le&&window.removeEventListener("beforeunload",Le),Le=t=>{ge&&t.preventDefault()},window.addEventListener("beforeunload",Le),Fe||(Fe=!0,R.use((t,d,u)=>{const p=window.location.hash.startsWith("#/pages/edit")||window.location.hash==="#/pages/new";return!ge||!p?u():E.confirm("You have unsaved changes. Leave this page?").then(h=>{h&&(ge=!1,u())})})),M.on("input",()=>{x||(ge=!0,e.find("#quick-switch").prop("disabled",!0),ie())});const be=e.find("#editor-meta-tabs").get(0);be&&(be.addEventListener("input",()=>{ge=!0,e.find("#quick-switch").prop("disabled",!0)}),be.addEventListener("change",t=>{t.target.id!=="quick-switch"&&(ge=!0,e.find("#quick-switch").prop("disabled",!0))})),ie();const Ce=t=>({title:e.find("#field-title").val().trim()||"Untitled",description:e.find("#field-description").val().trim(),layout:e.find("#field-layout").val(),status:e.find("#field-status").val(),sortOrder:parseInt(e.find("#field-sort-order").val(),10)||99,showInNav:e.find("#field-show-in-nav").is(":checked"),sidebar:e.find("#field-sidebar").is(":checked"),...e.find("#field-show-breadcrumbs").is(":checked")?{}:{breadcrumbs:!1},...e.find("#field-bundled").is(":checked")?{bundled:!0}:{},tags:Z?Z.getValue():[],category:e.find("#field-category").val().trim()||null,visibility:e.find("#field-visibility").val()||"public",project:e.find("#field-project").val()||"",seo:{title:e.find("#field-seo-title").val().trim(),description:e.find("#field-seo-desc").val().trim()},dconfig:t,...e.find("#field-theme").val()?{theme:e.find("#field-theme").val()}:{}});(()=>{const t=e.find("#editor-body").get(0),d=e.find("#editor-divider").get(0);if(!t||!d)return;const u=15,p=85,h=T=>Math.min(p,Math.max(u,T));let m=h(parseFloat(Ne().splitRatio)||50);const k=T=>{t.style.setProperty("--dm-editor-split",m+"%"),d.setAttribute("aria-valuenow",String(Math.round(m))),T&&ze("splitRatio",m)};k(!1);const ae=T=>{const re=t.getBoundingClientRect();return re.width?h((T-re.left)/re.width*100):m},se=T=>{m=ae(T.clientX),k(!1)},he=()=>{document.removeEventListener("pointermove",se),document.removeEventListener("pointerup",he),t.classList.remove("is-resizing"),d.classList.remove("is-dragging"),k(!0)};d.addEventListener("pointerdown",T=>{window.matchMedia("(max-width: 768px)").matches||(T.preventDefault(),t.classList.add("is-resizing"),d.classList.add("is-dragging"),document.addEventListener("pointermove",se),document.addEventListener("pointerup",he))}),d.addEventListener("dblclick",()=>{m=50,k(!0)}),d.addEventListener("keydown",T=>{const re=T.shiftKey?10:2;let Q=m;if(T.key==="ArrowLeft")Q=m-re;else if(T.key==="ArrowRight")Q=m+re;else if(T.key==="Home")Q=u;else if(T.key==="End")Q=p;else if(T.key==="Enter"||T.key===" ")Q=50;else return;T.preventDefault(),m=h(Q),k(!0)})})(),(()=>{const t=e.find("#live-preview-frame").get(0),d=e.find("#live-preview-status").get(0),u=e.find("#live-preview-stage").get(0);if(!t)return;let p=null,h=!0,m=!1,k=!1;const ae=J=>{d&&(d.textContent=J)},se=()=>{const J=(e.find("#field-dconfig").val()||"").trim();if(!J)return null;try{return JSON.parse(J)}catch{return null}},he=async()=>{if(!k){k=!0,ae("Rendering\u2026");try{const J=(e.find("#page-url-path").val()||"").trim()||v||"/",{html:we}=await L.pages.previewFull(J,Ce(se()),w.getUnfoldedContent());let ye=0;try{ye=t.contentWindow.scrollY||0}catch{}t.addEventListener("load",function Ee(){t.removeEventListener("load",Ee);try{t.contentWindow.scrollTo(0,ye)}catch{}},{once:!0}),t.srcdoc=we,h=!1,ae("Showing unsaved changes")}catch(J){ae("Preview failed - "+(J&&J.message?J.message:"unknown error"))}finally{k=!1}}},T=()=>{h=!0,m&&(clearTimeout(p),p=setTimeout(he,600))},re=e.find("#live-preview-tab").get(0);re&&re.addEventListener("click",()=>{m=!0,h&&he()}),e.find("#editor-meta-tabs .tab-item").each(function(){this.id!=="live-preview-tab"&&this.addEventListener("click",()=>{m=!1})}),f.addEventListener("input",T);const Q=e.find("#editor-meta-tabs").get(0);Q&&(Q.addEventListener("input",T),Q.addEventListener("change",T)),e.find("#live-preview-refresh").on("click",()=>he()),e.find(".live-preview-width").on("click",function(){const J=this.getAttribute("data-width");e.find(".live-preview-width").removeClass("active"),$(this).addClass("active"),J==="full"?t.removeAttribute("data-width"):t.setAttribute("data-width",J),u&&(u.scrollTop=0)})})(),e.find("#share-preview-btn").on("click",async()=>{if(!s){E.toast("Save the page first - a share link needs a page to point at.",{type:"warning"});return}await Ke(v)}),e.find("#save-btn").on("click",async()=>{const t=e.find("#page-url-path").val().trim();if(!t){E.toast("URL path is required.",{type:"warning"});return}const d=e.find("#field-dconfig").val().trim();let u=null;if(d)try{u=JSON.parse(d)}catch{E.toast("DConfig JSON is invalid. Please check the format before saving.",{type:"warning"});return}const p=Ce(u);try{e.find("#save-btn").prop("disabled",!0).text("Saving\u2026");const h=w.getUnfoldedContent();if(s){const m={frontmatter:p,body:h};t!==v&&(m.newUrlPath=t),await L.pages.update(v,m),C&&await L.settings.saveCustomCss(e.find("#css-editor").val()),E.toast(C?"Page and CSS saved.":"Page saved successfully.",{type:"success"}),ge=!1,e.find("#quick-switch").prop("disabled",!1),t!==v&&R.navigate(`/pages/edit${t}`)}else await L.pages.create({urlPath:t,frontmatter:p,body:h}),C&&await L.settings.saveCustomCss(e.find("#css-editor").val()),E.toast(C?"Page and CSS saved.":"Page saved successfully.",{type:"success"}),ge=!1,R.navigate("/pages")}catch(h){E.toast(`Save failed: ${h.message||"Unknown error"}`,{type:"error"})}finally{e.find("#save-btn").prop("disabled",!1).text("Save")}}),e.find("#cancel-btn").on("click",()=>R.navigate("/pages")),Domma.icons.scan()}};async function Ze(e,A){if(!e)return;let v=[];try{const i=await L.get("/collections/roles/entries?limit=100");v=Array.isArray(i)?i:i?.entries||[]}catch{}const s=v.map(i=>({name:i.data?.name,label:i.data?.label||i.data?.name,level:i.data?.level??99})).filter(i=>i.name&&i.level!==0).sort((i,P)=>P.level-i.level),b=(i,P)=>Object.assign(document.createElement("option"),{value:i,textContent:P}),V=()=>{typeof A=="string"&&A&&![...e.options].some(i=>i.value===A)&&e.append(b(A,`${A} (custom)`))};if(!s.length)return V();const W=document.createElement("optgroup");W.label="Role and above",s.forEach(i=>W.append(b(i.name,`${i.label} and above`)));const Y=document.createElement("optgroup");Y.label="Role only",s.forEach(i=>Y.append(b(`=${i.name}`,`${i.label} only`))),e.replaceChildren(b("public","Public - everyone"),W,Y,b("private","Private - super-admin only")),V()}
91
+ `)}const Qe="editor_prefs";function We(){return S.get(Qe)||{viewMode:"split",fullscreen:!1}}function _e(e,T){const A=We();A[e]=T,S.set(Qe,A)}export const pageEditorView={templateUrl:"/admin/js/templates/page-editor.html",async onMount(e){if(xt(),ce){const t=ce;ce=null,t.dispose()}const T=window.location.hash.replace(/^#/,""),A=[],p=t=>(A.push(t),t);let m=!1,U=()=>{};const V={path:T,dirty:()=>m,keepDraft:()=>{},dispose:()=>{A.splice(0).forEach(t=>{try{t()}catch{}})}};ce=V;const F=()=>ce===V&&e.get(0).isConnected,u=window.location.hash.match(/#\/pages\/edit(\/[^?]*)/),v=u?u[1]:null,x=!!v,G=E.loader(e.get(0),{type:"dots"}),P=[N.layouts.get().catch(()=>({})),N.settings.get().catch(()=>({}))];x&&(P.push(N.pages.get(v).catch(()=>null)),P.push(N.pages.list().catch(()=>[])));const[Y,oe,h,ae]=await Promise.all(P);if(!F()){G.destroy();return}if(G.destroy(),st(e.find("#field-theme").get(0),{includeDefault:!0}),await St(e.find("#field-visibility").get(0),h?.visibility),!F())return;const L=oe?.layoutOptions?.spacerSize??40;if(x&&!h){E.toast("Page not found.",{type:"error"}),R.navigate("/pages");return}e.find("#editor-title").text(x?`Edit Page - ${h.title||v}`:"New Page"),x&&e.find("#page-url-path").val(v),h&&(e.find("#field-title").val(h.title||""),e.find("#field-description").val(h.description||""),e.find("#field-status").val(h.status||"draft"),e.find("#field-sort-order").val(h.sortOrder??99),e.find("#field-show-in-nav").prop("checked",!!h.showInNav),e.find("#field-sidebar").prop("checked",!!h.sidebar),e.find("#field-show-breadcrumbs").prop("checked",h.breadcrumbs!==!1),e.find("#field-bundled").prop("checked",!!h.bundled),e.find("#field-category").val(h.category||""),e.find("#field-visibility").val(h.visibility||"public"),e.find("#field-theme").val(h.theme||""),e.find("#field-seo-title").val(h.seo?.title||""),e.find("#field-seo-desc").val(h.seo?.description||""),h.dconfig&&e.find("#field-dconfig").val(JSON.stringify(h.dconfig,null,2)));{const t=e.find("#field-project").get(0);if(t){const a=await N.projects.list().catch(()=>[]);if(!F())return;a.forEach(b=>{const y=document.createElement("option");y.value=b.slug,y.textContent=b.name||b.slug,t.appendChild(y)});let g="";if(!x){const{getProjectFromHash:b}=await import("../lib/project-context.js");if(!F())return;g=b()||""}if(!g&&h)if(h.project===null)g="";else if(typeof h.project=="string"&&h.project)g=h.project;else{const b=x?v:"";if(b){let y="",C=-1;for(const w of a)w.rootUrl&&(b===w.rootUrl||b.startsWith(w.rootUrl+"/"))&&w.rootUrl.length>C&&(y=w.slug,C=w.rootUrl.length);g=y}}t.value=g}}const k=e.find("#quick-switch");x&&Array.isArray(ae)&&ae.length&&([...ae].sort((t,a)=>(t.title||t.urlPath).localeCompare(a.title||a.urlPath)).forEach(t=>{const a=document.createElement("option");a.value=t.urlPath,a.textContent=`${t.title||"Untitled"} (${t.urlPath})`,t.urlPath===v&&(a.selected=!0),k.get(0).appendChild(a)}),k.css("display",""),k.on("change",function(){const t=this.value;t&&R.navigate("/pages/edit"+t)}));const H=await N.pages.tags().catch(()=>[]);if(!F())return;const B=e.find("#field-tags").get(0),f=B?E.pillbox(B,{data:H,value:h?.tags||[],creatable:!0,searchable:!0,placeholder:"Add tag\u2026",onChange:()=>U()}):null,l=e.find("#field-layout").empty();if(Object.entries(Y).forEach(([t,a])=>{const g=(h?.layout||"default")===t?"selected":"";l.append(`<option value="${t}" ${g}>${a.label||t}</option>`)}),x){const t=e.find("#view-page-btn").get(0);t.href=v,t.style.display="";const a=e.find("#history-tab").get(0);a.style.display=""}e.find("#live-preview-tab").get(0).style.display="",E.tabs(e.find("#editor-meta-tabs").get(0)),x&&Ct(e,v);const W=e.find("#markdown-editor"),q=e.find("#markdown-preview");h&&W.val(h.content||"");let z=!1,Ee="";N.settings.getCustomCss().then(({css:t})=>{Ee=t||""}).catch(()=>{});let j=!1;const ee=W.get(0),d=document.createElement("div");d.className="editor-line-numbers editor-line-numbers--foldable",ee.parentElement.insertBefore(d,ee);const s=ct(ee,d,{onFoldChange:()=>{}});s.setGuard(t=>{j=t});function K(){const t=e.find("#css-editor").get(0);if(!t)return;const a=t.value.split(`
92
+ `);for(;d.firstChild;)d.removeChild(d.firstChild);a.forEach((g,b)=>{const y=document.createElement("span");y.className="editor-line-number-row";const C=document.createElement("span");C.className="fold-toggle fold-toggle--empty";const w=document.createElement("span");w.className="editor-line-num",w.textContent=String(b+1),y.appendChild(C),y.appendChild(w),d.appendChild(y)}),d.scrollTop=t.scrollTop}{const t=e.find("#css-editor").get(0);t&&t.addEventListener("scroll",()=>{d.scrollTop=t.scrollTop})}const ue=()=>{s.refresh(),d.scrollTop=ee.scrollTop};ee.addEventListener("input",ue),ee.addEventListener("scroll",()=>{d.scrollTop=ee.scrollTop});let re=null;const ge=()=>q.get(0),be=t=>t.replace(/<\/head>/i,"<style>body.dm-cloaked{opacity:1 !important;transition:none !important}</style></head>"),le=()=>{const t=ge(),a=t&&t.contentDocument;if(!a||!a.head)return;const g=z&&e.find("#css-editor").val()||"";if(!g)return;let b=a.getElementById("preview-custom-css");b||(b=a.createElement("style"),b.id="preview-custom-css",a.head.appendChild(b)),b.textContent=g},pe=()=>{clearTimeout(re),re=setTimeout(async()=>{const t=ge();if(!t||e.find("#editor-body").hasClass("editor-mode-write"))return;const a=s.getUnfoldedContent();try{const g=(e.find("#field-dconfig").val()||"").trim();let b=null;if(g)try{b=JSON.parse(g)}catch{b=null}const y=(e.find("#page-url-path").val()||"").trim()||v||"/",{html:C}=await N.pages.previewFull(y,Ve(b),a),w=be(C);let Q=0;try{Q=t.contentWindow.scrollY||0}catch{}t.addEventListener("load",function me(){t.removeEventListener("load",me);try{t.contentWindow.scrollTo(0,Q)}catch{}le()},{once:!0}),t.srcdoc=w}catch(g){t.srcdoc='<!doctype html><meta charset="utf-8"><body style="font:14px system-ui;padding:1rem;color:#b91c1c;">Preview failed: '+String(g&&g.message||"unknown error").replace(/[<&]/g,b=>b==="<"?"&lt;":"&amp;")+"</body>"}},500)},te=it(W,e.find("#editor-toolbar"),{spacerDefault:L});rt(W.get(0));let he=!1,xe="split",ie=null;const J=document.createElement("button");J.className="editor-view-btn",J.type="button";const Ne=document.createElement("span");Ne.setAttribute("data-icon","css-code"),J.appendChild(Ne);const fe=document.createElement("button");fe.className="editor-view-btn",fe.type="button";const Oe=document.createElement("span");Oe.setAttribute("data-icon","code"),fe.appendChild(Oe);let Me=!1;const _=document.createElement("button");_.className="editor-view-btn",_.type="button",_.innerHTML='<span data-icon="chevrons-down" data-icon-size="10" style="display:inline-flex;align-items:center;vertical-align:middle;"></span>',_.style.cssText="font-size:9px;letter-spacing:-1px;";const ke=e.find(".editor-toolbar-right").get(0);ke.prepend(_),ke.prepend(fe),ke.prepend(J),I.scan(J),I.scan(fe),I.scan(_),E.tooltip(J,{content:"Edit Custom CSS",position:"top"}),E.tooltip(fe,{content:"Format Markdown",position:"top"}),E.tooltip(_,{content:"Fold / unfold all shortcodes",position:"top"}),fe.addEventListener("click",()=>{const t=W.get(0),a=t.selectionStart,g=kt(s.getUnfoldedContent());s.unfoldAll(),j=!0,t.value=g,j=!1,t.selectionStart=t.selectionEnd=Math.min(a,g.length),t.dispatchEvent(new Event("input")),s.refresh(),E.toast("Markdown formatted.",{type:"success"})}),_.addEventListener("click",()=>{Me?(s.unfoldAll(),_.innerHTML='<span data-icon="chevrons-down" data-icon-size="10" style="display:inline-flex;align-items:center;vertical-align:middle;"></span>',I.scan(_),_.classList.remove("active")):(s.foldAll(),_.innerHTML='<span data-icon="chevrons-right" data-icon-size="10" style="display:inline-flex;align-items:center;vertical-align:middle;"></span>',I.scan(_),_.classList.add("active")),Me=!Me});const Se=document.createElement("span");Se.className="editor-toolbar-sep",ke.insertBefore(Se,ke.children[3]),J.addEventListener("click",()=>{he=!he;const t=e.find("#markdown-editor"),a=e.find("#css-editor"),g=e.find("#editor-body");if(he){const b=e.find(".editor-view-btn[data-mode].active").get(0);xe=b?b.getAttribute("data-mode"):"split",e.find(".editor-view-btn[data-mode]").removeClass("active"),e.find('.editor-view-btn[data-mode="split"]').addClass("active"),g.removeClass("editor-mode-write editor-mode-preview").addClass("editor-mode-split"),t.hide(),a.show(),z||(a.val(Ee),z=!0,Ge(a.get(0))),K(),J.classList.add("active")}else e.find(".editor-view-btn[data-mode]").removeClass("active"),e.find(`.editor-view-btn[data-mode="${xe}"]`).addClass("active"),g.removeClass("editor-mode-split editor-mode-write editor-mode-preview").addClass(`editor-mode-${xe}`),a.hide(),t.show(),s.refresh(),J.classList.remove("active")});const Te=We();Te.viewMode&&Te.viewMode!=="split"&&(e.find(".editor-view-btn[data-mode]").removeClass("active"),e.find(`.editor-view-btn[data-mode="${Te.viewMode}"]`).addClass("active"),e.find("#editor-body").removeClass("editor-mode-split editor-mode-write editor-mode-preview").addClass(`editor-mode-${Te.viewMode}`)),Te.fullscreen&&e.find(".editor-card").addClass("editor-fullscreen"),e.find("#css-editor").on("input",()=>{U(),K(),clearTimeout(ie),ie=setTimeout(()=>{le()},400)}),dt({image:async t=>{const a=(await N.media.list().catch(()=>[])).filter(y=>/\.(png|jpe?g|gif|webp|svg)$/i.test(y.name)),g=document.createElement("div");if(g.className="media-picker-grid",a.length)a.forEach(y=>{const C=document.createElement("div");C.className="media-picker-item",C.dataset.url=y.url;const w=document.createElement("img");w.src=y.url,w.alt=y.name;const Q=document.createElement("span");Q.textContent=y.name,C.appendChild(w),C.appendChild(Q),g.appendChild(C)});else{const y=document.createElement("p");y.className="text-muted p-3",y.textContent="No images uploaded yet.",g.appendChild(y)}const b=E.slideover({title:"Insert Image",size:"lg",position:"right",content:g});$(b.element).on("click",".media-picker-item",function(){const y=$(this).data("url"),C=$(this).find("span").text();at(t,`![${C}](${y})`),b.close(),t.dispatchEvent(new Event("input",{bubbles:!0}))}),b.open()},scribe:t=>pt(t),card:t=>nt.open(t,{onMediaBrowse:()=>N.media.list().catch(()=>[])}),timeline:t=>ot.open(t,{onPreview:async a=>{try{return await N.pages.preview(a)}catch{return null}},onListCollections:()=>N.collections.list().catch(()=>[]),onGetCollection:a=>N.collections.get(a).catch(()=>null)})}),te.onEffects(t=>lt.open(t)),te.onHelp(()=>{Xe()}),te.onTutorial(t=>{mt(t)}),e.find(".editor-view-btn").on("click",function(){const t=$(this).data("mode");t&&(e.find(".editor-view-btn").removeClass("active"),$(this).addClass("active"),e.find("#editor-body").removeClass("editor-mode-split editor-mode-write editor-mode-preview").addClass(`editor-mode-${t}`),_e("viewMode",t),t!=="write"&&pe())}),e.find("#fullscreen-btn").on("click",function(){e.find(".editor-card").toggleClass("editor-fullscreen"),_e("fullscreen",e.find(".editor-card").hasClass("editor-fullscreen"))}),W.on("input",()=>{j||(U(),pe())});const ne=e.find("#editor-meta-tabs").get(0);ne&&(ne.addEventListener("input",()=>U()),ne.addEventListener("change",t=>{t.target.id!=="quick-switch"&&U()})),pe();const Ve=t=>({title:e.find("#field-title").val().trim()||"Untitled",description:e.find("#field-description").val().trim(),layout:e.find("#field-layout").val(),status:e.find("#field-status").val(),sortOrder:parseInt(e.find("#field-sort-order").val(),10)||99,showInNav:e.find("#field-show-in-nav").is(":checked"),sidebar:e.find("#field-sidebar").is(":checked"),...e.find("#field-show-breadcrumbs").is(":checked")?{}:{breadcrumbs:!1},...e.find("#field-bundled").is(":checked")?{bundled:!0}:{},tags:f?f.getValue():[],category:e.find("#field-category").val().trim()||null,visibility:e.find("#field-visibility").val()||"public",project:e.find("#field-project").val()||"",seo:{title:e.find("#field-seo-title").val().trim(),description:e.find("#field-seo-desc").val().trim()},dconfig:t,...e.find("#field-theme").val()?{theme:e.find("#field-theme").val()}:{}});(()=>{const t=e.find("#editor-body").get(0),a=e.find("#editor-divider").get(0);if(!t||!a)return;const g=15,b=85,y=O=>Math.min(b,Math.max(g,O));let C=y(parseFloat(We().splitRatio)||50);const w=O=>{t.style.setProperty("--dm-editor-split",C+"%"),a.setAttribute("aria-valuenow",String(Math.round(C))),O&&_e("splitRatio",C)};w(!1);const Q=O=>{const Ae=t.getBoundingClientRect();return Ae.width?y((O-Ae.left)/Ae.width*100):C},me=O=>{C=Q(O.clientX),w(!1)},Ue=()=>{document.removeEventListener("pointermove",me),document.removeEventListener("pointerup",Ue),t.classList.remove("is-resizing"),a.classList.remove("is-dragging"),w(!0)};a.addEventListener("pointerdown",O=>{window.matchMedia("(max-width: 768px)").matches||(O.preventDefault(),t.classList.add("is-resizing"),a.classList.add("is-dragging"),document.addEventListener("pointermove",me),document.addEventListener("pointerup",Ue))}),a.addEventListener("dblclick",()=>{C=50,w(!0)}),a.addEventListener("keydown",O=>{const Ae=O.shiftKey?10:2;let we=C;if(O.key==="ArrowLeft")we=C-Ae;else if(O.key==="ArrowRight")we=C+Ae;else if(O.key==="Home")we=g;else if(O.key==="End")we=b;else if(O.key==="Enter"||O.key===" ")we=50;else return;O.preventDefault(),C=y(we),w(!0)})})(),(()=>{const t=e.find("#live-preview-frame").get(0),a=e.find("#live-preview-status").get(0),g=e.find("#live-preview-stage").get(0);if(!t)return;let b=null,y=!0,C=!1,w=!1;const Q=se=>{a&&(a.textContent=se)},me=()=>{const se=(e.find("#field-dconfig").val()||"").trim();if(!se)return null;try{return JSON.parse(se)}catch{return null}},Ue=async()=>{if(!w){w=!0,Q("Rendering\u2026");try{const se=(e.find("#page-url-path").val()||"").trim()||v||"/",{html:et}=await N.pages.previewFull(se,Ve(me()),s.getUnfoldedContent());let je=0;try{je=t.contentWindow.scrollY||0}catch{}t.addEventListener("load",function tt(){t.removeEventListener("load",tt);try{t.contentWindow.scrollTo(0,je)}catch{}},{once:!0}),t.srcdoc=et,y=!1,Q("Showing unsaved changes")}catch(se){Q("Preview failed - "+(se&&se.message?se.message:"unknown error"))}finally{w=!1}}},O=()=>{y=!0,C&&(clearTimeout(b),b=setTimeout(Ue,600))},Ae=e.find("#live-preview-tab").get(0);Ae&&Ae.addEventListener("click",()=>{C=!0,y&&Ue()}),e.find("#editor-meta-tabs .tab-item").each(function(){this.id!=="live-preview-tab"&&this.addEventListener("click",()=>{C=!1})}),ee.addEventListener("input",O);const we=e.find("#editor-meta-tabs").get(0);we&&(we.addEventListener("input",O),we.addEventListener("change",O)),e.find("#live-preview-refresh").on("click",()=>Ue()),e.find(".live-preview-width").on("click",function(){const se=this.getAttribute("data-width");e.find(".live-preview-width").removeClass("active"),$(this).addClass("active"),se==="full"?t.removeAttribute("data-width"):t.setAttribute("data-width",se),g&&(g.scrollTop=0)})})(),e.find("#share-preview-btn").on("click",async()=>{if(!x){E.toast("Save the page first - a share link needs a page to point at.",{type:"warning"});return}await Et(v)});const ve=()=>({urlPath:(e.find("#page-url-path").val()||"").trim(),title:e.find("#field-title").val(),description:e.find("#field-description").val(),layout:e.find("#field-layout").val(),status:e.find("#field-status").val(),sortOrder:e.find("#field-sort-order").val(),showInNav:e.find("#field-show-in-nav").is(":checked"),sidebar:e.find("#field-sidebar").is(":checked"),breadcrumbs:e.find("#field-show-breadcrumbs").is(":checked"),bundled:e.find("#field-bundled").is(":checked"),tags:f?f.getValue():[],category:e.find("#field-category").val(),visibility:e.find("#field-visibility").val(),project:e.find("#field-project").val(),theme:e.find("#field-theme").val(),seoTitle:e.find("#field-seo-title").val(),seoDesc:e.find("#field-seo-desc").val(),dconfig:e.find("#field-dconfig").val(),body:s.getUnfoldedContent(),css:z?e.find("#css-editor").val():null}),X=(t,a)=>e.find(t).val(a==null?"":String(a)),Be=t=>{if(X("#page-url-path",t.urlPath),X("#field-title",t.title),X("#field-description",t.description),X("#field-layout",t.layout),X("#field-status",t.status),X("#field-sort-order",t.sortOrder),e.find("#field-show-in-nav").prop("checked",!!t.showInNav),e.find("#field-sidebar").prop("checked",!!t.sidebar),e.find("#field-show-breadcrumbs").prop("checked",!!t.breadcrumbs),e.find("#field-bundled").prop("checked",!!t.bundled),f&&f.setValue(Array.isArray(t.tags)?t.tags:[]),X("#field-category",t.category),X("#field-visibility",t.visibility),X("#field-project",t.project),X("#field-theme",t.theme),X("#field-seo-title",t.seoTitle),X("#field-seo-desc",t.seoDesc),X("#field-dconfig",t.dconfig),s.unfoldAll(),j=!0,ee.value=t.body==null?"":String(t.body),j=!1,s.refresh(),t.css!=null){const a=e.find("#css-editor").get(0);z||(z=!0,Ge(a)),a.value=String(t.css)}pe()};let de=qe(ve());const Ie=e.find("#pe-unsaved").get(0),ye=e.find("#discard-btn").get(0),Pe=e.find("#pe-problem").get(0);let Fe=null;const Ce=()=>{const t=ve();m=qe(t)!==de,Ie&&(Ie.hidden=!m),ye&&(ye.hidden=!m),e.find("#quick-switch").prop("disabled",m);const a=Je(t)[0];Pe&&(Pe.hidden=!a||!m,Pe.textContent=a?a.text:"")};U=()=>{clearTimeout(Fe),Fe=setTimeout(Ce,120)},p(()=>clearTimeout(Fe)),p(()=>{clearTimeout(re),clearTimeout(ie)});const ze=bt(v||""),$e=()=>{if(m)try{S.set(ze,vt(ve(),de))}catch{}},De=()=>{try{S.remove?S.remove(ze):S.set(ze,null)}catch{}};V.keepDraft=$e;const He=t=>{Ce(),m&&($e(),t.preventDefault(),t.returnValue="")};window.addEventListener("beforeunload",He),p(()=>window.removeEventListener("beforeunload",He));let c=!1;const r=async()=>{if(c)return;const t=ve(),a=Je(t);if(a.length){E.toast(a[0].text,{type:"warning"});const Q=[...e.find("#editor-meta-tabs .tab-item").get()],me=a[0].field==="dconfig"?3:1;Q[me]&&Q[me].click();return}const g=t.urlPath,b=(t.dconfig||"").trim(),y=b?JSON.parse(b):null,C=Ve(y);c=!0;const w=e.find("#save-btn").get(0);w&&(w.disabled=!0,w.lastChild.textContent=" Saving\u2026");try{const Q=s.getUnfoldedContent();if(x){const me={frontmatter:C,body:Q};g!==v&&(me.newUrlPath=g),await N.pages.update(v,me),z&&await N.settings.saveCustomCss(e.find("#css-editor").val()),E.toast(z?"Page and CSS saved.":"Page saved.",{type:"success"}),De(),de=qe(ve()),Ce(),g!==v&&R.navigate(`/pages/edit${g}`)}else await N.pages.create({urlPath:g,frontmatter:C,body:Q}),z&&await N.settings.saveCustomCss(e.find("#css-editor").val()),E.toast(z?"Page and CSS saved.":"Page saved.",{type:"success"}),De(),de=qe(ve()),m=!1,R.navigate("/pages")}catch(Q){E.toast(`Save failed: ${Q.message||"Unknown error"}`,{type:"error"})}finally{c=!1,w&&(w.disabled=!1,w.lastChild.textContent=" Save")}};e.find("#save-btn").on("click",()=>r());const o=async()=>{!m||!await E.confirm("Discard the changes you have not saved?")||(Be(JSON.parse(de)),De(),Ce())};ye&&ye.addEventListener("click",o);const i=t=>{(t.ctrlKey||t.metaKey)&&!t.shiftKey&&!t.altKey&&t.key.toLowerCase()==="s"&&F()&&(t.preventDefault(),r())};document.addEventListener("keydown",i),p(()=>document.removeEventListener("keydown",i));const n=e.get(0).querySelector(".dm-plugin-banner-name");if(n){const t=n.lastChild,a=ft(x,h?.title,v);t&&t.nodeType===3&&n.querySelector(".dm-plugin-banner-sep")?t.textContent=a:n.textContent=`Pages \u203A ${a}`}Ye(e,{id:"page-editor-back",icon:"arrow-left",title:"Back to Pages",onClick:()=>R.navigate("/pages")}),Ye(e,{id:"page-editor-help",icon:"help-circle",title:"Editor reference",onClick:()=>Xe()}),x&&Ye(e,{id:"page-editor-view",icon:"external-link",title:"View on the site",onClick:()=>window.open(e.find("#page-url-path").val()||v,"_blank","noopener")}),Ye(e,{id:"page-editor-save",icon:"save",title:"Save (Ctrl+S)",onClick:()=>r()});const Re=e.get(0).querySelector(".dm-plugin-body")||e.get(0);p(ut(Re,{position:"bottom"})),Domma.icons.scan(),Ce();let Z=null;try{Z=S.get(ze)}catch{}const Le=yt(Z);if(Le&&(De(),qe(Le.state)!==de)){const t=Le.at?` (${D(Le.at).format("D MMM HH:mm")})`:"",a=gt(Le,de)?" The saved page has changed since - restoring puts your version back over it (the saved one stays in History).":"";await E.confirm(`You left unsaved changes to this page${t}. Restore them?${a}`)&&F()&&(Be(Le.state),Ce())}}};async function St(e,T){if(!e)return;let A=[];try{const u=await N.get("/collections/roles/entries?limit=100");A=Array.isArray(u)?u:u?.entries||[]}catch{}const p=A.map(u=>({name:u.data?.name,label:u.data?.label||u.data?.name,level:u.data?.level??99})).filter(u=>u.name&&u.level!==0).sort((u,v)=>v.level-u.level),m=(u,v)=>Object.assign(document.createElement("option"),{value:u,textContent:v}),U=()=>{typeof T=="string"&&T&&![...e.options].some(u=>u.value===T)&&e.append(m(T,`${T} (custom)`))};if(!p.length)return U();const V=document.createElement("optgroup");V.label="Role and above",p.forEach(u=>V.append(m(u.name,`${u.label} and above`)));const F=document.createElement("optgroup");F.label="Role only",p.forEach(u=>F.append(m(`=${u.name}`,`${u.label} only`))),e.replaceChildren(m("public","Public - everyone"),V,F,m("private","Private - super-admin only")),U()}