From ab5bb7d56c659c4c070e848407b05e24e714eaa9 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 14 Feb 2025 16:35:34 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/13964 --- app/src/search/assets.ts | 24 ++++++++++++++---------- app/src/search/unRef.ts | 10 ++++++++++ app/src/search/util.ts | 13 +++++++++++-- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/src/search/assets.ts b/app/src/search/assets.ts index 3542a2201..7e3af886b 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) => {
-
+
↑/↓/PageUp/PageDown ${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 0dc74ea04..85c4e6bff 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 53b45d8bd..ccd414253 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
-
+
↑/↓/PageUp/PageDown ${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;