Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/13964

Vanessaab5bb7d56c65
diff --git a/app/src/search/assets.ts b/app/src/search/assets.ts
index 3542a22016..7e3af886b0 100644
--- a/app/src/search/assets.ts
+++ b/app/src/search/assets.ts
@@ -7,8 +7,6 @@ import {getQueryTip} from "./util";
/// #endif
import {MenuItem} from "../menus/Menu";
import {Dialog} from "../dialog";
-import {Menu} from "../plugin/Menu";
-import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {addClearButton} from "../util/addClearButton";
import {isPaidUser} from "../util/needSubscribe";
import {showMessage} from "../dialog/message";
@@ -70,7 +68,7 @@ export const openSearchAsset = (element: HTMLElement, isStick: boolean) => {
<div class="search__layout${localSearch.layout === 1 ? " search__layout--row" : ""}">
<div id="searchAssetList" class="fn__flex-1 search__list b3-list b3-list--background"></div>
<div class="search__drag"></div>
- <div id="searchAssetPreview" class="fn__flex-1 search__preview b3-typography" style="padding: 8px"></div>
+ <div id="searchAssetPreview" class="fn__flex-1 search__preview b3-typography" style="padding: 8px;box-sizing: border-box;"></div>
</div>
<div class="search__tip${isStick ? " fn__none" : ""}">
<kbd>↑/↓/PageUp/PageDown</kbd> ${window.siyuan.languages.searchTip1}
@@ -124,15 +122,14 @@ export const openSearchAsset = (element: HTMLElement, isStick: boolean) => {
const dragElement = element.querySelector(".search__drag");
dragElement.addEventListener("mousedown", (event: MouseEvent) => {
const documentSelf = document;
- const nextElement = dragElement.nextElementSibling as HTMLElement;
const previousElement = dragElement.previousElementSibling as HTMLElement;
const direction = localSearch.layout === 1 ? "lr" : "tb";
const x = event[direction === "lr" ? "clientX" : "clientY"];
- const previousSize = direction === "lr" ? previousElement.clientWidth : previousElement.clientHeight;
- const nextSize = direction === "lr" ? nextElement.clientWidth : nextElement.clientHeight;
+ const previousSize = direction === "lr" ? previousElement.offsetWidth : previousElement.offsetHeight;
+ const nextSize = direction === "lr" ? previewElement.offsetWidth : previewElement.offsetHeight;
- nextElement.classList.remove("fn__flex-1");
- nextElement.style[direction === "lr" ? "width" : "height"] = nextSize + "px";
+ previewElement.classList.remove("fn__flex-1");
+ previewElement.style[direction === "lr" ? "width" : "height"] = nextSize + "px";
element.style.userSelect = "none";
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
moveEvent.preventDefault();
@@ -142,7 +139,7 @@ export const openSearchAsset = (element: HTMLElement, isStick: boolean) => {
if (previousNowSize < 120 || nextNowSize < 120) {
return;
}
- nextElement.style[direction === "lr" ? "width" : "height"] = nextNowSize + "px";
+ previewElement.style[direction === "lr" ? "width" : "height"] = nextNowSize + "px";
};
documentSelf.onmouseup = () => {
@@ -152,10 +149,17 @@ export const openSearchAsset = (element: HTMLElement, isStick: boolean) => {
documentSelf.ondragstart = null;
documentSelf.onselectstart = null;
documentSelf.onselect = null;
- window.siyuan.storage[Constants.LOCAL_SEARCHASSET][direction === "lr" ? "col" : "row"] = nextElement[direction === "lr" ? "clientWidth" : "clientHeight"] + "px";
+ window.siyuan.storage[Constants.LOCAL_SEARCHASSET][direction === "lr" ? "col" : "row"] = previewElement[direction === "lr" ? "offsetWidth" : "offsetHeight"] + "px";
setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]);
};
});
+ dragElement.addEventListener("dblclick", () => {
+ previewElement.style[localSearch.layout === 1 ? "width" : "height"] = "";
+ previewElement.classList.add("fn__flex-1");
+ const direction = localSearch.layout === 1 ? "lr" : "tb";
+ window.siyuan.storage[Constants.LOCAL_SEARCHASSET][direction === "lr" ? "col" : "row"] = "";
+ setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]);
+ });
/// #endif
};
diff --git a/app/src/search/unRef.ts b/app/src/search/unRef.ts
index 0dc74ea044..85c4e6bff0 100644
--- a/app/src/search/unRef.ts
+++ b/app/src/search/unRef.ts
@@ -72,6 +72,16 @@ export const openSearchUnRef = (element: HTMLElement, editor: Protyle) => {
}
};
});
+ dragElement.addEventListener("dblclick", () => {
+ editor.protyle.element.style[localSearch.layout === 1 ? "width" : "height"] = "";
+ editor.protyle.element.classList.add("fn__flex-1");
+ const direction = localSearch.layout === 1 ? "lr" : "tb";
+ window.siyuan.storage[Constants.LOCAL_SEARCHUNREF][direction === "lr" ? "col" : "row"] = "";
+ setStorageVal(Constants.LOCAL_SEARCHUNREF, window.siyuan.storage[Constants.LOCAL_SEARCHUNREF]);
+ if (direction === "lr") {
+ resize(editor.protyle);
+ }
+ });
getUnRefList(element, editor);
};
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index 53b45d8bd9..ccd4142535 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -235,7 +235,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
<div class="search__layout${unRefLocal.layout === 1 ? " search__layout--row" : ""}">
<div id="searchUnRefList" class="fn__flex-1 search__list b3-list b3-list--background"></div>
<div class="search__drag"></div>
- <div id="searchUnRefPreview" class="fn__flex-1 search__preview b3-typography" style="padding: 8px"></div>
+ <div id="searchUnRefPreview" class="fn__flex-1 search__preview b3-typography"></div>
</div>
<div class="search__tip${closeCB ? "" : " fn__none"}">
<kbd>↑/↓/PageUp/PageDown</kbd> ${window.siyuan.languages.searchTip1}
@@ -338,7 +338,16 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
}
};
});
-
+ dragElement.addEventListener("dblclick", () => {
+ edit.protyle.element.style[localSearch.layout === 1 ? "width" : "height"] = "";
+ edit.protyle.element.classList.add("fn__flex-1");
+ const direction = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][closeCB ? "layout" : "layoutTab"] === 1 ? "lr" : "tb";
+ window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][direction === "lr" ? (closeCB ? "col" : "colTab") : (closeCB ? "row" : "rowTab")] = "";
+ setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
+ if (direction === "lr") {
+ resize(edit.protyle);
+ }
+ });
const localSearch = window.siyuan.storage[Constants.LOCAL_SEARCHASSET] as ISearchAssetOption;
const assetsElement = element.querySelector("#searchAssets") as HTMLElement;
const unRefPanelElement = element.querySelector("#searchUnRefPanel") as HTMLElement;