Skip to content

Commit 4c04a8a

Browse files
remove sim from formatting
1 parent d3e2677 commit 4c04a8a

19 files changed

+2304
-2310
lines changed

Diff for: .prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"semi": false
3+
}

Diff for: dialog_box.js

+26-27
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,43 @@ async function prompt(
1111
"sp-divider",
1212
"sp-body",
1313
"footer",
14-
].map((tag) => document.createElement(tag));
15-
[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => {
16-
el.style.margin = "6px";
17-
el.style.width = "calc(100% - 12px)";
18-
});
14+
].map((tag) => document.createElement(tag))
15+
;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => {
16+
el.style.margin = "6px"
17+
el.style.width = "calc(100% - 12px)"
18+
})
1919

20-
formEl.setAttribute("method", "dialog");
21-
formEl.addEventListener("submit", () => dlgEl.close());
20+
formEl.setAttribute("method", "dialog")
21+
formEl.addEventListener("submit", () => dlgEl.close())
2222

23-
footerEl.style.marginTop = "26px";
23+
footerEl.style.marginTop = "26px"
2424

25-
dividerEl.setAttribute("size", "large");
25+
dividerEl.setAttribute("size", "large")
2626

27-
headingEl.textContent = heading;
27+
headingEl.textContent = heading
2828

29-
bodyEl.textContent = body;
29+
bodyEl.textContent = body
3030

3131
buttons.forEach((btnText, idx) => {
32-
const btnEl = document.createElement("sp-button");
32+
const btnEl = document.createElement("sp-button")
3333
btnEl.setAttribute(
3434
"variant",
3535
idx === buttons.length - 1 ? btnText.variant || "cta" : "secondary"
36-
);
37-
if (idx === buttons.length - 1)
38-
btnEl.setAttribute("autofocus", "autofocus");
39-
if (idx < buttons.length - 1) btnEl.setAttribute("quiet");
40-
btnEl.textContent = btnText.text || btnText;
41-
btnEl.style.marginLeft = "12px";
42-
btnEl.addEventListener("click", () => dlgEl.close(btnText.text || btnText));
43-
footerEl.appendChild(btnEl);
44-
});
45-
[headingEl, dividerEl, bodyEl, footerEl].forEach((el) =>
36+
)
37+
if (idx === buttons.length - 1) btnEl.setAttribute("autofocus", "autofocus")
38+
if (idx < buttons.length - 1) btnEl.setAttribute("quiet")
39+
btnEl.textContent = btnText.text || btnText
40+
btnEl.style.marginLeft = "12px"
41+
btnEl.addEventListener("click", () => dlgEl.close(btnText.text || btnText))
42+
footerEl.appendChild(btnEl)
43+
})
44+
;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) =>
4645
formEl.appendChild(el)
47-
);
48-
dlgEl.appendChild(formEl);
49-
document.body.appendChild(dlgEl);
46+
)
47+
dlgEl.appendChild(formEl)
48+
document.body.appendChild(dlgEl)
5049

51-
return dlgEl.uxpShowModal(options);
50+
return dlgEl.uxpShowModal(options)
5251
}
5352

5453
// const r1 = await prompt(
@@ -73,4 +72,4 @@ async function prompt(
7372
// /* Do the delete */
7473
// }
7574

76-
module.exports = { prompt };
75+
module.exports = { prompt }

Diff for: export_png.js

+43-43
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
const { executeAsModal } = require("photoshop").core;
2-
const storage = require("uxp").storage;
3-
const fs = storage.localFileSystem;
4-
const formats = require("uxp").storage.formats;
1+
const { executeAsModal } = require("photoshop").core
2+
const storage = require("uxp").storage
3+
const fs = storage.localFileSystem
4+
const formats = require("uxp").storage.formats
55
async function exportPngCommand() {
6-
const batchPlay = require("photoshop").action.batchPlay;
6+
const batchPlay = require("photoshop").action.batchPlay
77
// const result = await batchPlay { _obj: “exportSelectionAsFileTypePressed”}
88

99
// const destFolder = (await storage.localFileSystem.getDataFolder()).nativePath;
10-
const storage = require("uxp").storage;
11-
const fs = storage.localFileSystem;
10+
const storage = require("uxp").storage
11+
const fs = storage.localFileSystem
1212

13-
let pluginFolder = await fs.getPluginFolder();
13+
let pluginFolder = await fs.getPluginFolder()
1414
// await fs.getFolder("./init_images")
1515
let init_images_dir = await pluginFolder.getEntry(
1616
"./server/python_server/init_images"
17-
);
17+
)
1818

1919
const exportCommand = {
2020
_obj: "exportSelectionAsFileTypePressed",
@@ -26,20 +26,20 @@ async function exportPngCommand() {
2626
sRGB: true,
2727
openWindow: false,
2828
_options: { dialogOptions: "dontDisplay" },
29-
};
29+
}
3030
const result = await batchPlay([exportCommand], {
3131
synchronousExecution: true,
3232
modalBehavior: "execute",
33-
});
33+
})
3434

35-
return result;
35+
return result
3636
}
3737
async function exportPng() {
38-
const { executeAsModal } = require("photoshop").core;
38+
const { executeAsModal } = require("photoshop").core
3939
try {
40-
await executeAsModal(exportPngCommand);
40+
await executeAsModal(exportPngCommand)
4141
} catch (e) {
42-
console.warn("exportPng error:", e);
42+
console.warn("exportPng error:", e)
4343
}
4444
}
4545

@@ -49,39 +49,39 @@ const readPng = async (image_name) => {
4949
await executeAsModal(
5050
async (control) => {
5151
// const tempFolder = await fs.getTemporaryFolder() ;
52-
const pluginFolder = await fs.getPluginFolder();
52+
const pluginFolder = await fs.getPluginFolder()
5353

5454
let init_images_dir = await pluginFolder.getEntry(
5555
"./server/python_server/init_images"
56-
);
56+
)
5757
// let init_images_dir = await pluginFolder.getEntry(
5858
// './server/python_server/init_images'
5959
// )
6060
const file = await init_images_dir.createFile(image_name, {
6161
overwrite: true,
62-
});
62+
})
6363

64-
const currentDocument = app.activeDocument;
64+
const currentDocument = app.activeDocument
6565
await currentDocument.saveAs.png(
6666
file,
6767
{
6868
compression: 6,
6969
},
7070
true
71-
);
71+
)
7272

7373
// const arrayBuffer = await file.read({format: formats.binary}) ;
7474
// console.log(arrayBuffer, 'arrayBuffer') ;
7575
},
7676

7777
{ commandName: "readPng" }
78-
);
78+
)
7979
} catch (e) {
80-
console.warn(e);
80+
console.warn(e)
8181
}
82-
};
82+
}
8383

84-
const psapi = require("./psapi");
84+
const psapi = require("./psapi")
8585
async function newExportPng(layer, image_name) {
8686
//store layers we want to export in variables
8787
// let layerToExports =
@@ -97,24 +97,24 @@ async function newExportPng(layer, image_name) {
9797

9898
//create new document
9999
let exportDoc = await executeAsModal(async () => {
100-
return await app.documents.add;
101-
});
100+
return await app.documents.add
101+
})
102102

103103
// for (layer of layersToExport) {
104104
await executeAsModal(async () => {
105-
console.log(layer.id);
106-
const dupLayer = await layer.duplicate(exportDoc);
107-
await psapi.selectLayers([dupLayer]);
108-
await psapi.selectLayerChannelCommand();
109-
const selection_info = await psapi.getSelectionInfoExe();
110-
await exportDoc.crop(selection_info);
105+
console.log(layer.id)
106+
const dupLayer = await layer.duplicate(exportDoc)
107+
await psapi.selectLayers([dupLayer])
108+
await psapi.selectLayerChannelCommand()
109+
const selection_info = await psapi.getSelectionInfoExe()
110+
await exportDoc.crop(selection_info)
111111
// export_image_name = `${layer.name}.png`
112-
await readPng(image_name);
112+
await readPng(image_name)
113113
// await exportDoc.closeWithoutSaving()
114-
});
114+
})
115115
// }
116116
} catch (e) {
117-
console.warn(e);
117+
console.warn(e)
118118
}
119119
}
120120

@@ -140,17 +140,17 @@ For the save function, if running UXP AP1 version 1 then use "wait" for modalBeh
140140
If running on UXP API version 2 then use "execute" for modalBahavior, or remove the options and use {} so the options go to default.
141141
*/
142142
async function savePNG(saveDataTemp) {
143-
const batchPlay = require("photoshop").action.batchPlay;
143+
const batchPlay = require("photoshop").action.batchPlay
144144

145145
async function savePNGCommand() {
146146
var saveFolder =
147-
await require("uxp").storage.localFileSystem.getPluginFolder();
147+
await require("uxp").storage.localFileSystem.getPluginFolder()
148148

149149
// Again, my variable here is global and assigned earlier. The value is changed during a batch loop for each file.
150-
var saveFile = await saveFolder.createFile("fileName.png");
150+
var saveFile = await saveFolder.createFile("fileName.png")
151151

152152
const saveData =
153-
await require("uxp").storage.localFileSystem.createSessionToken(saveFile);
153+
await require("uxp").storage.localFileSystem.createSessionToken(saveFile)
154154

155155
const result = await batchPlay(
156156
[
@@ -190,11 +190,11 @@ async function savePNG(saveDataTemp) {
190190
synchronousExecution: true,
191191
modalBehavior: "execute",
192192
}
193-
);
193+
)
194194
}
195195
await executeAsModal(async () => {
196-
savePNGCommand();
197-
});
196+
savePNGCommand()
197+
})
198198
}
199199

200200
////////////////////End method 3////////////////////////////
@@ -204,4 +204,4 @@ module.exports = {
204204
readPng,
205205
savePNG,
206206
newExportPng,
207-
};
207+
}

Diff for: helper.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
const { unselectActiveLayers } = require("./psapi");
1+
const { unselectActiveLayers } = require("./psapi")
22

3-
const app = window.require("photoshop").app;
3+
const app = window.require("photoshop").app
44

55
function getActiveLayer() {
6-
let activeLayers = app.activeDocument.activeLayers;
6+
let activeLayers = app.activeDocument.activeLayers
77
// console.dir(getSize())
88
for (const layer of activeLayers) {
9-
console.dir({ layer });
10-
const name = layer.name;
11-
console.dir({ name });
12-
let layer_size = getLayerSize(layer);
13-
console.dir({ layer_size });
9+
console.dir({ layer })
10+
const name = layer.name
11+
console.dir({ name })
12+
let layer_size = getLayerSize(layer)
13+
console.dir({ layer_size })
1414
}
1515

16-
return activeLayers[0];
16+
return activeLayers[0]
1717
}
1818

1919
function getSize() {
20-
let doc = app.activeDocument;
21-
return { height: doc.height, width: doc.width };
20+
let doc = app.activeDocument
21+
return { height: doc.height, width: doc.width }
2222
}
2323

24-
const { batchPlay } = require("photoshop").action;
25-
const { executeAsModal } = require("photoshop").core;
24+
const { batchPlay } = require("photoshop").action
25+
const { executeAsModal } = require("photoshop").core
2626

2727
async function reselectBatchPlay(selectionInfo) {
2828
const result = await batchPlay(
@@ -63,21 +63,21 @@ async function reselectBatchPlay(selectionInfo) {
6363
synchronousExecution: true,
6464
modalBehavior: "execute",
6565
}
66-
);
66+
)
6767
}
6868

6969
async function reselect(selectionInfo) {
7070
await executeAsModal(
7171
async () => {
72-
reselectBatchPlay(selectionInfo);
72+
reselectBatchPlay(selectionInfo)
7373
},
7474
{ commandName: "reselect" }
75-
);
75+
)
7676
}
7777

7878
//unselect the rectangular marquee selection area
7979
async function unSelect() {
80-
const batchPlay = require("photoshop").action.batchPlay;
80+
const batchPlay = require("photoshop").action.batchPlay
8181

8282
const result = await batchPlay(
8383
[
@@ -102,9 +102,9 @@ async function unSelect() {
102102
synchronousExecution: true,
103103
modalBehavior: "execute",
104104
}
105-
);
105+
)
106106

107-
return result;
107+
return result
108108
}
109109

110110
// async function layerToSelectionHelper () {
@@ -204,4 +204,4 @@ async function unSelect() {
204204

205205
module.exports = {
206206
// layerToSelection
207-
};
207+
}

0 commit comments

Comments
 (0)