Skip to content

Commit 316db01

Browse files
authored
Merge pull request #39 from MLH-Fellowship/jszip-sample
Added a sample using JSZip
2 parents 660408a + f04598d commit 316db01

File tree

14 files changed

+3090
-0
lines changed

14 files changed

+3090
-0
lines changed

jszip-sample/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# JSZip Sample
2+
3+
This plugin is a good place to get started when building a Adobe Photoshop plugin using JSZip. It comes defined with all the dependencies that you'll need to get started. As this is a Webpack project, you'll need to do some initial configuration before this will be usable in Adobe Photoshop.
4+
5+
## Install dependencies
6+
7+
First ensure that your terminal is in the root of this project. Then:
8+
9+
For `yarn` users, install all dependencies using:
10+
11+
```
12+
yarn install
13+
```
14+
15+
For `npm` users, install all dependencies using:
16+
17+
```
18+
npm install
19+
```
20+
21+
## Build Process
22+
23+
There are two ways to build the plugin for use in Adobe Photoshop:
24+
25+
- `yarn watch` or `npm run watch` will build a development version of the plugin, and recompile everytime you make a change to the source files. The result is placed in `dist`.
26+
- `yarn build` or `npm run build` will build a production version of the plugin and place it in `dist`. It will not update every time you make a change to the source files.
27+
28+
> You **must** run either `watch` or `build` prior to trying to use within Photoshop!
29+
30+
## Launching in Photoshop
31+
32+
You can use the UXP Developer Tools to load the plugin into Photoshop.
33+
34+
If the plugin hasn't already been added to your workspace in the UXP Developer Tools, you can add it by clicking "Add Plugin..." and selecting `dist/manifest.json`. **DO NOT** select the `manifest.json` file inside the `plugin` folder.
35+
36+
Once added, you can load it into Photoshop by clicking the ••• button on the corresponding row, and clicking "Load". Switch to Photoshop and you should see the starter panel.
37+
38+
## What this plugin does
39+
40+
This plugin shows how to use JSZip alongside Photoshop and includes a few useful demos of this functionality. The first one, `IMPORT ZIP FILE`, allows you to simply import a `zip` file containing images and automatically open them. The second demo, `EXPORT ARTBOARDS AS ZIP`, allows you to easily export all artboards in a Photoshop project as a single `zip` file. The last demo, `SAVE FILES TO ZIP`, allows you to select any number of files and export them to a `zip` file.

jszip-sample/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "com.adobe.jszip-sample",
3+
"version": "1.0.0",
4+
"private": true,
5+
"scripts": {
6+
"watch": "webpack -w --mode development",
7+
"build": "webpack --mode development"
8+
},
9+
"devDependencies": {
10+
"@babel/core": "^7.14.6",
11+
"@babel/plugin-transform-runtime": "^7.14.5",
12+
"@babel/preset-env": "^7.14.7",
13+
"babel-loader": "^8.2.2",
14+
"copy-webpack-plugin": "^9.0.1",
15+
"css-loader": "^5.2.6",
16+
"html-webpack-plugin": "^5.3.2",
17+
"style-loader": "^3.0.0",
18+
"webpack": "^5.44.0",
19+
"webpack-cli": "^4.7.2"
20+
},
21+
"dependencies": {
22+
"jszip": "^3.7.0"
23+
}
24+
}
452 Bytes
Loading
501 Bytes
Loading
450 Bytes
Loading
558 Bytes
Loading
893 Bytes
Loading
2.48 KB
Loading

jszip-sample/plugin/manifest.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"id": "com.adobe.jszip-sample",
3+
"name": "JSZip Sample",
4+
"version": "1.0.0",
5+
"host": {
6+
"app": "PS",
7+
"minVersion": "22.0.0"
8+
},
9+
"main": "index.html",
10+
"manifestVersion": 4,
11+
"entrypoints": [
12+
{
13+
"type": "panel",
14+
"id": "plugin",
15+
"label": {
16+
"default": "JSZip Sample"
17+
},
18+
"minimumSize": {
19+
"width": 150,
20+
"height": 200
21+
},
22+
"maximumSize": {
23+
"width": 350,
24+
"height": 2000
25+
},
26+
"preferredDockedSize": {
27+
"width": 200,
28+
"height": 425
29+
},
30+
"preferredFloatingSize": {
31+
"width": 200,
32+
"height": 425
33+
},
34+
"icons": [
35+
{
36+
"width": 23,
37+
"height": 23,
38+
"path": "icons/dark.png",
39+
"scale": [1, 2],
40+
"theme": ["darkest", "dark", "medium"]
41+
},
42+
{
43+
"width": 23,
44+
"height": 23,
45+
"path": "icons/light.png",
46+
"scale": [1, 2],
47+
"theme": ["lightest", "light"]
48+
}
49+
]
50+
}
51+
],
52+
"icons": [
53+
{
54+
"width": 48,
55+
"height": 48,
56+
"path": "icons/plugin.png",
57+
"scale": [1, 2],
58+
"theme": ["dark", "darkest", "medium", "lightest", "light", "all"],
59+
"species": ["pluginList"]
60+
}
61+
]
62+
}

jszip-sample/src/index.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
html, body {
2+
margin: 0;
3+
height: 100%;
4+
width: 100%;
5+
background-color: var(--uxp-host-background-color);
6+
color: var(--uxp-host-text-color);
7+
overflow: auto;
8+
}
9+
10+
.container {
11+
display: flex;
12+
flex-direction: column;
13+
padding: 12px;
14+
}
15+
16+
.titleDivider {
17+
margin: .5em 0;
18+
}
19+
20+
.fieldDivider {
21+
margin: 2em auto 1em auto;
22+
max-width: 75%;
23+
}
24+
25+
.error {
26+
margin: 0;
27+
color: #C95359;
28+
}
29+
30+
.heading {
31+
margin-top: 0;
32+
}
33+
34+
.fields {
35+
padding: 0;
36+
}
37+
38+
.fields .field {
39+
margin-top: 1em;
40+
}
41+
42+
.fields .field:not(:first-child) {
43+
margin-top: 3em;
44+
}
45+
46+
.field .button {
47+
margin-top: .5em;
48+
}
49+
50+
.button {
51+
width: 100%;
52+
}

0 commit comments

Comments
 (0)