Skip to main content
Mike Witherell
Community Expert
Community Expert
December 7, 2022
Question

Adding Undo to a UXP Script

  • December 7, 2022
  • 5 replies
  • 1280 views

Hi gang,

In a wonderful post here:

https://creativepro.com/add-undo-to-your-script/

... by the venerable Theunis De Jong, it was described how to add a few lines of code to a jsx script to cause it to undo in 1 undo step.

 

How is this done in UXPScripts?

This topic has been closed for replies.

5 replies

Mike Witherell
Community Expert
Community Expert
December 12, 2022

Thanks Peter. I had assumed (I don't know why I would) that once introduced, UXP would be a fairly complete implementation, and that JSX stuff would be deprecated.

Mike Witherell
Loic.Aigon
Legend
December 12, 2022

I understand this ongoing process, it allows Adobe to move priorities-wise. For example, they now know they need to fix doScript ;). This is a transition time and ExtendScript will be there for as long as UXP isn't fully up to date. If you are a team, you can set resources on this ExtendScript to UXP transition. If you are a freelancer, you may stick to ExtendScript for nowand use UXP for your own use with the intention of finding areas to improve.

Peter Kahrel
Community Expert
Community Expert
December 12, 2022

Adobe confirmed that app.doScript() doesn't work yet in UXP, and that they're working on its implementation. There are still quite a lot of things that don't work yet, UXP scripting is still very much work in progress.

Mike Witherell
Community Expert
Community Expert
December 7, 2022

I tried it in the Adobe Developer Tool debugger, but my experience level is not deep enough. All I can see is that it fails to work and complains about it. 

Where is there a lookup of new commands vs. old commands?

Mike Witherell
Loic.Aigon
Legend
December 7, 2022

I am not aware of a comparison between ExtendScript and UXP so you have a state of the art but there is the official UXP InDesign DOM here:

https://developer.adobe.com/indesign/uxp/omv/

But as doScript method seems to demonstrate, being listed on this page, doesn't mean it's working fully.

Yet I am not surprised, it's not that long that UXP Scripting is available with InDesign and there will be gaps for a while.

Loic

 

Mike Witherell
Community Expert
Community Expert
December 7, 2022

Oh no! I was hoping for an elegant answer. Thanks, Loic!

Mike Witherell
Loic.Aigon
Legend
December 7, 2022

I hope it might be wrong but this is how it looks like 😕😕

Loic.Aigon
Legend
December 7, 2022

Hi there,

 

Just tested app.doScript in UXP Scripting and I think it's partially implemented, to say the least:

  • calling a function fails whether you call it by its reference (app.doScript(main…)) or by a string (app.doScript("main()"…)
  • Passing the code as a string works ("app.doScript("app.activeDocument.textFrames.add(…) BUT the cancel instruction produces no effet (app.doScript("code", [arguments], [UndoModes], [script name]).
    Using UndoModes.ENTIRE_SCRIPT doesn't make the script "cancelable" as a whole.

 

I would report to Adobe via a BUG REPORT in the uservoice.