mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
This commit is contained in:
parent
e103b5c2f0
commit
98a9635dd3
2 changed files with 29 additions and 4 deletions
|
@ -6,7 +6,7 @@ import {isMobile, isWindow} from "../util/functions";
|
|||
import {Custom} from "../layout/dock/Custom";
|
||||
import {getAllModels} from "../layout/getAll";
|
||||
import {Tab} from "../layout/Tab";
|
||||
import {setPanelFocus} from "../layout/util";
|
||||
import {resizeTopBar, setPanelFocus} from "../layout/util";
|
||||
import {getDockByType} from "../layout/tabUtil";
|
||||
///#else
|
||||
import {MobileCustom} from "../mobile/dock/MobileCustom";
|
||||
|
@ -194,6 +194,17 @@ export class Plugin {
|
|||
iconElement.innerHTML = options.icon.startsWith("icon") ? `<svg><use xlink:href="#${options.icon}"></use></svg>` : options.icon;
|
||||
iconElement.addEventListener("click", options.callback);
|
||||
iconElement.setAttribute("data-location", options.position || "right");
|
||||
resizeTopBar();
|
||||
}
|
||||
if (isMobile()) {
|
||||
if (!window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(iconElement.id)) {
|
||||
document.querySelector("#menuAbout")?.after(iconElement);
|
||||
}
|
||||
} else if (!isWindow()) {
|
||||
if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(iconElement.id)) {
|
||||
iconElement.classList.add("fn__none");
|
||||
}
|
||||
document.querySelector("#" + (iconElement.getAttribute("data-location") === "right" ? "barPlugins" : "drag"))?.before(iconElement);
|
||||
}
|
||||
this.topBarIcons.push(iconElement);
|
||||
return iconElement;
|
||||
|
@ -206,6 +217,14 @@ export class Plugin {
|
|||
/// #if !MOBILE
|
||||
options.element.setAttribute("data-location", options.position || "right");
|
||||
this.statusBarIcons.push(options.element);
|
||||
const statusElement = document.getElementById("status");
|
||||
if (statusElement) {
|
||||
if (options.element.getAttribute("data-location") === "right") {
|
||||
statusElement.insertAdjacentElement("beforeend", options.element);
|
||||
} else {
|
||||
statusElement.insertAdjacentElement("afterbegin", options.element);
|
||||
}
|
||||
}
|
||||
return options.element;
|
||||
/// #endif
|
||||
}
|
||||
|
|
|
@ -129,6 +129,9 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
|||
|
||||
if (!isWindow() || isMobile()) {
|
||||
plugin.topBarIcons.forEach(element => {
|
||||
if (document.contains(element)) {
|
||||
return;
|
||||
}
|
||||
if (isMobile()) {
|
||||
if (!window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
|
||||
document.querySelector("#menuAbout").after(element);
|
||||
|
@ -144,6 +147,9 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
|||
/// #if !MOBILE
|
||||
resizeTopBar();
|
||||
plugin.statusBarIcons.forEach(element => {
|
||||
if (document.contains(element)) {
|
||||
return;
|
||||
}
|
||||
const statusElement = document.getElementById("status");
|
||||
if (element.getAttribute("data-location") === "right") {
|
||||
statusElement.insertAdjacentElement("beforeend", element);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue