Vanessa 2024-09-19 23:32:29 +08:00
parent 8809df839b
commit 35f5e7625b

View File

@ -230,7 +230,8 @@ export const keymap = {
}); });
}, },
search(value: string, keymapString: string) { search(value: string, keymapString: string) {
keymap.element.querySelectorAll("#keymapList .b3-list-item--hide-action > .b3-list-item__text").forEach(item => { const keymapListElement = keymap.element.querySelector("#keymapList")
keymapListElement.querySelectorAll(".b3-list-item--hide-action > .b3-list-item__text").forEach(item => {
const liElement = item.parentElement; const liElement = item.parentElement;
let matchedKeymap = false; let matchedKeymap = false;
if (keymapString === "" || liElement.querySelector(".b3-text-field").getAttribute("data-value").indexOf(keymapString) > -1) { if (keymapString === "" || liElement.querySelector(".b3-text-field").getAttribute("data-value").indexOf(keymapString) > -1) {
@ -245,10 +246,9 @@ export const keymap = {
} }
if (!liElement.nextElementSibling) { if (!liElement.nextElementSibling) {
const toggleElement = liElement.parentElement.previousElementSibling; const toggleElement = liElement.parentElement.previousElementSibling;
const toggleIconElement = toggleElement.querySelector(".b3-list-item__arrow");
if (value === "" && keymapString === "") { if (value === "" && keymapString === "") {
// 复原折叠状态 // 复原折叠状态
if (toggleIconElement.classList.contains("b3-list-item__arrow--open")) { if (toggleElement.querySelector(".b3-list-item__arrow").classList.contains("b3-list-item__arrow--open")) {
liElement.parentElement.classList.remove("fn__none"); liElement.parentElement.classList.remove("fn__none");
} else { } else {
liElement.parentElement.classList.add("fn__none"); liElement.parentElement.classList.add("fn__none");
@ -262,8 +262,14 @@ export const keymap = {
} }
} }
}); });
// 编辑器中三级菜单单独处理 // 编辑器单独处理
const editorKeymapElement = keymap.element.querySelector("#keymapList").lastElementChild; this._toggleSearchItem(keymapListElement.lastElementChild, value, keymapString);
// 插件单独处理
if (keymapListElement.childElementCount === 5) {
this._toggleSearchItem(keymapListElement.lastElementChild.previousElementSibling, value, keymapString);
}
},
_toggleSearchItem(editorKeymapElement: HTMLElement, value: string, keymapString: string) {
if (value === "" && keymapString === "") { if (value === "" && keymapString === "") {
// 复原折叠状态 // 复原折叠状态
if (editorKeymapElement.querySelector(".b3-list-item__arrow").classList.contains("b3-list-item__arrow--open")) { if (editorKeymapElement.querySelector(".b3-list-item__arrow").classList.contains("b3-list-item__arrow--open")) {