@rehdie
From the looks of it, you’re using this as a modal?
application.editDocument
is primarily used for panels, while dialogs (by the user interaction of opening the dialog via the plugins menu) already have an “open” slot when you can edit the scenegraph
. Instead of using application.editDocument(...)
, you should be fine by just using it without it (as long as you return a Promise from your function that doesn’t resolve until the dialog is closed (i.e., as long as you need to make edits). As you already have an async
function awaiting dialog.showModal()
. That should work.
In your use-case, you should therefore be able to use
button.addEventListener('click', (e) => {
console.log('button clicked');
// Do scenegraph manipulation here
});
While it’s probably not impossible to use application.editDocument
with modals (in one way or another), it really is meant for persistent panel UIs, where you don’t have this modal-esque timeslot that lasts until the dialog gets closed, but instead have to instantiate such a timeslot (as a result of a user interaction) yourself.
I hope this helps,
Happy Coding,
Pablo
References:
- https://adobexdplatform.com/plugin-docs/reference/core/lifecycle.html#edit-operation-duration
- https://adobexdplatform.com/plugin-docs/reference/core/lifecycle.html#initiating-an-edit-operation-from-panel-ui
- https://adobexdplatform.com/plugin-docs/reference/core/lifecycle.html#modalexclusive-ui
- https://adobexdplatform.com/plugin-docs/reference/application.html#module_application-editDocument (Quote: This API is irrelevant for plugin menu item commands, which are wrapped in an edit batch automatically.)