While I wouldn’t exactly say that I’m happy about the reason for it (no longer working for Adobe after my contract expired a month ago), this means that I now have more time to develop exciting side projects again. And, of course, I had to use this opportunity to play around with UXP for InDesign (while I’m much more familiar with XD and the DVA space, I’ve also used InDesign for projects in the past, so )
Showcase Video
It isn’t much, but I’ve already learned a few quirks about using UXP in InDesign, so I thought it might be valuable to some of you who come from UXP in a different host app to put these things into a short video:
Quick overview of the lessons I learned developing this first mini plugin:
InDesign’s DOM works somewhat differently compared to other UXP host apps. From what I’ve seen, I think this can add some convenience but takes some getting used to (e.g., bounds being [y1, x1, y2, x2] instead of [x1, y1, x2, y2] or [x, y, width, height])
from what I’ve seen, the InDesign equivalent of XD’s require('application').editDocument() and Photoshop’s require('photoshop').core.executeAsModal() is:
app.activeDocument.colors.itemByName(name) returns a Color regardless of if it exists or not (the same applies for other functions in this style). To check if it actually exists (and doesn’t have to get added to the set of colors first), you can’t check if it’s undefined, but have to check its isValid property:
let color = app.activeDocument.colors.itemByName(name);
if (!color.isValid) {
console.log(`Creating color ${name} because it doesn't exist`);
color = app.activeDocument.colors.add({
name: name,
colorValue: colorValue,
parentColorGroup: getOrCreateColorGroup()
});
}
return color;
I’m sure I’m not the only one trying their first steps of getting into the UXP in InDesign-world these days, so I’m curious what y’all have been up to (and lessons learned from that). So I’m hoping that maybe we can make this a showcase/lessons learned thread around first steps in using UXP in this “new” host app.
I’m glad you’re glad since the fact that I no longer have access to (and thus, no longer have to monitor) way too many internal Slack channels probably means you’ll see me around here more frequently, again .
Jokes aside, I’ll probably share a ready-to-use type declaration file (that’s ready to be pasted into any project) as soon as I have played around with InDesign-based UXP a bit more (probably sometime in the next 4 days) .
And … I’m happy to say that the test plugin just became a real plugin (and potentially the first ever published open-source UXP-based InDesign plugin? ) !
Hope you slept well, Zuri! This indeed is great and the first ever UXP InDesign Plugin that I am aware of. Can’t wait to see this live in the Marketplace
It’s still early days for UXP in InDesign (which, in more than one place, is also quite noticeable), which means it’s totally understandable that some weird issues occur and we as the developer community still have to figure out best practices around it. So I would (and I’ll do the same) ask/encourage that we make a habit of documenting things like those in forum threads so that we can all benefit from each other and build the best plugins we can !
I was never able to reproduce the exact crashing / freezing reported by the engineering team
A few days after the rejection, my Mac Mini testing machine (that I had ordered, also for other projects) arrived and I was able to do some deeper testing
I found a bunch of problems on macOS with things like segmentation faults happening sporadically (that “sporadically” is the key part since it meant there’s no reliable way of testing if it’s fixed or not, only proabilities)
Crucially, I was able to replicate these problems with the starter plugin, as well. So it didn’t seem to be one particular thing my plugin did
Adobe confirmed that this wasn’t a problem with my plugin, but with how InDesign handles the plugin, and a fix for this will likely arrive in v19.0.
With that change, an intensive 8-hour testing session (because we’re dealing with probabilities and not a clear way to replicate, that was the only way to get some confidence that it might actually be fixed) went smoothly. So the change, at the very least, severely decreases the chance of problems occurring, and I can only hope that this also “covers” the ones encountered by the review team.
I (because of the testing session, I currently believe that the plugin is mostly stable ) resubmitted the new version for review and it got approved.
So hopefully, it won’t be a concern as soon as v19.0 comes out. But after embarking on this journey, I wanted to go through with having the first ever published UXP based plugin for InDesign, so I was keen on releasing for v18.5, which is why I played around with it for many more hours. And while I can’t say for sure that it completely fixes it (in fact, based on me having these issues with the starter plugin, as well, I doubt that), the changes I was able to make seem to at least have made it a lot less likely to happen (and hopefully, cover the very bad complete freeze/crash that I was never able to replicate in the first place).