Vanessa 2024-03-09 11:08:11 +08:00
parent cbcc8141a8
commit 3f21eda746
5 changed files with 82 additions and 5 deletions

View file

@ -1,12 +1,12 @@
const update = (inputElement: HTMLInputElement, clearElement: Element, right: number) => {
if (inputElement.value === "") {
clearElement.classList.add("fn__none");
if (right) {
inputElement.style.paddingRight = "";
if (typeof right === "number") {
inputElement.style.paddingRight = inputElement.dataset.oldPaddingRight;
}
} else {
clearElement.classList.remove("fn__none");
if (right) {
if (typeof right === "number") {
inputElement.style.setProperty("padding-right", `${right * 2 + clearElement.clientWidth}px`, "important");
}
}
@ -18,6 +18,7 @@ export const addClearButton = (options: {
height?: number
className?: string
}) => {
options.inputElement.dataset.oldPaddingRight = options.inputElement.style.paddingRight;
options.inputElement.insertAdjacentHTML("afterend",
`<svg class="${options.className || "b3-form__icon-clear"} ariaLabel" aria-label="${window.siyuan.languages.clear}" style="${options.right ? "right: " + options.right + "px;" : ""}${options.height ? "height:" + options.height + "px" : ""}">
<use xlink:href="#iconCloseRound"></use></svg>`);