Vanessa 2024-05-06 00:17:42 +08:00
parent 5a0dbc1ab7
commit b195782a1c
4 changed files with 17 additions and 19 deletions

View file

@ -16,6 +16,7 @@ import {addEditorToDatabase, addFilesToDatabase} from "../../protyle/render/av/a
import {hasClosestByClassName} from "../../protyle/util/hasClosest";
import {newDailyNote} from "../../util/mount";
import {getCurrentEditor} from "../../mobile/editor";
import {openDock} from "../../mobile/dock/util";
export const commandPanel = (app: App) => {
const range = getSelection().getRangeAt(0);
@ -153,28 +154,16 @@ export const execByCommand = (options: {
/// #if MOBILE
switch (options.command) {
case "fileTree":
getDockByType("file").toggleModel("file");
openDock("file");
return;
case "outline":
getDockByType("outline").toggleModel("outline");
return;
case "bookmark":
getDockByType("bookmark").toggleModel("bookmark");
return;
case "tag":
getDockByType("tag").toggleModel("tag");
return;
case "inbox":
getDockByType("inbox").toggleModel("inbox");
openDock(options.command);
return;
case "backlinks":
getDockByType("backlink").toggleModel("backlink");
return;
case "graphView":
getDockByType("graph").toggleModel("graph");
return;
case "globalGraph":
getDockByType("globalGraph").toggleModel("globalGraph");
openDock("backlink");
return;
}
/// #else

View file

@ -1236,6 +1236,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
}
}
const target = event.target as HTMLElement;
/// #if !BROWSER
if (matchHotKey("⌘=", event) && !hasClosestByClassName(target, "pdf__outer")) {
setZoom("zoomIn");

View file

@ -0,0 +1,4 @@
export const openDock = (type: string) => {
document.getElementById("toolbarFile").dispatchEvent(new CustomEvent("click"));
document.querySelector("#sidebar .toolbar--border").dispatchEvent(new CustomEvent("click", {detail:type}));
}

View file

@ -69,10 +69,14 @@ export const initFramework = (app: App, isStart: boolean) => {
let tag: MobileTags;
// 不能使用 getEventName否则点击返回会展开右侧栏
const firstToolbarElement = sidebarElement.querySelector(".toolbar--border");
firstToolbarElement.addEventListener("click", (event: Event & {
target: Element
}) => {
const svgElement = hasTopClosestByTag(event.target, "svg");
firstToolbarElement.addEventListener("click", (event: MouseEvent) => {
const target = event.target as HTMLElement;
let svgElement: HTMLElement;
if (typeof event.detail === "string") {
svgElement = firstToolbarElement.querySelector(`svg[data-type="sidebar-${event.detail}-tab"]`) as HTMLElement;
} else {
svgElement = hasTopClosestByTag(target, "svg") as HTMLElement;
}
if (!svgElement) {
return;
}