I’m new to photoshop plugin development.
I started following the official adobe official Quick Start Guide.
I’m stuck at the part where we want to open a file dialog using the plugin button.
I’ve checked over and over again and I can’t see the problem.
I also took a look at the adobe git hub examples ( GitHub - AdobeDocs/uxp-photoshop-plugin-samples: UXP Plugin samples for Photoshop 22 and higher. ) and I found this one example called direct-action-js-sample.
Essentially I’m doing the same thing as the plugin example does.
The plugin example works, but not mine.What am I doing wrong in my code?Thanks for any help!(and yes, the button click is being called)
const { entrypoints } = require(“uxp”);const app = require(“photoshop”).app;const core = require(“photoshop”).core;
entrypoints.setup({
panels: {
vanilla: {
show(node) {
}}}
});
function renameLayerNames() {
return core.executeAsModal(() => {
const regExp = /^(.*?)( (\d+ %))?$/;app.activeDocument.layers.forEach
(layer => {
const baseName = layer.name.match(regExp)[1];layer.name =
`${baseName}(${layer.opacity} %)`;
});},
{
commandName: “Rename layers”
});
}
async function exportReport() {
return core.executeAsModal(async () => {
const fs = require(“uxp”).storage.localFileSystem;
const file = await fs.getFileForSaving(“layer names.txt”, { types: [“txt”] });
if (!file) {console.log(“no file”);return;}
await file.write(“test”);console.log(“file saved”);},
{commandName: “Export Report”});}
document.getElementById(“btnExport”).addEventListener(“click”, exportReport);
document.getElementById(“btnRename”).addEventListener(“click”, renameLayerNames);