mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
This commit is contained in:
parent
8985c9b3a9
commit
0ee6f5299e
6 changed files with 14 additions and 27 deletions
|
|
@ -664,12 +664,15 @@ app.whenReady().then(() => {
|
|||
ipcMain.on("siyuan-first-quit", () => {
|
||||
app.exit();
|
||||
});
|
||||
ipcMain.on("siyuan-show", (event) => {
|
||||
showWindow(getWindowByContentId(event.sender.id));
|
||||
});
|
||||
ipcMain.on("siyuan-cmd", (event, cmd) => {
|
||||
console.log(cmd)
|
||||
switch (cmd) {
|
||||
case "openDevTools":
|
||||
event.sender.openDevTools({mode: "bottom"});
|
||||
break;
|
||||
case "show":
|
||||
showWindow(getWindowByContentId(event.sender.id));
|
||||
break;
|
||||
case "hide":
|
||||
getWindowByContentId(event.sender.id).hide();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ export const initWindow = (app: App) => {
|
|||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],
|
||||
zoomIn: focus,
|
||||
});
|
||||
ipcRenderer.send(Constants.SIYUAN_SHOW);
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, "show");
|
||||
}
|
||||
app.plugins.forEach(plugin => {
|
||||
plugin.eventBus.emit("open-siyuan-url-block", {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ export abstract class Constants {
|
|||
public static readonly SIYUAN_DROP_EDITOR: string = "application/siyuan-editor";
|
||||
|
||||
// 渲染进程调主进程
|
||||
public static readonly SIYUAN_SHOW: string = "siyuan-show";
|
||||
public static readonly SIYUAN_CMD: string = "siyuan-cmd";
|
||||
|
||||
public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
|||
import {fetchPost} from "../util/fetch";
|
||||
import {mountHelp} from "../util/mount";
|
||||
/// #if !BROWSER
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
import { ipcRenderer } from "electron";
|
||||
/// #endif
|
||||
/// #endif
|
||||
import {MenuItem} from "../menus/Menu";
|
||||
|
|
@ -87,7 +87,7 @@ export const initStatus = (isWindow = false) => {
|
|||
label: window.siyuan.languages.debug,
|
||||
icon: "iconBug",
|
||||
click: () => {
|
||||
getCurrentWindow().webContents.openDevTools({mode: "bottom"});
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, "openDevTools");
|
||||
}
|
||||
}).element);
|
||||
/// #endif
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ import {MenuItem} from "../../menus/Menu";
|
|||
import {
|
||||
openFileAttr,
|
||||
} from "../../menus/commonMenuItem";
|
||||
/// #if !BROWSER
|
||||
import { ipcRenderer } from "electron";
|
||||
/// #endif
|
||||
import {Constants} from "../../constants";
|
||||
import {matchHotKey} from "../util/hotKey";
|
||||
import {readText, writeText} from "../util/compatibility";
|
||||
|
|
@ -27,6 +24,7 @@ import {transaction} from "../wysiwyg/transaction";
|
|||
import {hideTooltip} from "../../dialog/tooltip";
|
||||
import {commonClick} from "../wysiwyg/commonClick";
|
||||
import {openTitleMenu} from "./openTitleMenu";
|
||||
import {electronUndo} from "../undo";
|
||||
|
||||
export class Title {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -97,20 +95,9 @@ export class Title {
|
|||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
/// #if !BROWSER
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, "undo");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (electronUndo(event)) {
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, "redo");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
/// #endif
|
||||
if (event.key === "ArrowDown") {
|
||||
const noContainerElement = getNoContainerElement(protyle.wysiwyg.element.firstElementChild);
|
||||
// https://github.com/siyuan-note/siyuan/issues/4923
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@ 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";
|
||||
import { ipcRenderer } from "electron";
|
||||
|
||||
interface IOperations {
|
||||
doOperations: IOperation[],
|
||||
|
|
@ -99,13 +97,13 @@ export class Undo {
|
|||
export const electronUndo = (event: KeyboardEvent) => {
|
||||
/// #if !BROWSER
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {
|
||||
getCurrentWindow().webContents.undo();
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, "undo");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {
|
||||
getCurrentWindow().webContents.redo();
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, "redo");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue