@scaleflex/widget-thumbnail-generator 4.0.7 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6994 -6982
- package/LICENSE +21 -21
- package/README.md +181 -181
- package/assets/CHECKERED_BACKGROUND.svg +2507 -2507
- package/lib/index.js +37 -37
- package/package.json +3 -3
- package/types/index.d.ts +16 -16
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 scaleflex
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 scaleflex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,181 +1,181 @@
|
|
|
1
|
-
# `@scaleflex/widget-thumbnail-generator`
|
|
2
|
-
|
|
3
|
-
[![Plugins][plugins-image]](#plugins)
|
|
4
|
-
[![Website][filerobot-image]][sfx-url]
|
|
5
|
-
[![Version][filerobot-version]][version-url]
|
|
6
|
-
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
-
[![License][license-image]][license-url]
|
|
8
|
-
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<div align='center'>
|
|
12
|
-
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
A helper plugin used in generating thumbnails for files to be shown in [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core).
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
### NPM
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install --save @scaleflex/widget-thumbnail-generator
|
|
23
|
-
```
|
|
24
|
-
### YArn
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
yarn add @scaleflex/widget-thumbnail-generator
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
then
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
import ThumbnailGenerator from '@scaleflex/widget-thumbnail-generator'
|
|
34
|
-
...
|
|
35
|
-
...
|
|
36
|
-
...
|
|
37
|
-
scaleflexWidget.use(ThumbnailGenerator, propertiesObject)
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### CDN
|
|
41
|
-
|
|
42
|
-
The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.ThumbnailGenerator`
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
const ThumbnailGenerator = window.ScaleflexWidget.ThumbnailGenerator
|
|
46
|
-
...
|
|
47
|
-
...
|
|
48
|
-
...
|
|
49
|
-
scaleflexWidget.use(ThumbnailGenerator, propertiesObject)
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
> If you are using [`@scaleflex/widget-explorer`](../@scaleflex/widget-explorer/#scaleflexwidget-explorer) pluign you don't need to manually import this plugin as it is being imported automatically there and the default id `Explorer:thumbnail-generator` Unless the Explorer id is changed.
|
|
53
|
-
|
|
54
|
-
## Properties
|
|
55
|
-
|
|
56
|
-
### `id`
|
|
57
|
-
|
|
58
|
-
<u>Type:</u> `object`.
|
|
59
|
-
|
|
60
|
-
<u>Default:</u> `'ThumbnailGenerator'`
|
|
61
|
-
|
|
62
|
-
An unique identifier for the plugin to be identified between the other plugins through it.
|
|
63
|
-
|
|
64
|
-
### `thumbnailWidth`
|
|
65
|
-
|
|
66
|
-
<u>Type:</u> `number`.
|
|
67
|
-
|
|
68
|
-
<u>Default:</u> `200`
|
|
69
|
-
|
|
70
|
-
The width of the generated thumbnail to be, if it is not provided the default width would be used.
|
|
71
|
-
|
|
72
|
-
### `thumbnailHeight`
|
|
73
|
-
|
|
74
|
-
<u>Type:</u> `number`.
|
|
75
|
-
|
|
76
|
-
<u>Default:</u> `170`
|
|
77
|
-
|
|
78
|
-
The height of the generated thumbnail to be, if it is not provided the default height would be used.
|
|
79
|
-
|
|
80
|
-
### `waitForThumbnailsBeforeUpload`
|
|
81
|
-
|
|
82
|
-
<u>Type:</u> `boolean`.
|
|
83
|
-
|
|
84
|
-
<u>Default:</u> `false`
|
|
85
|
-
|
|
86
|
-
Delays the start of uploading process till the thumbnails for files selected to be uploaded are generated.
|
|
87
|
-
|
|
88
|
-
### `lazy`
|
|
89
|
-
|
|
90
|
-
<u>Type:</u> `boolean`.
|
|
91
|
-
|
|
92
|
-
<u>Default:</u> `false`
|
|
93
|
-
|
|
94
|
-
Starts the thumbnail generating process manually through the below events not automatically.
|
|
95
|
-
|
|
96
|
-
## Events
|
|
97
|
-
|
|
98
|
-
The plugin emits different events that you could subscribe to or add your handler to be called with the provided arguments passed while emitting/firing the event, the events are listed below with examples show the parameters for handler:
|
|
99
|
-
|
|
100
|
-
### Emitters
|
|
101
|
-
|
|
102
|
-
### `thumbnail:all-generated`
|
|
103
|
-
|
|
104
|
-
Emitted when all the thumbnails are generated.
|
|
105
|
-
|
|
106
|
-
`params`: No params returned.
|
|
107
|
-
|
|
108
|
-
example
|
|
109
|
-
|
|
110
|
-
```js
|
|
111
|
-
scaleflexWidget.on('thumbnail:all-generated', () => {
|
|
112
|
-
console.log('all thumbnails generated')
|
|
113
|
-
})
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
#### `thumbnail:generated`
|
|
117
|
-
|
|
118
|
-
Emitted when a file's thumbnail is generated.
|
|
119
|
-
|
|
120
|
-
`params`:
|
|
121
|
-
- `file`: The file object whom thumbnail is generated.
|
|
122
|
-
- `preview`: The generated thumbnail image local url.
|
|
123
|
-
|
|
124
|
-
example
|
|
125
|
-
|
|
126
|
-
```js
|
|
127
|
-
scaleflexWidget.on('thumbnail:generated', (file, previewUrl) => {
|
|
128
|
-
console.log('[Thumbnail-generator]: File's thumbnail is generated', file)
|
|
129
|
-
const img = document.createElement('img')
|
|
130
|
-
img.src = previewUrl
|
|
131
|
-
img.width = 111
|
|
132
|
-
document.body.appendChild(img)
|
|
133
|
-
})
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
#### `thumbnail:error`
|
|
137
|
-
|
|
138
|
-
Emitted when a file's thumbnail generating faced an error.
|
|
139
|
-
|
|
140
|
-
`params`:
|
|
141
|
-
- `file`: The file object whom thumbnail is generated.
|
|
142
|
-
- `error`: The error faced while generated.
|
|
143
|
-
|
|
144
|
-
example
|
|
145
|
-
|
|
146
|
-
```js
|
|
147
|
-
scaleflexWidget.on('thumbnail:generated', (file, error) => {
|
|
148
|
-
console.log('[Thumbnail-generator]: File's thumbnail had an error while generating', file)
|
|
149
|
-
console.log('The error: ', error)
|
|
150
|
-
})
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Subscribers
|
|
154
|
-
|
|
155
|
-
#### `thumbnail:request`
|
|
156
|
-
|
|
157
|
-
`handler`: (fileObject) => ...
|
|
158
|
-
|
|
159
|
-
Subscribes the handler of generating thumbnail for a file, fired when the event is emitted.
|
|
160
|
-
|
|
161
|
-
#### `thumbnail:update`
|
|
162
|
-
|
|
163
|
-
`handler`: (fileObject) => ...
|
|
164
|
-
|
|
165
|
-
Subscribes the handler of updating a generated thumbnail for a file, fired when the event is emitted.
|
|
166
|
-
|
|
167
|
-
<!-- Variables -->
|
|
168
|
-
|
|
169
|
-
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-thumbnail-generator
|
|
170
|
-
[license-url]: https://opensource.org/licenses/MIT
|
|
171
|
-
[sfx-url]: https://www.scaleflex.com/
|
|
172
|
-
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-thumbnail-generator
|
|
173
|
-
[codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
|
|
174
|
-
|
|
175
|
-
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
176
|
-
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
177
|
-
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
178
|
-
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
179
|
-
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
180
|
-
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-thumbnail-generator?label=Version&style=for-the-badge&logo=npm
|
|
181
|
-
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
|
1
|
+
# `@scaleflex/widget-thumbnail-generator`
|
|
2
|
+
|
|
3
|
+
[![Plugins][plugins-image]](#plugins)
|
|
4
|
+
[![Website][filerobot-image]][sfx-url]
|
|
5
|
+
[![Version][filerobot-version]][version-url]
|
|
6
|
+
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
+
[![License][license-image]][license-url]
|
|
8
|
+
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<div align='center'>
|
|
12
|
+
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
A helper plugin used in generating thumbnails for files to be shown in [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core).
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### NPM
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --save @scaleflex/widget-thumbnail-generator
|
|
23
|
+
```
|
|
24
|
+
### YArn
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn add @scaleflex/widget-thumbnail-generator
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
then
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import ThumbnailGenerator from '@scaleflex/widget-thumbnail-generator'
|
|
34
|
+
...
|
|
35
|
+
...
|
|
36
|
+
...
|
|
37
|
+
scaleflexWidget.use(ThumbnailGenerator, propertiesObject)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### CDN
|
|
41
|
+
|
|
42
|
+
The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.ThumbnailGenerator`
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const ThumbnailGenerator = window.ScaleflexWidget.ThumbnailGenerator
|
|
46
|
+
...
|
|
47
|
+
...
|
|
48
|
+
...
|
|
49
|
+
scaleflexWidget.use(ThumbnailGenerator, propertiesObject)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> If you are using [`@scaleflex/widget-explorer`](../@scaleflex/widget-explorer/#scaleflexwidget-explorer) pluign you don't need to manually import this plugin as it is being imported automatically there and the default id `Explorer:thumbnail-generator` Unless the Explorer id is changed.
|
|
53
|
+
|
|
54
|
+
## Properties
|
|
55
|
+
|
|
56
|
+
### `id`
|
|
57
|
+
|
|
58
|
+
<u>Type:</u> `object`.
|
|
59
|
+
|
|
60
|
+
<u>Default:</u> `'ThumbnailGenerator'`
|
|
61
|
+
|
|
62
|
+
An unique identifier for the plugin to be identified between the other plugins through it.
|
|
63
|
+
|
|
64
|
+
### `thumbnailWidth`
|
|
65
|
+
|
|
66
|
+
<u>Type:</u> `number`.
|
|
67
|
+
|
|
68
|
+
<u>Default:</u> `200`
|
|
69
|
+
|
|
70
|
+
The width of the generated thumbnail to be, if it is not provided the default width would be used.
|
|
71
|
+
|
|
72
|
+
### `thumbnailHeight`
|
|
73
|
+
|
|
74
|
+
<u>Type:</u> `number`.
|
|
75
|
+
|
|
76
|
+
<u>Default:</u> `170`
|
|
77
|
+
|
|
78
|
+
The height of the generated thumbnail to be, if it is not provided the default height would be used.
|
|
79
|
+
|
|
80
|
+
### `waitForThumbnailsBeforeUpload`
|
|
81
|
+
|
|
82
|
+
<u>Type:</u> `boolean`.
|
|
83
|
+
|
|
84
|
+
<u>Default:</u> `false`
|
|
85
|
+
|
|
86
|
+
Delays the start of uploading process till the thumbnails for files selected to be uploaded are generated.
|
|
87
|
+
|
|
88
|
+
### `lazy`
|
|
89
|
+
|
|
90
|
+
<u>Type:</u> `boolean`.
|
|
91
|
+
|
|
92
|
+
<u>Default:</u> `false`
|
|
93
|
+
|
|
94
|
+
Starts the thumbnail generating process manually through the below events not automatically.
|
|
95
|
+
|
|
96
|
+
## Events
|
|
97
|
+
|
|
98
|
+
The plugin emits different events that you could subscribe to or add your handler to be called with the provided arguments passed while emitting/firing the event, the events are listed below with examples show the parameters for handler:
|
|
99
|
+
|
|
100
|
+
### Emitters
|
|
101
|
+
|
|
102
|
+
### `thumbnail:all-generated`
|
|
103
|
+
|
|
104
|
+
Emitted when all the thumbnails are generated.
|
|
105
|
+
|
|
106
|
+
`params`: No params returned.
|
|
107
|
+
|
|
108
|
+
example
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
scaleflexWidget.on('thumbnail:all-generated', () => {
|
|
112
|
+
console.log('all thumbnails generated')
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### `thumbnail:generated`
|
|
117
|
+
|
|
118
|
+
Emitted when a file's thumbnail is generated.
|
|
119
|
+
|
|
120
|
+
`params`:
|
|
121
|
+
- `file`: The file object whom thumbnail is generated.
|
|
122
|
+
- `preview`: The generated thumbnail image local url.
|
|
123
|
+
|
|
124
|
+
example
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
scaleflexWidget.on('thumbnail:generated', (file, previewUrl) => {
|
|
128
|
+
console.log('[Thumbnail-generator]: File's thumbnail is generated', file)
|
|
129
|
+
const img = document.createElement('img')
|
|
130
|
+
img.src = previewUrl
|
|
131
|
+
img.width = 111
|
|
132
|
+
document.body.appendChild(img)
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### `thumbnail:error`
|
|
137
|
+
|
|
138
|
+
Emitted when a file's thumbnail generating faced an error.
|
|
139
|
+
|
|
140
|
+
`params`:
|
|
141
|
+
- `file`: The file object whom thumbnail is generated.
|
|
142
|
+
- `error`: The error faced while generated.
|
|
143
|
+
|
|
144
|
+
example
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
scaleflexWidget.on('thumbnail:generated', (file, error) => {
|
|
148
|
+
console.log('[Thumbnail-generator]: File's thumbnail had an error while generating', file)
|
|
149
|
+
console.log('The error: ', error)
|
|
150
|
+
})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Subscribers
|
|
154
|
+
|
|
155
|
+
#### `thumbnail:request`
|
|
156
|
+
|
|
157
|
+
`handler`: (fileObject) => ...
|
|
158
|
+
|
|
159
|
+
Subscribes the handler of generating thumbnail for a file, fired when the event is emitted.
|
|
160
|
+
|
|
161
|
+
#### `thumbnail:update`
|
|
162
|
+
|
|
163
|
+
`handler`: (fileObject) => ...
|
|
164
|
+
|
|
165
|
+
Subscribes the handler of updating a generated thumbnail for a file, fired when the event is emitted.
|
|
166
|
+
|
|
167
|
+
<!-- Variables -->
|
|
168
|
+
|
|
169
|
+
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-thumbnail-generator
|
|
170
|
+
[license-url]: https://opensource.org/licenses/MIT
|
|
171
|
+
[sfx-url]: https://www.scaleflex.com/
|
|
172
|
+
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-thumbnail-generator
|
|
173
|
+
[codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
|
|
174
|
+
|
|
175
|
+
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
176
|
+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
177
|
+
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
178
|
+
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
179
|
+
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
180
|
+
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-thumbnail-generator?label=Version&style=for-the-badge&logo=npm
|
|
181
|
+
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|