@gallerist/plugin-shortcuts 0.4.0 → 0.4.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/README.md +5 -3
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,11 +34,13 @@ mount(viewer, { preset: 'reviewer' })
|
|
|
34
34
|
|
|
35
35
|
Nothing joins the toolbar (it is crowded enough). The list opens:
|
|
36
36
|
|
|
37
|
-
- on **`?`** while the viewer has focus
|
|
37
|
+
- on **`?`** while the viewer has focus, from its first frame (its opening fade included; not while
|
|
38
|
+
it closes, not while typing in a field in it, not with Ctrl, ⌘ or Alt);
|
|
38
39
|
- from the [View menu](../plugin-view/README.md)'s last row, when both plugins are registered;
|
|
39
40
|
- from the host: `shortcuts()` returns the plugin with `open(keys?)` and `close()`, for a help button
|
|
40
|
-
of your own (`open()` returns `false` when no viewer it is registered on is open). The
|
|
41
|
-
(named `shortcuts`, `ShortcutsInstance`) has the same `open()` / `close()`, `isOpen`, and
|
|
41
|
+
of your own (`open()` returns `false` when no viewer it is registered on is open or opening). The
|
|
42
|
+
instance (named `shortcuts`, `ShortcutsInstance`) has the same `open()` / `close()`, `isOpen`, and
|
|
43
|
+
`label`.
|
|
42
44
|
|
|
43
45
|
`open()` with no argument shows the gestures on a coarse pointer (a phone, a tablet) and the keys
|
|
44
46
|
otherwise; `open(true)` the keys, `open(false)` the gestures. `?` always shows the keys (a keyboard
|
package/dist/index.cjs
CHANGED
|
@@ -183,7 +183,7 @@ function shortcuts(opts = {}) {
|
|
|
183
183
|
};
|
|
184
184
|
const open = (keys = !coarse()) => {
|
|
185
185
|
const r = root();
|
|
186
|
-
if (!r || !anchor?.isConnected || viewer.getState().phase
|
|
186
|
+
if (!r || !anchor?.isConnected || /^clos/.test(viewer.getState().phase)) return false;
|
|
187
187
|
close();
|
|
188
188
|
back = r.getRootNode().activeElement;
|
|
189
189
|
const s = el("div", "gallerist-shortcuts-scrim");
|
|
@@ -251,7 +251,7 @@ function shortcuts(opts = {}) {
|
|
|
251
251
|
init() {
|
|
252
252
|
live.push(instance);
|
|
253
253
|
unsub = viewer.subscribe((st) => {
|
|
254
|
-
if (st.phase
|
|
254
|
+
if (/^clos/.test(st.phase)) close();
|
|
255
255
|
});
|
|
256
256
|
},
|
|
257
257
|
destroy() {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["getInternals"],"mappings":";;;;;AAiFO,IAAM,yBAAA,GAA8C;AAAA,EACzD,KAAA,EAAO,oBAAA;AAAA,EACP,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,gBAAA;AAAA,EACT,KAAA,EAAO,OAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,MAAA,EAAQ,QAAA;AAAA,EACR,QAAA,EAAU,iBAAA;AAAA,EACV,aAAA,EAAe,uBAAA;AAAA,EACf,YAAA,EAAc,8BAAA;AAAA,EACd,QAAA,EAAU,mBAAA;AAAA,EACV,SAAA,EAAW,cAAA;AAAA,EACX,cAAA,EAAgB,oBAAA;AAAA,EAChB,IAAA,EAAM,mBAAA;AAAA,EACN,MAAA,EAAQ,SAAA;AAAA,EACR,OAAA,EAAS,UAAA;AAAA,EACT,GAAA,EAAK,eAAA;AAAA,EACL,GAAA,EAAK,mBAAA;AAAA,EACL,UAAA,EAAY,YAAA;AAAA,EACZ,IAAA,EAAM,YAAA;AAAA,EACN,KAAA,EAAO,WAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,MAAA,EAAQ,eAAA;AAAA,EACR,QAAA,EAAU,UAAA;AAAA,EACV,IAAA,EAAM,WA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AA,EACT,CAAA;AACA,EAAA,OAAO,MAAA,CAAO,OAAO,MAAA,EAAQ;AAAA,IAC3B,IAAA,EAAM,CAAC,IAAA,KAAmB,IAAA,CAAK,WAAA,CAAY,CAAC,IAAA,EAAM,CAAA,KAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,CAAK,IAAI,GAAG,KAAK,CAAA;AAAA,IACnF,OAAO,MAAM;AACX,MAAA,KAAA,MAAW,CAAA,IAAK,IAAA,EAAM,CAAA,CAAE,KAAA,EAAM;AAAA,IAChC;AAAA,GACD,CAAA;AACH","file":"index.cjs","sourcesContent":["// @gallerist/plugin-shortcuts — the viewer's keyboard shortcuts in a modal dialog, on `?`.\n//\n// The list is built each time it opens, from what the viewer does then: the renderer's own keys as\n// the layout has them (a row rail walks every item with ←/→ and has no ↑/↓; a side rail turns the\n// axes; right to left mirrors ←/→), the official plugins' keys while they are registered and hold\n// them (the aggregated keymap, so a key another plugin took isn't listed), and the host's entries.\n// Opened by a touch (the View menu's row, `open()`, on a coarse pointer) it lists the renderer's\n// gestures instead. `?` (with the viewer focused, not in a text field) opens the keys.\n//\n// The dialog sits in the viewer's root over a scrim that covers the viewer: `aria-modal`, the rest\n// of the root inert while it shows, Tab kept inside, focus back where it was on close. Keys pressed\n// in it never reach the viewer (a window listener in the capture phase takes them first): Escape and\n// `?` close it, and nothing else acts. The root is found from a hidden node in the toolbar region.\n\nimport type { Item, Plugin, PluginInstance, ViewerApi } from '@gallerist/core'\nimport { getInternals } from '@gallerist/core/internal'\n\n/** A host's own shortcut, listed with the built-in ones. */\nexport interface ShortcutEntry {\n /** what it does */\n label: string\n /** the keys, each drawn as a key cap (`['N']`, `['Shift', 'N']`); without them it's listed only\n * with the gestures */\n keys?: readonly string[]\n /** the gesture that does it on a touch screen (`'Long press'`); without one it's listed only with\n * the keys */\n gesture?: string\n /** the section it joins: a built-in one by its title (`strings.move`, `zoom`, `viewer`) or a new\n * one after them. Default: the Viewer section. */\n section?: string\n}\n\nexport interface ShortcutsStrings {\n /** the dialog's title with the keys, and the View menu's row */\n title: string\n /** the dialog's title with the gestures (and the View menu's row on a touch screen) */\n gestures: string\n /** the close button's text, `{key}` where the Esc key cap goes (\"{key} to close\") */\n toClose: string\n close: string\n /** section titles */\n move: string\n zoom: string\n viewer: string\n /** moving */\n prevNext: string\n prevNextGroup: string\n prevNextItem: string\n nextItem: string\n firstLast: string\n firstLastGroup: string\n jump: string\n /** zooming */\n zoomIn: string\n zoomOut: string\n fit: string\n pan: string\n /** the viewer, and the plugins' keys */\n fullscreen: string\n rail: string\n items: string\n grid: string\n pins: string\n addPin: string\n download: string\n help: string\n exit: string\n /** gestures */\n swipe: string\n swipeUp: string\n swipeDown: string\n pinch: string\n drag: string\n /** under the gestures */\n keysNote: string\n /** key names on their caps */\n home: string\n end: string\n esc: string\n}\n\nexport const DEFAULT_SHORTCUTS_STRINGS: ShortcutsStrings = {\n title: 'Keyboard shortcuts',\n gestures: 'Gestures',\n toClose: '{key} to close',\n close: 'Close',\n move: 'Move',\n zoom: 'Zoom',\n viewer: 'Viewer',\n prevNext: 'Previous / next',\n prevNextGroup: 'Previous / next group',\n prevNextItem: 'Previous / next in the group',\n nextItem: 'Next in the group',\n firstLast: 'First / last',\n firstLastGroup: 'First / last group',\n jump: 'Item in the group',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n fit: 'Fit to screen',\n pan: 'Move while zoomed',\n fullscreen: 'Fullscreen',\n rail: 'Thumbnails',\n items: 'Item list',\n grid: 'Grid',\n pins: 'Pins',\n addPin: 'Add a comment',\n download: 'Download',\n help: 'This list',\n exit: 'Close',\n swipe: 'Swipe left or right',\n swipeUp: 'Swipe up',\n swipeDown: 'Swipe down',\n pinch: 'Pinch, or double-tap',\n drag: 'Drag',\n keysNote: 'With a keyboard, ? lists its shortcuts.',\n home: 'Home',\n end: 'End',\n esc: 'Esc',\n}\n\nexport interface ShortcutsOptions {\n /** the host's own shortcuts, listed after the built-in ones */\n shortcuts?: readonly ShortcutEntry[]\n /** UI text overrides, for translation; merged over English. */\n strings?: Partial<ShortcutsStrings>\n}\n\n/** The plugin's instance on a viewer (named `shortcuts`); the View menu finds it by that name. */\nexport interface ShortcutsInstance extends PluginInstance {\n /** what `open()` shows now: the title of the keys, or of the gestures on a coarse pointer */\n readonly label: string\n readonly isOpen: boolean\n /** Opens the list on the open viewer: the keys (`true`), the gestures (`false`), or by the\n * pointer (default). False when there is no open viewer to show it in. */\n open(keys?: boolean): boolean\n close(): void\n}\n\n/** `shortcuts()`: a plugin, with `open()` / `close()` for the host (a help button of its own). */\nexport interface ShortcutsPlugin extends Plugin {\n /** Opens the list on the viewer this plugin was last registered on that is open. */\n open(keys?: boolean): boolean\n close(): void\n}\n\ntype Row = [label: string, keys: readonly string[] | string]\n\nconst KEYBOARD =\n '<svg class=\"gallerist-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\"/><path d=\"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10\"/></svg>'\nconst X =\n '<svg class=\"gallerist-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>'\nconst TABBABLE = 'button:not([disabled]), [href], [tabindex]:not([tabindex=\"-1\"])'\n\nlet lists = 0 // ids, for aria-labelledby\n\nconst el = <K extends keyof HTMLElementTagNameMap>(\n tag: K,\n className = '',\n text = '',\n): HTMLElementTagNameMap[K] => {\n const node = document.createElement(tag)\n if (className) node.className = className\n if (text) node.textContent = text\n return node\n}\nconst cap = (k: string) => (k.length === 1 ? k.toUpperCase() : k)\n// `?` typed with AltGr (Ctrl + Alt on Windows) is still `?`; another chord is the browser's\nconst chord = (e: KeyboardEvent) =>\n (e.ctrlKey || e.metaKey || e.altKey) && !e.getModifierState?.('AltGraph')\n\nexport function shortcuts(opts: ShortcutsOptions = {}): ShortcutsPlugin {\n const t: ShortcutsStrings = { ...DEFAULT_SHORTCUTS_STRINGS, ...opts.strings }\n const live: ShortcutsInstance[] = [] // registered instances, the latest last\n\n const plugin = (viewer: ViewerApi): ShortcutsInstance => {\n let anchor: HTMLElement | null = null\n let scrim: HTMLElement | null = null\n let back: HTMLElement | null = null // focus before it opened\n let inerted: Element[] = []\n let unsub: (() => void) | null = null\n const id = `gallerist-shortcuts-${++lists}`\n const root = () => anchor?.closest<HTMLElement>('.gallerist') ?? null\n const coarse = () => !!window.matchMedia?.('(pointer: coarse)').matches\n\n // What the viewer does now, read from its root and its plugins.\n const rows = (keys: boolean): Array<[string, Row[]]> => {\n const r = root() as HTMLElement\n const plugins = getInternals(viewer).getPlugins()\n const map: Record<string, unknown> = {}\n for (const p of plugins) Object.assign(map, p.keymap)\n const named = (name: string) => plugins.find((p) => p.name === name)\n // the key `k` of the plugin `name`, while it holds it (none: its first key)\n const held = (name: string, k?: string) => {\n const own = named(name)?.keymap ?? {}\n const key = k ?? Object.keys(own)[0]\n return key && own[key] && map[key] === own[key] ? key : undefined\n }\n const linear = r.hasAttribute('data-gallerist-linear')\n const vertical = r.getAttribute('data-gallerist-axis') === 'vertical'\n const across = r.getAttribute('data-gallerist-dir') === 'rtl' ? ['→', '←'] : ['←', '→']\n const along = ['↑', '↓']\n const grouped = !linear && viewer.getCollection().groups.some((g) => g.items.length > 1)\n const overlay = r.getAttribute('data-gallerist-mode') === 'overlay'\n const rail = (named('thumbnails') as { display?: string } | undefined)?.display\n\n // zooming, while an item can zoom: plugin-zoom's `zoomable`, else an image\n const can =\n (named('zoom') as { zoomable?: (item: Item) => boolean } | undefined)?.zoomable ??\n ((i: Item) => i.type === 'image')\n const zoom = viewer.getCollection().groups.some((g) => g.items.some((i) => can(i)))\n let sections: Array<[string, Row[]]>\n if (keys) {\n const move: Row[] = grouped\n ? [\n [t.prevNextGroup, vertical ? along : across],\n [t.prevNextItem, vertical ? across : along],\n [t.firstLastGroup, [t.home, t.end]],\n [t.jump, ['1–9']],\n ]\n : [\n [t.prevNext, vertical ? along : across],\n [t.firstLast, [t.home, t.end]],\n ]\n const fs = (document as { webkitFullscreenEnabled?: boolean }).webkitFullscreenEnabled\n const tools: Array<[string, string | undefined]> = [\n [t.fullscreen, (document.fullscreenEnabled ?? fs) ? held('fullscreen', 'f') : undefined],\n [t.rail, rail ? 't' : undefined],\n [t.items, held('thumbnails', 'e')],\n [t.grid, held('grid')],\n [t.pins, held('pins', 'p')],\n [t.addPin, held('pins', 'c')],\n [t.download, held('download')],\n [t.help, '?'],\n [t.exit, overlay ? t.esc : undefined],\n ]\n sections = [\n [t.move, move],\n [\n t.zoom,\n zoom\n ? [\n [t.zoomIn, ['+']],\n [t.zoomOut, ['−']],\n [t.fit, ['0']],\n ]\n : [],\n ],\n [t.viewer, tools.flatMap(([label, k]) => (k ? [[label, [cap(k)]] as Row] : []))],\n ]\n } else {\n sections = [\n [\n '',\n [\n [grouped ? t.prevNextGroup : t.prevNext, t.swipe],\n ...(grouped ? [[t.nextItem, t.swipeUp] as Row] : []),\n ...(zoom ? [[t.zoom, t.pinch] as Row, [t.pan, t.drag] as Row] : []),\n ...(overlay ? [[t.exit, t.swipeDown] as Row] : []),\n ],\n ],\n ]\n }\n for (const x of opts.shortcuts ?? []) {\n const what = keys ? x.keys : x.gesture\n if (!what?.length) continue\n const title = keys ? (x.section ?? t.viewer) : ''\n let section = sections.find(([s]) => s === title)\n if (!section) {\n section = [title, []]\n sections.push(section)\n }\n section[1].push([x.label, what])\n }\n return sections.filter(([, list]) => list.length)\n }\n\n const close = (refocus = false) => {\n if (!scrim) return\n scrim.remove()\n scrim = null\n for (const node of inerted) node.removeAttribute('inert')\n inerted = []\n window.removeEventListener('keydown', onKey, true)\n document.removeEventListener('pointerdown', onPress, true)\n if (refocus) (back?.isConnected ? back : root())?.focus({ preventScroll: true })\n back = null\n }\n\n // Every key pressed in the viewer while the list shows stops here: the viewer's keys, the zoom\n // tool's and the page's never see it. Escape and ? close; Tab stays in the dialog.\n const onKey = (e: KeyboardEvent) => {\n const r = root()\n if (!scrim?.isConnected) return close() // the viewer went away with it open\n if (!r || !e.composedPath().includes(r)) return\n e.stopPropagation()\n if (e.key === 'Escape' || (e.key === '?' && !chord(e))) {\n e.preventDefault()\n close(true)\n } else if (e.key === 'Tab') {\n const box = scrim.firstElementChild as HTMLElement\n const list = [...box.querySelectorAll<HTMLElement>(TABBABLE)]\n const active = (r.getRootNode() as Document | ShadowRoot).activeElement\n const first = list[0]\n const last = list[list.length - 1]\n const to = e.shiftKey\n ? active === first || active === box\n ? last\n : null\n : active === last\n ? first\n : null\n if (!first || to) {\n e.preventDefault()\n to?.focus()\n }\n }\n }\n // A press on the page outside the viewer closes it, leaving focus where the press puts it (a\n // press on the scrim closes it too, with focus back where it was: see open()).\n // (A viewer gone with it open is outside too: its listeners go with the next press or key.)\n const onPress = (e: Event) => {\n if (!e.composedPath().includes(root() as EventTarget)) close()\n }\n\n const open = (keys = !coarse()): boolean => {\n const r = root()\n if (!r || !anchor?.isConnected || viewer.getState().phase !== 'open') return false\n close()\n back = (r.getRootNode() as Document | ShadowRoot).activeElement as HTMLElement | null\n const s = el('div', 'gallerist-shortcuts-scrim')\n const box = el('div', 'gallerist-shortcuts')\n box.setAttribute('role', 'dialog')\n box.setAttribute('aria-modal', 'true')\n box.setAttribute('aria-labelledby', id)\n box.tabIndex = -1\n box.setAttribute('data-gallerist-list', keys ? 'keys' : 'gestures')\n const head = el('div', 'gallerist-shortcuts-head')\n if (keys) head.innerHTML = KEYBOARD\n const title = head.appendChild(el('h2', '', keys ? t.title : t.gestures))\n title.id = id\n const x = head.appendChild(el('button', 'gallerist-shortcuts-close'))\n x.type = 'button'\n if (keys) {\n const [before, after] = t.toClose.split('{key}')\n x.append(before as string, el('kbd', '', t.esc), after ?? '')\n } else {\n x.innerHTML = X\n x.setAttribute('aria-label', t.close)\n }\n x.addEventListener('click', () => close(true))\n // the list scrolls when the viewer is short: a stop for the keys, so they can scroll it (no\n // role or name of its own: the dialog's title names it already, once)\n const body = el('div', 'gallerist-shortcuts-body')\n body.tabIndex = 0\n for (const [name, list] of rows(keys)) {\n const section = body.appendChild(el('section'))\n if (name) section.appendChild(el('h3', '', name))\n const dl = section.appendChild(el('dl'))\n for (const [label, what] of list) {\n const row = dl.appendChild(el('div', 'gallerist-shortcuts-row'))\n row.appendChild(el('dt', '', label))\n const dd = row.appendChild(el('dd'))\n if (typeof what === 'string') dd.textContent = what\n else for (const k of what) dd.appendChild(el('kbd', '', k))\n }\n }\n box.append(head, body)\n if (!keys) box.appendChild(el('p', 'gallerist-shortcuts-note', t.keysNote))\n s.appendChild(box)\n // the scrim takes no focus (the viewer's root would, under a press), and a click on it closes\n s.addEventListener('mousedown', (e) => e.target === s && e.preventDefault())\n s.addEventListener('click', (e) => e.target === s && close(true))\n // the rest of the viewer is inert while the dialog shows (what was inert already stays so)\n for (const node of r.children)\n if (!node.hasAttribute('inert')) {\n node.setAttribute('inert', '')\n inerted.push(node)\n }\n r.appendChild(s)\n scrim = s\n window.addEventListener('keydown', onKey, true)\n document.addEventListener('pointerdown', onPress, true)\n box.focus({ preventScroll: true })\n return true\n }\n\n const instance: ShortcutsInstance = {\n name: 'shortcuts',\n get label() {\n return coarse() ? t.gestures : t.title\n },\n get isOpen() {\n return !!scrim\n },\n open,\n close: () => close(true),\n init() {\n live.push(instance)\n unsub = viewer.subscribe((st) => {\n if (st.phase === 'closing' || st.phase === 'closed') close()\n })\n },\n destroy() {\n close()\n unsub?.()\n unsub = anchor = null\n const at = live.indexOf(instance)\n if (at >= 0) live.splice(at, 1)\n },\n keymap: { '?': () => open(true) },\n // a hidden node, to find the viewer's root by (marked off: a bar shows not for it)\n regions: {\n toolbar: () => {\n anchor = el('span')\n anchor.hidden = true\n anchor.setAttribute('data-gallerist-off', '')\n return anchor\n },\n },\n }\n return instance\n }\n return Object.assign(plugin, {\n open: (keys?: boolean) => live.reduceRight((done, i) => done || i.open(keys), false),\n close: () => {\n for (const i of live) i.close()\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["getInternals"],"mappings":";;;;;AAiFO,IAAM,yBAAA,GAA8C;AAAA,EACzD,KAAA,EAAO,oBAAA;AAAA,EACP,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,gBAAA;AAAA,EACT,KAAA,EAAO,OAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,MAAA,EAAQ,QAAA;AAAA,EACR,QAAA,EAAU,iBAAA;AAAA,EACV,aAAA,EAAe,uBAAA;AAAA,EACf,YAAA,EAAc,8BAAA;AAAA,EACd,QAAA,EAAU,mBAAA;AAAA,EACV,SAAA,EAAW,cAAA;AAAA,EACX,cAAA,EAAgB,oBAAA;AAAA,EAChB,IAAA,EAAM,mBAAA;AAAA,EACN,MAAA,EAAQ,SAAA;AAAA,EACR,OAAA,EAAS,UAAA;AAAA,EACT,GAAA,EAAK,eAAA;AAAA,EACL,GAAA,EAAK,mBAAA;AAAA,EACL,UAAA,EAAY,YAAA;AAAA,EACZ,IAAA,EAAM,YAAA;AAAA,EACN,KAAA,EAAO,WAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,MAAA,EAAQ,eAAA;AAAA,EACR,QAAA,EAAU,UAAA;AAAA,EACV,IAAA,EAAM,WAAA;AAAA,EACN,IAAA,EAAM,OAAA;AAAA,EACN,KAAA,EAAO,qBAAA;AAAA,EACP,OAAA,EAAS,UAAA;AAAA,EACT,SAAA,EAAW,YAAA;AAAA,EACX,KAAA,EAAO,sBAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,QAAA,EAAU,yCAAA;A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IAAI,GAAG,KAAK,CAAA;AAAA,IACnF,OAAO,MAAM;AACX,MAAA,KAAA,MAAW,CAAA,IAAK,IAAA,EAAM,CAAA,CAAE,KAAA,EAAM;AAAA,IAChC;AAAA,GACD,CAAA;AACH","file":"index.cjs","sourcesContent":["// @gallerist/plugin-shortcuts — the viewer's keyboard shortcuts in a modal dialog, on `?`.\n//\n// The list is built each time it opens, from what the viewer does then: the renderer's own keys as\n// the layout has them (a row rail walks every item with ←/→ and has no ↑/↓; a side rail turns the\n// axes; right to left mirrors ←/→), the official plugins' keys while they are registered and hold\n// them (the aggregated keymap, so a key another plugin took isn't listed), and the host's entries.\n// Opened by a touch (the View menu's row, `open()`, on a coarse pointer) it lists the renderer's\n// gestures instead. `?` (with the viewer focused, not in a text field) opens the keys.\n//\n// The dialog sits in the viewer's root over a scrim that covers the viewer: `aria-modal`, the rest\n// of the root inert while it shows, Tab kept inside, focus back where it was on close. Keys pressed\n// in it never reach the viewer (a window listener in the capture phase takes them first): Escape and\n// `?` close it, and nothing else acts. The root is found from a hidden node in the toolbar region.\n\nimport type { Item, Plugin, PluginInstance, ViewerApi } from '@gallerist/core'\nimport { getInternals } from '@gallerist/core/internal'\n\n/** A host's own shortcut, listed with the built-in ones. */\nexport interface ShortcutEntry {\n /** what it does */\n label: string\n /** the keys, each drawn as a key cap (`['N']`, `['Shift', 'N']`); without them it's listed only\n * with the gestures */\n keys?: readonly string[]\n /** the gesture that does it on a touch screen (`'Long press'`); without one it's listed only with\n * the keys */\n gesture?: string\n /** the section it joins: a built-in one by its title (`strings.move`, `zoom`, `viewer`) or a new\n * one after them. Default: the Viewer section. */\n section?: string\n}\n\nexport interface ShortcutsStrings {\n /** the dialog's title with the keys, and the View menu's row */\n title: string\n /** the dialog's title with the gestures (and the View menu's row on a touch screen) */\n gestures: string\n /** the close button's text, `{key}` where the Esc key cap goes (\"{key} to close\") */\n toClose: string\n close: string\n /** section titles */\n move: string\n zoom: string\n viewer: string\n /** moving */\n prevNext: string\n prevNextGroup: string\n prevNextItem: string\n nextItem: string\n firstLast: string\n firstLastGroup: string\n jump: string\n /** zooming */\n zoomIn: string\n zoomOut: string\n fit: string\n pan: string\n /** the viewer, and the plugins' keys */\n fullscreen: string\n rail: string\n items: string\n grid: string\n pins: string\n addPin: string\n download: string\n help: string\n exit: string\n /** gestures */\n swipe: string\n swipeUp: string\n swipeDown: string\n pinch: string\n drag: string\n /** under the gestures */\n keysNote: string\n /** key names on their caps */\n home: string\n end: string\n esc: string\n}\n\nexport const DEFAULT_SHORTCUTS_STRINGS: ShortcutsStrings = {\n title: 'Keyboard shortcuts',\n gestures: 'Gestures',\n toClose: '{key} to close',\n close: 'Close',\n move: 'Move',\n zoom: 'Zoom',\n viewer: 'Viewer',\n prevNext: 'Previous / next',\n prevNextGroup: 'Previous / next group',\n prevNextItem: 'Previous / next in the group',\n nextItem: 'Next in the group',\n firstLast: 'First / last',\n firstLastGroup: 'First / last group',\n jump: 'Item in the group',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n fit: 'Fit to screen',\n pan: 'Move while zoomed',\n fullscreen: 'Fullscreen',\n rail: 'Thumbnails',\n items: 'Item list',\n grid: 'Grid',\n pins: 'Pins',\n addPin: 'Add a comment',\n download: 'Download',\n help: 'This list',\n exit: 'Close',\n swipe: 'Swipe left or right',\n swipeUp: 'Swipe up',\n swipeDown: 'Swipe down',\n pinch: 'Pinch, or double-tap',\n drag: 'Drag',\n keysNote: 'With a keyboard, ? lists its shortcuts.',\n home: 'Home',\n end: 'End',\n esc: 'Esc',\n}\n\nexport interface ShortcutsOptions {\n /** the host's own shortcuts, listed after the built-in ones */\n shortcuts?: readonly ShortcutEntry[]\n /** UI text overrides, for translation; merged over English. */\n strings?: Partial<ShortcutsStrings>\n}\n\n/** The plugin's instance on a viewer (named `shortcuts`); the View menu finds it by that name. */\nexport interface ShortcutsInstance extends PluginInstance {\n /** what `open()` shows now: the title of the keys, or of the gestures on a coarse pointer */\n readonly label: string\n readonly isOpen: boolean\n /** Opens the list on the open (or opening) viewer: the keys (`true`), the gestures (`false`), or\n * by the pointer (default). False when there is no such viewer to show it in (closing, closed). */\n open(keys?: boolean): boolean\n close(): void\n}\n\n/** `shortcuts()`: a plugin, with `open()` / `close()` for the host (a help button of its own). */\nexport interface ShortcutsPlugin extends Plugin {\n /** Opens the list on the viewer this plugin was last registered on that is open (or opening). */\n open(keys?: boolean): boolean\n close(): void\n}\n\ntype Row = [label: string, keys: readonly string[] | string]\n\nconst KEYBOARD =\n '<svg class=\"gallerist-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\"/><path d=\"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10\"/></svg>'\nconst X =\n '<svg class=\"gallerist-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>'\nconst TABBABLE = 'button:not([disabled]), [href], [tabindex]:not([tabindex=\"-1\"])'\n\nlet lists = 0 // ids, for aria-labelledby\n\nconst el = <K extends keyof HTMLElementTagNameMap>(\n tag: K,\n className = '',\n text = '',\n): HTMLElementTagNameMap[K] => {\n const node = document.createElement(tag)\n if (className) node.className = className\n if (text) node.textContent = text\n return node\n}\nconst cap = (k: string) => (k.length === 1 ? k.toUpperCase() : k)\n// `?` typed with AltGr (Ctrl + Alt on Windows) is still `?`; another chord is the browser's\nconst chord = (e: KeyboardEvent) =>\n (e.ctrlKey || e.metaKey || e.altKey) && !e.getModifierState?.('AltGraph')\n\nexport function shortcuts(opts: ShortcutsOptions = {}): ShortcutsPlugin {\n const t: ShortcutsStrings = { ...DEFAULT_SHORTCUTS_STRINGS, ...opts.strings }\n const live: ShortcutsInstance[] = [] // registered instances, the latest last\n\n const plugin = (viewer: ViewerApi): ShortcutsInstance => {\n let anchor: HTMLElement | null = null\n let scrim: HTMLElement | null = null\n let back: HTMLElement | null = null // focus before it opened\n let inerted: Element[] = []\n let unsub: (() => void) | null = null\n const id = `gallerist-shortcuts-${++lists}`\n const root = () => anchor?.closest<HTMLElement>('.gallerist') ?? null\n const coarse = () => !!window.matchMedia?.('(pointer: coarse)').matches\n\n // What the viewer does now, read from its root and its plugins.\n const rows = (keys: boolean): Array<[string, Row[]]> => {\n const r = root() as HTMLElement\n const plugins = getInternals(viewer).getPlugins()\n const map: Record<string, unknown> = {}\n for (const p of plugins) Object.assign(map, p.keymap)\n const named = (name: string) => plugins.find((p) => p.name === name)\n // the key `k` of the plugin `name`, while it holds it (none: its first key)\n const held = (name: string, k?: string) => {\n const own = named(name)?.keymap ?? {}\n const key = k ?? Object.keys(own)[0]\n return key && own[key] && map[key] === own[key] ? key : undefined\n }\n const linear = r.hasAttribute('data-gallerist-linear')\n const vertical = r.getAttribute('data-gallerist-axis') === 'vertical'\n const across = r.getAttribute('data-gallerist-dir') === 'rtl' ? ['→', '←'] : ['←', '→']\n const along = ['↑', '↓']\n const grouped = !linear && viewer.getCollection().groups.some((g) => g.items.length > 1)\n const overlay = r.getAttribute('data-gallerist-mode') === 'overlay'\n const rail = (named('thumbnails') as { display?: string } | undefined)?.display\n\n // zooming, while an item can zoom: plugin-zoom's `zoomable`, else an image\n const can =\n (named('zoom') as { zoomable?: (item: Item) => boolean } | undefined)?.zoomable ??\n ((i: Item) => i.type === 'image')\n const zoom = viewer.getCollection().groups.some((g) => g.items.some((i) => can(i)))\n let sections: Array<[string, Row[]]>\n if (keys) {\n const move: Row[] = grouped\n ? [\n [t.prevNextGroup, vertical ? along : across],\n [t.prevNextItem, vertical ? across : along],\n [t.firstLastGroup, [t.home, t.end]],\n [t.jump, ['1–9']],\n ]\n : [\n [t.prevNext, vertical ? along : across],\n [t.firstLast, [t.home, t.end]],\n ]\n const fs = (document as { webkitFullscreenEnabled?: boolean }).webkitFullscreenEnabled\n const tools: Array<[string, string | undefined]> = [\n [t.fullscreen, (document.fullscreenEnabled ?? fs) ? held('fullscreen', 'f') : undefined],\n [t.rail, rail ? 't' : undefined],\n [t.items, held('thumbnails', 'e')],\n [t.grid, held('grid')],\n [t.pins, held('pins', 'p')],\n [t.addPin, held('pins', 'c')],\n [t.download, held('download')],\n [t.help, '?'],\n [t.exit, overlay ? t.esc : undefined],\n ]\n sections = [\n [t.move, move],\n [\n t.zoom,\n zoom\n ? [\n [t.zoomIn, ['+']],\n [t.zoomOut, ['−']],\n [t.fit, ['0']],\n ]\n : [],\n ],\n [t.viewer, tools.flatMap(([label, k]) => (k ? [[label, [cap(k)]] as Row] : []))],\n ]\n } else {\n sections = [\n [\n '',\n [\n [grouped ? t.prevNextGroup : t.prevNext, t.swipe],\n ...(grouped ? [[t.nextItem, t.swipeUp] as Row] : []),\n ...(zoom ? [[t.zoom, t.pinch] as Row, [t.pan, t.drag] as Row] : []),\n ...(overlay ? [[t.exit, t.swipeDown] as Row] : []),\n ],\n ],\n ]\n }\n for (const x of opts.shortcuts ?? []) {\n const what = keys ? x.keys : x.gesture\n if (!what?.length) continue\n const title = keys ? (x.section ?? t.viewer) : ''\n let section = sections.find(([s]) => s === title)\n if (!section) {\n section = [title, []]\n sections.push(section)\n }\n section[1].push([x.label, what])\n }\n return sections.filter(([, list]) => list.length)\n }\n\n const close = (refocus = false) => {\n if (!scrim) return\n scrim.remove()\n scrim = null\n for (const node of inerted) node.removeAttribute('inert')\n inerted = []\n window.removeEventListener('keydown', onKey, true)\n document.removeEventListener('pointerdown', onPress, true)\n if (refocus) (back?.isConnected ? back : root())?.focus({ preventScroll: true })\n back = null\n }\n\n // Every key pressed in the viewer while the list shows stops here: the viewer's keys, the zoom\n // tool's and the page's never see it. Escape and ? close; Tab stays in the dialog.\n const onKey = (e: KeyboardEvent) => {\n const r = root()\n if (!scrim?.isConnected) return close() // the viewer went away with it open\n if (!r || !e.composedPath().includes(r)) return\n e.stopPropagation()\n if (e.key === 'Escape' || (e.key === '?' && !chord(e))) {\n e.preventDefault()\n close(true)\n } else if (e.key === 'Tab') {\n const box = scrim.firstElementChild as HTMLElement\n const list = [...box.querySelectorAll<HTMLElement>(TABBABLE)]\n const active = (r.getRootNode() as Document | ShadowRoot).activeElement\n const first = list[0]\n const last = list[list.length - 1]\n const to = e.shiftKey\n ? active === first || active === box\n ? last\n : null\n : active === last\n ? first\n : null\n if (!first || to) {\n e.preventDefault()\n to?.focus()\n }\n }\n }\n // A press on the page outside the viewer closes it, leaving focus where the press puts it (a\n // press on the scrim closes it too, with focus back where it was: see open()).\n // (A viewer gone with it open is outside too: its listeners go with the next press or key.)\n const onPress = (e: Event) => {\n if (!e.composedPath().includes(root() as EventTarget)) close()\n }\n\n const open = (keys = !coarse()): boolean => {\n const r = root()\n // on a viewer that is open or opening (its keys work from its first frame), not one going away\n if (!r || !anchor?.isConnected || /^clos/.test(viewer.getState().phase)) return false\n close()\n back = (r.getRootNode() as Document | ShadowRoot).activeElement as HTMLElement | null\n const s = el('div', 'gallerist-shortcuts-scrim')\n const box = el('div', 'gallerist-shortcuts')\n box.setAttribute('role', 'dialog')\n box.setAttribute('aria-modal', 'true')\n box.setAttribute('aria-labelledby', id)\n box.tabIndex = -1\n box.setAttribute('data-gallerist-list', keys ? 'keys' : 'gestures')\n const head = el('div', 'gallerist-shortcuts-head')\n if (keys) head.innerHTML = KEYBOARD\n const title = head.appendChild(el('h2', '', keys ? t.title : t.gestures))\n title.id = id\n const x = head.appendChild(el('button', 'gallerist-shortcuts-close'))\n x.type = 'button'\n if (keys) {\n const [before, after] = t.toClose.split('{key}')\n x.append(before as string, el('kbd', '', t.esc), after ?? '')\n } else {\n x.innerHTML = X\n x.setAttribute('aria-label', t.close)\n }\n x.addEventListener('click', () => close(true))\n // the list scrolls when the viewer is short: a stop for the keys, so they can scroll it (no\n // role or name of its own: the dialog's title names it already, once)\n const body = el('div', 'gallerist-shortcuts-body')\n body.tabIndex = 0\n for (const [name, list] of rows(keys)) {\n const section = body.appendChild(el('section'))\n if (name) section.appendChild(el('h3', '', name))\n const dl = section.appendChild(el('dl'))\n for (const [label, what] of list) {\n const row = dl.appendChild(el('div', 'gallerist-shortcuts-row'))\n row.appendChild(el('dt', '', label))\n const dd = row.appendChild(el('dd'))\n if (typeof what === 'string') dd.textContent = what\n else for (const k of what) dd.appendChild(el('kbd', '', k))\n }\n }\n box.append(head, body)\n if (!keys) box.appendChild(el('p', 'gallerist-shortcuts-note', t.keysNote))\n s.appendChild(box)\n // the scrim takes no focus (the viewer's root would, under a press), and a click on it closes\n s.addEventListener('mousedown', (e) => e.target === s && e.preventDefault())\n s.addEventListener('click', (e) => e.target === s && close(true))\n // the rest of the viewer is inert while the dialog shows (what was inert already stays so)\n for (const node of r.children)\n if (!node.hasAttribute('inert')) {\n node.setAttribute('inert', '')\n inerted.push(node)\n }\n r.appendChild(s)\n scrim = s\n window.addEventListener('keydown', onKey, true)\n document.addEventListener('pointerdown', onPress, true)\n box.focus({ preventScroll: true })\n return true\n }\n\n const instance: ShortcutsInstance = {\n name: 'shortcuts',\n get label() {\n return coarse() ? t.gestures : t.title\n },\n get isOpen() {\n return !!scrim\n },\n open,\n close: () => close(true),\n init() {\n live.push(instance)\n unsub = viewer.subscribe((st) => {\n if (/^clos/.test(st.phase)) close() // closing or closed\n })\n },\n destroy() {\n close()\n unsub?.()\n unsub = anchor = null\n const at = live.indexOf(instance)\n if (at >= 0) live.splice(at, 1)\n },\n keymap: { '?': () => open(true) },\n // a hidden node, to find the viewer's root by (marked off: a bar shows not for it)\n regions: {\n toolbar: () => {\n anchor = el('span')\n anchor.hidden = true\n anchor.setAttribute('data-gallerist-off', '')\n return anchor\n },\n },\n }\n return instance\n }\n return Object.assign(plugin, {\n open: (keys?: boolean) => live.reduceRight((done, i) => done || i.open(keys), false),\n close: () => {\n for (const i of live) i.close()\n },\n })\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -74,14 +74,14 @@ interface ShortcutsInstance extends PluginInstance {
|
|
|
74
74
|
/** what `open()` shows now: the title of the keys, or of the gestures on a coarse pointer */
|
|
75
75
|
readonly label: string;
|
|
76
76
|
readonly isOpen: boolean;
|
|
77
|
-
/** Opens the list on the open viewer: the keys (`true`), the gestures (`false`), or
|
|
78
|
-
* pointer (default). False when there is no
|
|
77
|
+
/** Opens the list on the open (or opening) viewer: the keys (`true`), the gestures (`false`), or
|
|
78
|
+
* by the pointer (default). False when there is no such viewer to show it in (closing, closed). */
|
|
79
79
|
open(keys?: boolean): boolean;
|
|
80
80
|
close(): void;
|
|
81
81
|
}
|
|
82
82
|
/** `shortcuts()`: a plugin, with `open()` / `close()` for the host (a help button of its own). */
|
|
83
83
|
interface ShortcutsPlugin extends Plugin {
|
|
84
|
-
/** Opens the list on the viewer this plugin was last registered on that is open. */
|
|
84
|
+
/** Opens the list on the viewer this plugin was last registered on that is open (or opening). */
|
|
85
85
|
open(keys?: boolean): boolean;
|
|
86
86
|
close(): void;
|
|
87
87
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -74,14 +74,14 @@ interface ShortcutsInstance extends PluginInstance {
|
|
|
74
74
|
/** what `open()` shows now: the title of the keys, or of the gestures on a coarse pointer */
|
|
75
75
|
readonly label: string;
|
|
76
76
|
readonly isOpen: boolean;
|
|
77
|
-
/** Opens the list on the open viewer: the keys (`true`), the gestures (`false`), or
|
|
78
|
-
* pointer (default). False when there is no
|
|
77
|
+
/** Opens the list on the open (or opening) viewer: the keys (`true`), the gestures (`false`), or
|
|
78
|
+
* by the pointer (default). False when there is no such viewer to show it in (closing, closed). */
|
|
79
79
|
open(keys?: boolean): boolean;
|
|
80
80
|
close(): void;
|
|
81
81
|
}
|
|
82
82
|
/** `shortcuts()`: a plugin, with `open()` / `close()` for the host (a help button of its own). */
|
|
83
83
|
interface ShortcutsPlugin extends Plugin {
|
|
84
|
-
/** Opens the list on the viewer this plugin was last registered on that is open. */
|
|
84
|
+
/** Opens the list on the viewer this plugin was last registered on that is open (or opening). */
|
|
85
85
|
open(keys?: boolean): boolean;
|
|
86
86
|
close(): void;
|
|
87
87
|
}
|
package/dist/index.js
CHANGED
|
@@ -181,7 +181,7 @@ function shortcuts(opts = {}) {
|
|
|
181
181
|
};
|
|
182
182
|
const open = (keys = !coarse()) => {
|
|
183
183
|
const r = root();
|
|
184
|
-
if (!r || !anchor?.isConnected || viewer.getState().phase
|
|
184
|
+
if (!r || !anchor?.isConnected || /^clos/.test(viewer.getState().phase)) return false;
|
|
185
185
|
close();
|
|
186
186
|
back = r.getRootNode().activeElement;
|
|
187
187
|
const s = el("div", "gallerist-shortcuts-scrim");
|
|
@@ -249,7 +249,7 @@ function shortcuts(opts = {}) {
|
|
|
249
249
|
init() {
|
|
250
250
|
live.push(instance);
|
|
251
251
|
unsub = viewer.subscribe((st) => {
|
|
252
|
-
if (st.phase
|
|
252
|
+
if (/^clos/.test(st.phase)) close();
|
|
253
253
|
});
|
|
254
254
|
},
|
|
255
255
|
destroy() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAiFO,IAAM,yBAAA,GAA8C;AAAA,EACzD,KAAA,EAAO,oBAAA;AAAA,EACP,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,gBAAA;AAAA,EACT,KAAA,EAAO,OAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,MAAA,EAAQ,QAAA;AAAA,EACR,QAAA,EAAU,iBAAA;AAAA,EACV,aAAA,EAAe,uBAAA;AAAA,EACf,YAAA,EAAc,8BAAA;AAAA,EACd,QAAA,EAAU,mBAAA;AAAA,EACV,SAAA,EAAW,cAAA;AAAA,EACX,cAAA,EAAgB,oBAAA;AAAA,EAChB,IAAA,EAAM,mBAAA;AAA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AAA,MACA,QAAQ,EAAE,GAAA,EAAK,MAAM,IAAA,CAAK,IAAI,CAAA,EAAE;AAAA;AAAA,MAEhC,OAAA,EAAS;AAAA,QACP,SAAS,MAAM;AACb,UAAA,MAAA,GAAS,GAAG,MAAM,CAAA;AAClB,UAAA,MAAA,CAAO,MAAA,GAAS,IAAA;AAChB,UAAA,MAAA,CAAO,YAAA,CAAa,sBAAsB,EAAE,CAAA;AAC5C,UAAA,OAAO,MAAA;AAAA,QACT;AAAA;AACF,KACF;AACA,IAAA,OAAO,QAAA;AAAA,EACT,CAAA;AACA,EAAA,OAAO,MAAA,CAAO,OAAO,MAAA,EAAQ;AAAA,IAC3B,IAAA,EAAM,CAAC,IAAA,KAAmB,IAAA,CAAK,WAAA,CAAY,CAAC,IAAA,EAAM,CAAA,KAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,CAAK,IAAI,GAAG,KAAK,CAAA;AAAA,IACnF,OAAO,MAAM;AACX,MAAA,KAAA,MAAW,CAAA,IAAK,IAAA,EAAM,CAAA,CAAE,KAAA,EAAM;AAAA,IAChC;AAAA,GACD,CAAA;AACH","file":"index.js","sourcesContent":["// @gallerist/plugin-shortcuts — the viewer's keyboard shortcuts in a modal dialog, on `?`.\n//\n// The list is built each time it opens, from what the viewer does then: the renderer's own keys as\n// the layout has them (a row rail walks every item with ←/→ and has no ↑/↓; a side rail turns the\n// axes; right to left mirrors ←/→), the official plugins' keys while they are registered and hold\n// them (the aggregated keymap, so a key another plugin took isn't listed), and the host's entries.\n// Opened by a touch (the View menu's row, `open()`, on a coarse pointer) it lists the renderer's\n// gestures instead. `?` (with the viewer focused, not in a text field) opens the keys.\n//\n// The dialog sits in the viewer's root over a scrim that covers the viewer: `aria-modal`, the rest\n// of the root inert while it shows, Tab kept inside, focus back where it was on close. Keys pressed\n// in it never reach the viewer (a window listener in the capture phase takes them first): Escape and\n// `?` close it, and nothing else acts. The root is found from a hidden node in the toolbar region.\n\nimport type { Item, Plugin, PluginInstance, ViewerApi } from '@gallerist/core'\nimport { getInternals } from '@gallerist/core/internal'\n\n/** A host's own shortcut, listed with the built-in ones. */\nexport interface ShortcutEntry {\n /** what it does */\n label: string\n /** the keys, each drawn as a key cap (`['N']`, `['Shift', 'N']`); without them it's listed only\n * with the gestures */\n keys?: readonly string[]\n /** the gesture that does it on a touch screen (`'Long press'`); without one it's listed only with\n * the keys */\n gesture?: string\n /** the section it joins: a built-in one by its title (`strings.move`, `zoom`, `viewer`) or a new\n * one after them. Default: the Viewer section. */\n section?: string\n}\n\nexport interface ShortcutsStrings {\n /** the dialog's title with the keys, and the View menu's row */\n title: string\n /** the dialog's title with the gestures (and the View menu's row on a touch screen) */\n gestures: string\n /** the close button's text, `{key}` where the Esc key cap goes (\"{key} to close\") */\n toClose: string\n close: string\n /** section titles */\n move: string\n zoom: string\n viewer: string\n /** moving */\n prevNext: string\n prevNextGroup: string\n prevNextItem: string\n nextItem: string\n firstLast: string\n firstLastGroup: string\n jump: string\n /** zooming */\n zoomIn: string\n zoomOut: string\n fit: string\n pan: string\n /** the viewer, and the plugins' keys */\n fullscreen: string\n rail: string\n items: string\n grid: string\n pins: string\n addPin: string\n download: string\n help: string\n exit: string\n /** gestures */\n swipe: string\n swipeUp: string\n swipeDown: string\n pinch: string\n drag: string\n /** under the gestures */\n keysNote: string\n /** key names on their caps */\n home: string\n end: string\n esc: string\n}\n\nexport const DEFAULT_SHORTCUTS_STRINGS: ShortcutsStrings = {\n title: 'Keyboard shortcuts',\n gestures: 'Gestures',\n toClose: '{key} to close',\n close: 'Close',\n move: 'Move',\n zoom: 'Zoom',\n viewer: 'Viewer',\n prevNext: 'Previous / next',\n prevNextGroup: 'Previous / next group',\n prevNextItem: 'Previous / next in the group',\n nextItem: 'Next in the group',\n firstLast: 'First / last',\n firstLastGroup: 'First / last group',\n jump: 'Item in the group',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n fit: 'Fit to screen',\n pan: 'Move while zoomed',\n fullscreen: 'Fullscreen',\n rail: 'Thumbnails',\n items: 'Item list',\n grid: 'Grid',\n pins: 'Pins',\n addPin: 'Add a comment',\n download: 'Download',\n help: 'This list',\n exit: 'Close',\n swipe: 'Swipe left or right',\n swipeUp: 'Swipe up',\n swipeDown: 'Swipe down',\n pinch: 'Pinch, or double-tap',\n drag: 'Drag',\n keysNote: 'With a keyboard, ? lists its shortcuts.',\n home: 'Home',\n end: 'End',\n esc: 'Esc',\n}\n\nexport interface ShortcutsOptions {\n /** the host's own shortcuts, listed after the built-in ones */\n shortcuts?: readonly ShortcutEntry[]\n /** UI text overrides, for translation; merged over English. */\n strings?: Partial<ShortcutsStrings>\n}\n\n/** The plugin's instance on a viewer (named `shortcuts`); the View menu finds it by that name. */\nexport interface ShortcutsInstance extends PluginInstance {\n /** what `open()` shows now: the title of the keys, or of the gestures on a coarse pointer */\n readonly label: string\n readonly isOpen: boolean\n /** Opens the list on the open viewer: the keys (`true`), the gestures (`false`), or by the\n * pointer (default). False when there is no open viewer to show it in. */\n open(keys?: boolean): boolean\n close(): void\n}\n\n/** `shortcuts()`: a plugin, with `open()` / `close()` for the host (a help button of its own). */\nexport interface ShortcutsPlugin extends Plugin {\n /** Opens the list on the viewer this plugin was last registered on that is open. */\n open(keys?: boolean): boolean\n close(): void\n}\n\ntype Row = [label: string, keys: readonly string[] | string]\n\nconst KEYBOARD =\n '<svg class=\"gallerist-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\"/><path d=\"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10\"/></svg>'\nconst X =\n '<svg class=\"gallerist-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>'\nconst TABBABLE = 'button:not([disabled]), [href], [tabindex]:not([tabindex=\"-1\"])'\n\nlet lists = 0 // ids, for aria-labelledby\n\nconst el = <K extends keyof HTMLElementTagNameMap>(\n tag: K,\n className = '',\n text = '',\n): HTMLElementTagNameMap[K] => {\n const node = document.createElement(tag)\n if (className) node.className = className\n if (text) node.textContent = text\n return node\n}\nconst cap = (k: string) => (k.length === 1 ? k.toUpperCase() : k)\n// `?` typed with AltGr (Ctrl + Alt on Windows) is still `?`; another chord is the browser's\nconst chord = (e: KeyboardEvent) =>\n (e.ctrlKey || e.metaKey || e.altKey) && !e.getModifierState?.('AltGraph')\n\nexport function shortcuts(opts: ShortcutsOptions = {}): ShortcutsPlugin {\n const t: ShortcutsStrings = { ...DEFAULT_SHORTCUTS_STRINGS, ...opts.strings }\n const live: ShortcutsInstance[] = [] // registered instances, the latest last\n\n const plugin = (viewer: ViewerApi): ShortcutsInstance => {\n let anchor: HTMLElement | null = null\n let scrim: HTMLElement | null = null\n let back: HTMLElement | null = null // focus before it opened\n let inerted: Element[] = []\n let unsub: (() => void) | null = null\n const id = `gallerist-shortcuts-${++lists}`\n const root = () => anchor?.closest<HTMLElement>('.gallerist') ?? null\n const coarse = () => !!window.matchMedia?.('(pointer: coarse)').matches\n\n // What the viewer does now, read from its root and its plugins.\n const rows = (keys: boolean): Array<[string, Row[]]> => {\n const r = root() as HTMLElement\n const plugins = getInternals(viewer).getPlugins()\n const map: Record<string, unknown> = {}\n for (const p of plugins) Object.assign(map, p.keymap)\n const named = (name: string) => plugins.find((p) => p.name === name)\n // the key `k` of the plugin `name`, while it holds it (none: its first key)\n const held = (name: string, k?: string) => {\n const own = named(name)?.keymap ?? {}\n const key = k ?? Object.keys(own)[0]\n return key && own[key] && map[key] === own[key] ? key : undefined\n }\n const linear = r.hasAttribute('data-gallerist-linear')\n const vertical = r.getAttribute('data-gallerist-axis') === 'vertical'\n const across = r.getAttribute('data-gallerist-dir') === 'rtl' ? ['→', '←'] : ['←', '→']\n const along = ['↑', '↓']\n const grouped = !linear && viewer.getCollection().groups.some((g) => g.items.length > 1)\n const overlay = r.getAttribute('data-gallerist-mode') === 'overlay'\n const rail = (named('thumbnails') as { display?: string } | undefined)?.display\n\n // zooming, while an item can zoom: plugin-zoom's `zoomable`, else an image\n const can =\n (named('zoom') as { zoomable?: (item: Item) => boolean } | undefined)?.zoomable ??\n ((i: Item) => i.type === 'image')\n const zoom = viewer.getCollection().groups.some((g) => g.items.some((i) => can(i)))\n let sections: Array<[string, Row[]]>\n if (keys) {\n const move: Row[] = grouped\n ? [\n [t.prevNextGroup, vertical ? along : across],\n [t.prevNextItem, vertical ? across : along],\n [t.firstLastGroup, [t.home, t.end]],\n [t.jump, ['1–9']],\n ]\n : [\n [t.prevNext, vertical ? along : across],\n [t.firstLast, [t.home, t.end]],\n ]\n const fs = (document as { webkitFullscreenEnabled?: boolean }).webkitFullscreenEnabled\n const tools: Array<[string, string | undefined]> = [\n [t.fullscreen, (document.fullscreenEnabled ?? fs) ? held('fullscreen', 'f') : undefined],\n [t.rail, rail ? 't' : undefined],\n [t.items, held('thumbnails', 'e')],\n [t.grid, held('grid')],\n [t.pins, held('pins', 'p')],\n [t.addPin, held('pins', 'c')],\n [t.download, held('download')],\n [t.help, '?'],\n [t.exit, overlay ? t.esc : undefined],\n ]\n sections = [\n [t.move, move],\n [\n t.zoom,\n zoom\n ? [\n [t.zoomIn, ['+']],\n [t.zoomOut, ['−']],\n [t.fit, ['0']],\n ]\n : [],\n ],\n [t.viewer, tools.flatMap(([label, k]) => (k ? [[label, [cap(k)]] as Row] : []))],\n ]\n } else {\n sections = [\n [\n '',\n [\n [grouped ? t.prevNextGroup : t.prevNext, t.swipe],\n ...(grouped ? [[t.nextItem, t.swipeUp] as Row] : []),\n ...(zoom ? [[t.zoom, t.pinch] as Row, [t.pan, t.drag] as Row] : []),\n ...(overlay ? [[t.exit, t.swipeDown] as Row] : []),\n ],\n ],\n ]\n }\n for (const x of opts.shortcuts ?? []) {\n const what = keys ? x.keys : x.gesture\n if (!what?.length) continue\n const title = keys ? (x.section ?? t.viewer) : ''\n let section = sections.find(([s]) => s === title)\n if (!section) {\n section = [title, []]\n sections.push(section)\n }\n section[1].push([x.label, what])\n }\n return sections.filter(([, list]) => list.length)\n }\n\n const close = (refocus = false) => {\n if (!scrim) return\n scrim.remove()\n scrim = null\n for (const node of inerted) node.removeAttribute('inert')\n inerted = []\n window.removeEventListener('keydown', onKey, true)\n document.removeEventListener('pointerdown', onPress, true)\n if (refocus) (back?.isConnected ? back : root())?.focus({ preventScroll: true })\n back = null\n }\n\n // Every key pressed in the viewer while the list shows stops here: the viewer's keys, the zoom\n // tool's and the page's never see it. Escape and ? close; Tab stays in the dialog.\n const onKey = (e: KeyboardEvent) => {\n const r = root()\n if (!scrim?.isConnected) return close() // the viewer went away with it open\n if (!r || !e.composedPath().includes(r)) return\n e.stopPropagation()\n if (e.key === 'Escape' || (e.key === '?' && !chord(e))) {\n e.preventDefault()\n close(true)\n } else if (e.key === 'Tab') {\n const box = scrim.firstElementChild as HTMLElement\n const list = [...box.querySelectorAll<HTMLElement>(TABBABLE)]\n const active = (r.getRootNode() as Document | ShadowRoot).activeElement\n const first = list[0]\n const last = list[list.length - 1]\n const to = e.shiftKey\n ? active === first || active === box\n ? last\n : null\n : active === last\n ? first\n : null\n if (!first || to) {\n e.preventDefault()\n to?.focus()\n }\n }\n }\n // A press on the page outside the viewer closes it, leaving focus where the press puts it (a\n // press on the scrim closes it too, with focus back where it was: see open()).\n // (A viewer gone with it open is outside too: its listeners go with the next press or key.)\n const onPress = (e: Event) => {\n if (!e.composedPath().includes(root() as EventTarget)) close()\n }\n\n const open = (keys = !coarse()): boolean => {\n const r = root()\n if (!r || !anchor?.isConnected || viewer.getState().phase !== 'open') return false\n close()\n back = (r.getRootNode() as Document | ShadowRoot).activeElement as HTMLElement | null\n const s = el('div', 'gallerist-shortcuts-scrim')\n const box = el('div', 'gallerist-shortcuts')\n box.setAttribute('role', 'dialog')\n box.setAttribute('aria-modal', 'true')\n box.setAttribute('aria-labelledby', id)\n box.tabIndex = -1\n box.setAttribute('data-gallerist-list', keys ? 'keys' : 'gestures')\n const head = el('div', 'gallerist-shortcuts-head')\n if (keys) head.innerHTML = KEYBOARD\n const title = head.appendChild(el('h2', '', keys ? t.title : t.gestures))\n title.id = id\n const x = head.appendChild(el('button', 'gallerist-shortcuts-close'))\n x.type = 'button'\n if (keys) {\n const [before, after] = t.toClose.split('{key}')\n x.append(before as string, el('kbd', '', t.esc), after ?? '')\n } else {\n x.innerHTML = X\n x.setAttribute('aria-label', t.close)\n }\n x.addEventListener('click', () => close(true))\n // the list scrolls when the viewer is short: a stop for the keys, so they can scroll it (no\n // role or name of its own: the dialog's title names it already, once)\n const body = el('div', 'gallerist-shortcuts-body')\n body.tabIndex = 0\n for (const [name, list] of rows(keys)) {\n const section = body.appendChild(el('section'))\n if (name) section.appendChild(el('h3', '', name))\n const dl = section.appendChild(el('dl'))\n for (const [label, what] of list) {\n const row = dl.appendChild(el('div', 'gallerist-shortcuts-row'))\n row.appendChild(el('dt', '', label))\n const dd = row.appendChild(el('dd'))\n if (typeof what === 'string') dd.textContent = what\n else for (const k of what) dd.appendChild(el('kbd', '', k))\n }\n }\n box.append(head, body)\n if (!keys) box.appendChild(el('p', 'gallerist-shortcuts-note', t.keysNote))\n s.appendChild(box)\n // the scrim takes no focus (the viewer's root would, under a press), and a click on it closes\n s.addEventListener('mousedown', (e) => e.target === s && e.preventDefault())\n s.addEventListener('click', (e) => e.target === s && close(true))\n // the rest of the viewer is inert while the dialog shows (what was inert already stays so)\n for (const node of r.children)\n if (!node.hasAttribute('inert')) {\n node.setAttribute('inert', '')\n inerted.push(node)\n }\n r.appendChild(s)\n scrim = s\n window.addEventListener('keydown', onKey, true)\n document.addEventListener('pointerdown', onPress, true)\n box.focus({ preventScroll: true })\n return true\n }\n\n const instance: ShortcutsInstance = {\n name: 'shortcuts',\n get label() {\n return coarse() ? t.gestures : t.title\n },\n get isOpen() {\n return !!scrim\n },\n open,\n close: () => close(true),\n init() {\n live.push(instance)\n unsub = viewer.subscribe((st) => {\n if (st.phase === 'closing' || st.phase === 'closed') close()\n })\n },\n destroy() {\n close()\n unsub?.()\n unsub = anchor = null\n const at = live.indexOf(instance)\n if (at >= 0) live.splice(at, 1)\n },\n keymap: { '?': () => open(true) },\n // a hidden node, to find the viewer's root by (marked off: a bar shows not for it)\n regions: {\n toolbar: () => {\n anchor = el('span')\n anchor.hidden = true\n anchor.setAttribute('data-gallerist-off', '')\n return anchor\n },\n },\n }\n return instance\n }\n return Object.assign(plugin, {\n open: (keys?: boolean) => live.reduceRight((done, i) => done || i.open(keys), false),\n close: () => {\n for (const i of live) i.close()\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAiFO,IAAM,yBAAA,GAA8C;AAAA,EACzD,KAAA,EAAO,oBAAA;AAAA,EACP,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,gBAAA;AAAA,EACT,KAAA,EAAO,OAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,MAAA,EAAQ,QAAA;AAAA,EACR,QAAA,EAAU,iBAAA;AAAA,EACV,aAAA,EAAe,uBAAA;AAAA,EACf,YAAA,EAAc,8BAAA;AAAA,EACd,QAAA,EAAU,mBAAA;AAAA,EACV,SAAA,EAAW,cAAA;AAAA,EACX,cAAA,EAAgB,oBAAA;AAAA,EAChB,IAAA,EAAM,mBAAA;AAAA,EACN,MAAA,EAAQ,SAAA;AAAA,EACR,OAAA,EAAS,UAAA;AAAA,EACT,GAAA,EAAK,eAAA;AAAA,EACL,GAAA,EAAK,mBAAA;AAAA,EACL,UAAA,EAAY,YAAA;AAAA,EACZ,IAAA,EAAM,YAAA;AAAA,EACN,KAAA,EAAO,WAAA;AAAA,EACP,IAAA,EAAM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B,UAAA,MAAA,CAAO,YAAA,CAAa,sBAAsB,EAAE,CAAA;AAC5C,UAAA,OAAO,MAAA;AAAA,QACT;AAAA;AACF,KACF;AACA,IAAA,OAAO,QAAA;AAAA,EACT,CAAA;AACA,EAAA,OAAO,MAAA,CAAO,OAAO,MAAA,EAAQ;AAAA,IAC3B,IAAA,EAAM,CAAC,IAAA,KAAmB,IAAA,CAAK,WAAA,CAAY,CAAC,IAAA,EAAM,CAAA,KAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,CAAK,IAAI,GAAG,KAAK,CAAA;AAAA,IACnF,OAAO,MAAM;AACX,MAAA,KAAA,MAAW,CAAA,IAAK,IAAA,EAAM,CAAA,CAAE,KAAA,EAAM;AAAA,IAChC;AAAA,GACD,CAAA;AACH","file":"index.js","sourcesContent":["// @gallerist/plugin-shortcuts — the viewer's keyboard shortcuts in a modal dialog, on `?`.\n//\n// The list is built each time it opens, from what the viewer does then: the renderer's own keys as\n// the layout has them (a row rail walks every item with ←/→ and has no ↑/↓; a side rail turns the\n// axes; right to left mirrors ←/→), the official plugins' keys while they are registered and hold\n// them (the aggregated keymap, so a key another plugin took isn't listed), and the host's entries.\n// Opened by a touch (the View menu's row, `open()`, on a coarse pointer) it lists the renderer's\n// gestures instead. `?` (with the viewer focused, not in a text field) opens the keys.\n//\n// The dialog sits in the viewer's root over a scrim that covers the viewer: `aria-modal`, the rest\n// of the root inert while it shows, Tab kept inside, focus back where it was on close. Keys pressed\n// in it never reach the viewer (a window listener in the capture phase takes them first): Escape and\n// `?` close it, and nothing else acts. The root is found from a hidden node in the toolbar region.\n\nimport type { Item, Plugin, PluginInstance, ViewerApi } from '@gallerist/core'\nimport { getInternals } from '@gallerist/core/internal'\n\n/** A host's own shortcut, listed with the built-in ones. */\nexport interface ShortcutEntry {\n /** what it does */\n label: string\n /** the keys, each drawn as a key cap (`['N']`, `['Shift', 'N']`); without them it's listed only\n * with the gestures */\n keys?: readonly string[]\n /** the gesture that does it on a touch screen (`'Long press'`); without one it's listed only with\n * the keys */\n gesture?: string\n /** the section it joins: a built-in one by its title (`strings.move`, `zoom`, `viewer`) or a new\n * one after them. Default: the Viewer section. */\n section?: string\n}\n\nexport interface ShortcutsStrings {\n /** the dialog's title with the keys, and the View menu's row */\n title: string\n /** the dialog's title with the gestures (and the View menu's row on a touch screen) */\n gestures: string\n /** the close button's text, `{key}` where the Esc key cap goes (\"{key} to close\") */\n toClose: string\n close: string\n /** section titles */\n move: string\n zoom: string\n viewer: string\n /** moving */\n prevNext: string\n prevNextGroup: string\n prevNextItem: string\n nextItem: string\n firstLast: string\n firstLastGroup: string\n jump: string\n /** zooming */\n zoomIn: string\n zoomOut: string\n fit: string\n pan: string\n /** the viewer, and the plugins' keys */\n fullscreen: string\n rail: string\n items: string\n grid: string\n pins: string\n addPin: string\n download: string\n help: string\n exit: string\n /** gestures */\n swipe: string\n swipeUp: string\n swipeDown: string\n pinch: string\n drag: string\n /** under the gestures */\n keysNote: string\n /** key names on their caps */\n home: string\n end: string\n esc: string\n}\n\nexport const DEFAULT_SHORTCUTS_STRINGS: ShortcutsStrings = {\n title: 'Keyboard shortcuts',\n gestures: 'Gestures',\n toClose: '{key} to close',\n close: 'Close',\n move: 'Move',\n zoom: 'Zoom',\n viewer: 'Viewer',\n prevNext: 'Previous / next',\n prevNextGroup: 'Previous / next group',\n prevNextItem: 'Previous / next in the group',\n nextItem: 'Next in the group',\n firstLast: 'First / last',\n firstLastGroup: 'First / last group',\n jump: 'Item in the group',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n fit: 'Fit to screen',\n pan: 'Move while zoomed',\n fullscreen: 'Fullscreen',\n rail: 'Thumbnails',\n items: 'Item list',\n grid: 'Grid',\n pins: 'Pins',\n addPin: 'Add a comment',\n download: 'Download',\n help: 'This list',\n exit: 'Close',\n swipe: 'Swipe left or right',\n swipeUp: 'Swipe up',\n swipeDown: 'Swipe down',\n pinch: 'Pinch, or double-tap',\n drag: 'Drag',\n keysNote: 'With a keyboard, ? lists its shortcuts.',\n home: 'Home',\n end: 'End',\n esc: 'Esc',\n}\n\nexport interface ShortcutsOptions {\n /** the host's own shortcuts, listed after the built-in ones */\n shortcuts?: readonly ShortcutEntry[]\n /** UI text overrides, for translation; merged over English. */\n strings?: Partial<ShortcutsStrings>\n}\n\n/** The plugin's instance on a viewer (named `shortcuts`); the View menu finds it by that name. */\nexport interface ShortcutsInstance extends PluginInstance {\n /** what `open()` shows now: the title of the keys, or of the gestures on a coarse pointer */\n readonly label: string\n readonly isOpen: boolean\n /** Opens the list on the open (or opening) viewer: the keys (`true`), the gestures (`false`), or\n * by the pointer (default). False when there is no such viewer to show it in (closing, closed). */\n open(keys?: boolean): boolean\n close(): void\n}\n\n/** `shortcuts()`: a plugin, with `open()` / `close()` for the host (a help button of its own). */\nexport interface ShortcutsPlugin extends Plugin {\n /** Opens the list on the viewer this plugin was last registered on that is open (or opening). */\n open(keys?: boolean): boolean\n close(): void\n}\n\ntype Row = [label: string, keys: readonly string[] | string]\n\nconst KEYBOARD =\n '<svg class=\"gallerist-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\"/><path d=\"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10\"/></svg>'\nconst X =\n '<svg class=\"gallerist-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>'\nconst TABBABLE = 'button:not([disabled]), [href], [tabindex]:not([tabindex=\"-1\"])'\n\nlet lists = 0 // ids, for aria-labelledby\n\nconst el = <K extends keyof HTMLElementTagNameMap>(\n tag: K,\n className = '',\n text = '',\n): HTMLElementTagNameMap[K] => {\n const node = document.createElement(tag)\n if (className) node.className = className\n if (text) node.textContent = text\n return node\n}\nconst cap = (k: string) => (k.length === 1 ? k.toUpperCase() : k)\n// `?` typed with AltGr (Ctrl + Alt on Windows) is still `?`; another chord is the browser's\nconst chord = (e: KeyboardEvent) =>\n (e.ctrlKey || e.metaKey || e.altKey) && !e.getModifierState?.('AltGraph')\n\nexport function shortcuts(opts: ShortcutsOptions = {}): ShortcutsPlugin {\n const t: ShortcutsStrings = { ...DEFAULT_SHORTCUTS_STRINGS, ...opts.strings }\n const live: ShortcutsInstance[] = [] // registered instances, the latest last\n\n const plugin = (viewer: ViewerApi): ShortcutsInstance => {\n let anchor: HTMLElement | null = null\n let scrim: HTMLElement | null = null\n let back: HTMLElement | null = null // focus before it opened\n let inerted: Element[] = []\n let unsub: (() => void) | null = null\n const id = `gallerist-shortcuts-${++lists}`\n const root = () => anchor?.closest<HTMLElement>('.gallerist') ?? null\n const coarse = () => !!window.matchMedia?.('(pointer: coarse)').matches\n\n // What the viewer does now, read from its root and its plugins.\n const rows = (keys: boolean): Array<[string, Row[]]> => {\n const r = root() as HTMLElement\n const plugins = getInternals(viewer).getPlugins()\n const map: Record<string, unknown> = {}\n for (const p of plugins) Object.assign(map, p.keymap)\n const named = (name: string) => plugins.find((p) => p.name === name)\n // the key `k` of the plugin `name`, while it holds it (none: its first key)\n const held = (name: string, k?: string) => {\n const own = named(name)?.keymap ?? {}\n const key = k ?? Object.keys(own)[0]\n return key && own[key] && map[key] === own[key] ? key : undefined\n }\n const linear = r.hasAttribute('data-gallerist-linear')\n const vertical = r.getAttribute('data-gallerist-axis') === 'vertical'\n const across = r.getAttribute('data-gallerist-dir') === 'rtl' ? ['→', '←'] : ['←', '→']\n const along = ['↑', '↓']\n const grouped = !linear && viewer.getCollection().groups.some((g) => g.items.length > 1)\n const overlay = r.getAttribute('data-gallerist-mode') === 'overlay'\n const rail = (named('thumbnails') as { display?: string } | undefined)?.display\n\n // zooming, while an item can zoom: plugin-zoom's `zoomable`, else an image\n const can =\n (named('zoom') as { zoomable?: (item: Item) => boolean } | undefined)?.zoomable ??\n ((i: Item) => i.type === 'image')\n const zoom = viewer.getCollection().groups.some((g) => g.items.some((i) => can(i)))\n let sections: Array<[string, Row[]]>\n if (keys) {\n const move: Row[] = grouped\n ? [\n [t.prevNextGroup, vertical ? along : across],\n [t.prevNextItem, vertical ? across : along],\n [t.firstLastGroup, [t.home, t.end]],\n [t.jump, ['1–9']],\n ]\n : [\n [t.prevNext, vertical ? along : across],\n [t.firstLast, [t.home, t.end]],\n ]\n const fs = (document as { webkitFullscreenEnabled?: boolean }).webkitFullscreenEnabled\n const tools: Array<[string, string | undefined]> = [\n [t.fullscreen, (document.fullscreenEnabled ?? fs) ? held('fullscreen', 'f') : undefined],\n [t.rail, rail ? 't' : undefined],\n [t.items, held('thumbnails', 'e')],\n [t.grid, held('grid')],\n [t.pins, held('pins', 'p')],\n [t.addPin, held('pins', 'c')],\n [t.download, held('download')],\n [t.help, '?'],\n [t.exit, overlay ? t.esc : undefined],\n ]\n sections = [\n [t.move, move],\n [\n t.zoom,\n zoom\n ? [\n [t.zoomIn, ['+']],\n [t.zoomOut, ['−']],\n [t.fit, ['0']],\n ]\n : [],\n ],\n [t.viewer, tools.flatMap(([label, k]) => (k ? [[label, [cap(k)]] as Row] : []))],\n ]\n } else {\n sections = [\n [\n '',\n [\n [grouped ? t.prevNextGroup : t.prevNext, t.swipe],\n ...(grouped ? [[t.nextItem, t.swipeUp] as Row] : []),\n ...(zoom ? [[t.zoom, t.pinch] as Row, [t.pan, t.drag] as Row] : []),\n ...(overlay ? [[t.exit, t.swipeDown] as Row] : []),\n ],\n ],\n ]\n }\n for (const x of opts.shortcuts ?? []) {\n const what = keys ? x.keys : x.gesture\n if (!what?.length) continue\n const title = keys ? (x.section ?? t.viewer) : ''\n let section = sections.find(([s]) => s === title)\n if (!section) {\n section = [title, []]\n sections.push(section)\n }\n section[1].push([x.label, what])\n }\n return sections.filter(([, list]) => list.length)\n }\n\n const close = (refocus = false) => {\n if (!scrim) return\n scrim.remove()\n scrim = null\n for (const node of inerted) node.removeAttribute('inert')\n inerted = []\n window.removeEventListener('keydown', onKey, true)\n document.removeEventListener('pointerdown', onPress, true)\n if (refocus) (back?.isConnected ? back : root())?.focus({ preventScroll: true })\n back = null\n }\n\n // Every key pressed in the viewer while the list shows stops here: the viewer's keys, the zoom\n // tool's and the page's never see it. Escape and ? close; Tab stays in the dialog.\n const onKey = (e: KeyboardEvent) => {\n const r = root()\n if (!scrim?.isConnected) return close() // the viewer went away with it open\n if (!r || !e.composedPath().includes(r)) return\n e.stopPropagation()\n if (e.key === 'Escape' || (e.key === '?' && !chord(e))) {\n e.preventDefault()\n close(true)\n } else if (e.key === 'Tab') {\n const box = scrim.firstElementChild as HTMLElement\n const list = [...box.querySelectorAll<HTMLElement>(TABBABLE)]\n const active = (r.getRootNode() as Document | ShadowRoot).activeElement\n const first = list[0]\n const last = list[list.length - 1]\n const to = e.shiftKey\n ? active === first || active === box\n ? last\n : null\n : active === last\n ? first\n : null\n if (!first || to) {\n e.preventDefault()\n to?.focus()\n }\n }\n }\n // A press on the page outside the viewer closes it, leaving focus where the press puts it (a\n // press on the scrim closes it too, with focus back where it was: see open()).\n // (A viewer gone with it open is outside too: its listeners go with the next press or key.)\n const onPress = (e: Event) => {\n if (!e.composedPath().includes(root() as EventTarget)) close()\n }\n\n const open = (keys = !coarse()): boolean => {\n const r = root()\n // on a viewer that is open or opening (its keys work from its first frame), not one going away\n if (!r || !anchor?.isConnected || /^clos/.test(viewer.getState().phase)) return false\n close()\n back = (r.getRootNode() as Document | ShadowRoot).activeElement as HTMLElement | null\n const s = el('div', 'gallerist-shortcuts-scrim')\n const box = el('div', 'gallerist-shortcuts')\n box.setAttribute('role', 'dialog')\n box.setAttribute('aria-modal', 'true')\n box.setAttribute('aria-labelledby', id)\n box.tabIndex = -1\n box.setAttribute('data-gallerist-list', keys ? 'keys' : 'gestures')\n const head = el('div', 'gallerist-shortcuts-head')\n if (keys) head.innerHTML = KEYBOARD\n const title = head.appendChild(el('h2', '', keys ? t.title : t.gestures))\n title.id = id\n const x = head.appendChild(el('button', 'gallerist-shortcuts-close'))\n x.type = 'button'\n if (keys) {\n const [before, after] = t.toClose.split('{key}')\n x.append(before as string, el('kbd', '', t.esc), after ?? '')\n } else {\n x.innerHTML = X\n x.setAttribute('aria-label', t.close)\n }\n x.addEventListener('click', () => close(true))\n // the list scrolls when the viewer is short: a stop for the keys, so they can scroll it (no\n // role or name of its own: the dialog's title names it already, once)\n const body = el('div', 'gallerist-shortcuts-body')\n body.tabIndex = 0\n for (const [name, list] of rows(keys)) {\n const section = body.appendChild(el('section'))\n if (name) section.appendChild(el('h3', '', name))\n const dl = section.appendChild(el('dl'))\n for (const [label, what] of list) {\n const row = dl.appendChild(el('div', 'gallerist-shortcuts-row'))\n row.appendChild(el('dt', '', label))\n const dd = row.appendChild(el('dd'))\n if (typeof what === 'string') dd.textContent = what\n else for (const k of what) dd.appendChild(el('kbd', '', k))\n }\n }\n box.append(head, body)\n if (!keys) box.appendChild(el('p', 'gallerist-shortcuts-note', t.keysNote))\n s.appendChild(box)\n // the scrim takes no focus (the viewer's root would, under a press), and a click on it closes\n s.addEventListener('mousedown', (e) => e.target === s && e.preventDefault())\n s.addEventListener('click', (e) => e.target === s && close(true))\n // the rest of the viewer is inert while the dialog shows (what was inert already stays so)\n for (const node of r.children)\n if (!node.hasAttribute('inert')) {\n node.setAttribute('inert', '')\n inerted.push(node)\n }\n r.appendChild(s)\n scrim = s\n window.addEventListener('keydown', onKey, true)\n document.addEventListener('pointerdown', onPress, true)\n box.focus({ preventScroll: true })\n return true\n }\n\n const instance: ShortcutsInstance = {\n name: 'shortcuts',\n get label() {\n return coarse() ? t.gestures : t.title\n },\n get isOpen() {\n return !!scrim\n },\n open,\n close: () => close(true),\n init() {\n live.push(instance)\n unsub = viewer.subscribe((st) => {\n if (/^clos/.test(st.phase)) close() // closing or closed\n })\n },\n destroy() {\n close()\n unsub?.()\n unsub = anchor = null\n const at = live.indexOf(instance)\n if (at >= 0) live.splice(at, 1)\n },\n keymap: { '?': () => open(true) },\n // a hidden node, to find the viewer's root by (marked off: a bar shows not for it)\n regions: {\n toolbar: () => {\n anchor = el('span')\n anchor.hidden = true\n anchor.setAttribute('data-gallerist-off', '')\n return anchor\n },\n },\n }\n return instance\n }\n return Object.assign(plugin, {\n open: (keys?: boolean) => live.reduceRight((done, i) => done || i.open(keys), false),\n close: () => {\n for (const i of live) i.close()\n },\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gallerist/plugin-shortcuts",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Gallerist plugin — a keyboard shortcut list on ?: the keys that work in the viewer as it is laid out (and the gestures on a touch screen), with the host's own, in a modal dialog.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"tsup": "^8.3.5",
|
|
33
33
|
"typescript": "^5.7.2",
|
|
34
|
-
"@gallerist/core": "0.4.
|
|
34
|
+
"@gallerist/core": "0.4.1"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|