diff options
| author | Eloy Robillard <eloy.robillard@gmail.com> | 2024-03-18 12:19:27 +0100 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-18 11:19:27 +0000 | 
| commit | 7ee76d708934adeef06479f7757beb22c6c01d14 (patch) | |
| tree | c03ad4227e8a71939bb5efddffe57fa21a75b043 /ext/js/input | |
| parent | 4fe881d68d4c1182bee2e78a559c2064aaf48b0d (diff) | |
Add an option to allow both viewing and adding duplicates (#693)
* Detect duplicates when checking if can add note
* Display the stacked add buttons
Diffstat (limited to 'ext/js/input')
| -rw-r--r-- | ext/js/input/hotkey-help-controller.js | 32 | 
1 files changed, 32 insertions, 0 deletions
| diff --git a/ext/js/input/hotkey-help-controller.js b/ext/js/input/hotkey-help-controller.js index 16f3d26f..b495365d 100644 --- a/ext/js/input/hotkey-help-controller.js +++ b/ext/js/input/hotkey-help-controller.js @@ -181,4 +181,36 @@ export class HotkeyHelpController {              defaultAttributeValues          };      } + +    /** +     * @param {HTMLElement} node +     * @returns {?string} +     */ +    getHotkeyLabel(node) { +        const {hotkey} = node.dataset; +        if (typeof hotkey !== 'string') { return null; } + +        const data = /** @type {unknown} */ (parseJson(hotkey)); +        if (!Array.isArray(data)) { return null; } + +        const values = /** @type {unknown[]} */ (data)[2]; +        if (typeof values !== 'string') { return null; } + +        return values; +    } + +    /** +     * @param {HTMLElement} node +     * @param {string} label +     */ +    setHotkeyLabel(node, label) { +        const {hotkey} = node.dataset; +        if (typeof hotkey !== 'string') { return; } + +        const data = /** @type {unknown} */ (parseJson(hotkey)); +        if (!Array.isArray(data)) { return; } + +        data[2] = label; +        node.dataset.hotkey = JSON.stringify(data); +    }  } |