-import {Component} from "./component";
+import {Component} from './component';
function reverseMap(map) {
const reversed = {};
return reversed;
}
-
export class Shortcuts extends Component {
setup() {
setupListeners() {
window.addEventListener('keydown', event => {
-
if (event.target.closest('input, select, textarea')) {
return;
}
window.addEventListener('keydown', event => {
if (event.key === '?') {
- this.hintsShowing ? this.hideHints() : this.showHints();
+ const action = this.hintsShowing ? this.hideHints : this.showHints;
+ action();
}
});
}
* @param {KeyboardEvent} event
*/
handleShortcutPress(event) {
-
const keys = [
event.ctrlKey ? 'Ctrl' : '',
event.metaKey ? 'Cmd' : '',
return true;
}
- console.error(`Shortcut attempted to be ran for element type that does not have handling setup`, el);
+ console.error('Shortcut attempted to be ran for element type that does not have handling setup', el);
return false;
}
const linkage = document.createElement('div');
linkage.classList.add('shortcut-linkage');
- linkage.style.left = targetBounds.x + 'px';
- linkage.style.top = targetBounds.y + 'px';
- linkage.style.width = targetBounds.width + 'px';
- linkage.style.height = targetBounds.height + 'px';
+ linkage.style.left = `${targetBounds.x}px`;
+ linkage.style.top = `${targetBounds.y}px`;
+ linkage.style.width = `${targetBounds.width}px`;
+ linkage.style.height = `${targetBounds.height}px`;
wrapper.append(label, linkage);
this.hintsShowing = false;
}
-}
\ No newline at end of file
+
+}