domma-cms 0.6.16 → 0.6.21

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 (44) hide show
  1. package/admin/js/api.js +1 -1
  2. package/admin/js/app.js +4 -4
  3. package/admin/js/lib/markdown-toolbar.js +14 -14
  4. package/admin/js/views/collection-editor.js +5 -3
  5. package/admin/js/views/collections.js +1 -1
  6. package/admin/js/views/page-editor.js +27 -27
  7. package/config/plugins.json +16 -0
  8. package/config/site.json +1 -1
  9. package/package.json +2 -2
  10. package/plugins/analytics/stats.json +1 -1
  11. package/plugins/contacts/admin/templates/contacts.html +126 -0
  12. package/plugins/contacts/admin/views/contacts.js +710 -0
  13. package/plugins/contacts/config.js +6 -0
  14. package/plugins/contacts/data/contacts.json +20 -0
  15. package/plugins/contacts/plugin.js +351 -0
  16. package/plugins/contacts/plugin.json +23 -0
  17. package/plugins/docs/admin/templates/docs.html +69 -0
  18. package/plugins/docs/admin/views/docs.js +276 -0
  19. package/plugins/docs/config.js +8 -0
  20. package/plugins/docs/data/documents/452f49b7-9c93-4a67-874d-27f882891ad2.json +11 -0
  21. package/plugins/docs/data/documents/57e003f0-68f2-47dc-9c36-ed4b10ed3deb.json +11 -0
  22. package/plugins/docs/data/folders.json +9 -0
  23. package/plugins/docs/data/templates.json +1 -0
  24. package/plugins/docs/plugin.js +375 -0
  25. package/plugins/docs/plugin.json +23 -0
  26. package/plugins/notes/admin/templates/notes.html +92 -0
  27. package/plugins/notes/admin/views/notes.js +304 -0
  28. package/plugins/notes/config.js +6 -0
  29. package/plugins/notes/data/notes.json +1 -0
  30. package/plugins/notes/plugin.js +177 -0
  31. package/plugins/notes/plugin.json +23 -0
  32. package/plugins/todo/admin/templates/todo.html +164 -0
  33. package/plugins/todo/admin/views/todo.js +328 -0
  34. package/plugins/todo/config.js +7 -0
  35. package/plugins/todo/data/todos.json +1 -0
  36. package/plugins/todo/plugin.js +155 -0
  37. package/plugins/todo/plugin.json +23 -0
  38. package/server/routes/api/auth.js +2 -0
  39. package/server/routes/api/collections.js +55 -0
  40. package/server/routes/api/forms.js +3 -0
  41. package/server/routes/api/settings.js +16 -1
  42. package/server/routes/public.js +2 -0
  43. package/server/services/markdown.js +169 -8
  44. package/server/services/plugins.js +3 -2
@@ -1,14 +1,14 @@
1
- import{api as W}from"../api.js";import{createToolbar as Te,insertAtCursor as fe}from"../lib/markdown-toolbar.js";import{populateThemeSelect as Se}from"../lib/themes.js";function Le(){const d=E.slideover({title:"Editor Reference",size:"md",position:"right"}),ie="background:var(--dm-surface-subtle,#1a1a2e);padding:.2rem .4rem;border-radius:3px;font-size:.85em;font-family:monospace;",ye="margin:1rem 0 .5rem;font-size:1rem;";function B(r){const t=document.createElement("code");return t.style.cssText=ie,t.textContent=r,t}function q(r){const t=document.createElement("h3");return t.style.cssText=ye,t.textContent=r,t}const xe=document.createElement("div");xe.style.cssText="padding:1rem;";const se=document.createElement("div");se.className="tabs";const Ee=document.createElement("div");Ee.className="tab-list",["Basics","Layout","Components","Data","Advanced"].forEach((r,t)=>{const e=document.createElement("button");e.className="tab-item"+(t===0?" active":""),e.textContent=r,Ee.appendChild(e)});const re=document.createElement("div");re.className="tab-content";const O="display:flex;flex-direction:column;gap:1rem;",ce=document.createElement("div");ce.className="tab-panel active",ce.style.cssText=O;const ne=document.createElement("div");ne.className="tab-panel",ne.style.cssText=O;const _=document.createElement("div");_.className="tab-panel",_.style.cssText=O;const pe=document.createElement("div");pe.className="tab-panel",pe.style.cssText=O;const ue=document.createElement("div");ue.className="tab-panel",ue.style.cssText=O,re.appendChild(ce),re.appendChild(ne),re.appendChild(_),re.appendChild(pe),re.appendChild(ue),se.appendChild(Ee),se.appendChild(re),xe.appendChild(se);const he=document.createElement("div");he.appendChild(q("Markdown Basics"));const X=document.createElement("table");X.style.cssText="width:100%;border-collapse:collapse;font-size:.9em;";const V=document.createElement("thead"),K=document.createElement("tr");["Syntax","Result"].forEach(r=>{const t=document.createElement("th");t.style.cssText="text-align:left;padding:.4rem .5rem;border-bottom:1px solid var(--dm-border,#333);",t.textContent=r,K.appendChild(t)}),V.appendChild(K),X.appendChild(V);const Y=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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.35rem .5rem;vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.35rem .5rem;vertical-align:top;color:var(--dm-text-muted,#aaa);font-size:.85em;",c.textContent=t,e.appendChild(n),e.appendChild(c),Y.appendChild(e)}),X.appendChild(Y),he.appendChild(X),ce.appendChild(he);const Z=document.createElement("div");Z.appendChild(q("Grid & Columns"));function L(r){const t=document.createElement("p");return t.style.cssText="margin:.3rem 0 .6rem;font-size:.82em;color:var(--dm-text-muted,#aaa);",t.textContent=r,t}function h(r,t,e){const n=document.createElement("p");n.style.cssText="margin:.75rem 0 .25rem;font-size:.85em;font-weight:600;",n.textContent=r;const c=document.createElement("pre");c.style.cssText=ie+"display:block;padding:.5rem .75rem;white-space:pre;overflow-x:auto;margin:0;",c.textContent=t;const ge=document.createDocumentFragment();return ge.appendChild(n),ge.appendChild(c),e&&ge.appendChild(L(e)),ge}const j=document.createElement("table");j.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['cols="N"',"[grid] only","Number of columns (1\u201312)"],['gap="N"',"[grid], [row]","Gap between columns/rows (1\u20136)"],['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(([r,t,e])=>{const n=document.createElement("tr");[r,t,e].forEach((c,ge)=>{const ve=document.createElement("td");ve.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",ge===0?ve.appendChild(B(r)):(ve.style.color="var(--dm-text-muted,#aaa)",ve.textContent=c),n.appendChild(ve)}),j.appendChild(n)}),Z.appendChild(j),Z.appendChild(h("Equal columns",`[grid cols="3" gap="4"]
1
+ import{api as V}from"../api.js";import{createToolbar as Te,insertAtCursor as fe}from"../lib/markdown-toolbar.js";import{populateThemeSelect as Se}from"../lib/themes.js";function Le(){const s=E.slideover({title:"Editor Reference",size:"md",position:"right"}),ie="background:var(--dm-surface-subtle,#1a1a2e);padding:.2rem .4rem;border-radius:3px;font-size:.85em;font-family:monospace;",ye="margin:1rem 0 .5rem;font-size:1rem;";function P(m){const t=document.createElement("code");return t.style.cssText=ie,t.textContent=m,t}function M(m){const t=document.createElement("h3");return t.style.cssText=ye,t.textContent=m,t}const xe=document.createElement("div");xe.style.cssText="padding:1rem;";const se=document.createElement("div");se.className="tabs";const Ee=document.createElement("div");Ee.className="tab-list",["Basics","Layout","Components","Data","Advanced"].forEach((m,t)=>{const e=document.createElement("button");e.className="tab-item"+(t===0?" active":""),e.textContent=m,Ee.appendChild(e)});const re=document.createElement("div");re.className="tab-content";const H="display:flex;flex-direction:column;gap:1rem;",ce=document.createElement("div");ce.className="tab-panel active",ce.style.cssText=H;const ne=document.createElement("div");ne.className="tab-panel",ne.style.cssText=H;const G=document.createElement("div");G.className="tab-panel",G.style.cssText=H;const pe=document.createElement("div");pe.className="tab-panel",pe.style.cssText=H;const ue=document.createElement("div");ue.className="tab-panel",ue.style.cssText=H,re.appendChild(ce),re.appendChild(ne),re.appendChild(G),re.appendChild(pe),re.appendChild(ue),se.appendChild(Ee),se.appendChild(re),xe.appendChild(se);const he=document.createElement("div");he.appendChild(M("Markdown Basics"));const X=document.createElement("table");X.style.cssText="width:100%;border-collapse:collapse;font-size:.9em;";const W=document.createElement("thead"),Q=document.createElement("tr");["Syntax","Result"].forEach(m=>{const t=document.createElement("th");t.style.cssText="text-align:left;padding:.4rem .5rem;border-bottom:1px solid var(--dm-border,#333);",t.textContent=m,Q.appendChild(t)}),W.appendChild(Q),X.appendChild(W);const Y=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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.35rem .5rem;vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.35rem .5rem;vertical-align:top;color:var(--dm-text-muted,#aaa);font-size:.85em;",u.textContent=t,e.appendChild(l),e.appendChild(u),Y.appendChild(e)}),X.appendChild(Y),he.appendChild(X),ce.appendChild(he);const Z=document.createElement("div");Z.appendChild(M("Grid & Columns"));function A(m){const t=document.createElement("p");return t.style.cssText="margin:.3rem 0 .6rem;font-size:.82em;color:var(--dm-text-muted,#aaa);",t.textContent=m,t}function y(m,t,e){const l=document.createElement("p");l.style.cssText="margin:.75rem 0 .25rem;font-size:.85em;font-weight:600;",l.textContent=m;const u=document.createElement("pre");u.style.cssText=ie+"display:block;padding:.5rem .75rem;white-space:pre;overflow-x:auto;margin:0;",u.textContent=t;const ge=document.createDocumentFragment();return ge.appendChild(l),ge.appendChild(u),e&&ge.appendChild(A(e)),ge}const j=document.createElement("table");j.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['cols="N"',"[grid] only","Number of columns (1\u201312)"],['gap="N"',"[grid], [row]","Gap between columns/rows (1\u20136)"],['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(([m,t,e])=>{const l=document.createElement("tr");[m,t,e].forEach((u,ge)=>{const ve=document.createElement("td");ve.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",ge===0?ve.appendChild(P(m)):(ve.style.color="var(--dm-text-muted,#aaa)",ve.textContent=u),l.appendChild(ve)}),j.appendChild(l)}),Z.appendChild(j),Z.appendChild(y("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.")),Z.appendChild(h("Column spanning (12-col base)",`[grid cols="12" gap="3"]
5
+ [/grid]`,"cols sets the track count; each [col] fills one track.")),Z.appendChild(y("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.")),Z.appendChild(h("Row (flexbox, equal-width)",`[row gap="4"]
8
+ [/grid]`,"span values must add up to cols. Common splits: 8/4, 6/6, 9/3.")),Z.appendChild(y("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.")),Z.appendChild(h("Card in a grid",`[grid cols="3" gap="4"]
11
+ [/row]`,"Use [row] when you want equal-width columns without specifying a count.")),Z.appendChild(y("Card in a grid",`[grid cols="3" gap="4"]
12
12
  [col]
13
13
  [card title="One"]Content[/card]
14
14
  [/col]
@@ -18,21 +18,21 @@ import{api as W}from"../api.js";import{createToolbar as Te,insertAtCursor as fe}
18
18
  [col]
19
19
  [card title="Three"]Content[/card]
20
20
  [/col]
21
- [/grid]`,null)),ne.appendChild(Z);const Q=document.createElement("div");Q.appendChild(q("Cards")),Q.appendChild(h("Basic card",`[card title="Optional Title"]
21
+ [/grid]`,null)),ne.appendChild(Z);const K=document.createElement("div");K.appendChild(M("Cards")),K.appendChild(y("Basic card",`[card title="Optional Title"]
22
22
  Markdown **works** here.
23
- [/card]`,"Omit title for a card with no header.")),Q.appendChild(h("Icon \u2014 inline (default)",`[card title="Feature" icon="star"]
23
+ [/card]`,"Omit title for a card with no header.")),K.appendChild(y("Icon \u2014 inline (default)",`[card title="Feature" icon="star"]
24
24
  Icon sits left of the title in a flex row.
25
- [/card]`,"icon accepts any Domma icon name. Default layout when icon is set.")),Q.appendChild(h("Icon \u2014 stacked (centred)",`[card title="Feature" icon="star" icon-layout="stacked" hover]
25
+ [/card]`,"icon accepts any Domma icon name. Default layout when icon is set.")),K.appendChild(y("Icon \u2014 stacked (centred)",`[card title="Feature" icon="star" icon-layout="stacked" hover]
26
26
  Icon is centred above the title. Great for feature tiles.
27
- [/card]`,'icon-layout="stacked" centres the icon above the title. Combine with hover for a lift effect.')),Q.appendChild(h("Icon with subtitle",`[card title="Feature" subtitle="Tagline here" icon="star" icon-layout="stacked"]
27
+ [/card]`,'icon-layout="stacked" centres the icon above the title. Combine with hover for a lift effect.')),K.appendChild(y("Icon with subtitle",`[card title="Feature" subtitle="Tagline here" icon="star" icon-layout="stacked"]
28
28
  Body content.
29
- [/card]`,"subtitle adds a secondary line beneath the title in both layouts.")),Q.appendChild(h("Collapsible card",`[card title="Click to expand" collapsible="true"]
29
+ [/card]`,"subtitle adds a secondary line beneath the title in both layouts.")),K.appendChild(y("Collapsible card",`[card title="Click to expand" collapsible="true"]
30
30
  Hidden by default.
31
- [/card]`,null)),Q.appendChild(h("Full attribute reference",`[card title="Title" subtitle="Sub" icon="star" icon-layout="stacked"
31
+ [/card]`,null)),K.appendChild(y("Full attribute reference",`[card title="Title" subtitle="Sub" icon="star" icon-layout="stacked"
32
32
  variant="primary" hover footer="Footer text"
33
33
  collapsible="true" class="extra" id="my-card"]
34
34
  Body content.
35
- [/card]`,'All attributes are optional. variant accepts "primary". icon-layout accepts "inline" (default) or "stacked".')),Q.appendChild(h("Rich header / footer sub-tags",`[card]
35
+ [/card]`,'All attributes are optional. variant accepts "primary". icon-layout accepts "inline" (default) or "stacked".')),K.appendChild(y("Rich header / footer sub-tags",`[card]
36
36
  [header]
37
37
  ### Custom Title with **bold** and [a link](/about)
38
38
  [/header]
@@ -42,45 +42,45 @@ Body content here.
42
42
  [footer]
43
43
  [Read more](/about) | [icon name="arrow-right" /]
44
44
  [/footer]
45
- [/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.")),_.appendChild(Q);const a=document.createElement("div");a.appendChild(q("Badge")),a.appendChild(L("Inline badge/label elements. Self-closing renders an empty coloured dot."));const m=document.createElement("table");m.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),m.appendChild(e)}),a.appendChild(m),a.appendChild(h("Basic badge",'[badge variant="success"]New[/badge]',null)),a.appendChild(h("Pill outline badge",'[badge variant="danger" outline pill]Deprecated[/badge]',null)),_.appendChild(a);const o=document.createElement("div");o.appendChild(q("Button")),o.appendChild(L("Renders a styled anchor as a Domma button. Use the Insert \u2192 Button toolbar item for a guided dialog."));const l=document.createElement("table");l.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),l.appendChild(e)}),o.appendChild(l),o.appendChild(h("Primary button",'[button href="/contact" variant="primary"]Get in touch[/button]',null)),o.appendChild(h("Self-closing with icon",'[button href="/download" variant="success" icon="download" size="sm" label="Download" /]',null)),o.appendChild(h("Opens in new tab",'[button href="https://example.com" variant="outline" target="_blank"]Visit site[/button]',null)),_.appendChild(o);const C=document.createElement("div");C.appendChild(q("Link (shortcode)")),C.appendChild(L("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 p=document.createElement("table");p.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),p.appendChild(e)}),C.appendChild(p),C.appendChild(h("External link in new tab",'[link href="https://example.com" target="_blank" icon-after="external-link"]Visit site[/link]',null)),C.appendChild(h("Self-closing with icon",'[link href="/about" icon="arrow-right" label="About us" /]',null)),_.appendChild(C);const u=document.createElement("div");u.appendChild(q("Spacer")),u.appendChild(L("Self-closing shortcode that inserts a fixed-height blank gap."));const v=document.createElement("table");v.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),v.appendChild(e)}),u.appendChild(v),u.appendChild(h("32px gap",'[spacer size="32" /]',null)),ne.appendChild(u);const f=document.createElement("div");f.appendChild(q("Icon")),f.appendChild(L("Self-closing shortcode that renders any Domma icon inline."));const g=document.createElement("table");g.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),g.appendChild(e)}),f.appendChild(g),f.appendChild(h("Coloured icon",'[icon name="star" size="24" color="#f5a623" /]',null)),_.appendChild(f);const w=document.createElement("div");w.appendChild(q("Center")),w.appendChild(L("Wraps content in a centred div. Works with any content including cards, grids, and text.")),w.appendChild(h("Example","[center]Centred content here[/center]",'Accepts an optional class="..." attribute for extra styling.')),ne.appendChild(w);const S=document.createElement("div");S.appendChild(q("Hero")),S.appendChild(L("Full-width hero sections \u2014 no plugin required. Uses Domma's built-in Hero CSS component."));const N=document.createElement("table");N.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),N.appendChild(e)}),S.appendChild(N),S.appendChild(h("Basic hero",'[hero title="Welcome" tagline="Build something great"][/hero]',null)),S.appendChild(h("Gradient with body content",`[hero title="Get Started" tagline="Everything you need." size="lg" variant="gradient-blue" align="center"]
45
+ [/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.")),G.appendChild(K);const n=document.createElement("div");n.appendChild(M("Badge")),n.appendChild(A("Inline badge/label elements. Self-closing renders an empty coloured dot."));const f=document.createElement("table");f.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),f.appendChild(e)}),n.appendChild(f),n.appendChild(y("Basic badge",'[badge variant="success"]New[/badge]',null)),n.appendChild(y("Pill outline badge",'[badge variant="danger" outline pill]Deprecated[/badge]',null)),G.appendChild(n);const d=document.createElement("div");d.appendChild(M("Button")),d.appendChild(A("Renders a styled anchor as a Domma button. Use the Insert \u2192 Button toolbar item for a guided dialog."));const o=document.createElement("table");o.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),o.appendChild(e)}),d.appendChild(o),d.appendChild(y("Primary button",'[button href="/contact" variant="primary"]Get in touch[/button]',null)),d.appendChild(y("Self-closing with icon",'[button href="/download" variant="success" icon="download" size="sm" label="Download" /]',null)),d.appendChild(y("Opens in new tab",'[button href="https://example.com" variant="outline" target="_blank"]Visit site[/button]',null)),G.appendChild(d);const v=document.createElement("div");v.appendChild(M("Link (shortcode)")),v.appendChild(A("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 h=document.createElement("table");h.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),h.appendChild(e)}),v.appendChild(h),v.appendChild(y("External link in new tab",'[link href="https://example.com" target="_blank" icon-after="external-link"]Visit site[/link]',null)),v.appendChild(y("Self-closing with icon",'[link href="/about" icon="arrow-right" label="About us" /]',null)),G.appendChild(v);const c=document.createElement("div");c.appendChild(M("Spacer")),c.appendChild(A("Self-closing shortcode that inserts a fixed-height blank gap."));const w=document.createElement("table");w.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),w.appendChild(e)}),c.appendChild(w),c.appendChild(y("32px gap",'[spacer size="32" /]',null)),ne.appendChild(c);const g=document.createElement("div");g.appendChild(M("Icon")),g.appendChild(A("Self-closing shortcode that renders any Domma icon inline."));const b=document.createElement("table");b.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),b.appendChild(e)}),g.appendChild(b),g.appendChild(y("Coloured icon",'[icon name="star" size="24" color="#f5a623" /]',null)),G.appendChild(g);const x=document.createElement("div");x.appendChild(M("Center")),x.appendChild(A("Wraps content in a centred div. Works with any content including cards, grids, and text.")),x.appendChild(y("Example","[center]Centred content here[/center]",'Accepts an optional class="..." attribute for extra styling.')),ne.appendChild(x);const S=document.createElement("div");S.appendChild(M("Hero")),S.appendChild(A("Full-width hero sections \u2014 no plugin required. Uses Domma's built-in Hero CSS component."));const z=document.createElement("table");z.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),z.appendChild(e)}),S.appendChild(z),S.appendChild(y("Basic hero",'[hero title="Welcome" tagline="Build something great"][/hero]',null)),S.appendChild(y("Gradient with body content",`[hero title="Get Started" tagline="Everything you need." size="lg" variant="gradient-blue" align="center"]
46
46
  Some introductory **Markdown** content here.
47
- [/hero]`,null)),S.appendChild(h("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.")),ne.appendChild(S);const T=document.createElement("div");T.appendChild(q("Interactive Components")),T.appendChild(L("Tabs, accordion, carousel, and countdown \u2014 no plugin required.")),T.appendChild(h("Tabs",`[tabs]
47
+ [/hero]`,null)),S.appendChild(y("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.")),ne.appendChild(S);const k=document.createElement("div");k.appendChild(M("Interactive Components")),k.appendChild(A("Tabs, accordion, carousel, and countdown \u2014 no plugin required.")),k.appendChild(y("Tabs",`[tabs]
48
48
  [tab title="First"]Content **A**[/tab]
49
49
  [tab title="Second"]Content **B**[/tab]
50
- [/tabs]`,'Add style="pills" for pill-style navigation.')),T.appendChild(h("Accordion",`[accordion]
50
+ [/tabs]`,'Add style="pills" for pill-style navigation.')),k.appendChild(y("Accordion",`[accordion]
51
51
  [item title="Question 1"]Answer here.[/item]
52
52
  [item title="Question 2"]Answer here.[/item]
53
- [/accordion]`,'Add multiple="true" to allow several panels open at once.')),T.appendChild(h("Accordion \u2014 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.")),T.appendChild(h("Carousel",`[carousel autoplay="true" interval="5000"]
53
+ [/accordion]`,'Add multiple="true" to allow several panels open at once.')),k.appendChild(y("Accordion \u2014 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.")),k.appendChild(y("Carousel",`[carousel autoplay="true" interval="5000"]
54
54
  [slide title="Slide 1"]Description[/slide]
55
55
  [slide image="/media/photo.jpg" title="Slide 2"]Caption[/slide]
56
- [/carousel]`,'Omit autoplay for a manual carousel. loop="false" disables wrapping.')),T.appendChild(h("Countdown (to date)",'[countdown to="2026-12-31" format="DD:HH:mm:ss" /]',null)),T.appendChild(h("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")),_.appendChild(T);const k=document.createElement("div");k.appendChild(q("Timeline")),k.appendChild(L("Renders a Domma Progression component with event items."));const F=document.createElement("table");F.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['layout="vertical|centred|horizontal"',"[timeline] \u2014 layout orientation (default: vertical)"],['theme="minimal|corporate|modern"',"[timeline] \u2014 visual theme (default: minimal)"],['mode="timeline|roadmap"',"[timeline] \u2014 display mode (default: timeline)"],['class="..."',"[timeline] \u2014 extra CSS classes"],['id="..."',"[timeline] \u2014 element id"],['title="..."',"[event] \u2014 event heading"],['date="..."',"[event] \u2014 display date string"],['status="planned|in-progress|completed|blocked"',"[event] \u2014 progress status"],['icon="..."',"[event] \u2014 Domma icon name"]].forEach(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),F.appendChild(e)}),k.appendChild(F),k.appendChild(h("Vertical timeline",`[timeline layout="vertical" theme="modern"]
56
+ [/carousel]`,'Omit autoplay for a manual carousel. loop="false" disables wrapping.')),k.appendChild(y("Countdown (to date)",'[countdown to="2026-12-31" format="DD:HH:mm:ss" /]',null)),k.appendChild(y("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")),G.appendChild(k);const T=document.createElement("div");T.appendChild(M("Timeline")),T.appendChild(A("Renders a Domma Progression component with event items."));const B=document.createElement("table");B.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",[['layout="vertical|centred|horizontal"',"[timeline] \u2014 layout orientation (default: vertical)"],['theme="minimal|corporate|modern"',"[timeline] \u2014 visual theme (default: minimal)"],['mode="timeline|roadmap"',"[timeline] \u2014 display mode (default: timeline)"],['class="..."',"[timeline] \u2014 extra CSS classes"],['id="..."',"[timeline] \u2014 element id"],['title="..."',"[event] \u2014 event heading"],['date="..."',"[event] \u2014 display date string"],['status="planned|in-progress|completed|blocked"',"[event] \u2014 progress status"],['icon="..."',"[event] \u2014 Domma icon name"]].forEach(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),B.appendChild(e)}),T.appendChild(B),T.appendChild(y("Vertical timeline",`[timeline layout="vertical" theme="modern"]
57
57
  [event title="Kickoff" date="Jan 2025" status="completed" icon="flag"]
58
58
  Project launched.
59
59
  [/event]
60
60
  [event title="Beta" date="Jun 2025" status="in-progress" icon="rocket"]
61
61
  In active development.
62
62
  [/event]
63
- [/timeline]`,null)),_.appendChild(k);const i=document.createElement("div");i.appendChild(q("Embedding a Form"));const x=document.createElement("table");x.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),x.appendChild(e)}),i.appendChild(x),i.appendChild(h("Basic",'[form name="contact" /]',"Forms are managed under Forms in the sidebar.")),i.appendChild(h("With wrapper styling",'[form name="newsletter" class="mt-4" id="newsletter-form" /]',null)),pe.appendChild(i);const s=document.createElement("div");s.appendChild(q("Displaying a Collection"));const y=document.createElement("pre");y.style.cssText=ie+"display:block;padding:.5rem .75rem;white-space:pre;overflow-x:auto;",y.textContent='[collection slug="enquiries" display="table" /]',s.appendChild(y);const b=[["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\u20134, default 3)."],["search","true/false \u2014 enable search in table mode (default true)."],["sortable","true/false \u2014 enable column sorting in table mode (default true)."],["exportable","true/false \u2014 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."]],z=document.createElement("table");z.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",b.forEach(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),z.appendChild(e)}),s.appendChild(z),s.appendChild(L("Table display uses Domma Table \u2014 search, sort, pagination, column selector, and CSV export are all built in. Cards and lists are static.")),pe.appendChild(s);const A=document.createElement("div");A.appendChild(q("View \u2014 Pro")),A.appendChild(L("Renders a Collection with full filtering, pagination, and display options. Requires a Pro MongoDB collection."));const H=document.createElement("table");H.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\u20134, default 3)."],["empty","Text shown when there are no entries."]].forEach(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),H.appendChild(e)}),A.appendChild(H),A.appendChild(h("Table display",'[view slug="products" display="table" limit="50" /]',null)),A.appendChild(h("Cards display",'[view slug="team" display="cards" columns="3" title-field="name" /]',null)),pe.appendChild(A);const M=document.createElement("div");M.appendChild(q("CTA \u2014 Pro")),M.appendChild(L("Renders an action button that triggers a Pro Action against an entry. Requires the Pro Actions feature."));const le=document.createElement("table");le.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),le.appendChild(e)}),M.appendChild(le),M.appendChild(h("Wrapping form",'[cta action="approve" entry="abc123" style="success" confirm="Approve this entry?"]Approve[/cta]',null)),M.appendChild(h("Self-closing",'[cta action="archive" entry="abc123" icon="archive" label="Archive" /]',null)),pe.appendChild(M);const ee=document.createElement("div");ee.appendChild(q("Effects")),ee.appendChild(L("Shortcodes for scroll-triggered animations, counters, typewriter text, and more. Requires the Domma Effects plugin."));const be=[['[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 \u2014 simple mode (text typed letter by letter)"],['[scribe loop="true"][render]Text[/render][wait]1500[/wait][undo /][/scribe]',"Typewriter \u2014 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"]],oe=document.createElement("table");oe.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",be.forEach(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),oe.appendChild(e)}),ee.appendChild(oe),ee.appendChild(h("Scribe script \u2014 looping multi-phrase typewriter",`[scribe loop="true" loop-delay="2000" delete-speed="20"]
63
+ [/timeline]`,null)),G.appendChild(T);const r=document.createElement("div");r.appendChild(M("Embedding a Form"));const p=document.createElement("table");p.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),p.appendChild(e)}),r.appendChild(p),r.appendChild(y("Basic",'[form name="contact" /]',"Forms are managed under Forms in the sidebar.")),r.appendChild(y("With wrapper styling",'[form name="newsletter" class="mt-4" id="newsletter-form" /]',null)),pe.appendChild(r);const a=document.createElement("div");a.appendChild(M("Displaying a Collection"));const C=document.createElement("pre");C.style.cssText=ie+"display:block;padding:.5rem .75rem;white-space:pre;overflow-x:auto;",C.textContent='[collection slug="enquiries" display="table" /]',a.appendChild(C);const i=[["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\u20134, default 3)."],["search","true/false \u2014 enable search in table mode (default true)."],["sortable","true/false \u2014 enable column sorting in table mode (default true)."],["exportable","true/false \u2014 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."]],L=document.createElement("table");L.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",i.forEach(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),L.appendChild(e)}),a.appendChild(L),a.appendChild(A("Table display uses Domma Table \u2014 search, sort, pagination, column selector, and CSV export are all built in. Cards and lists are static.")),pe.appendChild(a);const N=document.createElement("div");N.appendChild(M("View \u2014 Pro")),N.appendChild(A("Renders a Collection with full filtering, pagination, and display options. Requires a Pro MongoDB collection."));const F=document.createElement("table");F.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\u20134, default 3)."],["empty","Text shown when there are no entries."]].forEach(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),F.appendChild(e)}),N.appendChild(F),N.appendChild(y("Table display",'[view slug="products" display="table" limit="50" /]',null)),N.appendChild(y("Cards display",'[view slug="team" display="cards" columns="3" title-field="name" /]',null)),pe.appendChild(N);const O=document.createElement("div");O.appendChild(M("CTA \u2014 Pro")),O.appendChild(A("Renders an action button that triggers a Pro Action against an entry. Requires the Pro Actions feature."));const le=document.createElement("table");le.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;width:35%;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),le.appendChild(e)}),O.appendChild(le),O.appendChild(y("Wrapping form",'[cta action="approve" entry="abc123" style="success" confirm="Approve this entry?"]Approve[/cta]',null)),O.appendChild(y("Self-closing",'[cta action="archive" entry="abc123" icon="archive" label="Archive" /]',null)),pe.appendChild(O);const ee=document.createElement("div");ee.appendChild(M("Effects")),ee.appendChild(A("Shortcodes for scroll-triggered animations, counters, typewriter text, and more. Requires the Domma Effects plugin."));const be=[['[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 \u2014 simple mode (text typed letter by letter)"],['[scribe loop="true"][render]Text[/render][wait]1500[/wait][undo /][/scribe]',"Typewriter \u2014 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"]],oe=document.createElement("table");oe.style.cssText="width:100%;border-collapse:collapse;font-size:.85em;margin-bottom:.5rem;",be.forEach(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),oe.appendChild(e)}),ee.appendChild(oe),ee.appendChild(y("Scribe script \u2014 looping multi-phrase typewriter",`[scribe loop="true" loop-delay="2000" delete-speed="20"]
64
64
  [render]We build things that matter.[/render]
65
65
  [wait]1200[/wait]
66
66
  [undo all="true" /]
67
67
  [render]We design for humans.[/render]
68
68
  [wait]1200[/wait]
69
69
  [undo all="true" /]
70
- [/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 \u2014 plain text between actions is ignored.')),ee.appendChild(L("Enable the Domma Effects plugin to activate these shortcodes on your site.")),ue.appendChild(ee);const J=document.createElement("div");J.appendChild(q("Tables")),J.appendChild(L("Wrap a standard Markdown (GFM) table with Domma CSS classes and responsive horizontal scrolling."));const me=document.createElement("table");me.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),me.appendChild(e)}),J.appendChild(me),J.appendChild(h("Striped + bordered table",`[table striped="true" bordered="true" caption="Product Pricing"]
70
+ [/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 \u2014 plain text between actions is ignored.')),ee.appendChild(A("Enable the Domma Effects plugin to activate these shortcodes on your site.")),ue.appendChild(ee);const J=document.createElement("div");J.appendChild(M("Tables")),J.appendChild(A("Wrap a standard Markdown (GFM) table with Domma CSS classes and responsive horizontal scrolling."));const me=document.createElement("table");me.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),me.appendChild(e)}),J.appendChild(me),J.appendChild(y("Striped + bordered table",`[table striped="true" bordered="true" caption="Product Pricing"]
71
71
  | Product | Price |
72
72
  | ------- | ----: |
73
73
  | Widget | $9.99 |
74
74
  | Gadget | $14.99 |
75
- [/table]`,"The inner content must be a valid GFM Markdown table. The shortcode adds Domma CSS classes and wraps in a responsive scroll container.")),_.appendChild(J);const te=document.createElement("div");te.appendChild(q("Slideover")),te.appendChild(L("A trigger button that opens a slide-in panel with Markdown content. No plugin required."));const de=document.createElement("table");de.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),de.appendChild(e)}),te.appendChild(de),te.appendChild(h("Example",`[slideover title="More Info" trigger="Read more" size="md"]
75
+ [/table]`,"The inner content must be a valid GFM Markdown table. The shortcode adds Domma CSS classes and wraps in a responsive scroll container.")),G.appendChild(J);const te=document.createElement("div");te.appendChild(M("Slideover")),te.appendChild(A("A trigger button that opens a slide-in panel with Markdown content. No plugin required."));const de=document.createElement("table");de.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),de.appendChild(e)}),te.appendChild(de),te.appendChild(y("Example",`[slideover title="More Info" trigger="Read more" size="md"]
76
76
  ## Details
77
77
  Markdown content here.
78
- [/slideover]`,"Nested [card] and [grid] shortcodes work inside the slideover body.")),_.appendChild(te);const P=document.createElement("div");P.appendChild(q("DConfig \u2014 Declarative Behaviour")),P.appendChild(L("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.")),P.appendChild(h("Toggle a class on click",'{ "#my-btn": { "events": { "click": { "target": "#panel", "toggleClass": "hidden" } } } }','Selector keys use standard CSS selectors. "target" is optional \u2014 defaults to the element itself.')),P.appendChild(h("Inline shortcode syntax",`[dconfig]
78
+ [/slideover]`,"Nested [card] and [grid] shortcodes work inside the slideover body.")),G.appendChild(te);const q=document.createElement("div");q.appendChild(M("DConfig \u2014 Declarative Behaviour")),q.appendChild(A("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(y("Toggle a class on click",'{ "#my-btn": { "events": { "click": { "target": "#panel", "toggleClass": "hidden" } } } }','Selector keys use standard CSS selectors. "target" is optional \u2014 defaults to the element itself.')),q.appendChild(y("Inline shortcode syntax",`[dconfig]
79
79
  { "#my-btn": { "events": { "click": { "target": "#panel", "toggleClass": "hidden" } } } }
80
- [/dconfig]`,null)),ue.appendChild(P);const U=document.createElement("div");U.appendChild(q("Tips"));const G=document.createElement("table");G.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(([r,t])=>{const e=document.createElement("tr"),n=document.createElement("td");n.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",n.appendChild(B(r));const c=document.createElement("td");c.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",c.textContent=t,e.appendChild(n),e.appendChild(c),G.appendChild(e)}),U.appendChild(G),U.appendChild(L("Most shortcodes accept a class attribute for custom styling.")),ce.appendChild(U),d.setContent(xe),d.open(),E.tabs(se)}function ze(d,ie){const ye=d.find("#history-tab").get(0),B=d.find("#version-list").get(0),q=d.find("#version-compare").get(0),xe=d.find("#version-compare-old").get(0),se=d.find("#version-compare-new").get(0),Ee=d.find("#version-compare-label").get(0),re=d.find("#version-compare-back-btn").get(0),O=d.find("#version-restore-btn").get(0),ce=d.find("#history-save-named-btn").get(0);let ne=!1,_=null;function pe(){B.style.display="",q.style.display="none",_=null}function ue(){B.style.display="none",q.style.display=""}async function he(){B.textContent="";const X=document.createElement("p");X.style.color="var(--dm-text-muted)",X.textContent="Loading\u2026",B.appendChild(X);let V;try{V=(await W.versions.list(ie)).versions||[]}catch(L){B.textContent="";const h=document.createElement("p");h.style.color="var(--dm-text-danger,#e55)",h.textContent="Failed to load versions: "+L.message,B.appendChild(h);return}if(B.textContent="",!V.length){const L=document.createElement("p");L.style.color="var(--dm-text-muted)",L.textContent="No versions saved yet. Versions are created automatically on each save.",B.appendChild(L);return}const K=document.createElement("table");K.style.cssText="width:100%;border-collapse:collapse;font-size:.875rem;";const Y=document.createElement("thead"),ae=document.createElement("tr");["Date","Author","Type","Label","Actions"].forEach(L=>{const h=document.createElement("th");h.style.cssText="text-align:left;padding:.5rem .75rem;border-bottom:1px solid var(--dm-border);font-size:.8rem;color:var(--dm-text-muted);",h.textContent=L,ae.appendChild(h)}),Y.appendChild(ae),K.appendChild(Y);const Z=document.createElement("tbody");V.forEach(L=>{const h=document.createElement("tr");h.style.borderBottom="1px solid var(--dm-border)";const j=document.createElement("td");j.style.padding=".5rem .75rem",j.textContent=D(L.createdAt).format("D MMM YYYY, HH:mm");const Q=document.createElement("td");Q.style.padding=".5rem .75rem",Q.textContent=L.author||"\u2014";const a=document.createElement("td");a.style.padding=".5rem .75rem";const m=document.createElement("span");m.className="badge badge-"+(L.type==="manual"?"primary":"secondary"),m.style.cssText="font-size:.75rem;padding:.2rem .5rem;border-radius:4px;",m.textContent=L.type,a.appendChild(m);const o=document.createElement("td");o.style.cssText="padding:.5rem .75rem;color:var(--dm-text-muted);",o.textContent=L.label||"\u2014";const l=document.createElement("td");l.style.padding=".5rem .75rem";const C=document.createElement("button");C.className="btn btn-ghost btn-xs",C.style.marginRight=".4rem",C.textContent="Compare",C.addEventListener("click",async()=>{try{const u=await W.versions.get(ie,L.filename);xe.textContent=u.content,se.textContent=d.find("#markdown-editor").get(0).value,Ee.textContent=D(L.createdAt).format("D MMM YYYY, HH:mm")+(L.label?` \u2014 ${L.label}`:""),_=L.filename,ue()}catch(u){E.toast("Failed to load version: "+u.message,{type:"error"})}});const p=document.createElement("button");p.className="btn btn-ghost btn-xs",p.style.color="var(--dm-text-danger,#e55)",p.textContent="Delete",p.addEventListener("click",async()=>{if(await E.confirm("Delete this version? This cannot be undone."))try{await W.versions.delete(ie,L.filename),E.toast("Version deleted.",{type:"success"}),await he()}catch(v){E.toast("Failed to delete: "+v.message,{type:"error"})}}),l.appendChild(C),l.appendChild(p),h.appendChild(j),h.appendChild(Q),h.appendChild(a),h.appendChild(o),h.appendChild(l),Z.appendChild(h)}),K.appendChild(Z),B.appendChild(K)}ye.addEventListener("click",async()=>{ne||(ne=!0,await he())}),re.addEventListener("click",()=>{pe()}),O.addEventListener("click",async()=>{if(!(!_||!await E.confirm("Restore this version? The current page content will be overwritten (a pre-restore snapshot will be saved automatically).")))try{await W.versions.restore(ie,_),E.toast("Page restored. Reloading editor\u2026",{type:"success"}),R.navigate("/pages"),setTimeout(()=>R.navigate(`/pages/edit${ie}`),300)}catch(V){E.toast("Restore failed: "+V.message,{type:"error"})}}),ce.addEventListener("click",()=>{const X=E.modal({title:"Save Named Version"}),V=document.createElement("div");V.style.padding="1rem";const K=document.createElement("label");K.className="form-label",K.textContent="Version Label";const Y=document.createElement("input");Y.type="text",Y.className="form-input",Y.placeholder="e.g. Initial design, Before restructure",Y.style.marginBottom=".75rem";const ae=document.createElement("button");ae.className="btn btn-primary",ae.textContent="Save Version",ae.addEventListener("click",async()=>{const Z=Y.value.trim();try{await W.versions.create(ie,Z||null),E.toast("Named version saved.",{type:"success"}),X.close(),ne=!1,ye.classList.contains("active")&&(ne=!0,await he())}catch(L){E.toast("Failed to save version: "+L.message,{type:"error"})}}),V.appendChild(K),V.appendChild(Y),V.appendChild(ae),X.element.appendChild(V),X.open(),setTimeout(()=>Y.focus(),100)})}let Ce=!1,we=null,ke=!1;export const pageEditorView={templateUrl:"/admin/js/templates/page-editor.html",async onMount(d){const ye=window.location.hash.match(/#\/pages\/edit(\/.*)/),B=ye?ye[1]:null,q=!!B,xe=E.loader(d.get(0),{type:"dots"}),se=[W.layouts.get().catch(()=>({})),W.settings.get().catch(()=>({}))];q&&(se.push(W.pages.get(B).catch(()=>null)),se.push(W.pages.list().catch(()=>[])));const[Ee,re,O,ce]=await Promise.all(se);xe.destroy(),Se(d.find("#field-theme").get(0),{includeDefault:!0});const ne=re?.layoutOptions?.spacerSize??40;if(q&&!O){E.toast("Page not found.",{type:"error"}),R.navigate("/pages");return}d.find("#editor-title").text(q?`Edit Page \u2014 ${O.title||B}`:"New Page"),q&&d.find("#page-url-path").val(B),O&&(d.find("#field-title").val(O.title||""),d.find("#field-description").val(O.description||""),d.find("#field-status").val(O.status||"draft"),d.find("#field-sort-order").val(O.sortOrder??99),d.find("#field-show-in-nav").prop("checked",!!O.showInNav),d.find("#field-sidebar").prop("checked",!!O.sidebar),d.find("#field-show-breadcrumbs").prop("checked",O.breadcrumbs!==!1),d.find("#field-category").val(O.category||""),d.find("#field-visibility").val(O.visibility||"public"),d.find("#field-theme").val(O.theme||""),d.find("#field-seo-title").val(O.seo?.title||""),d.find("#field-seo-desc").val(O.seo?.description||""),O.dconfig&&d.find("#field-dconfig").val(JSON.stringify(O.dconfig,null,2)));const _=d.find("#quick-switch");q&&Array.isArray(ce)&&ce.length&&([...ce].sort((m,o)=>(m.title||m.urlPath).localeCompare(o.title||o.urlPath)).forEach(m=>{const o=document.createElement("option");o.value=m.urlPath,o.textContent=`${m.title||"Untitled"} (${m.urlPath})`,m.urlPath===B&&(o.selected=!0),_.get(0).appendChild(o)}),_.css("display",""),_.on("change",function(){const m=this.value;m&&R.navigate("/pages/edit"+m)}));const pe=await W.pages.tags().catch(()=>[]),ue=d.find("#field-tags").get(0),he=ue?E.pillbox(ue,{data:pe,value:O?.tags||[],creatable:!0,searchable:!0,placeholder:"Add tag\u2026"}):null,X=d.find("#field-layout").empty();if(Object.entries(Ee).forEach(([a,m])=>{const o=(O?.layout||"default")===a?"selected":"";X.append(`<option value="${a}" ${o}>${m.label||a}</option>`)}),q){const a=d.find("#view-page-btn").get(0);a.href=B,a.style.display="";const m=d.find("#live-preview-tab").get(0);m.style.display="";const o=d.find("#history-tab").get(0);o.style.display=""}if(E.tabs(d.find("#editor-meta-tabs").get(0)),q){const a=d.find("#live-preview-tab").get(0),m=d.find("#live-preview-frame").get(0);let o=!1;a.addEventListener("click",function(){o||(m.src=B,o=!0)}),ze(d,B)}const V=d.find("#markdown-editor"),K=d.find("#markdown-preview");O&&V.val(O.content||"");const Y=V.get(0),ae=document.createElement("div");ae.className="editor-line-numbers",Y.parentElement.insertBefore(ae,Y);const Z=()=>{const a=Y.value.split(`
81
- `).length;ae.textContent=Array.from({length:a},(m,o)=>o+1).join(`
82
- `),ae.scrollTop=Y.scrollTop};Z(),Y.addEventListener("input",Z),Y.addEventListener("scroll",()=>{ae.scrollTop=Y.scrollTop});let L=null;const h=()=>{clearTimeout(L),L=setTimeout(async()=>{try{const{html:a}=await W.pages.preview(V.val());K.html(a,{safe:!1}),I.scan(K.get(0)),K.get(0).querySelectorAll(".tabs").forEach(m=>Domma.elements.tabs(m))}catch{window.marked&&K.html(marked.parse(V.val()))}},400)},j=Te(V,d.find("#editor-toolbar"),{spacerDefault:ne});j.onLink(async a=>{const o=(await W.pages.list().catch(()=>[])).map(i=>({label:i.title||i.urlPath,value:i.urlPath})),l=document.createElement("div");l.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const C=document.createElement("label");C.className="form-label",C.textContent="URL";const p=document.createElement("input");p.type="text",p.className="form-input",p.placeholder="/about or https://example.com";const u=a.value.substring(a.selectionStart,a.selectionEnd);u&&u.startsWith("/")&&(p.value=u),l.appendChild(C),l.appendChild(p);const v=document.createElement("label");v.className="form-label",v.textContent="Link text";const f=document.createElement("input");f.type="text",f.className="form-input",f.placeholder="Display text",u&&!u.startsWith("/")&&(f.value=u),l.appendChild(v),l.appendChild(f);const g=document.createElement("label");g.className="form-label",g.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;";const w=document.createElement("input");w.type="checkbox",w.style.cssText="width:1rem;height:1rem;cursor:pointer;",g.appendChild(w),g.appendChild(document.createTextNode("Display as button")),l.appendChild(g);const S=document.createElement("label");S.className="form-label",S.textContent="Button colour",S.style.display="none";const N=document.createElement("select");N.className="form-select",N.style.display="none",[["primary","Primary"],["secondary","Secondary"],["success","Success (Green)"],["danger","Danger (Red)"],["warning","Warning (Orange)"],["info","Info (Blue)"],["outline","Outline"],["outline-success","Outline Success"],["outline-danger","Outline Danger"],["ghost","Ghost"]].forEach(([i,x])=>{const s=document.createElement("option");s.value=i,s.textContent=x,N.appendChild(s)}),l.appendChild(S),l.appendChild(N),w.addEventListener("change",()=>{const i=w.checked;S.style.display=i?"":"none",N.style.display=i?"":"none"});const k=document.createElement("button");k.type="button",k.className="btn btn-primary",k.textContent="Insert Link",l.appendChild(k);const F=E.modal({title:"Insert Link",size:"sm"});F.element.appendChild(l),F.open(),requestAnimationFrame(()=>{E.autocomplete(p,{data:o,minChars:1,onSelect:i=>{p.value=i.value,f.value||(f.value=i.label)}}),p.focus()}),k.addEventListener("click",()=>{const i=p.value.trim(),x=f.value.trim();if(!i)return;F.close();const s=w.checked?`[button href="${i}" variant="${N.value}"]${x||i}[/button]`:`[${x||i}](${i})`,y=a.selectionStart,b=a.selectionEnd;a.value=a.value.substring(0,y)+s+a.value.substring(b),a.selectionStart=a.selectionEnd=y+s.length,a.dispatchEvent(new Event("input",{bubbles:!0})),a.focus()})}),j.onImage(async a=>{const o=(await W.media.list().catch(()=>[])).filter(p=>/\.(png|jpe?g|gif|webp|svg)$/i.test(p.name)),l=document.createElement("div");if(l.className="media-picker-grid",o.length)o.forEach(p=>{const u=document.createElement("div");u.className="media-picker-item",u.dataset.url=p.url;const v=document.createElement("img");v.src=p.url,v.alt=p.name;const f=document.createElement("span");f.textContent=p.name,u.appendChild(v),u.appendChild(f),l.appendChild(u)});else{const p=document.createElement("p");p.className="text-muted p-3",p.textContent="No images uploaded yet.",l.appendChild(p)}const C=E.modal({title:"Insert Image",size:"lg"});C.element.appendChild(l),$(C.element).on("click",".media-picker-item",function(){const p=$(this).data("url"),u=$(this).find("span").text();fe(a,`![${u}](${p})`),C.close(),V.get(0).dispatchEvent(new Event("input",{bubbles:!0}))}),C.open()}),j.onCollection(async a=>{const[m,o]=await Promise.all([W.collections.list().catch(()=>[]),W.blocks.list().catch(()=>[])]),l=document.createElement("div");l.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const C="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",p="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",u=document.createElement("div"),v=document.createElement("label");v.style.cssText=C,v.textContent="Collection";const f=document.createElement("select");if(f.style.cssText=p,m.length)m.forEach(t=>{const e=document.createElement("option");e.value=t.slug,e.textContent=t.title||t.slug,f.appendChild(e)});else{const t=document.createElement("option");t.value="",t.textContent="No collections found",f.appendChild(t)}u.appendChild(v),u.appendChild(f),l.appendChild(u);const g=document.createElement("div"),w=document.createElement("label");w.style.cssText=C,w.textContent="Display";const S=document.createElement("select");S.style.cssText=p,["table","cards","list","block"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t.charAt(0).toUpperCase()+t.slice(1),S.appendChild(e)}),g.appendChild(w),g.appendChild(S),l.appendChild(g);const N=document.createElement("div");N.style.display="none";const T=document.createElement("label");T.style.cssText=C,T.textContent="Columns (2\u20134)";const k=document.createElement("input");k.type="number",k.min="2",k.max="4",k.value="3",k.style.cssText=p,N.appendChild(T),N.appendChild(k),l.appendChild(N);const F=document.createElement("div");F.style.display="none";const i=document.createElement("label");i.style.cssText=C,i.textContent="Block template";const x=document.createElement("select");if(x.style.cssText=p,o.length)o.forEach(t=>{const e=document.createElement("option");e.value=t.name??t,e.textContent=t.name??t,x.appendChild(e)});else{const t=document.createElement("option");t.value="",t.textContent="No block templates found",x.appendChild(t)}F.appendChild(i),F.appendChild(x),l.appendChild(F);const s=document.createElement("div"),y=document.createElement("label");y.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const b=document.createElement("input");b.type="checkbox",b.checked=!0,y.appendChild(b),y.appendChild(document.createTextNode("Enable search")),s.appendChild(y),l.appendChild(s);const z=document.createElement("div"),A=document.createElement("label");A.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const H=document.createElement("input");H.type="checkbox",H.checked=!0,A.appendChild(H),A.appendChild(document.createTextNode("Sortable columns")),z.appendChild(A),l.appendChild(z);const M=document.createElement("div"),le=document.createElement("label");le.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const ee=document.createElement("input");ee.type="checkbox",ee.checked=!1,le.appendChild(ee),le.appendChild(document.createTextNode("CSV export")),M.appendChild(le),l.appendChild(M);const be=document.createElement("div"),oe=document.createElement("label");oe.style.cssText=C,oe.textContent="Rows per page";const J=document.createElement("input");J.type="number",J.min="5",J.max="100",J.value="25",J.style.cssText=p,be.appendChild(oe),be.appendChild(J),l.appendChild(be);const me=document.createElement("div"),te=document.createElement("label");te.style.cssText=C,te.textContent="Limit (optional)";const de=document.createElement("input");de.type="number",de.placeholder="All",de.style.cssText=p,me.appendChild(te),me.appendChild(de),l.appendChild(me);const P=document.createElement("button");P.type="button",P.className="btn btn-primary",P.textContent="Insert",l.appendChild(P);const U=[s,z,M,be],G=()=>{const t=S.value,e=t==="table";U.forEach(n=>{n.style.display=e?"":"none"}),N.style.display=t==="cards"||t==="block"?"":"none",F.style.display=t==="block"?"":"none"};S.addEventListener("change",G),G();const r=E.modal({title:"Insert Collection",size:"sm"});r.element.appendChild(l),r.open(),P.addEventListener("click",()=>{const t=f.value;if(!t)return;const e=S.value;let n=`[collection slug="${t}" display="${e}"`;if(e==="cards"&&(n+=` columns="${k.value}"`),e==="block"){const ge=x.value;ge&&(n+=` block="${ge}"`);const ve=k.value.trim();ve&&(n+=` cols="${ve}"`)}e==="table"&&!b.checked&&(n+=' search="false"'),e==="table"&&!H.checked&&(n+=' sortable="false"'),e==="table"&&ee.checked&&(n+=' exportable="true"'),e==="table"&&J.value!=="25"&&(n+=` page-size="${J.value}"`);const c=de.value.trim();c&&(n+=` limit="${c}"`),n+=" /]",r.close(),fe(a,n),a.dispatchEvent(new Event("input",{bubbles:!0})),a.focus()})}),j.onForm(async a=>{const m=await W.forms.list().catch(()=>[]),o=document.createElement("div");o.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const l="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",C="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",p=document.createElement("div"),u=document.createElement("label");u.style.cssText=l,u.textContent="Form";const v=document.createElement("select");if(v.style.cssText=C,m.length)m.forEach(w=>{const S=document.createElement("option");S.value=w.slug,S.textContent=w.title||w.slug,v.appendChild(S)});else{const w=document.createElement("option");w.value="",w.textContent="No forms found",v.appendChild(w)}p.appendChild(u),p.appendChild(v),o.appendChild(p);const f=document.createElement("button");f.className="btn btn-primary btn-sm",f.style.cssText="align-self:flex-end;margin-top:.5rem;",f.textContent="Insert Form",o.appendChild(f);const g=E.modal({title:"Insert Form",size:"sm"});g.element.appendChild(o),g.open(),f.addEventListener("click",()=>{const w=v.value;w&&(fe(a,`[form slug="${w}" /]`),g.close(),V.get(0).dispatchEvent(new Event("input",{bubbles:!0})))})}),j.onView(async a=>{const m=await W.views.list().catch(()=>[]),o=document.createElement("div");o.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const l="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",C="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",p=document.createElement("div"),u=document.createElement("label");u.style.cssText=l,u.textContent="View";const v=document.createElement("select");if(v.style.cssText=C,m.length)m.forEach(T=>{const k=document.createElement("option");k.value=T.slug,k.textContent=T.title||T.slug,v.appendChild(k)});else{const T=document.createElement("option");T.value="",T.textContent="No Views configured yet \u2014 create one under Data \u2192 Views",v.appendChild(T)}p.appendChild(u),p.appendChild(v),o.appendChild(p);const f=document.createElement("div"),g=document.createElement("label");g.style.cssText=l,g.textContent="Display";const w=document.createElement("select");w.style.cssText=C,["table","cards","list"].forEach(T=>{const k=document.createElement("option");k.value=T,k.textContent=T.charAt(0).toUpperCase()+T.slice(1),w.appendChild(k)}),f.appendChild(g),f.appendChild(w),o.appendChild(f);const S=document.createElement("button");S.type="button",S.className="btn btn-primary",S.textContent="Insert",o.appendChild(S);const N=E.modal({title:"Insert View",size:"sm"});N.element.appendChild(o),N.open(),S.addEventListener("click",()=>{const T=v.value;if(!T)return;const k=`[view slug="${T}" display="${w.value}" /]`;N.close(),fe(a,k),a.dispatchEvent(new Event("input",{bubbles:!0})),a.focus()})}),j.onCta(async a=>{const m=await W.actions.list().catch(()=>[]),o=document.createElement("div");o.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const l="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",C="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;";function p(i,x){const s=document.createElement("div"),y=document.createElement("label");return y.style.cssText=l,y.textContent=i,s.appendChild(y),s.appendChild(x),s}function u(i){const x=document.createElement("select");return x.style.cssText=C,i.forEach(([s,y])=>{const b=document.createElement("option");b.value=s,b.textContent=y,x.appendChild(b)}),x}function v(i,x,s){const y=document.createElement("input");return y.type=i,y.placeholder=x||"",y.value=s||"",y.style.cssText=C,y}const f=u(m.length?m.map(i=>[i.slug,i.title||i.slug]):[["","No Actions configured yet \u2014 create one under Data \u2192 Actions"]]);o.appendChild(p("Action",f));const g=v("text","Button label","Run");if(o.appendChild(p("Label",g)),f.addEventListener("change",()=>{const i=m.find(x=>x.slug===f.value);i?.trigger?.label&&(g.value=i.trigger.label)}),m.length){const i=m[0];i?.trigger?.label&&(g.value=i.trigger.label)}const w=v("text","Paste entry UUID\u2026","");o.appendChild(p("Entry ID",w));const S=u([["primary","Primary"],["secondary","Secondary"],["ghost","Ghost"],["danger","Danger"]]);o.appendChild(p("Style",S));const N=v("text","e.g. check, zap, send (optional)","");o.appendChild(p("Icon",N));const T=v("text","Confirmation message (optional)","");o.appendChild(p("Confirm prompt",T));const k=document.createElement("button");k.type="button",k.className="btn btn-primary",k.textContent="Insert",o.appendChild(k);const F=E.modal({title:"Insert CTA Button",size:"sm"});F.element.appendChild(o),F.open(),k.addEventListener("click",()=>{const i=f.value;if(!i)return;const x=w.value.trim(),s=(g.value.trim()||"Run").replace(/\[\/cta\]/gi,""),y=S.value,b=N.value.trim().replace(/"/g,""),z=T.value.trim().replace(/"/g,""),A=x.replace(/"/g,"");let H=`action="${i}" style="${y}"`;A&&(H+=` entry="${A}"`),b&&(H+=` icon="${b}"`),z&&(H+=` confirm="${z}"`);const M=`[cta ${H}]${s}[/cta]`;F.close(),fe(a,M),a.dispatchEvent(new Event("input",{bubbles:!0})),a.focus()})}),j.onButton(async a=>{const o=(await W.pages.list().catch(()=>[])).map(b=>({label:b.title||b.urlPath,value:b.urlPath})),l=document.createElement("div");l.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const C="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",p="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;";function u(b,z){const A=document.createElement("div"),H=document.createElement("label");return H.style.cssText=C,H.textContent=b,A.appendChild(H),A.appendChild(z),A}function v(b,z){const A=document.createElement("input");return A.type="text",A.placeholder=b,A.value=z||"",A.style.cssText=p,A}function f(b){const z=document.createElement("select");return z.style.cssText=p,b.forEach(([A,H])=>{const M=document.createElement("option");M.value=A,M.textContent=H,z.appendChild(M)}),z}const g=a.value.substring(a.selectionStart,a.selectionEnd),w=v("/about or https://example.com",g.startsWith("/")?g:"");l.appendChild(u("URL",w));const S=v("Button label",g&&!g.startsWith("/")?g:"");l.appendChild(u("Label",S));const N=f([["primary","Primary"],["secondary","Secondary"],["success","Success (Green)"],["danger","Danger (Red)"],["warning","Warning (Orange)"],["info","Info (Blue)"],["outline","Outline"],["ghost","Ghost"],["link","Link"],["outline-success","Outline Success"],["outline-danger","Outline Danger"]]);l.appendChild(u("Variant",N));const T=f([["","Default"],["sm","Small"],["lg","Large"]]);l.appendChild(u("Size",T));const k=v("e.g. arrow-right, star (optional)","");l.appendChild(u("Icon (before label)",k));const F=v("e.g. arrow-right (optional)","");l.appendChild(u("Icon (after label)",F));const i=document.createElement("label");i.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9em;";const x=document.createElement("input");x.type="checkbox",x.style.cssText="width:1rem;height:1rem;",i.appendChild(x),i.appendChild(document.createTextNode("Open in new tab")),l.appendChild(i);const s=document.createElement("button");s.type="button",s.className="btn btn-primary",s.textContent="Insert Button",l.appendChild(s);const y=E.modal({title:"Insert Button",size:"sm"});y.element.appendChild(l),y.open(),requestAnimationFrame(()=>{E.autocomplete(w,{data:o,minChars:1,onSelect:b=>{w.value=b.value,S.value||(S.value=b.label)}}),w.focus()}),s.addEventListener("click",()=>{const b=w.value.trim();if(!b)return;y.close();const z=S.value.trim()||b;let A=`href="${b}" variant="${N.value}"`;T.value&&(A+=` size="${T.value}"`);const H=k.value.trim().replace(/"/g,"");H&&(A+=` icon="${H}"`);const M=F.value.trim().replace(/"/g,"");M&&(A+=` icon-after="${M}"`),x.checked&&(A+=' target="_blank"');const le=`[button ${A}]${z}[/button]`;fe(a,le)})}),j.onLinkShortcode(async a=>{const o=(await W.pages.list().catch(()=>[])).map(s=>({label:s.title||s.urlPath,value:s.urlPath})),l=document.createElement("div");l.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const C="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",p="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;";function u(s,y){const b=document.createElement("div"),z=document.createElement("label");return z.style.cssText=C,z.textContent=s,b.appendChild(z),b.appendChild(y),b}function v(s,y){const b=document.createElement("input");return b.type="text",b.placeholder=s,b.value=y||"",b.style.cssText=p,b}const f=a.value.substring(a.selectionStart,a.selectionEnd),g=v("/about or https://example.com",f.startsWith("/")?f:"");l.appendChild(u("URL",g));const w=v("Link text",f&&!f.startsWith("/")?f:"");l.appendChild(u("Link text",w));const S=v("e.g. text-primary, fw-bold (optional)","");l.appendChild(u("CSS class",S));const N=v("e.g. arrow-right (optional)","");l.appendChild(u("Icon (before text)",N));const T=v("e.g. external-link (optional)","");l.appendChild(u("Icon (after text)",T));const k=document.createElement("label");k.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9em;";const F=document.createElement("input");F.type="checkbox",F.style.cssText="width:1rem;height:1rem;",k.appendChild(F),k.appendChild(document.createTextNode("Open in new tab")),l.appendChild(k);const i=document.createElement("button");i.type="button",i.className="btn btn-primary",i.textContent="Insert Link",l.appendChild(i);const x=E.modal({title:"Insert Link Shortcode",size:"sm"});x.element.appendChild(l),x.open(),requestAnimationFrame(()=>{E.autocomplete(g,{data:o,minChars:1,onSelect:s=>{g.value=s.value,w.value||(w.value=s.label)}}),g.focus()}),i.addEventListener("click",()=>{const s=g.value.trim();if(!s)return;x.close();const y=w.value.trim()||s;let b=`href="${s}"`;const z=S.value.trim().replace(/"/g,"");z&&(b+=` class="${z}"`);const A=N.value.trim().replace(/"/g,"");A&&(b+=` icon="${A}"`);const H=T.value.trim().replace(/"/g,"");H&&(b+=` icon-after="${H}"`),F.checked&&(b+=' target="_blank"');const M=`[link ${b}]${y}[/link]`;fe(a,M)})}),j.onTabs(a=>{const m=document.createElement("div");m.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const o="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",l="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;";function C(i,x){const s=document.createElement("div"),y=document.createElement("label");return y.style.cssText=o,y.textContent=i,s.appendChild(y),s.appendChild(x),s}function p(i){const x=document.createElement("select");return x.style.cssText=l,i.forEach(([s,y])=>{const b=document.createElement("option");b.value=s,b.textContent=y,x.appendChild(b)}),x}const u=p([["","Default (underline)"],["pills","Pills"]]);m.appendChild(C("Style",u));const v=p([["","Left"],["center","Centre"]]);m.appendChild(C("Alignment",v));const f=document.createElement("div");f.style.cssText="display:flex;flex-direction:column;gap:.4rem;";const g=[];function w(){g.forEach(i=>{i.removeBtn.disabled=g.length<=2,i.removeBtn.style.opacity=g.length<=2?"0.3":"1"})}function S(i){const x=document.createElement("div");x.style.cssText="display:flex;gap:.4rem;align-items:center;";const s=document.createElement("input");s.type="text",s.placeholder="Tab title",s.value=i||"",s.style.cssText=l+"flex:1;";const y=document.createElement("button");y.type="button",y.textContent="\u2715",y.style.cssText="padding:.3rem .5rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;flex-shrink:0;";const b={row:x,input:s,removeBtn:y};g.push(b),x.appendChild(s),x.appendChild(y),f.appendChild(x),y.addEventListener("click",()=>{if(g.length<=2)return;const z=g.indexOf(b);g.splice(z,1),f.removeChild(x),w()}),w()}S("Overview"),S("Details");const N=document.createElement("div");N.style.cssText=o,N.textContent="Tabs",m.appendChild(N),m.appendChild(f);const T=document.createElement("button");T.type="button",T.textContent="+ Add Tab",T.style.cssText="padding:.35rem .75rem;background:transparent;border:1px dashed var(--dm-border,#555);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;align-self:flex-start;",T.addEventListener("click",()=>{g.length>=10||(S(""),g[g.length-1].input.focus())}),m.appendChild(T);const k=document.createElement("button");k.type="button",k.className="btn btn-primary",k.textContent="Insert Tabs",m.appendChild(k);const F=E.modal({title:"Insert Tabs",size:"sm"});F.element.appendChild(m),F.open(),requestAnimationFrame(()=>g[0].input.focus()),k.addEventListener("click",()=>{F.close();const i=u.value,x=v.value;let s=i?` style="${i}"`:"";x&&(s+=` align="${x}"`);let y=`[tabs${s}]
83
- `;g.forEach((b,z)=>{const A=b.input.value.trim()||`Tab ${z+1}`;y+=`[tab title="${A}"]Tab content here.[/tab]
84
- `}),y+="[/tabs]",fe(a,y),a.dispatchEvent(new Event("input",{bubbles:!0})),a.focus()})}),j.onAccordion(async a=>{const m=await W.collections.list().catch(()=>[]),o=document.createElement("div");o.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const l="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",C="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",p=document.createElement("div");p.style.cssText="display:flex;gap:.5rem;";const u=document.createElement("button");u.type="button",u.className="btn btn-sm btn-primary",u.textContent="Static";const v=document.createElement("button");v.type="button",v.className="btn btn-sm btn-ghost",v.textContent="Collection",p.appendChild(u),p.appendChild(v),o.appendChild(p);let f="static";const g=document.createElement("div");g.style.cssText="display:flex;flex-direction:column;gap:.5rem;";const w=[];function S(P){const U=document.createElement("div");U.style.cssText="display:flex;align-items:center;gap:.5rem;";const G=document.createElement("label");G.style.cssText="font-size:.85em;color:var(--dm-text-muted,#aaa);white-space:nowrap;",G.textContent=`Item ${P}`;const r=document.createElement("input");return r.type="text",r.placeholder="Item title",r.style.cssText=C,U.appendChild(G),U.appendChild(r),{row:U,input:r}}[1,2].forEach(P=>{const U=S(P);w.push(U),g.appendChild(U.row)});const N=document.createElement("button");N.type="button",N.className="btn btn-ghost btn-sm",N.textContent="+ Add Item",N.addEventListener("click",()=>{const P=S(w.length+1);w.push(P),g.insertBefore(P.row,N)}),g.appendChild(N);const T=document.createElement("label");T.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const k=document.createElement("input");k.type="checkbox",T.appendChild(k),T.appendChild(document.createTextNode("Allow multiple open")),g.appendChild(T),o.appendChild(g);const F=document.createElement("div");F.style.cssText="display:none;flex-direction:column;gap:.5rem;";const i=document.createElement("div"),x=document.createElement("label");x.style.cssText=l,x.textContent="Collection";const s=document.createElement("select");if(s.style.cssText=C,m.length)m.forEach(P=>{const U=document.createElement("option");U.value=P.slug,U.textContent=P.title||P.slug,s.appendChild(U)});else{const P=document.createElement("option");P.value="",P.textContent="No collections found",s.appendChild(P)}i.appendChild(x),i.appendChild(s),F.appendChild(i);const y=document.createElement("div"),b=document.createElement("label");b.style.cssText=l,b.textContent="Title field";const z=document.createElement("select");z.style.cssText=C,y.appendChild(b),y.appendChild(z),F.appendChild(y);const A=document.createElement("div"),H=document.createElement("label");H.style.cssText=l,H.textContent="Body field";const M=document.createElement("select");M.style.cssText=C,A.appendChild(H),A.appendChild(M),F.appendChild(A);async function le(P){z.textContent="",M.textContent="";try{const G=(await W.collections.get(P)).fields||[];if(!G.length){const r=document.createElement("option");r.value="",r.textContent="\u2014 none \u2014",z.appendChild(r.cloneNode(!0)),M.appendChild(r);return}G.forEach((r,t)=>{const e=()=>{const n=document.createElement("option");return n.value=r.name,n.textContent=r.label||r.name,n};z.appendChild(e()),M.appendChild(e()),r.name==="title"&&(z.value="title"),r.name==="description"&&(M.value="description")}),!z.value&&G[0]&&(z.value=G[0].name),!M.value&&G[1]&&(M.value=G[1].name)}catch{const U=document.createElement("option");U.value="",U.textContent="\u2014 unknown \u2014",z.appendChild(U.cloneNode(!0)),M.appendChild(U)}}m.length&&le(m[0].slug),s.addEventListener("change",()=>le(s.value));const ee=document.createElement("div"),be=document.createElement("label");be.style.cssText=l,be.textContent="Limit (optional)";const oe=document.createElement("input");oe.type="number",oe.placeholder="All",oe.style.cssText=C,ee.appendChild(be),ee.appendChild(oe),F.appendChild(ee);const J=document.createElement("label");J.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const me=document.createElement("input");me.type="checkbox",J.appendChild(me),J.appendChild(document.createTextNode("Allow multiple open")),F.appendChild(J),o.appendChild(F),u.addEventListener("click",()=>{f="static",u.className="btn btn-sm btn-primary",v.className="btn btn-sm btn-ghost",g.style.display="flex",F.style.display="none"}),v.addEventListener("click",()=>{f="collection",v.className="btn btn-sm btn-primary",u.className="btn btn-sm btn-ghost",F.style.display="flex",g.style.display="none"});const te=document.createElement("button");te.type="button",te.className="btn btn-primary",te.textContent="Insert Accordion",o.appendChild(te);const de=E.modal({title:"Insert Accordion",size:"sm"});de.element.appendChild(o),de.open(),requestAnimationFrame(()=>w[0].input.focus()),te.addEventListener("click",()=>{if(f==="collection"&&!s.value)return;de.close();let P;if(f==="static")P=`[accordion${k.checked?' multiple="true"':""}]
85
- `,w.forEach((G,r)=>{const t=G.input.value.trim()||`Item ${r+1}`;P+=`[item title="${t}"]Content here.[/item]
86
- `}),P+="[/accordion]";else{const U=s.value;if(!U)return;const G=z.value,r=M.value;let t=`slug="${U}" display="accordion"`;G&&(t+=` title-field="${G}"`),r&&(t+=` body-field="${r}"`);const e=oe.value.trim();e&&(t+=` limit="${e}"`),me.checked&&(t+=' multiple="true"'),P=`[collection ${t} /]`}fe(a,P),a.dispatchEvent(new Event("input",{bubbles:!0})),a.focus()})}),j.onHelp(()=>{Le()}),d.find(".editor-view-btn").on("click",function(){const a=$(this).data("mode");d.find(".editor-view-btn").removeClass("active"),$(this).addClass("active"),d.find("#editor-body").removeClass("editor-mode-split editor-mode-write editor-mode-preview").addClass(`editor-mode-${a}`)}),d.find("#fullscreen-btn").on("click",function(){d.find(".editor-card").toggleClass("editor-fullscreen")}),Ce=!1,d.find("#quick-switch").prop("disabled",!1),we&&window.removeEventListener("beforeunload",we),we=a=>{Ce&&a.preventDefault()},window.addEventListener("beforeunload",we),ke||(ke=!0,R.use((a,m,o)=>{const l=window.location.hash.startsWith("#/pages/edit")||window.location.hash==="#/pages/new";if(!Ce||!l)return o();E.confirm("You have unsaved changes. Leave this page?").then(C=>{C&&(Ce=!1,o())})})),V.on("input",()=>{Ce=!0,d.find("#quick-switch").prop("disabled",!0),h()});const Q=d.find("#editor-meta-tabs").get(0);Q&&(Q.addEventListener("input",()=>{Ce=!0,d.find("#quick-switch").prop("disabled",!0)}),Q.addEventListener("change",a=>{a.target.id!=="quick-switch"&&(Ce=!0,d.find("#quick-switch").prop("disabled",!0))})),h(),d.find("#save-btn").on("click",async()=>{const a=d.find("#page-url-path").val().trim();if(!a){E.toast("URL path is required.",{type:"warning"});return}const m=d.find("#field-dconfig").val().trim();let o=null;if(m)try{o=JSON.parse(m)}catch{E.toast("DConfig JSON is invalid. Please check the format before saving.",{type:"warning"});return}const l={title:d.find("#field-title").val().trim()||"Untitled",description:d.find("#field-description").val().trim(),layout:d.find("#field-layout").val(),status:d.find("#field-status").val(),sortOrder:parseInt(d.find("#field-sort-order").val(),10)||99,showInNav:d.find("#field-show-in-nav").is(":checked"),sidebar:d.find("#field-sidebar").is(":checked"),...d.find("#field-show-breadcrumbs").is(":checked")?{}:{breadcrumbs:!1},tags:he?he.getValue():[],category:d.find("#field-category").val().trim()||null,visibility:d.find("#field-visibility").val()||"public",seo:{title:d.find("#field-seo-title").val().trim(),description:d.find("#field-seo-desc").val().trim()},dconfig:o,...d.find("#field-theme").val()?{theme:d.find("#field-theme").val()}:{}};try{if(d.find("#save-btn").prop("disabled",!0).text("Saving\u2026"),q){const C={frontmatter:l,body:V.val()};a!==B&&(C.newUrlPath=a),await W.pages.update(B,C),E.toast("Page saved successfully.",{type:"success"}),Ce=!1,d.find("#quick-switch").prop("disabled",!1),a!==B&&R.navigate(`/pages/edit${a}`)}else await W.pages.create({urlPath:a,frontmatter:l,body:V.val()}),E.toast("Page saved successfully.",{type:"success"}),Ce=!1,R.navigate("/pages")}catch(C){E.toast(`Save failed: ${C.message||"Unknown error"}`,{type:"error"})}finally{d.find("#save-btn").prop("disabled",!1).text("Save")}}),d.find("#cancel-btn").on("click",()=>R.navigate("/pages")),Domma.icons.scan()}};
80
+ [/dconfig]`,null)),ue.appendChild(q);const U=document.createElement("div");U.appendChild(M("Tips"));const _=document.createElement("table");_.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(([m,t])=>{const e=document.createElement("tr"),l=document.createElement("td");l.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;",l.appendChild(P(m));const u=document.createElement("td");u.style.cssText="padding:.3rem .4rem;border-bottom:1px solid var(--dm-border,#333);vertical-align:top;color:var(--dm-text-muted,#aaa);",u.textContent=t,e.appendChild(l),e.appendChild(u),_.appendChild(e)}),U.appendChild(_),U.appendChild(A("Most shortcodes accept a class attribute for custom styling.")),ce.appendChild(U),s.setContent(xe),s.open(),E.tabs(se)}function ze(s,ie){const ye=s.find("#history-tab").get(0),P=s.find("#version-list").get(0),M=s.find("#version-compare").get(0),xe=s.find("#version-compare-old").get(0),se=s.find("#version-compare-new").get(0),Ee=s.find("#version-compare-label").get(0),re=s.find("#version-compare-back-btn").get(0),H=s.find("#version-restore-btn").get(0),ce=s.find("#history-save-named-btn").get(0);let ne=!1,G=null;function pe(){P.style.display="",M.style.display="none",G=null}function ue(){P.style.display="none",M.style.display=""}async function he(){P.textContent="";const X=document.createElement("p");X.style.color="var(--dm-text-muted)",X.textContent="Loading\u2026",P.appendChild(X);let W;try{W=(await V.versions.list(ie)).versions||[]}catch(A){P.textContent="";const y=document.createElement("p");y.style.color="var(--dm-text-danger,#e55)",y.textContent="Failed to load versions: "+A.message,P.appendChild(y);return}if(P.textContent="",!W.length){const A=document.createElement("p");A.style.color="var(--dm-text-muted)",A.textContent="No versions saved yet. Versions are created automatically on each save.",P.appendChild(A);return}const Q=document.createElement("table");Q.style.cssText="width:100%;border-collapse:collapse;font-size:.875rem;";const Y=document.createElement("thead"),ae=document.createElement("tr");["Date","Author","Type","Label","Actions"].forEach(A=>{const y=document.createElement("th");y.style.cssText="text-align:left;padding:.5rem .75rem;border-bottom:1px solid var(--dm-border);font-size:.8rem;color:var(--dm-text-muted);",y.textContent=A,ae.appendChild(y)}),Y.appendChild(ae),Q.appendChild(Y);const Z=document.createElement("tbody");W.forEach(A=>{const y=document.createElement("tr");y.style.borderBottom="1px solid var(--dm-border)";const j=document.createElement("td");j.style.padding=".5rem .75rem",j.textContent=D(A.createdAt).format("D MMM YYYY, HH:mm");const K=document.createElement("td");K.style.padding=".5rem .75rem",K.textContent=A.author||"\u2014";const n=document.createElement("td");n.style.padding=".5rem .75rem";const f=document.createElement("span");f.className="badge badge-"+(A.type==="manual"?"primary":"secondary"),f.style.cssText="font-size:.75rem;padding:.2rem .5rem;border-radius:4px;",f.textContent=A.type,n.appendChild(f);const d=document.createElement("td");d.style.cssText="padding:.5rem .75rem;color:var(--dm-text-muted);",d.textContent=A.label||"\u2014";const o=document.createElement("td");o.style.padding=".5rem .75rem";const v=document.createElement("button");v.className="btn btn-ghost btn-xs",v.style.marginRight=".4rem",v.textContent="Compare",v.addEventListener("click",async()=>{try{const c=await V.versions.get(ie,A.filename);xe.textContent=c.content,se.textContent=s.find("#markdown-editor").get(0).value,Ee.textContent=D(A.createdAt).format("D MMM YYYY, HH:mm")+(A.label?` \u2014 ${A.label}`:""),G=A.filename,ue()}catch(c){E.toast("Failed to load version: "+c.message,{type:"error"})}});const h=document.createElement("button");h.className="btn btn-ghost btn-xs",h.style.color="var(--dm-text-danger,#e55)",h.textContent="Delete",h.addEventListener("click",async()=>{if(await E.confirm("Delete this version? This cannot be undone."))try{await V.versions.delete(ie,A.filename),E.toast("Version deleted.",{type:"success"}),await he()}catch(w){E.toast("Failed to delete: "+w.message,{type:"error"})}}),o.appendChild(v),o.appendChild(h),y.appendChild(j),y.appendChild(K),y.appendChild(n),y.appendChild(d),y.appendChild(o),Z.appendChild(y)}),Q.appendChild(Z),P.appendChild(Q)}ye.addEventListener("click",async()=>{ne||(ne=!0,await he())}),re.addEventListener("click",()=>{pe()}),H.addEventListener("click",async()=>{if(!(!G||!await E.confirm("Restore this version? The current page content will be overwritten (a pre-restore snapshot will be saved automatically).")))try{await V.versions.restore(ie,G),E.toast("Page restored. Reloading editor\u2026",{type:"success"}),R.navigate("/pages"),setTimeout(()=>R.navigate(`/pages/edit${ie}`),300)}catch(W){E.toast("Restore failed: "+W.message,{type:"error"})}}),ce.addEventListener("click",()=>{const X=E.modal({title:"Save Named Version"}),W=document.createElement("div");W.style.padding="1rem";const Q=document.createElement("label");Q.className="form-label",Q.textContent="Version Label";const Y=document.createElement("input");Y.type="text",Y.className="form-input",Y.placeholder="e.g. Initial design, Before restructure",Y.style.marginBottom=".75rem";const ae=document.createElement("button");ae.className="btn btn-primary",ae.textContent="Save Version",ae.addEventListener("click",async()=>{const Z=Y.value.trim();try{await V.versions.create(ie,Z||null),E.toast("Named version saved.",{type:"success"}),X.close(),ne=!1,ye.classList.contains("active")&&(ne=!0,await he())}catch(A){E.toast("Failed to save version: "+A.message,{type:"error"})}}),W.appendChild(Q),W.appendChild(Y),W.appendChild(ae),X.element.appendChild(W),X.open(),setTimeout(()=>Y.focus(),100)})}let Ce=!1,we=null,ke=!1;export const pageEditorView={templateUrl:"/admin/js/templates/page-editor.html",async onMount(s){const ye=window.location.hash.match(/#\/pages\/edit(\/.*)/),P=ye?ye[1]:null,M=!!P,xe=E.loader(s.get(0),{type:"dots"}),se=[V.layouts.get().catch(()=>({})),V.settings.get().catch(()=>({}))];M&&(se.push(V.pages.get(P).catch(()=>null)),se.push(V.pages.list().catch(()=>[])));const[Ee,re,H,ce]=await Promise.all(se);xe.destroy(),Se(s.find("#field-theme").get(0),{includeDefault:!0});const ne=re?.layoutOptions?.spacerSize??40;if(M&&!H){E.toast("Page not found.",{type:"error"}),R.navigate("/pages");return}s.find("#editor-title").text(M?`Edit Page \u2014 ${H.title||P}`:"New Page"),M&&s.find("#page-url-path").val(P),H&&(s.find("#field-title").val(H.title||""),s.find("#field-description").val(H.description||""),s.find("#field-status").val(H.status||"draft"),s.find("#field-sort-order").val(H.sortOrder??99),s.find("#field-show-in-nav").prop("checked",!!H.showInNav),s.find("#field-sidebar").prop("checked",!!H.sidebar),s.find("#field-show-breadcrumbs").prop("checked",H.breadcrumbs!==!1),s.find("#field-category").val(H.category||""),s.find("#field-visibility").val(H.visibility||"public"),s.find("#field-theme").val(H.theme||""),s.find("#field-seo-title").val(H.seo?.title||""),s.find("#field-seo-desc").val(H.seo?.description||""),H.dconfig&&s.find("#field-dconfig").val(JSON.stringify(H.dconfig,null,2)));const G=s.find("#quick-switch");M&&Array.isArray(ce)&&ce.length&&([...ce].sort((f,d)=>(f.title||f.urlPath).localeCompare(d.title||d.urlPath)).forEach(f=>{const d=document.createElement("option");d.value=f.urlPath,d.textContent=`${f.title||"Untitled"} (${f.urlPath})`,f.urlPath===P&&(d.selected=!0),G.get(0).appendChild(d)}),G.css("display",""),G.on("change",function(){const f=this.value;f&&R.navigate("/pages/edit"+f)}));const pe=await V.pages.tags().catch(()=>[]),ue=s.find("#field-tags").get(0),he=ue?E.pillbox(ue,{data:pe,value:H?.tags||[],creatable:!0,searchable:!0,placeholder:"Add tag\u2026"}):null,X=s.find("#field-layout").empty();if(Object.entries(Ee).forEach(([n,f])=>{const d=(H?.layout||"default")===n?"selected":"";X.append(`<option value="${n}" ${d}>${f.label||n}</option>`)}),M){const n=s.find("#view-page-btn").get(0);n.href=P,n.style.display="";const f=s.find("#live-preview-tab").get(0);f.style.display="";const d=s.find("#history-tab").get(0);d.style.display=""}if(E.tabs(s.find("#editor-meta-tabs").get(0)),M){const n=s.find("#live-preview-tab").get(0),f=s.find("#live-preview-frame").get(0);let d=!1;n.addEventListener("click",function(){d||(f.src=P,d=!0)}),ze(s,P)}const W=s.find("#markdown-editor"),Q=s.find("#markdown-preview");H&&W.val(H.content||"");const Y=W.get(0),ae=document.createElement("div");ae.className="editor-line-numbers",Y.parentElement.insertBefore(ae,Y);const Z=()=>{const n=Y.value.split(`
81
+ `).length;ae.textContent=Array.from({length:n},(f,d)=>d+1).join(`
82
+ `),ae.scrollTop=Y.scrollTop};Z(),Y.addEventListener("input",Z),Y.addEventListener("scroll",()=>{ae.scrollTop=Y.scrollTop});let A=null;const y=()=>{clearTimeout(A),A=setTimeout(async()=>{try{const{html:n}=await V.pages.preview(W.val());Q.html(n,{safe:!1}),I.scan(Q.get(0)),Q.get(0).querySelectorAll(".tabs").forEach(f=>Domma.elements.tabs(f))}catch{window.marked&&Q.html(marked.parse(W.val()))}},400)},j=Te(W,s.find("#editor-toolbar"),{spacerDefault:ne});j.onLink(async n=>{const d=(await V.pages.list().catch(()=>[])).map(r=>({label:r.title||r.urlPath,value:r.urlPath})),o=document.createElement("div");o.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const v=document.createElement("label");v.className="form-label",v.textContent="URL";const h=document.createElement("input");h.type="text",h.className="form-input",h.placeholder="/about or https://example.com";const c=n.value.substring(n.selectionStart,n.selectionEnd);c&&c.startsWith("/")&&(h.value=c),o.appendChild(v),o.appendChild(h);const w=document.createElement("label");w.className="form-label",w.textContent="Link text";const g=document.createElement("input");g.type="text",g.className="form-input",g.placeholder="Display text",c&&!c.startsWith("/")&&(g.value=c),o.appendChild(w),o.appendChild(g);const b=document.createElement("label");b.className="form-label",b.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;";const x=document.createElement("input");x.type="checkbox",x.style.cssText="width:1rem;height:1rem;cursor:pointer;",b.appendChild(x),b.appendChild(document.createTextNode("Display as button")),o.appendChild(b);const S=document.createElement("label");S.className="form-label",S.textContent="Button colour",S.style.display="none";const z=document.createElement("select");z.className="form-select",z.style.display="none",[["primary","Primary"],["secondary","Secondary"],["success","Success (Green)"],["danger","Danger (Red)"],["warning","Warning (Orange)"],["info","Info (Blue)"],["outline","Outline"],["outline-success","Outline Success"],["outline-danger","Outline Danger"],["ghost","Ghost"]].forEach(([r,p])=>{const a=document.createElement("option");a.value=r,a.textContent=p,z.appendChild(a)}),o.appendChild(S),o.appendChild(z),x.addEventListener("change",()=>{const r=x.checked;S.style.display=r?"":"none",z.style.display=r?"":"none"});const T=document.createElement("button");T.type="button",T.className="btn btn-primary",T.textContent="Insert Link",o.appendChild(T);const B=E.modal({title:"Insert Link",size:"sm"});B.element.appendChild(o),B.open(),requestAnimationFrame(()=>{E.autocomplete(h,{data:d,minChars:1,onSelect:r=>{h.value=r.value,g.value||(g.value=r.label)}}),h.focus()}),T.addEventListener("click",()=>{const r=h.value.trim(),p=g.value.trim();if(!r)return;B.close();const a=x.checked?`[button href="${r}" variant="${z.value}"]${p||r}[/button]`:`[${p||r}](${r})`,C=n.selectionStart,i=n.selectionEnd;n.value=n.value.substring(0,C)+a+n.value.substring(i),n.selectionStart=n.selectionEnd=C+a.length,n.dispatchEvent(new Event("input",{bubbles:!0})),n.focus()})}),j.onImage(async n=>{const d=(await V.media.list().catch(()=>[])).filter(h=>/\.(png|jpe?g|gif|webp|svg)$/i.test(h.name)),o=document.createElement("div");if(o.className="media-picker-grid",d.length)d.forEach(h=>{const c=document.createElement("div");c.className="media-picker-item",c.dataset.url=h.url;const w=document.createElement("img");w.src=h.url,w.alt=h.name;const g=document.createElement("span");g.textContent=h.name,c.appendChild(w),c.appendChild(g),o.appendChild(c)});else{const h=document.createElement("p");h.className="text-muted p-3",h.textContent="No images uploaded yet.",o.appendChild(h)}const v=E.modal({title:"Insert Image",size:"lg"});v.element.appendChild(o),$(v.element).on("click",".media-picker-item",function(){const h=$(this).data("url"),c=$(this).find("span").text();fe(n,`![${c}](${h})`),v.close(),W.get(0).dispatchEvent(new Event("input",{bubbles:!0}))}),v.open()}),j.onCollection(async n=>{const[f,d]=await Promise.all([V.collections.list().catch(()=>[]),V.blocks.list().catch(()=>[])]),o=document.createElement("div");o.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const v="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",h="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",c=document.createElement("div"),w=document.createElement("label");w.style.cssText=v,w.textContent="Collection";const g=document.createElement("select");if(g.style.cssText=h,f.length)f.forEach(t=>{const e=document.createElement("option");e.value=t.slug,e.textContent=t.title||t.slug,g.appendChild(e)});else{const t=document.createElement("option");t.value="",t.textContent="No collections found",g.appendChild(t)}c.appendChild(w),c.appendChild(g),o.appendChild(c);const b=document.createElement("div"),x=document.createElement("label");x.style.cssText=v,x.textContent="Display";const S=document.createElement("select");S.style.cssText=h,["table","cards","list","block"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t.charAt(0).toUpperCase()+t.slice(1),S.appendChild(e)}),b.appendChild(x),b.appendChild(S),o.appendChild(b);const z=document.createElement("div");z.style.display="none";const k=document.createElement("label");k.style.cssText=v,k.textContent="Columns (2\u20134)";const T=document.createElement("input");T.type="number",T.min="2",T.max="4",T.value="3",T.style.cssText=h,z.appendChild(k),z.appendChild(T),o.appendChild(z);const B=document.createElement("div");B.style.display="none";const r=document.createElement("label");r.style.cssText=v,r.textContent="Block template";const p=document.createElement("select");if(p.style.cssText=h,d.length)d.forEach(t=>{const e=document.createElement("option");e.value=t.name??t,e.textContent=t.name??t,p.appendChild(e)});else{const t=document.createElement("option");t.value="",t.textContent="No block templates found",p.appendChild(t)}B.appendChild(r),B.appendChild(p),o.appendChild(B);const a=document.createElement("div"),C=document.createElement("label");C.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const i=document.createElement("input");i.type="checkbox",i.checked=!0,C.appendChild(i),C.appendChild(document.createTextNode("Enable search")),a.appendChild(C),o.appendChild(a);const L=document.createElement("div"),N=document.createElement("label");N.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const F=document.createElement("input");F.type="checkbox",F.checked=!0,N.appendChild(F),N.appendChild(document.createTextNode("Sortable columns")),L.appendChild(N),o.appendChild(L);const O=document.createElement("div"),le=document.createElement("label");le.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const ee=document.createElement("input");ee.type="checkbox",ee.checked=!1,le.appendChild(ee),le.appendChild(document.createTextNode("CSV export")),O.appendChild(le),o.appendChild(O);const be=document.createElement("div"),oe=document.createElement("label");oe.style.cssText=v,oe.textContent="Rows per page";const J=document.createElement("input");J.type="number",J.min="5",J.max="100",J.value="25",J.style.cssText=h,be.appendChild(oe),be.appendChild(J),o.appendChild(be);const me=document.createElement("div"),te=document.createElement("label");te.style.cssText=v,te.textContent="Limit (optional)";const de=document.createElement("input");de.type="number",de.placeholder="All",de.style.cssText=h,me.appendChild(te),me.appendChild(de),o.appendChild(me);const q=document.createElement("button");q.type="button",q.className="btn btn-primary",q.textContent="Insert",o.appendChild(q);const U=[a,L,O,be],_=()=>{const t=S.value,e=t==="table";U.forEach(l=>{l.style.display=e?"":"none"}),z.style.display=t==="cards"||t==="block"?"":"none",B.style.display=t==="block"?"":"none"};S.addEventListener("change",_),_();const m=E.modal({title:"Insert Collection",size:"sm"});m.element.appendChild(o),m.open(),q.addEventListener("click",()=>{const t=g.value;if(!t)return;const e=S.value;let l=`[collection slug="${t}" display="${e}"`;if(e==="cards"&&(l+=` columns="${T.value}"`),e==="block"){const ge=p.value;ge&&(l+=` block="${ge}"`);const ve=T.value.trim();ve&&(l+=` cols="${ve}"`)}e==="table"&&!i.checked&&(l+=' search="false"'),e==="table"&&!F.checked&&(l+=' sortable="false"'),e==="table"&&ee.checked&&(l+=' exportable="true"'),e==="table"&&J.value!=="25"&&(l+=` page-size="${J.value}"`);const u=de.value.trim();u&&(l+=` limit="${u}"`),l+=" /]",m.close(),fe(n,l),n.dispatchEvent(new Event("input",{bubbles:!0})),n.focus()})}),j.onBlock(async n=>{let f=[];try{f=await V.blocks.list()}catch{E.toast("Could not load blocks.",{type:"error"});return}if(!f.length){E.toast("No block templates found. Create one in Blocks first.",{type:"warning"});return}const d=E.modal({title:"Insert Block",size:"lg"}),o=document.createElement("div");o.style.cssText="display:flex;gap:1rem;min-height:320px;";const v=document.createElement("div");v.style.cssText="flex:1;display:flex;flex-direction:column;gap:.75rem;";const h=document.createElement("label");h.className="form-label",h.textContent="Block Template";const c=document.createElement("select");c.className="form-select";const w=document.createElement("option");w.value="",w.textContent="\u2014 select a template \u2014",c.appendChild(w),f.forEach(p=>{const a=document.createElement("option");a.value=p.name,a.textContent=p.name,c.appendChild(a)}),v.appendChild(h),v.appendChild(c);const g=document.createElement("div");g.style.cssText="display:flex;flex-direction:column;gap:.5rem;overflow-y:auto;max-height:260px;",v.appendChild(g);const b=document.createElement("button");b.className="btn btn-primary",b.type="button",b.textContent="Insert",b.disabled=!0,v.appendChild(b);const x=document.createElement("div");x.style.cssText="flex:1;border:1px solid var(--dm-border-color);border-radius:var(--dm-radius);padding:.75rem;overflow:auto;background:var(--dm-surface-bg);";const S=document.createElement("p");S.className="text-muted",S.style.cssText="font-size:.8rem;margin:0;",S.textContent="Select a template to see a preview.",x.appendChild(S),o.appendChild(v),o.appendChild(x),d.element.appendChild(o),d.open();let z=null,k=[];function T(p){return p.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function B(){if(!z)return;const p={};k.forEach(({key:C,input:i})=>{p[C]=i.value});const a=z.replace(/\{\{([\w_]+)\}\}/g,(C,i)=>(p[i]??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"));x.innerHTML=DOMPurify.sanitize(a)}function r(p){g.textContent="",k=[];const a=new Set(["_id","_createdAt","_updatedAt"]),C=new Set;for(const[,i]of p.matchAll(/\{\{([\w_]+)\}\}/g))a.has(i)||C.add(i);if(!C.size){const i=document.createElement("p");i.className="text-muted",i.style.cssText="font-size:.8rem;margin:0;",i.textContent="No editable placeholders in this template.",g.appendChild(i);return}C.forEach(i=>{const L=document.createElement("div"),N=document.createElement("label");N.className="form-label",N.style.cssText="font-size:.8rem;margin-bottom:.2rem;display:block;",N.textContent=T(i);const F=document.createElement("input");F.type="text",F.className="form-input",F.placeholder=T(i),F.addEventListener("input",B),L.appendChild(N),L.appendChild(F),g.appendChild(L),k.push({key:i,input:F})})}c.addEventListener("change",async()=>{const p=c.value;if(!p){z=null,k=[],g.textContent="",x.textContent="",x.appendChild(S),b.disabled=!0;return}z=null,k=[],g.textContent="",b.disabled=!0;try{z=(await V.blocks.get(p)).content||"",r(z),B(),b.disabled=!1}catch{E.toast("Could not load template.",{type:"error"})}}),b.addEventListener("click",()=>{if(!c.value)return;const p=i=>i.replace(/"/g,"&quot;");let a=`template="${p(c.value)}"`;k.forEach(({key:i,input:L})=>{L.value!==""&&(a+=` ${i}="${p(L.value)}"`)});const C=`[block ${a} /]`;fe(n,C),n.dispatchEvent(new Event("input",{bubbles:!0})),d.close(),n.focus()})}),j.onForm(async n=>{const f=await V.forms.list().catch(()=>[]),d=document.createElement("div");d.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const o="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",v="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",h=document.createElement("div"),c=document.createElement("label");c.style.cssText=o,c.textContent="Form";const w=document.createElement("select");if(w.style.cssText=v,f.length)f.forEach(x=>{const S=document.createElement("option");S.value=x.slug,S.textContent=x.title||x.slug,w.appendChild(S)});else{const x=document.createElement("option");x.value="",x.textContent="No forms found",w.appendChild(x)}h.appendChild(c),h.appendChild(w),d.appendChild(h);const g=document.createElement("button");g.className="btn btn-primary btn-sm",g.style.cssText="align-self:flex-end;margin-top:.5rem;",g.textContent="Insert Form",d.appendChild(g);const b=E.modal({title:"Insert Form",size:"sm"});b.element.appendChild(d),b.open(),g.addEventListener("click",()=>{const x=w.value;x&&(fe(n,`[form slug="${x}" /]`),b.close(),W.get(0).dispatchEvent(new Event("input",{bubbles:!0})))})}),j.onView(async n=>{const f=await V.views.list().catch(()=>[]),d=document.createElement("div");d.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const o="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",v="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",h=document.createElement("div"),c=document.createElement("label");c.style.cssText=o,c.textContent="View";const w=document.createElement("select");if(w.style.cssText=v,f.length)f.forEach(k=>{const T=document.createElement("option");T.value=k.slug,T.textContent=k.title||k.slug,w.appendChild(T)});else{const k=document.createElement("option");k.value="",k.textContent="No Views configured yet \u2014 create one under Data \u2192 Views",w.appendChild(k)}h.appendChild(c),h.appendChild(w),d.appendChild(h);const g=document.createElement("div"),b=document.createElement("label");b.style.cssText=o,b.textContent="Display";const x=document.createElement("select");x.style.cssText=v,["table","cards","list"].forEach(k=>{const T=document.createElement("option");T.value=k,T.textContent=k.charAt(0).toUpperCase()+k.slice(1),x.appendChild(T)}),g.appendChild(b),g.appendChild(x),d.appendChild(g);const S=document.createElement("button");S.type="button",S.className="btn btn-primary",S.textContent="Insert",d.appendChild(S);const z=E.modal({title:"Insert View",size:"sm"});z.element.appendChild(d),z.open(),S.addEventListener("click",()=>{const k=w.value;if(!k)return;const T=`[view slug="${k}" display="${x.value}" /]`;z.close(),fe(n,T),n.dispatchEvent(new Event("input",{bubbles:!0})),n.focus()})}),j.onCta(async n=>{const f=await V.actions.list().catch(()=>[]),d=document.createElement("div");d.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const o="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",v="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;";function h(r,p){const a=document.createElement("div"),C=document.createElement("label");return C.style.cssText=o,C.textContent=r,a.appendChild(C),a.appendChild(p),a}function c(r){const p=document.createElement("select");return p.style.cssText=v,r.forEach(([a,C])=>{const i=document.createElement("option");i.value=a,i.textContent=C,p.appendChild(i)}),p}function w(r,p,a){const C=document.createElement("input");return C.type=r,C.placeholder=p||"",C.value=a||"",C.style.cssText=v,C}const g=c(f.length?f.map(r=>[r.slug,r.title||r.slug]):[["","No Actions configured yet \u2014 create one under Data \u2192 Actions"]]);d.appendChild(h("Action",g));const b=w("text","Button label","Run");if(d.appendChild(h("Label",b)),g.addEventListener("change",()=>{const r=f.find(p=>p.slug===g.value);r?.trigger?.label&&(b.value=r.trigger.label)}),f.length){const r=f[0];r?.trigger?.label&&(b.value=r.trigger.label)}const x=w("text","Paste entry UUID\u2026","");d.appendChild(h("Entry ID",x));const S=c([["primary","Primary"],["secondary","Secondary"],["ghost","Ghost"],["danger","Danger"]]);d.appendChild(h("Style",S));const z=w("text","e.g. check, zap, send (optional)","");d.appendChild(h("Icon",z));const k=w("text","Confirmation message (optional)","");d.appendChild(h("Confirm prompt",k));const T=document.createElement("button");T.type="button",T.className="btn btn-primary",T.textContent="Insert",d.appendChild(T);const B=E.modal({title:"Insert CTA Button",size:"sm"});B.element.appendChild(d),B.open(),T.addEventListener("click",()=>{const r=g.value;if(!r)return;const p=x.value.trim(),a=(b.value.trim()||"Run").replace(/\[\/cta\]/gi,""),C=S.value,i=z.value.trim().replace(/"/g,""),L=k.value.trim().replace(/"/g,""),N=p.replace(/"/g,"");let F=`action="${r}" style="${C}"`;N&&(F+=` entry="${N}"`),i&&(F+=` icon="${i}"`),L&&(F+=` confirm="${L}"`);const O=`[cta ${F}]${a}[/cta]`;B.close(),fe(n,O),n.dispatchEvent(new Event("input",{bubbles:!0})),n.focus()})}),j.onButton(async n=>{const d=(await V.pages.list().catch(()=>[])).map(i=>({label:i.title||i.urlPath,value:i.urlPath})),o=document.createElement("div");o.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const v="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",h="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;";function c(i,L){const N=document.createElement("div"),F=document.createElement("label");return F.style.cssText=v,F.textContent=i,N.appendChild(F),N.appendChild(L),N}function w(i,L){const N=document.createElement("input");return N.type="text",N.placeholder=i,N.value=L||"",N.style.cssText=h,N}function g(i){const L=document.createElement("select");return L.style.cssText=h,i.forEach(([N,F])=>{const O=document.createElement("option");O.value=N,O.textContent=F,L.appendChild(O)}),L}const b=n.value.substring(n.selectionStart,n.selectionEnd),x=w("/about or https://example.com",b.startsWith("/")?b:"");o.appendChild(c("URL",x));const S=w("Button label",b&&!b.startsWith("/")?b:"");o.appendChild(c("Label",S));const z=g([["primary","Primary"],["secondary","Secondary"],["success","Success (Green)"],["danger","Danger (Red)"],["warning","Warning (Orange)"],["info","Info (Blue)"],["outline","Outline"],["ghost","Ghost"],["link","Link"],["outline-success","Outline Success"],["outline-danger","Outline Danger"]]);o.appendChild(c("Variant",z));const k=g([["","Default"],["sm","Small"],["lg","Large"]]);o.appendChild(c("Size",k));const T=w("e.g. arrow-right, star (optional)","");o.appendChild(c("Icon (before label)",T));const B=w("e.g. arrow-right (optional)","");o.appendChild(c("Icon (after label)",B));const r=document.createElement("label");r.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9em;";const p=document.createElement("input");p.type="checkbox",p.style.cssText="width:1rem;height:1rem;",r.appendChild(p),r.appendChild(document.createTextNode("Open in new tab")),o.appendChild(r);const a=document.createElement("button");a.type="button",a.className="btn btn-primary",a.textContent="Insert Button",o.appendChild(a);const C=E.modal({title:"Insert Button",size:"sm"});C.element.appendChild(o),C.open(),requestAnimationFrame(()=>{E.autocomplete(x,{data:d,minChars:1,onSelect:i=>{x.value=i.value,S.value||(S.value=i.label)}}),x.focus()}),a.addEventListener("click",()=>{const i=x.value.trim();if(!i)return;C.close();const L=S.value.trim()||i;let N=`href="${i}" variant="${z.value}"`;k.value&&(N+=` size="${k.value}"`);const F=T.value.trim().replace(/"/g,"");F&&(N+=` icon="${F}"`);const O=B.value.trim().replace(/"/g,"");O&&(N+=` icon-after="${O}"`),p.checked&&(N+=' target="_blank"');const le=`[button ${N}]${L}[/button]`;fe(n,le)})}),j.onLinkShortcode(async n=>{const d=(await V.pages.list().catch(()=>[])).map(a=>({label:a.title||a.urlPath,value:a.urlPath})),o=document.createElement("div");o.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const v="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",h="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;";function c(a,C){const i=document.createElement("div"),L=document.createElement("label");return L.style.cssText=v,L.textContent=a,i.appendChild(L),i.appendChild(C),i}function w(a,C){const i=document.createElement("input");return i.type="text",i.placeholder=a,i.value=C||"",i.style.cssText=h,i}const g=n.value.substring(n.selectionStart,n.selectionEnd),b=w("/about or https://example.com",g.startsWith("/")?g:"");o.appendChild(c("URL",b));const x=w("Link text",g&&!g.startsWith("/")?g:"");o.appendChild(c("Link text",x));const S=w("e.g. text-primary, fw-bold (optional)","");o.appendChild(c("CSS class",S));const z=w("e.g. arrow-right (optional)","");o.appendChild(c("Icon (before text)",z));const k=w("e.g. external-link (optional)","");o.appendChild(c("Icon (after text)",k));const T=document.createElement("label");T.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9em;";const B=document.createElement("input");B.type="checkbox",B.style.cssText="width:1rem;height:1rem;",T.appendChild(B),T.appendChild(document.createTextNode("Open in new tab")),o.appendChild(T);const r=document.createElement("button");r.type="button",r.className="btn btn-primary",r.textContent="Insert Link",o.appendChild(r);const p=E.modal({title:"Insert Link Shortcode",size:"sm"});p.element.appendChild(o),p.open(),requestAnimationFrame(()=>{E.autocomplete(b,{data:d,minChars:1,onSelect:a=>{b.value=a.value,x.value||(x.value=a.label)}}),b.focus()}),r.addEventListener("click",()=>{const a=b.value.trim();if(!a)return;p.close();const C=x.value.trim()||a;let i=`href="${a}"`;const L=S.value.trim().replace(/"/g,"");L&&(i+=` class="${L}"`);const N=z.value.trim().replace(/"/g,"");N&&(i+=` icon="${N}"`);const F=k.value.trim().replace(/"/g,"");F&&(i+=` icon-after="${F}"`),B.checked&&(i+=' target="_blank"');const O=`[link ${i}]${C}[/link]`;fe(n,O)})}),j.onTabs(n=>{const f=document.createElement("div");f.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const d="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",o="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;";function v(r,p){const a=document.createElement("div"),C=document.createElement("label");return C.style.cssText=d,C.textContent=r,a.appendChild(C),a.appendChild(p),a}function h(r){const p=document.createElement("select");return p.style.cssText=o,r.forEach(([a,C])=>{const i=document.createElement("option");i.value=a,i.textContent=C,p.appendChild(i)}),p}const c=h([["","Default (underline)"],["pills","Pills"]]);f.appendChild(v("Style",c));const w=h([["","Left"],["center","Centre"]]);f.appendChild(v("Alignment",w));const g=document.createElement("div");g.style.cssText="display:flex;flex-direction:column;gap:.4rem;";const b=[];function x(){b.forEach(r=>{r.removeBtn.disabled=b.length<=2,r.removeBtn.style.opacity=b.length<=2?"0.3":"1"})}function S(r){const p=document.createElement("div");p.style.cssText="display:flex;gap:.4rem;align-items:center;";const a=document.createElement("input");a.type="text",a.placeholder="Tab title",a.value=r||"",a.style.cssText=o+"flex:1;";const C=document.createElement("button");C.type="button",C.textContent="\u2715",C.style.cssText="padding:.3rem .5rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;flex-shrink:0;";const i={row:p,input:a,removeBtn:C};b.push(i),p.appendChild(a),p.appendChild(C),g.appendChild(p),C.addEventListener("click",()=>{if(b.length<=2)return;const L=b.indexOf(i);b.splice(L,1),g.removeChild(p),x()}),x()}S("Overview"),S("Details");const z=document.createElement("div");z.style.cssText=d,z.textContent="Tabs",f.appendChild(z),f.appendChild(g);const k=document.createElement("button");k.type="button",k.textContent="+ Add Tab",k.style.cssText="padding:.35rem .75rem;background:transparent;border:1px dashed var(--dm-border,#555);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;align-self:flex-start;",k.addEventListener("click",()=>{b.length>=10||(S(""),b[b.length-1].input.focus())}),f.appendChild(k);const T=document.createElement("button");T.type="button",T.className="btn btn-primary",T.textContent="Insert Tabs",f.appendChild(T);const B=E.modal({title:"Insert Tabs",size:"sm"});B.element.appendChild(f),B.open(),requestAnimationFrame(()=>b[0].input.focus()),T.addEventListener("click",()=>{B.close();const r=c.value,p=w.value;let a=r?` style="${r}"`:"";p&&(a+=` align="${p}"`);let C=`[tabs${a}]
83
+ `;b.forEach((i,L)=>{const N=i.input.value.trim()||`Tab ${L+1}`;C+=`[tab title="${N}"]Tab content here.[/tab]
84
+ `}),C+="[/tabs]",fe(n,C),n.dispatchEvent(new Event("input",{bubbles:!0})),n.focus()})}),j.onAccordion(async n=>{const f=await V.collections.list().catch(()=>[]),d=document.createElement("div");d.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const o="display:block;font-size:.85em;font-weight:600;margin-bottom:.25rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",v="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",h=document.createElement("div");h.style.cssText="display:flex;gap:.5rem;";const c=document.createElement("button");c.type="button",c.className="btn btn-sm btn-primary",c.textContent="Static";const w=document.createElement("button");w.type="button",w.className="btn btn-sm btn-ghost",w.textContent="Collection",h.appendChild(c),h.appendChild(w),d.appendChild(h);let g="static";const b=document.createElement("div");b.style.cssText="display:flex;flex-direction:column;gap:.5rem;";const x=[];function S(q){const U=document.createElement("div");U.style.cssText="display:flex;align-items:center;gap:.5rem;";const _=document.createElement("label");_.style.cssText="font-size:.85em;color:var(--dm-text-muted,#aaa);white-space:nowrap;",_.textContent=`Item ${q}`;const m=document.createElement("input");return m.type="text",m.placeholder="Item title",m.style.cssText=v,U.appendChild(_),U.appendChild(m),{row:U,input:m}}[1,2].forEach(q=>{const U=S(q);x.push(U),b.appendChild(U.row)});const z=document.createElement("button");z.type="button",z.className="btn btn-ghost btn-sm",z.textContent="+ Add Item",z.addEventListener("click",()=>{const q=S(x.length+1);x.push(q),b.insertBefore(q.row,z)}),b.appendChild(z);const k=document.createElement("label");k.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const T=document.createElement("input");T.type="checkbox",k.appendChild(T),k.appendChild(document.createTextNode("Allow multiple open")),b.appendChild(k),d.appendChild(b);const B=document.createElement("div");B.style.cssText="display:none;flex-direction:column;gap:.5rem;";const r=document.createElement("div"),p=document.createElement("label");p.style.cssText=o,p.textContent="Collection";const a=document.createElement("select");if(a.style.cssText=v,f.length)f.forEach(q=>{const U=document.createElement("option");U.value=q.slug,U.textContent=q.title||q.slug,a.appendChild(U)});else{const q=document.createElement("option");q.value="",q.textContent="No collections found",a.appendChild(q)}r.appendChild(p),r.appendChild(a),B.appendChild(r);const C=document.createElement("div"),i=document.createElement("label");i.style.cssText=o,i.textContent="Title field";const L=document.createElement("select");L.style.cssText=v,C.appendChild(i),C.appendChild(L),B.appendChild(C);const N=document.createElement("div"),F=document.createElement("label");F.style.cssText=o,F.textContent="Body field";const O=document.createElement("select");O.style.cssText=v,N.appendChild(F),N.appendChild(O),B.appendChild(N);async function le(q){L.textContent="",O.textContent="";try{const _=(await V.collections.get(q)).fields||[];if(!_.length){const m=document.createElement("option");m.value="",m.textContent="\u2014 none \u2014",L.appendChild(m.cloneNode(!0)),O.appendChild(m);return}_.forEach((m,t)=>{const e=()=>{const l=document.createElement("option");return l.value=m.name,l.textContent=m.label||m.name,l};L.appendChild(e()),O.appendChild(e()),m.name==="title"&&(L.value="title"),m.name==="description"&&(O.value="description")}),!L.value&&_[0]&&(L.value=_[0].name),!O.value&&_[1]&&(O.value=_[1].name)}catch{const U=document.createElement("option");U.value="",U.textContent="\u2014 unknown \u2014",L.appendChild(U.cloneNode(!0)),O.appendChild(U)}}f.length&&le(f[0].slug),a.addEventListener("change",()=>le(a.value));const ee=document.createElement("div"),be=document.createElement("label");be.style.cssText=o,be.textContent="Limit (optional)";const oe=document.createElement("input");oe.type="number",oe.placeholder="All",oe.style.cssText=v,ee.appendChild(be),ee.appendChild(oe),B.appendChild(ee);const J=document.createElement("label");J.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.9em;cursor:pointer;";const me=document.createElement("input");me.type="checkbox",J.appendChild(me),J.appendChild(document.createTextNode("Allow multiple open")),B.appendChild(J),d.appendChild(B),c.addEventListener("click",()=>{g="static",c.className="btn btn-sm btn-primary",w.className="btn btn-sm btn-ghost",b.style.display="flex",B.style.display="none"}),w.addEventListener("click",()=>{g="collection",w.className="btn btn-sm btn-primary",c.className="btn btn-sm btn-ghost",B.style.display="flex",b.style.display="none"});const te=document.createElement("button");te.type="button",te.className="btn btn-primary",te.textContent="Insert Accordion",d.appendChild(te);const de=E.modal({title:"Insert Accordion",size:"sm"});de.element.appendChild(d),de.open(),requestAnimationFrame(()=>x[0].input.focus()),te.addEventListener("click",()=>{if(g==="collection"&&!a.value)return;de.close();let q;if(g==="static")q=`[accordion${T.checked?' multiple="true"':""}]
85
+ `,x.forEach((_,m)=>{const t=_.input.value.trim()||`Item ${m+1}`;q+=`[item title="${t}"]Content here.[/item]
86
+ `}),q+="[/accordion]";else{const U=a.value;if(!U)return;const _=L.value,m=O.value;let t=`slug="${U}" display="accordion"`;_&&(t+=` title-field="${_}"`),m&&(t+=` body-field="${m}"`);const e=oe.value.trim();e&&(t+=` limit="${e}"`),me.checked&&(t+=' multiple="true"'),q=`[collection ${t} /]`}fe(n,q),n.dispatchEvent(new Event("input",{bubbles:!0})),n.focus()})}),j.onHelp(()=>{Le()}),s.find(".editor-view-btn").on("click",function(){const n=$(this).data("mode");s.find(".editor-view-btn").removeClass("active"),$(this).addClass("active"),s.find("#editor-body").removeClass("editor-mode-split editor-mode-write editor-mode-preview").addClass(`editor-mode-${n}`)}),s.find("#fullscreen-btn").on("click",function(){s.find(".editor-card").toggleClass("editor-fullscreen")}),Ce=!1,s.find("#quick-switch").prop("disabled",!1),we&&window.removeEventListener("beforeunload",we),we=n=>{Ce&&n.preventDefault()},window.addEventListener("beforeunload",we),ke||(ke=!0,R.use((n,f,d)=>{const o=window.location.hash.startsWith("#/pages/edit")||window.location.hash==="#/pages/new";if(!Ce||!o)return d();E.confirm("You have unsaved changes. Leave this page?").then(v=>{v&&(Ce=!1,d())})})),W.on("input",()=>{Ce=!0,s.find("#quick-switch").prop("disabled",!0),y()});const K=s.find("#editor-meta-tabs").get(0);K&&(K.addEventListener("input",()=>{Ce=!0,s.find("#quick-switch").prop("disabled",!0)}),K.addEventListener("change",n=>{n.target.id!=="quick-switch"&&(Ce=!0,s.find("#quick-switch").prop("disabled",!0))})),y(),s.find("#save-btn").on("click",async()=>{const n=s.find("#page-url-path").val().trim();if(!n){E.toast("URL path is required.",{type:"warning"});return}const f=s.find("#field-dconfig").val().trim();let d=null;if(f)try{d=JSON.parse(f)}catch{E.toast("DConfig JSON is invalid. Please check the format before saving.",{type:"warning"});return}const o={title:s.find("#field-title").val().trim()||"Untitled",description:s.find("#field-description").val().trim(),layout:s.find("#field-layout").val(),status:s.find("#field-status").val(),sortOrder:parseInt(s.find("#field-sort-order").val(),10)||99,showInNav:s.find("#field-show-in-nav").is(":checked"),sidebar:s.find("#field-sidebar").is(":checked"),...s.find("#field-show-breadcrumbs").is(":checked")?{}:{breadcrumbs:!1},tags:he?he.getValue():[],category:s.find("#field-category").val().trim()||null,visibility:s.find("#field-visibility").val()||"public",seo:{title:s.find("#field-seo-title").val().trim(),description:s.find("#field-seo-desc").val().trim()},dconfig:d,...s.find("#field-theme").val()?{theme:s.find("#field-theme").val()}:{}};try{if(s.find("#save-btn").prop("disabled",!0).text("Saving\u2026"),M){const v={frontmatter:o,body:W.val()};n!==P&&(v.newUrlPath=n),await V.pages.update(P,v),E.toast("Page saved successfully.",{type:"success"}),Ce=!1,s.find("#quick-switch").prop("disabled",!1),n!==P&&R.navigate(`/pages/edit${n}`)}else await V.pages.create({urlPath:n,frontmatter:o,body:W.val()}),E.toast("Page saved successfully.",{type:"success"}),Ce=!1,R.navigate("/pages")}catch(v){E.toast(`Save failed: ${v.message||"Unknown error"}`,{type:"error"})}finally{s.find("#save-btn").prop("disabled",!1).text("Save")}}),s.find("#cancel-btn").on("click",()=>R.navigate("/pages")),Domma.icons.scan()}};
@@ -29,5 +29,21 @@
29
29
  "job-board": {
30
30
  "enabled": false,
31
31
  "settings": {}
32
+ },
33
+ "todo": {
34
+ "enabled": true,
35
+ "settings": {}
36
+ },
37
+ "notes": {
38
+ "enabled": true,
39
+ "settings": {}
40
+ },
41
+ "contacts": {
42
+ "enabled": true,
43
+ "settings": {}
44
+ },
45
+ "docs": {
46
+ "enabled": false,
47
+ "settings": {}
32
48
  }
33
49
  }
package/config/site.json CHANGED
@@ -46,7 +46,7 @@
46
46
  "youtube": ""
47
47
  },
48
48
  "smtp": {
49
- "host": "localhost",
49
+ "host": "192.168.1.27",
50
50
  "port": 1025,
51
51
  "user": "",
52
52
  "pass": "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "0.6.16",
3
+ "version": "0.6.21",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -71,7 +71,7 @@
71
71
  "@fastify/rate-limit": "^10.3.0",
72
72
  "@fastify/static": "^8.1.0",
73
73
  "bcryptjs": "^3.0.3",
74
- "domma-js": "^0.21.1",
74
+ "domma-js": "^0.22.0",
75
75
  "dotenv": "^17.2.3",
76
76
  "fastify": "5.8.1",
77
77
  "gray-matter": "^4.0.3",