fixing the copy/paste function, correct code

This commit is contained in:
Danil Boldyrev 2023-07-02 19:20:49 +03:00
parent 8a07c59baa
commit 8519d52ef5

View File

@ -608,10 +608,16 @@ 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,
@ -632,7 +638,6 @@ onUiLoaded(async() => {
event.preventDefault();
}
}
}
// Get Mouse position
function getMousePosition(e) {
@ -692,11 +697,18 @@ 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) {
if (e.code === hotkeysConfig.canvas_hotkey_move) {
// 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') {
event.preventDefault;
} else {
if (e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'INPUT') {
return;
}
if (e.code === hotkeysConfig.canvas_hotkey_move) {
if (!e.ctrlKey && !e.metaKey && isKeyDownHandlerAttached) {
e.preventDefault();
document.activeElement.blur();
@ -704,7 +716,6 @@ onUiLoaded(async() => {
}
}
}
}
function handleMoveKeyUp(e) {
if (e.code === hotkeysConfig.canvas_hotkey_move) {