Added Apple keyboard shortcut Meta+s to save notes.
This commit is contained in:
@@ -53,7 +53,7 @@ Designed to support desktop, mobile and multi-screen devices.
|
|||||||
- View file info and metadata.
|
- View file info and metadata.
|
||||||
- Rename, move or **permanently** remove a model and all of it's related files.
|
- Rename, move or **permanently** remove a model and all of it's related files.
|
||||||
- Read, edit and save notes. (Saved as a `.txt` file beside the model).
|
- Read, edit and save notes. (Saved as a `.txt` file beside the model).
|
||||||
- `Ctrl+S` to save a note when the textarea is in focus.
|
- `Ctrl+s` to save a note when the textarea is in focus.
|
||||||
- Autosave can be enabled in settings. (Note: Once the model info view is closed, the undo history is lost.)
|
- Autosave can be enabled in settings. (Note: Once the model info view is closed, the undo history is lost.)
|
||||||
- Change or remove a model's preview image.
|
- Change or remove a model's preview image.
|
||||||
- View training tags and use the random tag generator to generate prompt ideas.
|
- View training tags and use the random tag generator to generate prompt ideas.
|
||||||
|
|||||||
@@ -59,11 +59,12 @@ class KeyComboListener {
|
|||||||
this.action = action;
|
this.action = action;
|
||||||
this.element = element;
|
this.element = element;
|
||||||
|
|
||||||
element.addEventListener("keydown", (e) => {
|
document.addEventListener("keydown", (e) => {
|
||||||
const code = e.code;
|
const code = e.code;
|
||||||
const keyCodes = this.#keyCodes;
|
const keyCodes = this.#keyCodes;
|
||||||
const combo = this.#combo;
|
const combo = this.#combo;
|
||||||
if (keyCodes.includes(code) && !combo.includes(code)) {
|
if (keyCodes.includes(code) && !combo.includes(code)) {
|
||||||
|
console.log(`COMBO ADD: ${code}, COMBO:${combo}`);
|
||||||
combo.push(code);
|
combo.push(code);
|
||||||
}
|
}
|
||||||
if (combo.length === 0 || keyCodes.length !== combo.length) {
|
if (combo.length === 0 || keyCodes.length !== combo.length) {
|
||||||
@@ -74,13 +75,24 @@ class KeyComboListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (document.activeElement !== this.element) {
|
||||||
|
console.log("not active");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("SAVE");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.action();
|
this.action();
|
||||||
});
|
});
|
||||||
element.addEventListener("keyup", (e) => {
|
document.addEventListener("keyup", (e) => {
|
||||||
|
// Mac keyup doesn't fire when meta key is held: https://stackoverflow.com/a/73419500
|
||||||
const code = e.code;
|
const code = e.code;
|
||||||
this.#combo = this.#combo.filter(x => x !== code);
|
if (code === "MetaLeft" || code === "MetaRight") {
|
||||||
|
this.#combo.length = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.#combo = this.#combo.filter(x => x !== code);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2715,12 +2727,12 @@ class ModelInfo {
|
|||||||
notes,
|
notes,
|
||||||
);
|
);
|
||||||
new KeyComboListener(
|
new KeyComboListener(
|
||||||
["ControlLeft", "KeyS"],
|
["MetaLeft", "KeyS"],
|
||||||
saveDebounce,
|
saveDebounce,
|
||||||
notes,
|
notes,
|
||||||
);
|
);
|
||||||
new KeyComboListener(
|
new KeyComboListener(
|
||||||
["ControlRight", "KeyS"],
|
["MetaRight", "KeyS"],
|
||||||
saveDebounce,
|
saveDebounce,
|
||||||
notes,
|
notes,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user