This commit is contained in:
Vanessa 2023-06-28 22:57:18 +08:00
parent 6737a68fd7
commit 7331e9d834
4 changed files with 19 additions and 19 deletions

View file

@ -728,17 +728,17 @@ export const bazaar = {
if (!target.getAttribute("disabled")) { if (!target.getAttribute("disabled")) {
target.setAttribute("disabled", "disabled"); target.setAttribute("disabled", "disabled");
window.siyuan.config.bazaar.petalDisabled = !(target as HTMLInputElement).checked; window.siyuan.config.bazaar.petalDisabled = !(target as HTMLInputElement).checked;
fetchPost("/api/setting/setBazaar", window.siyuan.config.bazaar, (response) => { fetchPost("/api/setting/setBazaar", window.siyuan.config.bazaar, () => {
target.removeAttribute("disabled"); target.removeAttribute("disabled");
if (window.siyuan.config.bazaar.petalDisabled) { if (window.siyuan.config.bazaar.petalDisabled) {
bazaar.element.querySelectorAll("#configBazaarDownloaded .b3-card").forEach(item => { bazaar.element.querySelectorAll("#configBazaarDownloaded .b3-card").forEach(item => {
item.classList.add("b3-card--disabled"); item.classList.add("b3-card--disabled");
uninstall(app, JSON.parse(item.getAttribute("data-obj")).name); uninstall(app, JSON.parse(item.getAttribute("data-obj")).name);
}) });
} else { } else {
bazaar.element.querySelectorAll("#configBazaarDownloaded .b3-card").forEach(item => { bazaar.element.querySelectorAll("#configBazaarDownloaded .b3-card").forEach(item => {
item.classList.remove("b3-card--disabled"); item.classList.remove("b3-card--disabled");
}) });
loadPlugins(app).then(() => { loadPlugins(app).then(() => {
app.plugins.forEach(item => { app.plugins.forEach(item => {
afterLoadPlugin(item); afterLoadPlugin(item);

View file

@ -383,7 +383,7 @@ const openPlugin = (app: App, target: Element) => {
} }
}); });
if (!hasPlugin) { if (!hasPlugin) {
window.siyuan.menus.menu.element.querySelector(".b3-menu__separator").remove() window.siyuan.menus.menu.element.querySelector(".b3-menu__separator").remove();
} }
let rect = target.getBoundingClientRect(); let rect = target.getBoundingClientRect();
if (rect.width === 0) { if (rect.width === 0) {

View file

@ -17,21 +17,21 @@ export const commandPanel = (app: App) => {
<ul class="b3-list b3-list--background fn__flex-1" id="commands"></ul> <ul class="b3-list b3-list--background fn__flex-1" id="commands"></ul>
<div class="fn__hr"></div> <div class="fn__hr"></div>
</div>` </div>`
}) });
const listElement = dialog.element.querySelector("#commands"); const listElement = dialog.element.querySelector("#commands");
app.plugins.forEach(plugin => { app.plugins.forEach(plugin => {
plugin.commands.forEach(command => { plugin.commands.forEach(command => {
const liElement = document.createElement("li"); const liElement = document.createElement("li");
liElement.classList.add("b3-list-item") liElement.classList.add("b3-list-item");
liElement.innerHTML = `<span class="b3-list-item__text">${command.langText || plugin.i18n[command.langKey]}</span> liElement.innerHTML = `<span class="b3-list-item__text">${command.langText || plugin.i18n[command.langKey]}</span>
<span class="b3-list-item__meta">${updateHotkeyTip(command.customHotkey)}</span>`; <span class="b3-list-item__meta">${updateHotkeyTip(command.customHotkey)}</span>`;
liElement.addEventListener("click", () => { liElement.addEventListener("click", () => {
command.callback(); command.callback();
dialog.destroy(); dialog.destroy();
}) });
listElement.insertAdjacentElement("beforeend", liElement); listElement.insertAdjacentElement("beforeend", liElement);
}) });
}) });
if (listElement.childElementCount === 0) { if (listElement.childElementCount === 0) {
const liElement = document.createElement("li"); const liElement = document.createElement("li");
@ -40,7 +40,7 @@ export const commandPanel = (app: App) => {
liElement.addEventListener("click", () => { liElement.addEventListener("click", () => {
dialog.destroy(); dialog.destroy();
openSetting(app).element.querySelector('.b3-tab-bar [data-name="bazaar"]').dispatchEvent(new CustomEvent("click")); openSetting(app).element.querySelector('.b3-tab-bar [data-name="bazaar"]').dispatchEvent(new CustomEvent("click"));
}) });
listElement.insertAdjacentElement("beforeend", liElement); listElement.insertAdjacentElement("beforeend", liElement);
} else { } else {
listElement.firstElementChild.classList.add("b3-list-item--focus"); listElement.firstElementChild.classList.add("b3-list-item--focus");
@ -64,9 +64,9 @@ export const commandPanel = (app: App) => {
dialog.destroy(); dialog.destroy();
} }
}); });
inputElement.addEventListener("compositionend", (event: InputEvent) => { inputElement.addEventListener("compositionend", () => {
filterList(inputElement, listElement); filterList(inputElement, listElement);
}) });
inputElement.addEventListener("input", (event: InputEvent) => { inputElement.addEventListener("input", (event: InputEvent) => {
if (event.isComposing) { if (event.isComposing) {
return; return;
@ -74,7 +74,7 @@ export const commandPanel = (app: App) => {
event.stopPropagation(); event.stopPropagation();
filterList(inputElement, listElement); filterList(inputElement, listElement);
}); });
} };
const filterList = (inputElement: HTMLInputElement, listElement: Element) => { const filterList = (inputElement: HTMLInputElement, listElement: Element) => {
const inputValue = inputElement.value.toLowerCase(); const inputValue = inputElement.value.toLowerCase();
@ -83,7 +83,7 @@ const filterList = (inputElement: HTMLInputElement, listElement: Element) => {
if (inputValue.indexOf(elementValue) > -1 || elementValue.indexOf(inputValue) > -1) { if (inputValue.indexOf(elementValue) > -1 || elementValue.indexOf(inputValue) > -1) {
element.classList.remove("fn__none"); element.classList.remove("fn__none");
} else { } else {
element.classList.add("fn__none") element.classList.add("fn__none");
}
})
} }
});
};

View file

@ -621,17 +621,17 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
return; return;
} else if (value.startsWith("plugin")) { } else if (value.startsWith("plugin")) {
protyle.app.plugins.find((plugin) => { protyle.app.plugins.find((plugin) => {
const ids = value.split(Constants.ZWSP) const ids = value.split(Constants.ZWSP);
if (ids[1] === plugin.name) { if (ids[1] === plugin.name) {
plugin.protyleSlash.find((slash) => { plugin.protyleSlash.find((slash) => {
if (slash.id === ids[2]){ if (slash.id === ids[2]){
slash.callback(protyle.getInstance()); slash.callback(protyle.getInstance());
return true; return true;
} }
}) });
return true; return true;
} }
}) });
return; return;
} else { } else {
range.deleteContents(); range.deleteContents();