|
3 | 3 | class="sk-mousetrap-tooltip-wrapper" |
4 | 4 | ref="wrapperElement" |
5 | 5 | :class="[ |
6 | | - isControlKeyPressed && !disabled && highlightEffect !== 'none' ? `sk-mousetrap-highlight-${highlightEffect}` : '' |
| 6 | + isControlKeyPressed && !disabled && highlightEffect !== 'none' ? `sk-mousetrap-highlight-${highlightEffect}` : '', |
7 | 7 | ]" |
8 | 8 | > |
9 | 9 | <slot></slot> |
10 | 10 | <transition name="fade"> |
11 | 11 | <div |
12 | 12 | v-if="showTooltip && isControlKeyPressed && !disabled" |
13 | 13 | class="sk-mousetrap-tooltip" |
14 | | - :class="{ |
15 | | - 'sk-mt-tooltip-top': position === 'top', |
| 14 | + :class="{ |
| 15 | + 'sk-mt-tooltip-top': position === 'top', |
16 | 16 | 'sk-mt-tooltip-bottom': position === 'bottom', |
17 | 17 | 'sk-mt-tooltip-left': position === 'left', |
18 | | - 'sk-mt-tooltip-right': position === 'right' |
| 18 | + 'sk-mt-tooltip-right': position === 'right', |
19 | 19 | }" |
20 | 20 | > |
21 | 21 | {{ formattedHotkey }} |
@@ -70,11 +70,11 @@ export default defineComponent({ |
70 | 70 | const hotkey = Array.isArray(props.hotkey) ? props.hotkey[0] : props.hotkey; |
71 | 71 | // Check if this is a sequence (has spaces) or a combination (has +) |
72 | 72 | if (hotkey.includes(' ')) { |
73 | | - // For sequences like "g h", display as "G, H" |
| 73 | + // For sequences like "g h", display as "g, h" |
74 | 74 | return hotkey |
75 | 75 | .toLowerCase() |
76 | 76 | .split(' ') |
77 | | - .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) |
| 77 | + .map((part) => part.charAt(0) + part.slice(1)) |
78 | 78 | .join(', '); |
79 | 79 | } else { |
80 | 80 | // For combinations like "ctrl+s", display as "Ctrl + S" |
@@ -139,11 +139,12 @@ export default defineComponent({ |
139 | 139 | } |
140 | 140 |
|
141 | 141 | // If still no element found, try the wrapper itself - it might be clickable |
142 | | - if (!clickableElement && ( |
143 | | - wrapperElement.value.hasAttribute('to') || |
144 | | - wrapperElement.value.tagName === 'A' || |
145 | | - wrapperElement.value.classList.contains('v-list-item') |
146 | | - )) { |
| 142 | + if ( |
| 143 | + !clickableElement && |
| 144 | + (wrapperElement.value.hasAttribute('to') || |
| 145 | + wrapperElement.value.tagName === 'A' || |
| 146 | + wrapperElement.value.classList.contains('v-list-item')) |
| 147 | + ) { |
147 | 148 | clickableElement = wrapperElement.value; |
148 | 149 | } |
149 | 150 |
|
@@ -185,32 +186,17 @@ export default defineComponent({ |
185 | 186 | // Register/unregister the hotkey binding |
186 | 187 | const registerHotkey = () => { |
187 | 188 | if (!props.disabled) { |
188 | | - SkldrMouseTrap.bind([ |
189 | | - { |
190 | | - hotkey: props.hotkey, |
191 | | - command: props.command, |
192 | | - callback: handleHotkeyPress, |
193 | | - }, |
194 | | - ]); |
| 189 | + SkldrMouseTrap.addBinding({ |
| 190 | + hotkey: props.hotkey, |
| 191 | + command: props.command, |
| 192 | + callback: handleHotkeyPress, |
| 193 | + }); |
195 | 194 | } |
196 | 195 | }; |
197 | 196 |
|
198 | 197 | const unregisterHotkey = () => { |
199 | | - // Currently, SkldrMouseTrap only supports full reset |
200 | | - // To avoid affecting other hotkeys, we need to track all active hotkeys |
201 | | - // and rebind the ones we want to keep |
202 | | - const currentCommands = [...SkldrMouseTrap.commands]; |
203 | | - const filteredCommands = currentCommands.filter( |
204 | | - (cmd) => JSON.stringify(cmd.hotkey) !== JSON.stringify(props.hotkey) |
205 | | - ); |
206 | | -
|
207 | | - if (filteredCommands.length !== currentCommands.length) { |
208 | | - // There was a match - we need to reset and rebind the remaining hotkeys |
209 | | - SkldrMouseTrap.reset(); |
210 | | -
|
211 | | - // Rebind all the other hotkeys |
212 | | - // Note: this approach has limitations since we don't have access to the callbacks |
213 | | - // In a future enhancement, SkldrMouseTrap should be updated to support selective unbinding |
| 198 | + if (!props.disabled) { |
| 199 | + SkldrMouseTrap.removeBinding(props.hotkey); |
214 | 200 | } |
215 | 201 | }; |
216 | 202 |
|
|
0 commit comments