This commit is contained in:
Vanessa 2023-05-26 17:03:35 +08:00
parent ea589fef7b
commit 7e114a6671
6 changed files with 21 additions and 16 deletions

View file

@ -129,7 +129,7 @@ export class BlockPanel {
target = target.parentElement;
}
});
/// if !MOBILE
/// #if !MOBILE
moveResize(this.element, (type: string) => {
if (type !== "move") {
this.editors.forEach(item => {

View file

@ -1,5 +1,5 @@
import {genUUID} from "../util/genID";
/// if !MOBILE
/// #if !MOBILE
import {moveResize} from "./moveResize";
/// #endif
import {isMobile} from "../util/functions";
@ -59,7 +59,7 @@ export class Dialog {
this.element.classList.add("b3-dialog--open");
});
}
/// if !MOBILE
/// #if !MOBILE
moveResize(this.element.querySelector(".b3-dialog__container"));
/// #endif
}

View file

@ -22,7 +22,7 @@ import {getSearch} from "../util/functions";
import {initRightMenu} from "./menu";
import {openChangelog} from "../boot/openChangelog";
import {registerServiceWorker} from "../util/serviceWorker";
import {loadPlugins} from "../plugin/loader";
import {afterLoadPlugin, loadPlugins} from "../plugin/loader";
class App {
public plugins: import("../plugin").Plugin[] = [];
@ -81,6 +81,9 @@ class App {
initFramework(this);
initRightMenu(this);
openChangelog();
this.plugins.forEach(item => {
afterLoadPlugin(item);
});
});
});
});

View file

@ -68,6 +68,7 @@ export class Plugin {
const iconElement = document.createElement("div");
if (isMobile()) {
iconElement.className = "b3-menu__item";
iconElement.setAttribute("data-menu", "true");
iconElement.innerHTML = (options.icon.startsWith("icon") ? `<svg class="b3-menu__icon"><use xlink:href="#${options.icon}"></use></svg>` : options.icon) +
`<span class="b3-menu__label">${options.title}</span>`;
iconElement.addEventListener("click", options.callback);

View file

@ -104,19 +104,20 @@ export const afterLoadPlugin = (plugin: Plugin) => {
console.error(`plugin ${plugin.name} onLayoutReady error:`, e);
}
if (!isWindow() || isMobile()) {
plugin.topBarIcons.forEach(element => {
if (isMobile()) {
document.querySelector("#menuAbout").after(element);
} else if (!isWindow()) {
document.querySelector("#" + (element.getAttribute("data-position") === "right" ? "barSearch" : "drag")).before(element);
}
});
}
if (isWindow()) {
return;
}
plugin.topBarIcons.forEach(element => {
if (isMobile()) {
document.querySelector("#menuAbout").after(element);
} else if (!isWindow()) {
document.querySelector("#" + (element.getAttribute("data-position") === "right" ? "barSearch" : "drag")).before(element);
}
});
/// if !MOBILE
/// #if !MOBILE
window.siyuan.config.uiLayout.left.data.forEach((dockItem: IDockTab[], index: number) => {
updateDock(dockItem, index, plugin, "Left");
});
@ -157,5 +158,5 @@ export const afterLoadPlugin = (plugin: Plugin) => {
}], dock.config.position === "RightBottom" ? 1 : 0, dock.config.index);
}
});
/// endif
/// #endif
};

View file

@ -26,7 +26,7 @@ import {blockRender} from "../markdown/blockRender";
/// #if !BROWSER
import {openBy} from "../../editor/util";
/// #endif
/// if !MOBILE
/// #if !MOBILE
import {moveResize} from "../../dialog/moveResize";
/// #endif
import {fetchPost} from "../../util/fetch";
@ -1013,7 +1013,7 @@ export class Toolbar {
});
}, Constants.TIMEOUT_LOAD);
};
/// if !MOBILE
/// #if !MOBILE
moveResize(this.subElement, () => {
const pinElement = headerElement.querySelector('[data-type="pin"]');
pinElement.classList.add("block__icon--active");