This commit is contained in:
Vanessa 2023-06-04 00:13:54 +08:00
parent 8e3ebe8fa1
commit abf7b57827
4 changed files with 21 additions and 24 deletions

View file

@ -1,8 +1,6 @@
import {Dialog} from "../dialog";
import {confirmDialog} from "../dialog/confirmDialog";
import {Constants} from "../constants";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {renderAssetsPreview} from "../asset/renderAssets";
import {Protyle} from "../protyle";
import {disabledProtyle, onGet} from "../protyle/util/onGet";
import * as dayjs from "dayjs";
@ -23,7 +21,7 @@ const renderDoc = (element: HTMLElement, currentPage: number, id: string) => {
previousElement.setAttribute("disabled", "disabled");
}
const opElement = element.querySelector('.b3-select[data-type="opselect"]') as HTMLSelectElement;
const listElement = element.querySelector('.b3-list--background')
const listElement = element.querySelector(".b3-list--background");
element.querySelector('.history__text[data-type="docPanel"]').classList.add("fn__none");
element.querySelector('.history__text[data-type="mdPanel"]').classList.remove("fn__none");
fetchPost("/api/history/searchHistory", {
@ -126,7 +124,7 @@ export const openDocHistory = (options: {
while (target && !target.isEqualNode(dialog.element)) {
const type = target.getAttribute("data-type");
if (type === "close") {
dialog.destroy()
dialog.destroy();
} else if (type === "rollback" && !isLoading) {
getHistoryPath(target.parentElement, opElement.value, options.id, (dataPath) => {
isLoading = false;
@ -181,7 +179,7 @@ export const openDocHistory = (options: {
const getHistoryPath = (target: Element, op: string, id: string, cb: (path: string) => void) => {
isLoading = true;
const path = target.getAttribute("data-path")
const path = target.getAttribute("data-path");
if (path) {
cb(path);
}
@ -191,6 +189,6 @@ const getHistoryPath = (target: Element, op: string, id: string, cb: (path: stri
type: 3,
created: target.getAttribute("data-created")
}, (response) => {
cb(response.data.items[0].path)
cb(response.data.items[0].path);
});
}
};

View file

@ -282,11 +282,11 @@ const openPlugin = (app: App, target: Element) => {
click() {
if (hasUnpin) {
window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].splice(window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].indexOf(item.id), 1);
item.classList.remove("fn__none")
item.classList.remove("fn__none");
} else {
window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].push(item.id);
window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN] = Array.from(new Set(window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN]));
item.classList.add("fn__none")
item.classList.add("fn__none");
}
setStorageVal(Constants.LOCAL_PLUGINTOPUNPIN, window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN]);
}
@ -298,31 +298,31 @@ const openPlugin = (app: App, target: Element) => {
click() {
plugin.openSetting();
},
})
});
}
const menuOption: IMenu = {
icon: "iconInfo",
label: item.getAttribute("aria-label"),
click() {
item.dispatchEvent(new CustomEvent("click"))
item.dispatchEvent(new CustomEvent("click"));
},
type: "submenu",
submenu
}
};
if (item.querySelector("use")) {
menuOption.icon = item.querySelector("use").getAttribute("xlink:href").replace("#", "");
} else {
const svgElement = item.querySelector("svg").cloneNode(true) as HTMLElement;
svgElement.classList.add("b3-menu__icon")
svgElement.classList.add("b3-menu__icon");
menuOption.iconHTML = svgElement.outerHTML;
}
menu.addItem(menuOption);
hasPlugin = true
})
})
hasPlugin = true;
});
});
if (hasPlugin) {
menu.addSeparator()
menu.addSeparator();
}
menu.addItem({
icon: "iconSettings",
@ -336,5 +336,5 @@ const openPlugin = (app: App, target: Element) => {
if (rect.width === 0) {
rect = document.querySelector("#barMore").getBoundingClientRect();
}
menu.open({x: rect.right, y: rect.bottom, isLeft: true})
}
menu.open({x: rect.right, y: rect.bottom, isLeft: true});
};

View file

@ -43,7 +43,7 @@ export class Setting {
});
const contentElement = dialog.element.querySelector(".b3-dialog__content");
this.items.forEach((item) => {
let html = ""
let html = "";
let actionElement = item.actionElement;
if (!item.actionElement && item.createActionElement) {
actionElement = item.createActionElement();
@ -55,7 +55,7 @@ export class Setting {
${item.description ? `<div class="b3-label__text">${item.description}</div>` : ""}
<div class="fn__hr"></div>
</div>
</label>`
</label>`;
} else {
html = `<label class="fn__flex b3-label config__item">
<div class="fn__flex-1">
@ -63,7 +63,7 @@ export class Setting {
${item.description ? `<div class="b3-label__text">${item.description}</div>` : ""}
</div>
<span class="fn__space${actionElement ? "" : " fn__none"}"></span>
</label>`
</label>`;
}
contentElement.insertAdjacentHTML("beforeend", html);
if (actionElement) {
@ -78,7 +78,7 @@ export class Setting {
contentElement.lastElementChild.insertAdjacentElement("beforeend", actionElement);
}
}
})
});
contentElement.querySelector("input")?.focus();
const btnsElement = dialog.element.querySelectorAll(".b3-dialog__action .b3-button");
btnsElement[0].addEventListener("click", () => {

View file

@ -9,7 +9,6 @@ import {Tab} from "../layout/Tab";
import {getDockByType, setPanelFocus} from "../layout/util";
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
import {BlockPanel} from "../block/Panel";
import {genUUID} from "../util/genID";
import {Setting} from "./Setting";
export class Plugin {