I’m in the process of learning a lot of the UXP Documentation. Using @DavideBarranca new “UXP plugins developement with React JS”. I had some code working that would play an action from an action set in API 1. When I upgraded to the PS 2022, my practice plug in wouldn’t load and stated that I had to switch to API 2. Now in API 2 the following code will no longer play the action.
const doAction = async (actionset, action) => {
console.log(actionset, action);
photoshop.app.actionTree
.find(({name}) => name === actionset)
.actions
.find(({name}) => name === action)
.play()
}
When I tried logging the promise associated with play() it said it was rejected:
- Promise {[[PromiseState]]: “pending”, [[PromiseResult]]: undefined}
- proto: Promise
- [[PromiseState]]: “rejected”
- [[PromiseResult]]: Error: Event: play may modify the state of Photoshop. Such events are only allowed from inside a modal scope
So I tried using executeAsModal and got it to play the action:
const executeAsModal = require(“photoshop”).core.executeAsModal;
const doAction = async (actionset, action) => { await executeAsModal(async () => {
console.log(actionset, action);
await photoshop.app.actionTree
.find(({name}) => name === actionset)
.actions
.find(({name}) => name === action)
.play()
})
}
The issue I am having now is that every dialog box that may be associated with a given step with in the action pops up forcing the user to click ok on each rather than running the action without user input.
Is there a way to suppress these dialog boxes and run the action all the way through without user input/confirmation?