mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-07-03 14:09:06 +02:00
This commit is contained in:
@@ -17,7 +17,7 @@ import {Setting} from "./Setting";
|
||||
import {clearOBG} from "../layout/dock/util";
|
||||
import {Constants} from "../constants";
|
||||
import {uninstall} from "./uninstall";
|
||||
import {afterLoadPlugin, loadPlugins} from "./loader";
|
||||
import {addPluginDock, afterLoadPlugin, loadPlugins} from "./loader";
|
||||
import {normalizeStoragePath} from "../util/pathName";
|
||||
|
||||
export class Plugin {
|
||||
@@ -450,6 +450,7 @@ export class Plugin {
|
||||
}
|
||||
window.siyuan.config.keymap.plugin[this.name][type2]["default"] = hotkey;
|
||||
}
|
||||
addPluginDock(this);
|
||||
return this.docks[type2];
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,8 @@ export const loadPlugin = async (app: App, item: IPluginData) => {
|
||||
const updateDock = (dockItem: Config.IUILayoutDockTab[], index: number, plugin: Plugin, type: string) => {
|
||||
const dockKeys = Object.keys(plugin.docks);
|
||||
dockItem.forEach((tabItem: Config.IUILayoutDockTab, tabIndex: number) => {
|
||||
if (dockKeys.includes(tabItem.type)) {
|
||||
if (dockKeys.includes(tabItem.type) &&
|
||||
!document.querySelector(`.dock .dock__item[data-type="${tabItem.type}"]`)) {
|
||||
if (type === "Left") {
|
||||
plugin.docks[tabItem.type].config.position = index === 0 ? "LeftTop" : "LeftBottom";
|
||||
} else if (type === "Right") {
|
||||
@@ -170,11 +171,14 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
||||
}
|
||||
});
|
||||
/// #endif
|
||||
if (isWindow()) {
|
||||
addPluginDock(plugin);
|
||||
};
|
||||
|
||||
export const addPluginDock = (plugin: Plugin) => {
|
||||
/// #if !MOBILE
|
||||
if (isWindow() || !window.siyuan.layout.leftDock) {
|
||||
return;
|
||||
}
|
||||
|
||||
/// #if !MOBILE
|
||||
window.siyuan.config.uiLayout.left.data.forEach((dockItem: Config.IUILayoutDockTab[], index: number) => {
|
||||
updateDock(dockItem, index, plugin, "Left");
|
||||
});
|
||||
@@ -185,6 +189,9 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
||||
updateDock(dockItem, index, plugin, "Bottom");
|
||||
});
|
||||
Object.keys(plugin.docks).forEach(key => {
|
||||
if (document.querySelector(`.dock .dock__item[data-type="${key}"]`)) {
|
||||
return;
|
||||
}
|
||||
if (window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name] && window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key]) {
|
||||
plugin.docks[key].config = window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user