I am working on my very first plugin for Obsidian - a simple way to arrange and organize nodes in canvas view. Just to test and get things working I am trying to move a selected node 50 units to the right – but it’s not working.
Its accepting the new values but the node isn’t moved in the canvas view. Below is the code I am using, but not having much luck – could someone point me in the right direction? (ie. how to mode a node, maybe even resized it, etc) I apologize if this is a basic question - I am just a beginner.
selectedNodes.forEach((nodeId: string) => {
const node = canvas.nodes[nodeId];
if (node?.position) {
console.log("Node details before move:", node);
// Update position
const newX = node.position.x + 50;
const newY = node.position.y;
node.position = { x: newX, y: newY };
console.log(`Updated position for node ${node.id}:`, node.position);
} else {
console.error(`Node ${nodeId} does not support movement.`);
}
});
// Trigger canvas re-render
canvas.requestSave();
canvas.render();