Edit context rules
November 27, 2018 ยท View on GitHub
The edit context is the scope in which selection and edit operations must occur:
- If the user has drilled down into a container node, that container is the current edit context and only its immediate children are in scope for selection/editing.
- If the user hasn't drilled into any container nodes, then XD is in the root edit context, and its scope includes all immediate children of the pasteboard (including Artboards), and all immediate children of all those Artboards.
Like nearly all edit operations in XD, your plugin is limited to making changes inside the scope of the current edit context.

Simple changes can be made directly to the scenegraph nodes that are in scope:
- Change a property
- Delete a node
- Add a new leaf node (basic shape node)
Structural changes cannot be made directly, since their impact extends to nodes outside the edit context's scope. You can make structural changes by scripting XD commands:
- Ungroup (or break apart other container types) - use the
ungroup()command - Create new Groups (add a whole tree of new nodes) - use the
group()command - Rearrange Z order - use commands such as
bringToFront()
If a plugin breaks any of these rules, its entire edit operation will be reverted to protect the user's document from corruption.