|
445 | 445 | } |
446 | 446 | window.document.addEventListener("click", onDocumentClick); |
447 | 447 | window.document.addEventListener("keydown", function (e) { |
448 | | - // for undo. refer to LivePreviewEdit.js file 'handleLivePreviewEditOperation' function |
449 | | - if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z" && !e.shiftKey) { |
450 | | - MessageBroker.send({ |
451 | | - livePreviewEditEnabled: true, |
452 | | - undoLivePreviewOperation: true |
453 | | - }); |
454 | | - } |
455 | | - |
456 | | - // for redo - supports both Ctrl+Y and Ctrl+Shift+Z (Cmd+Y and Cmd+Shift+Z on Mac) |
457 | | - if ((e.ctrlKey || e.metaKey) && (e.key.toLowerCase() === "y" || (e.key.toLowerCase() === "z" && e.shiftKey))) { |
458 | | - MessageBroker.send({ |
459 | | - livePreviewEditEnabled: true, |
460 | | - redoLivePreviewOperation: true |
461 | | - }); |
462 | | - } |
463 | | - |
464 | 448 | // Check if user is editing text content - if so, allow normal text cut |
465 | 449 | // Get the truly active element, even if inside shadow roots |
466 | 450 | let activeElement = document.activeElement; |
467 | 451 |
|
468 | 452 | const isEditingText = activeElement && ( |
469 | 453 | // Check for standard form input elements |
470 | | - ['INPUT', 'TEXTAREA', 'SELECT', 'OPTION'].includes(activeElement.tagName) || |
| 454 | + ['INPUT', 'TEXTAREA'].includes(activeElement.tagName) || |
471 | 455 | // Check for contentEditable elements |
472 | 456 | activeElement.isContentEditable || |
473 | 457 | // Check for ARIA roles that indicate text input |
|
476 | 460 | (activeElement.hasAttribute("contenteditable") && activeElement.hasAttribute("data-brackets-id")) |
477 | 461 | ); |
478 | 462 | const isInEditMode = window._LD && window._LD.getMode && window._LD.getMode() === 'edit'; |
| 463 | + |
| 464 | + // for undo. refer to LivePreviewEdit.js file 'handleLivePreviewEditOperation' function |
| 465 | + if (!isEditingText && isInEditMode && (e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z" && !e.shiftKey) { |
| 466 | + MessageBroker.send({ |
| 467 | + livePreviewEditEnabled: true, |
| 468 | + undoLivePreviewOperation: true |
| 469 | + }); |
| 470 | + } |
| 471 | + |
| 472 | + // for redo - supports both Ctrl+Y and Ctrl+Shift+Z (Cmd+Y and Cmd+Shift+Z on Mac) |
| 473 | + if (!isEditingText && isInEditMode && (e.ctrlKey || e.metaKey) && |
| 474 | + (e.key.toLowerCase() === "y" || (e.key.toLowerCase() === "z" && e.shiftKey))) { |
| 475 | + MessageBroker.send({ |
| 476 | + livePreviewEditEnabled: true, |
| 477 | + redoLivePreviewOperation: true |
| 478 | + }); |
| 479 | + } |
| 480 | + |
479 | 481 | // Cut: Ctrl+X / Cmd+X - operates on selected element |
480 | 482 | if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "x") { |
481 | 483 |
|
|
0 commit comments