From ce9010ff13287f0e3adeb5eebd7c5f8470db8327 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 7 Jul 2025 20:04:17 +0300 Subject: [PATCH] chore(client): add some documentation --- apps/client/src/services/link.ts | 8 ++++++++ apps/client/src/widgets/note_tree.ts | 3 +++ 2 files changed, 11 insertions(+) diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts index 107a9c9e3..a16f0bccf 100644 --- a/apps/client/src/services/link.ts +++ b/apps/client/src/services/link.ts @@ -277,6 +277,14 @@ function goToLink(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent) { return goToLinkExt(evt, hrefLink, $link); } +/** + * Handles navigation to a link, which can be an internal note path (e.g., `#root/1234`) or an external URL (e.g., `https://example.com`). + * + * @param evt the event that triggered the link navigation, or `null` if the link was clicked programmatically. Used to determine if the link should be opened in a new tab/window, based on the button presses. + * @param hrefLink the link to navigate to, which can be a note path (e.g., `#root/1234`) or an external URL with any supported protocol (e.g., `https://example.com`). + * @param $link the jQuery element of the link that was clicked, used to determine if the link is an anchor link (e.g., `#fn1` or `#fnref1`) and to handle it accordingly. + * @returns `true` if the link was handled (i.e., the element was found and scrolled to), or a falsy value otherwise. + */ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent | React.PointerEvent | null, hrefLink: string | undefined, $link?: JQuery | null) { if (hrefLink?.startsWith("data:")) { return true; diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts index ea6e50325..1a9bb5ce6 100644 --- a/apps/client/src/widgets/note_tree.ts +++ b/apps/client/src/widgets/note_tree.ts @@ -186,6 +186,9 @@ interface RefreshContext { noteIdsToReload: Set; } +/** + * The information contained within a drag event. + */ export interface DragData { noteId: string; branchId: string;