Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Cast window.roamAlphaAPI.ui to access untyped slashCommand API with proper type annotation instead of relying on any. Fix void callback returning null.
| const CanvasEmbedPlaceholder = ({ message }: { message: string }) => ( | ||
| <div | ||
| style={{ | ||
| display: "flex", |
| button: HTMLElement, | ||
| onloadArgs: OnloadArgs, | ||
| ) => { | ||
| button.style.display = "none"; |
| if (!title) return; | ||
|
|
||
| const currentPageTitle = getCurrentPageTitle(button); | ||
| if (currentPageTitle === title) { |
| return; | ||
| } | ||
|
|
||
| button.parentElement.onmousedown = (e: MouseEvent) => e.stopPropagation(); |
| button.parentElement.onmousedown = (e: MouseEvent) => e.stopPropagation(); | ||
|
|
||
| const wrapper = document.createElement("div"); | ||
| wrapper.className = "dg-canvas-embed"; |
| const { canvasPageFormat } = getFormattedConfigTree(); | ||
| const format = canvasPageFormat.value || DEFAULT_CANVAS_PAGE_FORMAT; | ||
| const regexSource = `^${format.replace(/\*/g, ".+")}$`; | ||
| const escaped = regexSource.replace(/\\/g, "\\\\").replace(/"/g, '\\"'); | ||
|
|
||
| try { | ||
| const results = window.roamAlphaAPI.q(`[ | ||
| :find (pull ?node [:node/title :block/uid]) | ||
| :where | ||
| [(re-pattern "${escaped}") ?regex] | ||
| [?node :node/title ?title] | ||
| [(re-find ?regex ?title)] | ||
| ]`) as [{ title: string; uid: string }][]; |
There was a problem hiding this comment.
Do we do this (both a identify canvas pages and b search for canvas pages) anywhere else in the codebase?
What parts can we make DRY?
EG:
apps/roam/src/utils/conditionToDatalog.tsgetCanvasPageTargets()scans all page names and filters them with a regex built from the canvas page format.
apps/roam/src/utils/isCanvasPage.ts- Checks whether a title matches the configured canvas format regex.
apps/roam/src/components/Export.tsxcheckForCanvasPage()uses the same regex-test style to determine if a selected page is a canvas page.
| style={{ width: 400, paddingBottom: 0 }} | ||
| > | ||
| <div style={{ padding: "16px" }}> | ||
| <InputGroup |
There was a problem hiding this comment.
Could we have used the <AutocompleteInput> component instead of rebuilding one from scratch? If yes, prefer that. If not, please identify what is blocking it.
There was a problem hiding this comment.
| isOpen={isOpen} | ||
| onClose={onClose} | ||
| title="Embed Canvas" | ||
| style={{ width: 400, paddingBottom: 0 }} |
There was a problem hiding this comment.
use tailwind (multiple places in this component)
| @@ -314,6 +315,31 @@ export const registerCommandPaletteCommands = (onloadArgs: OnloadArgs) => { | |||
| }; | |||
|
|
|||
| // Roam organizes commands alphabetically | |||
There was a problem hiding this comment.
This is for roam command palette commands, let's move the slashCommand outside of this comment.
|
|
||
| // Roam organizes commands alphabetically | ||
| ( | ||
| window.roamAlphaAPI.ui as unknown as { |
There was a problem hiding this comment.
If we are reaching for unknown because roamjs-components does not yet list this API, then we need to add it to roamjs-components. That should be part of this task (or as another task that is a prerequisite to completion), otherwise we will just keep adding unknown to our codebase, which is an anti-pattern.
https://www.loom.com/share/39b8760fe4094661a6f16f0fc764b4f5