-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdummy.js
67 lines (52 loc) · 1.89 KB
/
dummy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import sampleImage from '../../assets/images/sample.png';
class DummyPlugin {
constructor(env, config) {
this.name = 'Dummy Plugin';
this.description = 'This is a dummy plugin which just \'console.log\'s some stuff';
this.configParams = {
message: {
label: 'A message',
type: 'string',
},
amount: {
label: 'A number',
type: 'number',
},
};
// will be updated via setConfig()
this.config = {};
this.setConfig(config);
// saveAs is a reference to the saveAs method from https://www.npmjs.com/package/file-saver
// progress should be called with values between 0 and 1 to indicate plugin progress
// both values should be stored as follows:
this.saveAs = env.saveAs;
this.progress = env.progress;
// the env object env contains a reference to the redux-store.
// if you need it, be careful what you do with it and if possible learn the basic concepts of redux https://redux.js.org/understanding/thinking-in-redux/motivation
console.log(env);
// this is a way to import (small) binary assets into your js
// the value can be handled as any URL
console.log(sampleImage);
// custom init code
}
setConfig(configUpdate) {
// custom config update code
Object.assign(this.config, configUpdate);
// you can parse or manipulate config values after receiving the config state here
console.log(this.config);
}
withImage(image) {
// get basic metadata
image.getMeta().then((meta) => console.log(meta));
// get the palette
image.getPalette().then((palette) => console.log(palette));
// get the tiles as array of strings
image.getTiles().then((tiles) => console.log(tiles));
// get canvas
image.getCanvas().then((canvas) => console.log(canvas));
}
withSelection(images) {
console.log(images);
}
}
window.gbpwRegisterPlugin(DummyPlugin);