domma-cms 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.8.1] - 2026-10-16
|
|
4
|
+
|
|
5
|
+
- Search display offers Icon/Text, Icon and Hidden for navbar and floating triggers. Hidden removes the button while keeping site search available through Ctrl+K or Cmd+K whenever search is enabled. Existing icon and text settings retain their appearance.
|
|
6
|
+
|
|
3
7
|
## [1.8.0] - 2026-10-15
|
|
4
8
|
|
|
5
9
|
- **Built against domma-js 0.53.0** - see [its release notes](https://github.com/pinpointzero73/domma/releases/tag/v0.53.0).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIMITS={maxResults:[1,50],minQueryLength:[1,5],debounceMs:[100,1e3],offsetX:[0,500],offsetY:[0,500],iconSize:[32,96]},DEFAULTS={enabled:!0,placeholder:"Search pages...",keyboardShortcut:!0,maxResults:10,minQueryLength:2,debounceMs:300,displayMode:"navbar",position:"bottom-right",offsetX:32,offsetY:32,iconOnly:!0,iconSize:52,iconRadius:26},POSITIONS=["top-left","top-right","left-center","right-center","bottom-left","bottom-right"],POSITION_LABEL={"top-left":"Top left","top-right":"Top right","left-center":"Left side","right-center":"Right side","bottom-left":"Bottom left","bottom-right":"Bottom right"};const c={maxResults:"Max results",minQueryLength:"Minimum query length",debounceMs:"Debounce delay",offsetX:"Horizontal offset",offsetY:"Vertical offset",iconSize:"Icon size"};export const maxRadius=t=>Math.floor((Number(t)||DEFAULTS.iconSize)/2);export function radiusForSize(t,e,
|
|
1
|
+
export const LIMITS={maxResults:[1,50],minQueryLength:[1,5],debounceMs:[100,1e3],offsetX:[0,500],offsetY:[0,500],iconSize:[32,96]},DEFAULTS={enabled:!0,placeholder:"Search pages...",keyboardShortcut:!0,maxResults:10,minQueryLength:2,debounceMs:300,displayMode:"navbar",position:"bottom-right",offsetX:32,offsetY:32,iconOnly:!0,iconSize:52,iconRadius:26},POSITIONS=["top-left","top-right","left-center","right-center","bottom-left","bottom-right"],POSITION_LABEL={"top-left":"Top left","top-right":"Top right","left-center":"Left side","right-center":"Right side","bottom-left":"Bottom left","bottom-right":"Bottom right"};const c={maxResults:"Max results",minQueryLength:"Minimum query length",debounceMs:"Debounce delay",offsetX:"Horizontal offset",offsetY:"Vertical offset",iconSize:"Icon size"};export const maxRadius=t=>Math.floor((Number(t)||DEFAULTS.iconSize)/2);export function radiusForSize(t,e,n){const o=Number(t)||0,i=maxRadius(n);return o>=maxRadius(e)||o>i?i:o}const r=t=>{const e=typeof t=="number"?t:parseInt(t,10);return Number.isFinite(e)?Math.round(e):null},l=(t,[e,n])=>Math.min(n,Math.max(e,t));export function formFromSettings(t){const e={...DEFAULTS,...t&&typeof t=="object"?t:{}};return{enabled:e.enabled!==!1,placeholder:String(e.placeholder??DEFAULTS.placeholder),keyboardShortcut:!0,maxResults:String(e.maxResults),minQueryLength:String(e.minQueryLength),debounceMs:String(e.debounceMs),displayMode:e.displayMode==="floating"?"floating":"navbar",position:POSITIONS.includes(e.position)?e.position:DEFAULTS.position,offsetX:String(e.offsetX),offsetY:String(e.offsetY),triggerStyle:["icon-text","icon","hidden"].includes(e.triggerStyle)?e.triggerStyle:e.iconOnly===!1?"icon-text":"icon",iconOnly:e.triggerStyle==="icon-text"?!1:["icon","hidden"].includes(e.triggerStyle)?!0:e.iconOnly!==!1,iconSize:String(e.iconSize),iconRadius:String(e.iconRadius)}}export function payloadFromForm(t){const e={...formFromSettings(null),...t||{}},n=s=>{const a=r(e[s]);return a===null?DEFAULTS[s]:l(a,LIMITS[s])},o=n("iconSize"),i=r(e.iconRadius);return{enabled:e.enabled!==!1,placeholder:String(e.placeholder??"").trim().slice(0,120)||DEFAULTS.placeholder,keyboardShortcut:!0,maxResults:n("maxResults"),minQueryLength:n("minQueryLength"),debounceMs:n("debounceMs"),displayMode:e.displayMode==="floating"?"floating":"navbar",position:POSITIONS.includes(e.position)?e.position:DEFAULTS.position,offsetX:n("offsetX"),offsetY:n("offsetY"),triggerStyle:["icon-text","icon","hidden"].includes(e.triggerStyle)?e.triggerStyle:e.iconOnly===!1?"icon-text":"icon",iconOnly:e.triggerStyle==="icon-text"?!1:["icon","hidden"].includes(e.triggerStyle)?!0:e.iconOnly!==!1,iconSize:o,iconRadius:i===null?Math.min(DEFAULTS.iconRadius,maxRadius(o)):l(i,[0,maxRadius(o)])}}export const snapshot=t=>JSON.stringify(payloadFromForm(t));export function clampNotes(t){const e=[];for(const[n,o]of Object.entries(LIMITS)){const i=String(t?.[n]??"").trim(),s=r(i);i===""||s===null?e.push(`${c[n]} is empty - it will be saved as ${DEFAULTS[n]}.`):(s<o[0]||s>o[1])&&e.push(`${c[n]} is ${o[0]}-${o[1]} - ${s} will be saved as ${l(s,o)}.`)}return e}export function liveChips(t,e=null){const n={...DEFAULTS,...t||{}};if(!n.enabled)return[{text:"Off - nothing is added to public pages",tone:"warn"}];const o=[{text:"On",tone:"ok"}];return o.push({text:n.triggerStyle==="hidden"?"Hidden (keyboard shortcut available)":n.displayMode==="floating"?`Floating button, ${(POSITION_LABEL[n.position]||n.position).toLowerCase()}`:"Icon in the navigation bar",tone:""}),o.push({text:"Ctrl+K / \u2318K",tone:""}),o.push({text:`Up to ${n.maxResults} results`,tone:""}),e&&o.push({text:`${e.searchable} page${e.searchable===1?"":"s"} searchable`,tone:""}),o}export function previewState(t,e){const n=String(t??"").trim(),o=r(e)??DEFAULTS.minQueryLength;return n?n.length<o?{run:!0,note:`Visitors need at least ${o} characters - on the site this would not search yet.`}:{run:!0,note:""}:{run:!1,note:"Type a word or two - results appear as you type."}}export function resultRow(t,e){return{id:`${e}|${t.url}`,url:String(t.url||"/"),title:String(t.title||"Untitled"),snippet:String(t.snippet||t.description||""),meta:[t.url,(t.tags||[]).length?`tags: ${(t.tags||[]).join(", ")}`:""].filter(Boolean).join(" \xB7 "),score:`score ${Number(t.score)||0}`,rank:String(e+1)}}export const searchDraftKey=t=>t?`search.draft.${t}`:null;export function keptDraft(t,e,n){if(!n||!t||typeof t!="object"||t.owner!==n||!t.form||typeof t.form!="object")return null;const o=typeof t.was=="string"?t.was:typeof t.base=="string"?t.base:"";let i=!1;try{i=snapshot(t.form)===e}catch{}return i?null:{form:t.form,was:o,at:typeof t.at=="string"?t.at:"",stale:!!o&&o!==e}}export function draftQuestion({when:t="",stale:e=!1}={}){return{title:"Unsaved changes",text:`Throw away the search settings you left unsaved${t?` (${t})`:""}?`+(e?" Note: the saved settings have changed since you began - check before you save.":""),confirmText:"Throw away",cancelText:"Keep them"}}
|
|
@@ -46,11 +46,7 @@
|
|
|
46
46
|
<input id="ssx-placeholder" type="text" class="form-input" maxlength="120" placeholder="Search pages..." data-model="placeholder.value">
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
49
|
-
<
|
|
50
|
-
<label class="form-label" for="ssx-shortcut">Keyboard shortcut (Ctrl+K / ⌘K)
|
|
51
|
-
<span data-help="Lets visitors open search from anywhere on a page with Ctrl+K (⌘K on a Mac), as well as by clicking the trigger."></span></label>
|
|
52
|
-
<input id="ssx-shortcut" type="checkbox" class="form-switch" data-model="keyboardShortcut.value">
|
|
53
|
-
</div>
|
|
49
|
+
<p class="ssx-note">Ctrl+K / ⌘K always opens search when search is enabled, including when the trigger is hidden.</p>
|
|
54
50
|
</div>
|
|
55
51
|
|
|
56
52
|
<div class="ssx-card">
|
|
@@ -80,6 +76,13 @@
|
|
|
80
76
|
<div class="ssx-card">
|
|
81
77
|
<div class="ssx-card-title">How visitors open it
|
|
82
78
|
<span data-help-title="Trigger" data-help="Navbar adds a search icon to the site's navigation bar. Floating button puts a fixed button on every page, in the corner or side you choose - useful when the navigation is busy or hidden on small screens."></span></div>
|
|
79
|
+
<label class="form-label" for="ssx-trigger-style">Search display</label>
|
|
80
|
+
<select id="ssx-trigger-style" class="form-select" data-model="triggerStyle.value">
|
|
81
|
+
<option value="icon-text">Icon/Text</option>
|
|
82
|
+
<option value="icon">Icon</option>
|
|
83
|
+
<option value="hidden">Hidden</option>
|
|
84
|
+
</select>
|
|
85
|
+
<p class="ssx-note">Ctrl+K / ⌘K is always available when search is enabled.</p>
|
|
83
86
|
<div class="ssx-seg" role="group" aria-label="Display mode">
|
|
84
87
|
<button type="button" data-on-click="useNavbar" data-bind-class="displayMode.value === 'navbar' && 'is-on'">
|
|
85
88
|
<span data-icon="menu" data-icon-size="14"></span> Navbar</button>
|
|
@@ -88,14 +91,9 @@
|
|
|
88
91
|
</div>
|
|
89
92
|
</div>
|
|
90
93
|
|
|
91
|
-
<div class="ssx-card" data-bind-hidden="displayMode.value !== 'floating'">
|
|
94
|
+
<div class="ssx-card" data-bind-hidden="displayMode.value !== 'floating' || triggerStyle.value === 'hidden'">
|
|
92
95
|
<div class="ssx-card-title">The floating button</div>
|
|
93
|
-
<div class="ssx-
|
|
94
|
-
<label class="form-label" for="ssx-icononly">Icon only
|
|
95
|
-
<span data-help="On: a round or square icon button. Off: a pill with a Search label beside the icon (size and corners then follow the label)."></span></label>
|
|
96
|
-
<input id="ssx-icononly" type="checkbox" class="form-switch" data-model="iconOnly.value">
|
|
97
|
-
</div>
|
|
98
|
-
<div class="ssx-button-row" data-bind-hidden="!iconOnly.value">
|
|
96
|
+
<div class="ssx-button-row" data-bind-hidden="triggerStyle.value !== 'icon'">
|
|
99
97
|
<div class="ssx-sliders">
|
|
100
98
|
<label class="form-label" for="ssx-size">Size <span class="ssx-readout" data-bind-text="sizeText.value"></span>
|
|
101
99
|
<span data-help="How big the button is (32-96 px). The glyph inside scales with it. 44 px and up is comfortable to tap on a phone."></span></label>
|
package/package.json
CHANGED
package/public/css/search.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.site-search-trigger{display:inline-flex;align-items:center;justify-content:center;background:none;border:none;cursor:pointer;padding:6px 8px;border-radius:var(--dm-radius, 6px);color:inherit;opacity:.75;transition:opacity .15s,background .15s;font-size:var(--dm-font-size-sm, 14px)}.site-search-trigger:hover{opacity:1;background:var(--dm-hover-bg, rgba(128, 128, 128, .14))}.site-search-trigger svg,.site-search-trigger span[data-icon]{width:18px;height:18px}.site-search-shortcut-hint{display:inline-block;font-size:11px;line-height:1;padding:2px 5px;border-radius:4px;border:1px solid var(--dm-border, rgba(0, 0, 0, .15));color:var(--dm-text-muted, #888);margin-left:4px;vertical-align:middle;font-family:var(--dm-font-mono, monospace)}.site-search-overlay{position:fixed;inset:0;z-index:10000;background:#00000073;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);display:flex;align-items:flex-start;justify-content:center;padding-top:10vh;animation:ss-overlay-in .15s ease}@keyframes ss-overlay-in{0%{opacity:0}to{opacity:1}}.site-search-panel{width:100%;max-width:600px;margin:0 16px;border-radius:var(--dm-radius-lg, 10px);background:#1e2030;color:#e8eaf0;border:1px solid rgba(255,255,255,.1);box-shadow:0 24px 64px #0009;overflow:hidden;animation:ss-panel-in .15s ease}@keyframes ss-panel-in{0%{transform:translateY(-12px);opacity:0}to{transform:translateY(0);opacity:1}}.site-search-header{display:flex;align-items:center;padding:12px 16px;border-bottom:1px solid rgba(255,255,255,.08);gap:8px}.site-search-header span[data-icon],.site-search-header svg{width:18px;height:18px;flex-shrink:0;opacity:.45;color:#e8eaf0}.site-search-input{flex:1;border:none;outline:none;background:transparent;font-size:var(--dm-font-size-lg, 16px);color:#e8eaf0;font-family:var(--dm-font-sans, sans-serif);padding:0}.site-search-input::placeholder{color:#e8eaf066;opacity:1}.site-search-close-btn{display:inline-flex;align-items:center;justify-content:center;background:none;border:1px solid rgba(255,255,255,.15);cursor:pointer;color:#e8eaf080;border-radius:var(--dm-radius, 6px);padding:4px 8px;font-size:12px;font-family:var(--dm-font-mono, monospace);transition:color .15s,border-color .15s;flex-shrink:0}.site-search-close-btn:hover{color:#e8eaf0;border-color:#ffffff4d}.site-search-results{max-height:60vh;overflow-y:auto;padding:8px 0}.site-search-result{display:block;padding:10px 16px;text-decoration:none;color:inherit;border-left:3px solid transparent;transition:background .1s,border-color .1s;cursor:pointer}.site-search-result:hover,.site-search-result.active{background:#ffffff0f;border-left-color:var(--dm-primary, #5b8cff)}.site-search-result-title{font-weight:600;font-size:var(--dm-font-size-sm, 14px);margin-bottom:2px;color:#e8eaf0}.site-search-result-snippet{font-size:12px;color:#e8eaf08c;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.site-search-result-snippet mark{background:#5b8cff40;color:#e8eaf0;border-radius:2px;padding:0 1px}.site-search-loading,.site-search-empty{padding:24px 16px;text-align:center;color:#e8eaf073;font-size:var(--dm-font-size-sm, 14px)}.site-search-loading-dots{display:inline-flex;gap:4px}.site-search-loading-dots span{width:6px;height:6px;border-radius:50%;background:#e8eaf066;animation:ss-dot-pulse 1.2s ease-in-out infinite}.site-search-loading-dots span:nth-child(2){animation-delay:.2s}.site-search-loading-dots span:nth-child(3){animation-delay:.4s}@keyframes ss-dot-pulse{0%,80%,to{transform:scale(.6);opacity:.4}40%{transform:scale(1);opacity:1}}.site-search-results:not(:empty){border-top:1px solid rgba(255,255,255,.06)}.site-search-footer{padding:6px 16px;border-top:1px solid rgba(255,255,255,.06);display:flex;gap:12px;font-size:11px;color:#e8eaf059}.site-search-footer kbd{display:inline-block;padding:1px 4px;border-radius:3px;border:1px solid rgba(255,255,255,.15);font-family:var(--dm-font-mono, monospace);font-size:10px}@media(max-width:640px){.site-search-overlay{padding-top:5vh;align-items:flex-start}.site-search-panel{margin:0 8px;border-radius:var(--dm-radius, 6px)}.site-search-results{max-height:70vh}.site-search-shortcut-hint{display:none}}.site-search-floating-trigger{position:fixed;z-index:9999;width:52px;height:52px;border-radius:50%;border:1px solid var(--dm-border, rgba(0, 0, 0, .12));cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;background:var(--dm-surface, #fff);color:var(--dm-text, #111);box-shadow:0 4px 16px #00000024;transition:background .15s,color .15s,border-color .15s,transform .15s,box-shadow .15s;outline:none;white-space:nowrap}.site-search-floating-trigger:hover{background:var(--dm-primary, #5b8cff);color:#fff;border-color:var(--dm-primary, #5b8cff);box-shadow:0 6px 20px #00000038;transform:scale(1.05)}.site-search-floating-trigger:active{transform:scale(.97)}.site-search-floating-trigger svg,.site-search-floating-trigger [data-icon]{width:var(--ss-icon-glyph, 20px);height:var(--ss-icon-glyph, 20px);flex-shrink:0;pointer-events:none}.site-search-floating-trigger--pill{width:auto;height:44px;border-radius:999px;padding:0 18px 0 14px}.site-search-floating-label{font-size:.875rem;font-weight:500;letter-spacing:.01em;pointer-events:none}
|
|
1
|
+
.site-search-trigger{display:inline-flex;align-items:center;justify-content:center;background:none;border:none;cursor:pointer;padding:6px 8px;border-radius:var(--dm-radius, 6px);color:inherit;opacity:.75;transition:opacity .15s,background .15s;font-size:var(--dm-font-size-sm, 14px)}.site-search-trigger:hover{opacity:1;background:var(--dm-hover-bg, rgba(128, 128, 128, .14))}.site-search-trigger svg,.site-search-trigger span[data-icon]{width:18px;height:18px}.site-search-label{margin-left:6px}.site-search-shortcut-hint{display:inline-block;font-size:11px;line-height:1;padding:2px 5px;border-radius:4px;border:1px solid var(--dm-border, rgba(0, 0, 0, .15));color:var(--dm-text-muted, #888);margin-left:4px;vertical-align:middle;font-family:var(--dm-font-mono, monospace)}.site-search-overlay{position:fixed;inset:0;z-index:10000;background:#00000073;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);display:flex;align-items:flex-start;justify-content:center;padding-top:10vh;animation:ss-overlay-in .15s ease}@keyframes ss-overlay-in{0%{opacity:0}to{opacity:1}}.site-search-panel{width:100%;max-width:600px;margin:0 16px;border-radius:var(--dm-radius-lg, 10px);background:#1e2030;color:#e8eaf0;border:1px solid rgba(255,255,255,.1);box-shadow:0 24px 64px #0009;overflow:hidden;animation:ss-panel-in .15s ease}@keyframes ss-panel-in{0%{transform:translateY(-12px);opacity:0}to{transform:translateY(0);opacity:1}}.site-search-header{display:flex;align-items:center;padding:12px 16px;border-bottom:1px solid rgba(255,255,255,.08);gap:8px}.site-search-header span[data-icon],.site-search-header svg{width:18px;height:18px;flex-shrink:0;opacity:.45;color:#e8eaf0}.site-search-input{flex:1;border:none;outline:none;background:transparent;font-size:var(--dm-font-size-lg, 16px);color:#e8eaf0;font-family:var(--dm-font-sans, sans-serif);padding:0}.site-search-input::placeholder{color:#e8eaf066;opacity:1}.site-search-close-btn{display:inline-flex;align-items:center;justify-content:center;background:none;border:1px solid rgba(255,255,255,.15);cursor:pointer;color:#e8eaf080;border-radius:var(--dm-radius, 6px);padding:4px 8px;font-size:12px;font-family:var(--dm-font-mono, monospace);transition:color .15s,border-color .15s;flex-shrink:0}.site-search-close-btn:hover{color:#e8eaf0;border-color:#ffffff4d}.site-search-results{max-height:60vh;overflow-y:auto;padding:8px 0}.site-search-result{display:block;padding:10px 16px;text-decoration:none;color:inherit;border-left:3px solid transparent;transition:background .1s,border-color .1s;cursor:pointer}.site-search-result:hover,.site-search-result.active{background:#ffffff0f;border-left-color:var(--dm-primary, #5b8cff)}.site-search-result-title{font-weight:600;font-size:var(--dm-font-size-sm, 14px);margin-bottom:2px;color:#e8eaf0}.site-search-result-snippet{font-size:12px;color:#e8eaf08c;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.site-search-result-snippet mark{background:#5b8cff40;color:#e8eaf0;border-radius:2px;padding:0 1px}.site-search-loading,.site-search-empty{padding:24px 16px;text-align:center;color:#e8eaf073;font-size:var(--dm-font-size-sm, 14px)}.site-search-loading-dots{display:inline-flex;gap:4px}.site-search-loading-dots span{width:6px;height:6px;border-radius:50%;background:#e8eaf066;animation:ss-dot-pulse 1.2s ease-in-out infinite}.site-search-loading-dots span:nth-child(2){animation-delay:.2s}.site-search-loading-dots span:nth-child(3){animation-delay:.4s}@keyframes ss-dot-pulse{0%,80%,to{transform:scale(.6);opacity:.4}40%{transform:scale(1);opacity:1}}.site-search-results:not(:empty){border-top:1px solid rgba(255,255,255,.06)}.site-search-footer{padding:6px 16px;border-top:1px solid rgba(255,255,255,.06);display:flex;gap:12px;font-size:11px;color:#e8eaf059}.site-search-footer kbd{display:inline-block;padding:1px 4px;border-radius:3px;border:1px solid rgba(255,255,255,.15);font-family:var(--dm-font-mono, monospace);font-size:10px}@media(max-width:640px){.site-search-overlay{padding-top:5vh;align-items:flex-start}.site-search-panel{margin:0 8px;border-radius:var(--dm-radius, 6px)}.site-search-results{max-height:70vh}.site-search-shortcut-hint{display:none}}.site-search-floating-trigger{position:fixed;z-index:9999;width:52px;height:52px;border-radius:50%;border:1px solid var(--dm-border, rgba(0, 0, 0, .12));cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;background:var(--dm-surface, #fff);color:var(--dm-text, #111);box-shadow:0 4px 16px #00000024;transition:background .15s,color .15s,border-color .15s,transform .15s,box-shadow .15s;outline:none;white-space:nowrap}.site-search-floating-trigger:hover{background:var(--dm-primary, #5b8cff);color:#fff;border-color:var(--dm-primary, #5b8cff);box-shadow:0 6px 20px #00000038;transform:scale(1.05)}.site-search-floating-trigger:active{transform:scale(.97)}.site-search-floating-trigger svg,.site-search-floating-trigger [data-icon]{width:var(--ss-icon-glyph, 20px);height:var(--ss-icon-glyph, 20px);flex-shrink:0;pointer-events:none}.site-search-floating-trigger--pill{width:auto;height:44px;border-radius:999px;padding:0 18px 0 14px}.site-search-floating-label{font-size:.875rem;font-weight:500;letter-spacing:.01em;pointer-events:none}
|
package/public/js/search.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";var l=window.__CMS_SEARCH__||window.__SITE_SEARCH__||{},N=l.placeholder||"Search pages...",
|
|
1
|
+
(function(){"use strict";var l=window.__CMS_SEARCH__||window.__SITE_SEARCH__||{},N=l.placeholder||"Search pages...",x=l.debounceMs||300,D=l.displayMode||"navbar",C=l.triggerStyle||(l.iconOnly===!1?"icon-text":"icon"),h=C!=="icon-text",L=l.iconRadius!=null?l.iconRadius:26,b=l.iconSize!=null?l.iconSize:52,p=null,c=null,s=null,g=null,m=!1;function y(){var t=document.querySelector("#site-navbar, .navbar");if(t){var e=t.querySelector(".navbar-actions");if(!e){var r=t.querySelector(".navbar-container")||t;e=document.createElement("div"),e.className="navbar-actions",r.appendChild(e)}if(!e.querySelector(".site-search-trigger")){var a=/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent),i=a?"\u2318K":"Ctrl+K",n=document.createElement("button");n.className="navbar-action-link site-search-trigger",n.setAttribute("aria-label","Search"),n.setAttribute("type","button");var o=document.createElement("span");if(o.setAttribute("data-icon","search"),n.appendChild(o),!h){var d=document.createElement("span");d.className="site-search-label",d.textContent="Search",n.appendChild(d)}var u=document.createElement("span");u.className="site-search-shortcut-hint",u.textContent=i,n.appendChild(u),e.insertBefore(n,e.firstChild),n.addEventListener("click",f),window.Domma&&Domma.icons&&Domma.icons.scan&&Domma.icons.scan(n)}}}function T(){if(document.querySelector("#site-navbar .navbar-actions, .navbar .navbar-actions")){y();return}var t=new MutationObserver(function(){var e=document.querySelector("#site-navbar, .navbar");e&&(t.disconnect(),y())});t.observe(document.body,{childList:!0,subtree:!0}),setTimeout(function(){t.disconnect(),y()},5e3)}function k(){var t=document.createElement("div");t.className="site-search-overlay",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Site search");var e=document.createElement("div");e.className="site-search-panel",e.setAttribute("role","search");var r=document.createElement("div");r.className="site-search-header";var a=document.createElement("span");a.setAttribute("data-icon","search"),r.appendChild(a),c=document.createElement("input"),c.className="site-search-input",c.type="search",c.setAttribute("autocomplete","off"),c.setAttribute("autocorrect","off"),c.setAttribute("spellcheck","false"),c.setAttribute("aria-label","Search"),c.placeholder=N,r.appendChild(c);var i=document.createElement("button");i.className="site-search-close-btn",i.setAttribute("type","button"),i.setAttribute("aria-label","Close search"),i.textContent="Esc",r.appendChild(i),e.appendChild(r),s=document.createElement("div"),s.className="site-search-results",s.setAttribute("role","listbox"),s.setAttribute("aria-live","polite"),e.appendChild(s);var n=document.createElement("div");return n.className="site-search-footer",n.innerHTML="<span><kbd>\u2191</kbd><kbd>\u2193</kbd> navigate</span><span><kbd>\u21B5</kbd> open</span><span><kbd>Esc</kbd> close</span>",e.appendChild(n),t.appendChild(e),t.addEventListener("click",function(o){o.target===t&&v()}),i.addEventListener("click",v),c.addEventListener("input",function(){clearTimeout(g);var o=c.value.trim();if(!o){E();return}g=setTimeout(function(){M(o)},x)}),c.addEventListener("keydown",q),window.Domma&&Domma.icons&&Domma.icons.scan&&Domma.icons.scan(r),t}function f(){m||(m=!0,p=k(),document.body.appendChild(p),document.body.style.overflow="hidden",setTimeout(function(){c&&c.focus()},30))}function v(){m&&(m=!1,clearTimeout(g),p&&p.parentNode&&p.parentNode.removeChild(p),p=null,c=null,s=null,document.body.style.overflow="")}function M(t){s&&(R(),fetch("/api/search?q="+encodeURIComponent(t)).then(function(e){return e.json()}).then(function(e){_(e.results||[],t)}).catch(function(){E();var e=document.createElement("div");e.className="site-search-empty",e.textContent="Search unavailable. Please try again.",s.appendChild(e)}))}function R(){s&&(s.innerHTML='<div class="site-search-loading"><div class="site-search-loading-dots"><span></span><span></span><span></span></div></div>')}function E(){s&&(s.innerHTML="")}function _(t,e){if(s){if(s.innerHTML="",!t.length){var r=document.createElement("div");r.className="site-search-empty",r.textContent='No results found for "'+e+'"',s.appendChild(r);return}for(var a=document.createDocumentFragment(),i=0;i<t.length;i++){var n=t[i],o=document.createElement("a");o.className="site-search-result",o.href=n.url||"/",o.setAttribute("role","option"),o.setAttribute("tabindex","-1"),o.setAttribute("data-index",String(i));var d=document.createElement("div");if(d.className="site-search-result-title",S(d,n.title||"Untitled",e),o.appendChild(d),n.snippet){var u=document.createElement("div");u.className="site-search-result-snippet",S(u,n.snippet,e),o.appendChild(u)}o.addEventListener("click",v),a.appendChild(o)}s.appendChild(a)}}function S(t,e,r){if(!r){t.textContent=e;return}var a=r.trim().split(/\s+/).filter(Boolean);if(!a.length){t.textContent=e;return}var i;try{i=new RegExp("("+a.map(function(u){return u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}).join("|")+")","gi")}catch{t.textContent=e;return}for(var n=e.split(i),o=0;o<n.length;o++){if(i.test(n[o])){var d=document.createElement("mark");d.textContent=n[o],t.appendChild(d)}else t.appendChild(document.createTextNode(n[o]));i.lastIndex=0}}function q(t){if(t.key==="Escape"){t.preventDefault(),v();return}if(s){var e=s.querySelectorAll(".site-search-result");if(e.length){for(var r=s.querySelector(".site-search-result.active"),a=-1,i=0;i<e.length;i++)if(e[i]===r){a=i;break}if(t.key==="ArrowDown")t.preventDefault(),A(e,a<e.length-1?a+1:0);else if(t.key==="ArrowUp")t.preventDefault(),A(e,a>0?a-1:e.length-1);else if(t.key==="Enter"&&r){t.preventDefault();var n=r.getAttribute("href");v(),window.location.href=n}}}}function A(t,e){for(var r=0;r<t.length;r++)t[r].classList.toggle("active",r===e);t[e]&&t[e].scrollIntoView({block:"nearest"})}document.addEventListener("keydown",function(t){if((t.metaKey||t.ctrlKey)&&t.key.toLowerCase()==="k"){var e=document.activeElement&&document.activeElement.tagName;if((e==="INPUT"||e==="TEXTAREA"||e==="SELECT")&&!m)return;t.preventDefault(),m?v():f()}});function H(t,e,r,a){var i=e==="left-center"||e==="bottom-left"||e==="top-left",n=e==="bottom-left"||e==="bottom-right",o=e==="top-left"||e==="top-right";Object.assign(t.style,{right:i?"auto":r+"px",left:i?r+"px":"auto",top:o?a+"px":n?"auto":"50vh",bottom:n?a+"px":"auto",transform:o||n?"none":"translateY(-50%)"})}function O(){if(!document.querySelector(".site-search-floating-trigger")){var t=l.position||"bottom-right",e=l.offsetX!=null?l.offsetX:32,r=l.offsetY!=null?l.offsetY:32,a=document.createElement("button");a.className="site-search-floating-trigger"+(h?"":" site-search-floating-trigger--pill"),a.setAttribute("type","button"),a.setAttribute("aria-label","Search");var i=document.createElement("span");if(i.setAttribute("data-icon","search"),a.appendChild(i),h)a.style.borderRadius=L+"px",a.style.width=b+"px",a.style.height=b+"px",a.style.setProperty("--ss-icon-glyph",Math.round(b*20/52)+"px");else{var n=document.createElement("span");n.className="site-search-floating-label",n.textContent="Search",a.appendChild(n)}H(a,t,e,r),document.body.appendChild(a),a.addEventListener("click",f),window.Domma&&Domma.icons&&Domma.icons.scan&&Domma.icons.scan(a)}}function w(){C!=="hidden"&&(D==="floating"?O():T())}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",w):w(),window.DommaSiteSearch={open:f,close:v,isAvailable:()=>!0}})();
|
|
@@ -33,6 +33,7 @@ export const SEARCH_DEFAULTS = Object.freeze({
|
|
|
33
33
|
position: 'right-center',
|
|
34
34
|
offsetX: 32,
|
|
35
35
|
offsetY: 32,
|
|
36
|
+
triggerStyle: 'icon',
|
|
36
37
|
iconOnly: true,
|
|
37
38
|
iconSize: 52,
|
|
38
39
|
iconRadius: 26
|
|
@@ -101,7 +102,7 @@ export function normaliseSearchSettings(raw = {}) {
|
|
|
101
102
|
return {
|
|
102
103
|
enabled: raw.enabled !== false,
|
|
103
104
|
placeholder,
|
|
104
|
-
keyboardShortcut:
|
|
105
|
+
keyboardShortcut: true,
|
|
105
106
|
maxResults: num(raw.maxResults, SEARCH_DEFAULTS.maxResults, 1, 50),
|
|
106
107
|
minQueryLength: num(raw.minQueryLength, SEARCH_DEFAULTS.minQueryLength, 1, 5),
|
|
107
108
|
debounceMs: num(raw.debounceMs, SEARCH_DEFAULTS.debounceMs, 100, 1000),
|
|
@@ -109,7 +110,10 @@ export function normaliseSearchSettings(raw = {}) {
|
|
|
109
110
|
position: POSITIONS.has(raw.position) ? raw.position : SEARCH_DEFAULTS.position,
|
|
110
111
|
offsetX: num(raw.offsetX, SEARCH_DEFAULTS.offsetX, 0, 500),
|
|
111
112
|
offsetY: num(raw.offsetY, SEARCH_DEFAULTS.offsetY, 0, 500),
|
|
112
|
-
|
|
113
|
+
triggerStyle: ['icon-text', 'icon', 'hidden'].includes(raw.triggerStyle)
|
|
114
|
+
? raw.triggerStyle : (raw.iconOnly === false ? 'icon-text' : 'icon'),
|
|
115
|
+
iconOnly: raw.triggerStyle === 'icon-text' ? false
|
|
116
|
+
: ['icon', 'hidden'].includes(raw.triggerStyle) ? true : raw.iconOnly !== false,
|
|
113
117
|
iconSize,
|
|
114
118
|
iconRadius: Math.min(maxRadius, num(raw.iconRadius, SEARCH_DEFAULTS.iconRadius, 0, maxRadius))
|
|
115
119
|
};
|
|
@@ -572,7 +576,7 @@ export function searchBadge(settings = SEARCH_DEFAULTS, pages = [], exclusions =
|
|
|
572
576
|
const s = normaliseSearchSettings(settings);
|
|
573
577
|
const c = searchCoverage(pages, exclusions);
|
|
574
578
|
const pl = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
575
|
-
const trigger = s.displayMode === 'floating'
|
|
579
|
+
const trigger = s.triggerStyle === 'hidden' ? 'Hidden (keyboard shortcut available)' : s.displayMode === 'floating'
|
|
576
580
|
? `Floating button, ${s.position.replace('-', ' ')}`
|
|
577
581
|
: 'Icon in the navigation bar';
|
|
578
582
|
return {
|