Skip to content

ENG-1549: Add convert existing page to discourse node command#987

Open
sid597 wants to merge 2 commits intomainfrom
eng-1549-convert-existing-page-to-node-roam
Open

ENG-1549: Add convert existing page to discourse node command#987
sid597 wants to merge 2 commits intomainfrom
eng-1549-convert-existing-page-to-node-roam

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 ↗︎.

devin-ai-integration[bot]

This comment was marked as resolved.

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 new potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment thread apps/roam/src/utils/registerCommandPaletteCommands.ts
@sid597 sid597 requested a review from mdroidian May 2, 2026 06:52
createOverride?: (args: {
formattedTitle: string;
configPageUid: string;
}) => Promise<string | void>;
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.

Why void?

const configPageUid = selectedNodeType?.type ?? "";
const overrideUid = createOverride
? await createOverride({ formattedTitle, configPageUid })
: undefined;
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 just do a single const:

const overrideUid = createOverride
          ? await createOverride({ formattedTitle, configPageUid })
          : await createDiscourseNode({
              text: formattedTitle,
              configPageUid,
              extensionAPI,
              imageUrl,
            });

Comment on lines +169 to +205
const nodeTree = getFullTreeByParentUid(configPageUid).children;
const templateNode = getSubTree({ tree: nodeTree, key: "template" });
if (templateNode.children.length > 0) {
const hasSmartBlockSyntax = (
node: Parameters<typeof stripUid>[0][0],
): boolean => {
if (node.text.includes("<%")) return true;
if (node.children) return node.children.some(hasSmartBlockSyntax);
return false;
};
const useSmartBlocks = hasSmartBlockSyntax(templateNode);

if (useSmartBlocks && window.roamjs?.extension?.smartblocks) {
void window.roamjs.extension.smartblocks?.triggerSmartblock({
srcUid: templateNode.uid,
targetUid: pageUid,
});
} else {
if (useSmartBlocks) {
renderToast({
content:
"This template requires SmartBlocks. Enable SmartBlocks in Roam Depot to use this template.",
id: "smartblocks-extension-disabled",
intent: "warning",
});
}
const existingChildren =
getFullTreeByParentUid(pageUid).children || [];
const lastOrder = existingChildren.length;
await Promise.all(
stripUid(templateNode.children).map((node, order) =>
createBlock({
node,
order: lastOrder + order,
parentUid: pageUid,
}),
),
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 looks like code that is used elsewhere. Can we DRY it?

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