An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/9801
Vanessad1c5c9ac7ddf
diff --git a/app/src/mobile/menu/search.ts b/app/src/mobile/menu/search.tsindex 4cd872b34d..1b328efb99 100644--- a/app/src/mobile/menu/search.ts+++ b/app/src/mobile/menu/search.ts@@ -23,6 +23,7 @@ import {renderNextAssetMark,renderPreview,} from "../../search/assets";+import {addClearButton} from "../../util/addClearButton";const replace = (element: Element, config: ISearchOption, isAll: boolean) => {if (config.method === 1 || config.method === 2) {@@ -32,7 +33,7 @@ const replace = (element: Element, config: ISearchOption, isAll: boolean) => {const searchListElement = element.querySelector("#searchList");const replaceInputElement = element.querySelector("#toolbarReplace") as HTMLInputElement;- const loadElement = replaceInputElement.nextElementSibling;+ const loadElement = replaceInputElement.parentElement.querySelector(".fn__rotate");if (!loadElement.classList.contains("fn__none")) {return;}@@ -281,9 +282,20 @@ const initSearchEvent = (app: App, element: Element, config: ISearchOption) => {setStorageVal(Constants.LOCAL_SEARCHDATA, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]);}});+ addClearButton({+ inputElement: searchInputElement,+ className: "toolbar__icon",+ clearCB() {+ config.page = 1;+ updateSearchResult(config, element);+ }+ });const replaceInputElement = element.querySelector(".toolbar .toolbar__title") as HTMLInputElement;replaceInputElement.value = config.r || "";-+ addClearButton({+ inputElement: replaceInputElement,+ className: "toolbar__icon",+ });const criteriaData: ISearchOption[] = [];initCriteriaMenu(element.querySelector("#criteria"), criteriaData, config);@@ -648,10 +660,7 @@ export const popSearch = (app: App, config = window.siyuan.storage[Constants.LOC<div class="fn__none fn__flex-column" style="position: fixed;top: 0;width: 100%;background: var(--b3-theme-surface);height: 100%;" id="searchAssetsPanel"><div class="toolbar toolbar--border"><svg class="toolbar__icon"><use xlink:href="#iconSearch"></use></svg>- <span class="toolbar__text"><input id="searchAssetInput" placeholder="${window.siyuan.languages.keyword}" class="toolbar__title fn__block"></span>- <svg class="toolbar__icon" data-type="goSearch">- <use xlink:href="#iconCloseRound"></use>- </svg>+ <input id="searchAssetInput" placeholder="${window.siyuan.languages.keyword}" class="toolbar__title fn__block"></div><div class="toolbar"><span class="fn__space"></span>@@ -706,4 +715,11 @@ const goAsset = () => {assetInputEvent(assetsElement, localSearch);});assetInputEvent(assetsElement, localSearch);+ addClearButton({+ inputElement,+ className:"toolbar__icon",+ clearCB() {+ assetInputEvent(assetsElement, localSearch);+ }+ })};diff --git a/app/src/search/assets.ts b/app/src/search/assets.tsindex 1ff9fbfe7b..789c9073b8 100644--- a/app/src/search/assets.ts+++ b/app/src/search/assets.ts@@ -121,8 +121,11 @@ export const openSearchAsset = (element: Element, isStick: boolean) => {setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]);});assetInputEvent(element, localSearch);- addClearButton(searchInputElement, () => {- assetInputEvent(element, localSearch);+ addClearButton({+ inputElement: searchInputElement,+ clearCB() {+ assetInputEvent(element, localSearch);+ }});const dragElement = element.querySelector(".search__drag");diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex 3d5122f76e..45439116da 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -952,10 +952,18 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo}saveKeyList("keys", searchInputElement.value);});- addClearButton(searchInputElement, () => {- inputEvent(element, config, edit);+ addClearButton({+ inputElement: searchInputElement,+ height: searchInputElement.clientHeight,+ clearCB () {+ config.page = 1;+ inputEvent(element, config, edit);+ }+ });+ addClearButton({+ inputElement: replaceInputElement,+ height: searchInputElement.clientHeight,});- addClearButton(replaceInputElement, undefined, undefined, searchInputElement.clientHeight);inputEvent(element, config, edit);return edit;};diff --git a/app/src/util/addClearButton.ts b/app/src/util/addClearButton.tsindex 21e365db8f..fef5a6715c 100644--- a/app/src/util/addClearButton.ts+++ b/app/src/util/addClearButton.ts@@ -1,27 +1,37 @@-const update = (inputElement: HTMLInputElement, clearElement: Element, right = 8) => {+const update = (inputElement: HTMLInputElement, clearElement: Element, right: number) => {if (inputElement.value === "") {clearElement.classList.add("fn__none");- inputElement.style.paddingRight = "";+ if (right) {+ inputElement.style.paddingRight = "";+ }} else {clearElement.classList.remove("fn__none");- inputElement.style.setProperty('padding-right', `${right * 2 + clearElement.clientWidth}px`, 'important');+ if (right) {+ inputElement.style.setProperty('padding-right', `${right * 2 + clearElement.clientWidth}px`, 'important');+ }}}-export const addClearButton = (inputElement: HTMLInputElement, clearCB?: () => void, right = 8, height?: number) => {- inputElement.insertAdjacentHTML("afterend",- `<svg class="b3-form__icon-clear" style="right:${right}px;height: ${height || inputElement.clientHeight}px;">+export const addClearButton = (options: {+ inputElement: HTMLInputElement,+ clearCB?: () => void,+ right?: number,+ height?: number+ className?: string+}) => {+ 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" : ""}"><use xlink:href="#iconCloseRound"></use></svg>`);- const clearElement = inputElement.nextElementSibling;+ const clearElement = options.inputElement.nextElementSibling;clearElement.addEventListener("click", () => {- inputElement.value = "";- inputElement.focus();- update(inputElement, clearElement, right);- if (clearCB) {- clearCB();+ options.inputElement.value = "";+ options.inputElement.focus();+ update(options.inputElement, clearElement, options.right);+ if (options.clearCB) {+ options.clearCB();}})- inputElement.addEventListener("input", () => {- update(inputElement, clearElement, right);+ options.inputElement.addEventListener("input", () => {+ update(options.inputElement, clearElement, options.right);});- update(inputElement, clearElement, right);+ update(options.inputElement, clearElement, options.right);};