Vanessa 2024-08-06 12:36:44 +08:00
parent f7920fa853
commit 8ff4bd0200
2 changed files with 9 additions and 3 deletions

View file

@ -85,6 +85,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
return true; return true;
} }
/// #if !MOBILE
const searchIconElement = hasClosestByAttribute(event.target, "data-type", "av-search-icon"); const searchIconElement = hasClosestByAttribute(event.target, "data-type", "av-search-icon");
if (searchIconElement) { if (searchIconElement) {
const searchElement = blockElement.querySelector('input[data-type="av-search"]') as HTMLInputElement; const searchElement = blockElement.querySelector('input[data-type="av-search"]') as HTMLInputElement;
@ -98,7 +99,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
event.stopPropagation(); event.stopPropagation();
return true; return true;
} }
/// #endif
const viewItemElement = hasClosestByClassName(event.target, "item"); const viewItemElement = hasClosestByClassName(event.target, "item");
if (viewItemElement && viewItemElement.parentElement.classList.contains("layout-tab-bar")) { if (viewItemElement && viewItemElement.parentElement.classList.contains("layout-tab-bar")) {
if (viewItemElement.classList.contains("item--focus")) { if (viewItemElement.classList.contains("item--focus")) {

View file

@ -10,6 +10,7 @@ import {getCalcValue} from "./calc";
import {renderAVAttribute} from "./blockAttr"; import {renderAVAttribute} from "./blockAttr";
import {showMessage} from "../../../dialog/message"; import {showMessage} from "../../../dialog/message";
import {addClearButton} from "../../../util/addClearButton"; import {addClearButton} from "../../../util/addClearButton";
import {isMobile} from "../../../util/functions";
export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, viewID?: string) => { export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, viewID?: string) => {
let avElements: Element[] = []; let avElements: Element[] = [];
@ -235,11 +236,11 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex)}
<svg><use xlink:href="#iconSort"></use></svg> <svg><use xlink:href="#iconSort"></use></svg>
</span> </span>
<div class="fn__space"></div> <div class="fn__space"></div>
<span data-type="av-search-icon" class="block__icon"> <span data-type="av-search-icon" class="block__icon${isMobile() ? " fn__none" : ""}">
<svg><use xlink:href="#iconSearch"></use></svg> <svg><use xlink:href="#iconSearch"></use></svg>
</span> </span>
<div style="position: relative" class="fn__flex"> <div style="position: relative" class="fn__flex">
<input style="${isSearching || query ? "width:128px" : "width:0;padding-left: 0;padding-right: 0;"}" data-type="av-search" class="b3-text-field b3-text-field--text" placeholder="${window.siyuan.languages.search}"> <input style="${(isSearching || query || isMobile()) ? "width:128px" : "width:0;padding-left: 0;padding-right: 0;"}" data-type="av-search" class="b3-text-field b3-text-field--text" placeholder="${window.siyuan.languages.search}">
</div> </div>
<div class="fn__space"></div> <div class="fn__space"></div>
<span data-type="av-more" class="block__icon"> <span data-type="av-more" class="block__icon">
@ -365,6 +366,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex)}
searchInputElement.addEventListener("compositionend", () => { searchInputElement.addEventListener("compositionend", () => {
updateSearch(e, protyle); updateSearch(e, protyle);
}); });
/// #if !MOBILE
searchInputElement.addEventListener("blur", (event: KeyboardEvent) => { searchInputElement.addEventListener("blur", (event: KeyboardEvent) => {
if (event.isComposing) { if (event.isComposing) {
return; return;
@ -376,6 +378,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex)}
searchInputElement.style.paddingRight = "0"; searchInputElement.style.paddingRight = "0";
} }
}); });
/// #endif
addClearButton({ addClearButton({
inputElement: searchInputElement, inputElement: searchInputElement,
right: 0, right: 0,
@ -383,9 +386,11 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex)}
height: searchInputElement.clientHeight, height: searchInputElement.clientHeight,
clearCB() { clearCB() {
viewsElement.classList.remove("av__views--show"); viewsElement.classList.remove("av__views--show");
/// #if !MOBILE
searchInputElement.style.width = "0"; searchInputElement.style.width = "0";
searchInputElement.style.paddingLeft = "0"; searchInputElement.style.paddingLeft = "0";
searchInputElement.style.paddingRight = "0"; searchInputElement.style.paddingRight = "0";
/// #endif
focusBlock(e); focusBlock(e);
updateSearch(e, protyle); updateSearch(e, protyle);
} }