Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/roam/src/components/ModifyNodeDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type ModifyNodeDialogProps = {
text: string;
uid: string;
action: string;
nodeType: string;
}) => Promise<void>;
onClose: () => void;
};
Expand Down Expand Up @@ -333,6 +334,7 @@ const ModifyNodeDialog = ({
text: content.text,
uid: content.uid,
action: "create",
nodeType: selectedNodeType.type,
});

onClose();
Expand Down Expand Up @@ -441,6 +443,7 @@ const ModifyNodeDialog = ({
text: formattedTitle,
uid: newPageUid,
action: "create",
nodeType: selectedNodeType.type,
});
} else {
// Edit mode: update the existing block
Expand Down Expand Up @@ -477,6 +480,7 @@ const ModifyNodeDialog = ({
text: updatedContent,
uid: sourceBlockUid || content.uid,
action: "edit",
nodeType: selectedNodeType.type,
});
}
onClose();
Expand Down
7 changes: 5 additions & 2 deletions apps/roam/src/components/canvas/DiscourseNodeUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export class BaseDiscourseNodeUtil extends BaseBoxShapeUtil<DiscourseNodeShape>
: undefined,
extensionAPI,
includeDefaultNodes: true,
onSuccess: async ({ text, uid, action }) => {
onSuccess: async ({ text, uid, action, nodeType }) => {
if (action === "edit") {
if (isPageUid(shape.props.uid))
await window.roamAlphaAPI.updatePage({
Expand All @@ -511,7 +511,10 @@ export class BaseDiscourseNodeUtil extends BaseBoxShapeUtil<DiscourseNodeShape>
// Node creation is handled by ModifyNodeDialog - no fallback needed here

void setSizeAndImgPropsLocal({ text, uid });
this.updateProps(shape.id, shape.type, {

// Update shape type if it has changed (e.g., user changed from Claim to Hypothesis during creation)
const finalShapeType = nodeType || shape.type;
this.updateProps(shape.id, finalShapeType, {
title: text,
uid,
});
Expand Down
8 changes: 5 additions & 3 deletions apps/roam/src/components/canvas/uiOverrides.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,24 @@ export const getOnSelectForShape = ({
extensionAPI,
includeDefaultNodes: true,
imageUrl,
onSuccess: async ({ text, uid }) => {
onSuccess: async ({ text, uid, nodeType: selectedNodeType }) => {
editor.deleteShapes([shape.id]);

// Use the selected node type from the dialog, which may have changed during creation
const finalNodeType = selectedNodeType || nodeType;
const {
h,
w,
imageUrl: nodeImageUrl,
} = await calcCanvasNodeSizeAndImg({
nodeText: text,
extensionAPI,
nodeType,
nodeType: finalNodeType,
uid,
});
editor.createShapes([
{
type: nodeType,
type: finalNodeType,
id: createShapeId(),
props: {
uid,
Expand Down
2 changes: 1 addition & 1 deletion apps/roam/src/utils/renderNodeTagPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const renderNodeTagPopupButton = (
nodeType: matchedNode.type,
initialValue: { text: cleanedBlockText, uid: "" },
initialReferencedNode,
onSuccess: async () => {
onSuccess: async ({ nodeType }) => {
// Success is handled by the dialog itself
},
onClose: () => {},
Expand Down