This commit is contained in:
Vanessa 2023-07-13 23:18:09 +08:00
parent 2ee0155ee0
commit ca891b6440
3 changed files with 28 additions and 28 deletions

View File

@ -55,20 +55,20 @@ export const genCellValue = (colType: TAVCol, value: string | {
};
const toggleEmpty = (element: HTMLElement, show: boolean) => {
const menuElement = hasClosestByClassName(element, "b3-menu")
const menuElement = hasClosestByClassName(element, "b3-menu");
if (menuElement) {
menuElement.querySelectorAll("input, .b3-chip").forEach(inputElement => {
const menuItemElement = hasClosestByClassName(inputElement, "b3-menu__item")
const menuItemElement = hasClosestByClassName(inputElement, "b3-menu__item");
if (menuItemElement) {
if (show) {
menuItemElement.classList.remove("fn__none")
menuItemElement.classList.remove("fn__none");
} else {
menuItemElement.classList.add("fn__none")
menuItemElement.classList.add("fn__none");
}
}
})
});
}
}
};
export const setFilter = (options: {
filter: IAVFilter,
@ -84,16 +84,16 @@ export const setFilter = (options: {
if (textElement) {
cellValue = genCellValue(options.filter.value.type, textElement.value);
} else {
const mSelect: { color: string, content: string }[] = []
window.siyuan.menus.menu.element.querySelectorAll('svg').forEach(item => {
const mSelect: { color: string, content: string }[] = [];
window.siyuan.menus.menu.element.querySelectorAll("svg").forEach(item => {
if (item.firstElementChild.getAttribute("xlink:href") === "#iconCheck") {
const chipElement = item.nextElementSibling.firstElementChild as HTMLElement
const chipElement = item.nextElementSibling.firstElementChild as HTMLElement;
mSelect.push({
color: chipElement.dataset.color,
content: chipElement.dataset.name
})
});
}
})
});
cellValue = genCellValue(options.filter.value.type, mSelect);
}
const newFilter: IAVFilter = {
@ -188,12 +188,12 @@ export const setFilter = (options: {
});
if (options.filter.value.type === "select" || options.filter.value.type === "mSelect") {
colData.options?.forEach((option) => {
let icon = "iconUncheck"
let icon = "iconUncheck";
options.filter.value.mSelect.find((optionItem) => {
if (optionItem.content === option.name) {
icon = "iconCheck"
icon = "iconCheck";
}
})
});
menu.addItem({
icon,
label: `<span class="b3-chip b3-chip--middle" data-name="${option.name}" data-color="${option.color}" style="margin:3px 0;background-color:var(--b3-font-background${option.color});color:var(--b3-font-color${option.color})">
@ -201,15 +201,15 @@ export const setFilter = (options: {
</span>`,
bind(element) {
element.addEventListener("click", () => {
const useElement = element.querySelector("use")
const useElement = element.querySelector("use");
if (useElement.getAttribute("xlink:href") === "#iconUncheck") {
useElement.setAttribute("xlink:href", "#iconCheck");
} else {
useElement.setAttribute("xlink:href", "#iconUncheck");
}
})
});
}
})
});
});
} else if (options.filter.value.type === "text") {
menu.addItem({
@ -250,7 +250,7 @@ export const setFilter = (options: {
});
const selectElement = (window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement);
selectElement.addEventListener("change", () => {
toggleEmpty(selectElement, selectElement.value !== "Is empty" && selectElement.value !== "Is not empty")
toggleEmpty(selectElement, selectElement.value !== "Is empty" && selectElement.value !== "Is not empty");
});
const textElement = window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement;
if (textElement) {
@ -265,7 +265,7 @@ export const setFilter = (options: {
}
});
}
toggleEmpty(selectElement, selectElement.value !== "Is empty" && selectElement.value !== "Is not empty")
toggleEmpty(selectElement, selectElement.value !== "Is empty" && selectElement.value !== "Is not empty");
menu.open({x: rectTarget.left, y: rectTarget.bottom});
if (textElement) {
textElement.select();

View File

@ -388,15 +388,15 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
id: Lute.NewNodeID(),
value: genCellValue(colData.type, ""),
valueType: colData.type
}
};
} else {
let hasSelected = false
let hasSelected = false;
cellData.value.mSelect.find((item) => {
if (item.content === currentElement.dataset.name) {
hasSelected = true
hasSelected = true;
return true;
}
})
});
if (hasSelected) {
menuElement.querySelector("input").focus();
return;

View File

@ -13,7 +13,7 @@ import {addLoading, setPadding} from "../protyle/ui/initUI";
import {getIconByType} from "../editor/getIcon";
import {unicode2Emoji} from "../emoji";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {isCtrl, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
import {newFileByName} from "../util/newFile";
import {matchHotKey} from "../protyle/util/hotKey";
import {filterMenu, getKeyByLiElement, initCriteriaMenu, moreMenu, queryMenu, saveCriterion} from "./menu";
@ -294,7 +294,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
}
}, config, edit, app);
}, config, edit);
event.stopPropagation();
event.preventDefault();
break;
@ -323,7 +323,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
config.removed = false;
criteriaData.find(item => {
if (item.name === target.innerText.trim()) {
updateConfig(element, item, config, edit, app);
updateConfig(element, item, config, edit);
return true;
}
});
@ -483,7 +483,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
}
}, config, edit, app);
}, config, edit);
}, () => {
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
const isPopover = hasClosestByClassName(element, "b3-dialog__container");
@ -855,7 +855,7 @@ const getQueryTip = (method: number) => {
return methodTip;
};
const updateConfig = (element: Element, item: ISearchOption, config: ISearchOption, edit: Protyle, app: App) => {
const updateConfig = (element: Element, item: ISearchOption, config: ISearchOption, edit: Protyle) => {
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
if (dialogElement && dialogElement.getAttribute("data-key") === window.siyuan.config.keymap.general.search.custom) {
// https://github.com/siyuan-note/siyuan/issues/6828