-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-1252 - Query builder link renderString #675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mdroidian
merged 7 commits into
main
from
cursor/ENG-1252-query-builder-link-render-a08c
Jan 12, 2026
+13,769
−7,719
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c61acdf
feat: Add CellLink component for rendering links in results
cursoragent ca99d60
Refactor CellLink to remove unused props and simplify event handling
cursoragent fabebd0
Fix: Render links correctly in ResultsTable
cursoragent bbe4147
Update roamjs-components to version 0.86.3 and enhance error handling…
mdroidian e3d6c0c
misc lint fixes
mdroidian a86dca4
Refactor ResultsTable and ResultsView components to enhance link rend…
mdroidian ce67dd8
Refactor ResultsTable to streamline link rendering and remove CellLin…
mdroidian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import { CONTEXT_OVERLAY_SUGGESTION } from "~/utils/predefinedSelections"; | |
| import { USE_REIFIED_RELATIONS } from "~/data/userSettings"; | ||
| import { getSetting } from "~/utils/extensionSettings"; | ||
| import { strictQueryForReifiedBlocks } from "~/utils/createReifiedBlock"; | ||
| import internalError from "~/utils/internalError"; | ||
|
|
||
| const EXTRA_ROW_TYPES = ["context", "discourse"] as const; | ||
| type ExtraRowType = (typeof EXTRA_ROW_TYPES)[number] | null; | ||
|
|
@@ -35,17 +36,35 @@ const ExtraContextRow = ({ uid }: { uid: string }) => { | |
| useEffect(() => { | ||
| if (!containerRef.current) return; | ||
| if (getPageTitleByPageUid(uid)) { | ||
| window.roamAlphaAPI.ui.components.renderPage({ | ||
| uid, | ||
| el: containerRef.current, | ||
| "hide-mentions?": true, | ||
| }); | ||
| window.roamAlphaAPI.ui.components | ||
| .renderPage({ | ||
| uid, | ||
| el: containerRef.current, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| "hide-mentions?": true, | ||
| }) | ||
| .catch((error) => { | ||
| internalError({ | ||
| error, | ||
| type: "Results Table: Extra Context Row", | ||
| context: { uid }, | ||
| }); | ||
| }); | ||
| } else { | ||
| window.roamAlphaAPI.ui.components.renderBlock({ | ||
| uid, | ||
| el: containerRef.current, | ||
| "zoom-path?": true, | ||
| }); | ||
| window.roamAlphaAPI.ui.components | ||
| .renderBlock({ | ||
| uid, | ||
| el: containerRef.current, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| "zoom-path?": true, | ||
| }) | ||
| .catch((error) => { | ||
| internalError({ | ||
| error, | ||
| type: "Results Table: Extra Context Row", | ||
| context: { uid }, | ||
| }); | ||
| }); | ||
| } | ||
| }, [containerRef, uid]); | ||
|
|
||
|
|
@@ -69,19 +88,16 @@ const ResultHeader = React.forwardRef< | |
| columnWidth?: string; | ||
| } | ||
| >( | ||
| ( | ||
| { | ||
| c, | ||
| allResults, | ||
| activeSort, | ||
| setActiveSort, | ||
| filters, | ||
| setFilters, | ||
| initialFilter, | ||
| columnWidth, | ||
| }, | ||
| ref, | ||
| ) => { | ||
| ({ | ||
| c, | ||
| allResults, | ||
| activeSort, | ||
| setActiveSort, | ||
| filters, | ||
| setFilters, | ||
| initialFilter, | ||
| columnWidth, | ||
| }) => { | ||
| const filterData = useMemo( | ||
| () => ({ | ||
| values: Array.from( | ||
|
|
@@ -155,6 +171,8 @@ const ResultHeader = React.forwardRef< | |
| }, | ||
| ); | ||
|
|
||
| ResultHeader.displayName = "ResultHeader"; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lint fix |
||
|
|
||
| export const CellEmbed = ({ | ||
| uid, | ||
| viewValue, | ||
|
|
@@ -167,22 +185,61 @@ export const CellEmbed = ({ | |
| useEffect(() => { | ||
| const el = contentRef.current; | ||
| const open = | ||
| viewValue === "open" ? true : viewValue === "closed" ? false : null; | ||
| viewValue === "open" ? true : viewValue === "closed" ? false : undefined; | ||
| if (el) { | ||
| window.roamAlphaAPI.ui.components.renderBlock({ | ||
| uid, | ||
| el, | ||
| // @ts-expect-error - add to roamjs-components | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| "open?": open, | ||
| }); | ||
| window.roamAlphaAPI.ui.components | ||
| .renderBlock({ | ||
| uid, | ||
| el, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| "open?": open, | ||
| }) | ||
| .catch((error) => { | ||
| internalError({ | ||
| error, | ||
| type: "Results Table: Cell Embed", | ||
| context: { uid }, | ||
| }); | ||
| }); | ||
| } | ||
| }, [contentRef, uid, viewValue]); | ||
| return ( | ||
| <div ref={contentRef} className={title ? "page-embed" : "block-embed"} /> | ||
| ); | ||
| }; | ||
|
|
||
| export const CellRender = ({ | ||
| content, | ||
| uid, | ||
| }: { | ||
| content: string; | ||
| uid: string; | ||
| }) => { | ||
| const contentRef = useRef<HTMLSpanElement>(null); | ||
| const isPage = !!getPageTitleByPageUid(uid); | ||
| const displayString = isPage ? `[[${content}]]` : content; | ||
|
|
||
| useEffect(() => { | ||
| const el = contentRef.current; | ||
| if (el && displayString) { | ||
| window.roamAlphaAPI.ui.components | ||
| .renderString({ | ||
| el, | ||
| string: displayString, | ||
| }) | ||
| .catch((error) => { | ||
| internalError({ | ||
| error, | ||
| type: "Results Table: Cell Render", | ||
| context: { displayString }, | ||
| }); | ||
| }); | ||
| } | ||
| }, [displayString]); | ||
|
|
||
| return <span ref={contentRef} className="roamjs-query-link-cell" />; | ||
| }; | ||
|
|
||
| type ResultRowProps = { | ||
| r: Result; | ||
| columns: Column[]; | ||
|
|
@@ -328,20 +385,23 @@ const ResultRow = ({ | |
| className={"relative overflow-hidden text-ellipsis"} | ||
| key={key} | ||
| {...{ | ||
| [`data-cell-content`]: typeof val === "string" ? val : `${val}`, | ||
| [`data-cell-content`]: | ||
| typeof val === "string" ? val : String(val), | ||
| [`data-column-title`]: key, | ||
| }} | ||
| > | ||
| {val === "" ? ( | ||
| <i>[block is blank]</i> | ||
| ) : view === "render" ? ( | ||
| <CellRender content={val.toString()} uid={uid} /> | ||
| ) : view === "link" || view === "alias" ? ( | ||
| <a | ||
| className={"rm-page-ref"} | ||
| data-link-title={getPageTitleByPageUid(uid) || ""} | ||
| href={(r[`${key}-url`] as string) || getRoamUrl(uid)} | ||
| onMouseDown={(e) => { | ||
| if (e.shiftKey) { | ||
| openBlockInSidebar(uid); | ||
| void openBlockInSidebar(uid); | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| } else if (e.ctrlKey) { | ||
|
|
@@ -641,7 +701,7 @@ const ResultsTable = ({ | |
| key: "filters", | ||
| parentUid, | ||
| }); | ||
| filtersNode.children.forEach((c) => deleteBlock(c.uid)); | ||
| filtersNode.children.forEach((c) => void deleteBlock(c.uid)); | ||
| Object.entries(fs) | ||
| .filter( | ||
| ([, data]) => data.includes.values.size || data.excludes.values.size, | ||
|
|
@@ -663,12 +723,13 @@ const ResultsTable = ({ | |
| }, | ||
| ], | ||
| })) | ||
| .forEach((node, order) => | ||
| createBlock({ | ||
| parentUid: filtersNode.uid, | ||
| node, | ||
| order, | ||
| }), | ||
| .forEach( | ||
| (node, order) => | ||
| void createBlock({ | ||
| parentUid: filtersNode.uid, | ||
| node, | ||
| order, | ||
| }), | ||
| ); | ||
| }, | ||
| [setFilters, preventSavingSettings, parentUid], | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint fix