Commit ·
ece7379
1
Parent(s): 5a4f444
fix: Ctrl+Z/Y undo/redo works with Arabic keyboard (e.code instead of e.key)
Browse files- src/js/editor.js +3 -2
src/js/editor.js
CHANGED
|
@@ -138,8 +138,9 @@ function initEditor() {
|
|
| 138 |
});
|
| 139 |
|
| 140 |
// Custom Undo/Redo — on editor only, capture phase to beat browser native undo
|
|
|
|
| 141 |
editor.addEventListener('keydown', (e) => {
|
| 142 |
-
if ((e.ctrlKey || e.metaKey) && e.
|
| 143 |
if (_undoStack.length > 0) {
|
| 144 |
e.preventDefault();
|
| 145 |
e.stopImmediatePropagation();
|
|
@@ -147,7 +148,7 @@ function initEditor() {
|
|
| 147 |
return;
|
| 148 |
}
|
| 149 |
}
|
| 150 |
-
if ((e.ctrlKey || e.metaKey) && (e.
|
| 151 |
if (_redoStack.length > 0) {
|
| 152 |
e.preventDefault();
|
| 153 |
e.stopImmediatePropagation();
|
|
|
|
| 138 |
});
|
| 139 |
|
| 140 |
// Custom Undo/Redo — on editor only, capture phase to beat browser native undo
|
| 141 |
+
// Uses e.code instead of e.key so shortcuts work with any keyboard language
|
| 142 |
editor.addEventListener('keydown', (e) => {
|
| 143 |
+
if ((e.ctrlKey || e.metaKey) && e.code === 'KeyZ' && !e.shiftKey) {
|
| 144 |
if (_undoStack.length > 0) {
|
| 145 |
e.preventDefault();
|
| 146 |
e.stopImmediatePropagation();
|
|
|
|
| 148 |
return;
|
| 149 |
}
|
| 150 |
}
|
| 151 |
+
if ((e.ctrlKey || e.metaKey) && (e.code === 'KeyY' || (e.code === 'KeyZ' && e.shiftKey))) {
|
| 152 |
if (_redoStack.length > 0) {
|
| 153 |
e.preventDefault();
|
| 154 |
e.stopImmediatePropagation();
|