mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
This commit is contained in:
parent
4ecb555c1f
commit
aa56c16830
5 changed files with 20 additions and 7 deletions
|
|
@ -26,6 +26,7 @@ import {initBar} from "../layout/topBar";
|
||||||
import {setProxy} from "../config/util/setProxy";
|
import {setProxy} from "../config/util/setProxy";
|
||||||
import {openChangelog} from "./openChangelog";
|
import {openChangelog} from "./openChangelog";
|
||||||
import {getIdFromSYProtocol, isSYProtocol} from "../util/pathName";
|
import {getIdFromSYProtocol, isSYProtocol} from "../util/pathName";
|
||||||
|
import {App} from "../index";
|
||||||
|
|
||||||
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
||||||
if (key1 === "general") {
|
if (key1 === "general") {
|
||||||
|
|
@ -84,7 +85,7 @@ const hasKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "edito
|
||||||
return match;
|
return match;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const onGetConfig = (isStart: boolean) => {
|
export const onGetConfig = (isStart: boolean, app:App) => {
|
||||||
const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general");
|
const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general");
|
||||||
const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general");
|
const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general");
|
||||||
const matchKeymap3 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.insert, "editor", "insert");
|
const matchKeymap3 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.insert, "editor", "insert");
|
||||||
|
|
@ -140,7 +141,7 @@ export const onGetConfig = (isStart: boolean) => {
|
||||||
resetLayout();
|
resetLayout();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
initBar();
|
initBar(app);
|
||||||
setProxy();
|
setProxy();
|
||||||
initStatus();
|
initStatus();
|
||||||
initWindow();
|
initWindow();
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ export class App {
|
||||||
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
||||||
window.siyuan.user = userResponse.data;
|
window.siyuan.user = userResponse.data;
|
||||||
loadPlugins(siyuanApp);
|
loadPlugins(siyuanApp);
|
||||||
onGetConfig(response.data.start);
|
onGetConfig(response.data.start, siyuanApp);
|
||||||
account.onSetaccount();
|
account.onSetaccount();
|
||||||
resizeDrag();
|
resizeDrag();
|
||||||
setTitle(window.siyuan.languages.siyuanNote);
|
setTitle(window.siyuan.languages.siyuanNote);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {MenuItem} from "../menus/Menu";
|
||||||
import {setMode} from "../util/assets";
|
import {setMode} from "../util/assets";
|
||||||
import {openSetting} from "../config";
|
import {openSetting} from "../config";
|
||||||
import {openSearch} from "../search/spread";
|
import {openSearch} from "../search/spread";
|
||||||
|
import {App} from "../index";
|
||||||
|
|
||||||
export const updateEditModeElement = () => {
|
export const updateEditModeElement = () => {
|
||||||
const target = document.querySelector("#barReadonly");
|
const target = document.querySelector("#barReadonly");
|
||||||
|
|
@ -23,7 +24,7 @@ export const updateEditModeElement = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initBar = () => {
|
export const initBar = (app: App) => {
|
||||||
const toolbarElement = document.getElementById("toolbar");
|
const toolbarElement = document.getElementById("toolbar");
|
||||||
toolbarElement.innerHTML = `
|
toolbarElement.innerHTML = `
|
||||||
<div id="barWorkspace" class="toolbar__item">
|
<div id="barWorkspace" class="toolbar__item">
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,5 @@ export const API = {
|
||||||
Plugin: Plugin,
|
Plugin: Plugin,
|
||||||
confirm: confirmDialog,
|
confirm: confirmDialog,
|
||||||
showMessage,
|
showMessage,
|
||||||
Dialog
|
Dialog,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,19 @@ export class Plugin {
|
||||||
this.eventBus = new EventBus(options.name);
|
this.eventBus = new EventBus(options.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getData() {
|
public addTopBar(options: {
|
||||||
|
icon: string,
|
||||||
|
title: string,
|
||||||
|
position: "right",
|
||||||
|
callback: (evt: MouseEvent) => void
|
||||||
|
}) {
|
||||||
|
const iconElement = document.createElement("div");
|
||||||
|
iconElement.className = "toolbar__item b3-tooltips b3-tooltips__sw";
|
||||||
|
iconElement.setAttribute("aria-label", options.title);
|
||||||
|
iconElement.innerHTML = options.icon.startsWith("icon") ? `<svg><use xlink:href="#${options.icon}"></use></svg>` : options.icon;
|
||||||
|
iconElement.addEventListener("click", options.callback);
|
||||||
|
document.querySelector("#" + (options.position === "right" ? "barSearch" : "drag")).before(iconElement);
|
||||||
|
return iconElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public onload() {
|
public onload() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue