How to handle cancel during long editDocument()?

I had to redo part of my plugin because of a long process (see Vectorize plugin vectorizing the document). It wasn’t as difficult as I thought.

I used a pseudo sleep() method to give my loop time to breath and time to allow user interaction. Without user interaction the UI would lock up until the loop was finished.

Because editDocument modifications have to occur within a click event you can’t do some actions. So sleep() won’t work for everything. You would have to present a dialog and add a cancel button to it.

Maybe UXP could dispatch a stop event or have a stop callback method for when the automatic dialog appears? Then, @cpryland can handle for that bc sleep won’t work inside editDocument panel event.