mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
d1c5c9ac7d
commit
2f34408577
4 changed files with 11 additions and 7 deletions
|
|
@ -721,5 +721,5 @@ const goAsset = () => {
|
||||||
clearCB() {
|
clearCB() {
|
||||||
assetInputEvent(assetsElement, localSearch);
|
assetInputEvent(assetsElement, localSearch);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,8 @@ export const openSearchAsset = (element: Element, isStick: boolean) => {
|
||||||
});
|
});
|
||||||
assetInputEvent(element, localSearch);
|
assetInputEvent(element, localSearch);
|
||||||
addClearButton({
|
addClearButton({
|
||||||
|
right: 8,
|
||||||
|
height: searchInputElement.clientHeight,
|
||||||
inputElement: searchInputElement,
|
inputElement: searchInputElement,
|
||||||
clearCB() {
|
clearCB() {
|
||||||
assetInputEvent(element, localSearch);
|
assetInputEvent(element, localSearch);
|
||||||
|
|
|
||||||
|
|
@ -954,6 +954,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
|
||||||
});
|
});
|
||||||
addClearButton({
|
addClearButton({
|
||||||
inputElement: searchInputElement,
|
inputElement: searchInputElement,
|
||||||
|
right: 8,
|
||||||
height: searchInputElement.clientHeight,
|
height: searchInputElement.clientHeight,
|
||||||
clearCB() {
|
clearCB() {
|
||||||
config.page = 1;
|
config.page = 1;
|
||||||
|
|
@ -961,6 +962,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addClearButton({
|
addClearButton({
|
||||||
|
right: 8,
|
||||||
inputElement: replaceInputElement,
|
inputElement: replaceInputElement,
|
||||||
height: searchInputElement.clientHeight,
|
height: searchInputElement.clientHeight,
|
||||||
});
|
});
|
||||||
|
|
@ -1114,7 +1116,7 @@ export const replace = (element: Element, config: ISearchOption, edit: Protyle,
|
||||||
const replaceInputElement = element.querySelector("#replaceInput") as HTMLInputElement;
|
const replaceInputElement = element.querySelector("#replaceInput") as HTMLInputElement;
|
||||||
const searchInputElement = element.querySelector("#searchInput") as HTMLInputElement;
|
const searchInputElement = element.querySelector("#searchInput") as HTMLInputElement;
|
||||||
|
|
||||||
const loadElement = element.querySelector("#searchRefresh");
|
const loadElement = element.querySelector("svg.fn__rotate");
|
||||||
if (!loadElement.classList.contains("fn__none")) {
|
if (!loadElement.classList.contains("fn__none")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ const update = (inputElement: HTMLInputElement, clearElement: Element, right: nu
|
||||||
} else {
|
} else {
|
||||||
clearElement.classList.remove("fn__none");
|
clearElement.classList.remove("fn__none");
|
||||||
if (right) {
|
if (right) {
|
||||||
inputElement.style.setProperty('padding-right', `${right * 2 + clearElement.clientWidth}px`, 'important');
|
inputElement.style.setProperty("padding-right", `${right * 2 + clearElement.clientWidth}px`, "important");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
export const addClearButton = (options: {
|
export const addClearButton = (options: {
|
||||||
inputElement: HTMLInputElement,
|
inputElement: HTMLInputElement,
|
||||||
clearCB?: () => void,
|
clearCB?: () => void,
|
||||||
|
|
@ -19,7 +19,7 @@ export const addClearButton = (options: {
|
||||||
className?: string
|
className?: string
|
||||||
}) => {
|
}) => {
|
||||||
options.inputElement.insertAdjacentHTML("afterend",
|
options.inputElement.insertAdjacentHTML("afterend",
|
||||||
`<svg class="${options.className || "b3-form__icon-clear"}" style="${options.right ? "right: " + options.right + "px" : ""}${options.height ? "height:" + options.height + "px" : ""}">
|
`<svg class="${options.className || "b3-form__icon-clear"}" style="${options.right ? "right: " + options.right + "px;" : ""}${options.height ? "height:" + options.height + "px" : ""}">
|
||||||
<use xlink:href="#iconCloseRound"></use></svg>`);
|
<use xlink:href="#iconCloseRound"></use></svg>`);
|
||||||
const clearElement = options.inputElement.nextElementSibling;
|
const clearElement = options.inputElement.nextElementSibling;
|
||||||
clearElement.addEventListener("click", () => {
|
clearElement.addEventListener("click", () => {
|
||||||
|
|
@ -29,7 +29,7 @@ export const addClearButton = (options: {
|
||||||
if (options.clearCB) {
|
if (options.clearCB) {
|
||||||
options.clearCB();
|
options.clearCB();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
options.inputElement.addEventListener("input", () => {
|
options.inputElement.addEventListener("input", () => {
|
||||||
update(options.inputElement, clearElement, options.right);
|
update(options.inputElement, clearElement, options.right);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue