Skip to content

Commit 546ef76

Browse files
committed
Refactor ResultsTable to streamline link rendering and remove CellLink component
- Removed the CellLink component and integrated its functionality directly into ResultRow for improved clarity. - Updated link rendering logic to handle both 'link' and 'alias' views more efficiently. - Simplified event handling for link interactions, enhancing overall performance.
1 parent 111e91b commit 546ef76

File tree

1 file changed

+2
-58
lines changed

1 file changed

+2
-58
lines changed

apps/roam/src/components/results-view/ResultsTable.tsx

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -240,55 +240,6 @@ export const CellRender = ({
240240
return <span ref={contentRef} className="roamjs-query-link-cell" />;
241241
};
242242

243-
export const CellLink = ({
244-
content,
245-
uid,
246-
url,
247-
ctrlClick,
248-
}: {
249-
content: string;
250-
uid: string;
251-
url?: string;
252-
ctrlClick?: (e: { text: string; uid: string }) => void;
253-
}) => {
254-
const pageTitle = getPageTitleByPageUid(uid);
255-
return (
256-
<a
257-
className={"rm-page-ref"}
258-
data-link-title={pageTitle || ""}
259-
href={url || getRoamUrl(uid)}
260-
onMouseDown={(e) => {
261-
if (e.shiftKey) {
262-
void openBlockInSidebar(uid);
263-
e.preventDefault();
264-
e.stopPropagation();
265-
} else if (e.ctrlKey && ctrlClick) {
266-
ctrlClick({
267-
text: content,
268-
uid,
269-
});
270-
e.preventDefault();
271-
e.stopPropagation();
272-
}
273-
}}
274-
onClick={(e) => {
275-
if (e.shiftKey || e.ctrlKey) {
276-
e.preventDefault();
277-
e.stopPropagation();
278-
}
279-
}}
280-
onContextMenu={(e) => {
281-
if (e.ctrlKey) {
282-
e.preventDefault();
283-
e.stopPropagation();
284-
}
285-
}}
286-
>
287-
{content}
288-
</a>
289-
);
290-
};
291-
292243
type ResultRowProps = {
293244
r: Result;
294245
columns: Column[];
@@ -441,16 +392,9 @@ const ResultRow = ({
441392
>
442393
{val === "" ? (
443394
<i>[block is blank]</i>
444-
) : view === "link" ? (
445-
<CellLink
446-
content={val.toString()}
447-
uid={uid}
448-
url={(r[`${key}-url`] as string) || undefined}
449-
ctrlClick={ctrlClick}
450-
/>
451395
) : view === "render" ? (
452396
<CellRender content={val.toString()} uid={uid} />
453-
) : view === "alias" ? (
397+
) : view === "link" || view === "alias" ? (
454398
<a
455399
className={"rm-page-ref"}
456400
data-link-title={getPageTitleByPageUid(uid) || ""}
@@ -482,7 +426,7 @@ const ResultRow = ({
482426
}
483427
}}
484428
>
485-
{viewValue}
429+
{view === "alias" ? viewValue : cell(key)}
486430
</a>
487431
) : view === "embed" ? (
488432
<CellEmbed uid={uid} viewValue={viewValue} />

0 commit comments

Comments
 (0)