mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 00:20:12 +01:00
This commit is contained in:
parent
c7cba8a831
commit
fbe0f4f303
9 changed files with 34 additions and 26 deletions
|
|
@ -88,7 +88,7 @@ const hasKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "edito
|
||||||
return match;
|
return match;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const onGetConfig = async (isStart: boolean, app: App) => {
|
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");
|
||||||
|
|
@ -142,7 +142,6 @@ export const onGetConfig = async (isStart: boolean, app: App) => {
|
||||||
appearance.onSetappearance(window.siyuan.config.appearance);
|
appearance.onSetappearance(window.siyuan.config.appearance);
|
||||||
initAssets();
|
initAssets();
|
||||||
setInlineStyle();
|
setInlineStyle();
|
||||||
await loadPlugins(app);
|
|
||||||
renderSnippet();
|
renderSnippet();
|
||||||
let resizeTimeout = 0;
|
let resizeTimeout = 0;
|
||||||
window.addEventListener("resize", () => {
|
window.addEventListener("resize", () => {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import {getAllTabs} from "./layout/getAll";
|
||||||
import {getLocalStorage} from "./protyle/util/compatibility";
|
import {getLocalStorage} from "./protyle/util/compatibility";
|
||||||
import {getSearch} from "./util/functions";
|
import {getSearch} from "./util/functions";
|
||||||
import {hideAllElements} from "./protyle/ui/hideElements";
|
import {hideAllElements} from "./protyle/ui/hideElements";
|
||||||
|
import {loadPlugins} from "./plugin/loader";
|
||||||
import "./assets/scss/base.scss";
|
import "./assets/scss/base.scss";
|
||||||
|
|
||||||
export class App {
|
export class App {
|
||||||
|
|
@ -146,7 +147,7 @@ export class App {
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchPost("/api/system/getConf", {}, (response) => {
|
fetchPost("/api/system/getConf", {}, async (response) => {
|
||||||
window.siyuan.config = response.data.conf;
|
window.siyuan.config = response.data.conf;
|
||||||
// 历史数据兼容,202306后可删除
|
// 历史数据兼容,202306后可删除
|
||||||
if (window.siyuan.config.uiLayout.left && !window.siyuan.config.uiLayout.left.data) {
|
if (window.siyuan.config.uiLayout.left && !window.siyuan.config.uiLayout.left.data) {
|
||||||
|
|
@ -163,6 +164,7 @@ export class App {
|
||||||
data: response.data.conf.uiLayout.bottom
|
data: response.data.conf.uiLayout.bottom
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
await loadPlugins(this);
|
||||||
getLocalStorage(() => {
|
getLocalStorage(() => {
|
||||||
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages) => {
|
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages) => {
|
||||||
window.siyuan.languages = lauguages;
|
window.siyuan.languages = lauguages;
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,10 @@ class App {
|
||||||
window.addEventListener("pagehide", () => {
|
window.addEventListener("pagehide", () => {
|
||||||
saveScroll(window.siyuan.mobile.editor.protyle);
|
saveScroll(window.siyuan.mobile.editor.protyle);
|
||||||
}, false);
|
}, false);
|
||||||
fetchPost("/api/system/getConf", {}, (confResponse) => {
|
fetchPost("/api/system/getConf", {}, async (confResponse) => {
|
||||||
confResponse.data.conf.keymap = Constants.SIYUAN_KEYMAP;
|
confResponse.data.conf.keymap = Constants.SIYUAN_KEYMAP;
|
||||||
window.siyuan.config = confResponse.data.conf;
|
window.siyuan.config = confResponse.data.conf;
|
||||||
|
await loadPlugins(this);
|
||||||
getLocalStorage(() => {
|
getLocalStorage(() => {
|
||||||
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages) => {
|
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages) => {
|
||||||
window.siyuan.languages = lauguages;
|
window.siyuan.languages = lauguages;
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ const focusStack = (backStack: IBackStack) => {
|
||||||
|
|
||||||
export const pushBack = () => {
|
export const pushBack = () => {
|
||||||
const protyle = getCurrentEditor().protyle;
|
const protyle = getCurrentEditor().protyle;
|
||||||
|
if (protyle.wysiwyg.element.firstElementChild) {
|
||||||
window.siyuan.backStack.push({
|
window.siyuan.backStack.push({
|
||||||
id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,
|
id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -121,6 +122,7 @@ export const pushBack = () => {
|
||||||
callback: protyle.block.action,
|
callback: protyle.block.action,
|
||||||
zoomId: protyle.block.showAll ? protyle.block.id : undefined
|
zoomId: protyle.block.showAll ? protyle.block.id : undefined
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const goBack = () => {
|
export const goBack = () => {
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,9 @@ import {activeBlur, hideKeyboardToolbar, initKeyboardToolbar} from "./keyboardTo
|
||||||
import {syncGuide} from "../../sync/syncGuide";
|
import {syncGuide} from "../../sync/syncGuide";
|
||||||
import {Inbox} from "../../layout/dock/Inbox";
|
import {Inbox} from "../../layout/dock/Inbox";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
import {loadPlugins} from "../../plugin/loader";
|
|
||||||
|
|
||||||
export const initFramework = async (app: App) => {
|
export const initFramework = (app: App) => {
|
||||||
setInlineStyle();
|
setInlineStyle();
|
||||||
await loadPlugins(app);
|
|
||||||
renderSnippet();
|
renderSnippet();
|
||||||
initKeyboardToolbar();
|
initKeyboardToolbar();
|
||||||
const sidebarElement = document.getElementById("sidebar");
|
const sidebarElement = document.getElementById("sidebar");
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@ export const addStyle = (url: string, id: string) => {
|
||||||
styleElement.rel = "stylesheet";
|
styleElement.rel = "stylesheet";
|
||||||
styleElement.type = "text/css";
|
styleElement.type = "text/css";
|
||||||
styleElement.href = url;
|
styleElement.href = url;
|
||||||
|
const pluginsStyle = document.querySelector("#pluginsStyle");
|
||||||
|
if (pluginsStyle) {
|
||||||
|
pluginsStyle.before(styleElement);
|
||||||
|
} else {
|
||||||
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ export const setInlineStyle = (set = true) => {
|
||||||
if (siyuanStyle) {
|
if (siyuanStyle) {
|
||||||
siyuanStyle.innerHTML = style;
|
siyuanStyle.innerHTML = style;
|
||||||
} else {
|
} else {
|
||||||
document.head.insertAdjacentHTML("beforeend", `<style id="siyuanStyle">${style}</style>`);
|
document.querySelector("#pluginsStyle").insertAdjacentHTML("beforebegin", `<style id="siyuanStyle">${style}</style>`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import {initMessage} from "../dialog/message";
|
||||||
import {getAllTabs} from "../layout/getAll";
|
import {getAllTabs} from "../layout/getAll";
|
||||||
import {getLocalStorage} from "../protyle/util/compatibility";
|
import {getLocalStorage} from "../protyle/util/compatibility";
|
||||||
import {init} from "../window/init";
|
import {init} from "../window/init";
|
||||||
|
import {loadPlugins} from "../plugin/loader";
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
public plugins: import("../plugin").Plugin[] = [];
|
public plugins: import("../plugin").Plugin[] = [];
|
||||||
|
|
@ -127,8 +128,9 @@ class App {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
fetchPost("/api/system/getConf", {}, (response) => {
|
fetchPost("/api/system/getConf", {}, async (response) => {
|
||||||
window.siyuan.config = response.data.conf;
|
window.siyuan.config = response.data.conf;
|
||||||
|
await loadPlugins(this);
|
||||||
getLocalStorage(() => {
|
getLocalStorage(() => {
|
||||||
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages) => {
|
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages) => {
|
||||||
window.siyuan.languages = lauguages;
|
window.siyuan.languages = lauguages;
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ import {renderSnippet} from "../config/util/snippets";
|
||||||
import {getSearch} from "../util/functions";
|
import {getSearch} from "../util/functions";
|
||||||
import {initWindow} from "../boot/onGetConfig";
|
import {initWindow} from "../boot/onGetConfig";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
import {afterLoadPlugin, loadPlugins} from "../plugin/loader";
|
import {afterLoadPlugin} from "../plugin/loader";
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
import {initWindowEvent} from "../boot/globalEvent/event";
|
import {initWindowEvent} from "../boot/globalEvent/event";
|
||||||
|
|
||||||
export const init = async (app: App) => {
|
export const init = (app: App) => {
|
||||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||||
initWindowEvent(app);
|
initWindowEvent(app);
|
||||||
fetchPost("/api/system/getEmojiConf", {}, response => {
|
fetchPost("/api/system/getEmojiConf", {}, response => {
|
||||||
|
|
@ -48,7 +48,6 @@ export const init = async (app: App) => {
|
||||||
appearance.onSetappearance(window.siyuan.config.appearance);
|
appearance.onSetappearance(window.siyuan.config.appearance);
|
||||||
initAssets();
|
initAssets();
|
||||||
setInlineStyle();
|
setInlineStyle();
|
||||||
await loadPlugins(app);
|
|
||||||
renderSnippet();
|
renderSnippet();
|
||||||
let resizeTimeout = 0;
|
let resizeTimeout = 0;
|
||||||
window.addEventListener("resize", () => {
|
window.addEventListener("resize", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue