Skip to content

Commit d6fa286

Browse files
committed
Update plugins for 23.0
1 parent 860da3b commit d6fa286

File tree

21 files changed

+182
-172
lines changed

21 files changed

+182
-172
lines changed

cross-compatible-js-sample/plugin/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"host": [
66
{
77
"app": "PS",
8-
"minVersion": "22.0.0"
8+
"minVersion": "23.0.0"
99
},
1010
{
1111
"app": "XD",

cross-compatible-js-sample/src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function createLabel(e) {
6969
textArea.invalid = true;
7070
} else if (APP_TYPE === "Photoshop") {
7171
const { batchPlay } = require("photoshop").action;
72+
const { executeAsModal } = require("photoshop").core;
7273

7374
const command = {
7475
_obj: "make",
@@ -115,8 +116,12 @@ function createLabel(e) {
115116
_isCommand: true
116117
}
117118
};
118-
119-
batchPlay([command], {});
119+
executeAsModal(() => {
120+
batchPlay([command], {});
121+
}, {
122+
commandName: "Create Label"
123+
});
124+
120125
} else if (APP_TYPE === "XD") {
121126
const { Text, Color } = require("scenegraph");
122127
const { editDocument } = require("application");

desktop-helper-sample/uxp/plugin/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"host": [
66
{
77
"app": "PS",
8-
"minVersion": "22.0.0"
8+
"minVersion": "23.0.0"
99
}
1010
],
1111
"main": "index.html",
@@ -92,4 +92,4 @@
9292
]
9393
}
9494
]
95-
}
95+
}

direct-action-js-sample/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"host": [
77
{
88
"app": "PS",
9-
"minVersion": "22.0.0"
9+
"minVersion": "23.0.0"
1010
}
1111
],
1212
"manifestVersion": 4,
@@ -41,4 +41,4 @@
4141
]
4242
}
4343
]
44-
}
44+
}

hello-world-js-sample/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"host": [
77
{
88
"app": "PS",
9-
"minVersion": "22.0.0"
9+
"minVersion": "23.0.0"
1010
}
1111
],
1212
"manifestVersion": 4,
@@ -41,4 +41,4 @@
4141
]
4242
}
4343
]
44-
}
44+
}

hello-world-panel-js-sample/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,22 @@ function showLayerNames() {
66
}
77
const activeDocTitle = app.activeDocument.title;
88
document.getElementById("layer-title").innerHTML = `Layers for document ${activeDocTitle}`;
9-
const allLayers = app.activeDocument.layers;
10-
const allLayerNames = allLayers.map(layer => layer.name);
9+
10+
// Collection classes are proxies on arrays. So if you want to push on them and alter them
11+
// you need to copy them into a proper array
12+
let allLayers = Array.from(app.activeDocument.layers);
13+
14+
const allLayerNames = [];
15+
// We do not have a way to get a flat list of all layer names in a document
16+
// but you can use layers and Array.reduce to recursively collect names
17+
while (allLayers.length > 0) {
18+
const layer = allLayers.shift();
19+
allLayerNames.push(layer.name);
20+
if (layer.layers) {
21+
layer.layers.forEach(l => allLayers.push(l));
22+
}
23+
}
24+
1125
const sortedNames = allLayerNames.sort((a, b) => a.toUpperCase() < b.toUpperCase() ? -1 : a.toUpperCase() > b.toUpperCase() ? 1 : 0);
1226
document.getElementById("layers").innerHTML = `
1327
<ul>${

hello-world-panel-js-sample/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"host": [
77
{
88
"app": "PS",
9-
"minVersion": "22.0.0"
9+
"minVersion": "23.0.0"
1010
}
1111
],
1212
"manifestVersion": 4,
@@ -86,4 +86,4 @@
8686
]
8787
}
8888
]
89-
}
89+
}

io-websocket-example/plugin/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.html",
66
"host": [{
77
"app": "PS",
8-
"minVersion": "22.0.0"
8+
"minVersion": "23.0.0"
99
}],
1010
"manifestVersion": 4,
1111
"entrypoints": [
@@ -70,4 +70,4 @@
7070
]
7171
}
7272
]
73-
}
73+
}

jszip-sample/plugin/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "1.0.0",
55
"host": {
66
"app": "PS",
7-
"minVersion": "22.0.0"
7+
"minVersion": "23.0.0"
88
},
99
"main": "index.html",
1010
"manifestVersion": 4,

jszip-sample/src/index.js

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -58,42 +58,30 @@ async function exportArtboards() {
5858
if (!file) return;
5959

6060
const temp = await fs.getTemporaryFolder();
61-
62-
const artboards = app.activeDocument.layerTree.filter(layer => {
63-
const command = {
64-
_obj: "get",
65-
_target: [
66-
{
67-
_property: "artboardEnabled"
68-
},
69-
{
61+
62+
// With 23.0, all state changing calls have to be made inside a modal execution state.
63+
await require("photoshop").core.executeAsModal(async () => {
64+
const artboards = app.activeDocument.artboards;
65+
66+
for (let artboard of artboards) {
67+
const command = {
68+
_obj: "exportSelectionAsFileTypePressed",
69+
_target: {
7070
_ref: "layer",
71-
_id: layer._id
72-
}
73-
]
74-
};
75-
76-
return action.batchPlay([command], { synchronousExecution: true })[0].artboardEnabled;
77-
});
78-
79-
for (let artboard of artboards) {
80-
const command = {
81-
_obj: "exportSelectionAsFileTypePressed",
82-
_target: {
83-
_ref: "layer",
84-
_id: artboard._id
85-
},
86-
fileType: "png",
87-
quality: 32,
88-
metadata: 0,
89-
destFolder: temp.nativePath,
90-
sRGB: true,
91-
openWindow: false,
92-
_options: { dialogOptions: "dontDisplay" }
93-
};
94-
95-
await action.batchPlay([command], {});
96-
}
71+
_id: artboard.id
72+
},
73+
fileType: "png",
74+
quality: 32,
75+
metadata: 0,
76+
destFolder: temp.nativePath,
77+
sRGB: true,
78+
openWindow: false,
79+
_options: { dialogOptions: "dontDisplay" }
80+
};
81+
82+
await action.batchPlay([command], {});
83+
}
84+
}, { commandName: "Export Artboards"});
9785

9886
const zip = new JSZip();
9987

0 commit comments

Comments
 (0)