function setRootNodePluginData(data) {
scenegraph.root.pluginData = {data: data};
}
but when message received i’ve got error about edit context: Plugin Error: Plugin <PLUGIN_ID> is not permitted to make changes from the background. Use editDocument() for panel UI handlers, or return a Promise to extend an edit operation asynchronously.
Is there any way to edit scenegraph from background? Maybe some workarounds?
None that I’m aware of. The only “workaround” (and it really isn’t one, but just the only option I see of somehow doing this) would be to leave the plugin running in this time, but this would require the user not being able to edit the document during this time.
Maybe, with live collaboration now being a thing in XD, it would be possible to leave one computer running the plugin with another one doing the changes to the document, but that’s really just an option in some hacky use-case where you yourself are the plugin’s user (and it’s probably required to have two Adobe accounts for that to work). Since I believe we can both agree that this is far from practical in a real scenario, I tend to believe you’re out of luck there. Of course, it’s possible that I just don’t know of a workaround, if there is one, but for a first, quick response, I’d say it’s currently not possible.
Thanks for the answer. I think we can request a feature It would be great to have ability to store some common pluginData (on root node) outside edit context.
Ok, I’m curious (not saying anything is wrong, just interested in the why ). Without going into detail, I’d be interested to know why this uses a websocket, then. Are you using some external that you don’t have any control over? Because otherwise, a websocket that basically “resolves” fast enough that the above doesn’t cause problems sounds pretty much like an overly complicated HTTP request to me .
@kerrishotts Just out of curiosity (and, as it is potentially interesting for some personal projects of mine regarding automated plugin testing for XD): Could this actually work?
I’m not sure if that could work or not. IIRC, there were issues in the past wrt plugins & coediting, so you could get some very odd results. Not sure if those are still a thing (@schenglooi, is that still true?)
As for editing the root node’s data – because it’s part of the document (and has to be sync’d with the rest of XD and any attached editors), there’s no way to safely edit this without locking the document. So the promise solution is the correct way to handle things – lock the document until your response comes back.
XD doesn’t currently have the ability to start a server, but it’s something on my wishlist…
Coediting works if you are editing the same document from two devices though it doesn’t have to be two different accounts. Basically you can turn on coediting and share the document to yourself on two different devices. Keep in mind this is still a beta feature so there may will be weirdness still going on. Note that plugins that opens a modal dialog will block all future remote edits until the modal dialog is dismissed. And remote user that has first access to the document may also prevent the other user on a different device from changing the same document, i.e. some changes maybe auto-reverted.
Currently, any edits to the document, including the root node, must be done within editDocument context since it is an undoable change.