Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/text editor/link editor: tweak UI
Adorian Doranf8dd76286a77
diff --git a/apps/client/src/widgets/dialogs/add_link.css b/apps/client/src/widgets/dialogs/add_link.cssindex 142a9cfbd3..82b9a680b8 100644--- a/apps/client/src/widgets/dialogs/add_link.css+++ b/apps/client/src/widgets/dialogs/add_link.css@@ -47,10 +47,7 @@.add-link-target {display: flex;- width: 100%;-- .btn {- flex: 1;- }+ width: fit-content;+ margin: 0 auto 1rem;}}diff --git a/apps/client/src/widgets/dialogs/add_link.spec.tsx b/apps/client/src/widgets/dialogs/add_link.spec.tsxindex a84b219420..30be856993 100644--- a/apps/client/src/widgets/dialogs/add_link.spec.tsx+++ b/apps/client/src/widgets/dialogs/add_link.spec.tsx@@ -106,13 +106,16 @@ describe("AddLinkDialog", () => {it("inserts a typed web link, titled by its URL unless given a text", async () => {await open();expect(headings()).toStrictEqual([]);- expect(container.querySelector(".tn-card .tn-segmented-choice")).not.toBeNull();+ const segmented = container.querySelector(".tn-segmented-choice");+ expect(segmented).not.toBeNull();+ expect(segmented?.closest(".tn-card")).toBeNull();+ expect(segmented?.nextElementSibling?.classList.contains("tn-card")).toBe(true);expect(choice().map((button) => button.textContent?.trim()))- .toStrictEqual([ "add_link.note", "add_link.web_link" ]);+ .toStrictEqual([ "add_link.web_link", "add_link.note" ]);expect(current()).toBe("add_link.note");expect(container.querySelector(".note-autocomplete")).not.toBeNull();- await act(async () => choice()[1]?.click());+ await act(async () => choice()[0]?.click());expect(current()).toBe("add_link.web_link");expect(container.querySelector(".note-autocomplete")).toBeNull();expect(field("url")?.inputMode).toBe("url");@@ -123,7 +126,7 @@ describe("AddLinkDialog", () => {.toHaveBeenLastCalledWith("https://example.com", "https://example.com", true);await open();- await act(async () => choice()[1]?.click());+ await act(async () => choice()[0]?.click());await type(field("url"), "https://trilium.cc");expect(nested("text")).toBe(true);expect(stacked()).toStrictEqual([]);diff --git a/apps/client/src/widgets/dialogs/add_link.tsx b/apps/client/src/widgets/dialogs/add_link.tsxindex b183928bd3..7e79956882 100644--- a/apps/client/src/widgets/dialogs/add_link.tsx+++ b/apps/client/src/widgets/dialogs/add_link.tsx@@ -10,7 +10,7 @@ import tree from "../../services/tree";import { isMobile } from "../../services/utils";import { logError } from "../../services/ws";import Button from "../react/Button";-import { Card, CardSection, OptionCardSection } from "../react/Card";+import { Card, OptionCardSection } from "../react/Card";import FormSelect from "../react/FormSelect";import FormTextBox from "../react/FormTextBox";import FormToggle from "../react/FormToggle";@@ -408,22 +408,20 @@ function useAddLinkForm(opts: AddLinkOpts | undefined) {onShown: () => setIsShowPending(true),applyLink,reset,- body: (- <Card>- {!opts?.fixLink && (- <CardSection>- <SegmentedChoice<LinkTarget>- className="add-link-target"- options={[- { value: "note", label: t("add_link.note"), icon: "bx-note" },- { value: "url", label: t("add_link.web_link"), icon: "bx-globe" }- ]}- currentValue={target}- onChange={(next) => changeTarget(next)}- />- </CardSection>- )}+ body: (<>+ {!opts?.fixLink && (+ <SegmentedChoice<LinkTarget>+ className="add-link-target"+ options={[+ { value: "url", label: t("add_link.web_link"), icon: "bx-globe" },+ { value: "note", label: t("add_link.note"), icon: "bx-note" }+ ]}+ currentValue={target}+ onChange={(next) => changeTarget(next)}+ />+ )}+ <Card>{target === "url" ? (<OptionCardSectionclassName="add-link-url" name="url" label={t("add_link.url")}@@ -508,7 +506,7 @@ function useAddLinkForm(opts: AddLinkOpts | undefined) {</>)}</Card>- )+ </>)};}