Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving multiple blocks with Inbox doesn't maintain tree structure #456

Open
mdroidian opened this issue Oct 11, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@mdroidian
Copy link
Collaborator

mdroidian commented Oct 11, 2023

Reported by Ekuboh, roam slack

https://www.loom.com/share/f0e96c5ff05e4ba793c74bd5b14c6fcb

Solution:

  • calculate parent blocks
  • move only parent block (children will follow)

const moveBlocks = ({
uids,
base = 0,
parentUid,
blockRef = false,
}: {
uids: string[];
base?: number;
parentUid: string;
blockRef?: string | boolean;
}) =>
Promise.all(
uids.map((uid, order) =>
blockRef === "reverse"
? createBlock({
parentUid,
order: base + order,
node: { text: `((${uid}))` },
})
: blockRef
? createBlock({
parentUid: getParentUidByBlockUid(uid),
order: getOrderByBlockUid(uid),
node: { text: `((${uid}))` },
}).then(() =>
window.roamAlphaAPI.moveBlock({
location: { "parent-uid": parentUid, order: base + order },
block: { uid },
})
)
: window.roamAlphaAPI.moveBlock({
location: { "parent-uid": parentUid, order: base + order },
block: { uid },
})
)
);

@mdroidian mdroidian added the bug Something isn't working label Oct 11, 2023
@mdroidian
Copy link
Collaborator Author

Current workaround: If you move them one tree at a time, it will maintain the tree structure.
Put your cursor on the first block of the tree, then run the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant