This commit is contained in:
Vanessa 2022-07-31 10:56:03 +08:00
parent ffc9563f6c
commit 3d1de2ad56
3 changed files with 95 additions and 0 deletions

View file

@ -14,6 +14,8 @@ import {MobileFiles} from "./MobileFiles";
import {MobileOutline} from "./MobileOutline";
import {hasTopClosestByTag} from "../../protyle/util/hasClosest";
import {MobileBacklinks} from "./MobileBacklinks";
import {MobileBookmarks} from "./MobileBookmarks";
import {MobileTags} from "./MobileTags";
export const initFramework = () => {
setInlineStyle();
@ -21,6 +23,8 @@ export const initFramework = () => {
const sidebarElement = document.getElementById("sidebar");
let outline: MobileOutline;
let backlink: MobileBacklinks;
let bookmark: MobileBookmarks
let tag: MobileTags
sidebarElement.querySelector(".toolbar--border").addEventListener(getEventName(), (event: Event & { target: Element }) => {
const svgElement = hasTopClosestByTag(event.target, "svg");
if (!svgElement || svgElement.classList.contains("toolbar__icon--active")) {
@ -42,6 +46,18 @@ export const initFramework = () => {
} else {
backlink.update();
}
} else if (type === "sidebar-bookmark-tab") {
if (!backlink) {
bookmark = new MobileBookmarks();
} else {
backlink.update();
}
} else if (type === "sidebar-tag-tab") {
if (!backlink) {
tag = new MobileTags();
} else {
backlink.update();
}
}
svgElement.classList.add("toolbar__icon--active");
sidebarElement.lastElementChild.querySelector(`[data-type="${itemType.replace("-tab", "")}"]`).classList.remove("fn__none");
@ -60,6 +76,10 @@ export const initFramework = () => {
outline.update();
} else if (type === "sidebar-backlink-tab") {
backlink.update();
} else if (type === "sidebar-bookmark-tab") {
bookmark.update();
} else if (type === "sidebar-tag-tab") {
tag.update();
}
});
document.getElementById("toolbarMore").addEventListener(getEventName(), () => {