aboutsummaryrefslogtreecommitdiff
path: root/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js')
-rw-r--r--extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js67
1 files changed, 39 insertions, 28 deletions
diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
index ed3e52bc..29f43a3f 100644
--- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
+++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
@@ -608,29 +608,34 @@ onUiLoaded(async() => {
// Handle keydown events
function handleKeyDown(event) {
+ // Disable key locks to make pasting from the buffer work correctly
+ if ((event.ctrlKey && event.code === 'KeyV') || event.code === "F5") {
+ return;
+ }
+
// before activating shortcut, ensure user is not actively typing in an input field
- if(event.target.nodeName === 'TEXTAREA' || event.target.nodeName === 'INPUT') {
- event.preventDefault;
- } else {
+ if (event.target.nodeName === 'TEXTAREA' || event.target.nodeName === 'INPUT') {
+ return;
+ }
- const hotkeyActions = {
- [hotkeysConfig.canvas_hotkey_reset]: resetZoom,
- [hotkeysConfig.canvas_hotkey_overlap]: toggleOverlap,
- [hotkeysConfig.canvas_hotkey_fullscreen]: fitToScreen
- };
- const action = hotkeyActions[event.code];
- if (action) {
- event.preventDefault();
- action(event);
- }
+ const hotkeyActions = {
+ [hotkeysConfig.canvas_hotkey_reset]: resetZoom,
+ [hotkeysConfig.canvas_hotkey_overlap]: toggleOverlap,
+ [hotkeysConfig.canvas_hotkey_fullscreen]: fitToScreen
+ };
- if (
- isModifierKey(event, hotkeysConfig.canvas_hotkey_zoom) ||
- isModifierKey(event, hotkeysConfig.canvas_hotkey_adjust)
- ) {
- event.preventDefault();
- }
+ const action = hotkeyActions[event.code];
+ if (action) {
+ event.preventDefault();
+ action(event);
+ }
+
+ if (
+ isModifierKey(event, hotkeysConfig.canvas_hotkey_zoom) ||
+ isModifierKey(event, hotkeysConfig.canvas_hotkey_adjust)
+ ) {
+ event.preventDefault();
}
}
@@ -692,16 +697,22 @@ onUiLoaded(async() => {
// Handle the move event for pan functionality. Updates the panX and panY variables and applies the new transform to the target element.
function handleMoveKeyDown(e) {
+
+ // Disable key locks to make pasting from the buffer work correctly
+ if ((e.ctrlKey && e.code === 'KeyV') || e.code === "F5") {
+ return;
+ }
+
+ // before activating shortcut, ensure user is not actively typing in an input field
+ if (e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'INPUT') {
+ return;
+ }
+
if (e.code === hotkeysConfig.canvas_hotkey_move) {
- // before activating shortcut, ensure user is not actively typing in an input field
- if(e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'INPUT') {
- event.preventDefault;
- } else {
- if (!e.ctrlKey && !e.metaKey && isKeyDownHandlerAttached) {
- e.preventDefault();
- document.activeElement.blur();
- isMoving = true;
- }
+ if (!e.ctrlKey && !e.metaKey && isKeyDownHandlerAttached) {
+ e.preventDefault();
+ document.activeElement.blur();
+ isMoving = true;
}
}
}