mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-15 11:38:06 +01:00
This commit is contained in:
parent
455bb1c050
commit
b6cf45b003
3 changed files with 33 additions and 14 deletions
|
|
@ -39,6 +39,7 @@ import {escapeHtml} from "../../util/escape";
|
|||
import {hideElements} from "../ui/hideElements";
|
||||
import {linkMenu} from "../../menus/protyle";
|
||||
import {renderAssetsPreview} from "../../asset/renderAssets";
|
||||
import {electronUndo} from "../undo";
|
||||
|
||||
export class Toolbar {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -866,18 +867,7 @@ export class Toolbar {
|
|||
if (event.isComposing) {
|
||||
return;
|
||||
}
|
||||
/// #if !BROWSER
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {
|
||||
getCurrentWindow().webContents.undo();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {
|
||||
getCurrentWindow().webContents.redo();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
/// #endif
|
||||
electronUndo(event);
|
||||
if (event.key === "Escape" || matchHotKey("⌘↩", event)) {
|
||||
this.subElement.classList.add("fn__none");
|
||||
this.subElement.querySelector('[data-type="pin"]').classList.remove("block__icon--active");
|
||||
|
|
|
|||
|
|
@ -3,13 +3,17 @@ import {preventScroll} from "../scroll/preventScroll";
|
|||
import {Constants} from "../../constants";
|
||||
import {hideElements} from "../ui/hideElements";
|
||||
import {scrollCenter} from "../../util/highlightById";
|
||||
/// #if !BROWSER
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
/// #endif
|
||||
import {matchHotKey} from "../util/hotKey";
|
||||
|
||||
interface IOperations {
|
||||
doOperations: IOperation[],
|
||||
undoOperations: IOperation[]
|
||||
}
|
||||
|
||||
class Undo {
|
||||
export class Undo {
|
||||
private hasUndo = false;
|
||||
private redoStack: IOperations[];
|
||||
private undoStack: IOperations[];
|
||||
|
|
@ -86,4 +90,17 @@ class Undo {
|
|||
}
|
||||
}
|
||||
|
||||
export {Undo};
|
||||
export const electronUndo = (event: KeyboardEvent) => {
|
||||
/// #if !BROWSER
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {
|
||||
getCurrentWindow().webContents.undo();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {
|
||||
getCurrentWindow().webContents.redo();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
/// #endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue