domma-cms 1.34.0 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/admin/js/api.js +1 -1
  3. package/admin/js/app.js +2 -2
  4. package/admin/js/lib/image-editor.js +1 -1
  5. package/admin/js/lib/media-arrange.js +1 -1
  6. package/admin/js/lib/media-picker.js +2 -2
  7. package/admin/js/lib/media-upload.js +1 -1
  8. package/admin/js/lib/seo-redirects.js +1 -1
  9. package/admin/js/templates/docs/usage-media.html +6 -0
  10. package/admin/js/templates/media.html +1 -0
  11. package/admin/js/views/media.js +3 -3
  12. package/docs/DommaFeatures.md +3 -0
  13. package/package.json +1 -1
  14. package/plugins/_lib/admin/mail/body-menu.js +1 -1
  15. package/plugins/_lib/admin/mail/cms-host.js +1 -1
  16. package/plugins/_lib/admin/mail/compose-window.js +1 -1
  17. package/plugins/_lib/admin/mail/contacts.js +1 -1
  18. package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
  19. package/plugins/_lib/admin/mail/drag-drop.js +1 -1
  20. package/plugins/_lib/admin/mail/folder-tree.js +26 -1
  21. package/plugins/_lib/admin/mail/font-controls.js +1 -1
  22. package/plugins/_lib/admin/mail/fonts.js +1 -1
  23. package/plugins/_lib/admin/mail/host-context.js +1 -1
  24. package/plugins/_lib/admin/mail/identity.js +1 -1
  25. package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
  26. package/plugins/_lib/admin/mail/keyboard.js +1 -1
  27. package/plugins/_lib/admin/mail/mail.html +4 -1
  28. package/plugins/_lib/admin/mail/message-actions.js +1 -1
  29. package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
  30. package/plugins/_lib/admin/mail/panes.js +1 -1
  31. package/plugins/_lib/admin/mail/reader-kit.js +9 -3
  32. package/plugins/_lib/admin/mail/reader-runtime.js +154 -6
  33. package/plugins/_lib/admin/mail/reader-view.js +1 -1
  34. package/plugins/_lib/admin/mail/resizable.js +1 -1
  35. package/plugins/_lib/admin/mail/restore-spam.js +1 -1
  36. package/plugins/_lib/admin/mail/rules.js +1 -1
  37. package/plugins/_lib/admin/mail/scheduling.js +1 -1
  38. package/plugins/_lib/admin/mail/section-kit.js +1 -1
  39. package/plugins/_lib/admin/mail/security-note.js +1 -1
  40. package/plugins/_lib/admin/mail/settings-section.js +1 -1
  41. package/plugins/_lib/admin/mail/templates.js +1 -1
  42. package/plugins/_lib/admin/mail/threads.js +1 -1
  43. package/plugins/_lib/admin/mail/vacation.js +1 -1
  44. package/plugins/_lib/admin/mail/when-closed.js +1 -1
  45. package/plugins/_lib/admin/ui/dates.js +1 -1
  46. package/plugins/_lib/admin/ui/resizable.js +1 -1
  47. package/plugins/_lib/domma-mail.lock.json +80 -80
  48. package/plugins/_lib/mail/accountFileStore.js +1 -1
  49. package/plugins/_lib/mail/accountRepository.js +1 -1
  50. package/plugins/_lib/mail/accountRoutes.js +1 -1
  51. package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
  52. package/plugins/_lib/mail/bodyTokens.js +1 -1
  53. package/plugins/_lib/mail/compose.js +1 -1
  54. package/plugins/_lib/mail/defaults.js +1 -1
  55. package/plugins/_lib/mail/envelope.js +1 -1
  56. package/plugins/_lib/mail/folderActions.js +1 -1
  57. package/plugins/_lib/mail/folderRuntime.js +1 -1
  58. package/plugins/_lib/mail/folders.js +1 -1
  59. package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
  60. package/plugins/_lib/mail/mbox.js +1 -1
  61. package/plugins/_lib/mail/message-action.js +1 -1
  62. package/plugins/_lib/mail/messageSecurity.js +1 -1
  63. package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
  64. package/plugins/_lib/mail/networkAddresses.js +1 -1
  65. package/plugins/_lib/mail/networkPolicy.js +1 -1
  66. package/plugins/_lib/mail/oauthAccounts.js +1 -1
  67. package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
  68. package/plugins/_lib/mail/oauthRuntime.js +1 -1
  69. package/plugins/_lib/mail/pollSchedule.js +1 -1
  70. package/plugins/_lib/mail/poller.js +1 -1
  71. package/plugins/_lib/mail/pollerRuntime.js +1 -1
  72. package/plugins/_lib/mail/priority.js +1 -1
  73. package/plugins/_lib/mail/publicMailbox.js +1 -1
  74. package/plugins/_lib/mail/readRuntime.js +1 -1
  75. package/plugins/_lib/mail/render.js +1 -1
  76. package/plugins/_lib/mail/ruleRunner.js +1 -1
  77. package/plugins/_lib/mail/schedulerRuntime.js +1 -1
  78. package/plugins/_lib/mail/secretProvider.js +1 -1
  79. package/plugins/_lib/mail/secretbox.js +1 -1
  80. package/plugins/_lib/mail/senderAuth.js +1 -1
  81. package/plugins/_lib/mail/sieve.js +1 -1
  82. package/plugins/_lib/mail/smtpService.js +1 -1
  83. package/plugins/_lib/mail/snoozeRuntime.js +1 -1
  84. package/plugins/_lib/mail/store.js +1 -1
  85. package/plugins/_lib/mail/subscriptions.js +1 -1
  86. package/plugins/_lib/mail/syncPlan.js +1 -1
  87. package/plugins/_lib/mail/syncRuntime.js +1 -1
  88. package/plugins/_lib/mail/syncSelection.js +1 -1
  89. package/plugins/_lib/mail/unreadBadge.js +1 -1
  90. package/plugins/_lib/mail/unsubscribe.js +1 -1
  91. package/plugins/_lib/mail/vacationRuntime.js +1 -1
  92. package/plugins/_lib/mail/write.js +1 -1
  93. package/server/routes/api/media.js +3 -1
  94. package/server/routes/api/sidebar.js +2 -2
  95. package/server/services/content.js +26 -2
  96. package/server/services/hooks.js +27 -4
  97. package/server/services/plugins.js +9 -3
  98. package/server/services/renderer.js +3 -1
@@ -1,4 +1,4 @@
1
- import{api as L}from"../api.js";import{catchFiles as qe,mediaUploader as Ne}from"../lib/media-upload.js";import{addBannerAction as ze}from"../lib/plugin-chrome.js";import{SHAPES as Ie,whileLoading as Re}from"../lib/loading.js";import{helpPopovers as be}from"../lib/help-popover.js";import{onceClosed as Ue,openMenuAt as ve,settingsStore as Be,sidebarCount as j,viewLifetime as Fe}from"../lib/tool-kit.js";import{openImageEditor as He}from"../lib/image-editor.js";import{KIND_LABEL as ye,arrangeMedia as Pe,formatBytes as he,isEditable as G,isPreviewable as Ke,kindCounts as Oe,kindOf as _e,markdownFor as J,mediaTile as Ve,normalisePrefs as Ye,safeName as T}from"../lib/media-arrange.js";import{fmtDateTime as je}from"../lib/dates.js";const ge=/^#\/media\/?(\?.*)?$/,Q="#/media",q="media.draft",we=Be("media.prefs",Ye),Ge=`
1
+ import{api as C}from"../api.js";import{catchFiles as qe,mediaUploader as ze}from"../lib/media-upload.js";import{addBannerAction as Ie}from"../lib/plugin-chrome.js";import{SHAPES as Re,whileLoading as Ue}from"../lib/loading.js";import{helpPopovers as ve}from"../lib/help-popover.js";import{onceClosed as Be,openMenuAt as ye,settingsStore as Fe,sidebarCount as j,viewLifetime as He}from"../lib/tool-kit.js";import{openImageEditor as Pe}from"../lib/image-editor.js";import{KIND_LABEL as he,arrangeMedia as Ke,formatBytes as ge,isEditable as G,isPreviewable as Oe,kindCounts as _e,kindOf as Ve,markdownFor as J,foldersText as Ye,mediaTile as je,normalisePrefs as Ge,safeName as L}from"../lib/media-arrange.js";import{fmtDateTime as Je}from"../lib/dates.js";const we=/^#\/media\/?(\?.*)?$/,Q="#/media",N="media.draft",ke=Fe("media.prefs",Ge),Qe=`
2
2
  <div class="mdx-tile" data-name="{{name}}" tabindex="0" title="{{name}}">
3
3
  <div class="mdx-thumb">
4
4
  <img data-bind-hidden="!preview" data-bind-src="thumb" alt="" loading="lazy" decoding="async">
@@ -7,7 +7,7 @@ import{api as L}from"../api.js";import{catchFiles as qe,mediaUploader as Ne}from
7
7
  <span class="mdx-chip">{{kindLabel}}</span>
8
8
  <button type="button" class="mdx-kebab" aria-label="Actions for {{name}}" title="Actions">\u22EE</button>
9
9
  <div class="mdx-info"><span class="mdx-name">{{name}}</span><span class="mdx-meta">{{meta}}</span></div>
10
- </div>`,N=c=>String(c??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Je(c){const s=document.createElement("template");return s.innerHTML=c.trim(),s.content.firstElementChild}const l=Fe(ge);let W=null;async function z(c,s){try{await navigator.clipboard.writeText(c),E.toast(`${s} copied.`,{type:"success"})}catch{E.toast("Copy failed - the browser refused the clipboard.",{type:"error"})}}export const mediaView={templateUrl:"/admin/js/templates/media.html",async onMount(c){l.reset();const s=c.get(0).querySelector(".mdx")||c.get(0),u=()=>ge.test(location.hash)&&s.isConnected,X=we.read(),p=M.observable([]),Z=M.observable(!0),R=M.observable(""),b=M.observable(X.kind),U=M.observable(X.sort),ee=M.observable(""),te=M.observable(!1),ae=M.observable("");let B=String(Date.now());l.add(M.effect(()=>we.write({kind:b.value,sort:U.value})));const C=M.observable([]);l.add(M.effect(()=>{const e=Date.now();C.value=Pe(p.value,{kind:b.value,query:ee.value,sort:U.value}).map(a=>Ve(a,{now:e,stamp:B}))}));const ne=M.computed(()=>Oe(p.value));l.add(M.effect(()=>{b.value!=="all"&&!ne.value[b.value]&&p.value.length&&(b.value="all")}));const ke=M.computed(()=>{const e=p.value,a=C.value.length,i=he(e.reduce((n,m)=>n+(Number(m.size)||0),0));return a===e.length?`${e.length} file${e.length===1?"":"s"} \xB7 ${i}`:`${a} of ${e.length} \xB7 ${i} in all`}),xe=M.computed(()=>p.value.length?"No files match.":"Nothing uploaded yet - drop files here, or Upload in the banner."),h=e=>p.peek().find(a=>a.name===e);async function g(){try{const e=await Re(s.querySelector(".dm-loading-slot"),L.media.list(),Ie.tiles);if(!u())return;B=String(Date.now()),p.value=Array.isArray(e)?e:[],R.value=""}catch(e){R.value=`Could not load the media: ${e.message||e}`}finally{Z.value=!1}}async function F(e){if(!await E.confirm(`Delete "${N(e.name)}"? Pages that show it will show a broken image or link. This cannot be undone.`))return!1;try{return await L.media.delete(e.name),E.toast(`Deleted "${e.name}".`,{type:"success"}),j(Q),u()&&await g(),!0}catch(a){return E.toast(`Not deleted: ${a.message||a}`,{type:"error"}),!1}}async function oe(e){const a=await He(e);return a&&u()&&(j(Q),await g()),a}const H=e=>window.location.origin+e.url;let v=null,se=!1;const P=new Set;function w(e,{focusRename:a=!1,draftName:i=null}={}){const n=h(e);if(!n){E.toast(`"${e}" is not here any more.`,{type:"warning"});return}const m=M.observable(i??n.name),D=M.observable(!1),de=M.computed(()=>{const t=m.value.trim();if(!t)return"A file needs a name.";const o=T(t);return o!==n.name&&h(o)?`"${o}" is already here.`:""}),Ae=M.computed(()=>{const t=m.value.trim(),o=T(t);return t&&o!==t?`Saved as "${o}" - only letters, numbers, dots, hyphens and underscores are kept.`:""}),ce=()=>m.peek().trim()!==n.name,me={newName:m,saving:D,renameErr:de,renameHint:Ae,cannotRename:M.computed(()=>D.value||!!de.value||T(m.value.trim())===n.name),editable:G(n.name)},d=E.slideover({title:N(n.name),size:"md",position:"right"}),r=Je(`
10
+ </div>`,q=c=>String(c??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function We(c){const s=document.createElement("template");return s.innerHTML=c.trim(),s.content.firstElementChild}const l=He(we);let W=null;async function z(c,s){try{await navigator.clipboard.writeText(c),E.toast(`${s} copied.`,{type:"success"})}catch{E.toast("Copy failed - the browser refused the clipboard.",{type:"error"})}}export const mediaView={templateUrl:"/admin/js/templates/media.html",async onMount(c){l.reset();const s=c.get(0).querySelector(".mdx")||c.get(0),m=()=>we.test(location.hash)&&s.isConnected,X=ke.read(),p=M.observable([]),Z=M.observable(!0),R=M.observable(""),b=M.observable(X.kind),U=M.observable(X.sort),ee=M.observable(""),te=M.observable(!1),ae=M.observable(""),ne=M.observable("");let B=String(Date.now());l.add(M.effect(()=>ke.write({kind:b.value,sort:U.value})));const D=M.observable([]);l.add(M.effect(()=>{const e=Date.now();D.value=Ke(p.value,{kind:b.value,query:ee.value,sort:U.value}).map(a=>je(a,{now:e,stamp:B}))}));const oe=M.computed(()=>_e(p.value));l.add(M.effect(()=>{b.value!=="all"&&!oe.value[b.value]&&p.value.length&&(b.value="all")}));const xe=M.computed(()=>{const e=p.value,a=D.value.length,i=ge(e.reduce((n,u)=>n+(Number(u.size)||0),0));return a===e.length?`${e.length} file${e.length===1?"":"s"} \xB7 ${i}`:`${a} of ${e.length} \xB7 ${i} in all`}),Ee=M.computed(()=>p.value.length?"No files match.":"Nothing uploaded yet - drop files here, or Upload in the banner."),h=e=>p.peek().find(a=>a.name===e);async function g(){try{const e=await Ue(s.querySelector(".dm-loading-slot"),C.media.list(),Re.tiles);if(!m())return;B=String(Date.now()),p.value=Array.isArray(e)?e:[],R.value=""}catch(e){R.value=`Could not load the media: ${e.message||e}`}finally{Z.value=!1}}async function F(e){if(!await E.confirm(`Delete "${q(e.name)}"? Pages that show it will show a broken image or link. This cannot be undone.`))return!1;try{return await C.media.delete(e.name),E.toast(`Deleted "${e.name}".`,{type:"success"}),j(Q),m()&&await g(),!0}catch(a){return E.toast(`Not deleted: ${a.message||a}`,{type:"error"}),!1}}async function se(e){const a=await Pe(e);return a&&m()&&(j(Q),await g()),a}const H=e=>window.location.origin+e.url;let v=null,ie=!1;const P=new Set;function w(e,{focusRename:a=!1,draftName:i=null}={}){const n=h(e);if(!n){E.toast(`"${e}" is not here any more.`,{type:"warning"});return}const u=M.observable(i??n.name),$=M.observable(!1),ce=M.computed(()=>{const t=u.value.trim();if(!t)return"A file needs a name.";const o=L(t);return o!==n.name&&h(o)?`"${o}" is already here.`:""}),Ce=M.computed(()=>{const t=u.value.trim(),o=L(t);return t&&o!==t?`Saved as "${o}" - only letters, numbers, dots, hyphens and underscores are kept.`:""}),me=()=>u.peek().trim()!==n.name,ue={newName:u,saving:$,renameErr:ce,renameHint:Ce,cannotRename:M.computed(()=>$.value||!!ce.value||L(u.value.trim())===n.name),editable:G(n.name)},d=E.slideover({title:q(n.name),size:"md",position:"right"}),r=We(`
11
11
  <div class="mdx-panel">
12
12
  <div class="mdx-preview"></div>
13
13
  <dl class="mdx-facts"></dl>
@@ -37,4 +37,4 @@ import{api as L}from"../api.js";import{catchFiles as qe,mediaUploader as Ne}from
37
37
  <a class="btn btn-sm btn-ghost mdx-open" target="_blank" rel="noopener"><span data-icon="external-link" data-icon-size="13"></span> Open</a>
38
38
  <button type="button" class="btn btn-sm btn-outline" data-on-click="edit" data-bind-hidden="!editable"><span data-icon="edit" data-icon-size="13"></span> Edit image</button>
39
39
  </div>
40
- </div>`),O=r.querySelector(".mdx-preview"),x=_e(n.name);if(Ke(n.name)){const t=document.createElement("img");t.src=`${n.url}?t=${encodeURIComponent(B)}`,t.alt=n.name,O.appendChild(t)}else if(x==="video"||x==="audio"){const t=document.createElement(x);t.src=n.url,t.controls=!0,t.preload="metadata",O.appendChild(t)}else{const t=document.createElement("span");t.setAttribute("data-icon",x==="document"?"file-text":"paperclip"),t.setAttribute("data-icon-size","40"),O.appendChild(t)}const Ce=r.querySelector(".mdx-facts"),$=(t,o)=>{const fe=document.createElement("dt");fe.textContent=t;const Y=document.createElement("dd");return Y.textContent=o,Ce.append(fe,Y),Y};if($("Type",`${ye[x]==="Images"?"Image":ye[x].replace(/s$/,"")} (${(n.name.split(".").pop()||"").toUpperCase()})`),$("Size",he(n.size)),$("Uploaded",n.createdAt?je(n.createdAt):"-"),G(n.name)){const t=$("Dimensions","\u2026");L.media.info(n.name).then(o=>{t.textContent=o?.width?`${o.width} \xD7 ${o.height} px`:"-"}).catch(()=>{t.textContent="-"})}r.querySelector(".mdx-url").value=H(n),r.querySelector(".mdx-md").value=J(n),r.querySelector(".mdx-open").href=n.url;let A=!1;async function ue(){if(!me.cannotRename.peek()){D.value=!0;try{const t=await L.media.rename(n.name,m.peek().trim());E.toast(`Renamed to "${t?.name||T(m.peek().trim())}".`,{type:"success"}),A=!0,d.close(),u()&&await g()}catch(t){E.toast(`Not renamed: ${t.message||t}`,{type:"error"})}finally{D.value=!1}}}d.element.appendChild(r);const De=be(r),$e=M.applyBindings(me,r,{methods:{rename:ue,copyUrl:()=>z(H(n),"Address"),copyMd:()=>z(J(n),"Markdown"),async del(){await F(n)&&(A=!0,d.close())},async edit(){A=!0,d.close(),await oe(n)}}}),_=r.querySelector("#mdx-rename"),Le=t=>{t.key==="Enter"&&t.target===_&&(t.preventDefault(),ue())};r.addEventListener("keydown",Le);const pe={name:n.name,dirty:ce,newName:()=>m.peek()};v=pe,P.add(d),Ue(d,()=>{$e.dispose(),De(),r.querySelectorAll("video, audio").forEach(t=>{try{t.pause()}catch{}}),P.delete(d),v===pe&&(v=null)});const Te=d.close.bind(d);let V=!1;d.close=async t=>{if(!A&&!se&&t!==!0&&ce()){if(V)return;V=!0;const o=await E.confirm("Discard the new name you typed?");if(V=!1,!o)return}return A=!0,Te()},I.scan(r),d.open(),(a||i)&&(_.focus(),_.select())}function Ee(e){const a=h(e);return a?[{header:a.name},{label:"Details\u2026",icon:"info",action:()=>w(a.name)},{label:"Copy address",icon:"link",action:()=>z(H(a),"Address")},{label:"Copy for a page",icon:"copy",action:()=>z(J(a),"Markdown")},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(a.url,"_blank","noopener")},{type:"divider"},{label:"Rename\u2026",icon:"type",action:()=>w(a.name,{focusRename:!0})},...G(a.name)?[{label:"Edit image\u2026",icon:"edit",action:()=>oe(a)}]:[],{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>F(a)}]:[]}const f=s.querySelector(".mdx-grid");f.innerHTML=Ge;const k=e=>()=>{b.value=e},Me=M.applyBindings({files:p,loading:Z,loadError:R,kind:b,sort:U,query:ee,tiles:C,counts:ne,totalText:ke,emptyText:xe,hintText:ae,dragging:te},s,{methods:{kindAll:k("all"),kindImage:k("image"),kindVideo:k("video"),kindAudio:k("audio"),kindDocument:k("document"),kindOther:k("other")}});l.add(()=>Me.dispose()),l.add(be(s,{position:"bottom"})),l.add(M.effect(()=>{C.value,requestAnimationFrame(()=>{f.isConnected&&I.scan(f)})}));const Se=E.contextMenu(f,{cursor:"glyph",match:".mdx-tile",inherit:!1,density:"compact",items:e=>Ee(e.dataset.name)});l.add(()=>Se?.destroy?.());const ie=e=>{const a=e.target.closest(".mdx-tile");if(!a)return;const i=e.target.closest(".mdx-kebab");if(i){ve(i);return}w(a.dataset.name)},le=e=>{const a=e.target.closest(".mdx-tile");if(!a||e.target!==a)return;const i=h(a.dataset.name);i&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),ve(a)):e.key==="Enter"?w(i.name):e.key==="F2"?(e.preventDefault(),w(i.name,{focusRename:!0})):e.key==="Delete"&&(e.preventDefault(),F(i)))};f.addEventListener("click",ie),f.addEventListener("keydown",le),l.add(()=>{f.removeEventListener("click",ie),f.removeEventListener("keydown",le)});const K=Ne(s.querySelector(".mdx-zone"),{input:s.querySelector(".mdx-file-input"),exists:e=>!!h(e),showing:u,onHint:e=>{ae.value=e},onUploaded(){j(Q),u()?g():W?.()}});W=()=>{u()&&g()},l.add(()=>{W=null,K.release()}),ze(c,{id:"media-upload",icon:"upload",title:"Upload files",onClick:()=>K.browse()}),l.add(qe(c.get(0),K.addFiles,{onDragging:e=>{te.value=e}}));const re=e=>{v?.dirty()&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",re),l.add(()=>window.removeEventListener("beforeunload",re)),l.add(()=>{if(v?.dirty())try{S.set(q,{name:v.name,newName:v.newName(),at:new Date().toISOString()})}catch{}se=!0,[...P].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(s),await g(),!u())return;let y=null;try{y=S.get(q)}catch{}if(y?.name){try{S.remove?S.remove(q):S.set(q,null)}catch{}h(y.name)&&await E.confirm(`You were renaming "${N(y.name)}" to "${N(y.newName)}" and left before saving. Pick up where you left off?`)&&u()&&w(y.name,{draftName:y.newName})}}};
40
+ </div>`),O=r.querySelector(".mdx-preview"),x=Ve(n.name);if(Oe(n.name)){const t=document.createElement("img");t.src=`${n.url}?t=${encodeURIComponent(B)}`,t.alt=n.name,O.appendChild(t)}else if(x==="video"||x==="audio"){const t=document.createElement(x);t.src=n.url,t.controls=!0,t.preload="metadata",O.appendChild(t)}else{const t=document.createElement("span");t.setAttribute("data-icon",x==="document"?"file-text":"paperclip"),t.setAttribute("data-icon-size","40"),O.appendChild(t)}const De=r.querySelector(".mdx-facts"),T=(t,o)=>{const be=document.createElement("dt");be.textContent=t;const Y=document.createElement("dd");return Y.textContent=o,De.append(be,Y),Y};if(T("Type",`${he[x]==="Images"?"Image":he[x].replace(/s$/,"")} (${(n.name.split(".").pop()||"").toUpperCase()})`),T("Size",ge(n.size)),T("Uploaded",n.createdAt?Je(n.createdAt):"-"),G(n.name)){const t=T("Dimensions","\u2026");C.media.info(n.name).then(o=>{t.textContent=o?.width?`${o.width} \xD7 ${o.height} px`:"-"}).catch(()=>{t.textContent="-"})}r.querySelector(".mdx-url").value=H(n),r.querySelector(".mdx-md").value=J(n),r.querySelector(".mdx-open").href=n.url;let A=!1;async function pe(){if(!ue.cannotRename.peek()){$.value=!0;try{const t=await C.media.rename(n.name,u.peek().trim());E.toast(`Renamed to "${t?.name||L(u.peek().trim())}".`,{type:"success"}),A=!0,d.close(),m()&&await g()}catch(t){E.toast(`Not renamed: ${t.message||t}`,{type:"error"})}finally{$.value=!1}}}d.element.appendChild(r);const $e=ve(r),Te=M.applyBindings(ue,r,{methods:{rename:pe,copyUrl:()=>z(H(n),"Address"),copyMd:()=>z(J(n),"Markdown"),async del(){await F(n)&&(A=!0,d.close())},async edit(){A=!0,d.close(),await se(n)}}}),_=r.querySelector("#mdx-rename"),Le=t=>{t.key==="Enter"&&t.target===_&&(t.preventDefault(),pe())};r.addEventListener("keydown",Le);const fe={name:n.name,dirty:me,newName:()=>u.peek()};v=fe,P.add(d),Be(d,()=>{Te.dispose(),$e(),r.querySelectorAll("video, audio").forEach(t=>{try{t.pause()}catch{}}),P.delete(d),v===fe&&(v=null)});const Ne=d.close.bind(d);let V=!1;d.close=async t=>{if(!A&&!ie&&t!==!0&&me()){if(V)return;V=!0;const o=await E.confirm("Discard the new name you typed?");if(V=!1,!o)return}return A=!0,Ne()},I.scan(r),d.open(),(a||i)&&(_.focus(),_.select())}function Me(e){const a=h(e);return a?[{header:a.name},{label:"Details\u2026",icon:"info",action:()=>w(a.name)},{label:"Copy address",icon:"link",action:()=>z(H(a),"Address")},{label:"Copy for a page",icon:"copy",action:()=>z(J(a),"Markdown")},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(a.url,"_blank","noopener")},{type:"divider"},{label:"Rename\u2026",icon:"type",action:()=>w(a.name,{focusRename:!0})},...G(a.name)?[{label:"Edit image\u2026",icon:"edit",action:()=>se(a)}]:[],{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>F(a)}]:[]}const f=s.querySelector(".mdx-grid");f.innerHTML=Qe;const k=e=>()=>{b.value=e},Se=M.applyBindings({files:p,loading:Z,loadError:R,kind:b,sort:U,query:ee,tiles:D,counts:oe,totalText:xe,emptyText:Ee,hintText:ae,foldersNote:ne,dragging:te},s,{methods:{kindAll:k("all"),kindImage:k("image"),kindVideo:k("video"),kindAudio:k("audio"),kindDocument:k("document"),kindOther:k("other")}});l.add(()=>Se.dispose()),l.add(ve(s,{position:"bottom"})),l.add(M.effect(()=>{D.value,requestAnimationFrame(()=>{f.isConnected&&I.scan(f)})}));const Ae=E.contextMenu(f,{cursor:"glyph",match:".mdx-tile",inherit:!1,density:"compact",items:e=>Me(e.dataset.name)});l.add(()=>Ae?.destroy?.());const le=e=>{const a=e.target.closest(".mdx-tile");if(!a)return;const i=e.target.closest(".mdx-kebab");if(i){ye(i);return}w(a.dataset.name)},re=e=>{const a=e.target.closest(".mdx-tile");if(!a||e.target!==a)return;const i=h(a.dataset.name);i&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),ye(a)):e.key==="Enter"?w(i.name):e.key==="F2"?(e.preventDefault(),w(i.name,{focusRename:!0})):e.key==="Delete"&&(e.preventDefault(),F(i)))};f.addEventListener("click",le),f.addEventListener("keydown",re),l.add(()=>{f.removeEventListener("click",le),f.removeEventListener("keydown",re)});const K=ze(s.querySelector(".mdx-zone"),{input:s.querySelector(".mdx-file-input"),exists:e=>!!h(e),showing:m,onHint:e=>{ae.value=e},onUploaded(){j(Q),m()?g():W?.()}});W=()=>{m()&&g()},l.add(()=>{W=null,K.release()}),Ie(c,{id:"media-upload",icon:"upload",title:"Upload files",onClick:()=>K.browse()}),l.add(qe(c.get(0),K.addFiles,{onDragging:e=>{te.value=e}}));const de=e=>{v?.dirty()&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",de),l.add(()=>window.removeEventListener("beforeunload",de)),l.add(()=>{if(v?.dirty())try{S.set(N,{name:v.name,newName:v.newName(),at:new Date().toISOString()})}catch{}ie=!0,[...P].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(s),await g(),!m())return;C.media.folders().then(e=>{m()&&e?.files&&(ne.value=Ye(e))}).catch(()=>{});let y=null;try{y=S.get(N)}catch{}if(y?.name){try{S.remove?S.remove(N):S.set(N,null)}catch{}h(y.name)&&await E.confirm(`You were renaming "${q(y.name)}" to "${q(y.newName)}" and left before saving. Pick up where you left off?`)&&m()&&w(y.name,{draftName:y.newName})}}};
@@ -40,6 +40,7 @@ Code was treated as the truth. Where docs disagree with it, the disagreement is
40
40
  | `booking-pro` | paid | 0.4.1 | More for Booking: online appointments as a video call on your site (optional host recording), Call now - open a booking's call at once or call anyone from a contact or an email (switches on the CMS's instant calls), a person and a room together, classes with places and a waiting list that fills a freed place by itself, repeat bookings, questions on the booking form, a daily limit and one booking per customer every N days. A lapse leaves Booking and every booking as they were. |
41
41
  | `calendar` | paid | 1.15.4 | Events calendar - month, day and list views, online meetings as a video call on your site (with the call's chat kept, and Add people during the call), call anyone now from a contact or an email, all-day and recurring events, sharing with people and roles, RSVPs and an iCal feed. |
42
42
  | `campaigns-pro` | paid | 1.6.0 | Marketing campaigns, one paid Tool: compose a message, send it to Contacts groups (read live when it sends) or an audience of its own (shared with Surveys), from the site's sending or your own Email mailbox (small lists), schedule sends, attach an offer that closes by a date or a claim limit. Opens and clicks (cookieless), links tagged for Analytics, a linked Shop discount code, send a survey as a campaign, follow-up sequences, resend to non-openers, A/B subject tests, and a version-1 stats feed other Tools read. |
43
+ | `media-pro` | paid | 0.2.0 | Media, properly organised: folders inside folders, choose from them anywhere, and move or rename anything without breaking a page. Select several, see where each file is used, find what is unused or duplicated, shrink big pictures, alt text and credits with each file, Trash, and a whole folder as a gallery. Works on the same files as the built-in Tool. |
43
44
  | `contacts-pro` | paid | 0.13.0 | Contacts, with more to them: send a campaign to a group or the selected contacts (with Campaigns Pro), your own custom fields, birthdays and ages with the ones coming up and a reminder in the sidebar, and groups with their own emblem and colours. Share a contact, several, or a whole group with people or roles - to view, or to edit. Call a contact now on a video call on your site. Works over the same contacts as the built-in Tool, so nothing moves and nothing is lost. |
44
45
  | `crossword` | paid (giftable) | 1.5.1 | Crosswords on your site: type the answers and clues and the grid lays itself out (live preview, Another layout). Players type a name and race the server's clock, checks and wrong guesses cost time, fastest solvers on a leaderboard. Hints for a time penalty, personal best and Share, animations, export and import. Test it from the Tool - a test go never reaches the board. Rotation (a new quiz every day or week from a queue, off by default) and fresh quizzes from Domma for review. |
45
46
  | `daily-word` | paid (giftable) | 1.3.0 | One hidden word a day, the same for everyone: six guesses, each letter marked right place, in the word or not; real words only (a bundled dictionary, switchable), an archive of past days, streaks, Share as coloured squares, a calendar of what is coming. Fewest guesses tops the day's board, then the fastest. |
@@ -335,6 +336,8 @@ Fast, file-based and friendly.
335
336
  ### Media library
336
337
 
337
338
  - **Media library** - upload by button or by dropping files anywhere on the screen (images, documents, audio, video; 10 MB default limit). Tiles with thumbnail, size, age and type; filter All / Images / Video / Audio / Documents / Other; sort newest, oldest, name or largest. Details slideover with rename, Copy address and Copy for a page (Markdown); right-click menu, F2 to rename, Delete key. Replacing a same-named file asks first.
339
+ - **Files in folders** - the built-in screen lists the top of the library; when there are files in folders it says how many, and they keep working at their addresses (`GET /api/media/_folders`). Managing folders is Media Pro.
340
+ - **Media Pro** (paid, `media-pro`, marketplace; dev on dcm) - takes over the Media screen and every image picker. Nested folders that are real folders (`/media/products/shoes/red.jpg`), drag to move, upload a whole folder keeping its shape, select several (move, tag, shrink, zip, Trash). Moving or renaming anything updates pages, collections and settings that use it and adds a redirect in the SEO Tool; blocks, forms, menus, custom.css and other Tools' data are reported and kept working by that redirect. Used-on list per file, Tidy up (unused, duplicates, big pictures, no alt text), alt text, caption, credit and tags with each file, Replace keeping the address, Shrink (optionally to WebP), upload rules (longest side, remove location data, store as WebP), Trash with restore, thumbnails, `[media-gallery folder="…" /]`. 0.2.0: pages offer phones smaller copies (`srcset`), a focal point per picture is kept in crops, and Claude writes alt text for a person to check, included in the plan (the Manager holds the key: site-manager `mediaAltRoutes.js`, `tools/media-alt`; 5,000 per site per month). Over the same files as the built-in Tool: a lapsed licence loses no file and breaks no address. Hooks in core: `BUILT_IN_TOOLS` takes `media`, `admin.mediaPicker` in a manifest, `openImageEditor(file, {api})`, `mediaUploader(zone, {url})`.
338
341
  - Where: **Content > Media**; `content/media/`; `config/server.json` `uploads.maxFileSize`
339
342
  - Since: 0.5.0
340
343
  - **Image editor** - edit JPEG, PNG, WebP, GIF or TIFF in place: crop (aspect lock), resize, rotate, flip, colour presets (grayscale, sepia, warm, cool, enhance, sharpen, soften, invert), adjustments, watermark (position, scale, opacity), border (solid, mirror, repeat) and output format (JPEG, PNG, WebP with quality). Save as a copy or overwrite.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.34.0",
3
+ "version": "1.36.0",
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",
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/body-menu.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/body-menu.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The reading pane's right-click menu - the pure parts.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/cms-host.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/cms-host.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** The CMS shell boundary. Standalone never imports this adapter. */
4
4
  const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/compose-window.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/compose-window.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  const {createMailHost} = await import(new URL(`./host-context.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/contacts.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/contacts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Recipient suggestions from the host address book.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/diagnostics-section.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/diagnostics-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The settings section that answers "which build is this, and what went wrong".
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/drag-drop.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/drag-drop.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Drag identities include the mailbox and source folder: UIDs alone are not unique. */
4
4
  const PROTECTED_USES = new Set(['\\Inbox', '\\Sent', '\\Drafts', '\\Trash', '\\Junk', '\\Archive', '\\All', '\\Flagged']);
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/folder-tree.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/folder-tree.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Mail folder presentation, shared by the Mail Reader and Email Pro.
@@ -174,6 +174,31 @@ export function unreadInSubtree(node) {
174
174
  return node.children.reduce((total, child) => total + unreadInSubtree(child), own);
175
175
  }
176
176
 
177
+ /**
178
+ * Every folder that has folders inside it - what "Close all folders" shuts.
179
+ *
180
+ * @param {object[]} roots
181
+ * @returns {string[]}
182
+ */
183
+ export function foldablePaths(roots) {
184
+ return flattenFolderTree(roots).filter(node => node.children.length > 0).map(node => node.path);
185
+ }
186
+
187
+ /**
188
+ * A folder and every folder beneath it that can hold mail, parent first -
189
+ * what "including folders inside" acts on. Unselectable levels (a parent a
190
+ * server lists only as a container, or one the tree synthesised) are left out.
191
+ *
192
+ * @param {object[]} roots
193
+ * @param {string} path
194
+ * @returns {string[]} empty when the path is not in the tree
195
+ */
196
+ export function subtreePaths(roots, path) {
197
+ const node = flattenFolderTree(roots).find(item => item.path === path);
198
+ if (!node) return [];
199
+ return flattenFolderTree([node]).filter(item => item.selectable !== false).map(item => item.path);
200
+ }
201
+
177
202
  /**
178
203
  * Keep only the branches that lead to unread mail.
179
204
  *
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/font-controls.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/font-controls.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/fonts.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/fonts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The fonts and sizes the mail editor offers - pure, so both the compose
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/host-context.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/host-context.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Services supplied by the application that hosts the shared mail interface. */
4
4
  export function createMailApi({getToken, fetch: request = globalThis.fetch, onUnauthorized = () => {}}) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/identity.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/identity.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Who a mailbox sends as, and what it signs off with.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/image-senders-section.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/image-senders-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The settings section for senders whose images always load.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/keyboard.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/keyboard.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Keyboard navigation for the reader.
@@ -1,4 +1,4 @@
1
- <!-- Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/mail.html. -->
1
+ <!-- Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/mail.html. -->
2
2
  <div class="mail-layout">
3
3
 
4
4
  <!-- Folders -->
@@ -9,6 +9,9 @@
9
9
  <input type="checkbox" id="mail-unread-only">
10
10
  <span>Unread</span>
11
11
  </label>
12
+ <button class="btn btn-sm btn-ghost" id="mail-fold-all-btn" title="Close all folders" hidden>
13
+ <span data-icon="chevrons-right" data-icon-size="14"></span>
14
+ </button>
12
15
  <button class="btn btn-sm btn-ghost" id="mail-new-folder-btn" title="New folder" hidden>
13
16
  <span data-icon="folder-plus" data-icon-size="14"></span>
14
17
  </button>
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/message-actions.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/message-actions.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * What other Tools add to a message's menu - Booking's "Book Sam...".
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/oauth-panel.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/oauth-panel.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * "Sign in with Microsoft / Google" for a mailbox - the part of the mailbox
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/panes.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/panes.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Pane sizing for the mail reader, shared by the Mail Reader and Email Pro.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/reader-kit.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/reader-kit.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The reader view's decisions that need no DOM - escaping, the mailbox form's
@@ -237,14 +237,20 @@ export function onceOnly() {
237
237
  /**
238
238
  * What a mailbox row's menu offers, as ids the view maps to actions.
239
239
  *
240
- * @param {{isCurrent: boolean, isDefault: boolean, count: number, canWrite?: boolean}} o
240
+ * @param {{isCurrent: boolean, isDefault: boolean, count: number, foldable?: number|null}} o
241
241
  * @returns {{id: string, label: string, icon: string, disabled?: boolean, danger?: boolean}[]|object[]}
242
242
  */
243
- export function accountMenuModel({isCurrent = false, isDefault = false, count = 1} = {}) {
243
+ export function accountMenuModel({isCurrent = false, isDefault = false, count = 1, foldable = null} = {}) {
244
+ // `foldable` is how many folders have folders inside, known only for the
245
+ // open mailbox; for another one the items open it first, so they stay on.
246
+ const nothingToFold = isCurrent && foldable === 0;
244
247
  return [
245
248
  {id: 'open', label: isCurrent ? 'Open (already open)' : 'Open', icon: 'inbox', disabled: isCurrent},
246
249
  {id: 'refresh', label: 'Check for new mail', icon: 'refresh-cw', disabled: !isCurrent},
247
250
  {type: 'divider'},
251
+ {id: 'expandAll', label: 'Open all folders', icon: 'chevrons-down', disabled: nothingToFold},
252
+ {id: 'collapseAll', label: 'Close all folders', icon: 'chevrons-right', disabled: nothingToFold},
253
+ {type: 'divider'},
248
254
  {id: 'edit', label: 'Edit…', icon: 'edit-3'},
249
255
  ...(count > 1 ? [{id: 'default', label: isDefault ? 'Unset default' : 'Make default', icon: 'star'}] : []),
250
256
  {type: 'divider'},
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/reader-runtime.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/reader-runtime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  const {createMailHost} = await import(new URL(`./host-context.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
@@ -35,9 +35,11 @@ const {
35
35
  flattenFolderTree,
36
36
  folderHeading,
37
37
  folderMenuItems,
38
+ foldablePaths,
38
39
  iconForFolder,
39
40
  isSpamFolder,
40
41
  pruneToUnread,
42
+ subtreePaths,
41
43
  unreadInSubtree
42
44
  } = await import(versioned('folder-tree.js'));
43
45
  const {imageSendersSection} = await import(versioned('image-senders-section.js'));
@@ -296,6 +298,7 @@ return {
296
298
  */
297
299
  let folderMenu = null;
298
300
  let folderActionMenu = null;
301
+ let folderHeadMenu = null;
299
302
  let folderActionBusy = false;
300
303
  let dragState = null;
301
304
  let dropBusy = false;
@@ -384,6 +387,27 @@ return {
384
387
  renderFolders();
385
388
  }
386
389
 
390
+ /**
391
+ * Open or shut every folder in a mailbox, opening that mailbox first
392
+ * when it is not the one on screen (only its folders are loaded).
393
+ *
394
+ * @param {string} accountId
395
+ * @param {boolean} open
396
+ * @returns {Promise<void>}
397
+ */
398
+ async function setAllFolded(accountId, open) {
399
+ if (accountId !== currentAccountId) await selectAccount(accountId);
400
+ if (!here() || currentAccountId !== accountId) return;
401
+ const paths = open ? [] : foldablePaths(buildFolderTree(folders));
402
+ collapsedByAccount = {...collapsedByAccount, [currentAccountId]: paths};
403
+ try {
404
+ S.set(COLLAPSED_KEY, collapsedByAccount);
405
+ } catch {
406
+ // Storage unavailable - the fold still works for this visit.
407
+ }
408
+ renderFolders();
409
+ }
410
+
387
411
  const foldersEl = $container.find('#mail-folders-list').get(0);
388
412
  const listEl = $container.find('#mail-list').get(0);
389
413
  const selectAllEl = $container.find('#mail-select-all').get(0);
@@ -393,6 +417,7 @@ return {
393
417
  const readerBodyEl = $container.find('#mail-reader-body').get(0);
394
418
  const listTitleEl = $container.find('#mail-list-title').get(0);
395
419
  const folderActionsBtn = $container.find('#mail-folder-actions-btn').get(0);
420
+ const foldAllBtn = $container.find('#mail-fold-all-btn').get(0);
396
421
  const searchEl = $container.find('#mail-search').get(0);
397
422
  const searchInputEl = $container.find('#mail-search-input').get(0);
398
423
  const searchClearEl = $container.find('#mail-search-clear').get(0);
@@ -691,6 +716,8 @@ return {
691
716
  folderMenu = null;
692
717
  folderActionMenu?.destroy?.();
693
718
  folderActionMenu = null;
719
+ folderHeadMenu?.destroy?.();
720
+ folderHeadMenu = null;
694
721
  clearDrag();
695
722
  stopFitting?.();
696
723
  stopFitting = null;
@@ -1910,6 +1937,7 @@ return {
1910
1937
  foldersEl.textContent = '';
1911
1938
  if (folderActionsBtn) folderActionsBtn.disabled = !currentAccountId || folderActionBusy || !folders.length;
1912
1939
  paintUnreadFilter();
1940
+ paintFoldAll();
1913
1941
 
1914
1942
  for (const box of mailboxes) {
1915
1943
  const isCurrent = box.id === currentAccountId;
@@ -2073,6 +2101,37 @@ return {
2073
2101
  *
2074
2102
  * @returns {void}
2075
2103
  */
2104
+ /**
2105
+ * What the Folders head offers for the open mailbox: open everything
2106
+ * when every branch is shut, otherwise close everything. Nothing to
2107
+ * fold, no button.
2108
+ *
2109
+ * @returns {{foldable: string[], allShut: boolean}}
2110
+ */
2111
+ function foldAllState() {
2112
+ const foldable = currentAccountId ? foldablePaths(buildFolderTree(folders)) : [];
2113
+ const collapsed = collapsedSet();
2114
+ return {foldable, allShut: foldable.length > 0 && foldable.every(path => collapsed.has(path))};
2115
+ }
2116
+
2117
+ /** @returns {void} */
2118
+ function paintFoldAll() {
2119
+ if (!foldAllBtn) return;
2120
+ const {foldable, allShut} = foldAllState();
2121
+ foldAllBtn.hidden = !foldable.length;
2122
+ const label = allShut ? 'Open all folders' : 'Close all folders';
2123
+ foldAllBtn.title = label;
2124
+ foldAllBtn.setAttribute('aria-label', label);
2125
+ const icon = allShut ? 'chevrons-down' : 'chevrons-right';
2126
+ if (foldAllBtn.dataset.icon === icon) return;
2127
+ foldAllBtn.dataset.icon = icon;
2128
+ const glyph = document.createElement('span');
2129
+ glyph.setAttribute('data-icon', icon);
2130
+ glyph.setAttribute('data-icon-size', '14');
2131
+ foldAllBtn.replaceChildren(glyph);
2132
+ try { Domma.icons?.scan?.(foldAllBtn); } catch { /* the title still names it */ }
2133
+ }
2134
+
2076
2135
  function paintUnreadFilter() {
2077
2136
  const label = unreadFilterEl?.querySelector('span');
2078
2137
  if (!label) return;
@@ -5214,6 +5273,24 @@ return {
5214
5273
  return true;
5215
5274
  }
5216
5275
  });
5276
+ // The Folders head: open or close every folder - the only place
5277
+ // for it when there is one mailbox and so no mailbox row.
5278
+ const head = foldersEl.closest('.mail-folders-pane')?.querySelector('.mail-pane-head');
5279
+ if (head) {
5280
+ folderHeadMenu = elements.contextMenu(head, {
5281
+ inherit: false,
5282
+ items: [],
5283
+ onBeforeOpen: () => {
5284
+ const {foldable} = foldAllState();
5285
+ if (!foldable.length) return false;
5286
+ folderHeadMenu.setItems([
5287
+ {label: 'Open all folders', icon: 'chevrons-down', action: () => setAllFolded(currentAccountId, true)},
5288
+ {label: 'Close all folders', icon: 'chevrons-right', action: () => setAllFolded(currentAccountId, false)}
5289
+ ]);
5290
+ return true;
5291
+ }
5292
+ });
5293
+ }
5217
5294
  if (features.folders && folderActionsBtn) {
5218
5295
  folderActionsBtn.hidden = false;
5219
5296
  folderActionMenu = elements.contextMenu(folderActionsBtn, {
@@ -5240,10 +5317,13 @@ return {
5240
5317
  return mergeExtensionItems(menuItems(accountMenuModel({
5241
5318
  isCurrent: box.id === currentAccountId,
5242
5319
  isDefault: box.isDefault === true,
5243
- count: mailboxes.length
5320
+ count: mailboxes.length,
5321
+ foldable: box.id === currentAccountId ? foldablePaths(buildFolderTree(folders)).length : null
5244
5322
  }), {
5245
5323
  open: () => selectAccount(box.id),
5246
5324
  refresh: () => refreshMailbox(),
5325
+ expandAll: () => setAllFolded(box.id, true),
5326
+ collapseAll: () => setAllFolded(box.id, false),
5247
5327
  edit: () => openMailboxForm(box),
5248
5328
  default: () => toggleDefaultMailbox(box),
5249
5329
  remove: () => removeMailbox(box)
@@ -5290,14 +5370,23 @@ return {
5290
5370
  const read = folderReadItems(folder);
5291
5371
  const extra = extensionItems('folderItems', folder);
5292
5372
  if (!features.folders) return mergeExtensionItems(read, extra);
5373
+ // A folder with folders inside offers "this one" or "the lot" as a
5374
+ // submenu; a leaf keeps the plain item.
5375
+ const inside = subtreePaths(buildFolderTree(folders), folder.path).filter(path => path !== folder.path);
5376
+ const markItem = (label, icon, action) => !inside.length
5377
+ ? {label, icon, disabled: () => folderActionBusy, action: () => folderContentsAction(folder, action)}
5378
+ : {label, icon, disabled: () => folderActionBusy, submenu: [
5379
+ {label: 'This folder', icon: 'folder', disabled: () => folderActionBusy || folder.selectable === false,
5380
+ action: () => folderContentsAction(folder, action)},
5381
+ {label: 'Including folders inside', icon: 'folder-open', disabled: () => folderActionBusy,
5382
+ action: () => folderTreeAction(folder, action)}
5383
+ ]};
5293
5384
  return mergeExtensionItems([
5294
5385
  ...read,
5295
5386
  {type: 'divider'},
5296
5387
  {label: 'Refresh folders', icon: 'refresh-cw', action: () => refreshFolders()},
5297
- {label: 'Mark all as read', icon: 'mail-open', disabled: () => folderActionBusy,
5298
- action: () => folderContentsAction(folder, 'markRead')},
5299
- {label: 'Mark all as unread', icon: 'mail', disabled: () => folderActionBusy,
5300
- action: () => folderContentsAction(folder, 'markUnread')},
5388
+ markItem('Mark all as read', 'mail-open', 'markRead'),
5389
+ markItem('Mark all as unread', 'mail', 'markUnread'),
5301
5390
  {label: folder.specialUse === '\\Trash' ? 'Empty Trash...' : 'Clear folder...', icon: 'trash', danger: true,
5302
5391
  disabled: () => folderActionBusy || ['\\All', '\\Flagged'].includes(folder.specialUse)
5303
5392
  || !folders.some(item => item.specialUse === '\\Trash'),
@@ -5353,6 +5442,62 @@ return {
5353
5442
  ], extra);
5354
5443
  }
5355
5444
 
5445
+ /**
5446
+ * Mark every message in a folder and the folders beneath it, one
5447
+ * folder at a time (the server allows one folder action per mailbox).
5448
+ *
5449
+ * @param {object} folder
5450
+ * @param {'markRead'|'markUnread'} action
5451
+ * @returns {Promise<void>}
5452
+ */
5453
+ async function folderTreeAction(folder, action) {
5454
+ if (folderActionBusy || !currentAccountId) return;
5455
+ const account = currentAccountId;
5456
+ const paths = subtreePaths(buildFolderTree(folders), folder.path);
5457
+ if (!paths.length) return;
5458
+ folderActionBusy = true;
5459
+ if (folderActionsBtn) folderActionsBtn.disabled = true;
5460
+ let count = 0;
5461
+ let done = 0;
5462
+ const failed = [];
5463
+ try {
5464
+ if (paths.includes(currentFolder)) cancelMarkRead();
5465
+ for (const path of paths) {
5466
+ if (!here() || currentAccountId !== account) return;
5467
+ try {
5468
+ const result = await api(`${BASE}/folders/messages?${new URLSearchParams({account})}`, 'POST', {
5469
+ path, action, confirmed: false
5470
+ });
5471
+ count += Number(result?.processed) || 0;
5472
+ done++;
5473
+ } catch {
5474
+ failed.push(path);
5475
+ }
5476
+ }
5477
+ if (!here() || currentAccountId !== account) return;
5478
+ const word = action === 'markRead' ? 'read' : 'unread';
5479
+ const where = `${done} folder${done === 1 ? '' : 's'}`;
5480
+ if (failed.length) {
5481
+ E.toast(`Marked ${count} messages as ${word} in ${where}; could not do ${failed.join(', ')}.`, {type: 'warning'});
5482
+ } else {
5483
+ E.toast(`Marked ${count} messages as ${word} in ${where}.`, {type: 'success'});
5484
+ }
5485
+ } finally {
5486
+ folderActionBusy = false;
5487
+ if (here()) {
5488
+ if (folderActionsBtn) folderActionsBtn.disabled = !currentAccountId || !folders.length;
5489
+ if (currentAccountId === account) {
5490
+ if (paths.includes(currentFolder)) {
5491
+ clearSelection();
5492
+ page = 1;
5493
+ }
5494
+ await refreshFolders();
5495
+ if (searchQuery) await loadMessages({fresh: true, quiet: true});
5496
+ }
5497
+ }
5498
+ }
5499
+ }
5500
+
5356
5501
  /** Apply to the entire named folder, including messages beyond this page. */
5357
5502
  async function folderContentsAction(folder, action) {
5358
5503
  if (folderActionBusy || !currentAccountId) return;
@@ -6425,6 +6570,9 @@ return {
6425
6570
  } catch { /* no banner: the pane buttons stay */ }
6426
6571
  if (!here()) return;
6427
6572
  $container.find('#mail-refresh-btn').on('click', () => refreshMailbox());
6573
+ foldAllBtn?.addEventListener('click', () => {
6574
+ if (currentAccountId) setAllFolded(currentAccountId, foldAllState().allShut);
6575
+ });
6428
6576
 
6429
6577
  // Folder management was right-click only, which is the same as not
6430
6578
  // existing for anyone who does not already know it is there.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/reader-view.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/reader-view.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Existing CMS entry point for the shared mail view. */
4
4
  const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/resizable.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/resizable.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The mail reader's resizable slideovers.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/restore-spam.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/restore-spam.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Undo restores both junk status and the original folder, following each UID remap. */
4
4
  export async function restoreSpam({api, base, account, from, destination, uids, spam}) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/rules.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/rules.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Filing rules.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/scheduling.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/scheduling.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/section-kit.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/section-kit.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/security-note.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/security-note.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * What the reader says about a signed or encrypted (S/MIME) message.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/settings-section.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/settings-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Browser preferences for the shared mail reader. */
4
4
  export const READ_DELAY_KEY = 'domma-mail.mark-read-seconds';