webview-preview 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ export function pageKeys(saved) {
2
+ const DEFAULT_KEYS = { pick: "p", notes: "n", freeze: "f", toggle: "t", parent: "ArrowUp", child: "ArrowDown", done: "Control+Enter" }
3
+ const KEY_ACTIONS = [
4
+ ["pick", "Pick elements"],
5
+ ["notes", "Show / hide notes"],
6
+ ["freeze", "Freeze"],
7
+ ["toggle", "Show / hide tools"],
8
+ ["parent", "Outline the parent"],
9
+ ["child", "Back to the child"],
10
+ ["done", "Done"]
11
+ ];
12
+ const bindings = { ...DEFAULT_KEYS, ...(saved ?? {}) }
13
+
14
+ const KEY_NAMES = { Control: "Ctrl", ArrowUp: "↑", ArrowDown: "↓", ArrowLeft: "←", ArrowRight: "→", " ": "Space" }
15
+ const showKey = combo => combo.split("+").map(part => KEY_NAMES[part] ?? (part.length === 1 ? part.toUpperCase() : part)).join("+");
16
+ const comboOf = event => {
17
+ if (["Control", "Alt", "Shift", "Meta"].includes(event.key)) return null;
18
+ const parts = [];
19
+ if (event.ctrlKey) parts.push("Control");
20
+ if (event.altKey) parts.push("Alt");
21
+ const code = event.code ?? "";
22
+ const key = /^Key[A-Z]$/.test(code) ? code.slice(3).toLowerCase()
23
+ : /^Digit\d$/.test(code) ? code.slice(5)
24
+ : event.key.length === 1 ? event.key.toLowerCase() : event.key;
25
+ if (event.shiftKey && key.length > 1) parts.push("Shift");
26
+ if (event.metaKey) parts.push("Meta");
27
+ parts.push(key);
28
+ return parts.join("+");
29
+ }
30
+
31
+ const actionFor = combo => Object.keys(bindings).find(action => bindings[action] === combo) ?? null;
32
+ return { DEFAULT_KEYS, KEY_ACTIONS, bindings, showKey, comboOf, actionFor }
33
+ }
@@ -0,0 +1,37 @@
1
+ import { ICONS } from "#src/page/annotate/icons.mjs";
2
+
3
+ export const MARKUP = `
4
+ <div class="layer">
5
+ <div class="masks"></div>
6
+ <div class="picks"></div>
7
+ <div class="outline"><div class="outline-label"></div></div>
8
+ </div>
9
+ <div class="dock" role="toolbar" aria-label="webview-preview annotate">
10
+ <div class="card toolbar">
11
+ <div class="grip" aria-hidden="true">${ICONS.grip}</div>
12
+ <button type="button" class="tool toggle" data-action="toggle"></button>
13
+ <div class="collapse"><div><div class="tools">
14
+ <button type="button" class="tool pick" data-action="pick" data-tip="Pick elements">${ICONS.pick}</button>
15
+ <button type="button" class="tool notes-button" data-action="notes" data-tip="Notes">${ICONS.notes}<span class="badge"></span></button>
16
+ <button type="button" class="tool freeze" data-action="freeze" data-tip="Freeze">${ICONS.freeze}<span class="badge freeze-badge"></span></button>
17
+ <button type="button" class="tool keys" data-tip="Key bindings">${ICONS.keys}</button>
18
+ <div class="divider"></div>
19
+ <button type="button" class="tool accent done" data-action="done" data-tip="Done">${ICONS.done}</button>
20
+ <button type="button" class="tool cancel" data-tip="Cancel">${ICONS.cancel}</button>
21
+ </div></div></div>
22
+ </div>
23
+ <div class="card sheet notes-sheet" hidden>
24
+ <div class="sheet-head"><b>Notes</b><span class="run-name"></span></div>
25
+ <p class="privacy"></p>
26
+ <ol class="notes"></ol>
27
+ <label>General note<textarea class="general" rows="2" placeholder="About the whole screen"></textarea></label>
28
+ <p class="hint"></p>
29
+ </div>
30
+ <div class="card sheet keys-sheet" hidden>
31
+ <div class="sheet-head"><b>Key bindings</b><span>click, then press a key</span></div>
32
+ <div class="rows"></div>
33
+ <div class="actions"><button type="button" class="button reset-keys">Reset</button></div>
34
+ </div>
35
+ </div>
36
+ <div class="tip"></div>
37
+ `;