An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Size settings selectors to their options https://github.com/siyuan-note/siyuan/issues/19164
Daniel6dbf97f8a8ec
diff --git a/app/src/config/bazaar/events.ts b/app/src/config/bazaar/events.tsindex 0df1693df6..570e1e505a 100644--- a/app/src/config/bazaar/events.ts+++ b/app/src/config/bazaar/events.ts@@ -15,6 +15,7 @@ import {useShell} from "../../util/pathName";import {previewImages} from "../../protyle/preview/image";import {isBazaarPackageRatingEditable, sortBazaarPackages} from "../../util/bazaarPackage";import {Constants} from "../../constants";+import {fitSelectWidthToOptions} from "../../util/select";import {BAZAAR_PACKAGE_CONFIG,getBazaarTypeByMyType,@@ -576,6 +577,7 @@ const bindBazaarSearchEvents = (const bindBazaarSelectEvents = (controller: TBazaarController) => {controller.element.querySelectorAll(".b3-select").forEach((selectElement: HTMLSelectElement) => {+ fitSelectWidthToOptions(selectElement);selectElement.addEventListener("change", () => {if (selectElement.getAttribute("data-type") === "downloaded-sort") {const activeBtn = controller.element.querySelector("#configBazaarDownloaded")?.previousElementSiblingdiff --git a/app/src/config/tabs/ai/aiCapabilityUi.ts b/app/src/config/tabs/ai/aiCapabilityUi.tsindex 093f25f854..2a88945c66 100644--- a/app/src/config/tabs/ai/aiCapabilityUi.ts+++ b/app/src/config/tabs/ai/aiCapabilityUi.ts@@ -1,5 +1,6 @@import {escapeAttr, escapeHtml} from "../../../util/escape";import {fetchPost} from "../../../util/fetch";+import {fitSelectWidthToOptions} from "../../../util/select";import {listCapabilityManifests} from "../../../layout/dock/agent/frontendCapabilities";import {AgentActionApprovalDecision,@@ -346,6 +347,7 @@ const openAgentCapabilityView = (settingRoot: HTMLElement, backendCapabilities:const selected = capabilities.filter((capability) => isCapabilityAllowed(capability.id, scope)).length;count.textContent = window.siyuan.languages.agentCapabilitiesSelected.replace("${selected}", String(selected)).replace("${total}", String(capabilities.length));+ list.querySelectorAll<HTMLSelectElement>(".b3-select").forEach(fitSelectWidthToOptions);const groupEntries = Array.from(groups.values());list.querySelectorAll<HTMLElement>("[data-type='toggleAgentCapabilityGroup']").forEach((button) => {diff --git a/app/src/config/tabs/appTab.ts b/app/src/config/tabs/appTab.tsindex 66e5d40669..b1429837bd 100644--- a/app/src/config/tabs/appTab.ts+++ b/app/src/config/tabs/appTab.ts@@ -24,6 +24,7 @@ import {afterExport} from "../../protyle/export/util";import {genConfigItemMainHtml, genConfigItemName} from "../render/fragments";import {sendAppSetting} from "./appRuntime";import {getHostCapabilities} from "../../util/hostCapabilities";+import {fitSelectWidthToOptions} from "../../util/select";/// #if MOBILEconst registerAppWorkspaceGroup = (tab: SettingTabBuilder) => {@@ -258,15 +259,7 @@ const mountNetworkProxy = (root: HTMLElement) => {const schemeElement = root.querySelector("#networkProxyScheme") as HTMLSelectElement;const hostElement = root.querySelector("#networkProxyHost") as HTMLInputElement;const portElement = root.querySelector("#networkProxyPort") as HTMLInputElement;- const schemeStyle = getComputedStyle(schemeElement);- const measureContext = document.createElement("canvas").getContext("2d");- if (measureContext) {- measureContext.font = schemeStyle.font;- const optionWidth = Array.from(schemeElement.options).reduce((width, option) =>- Math.max(width, measureContext.measureText(option.text).width), 0);- const paddingWidth = Number.parseFloat(schemeStyle.paddingLeft) + Number.parseFloat(schemeStyle.paddingRight);- schemeElement.style.minWidth = `${Math.ceil(optionWidth + paddingWidth)}px`;- }+ fitSelectWidthToOptions(schemeElement);const updateInputs = () => {const disabled = schemeElement.value === "" || schemeElement.value === "system";hostElement.disabled = disabled;diff --git a/app/src/util/select.ts b/app/src/util/select.tsnew file mode 100644index 0000000000..fa4e7df176--- /dev/null+++ b/app/src/util/select.ts@@ -0,0 +1,12 @@+export const fitSelectWidthToOptions = (selectElement: HTMLSelectElement) => {+ const style = getComputedStyle(selectElement);+ const measureContext = document.createElement("canvas").getContext("2d");+ if (!measureContext) {+ return;+ }+ measureContext.font = style.font;+ const optionWidth = Array.from(selectElement.options).reduce((width, option) =>+ Math.max(width, measureContext.measureText(option.text).width), 0);+ const paddingWidth = Number.parseFloat(style.paddingLeft) + Number.parseFloat(style.paddingRight);+ selectElement.style.minWidth = `${Math.ceil(optionWidth + paddingWidth)}px`;+};