mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
This commit is contained in:
parent
9cae635647
commit
4bc21c493b
8 changed files with 12 additions and 13 deletions
|
|
@ -57,7 +57,7 @@ const exitApp = (port, errorWindowId) => {
|
||||||
// 关闭端口相同的所有非主窗口
|
// 关闭端口相同的所有非主窗口
|
||||||
BrowserWindow.getAllWindows().forEach((item) => {
|
BrowserWindow.getAllWindows().forEach((item) => {
|
||||||
try {
|
try {
|
||||||
const currentURL = new URL(item.getURL())
|
const currentURL = new URL(item.getURL());
|
||||||
if (port.toString() === currentURL.port.toString()) {
|
if (port.toString() === currentURL.port.toString()) {
|
||||||
if (currentURL.href.indexOf("/stage/build/app/?v=") > -1) {
|
if (currentURL.href.indexOf("/stage/build/app/?v=") > -1) {
|
||||||
mainWindow = item;
|
mainWindow = item;
|
||||||
|
|
@ -114,7 +114,7 @@ const exitApp = (port, errorWindowId) => {
|
||||||
globalShortcut.unregisterAll();
|
globalShortcut.unregisterAll();
|
||||||
writeLog("exited ui");
|
writeLog("exited ui");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const getServer = (port = kernelPort) => {
|
const getServer = (port = kernelPort) => {
|
||||||
return "http://127.0.0.1:" + port;
|
return "http://127.0.0.1:" + port;
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ export const exitSiYuan = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const transactionError = (data: { code: number, data: string }) => {
|
export const transactionError = () => {
|
||||||
if (document.getElementById("transactionError")) {
|
if (document.getElementById("transactionError")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,14 +136,14 @@ export const workspaceMenu = (rect: DOMRect) => {
|
||||||
showMessage(window.siyuan.languages.duplicate);
|
showMessage(window.siyuan.languages.duplicate);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
if (hadName) {
|
if (hadName) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
||||||
name: value,
|
name: value,
|
||||||
layout: exportLayout(false, undefined, true)
|
layout: exportLayout(false, undefined, true)
|
||||||
})
|
});
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
saveDialog.destroy();
|
saveDialog.destroy();
|
||||||
});
|
});
|
||||||
|
|
@ -169,7 +169,7 @@ export const workspaceMenu = (rect: DOMRect) => {
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetchPost("/api/system/setUILayout", {layout: item.layout}, () => {
|
fetchPost("/api/system/setUILayout", {layout: item.layout}, () => {
|
||||||
|
|
|
||||||
|
|
@ -959,7 +959,7 @@ export class Toolbar {
|
||||||
const msgId = showMessage(window.siyuan.languages.exporting, 0);
|
const msgId = showMessage(window.siyuan.languages.exporting, 0);
|
||||||
if (renderElement.getAttribute("data-subtype") === "plantuml") {
|
if (renderElement.getAttribute("data-subtype") === "plantuml") {
|
||||||
fetch(renderElement.querySelector("img").getAttribute("src")).then(function (response) {
|
fetch(renderElement.querySelector("img").getAttribute("src")).then(function (response) {
|
||||||
return response.blob()
|
return response.blob();
|
||||||
}).then(function (blob) {
|
}).then(function (blob) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", blob);
|
formData.append("file", blob);
|
||||||
|
|
|
||||||
|
|
@ -460,7 +460,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
|
|
||||||
if ((event.shiftKey && !event.altKey && !isCtrl(event) && (event.key === "Home" || event.key === "End") && isMac()) ||
|
if ((event.shiftKey && !event.altKey && !isCtrl(event) && (event.key === "Home" || event.key === "End") && isMac()) ||
|
||||||
(event.shiftKey && !event.altKey && isCtrl(event) && (event.key === "Home" || event.key === "End") && !isMac())) {
|
(event.shiftKey && !event.altKey && isCtrl(event) && (event.key === "Home" || event.key === "End") && !isMac())) {
|
||||||
const topElement = hasTopClosestByAttribute(nodeElement, "data-node-id", null)
|
const topElement = hasTopClosestByAttribute(nodeElement, "data-node-id", null);
|
||||||
if (topElement) {
|
if (topElement) {
|
||||||
topElement.classList.add("protyle-wysiwyg--select");
|
topElement.classList.add("protyle-wysiwyg--select");
|
||||||
let nextElement = event.key === "Home" ? topElement.previousElementSibling : topElement.nextElementSibling;
|
let nextElement = event.key === "Home" ? topElement.previousElementSibling : topElement.nextElementSibling;
|
||||||
|
|
@ -469,9 +469,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
nextElement = event.key === "Home" ? nextElement.previousElementSibling : nextElement.nextElementSibling;
|
nextElement = event.key === "Home" ? nextElement.previousElementSibling : nextElement.nextElementSibling;
|
||||||
}
|
}
|
||||||
if (event.key === "Home") {
|
if (event.key === "Home") {
|
||||||
protyle.wysiwyg.element.firstElementChild.scrollIntoView()
|
protyle.wysiwyg.element.firstElementChild.scrollIntoView();
|
||||||
} else {
|
} else {
|
||||||
protyle.wysiwyg.element.lastElementChild.scrollIntoView(false)
|
protyle.wysiwyg.element.lastElementChild.scrollIntoView(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {ipcRenderer} from "electron";
|
import {ipcRenderer} from "electron";
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
|
||||||
/// #endif
|
/// #endif
|
||||||
import {processMessage} from "./processMessage";
|
import {processMessage} from "./processMessage";
|
||||||
import {kernelError} from "../dialog/processSystem";
|
import {kernelError} from "../dialog/processSystem";
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
|
||||||
if (!top && getSelection().rangeCount > 0 && hasClosestBlock(getSelection().getRangeAt(0).startContainer)) {
|
if (!top && getSelection().rangeCount > 0 && hasClosestBlock(getSelection().getRangeAt(0).startContainer)) {
|
||||||
const editorElement = protyle.contentElement;
|
const editorElement = protyle.contentElement;
|
||||||
const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top;
|
const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top;
|
||||||
let top = 0
|
let top = 0;
|
||||||
if (cursorTop < 0) {
|
if (cursorTop < 0) {
|
||||||
top = editorElement.scrollTop + cursorTop;
|
top = editorElement.scrollTop + cursorTop;
|
||||||
} else if (cursorTop > editorElement.clientHeight - 74) { // 74 = 移动端底部 + 段落块高度
|
} else if (cursorTop > editorElement.clientHeight - 74) { // 74 = 移动端底部 + 段落块高度
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ export const onGetConfig = (isStart: boolean) => {
|
||||||
try {
|
try {
|
||||||
JSONToLayout(isStart);
|
JSONToLayout(isStart);
|
||||||
if (window.JSAndroid) {
|
if (window.JSAndroid) {
|
||||||
window.openFileByURL(window.JSAndroid.getBlockURL())
|
window.openFileByURL(window.JSAndroid.getBlockURL());
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
resetLayout();
|
resetLayout();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue