Understanding how copy-paste work #253
cruxcode
started this conversation in
Guides: Atri Framework Reference
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's suppose there is a very simple component structure on the canvas. One flexbox with a button inside it.
Now if we select the flexbox and copy press
Ctrl+C
to copy it and paste it inside the JSON editor, it lookssomewhat like this. I've removed some extra styles etc. for simplicity.
Every component has an id attached to it, the JSON for that component has the id of itself as well as the parent.
The outermost component in our set is assigned the special
templateRoot
. The JSON also shows that on pasting thisset of components it emits numerous events, though it only made up of two simple components. The
cssTree
,componentTree
,callbackHandlerTree
andcustomPropsTree
all emit a separate event which can be seen in the JSON above.Copy pasting in case of templates is handled just like wiring. We see the outermost element and handle undo redo by triggering opposite events for the same. When we paste this set of components inside something, the id
parentRoot
earlier assigned is replacedwith the id of new parent component. The JSON also has a copied id which is same as that of the flexbox so that
after pasting if we want to undo our action, we can just reference the copied id and the entire set of components
gets removed.
Beta Was this translation helpful? Give feedback.
All reactions