Skip to content

Commit 0ca5ed6

Browse files
committed
cleanup
1 parent dfa6bad commit 0ca5ed6

4 files changed

Lines changed: 26 additions & 26 deletions

File tree

apps/roam/src/components/AdvancedNodeSearchDialog/AdvancedSearchDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { DiscourseNodeSortControl } from "~/components/DiscourseNodeSortControl"
2323
import getDiscourseNodes, {
2424
type DiscourseNode,
2525
} from "~/utils/getDiscourseNodes";
26-
import { openSearchResultInMain } from "~/utils/advancedSearchNavigation";
26+
import { openSearchResultInMain } from "~/utils/advancedSearchFooterUtils";
2727
import { openDgSearchInSidebar } from "~/utils/openDgSearchInSidebar";
2828
import {
2929
DEBOUNCE_MS,

apps/roam/src/components/AdvancedNodeSearchDialog/AdvancedSearchSidebarPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { SORT_FIELD_LABELS, isNonDefaultSort, type SortConfig } from "./utils";
2525
import getRoamUrl from "roamjs-components/dom/getRoamUrl";
2626
import type { DiscourseNode } from "~/utils/getDiscourseNodes";
2727
import { getNodeTagStyles } from "~/utils/getDiscourseNodeColors";
28-
import { openSearchResultFromLinkEvent } from "~/utils/advancedSearchNavigation";
2928
import { splitWithHighlights, stripTypePrefix } from "./utils";
29+
import { openSearchResultFromLinkEvent } from "~/utils/advancedSearchFooterUtils";
3030

3131
const renderHighlightedText = (
3232
text: string,

apps/roam/src/utils/advancedSearchFooterUtils.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import getUids from "roamjs-components/dom/getUids";
22
import getTextByBlockUid from "roamjs-components/queries/getTextByBlockUid";
33
import updateBlock from "roamjs-components/writes/updateBlock";
4+
import getPageTitleByPageUid from "roamjs-components/queries/getPageTitleByPageUid";
5+
import openBlockInSidebar from "roamjs-components/writes/openBlockInSidebar";
46

57
export type BlockSelection = {
68
selectionStart: number;
@@ -17,6 +19,28 @@ export type InsertTarget = {
1719

1820
const DEFAULT_WINDOW_ID = "main-window";
1921

22+
export const openSearchResultInMain = async (uid: string): Promise<void> => {
23+
if (getPageTitleByPageUid(uid)) {
24+
await window.roamAlphaAPI.ui.mainWindow.openPage({ page: { uid } });
25+
return;
26+
}
27+
await window.roamAlphaAPI.ui.mainWindow.openBlock({ block: { uid } });
28+
};
29+
30+
export const openSearchResultFromLinkEvent = async ({
31+
shiftKey,
32+
uid,
33+
}: {
34+
shiftKey: boolean;
35+
uid: string;
36+
}): Promise<void> => {
37+
if (shiftKey) {
38+
await openBlockInSidebar(uid);
39+
return;
40+
}
41+
await openSearchResultInMain(uid);
42+
};
43+
2044
export const getBlockSelection = (uid: string): BlockSelection => {
2145
const activeElement = document.activeElement;
2246
const isFocusedTextarea =

apps/roam/src/utils/advancedSearchNavigation.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)