Skip to content

ENG-1553: Embed canvas in block#988

Open
sid597 wants to merge 2 commits intomainfrom
eng-1553-embed-canvas-in-block
Open

ENG-1553: Embed canvas in block#988
sid597 wants to merge 2 commits intomainfrom
eng-1553-embed-canvas-in-block

Conversation

@sid597
Copy link
Copy Markdown
Collaborator

@sid597 sid597 commented Apr 30, 2026

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 30, 2026

@supabase
Copy link
Copy Markdown

supabase Bot commented Apr 30, 2026

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment thread apps/roam/src/utils/registerCommandPaletteCommands.ts Outdated
Cast window.roamAlphaAPI.ui to access untyped slashCommand API
with proper type annotation instead of relying on any. Fix void
callback returning null.
@sid597 sid597 requested a review from mdroidian May 2, 2026 06:52
const CanvasEmbedPlaceholder = ({ message }: { message: string }) => (
<div
style={{
display: "flex",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tailwind

button: HTMLElement,
onloadArgs: OnloadArgs,
) => {
button.style.display = "none";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tailwind class

if (!title) return;

const currentPageTitle = getCurrentPageTitle(button);
if (currentPageTitle === title) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problem is this solving?

return;
}

button.parentElement.onmousedown = (e: MouseEvent) => e.stopPropagation();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problem is this solving?

button.parentElement.onmousedown = (e: MouseEvent) => e.stopPropagation();

const wrapper = document.createElement("div");
wrapper.className = "dg-canvas-embed";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tailwind

Comment on lines +14 to +26
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 }][];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts
    • getCanvasPageTargets() 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.tsx
    • checkForCanvasPage() 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isOpen={isOpen}
onClose={onClose}
title="Embed Canvas"
style={{ width: 400, paddingBottom: 0 }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use tailwind (multiple places in this component)

@@ -314,6 +315,31 @@ export const registerCommandPaletteCommands = (onloadArgs: OnloadArgs) => {
};

// Roam organizes commands alphabetically
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants