-
Notifications
You must be signed in to change notification settings - Fork 16
Feat: single-pod cut-n-paste support #165
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
Feat: single-pod cut-n-paste support #165
Conversation
Thanks, Xinyi! Yes, this is what we want. @forrestbao FYI, this would complete #99 and deprecate #143 Later, we'll have another PR to support copy/cut for a scope (recursively for all descendants). |
Update: Check if there is an in-progress pasting before exiting. If there is, do what Esc does. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@@ -1344,12 +1394,16 @@ export function Canvas() { | |||
checkNodesEndLocation(event, [currentNode], "ROOT"); | |||
//clear the pasting state | |||
setPasting(null); | |||
// delete the original (hidden) node | |||
if (cutting) { | |||
reactFlowInstance.deleteElements({ nodes: [{ id: cutting }] }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When cutting, once the user left-click to drop the node, it will trigger:
- add the new node (the
addPod(apolloClient, ...)
above) - delete the original hidden node.
I'm having some trouble with 2. This line seems to trigger deletePod(null, ...)
in nodes.tsx
, so there won't be a remote deletePod
graphql query. But I do see a deletePod
query. Can you point out where does that deletePod
query come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. It should come from onNodesDelete
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it triggers onNodeChanges
's delete
type when deleteElements
is called, which deletes the corresponding in nodesMap
, any deletion in nodesMap
invokes a deletePod(null, ...)
call.
I generalized the logic in #184. This PR is almost done, except I need a better implementation to create a scope as well as its children in DB at once. You can try that PR to see if it is the expected behavior of scope cut-copy-paste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, thanks. Yeah, that PR is a great reference on this. I'll take a close look.
Don't merge now, this is just a demo to align the idea of cut-n-paste functionality and tests. The code is too dirty now, clean-up is required after we agree on the idea.Update: clean-up & ready for review.
How to use:
Note:
Any test and suggestion are welcome.