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