@scaleflex/widget-core 0.0.1
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 +7324 -0
- package/LICENSE +21 -0
- package/README.md +1089 -0
- package/dist/style.css +190 -0
- package/dist/style.min.css +1 -0
- package/lib/Client.js +390 -0
- package/lib/Plugin.js +298 -0
- package/lib/Providers.js +112 -0
- package/lib/SassKeyRenewer.js +332 -0
- package/lib/_common.scss +240 -0
- package/lib/_utils.scss +38 -0
- package/lib/_variables.scss +64 -0
- package/lib/createStore.js +45 -0
- package/lib/defaultLocale.js +66 -0
- package/lib/hooks/index.js +7 -0
- package/lib/hooks/useContextMenu.js +42 -0
- package/lib/hooks/useContextMenuData.js +17 -0
- package/lib/hooks/useCore.js +10 -0
- package/lib/hooks/useModal.js +72 -0
- package/lib/hooks/useModalData.js +7 -0
- package/lib/hooks/usePlugin.js +20 -0
- package/lib/hooks/usePluginsType.js +18 -0
- package/lib/index.js +1918 -0
- package/lib/loggers.js +45 -0
- package/lib/slices/common.slice.js +90 -0
- package/lib/slices/index.js +12 -0
- package/lib/slices/info.slice.js +52 -0
- package/lib/slices/uploads.slice.js +294 -0
- package/lib/slices/user.slice.js +256 -0
- package/lib/style.scss +3 -0
- package/lib/supportsUploadProgress.js +42 -0
- package/lib/utils/calculateTotalEta.js +21 -0
- package/package.json +38 -0
- package/types/index.d.ts +301 -0
package/README.md
ADDED
|
@@ -0,0 +1,1089 @@
|
|
|
1
|
+
# Scaleflex Media Asset Widget (FMAW)
|
|
2
|
+
|
|
3
|
+
> This package contains both the main/global readme for the whole widget and the readme for (@scaleflex/widget-core)[#scaleflexwidget-core] plugin itself.
|
|
4
|
+
|
|
5
|
+
[![Plugins][plugins-image]](#plugins)
|
|
6
|
+
[![Website][filerobot-image]][sfx-url]
|
|
7
|
+
[![Version][filerobot-version]][version-url]
|
|
8
|
+
[![Version][filerobot-version-latest]][version-url-latest]
|
|
9
|
+
[![Version][filerobot-version-stable]][version-url-stable]
|
|
10
|
+
[![Scaleflex team][made-by-image]][sfx-url]
|
|
11
|
+
[![License][license-image]][license-url]
|
|
12
|
+
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
13
|
+
|
|
14
|
+
<div align='center'>
|
|
15
|
+
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://cdn.scaleflex.com/plugins/filerobot-widget/assets/filerobot_widget_logo_with_fire.png?vh=b2ff09" width="140"/>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
The **FMAW** is a file uploader and media gallery in one easy-to-integrate modal or inline widget. It is the storefront of the [**Scaleflex**](https://scaleflex.com) DAM (Digital Asset Management) and enables accelerated uploads through Scaleflex's content ingestion network and reverse CDN.
|
|
19
|
+
|
|
20
|
+
Various plugins like for example the [**Scaleflex Image Editor**](https://www.npmjs.com/package/@scaleflex/widget-image-editor/#scaleflexwidgetimage-editor) can be enabled to address use cases requiring the interaction with images, videos and static files in your web application. The modular architecture only loads relevant code, thus making the widget as lightweight as possible.
|
|
21
|
+
|
|
22
|
+
<!-- <img src="https://cdn.scaleflex.com/demo/widget-npm_v8.gif?vh=4780be" title="Overview of the widget GIF" alt="Overview of the widget GIF" width="600" /> -->
|
|
23
|
+
|
|
24
|
+
**[Check it live in action](https://cdn.scaleflex.com/plugins/filerobot-widget/v3/demo/index.html)**
|
|
25
|
+
|
|
26
|
+
<details>
|
|
27
|
+
<summary>Table of contents</summary>
|
|
28
|
+
|
|
29
|
+
- [Scaleflex Media Asset Widget (FMAW)](#scaleflexwidget-media-asset-widget-fmaw)
|
|
30
|
+
- [Main features:](#main-features)
|
|
31
|
+
- [Installation](#installation)
|
|
32
|
+
- [Quickstart](#quickstart)
|
|
33
|
+
- [Demo](#demo)
|
|
34
|
+
- [React](#react)
|
|
35
|
+
- [Vanilla (plain) JS](#vanilla-plain-js)
|
|
36
|
+
- [Modules](#modules)
|
|
37
|
+
- [Plugins](#plugins)
|
|
38
|
+
- [UI Elements](#ui-elements)
|
|
39
|
+
- [Upload connectors](#upload-connectors)
|
|
40
|
+
- [Destinations](#destinations)
|
|
41
|
+
- [Miscellaneous](#miscellaneous)
|
|
42
|
+
- [Widget modes](#modes)
|
|
43
|
+
- [@scaleflex/widget-core](#scaleflexwidget-core)
|
|
44
|
+
- [Usage](#usage)
|
|
45
|
+
- [Properties](#properties)
|
|
46
|
+
- [Events](#events)
|
|
47
|
+
- [License](#license)
|
|
48
|
+
</details>
|
|
49
|
+
|
|
50
|
+
## Main features:
|
|
51
|
+
|
|
52
|
+
- Single and multiple file upload into a Scaleflex storage container (project)
|
|
53
|
+
- Upload via Drag & Drop or Copy & Paste
|
|
54
|
+
- Upload from 3rd party storages such as Google Drive, Dropbox, OneDrive, Facebook, Instagram
|
|
55
|
+
- Webcam and screen cast integration to upload realtime videos and screen recordings
|
|
56
|
+
- File explorer and media gallery with file management capabilites (folder creation, file move, rename, ...)
|
|
57
|
+
- Zipped download of multiple files
|
|
58
|
+
- File versioning with history, version browsing
|
|
59
|
+
- File and media asset sharing via accelerated CDN links
|
|
60
|
+
- Media gallery with powerful search capabilities based on tags and customizable metadata (taxonomy)
|
|
61
|
+
- AI-based tagging of images
|
|
62
|
+
- Embedded Scaleflex Image Editor for inline image editing
|
|
63
|
+
- Image annotator and comments for collaboration
|
|
64
|
+
- Image variant generator with customizable template to generate optimal sizes for social media posts (example)
|
|
65
|
+
- Post-upload video transcoding for delivering HLS & DASH playlists for adaptive streaming
|
|
66
|
+
- On-the-fly image resizing via [Cloudimage](https://cloudimage.io)
|
|
67
|
+
|
|
68
|
+
The widget can be integrated in a web page HTML element, as a pop-up modal on button click.
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
The widget's architecture contains the [**Core**](#scaleflexwidget-core) module and various [**plugins**](#plugins). Each [**plugin**](#plugins) has its own dedicated documentation.
|
|
73
|
+
|
|
74
|
+
**CDN links to JS and CSS (containing all plugins)**
|
|
75
|
+
|
|
76
|
+
- Add the following CSS file before the end of `</head>` in your `HTML` file
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<link
|
|
80
|
+
rel="stylesheet"
|
|
81
|
+
type="text/css"
|
|
82
|
+
href="https://cdn.scaleflex.com/plugins/filerobot-widget/v3/stable/filerobot-widget.min.css"
|
|
83
|
+
/>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- Add the following JS file before the end of `</body>` in your `HTML` file.
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<script
|
|
90
|
+
type="text/javascript"
|
|
91
|
+
src="https://cdn.scaleflex.com/plugins/filerobot-widget/v3/stable/filerobot-widget.min.js"
|
|
92
|
+
></script>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
> The CDN versions of the library contains all plugins whereas npm gives you flexibility to include only plugins/modules you need to have lighter lib files. For example, you can just use the [**Core**](https://www.npmjs.com/package/@scaleflex/widget-core/#scaleflexwidget-core) module and the [**XHR Upload**](https://www.npmjs.com/package/@scaleflex/widget-xhr-upload/#scaleflexwidgetxhr-upload) plugin to integrate a simple uploader to your application, without file explorer, media gallery and image editor.
|
|
96
|
+
|
|
97
|
+
## Quickstart
|
|
98
|
+
|
|
99
|
+
### Demo
|
|
100
|
+
|
|
101
|
+
[See the FMAW in action here](https://cdn.scaleflex.com/plugins/filerobot-widget/v3/demo/index.html).
|
|
102
|
+
|
|
103
|
+
The following implementation examples build a FMAW for uploading files, showing the [**Scaleflex Explorer**](https://www.npmjs.com/package/@scaleflex/widget-explorer/#scaleflexwidgetexplorer) as a file explorer/media gallery, enabling the [**Webcam**](https://www.npmjs.com/package/@scaleflex/widget-webcam/#scaleflexwidgetwebcam) for capturing photos and videos and the [**Scaleflex Image Editor**](https://www.npmjs.com/package/@scaleflex/widget-image-editor/#scaleflexwidgetimage-editor) for editing images inline.
|
|
104
|
+
|
|
105
|
+
At minima, you will need the following 3 packages to display a basic FMAW:
|
|
106
|
+
|
|
107
|
+
- [**Core**](#scaleflexwidget-core)
|
|
108
|
+
- [**Scaleflex Explorer**](https://www.npmjs.com/package/@scaleflex/widget-explorer/#scaleflexwidgetexplorer)
|
|
109
|
+
- [**XHR Upload**](https://www.npmjs.com/package/@scaleflex/widget-xhr-upload/#scaleflexwidgetxhr-upload)
|
|
110
|
+
|
|
111
|
+
You can obtain a `container` name and `securityTemplateId` from your [Scaleflex](https://www.scaleflex.com/) account in order for files to be uploaded in the specified Scaleflex storage container (also called project in Scaleflex).
|
|
112
|
+
|
|
113
|
+
### React
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import ScaleflexWidget from "@scaleflex/widget-core";
|
|
117
|
+
import Explorer from "@scaleflex/widget-explorer";
|
|
118
|
+
import XHRUpload from "@scaleflex/widget-xhr-upload";
|
|
119
|
+
import ImageEditor from "@scaleflex/widget-image-editor";
|
|
120
|
+
import Webcam from "@scaleflex/widget-webcam";
|
|
121
|
+
|
|
122
|
+
import "@scaleflex/widget-core/dist/style.min.css";
|
|
123
|
+
import "@scaleflex/widget-explorer/dist/style.min.css";
|
|
124
|
+
import "@scaleflex/widget-image-editor/dist/style.min.css";
|
|
125
|
+
import "@scaleflex/widget-webcam/dist/style.min.css";
|
|
126
|
+
|
|
127
|
+
const App = () => {
|
|
128
|
+
const scaleflexWidget = useRef(null);
|
|
129
|
+
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
const demoContainer = "scaleflex-tests-v5a";
|
|
132
|
+
const demoSecurityTemplateId = "......";
|
|
133
|
+
|
|
134
|
+
scaleflexWidget.current = ScaleflexWidget({
|
|
135
|
+
securityTemplateId: demoSecurityTemplateId,
|
|
136
|
+
container: demoContainer,
|
|
137
|
+
dev: false,
|
|
138
|
+
})
|
|
139
|
+
.use(Explorer, { target: "#scaleflex-widget", inline: true })
|
|
140
|
+
.use(XHRUpload)
|
|
141
|
+
.use(ImageEditor)
|
|
142
|
+
.use(Webcam);
|
|
143
|
+
|
|
144
|
+
return () => {
|
|
145
|
+
scaleflexWidget.current.close();
|
|
146
|
+
};
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<div>
|
|
151
|
+
<h1>React Example</h1>
|
|
152
|
+
<div id="scaleflex-widget" />
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
render(<App />, document.getElementById("app"));
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Vanilla (plain) JS
|
|
161
|
+
|
|
162
|
+
```html
|
|
163
|
+
<html>
|
|
164
|
+
<head>
|
|
165
|
+
<link
|
|
166
|
+
rel="stylesheet"
|
|
167
|
+
type="text/css"
|
|
168
|
+
href="https://cdn.scaleflex.com/plugins/filerobot-widget/v3/stable/filerobot-widget.min.css"
|
|
169
|
+
/>
|
|
170
|
+
</head>
|
|
171
|
+
<body>
|
|
172
|
+
<div id="scaleflex-widget"></div>
|
|
173
|
+
|
|
174
|
+
<script src="https://cdn.scaleflex.com/plugins/filerobot-widget/v3/stable/filerobot-widget.min.js"></script>
|
|
175
|
+
|
|
176
|
+
<script type="text/javascript">
|
|
177
|
+
const widget = window.ScaleflexWidget;
|
|
178
|
+
const demoContainer = "scaleflex-tests-v5a";
|
|
179
|
+
const demoSecurityTemplateId = "......";
|
|
180
|
+
|
|
181
|
+
const scaleflexWidget = widget.Core({
|
|
182
|
+
securityTemplateId: demoSecurityTemplateId,
|
|
183
|
+
container: demoContainer,
|
|
184
|
+
dev: false, // optional, default: false
|
|
185
|
+
});
|
|
186
|
+
const Explorer = widget.Explorer;
|
|
187
|
+
const XHRUpload = widget.XHRUpload;
|
|
188
|
+
const ImageEditor = widget.ImageEditor;
|
|
189
|
+
const Webcam = widget.Webcam;
|
|
190
|
+
|
|
191
|
+
scaleflexWidget
|
|
192
|
+
.use(Explorer, { target: "#scaleflex-widget", inline: true })
|
|
193
|
+
.use(XHRUpload)
|
|
194
|
+
.use(ImageEditor)
|
|
195
|
+
.use(Webcam);
|
|
196
|
+
</script>
|
|
197
|
+
</body>
|
|
198
|
+
</html>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Modules
|
|
202
|
+
|
|
203
|
+
The Scaleflex Core module: [**Core**](#scaleflexwidget-core)
|
|
204
|
+
|
|
205
|
+
## Plugins
|
|
206
|
+
|
|
207
|
+
### UI Elements
|
|
208
|
+
|
|
209
|
+
- [**Scaleflex Explorer**](https://www.npmjs.com/package/@scaleflex/widget-explorer/#scaleflexwidgetexplorer): Scaleflex File Explorer provides different modes to achieve different capabilities like basic uploader, light DAM for managing your assets or even a file picker for your assets with customizing your functionality.
|
|
210
|
+
|
|
211
|
+
Following plugins can be added to augment the Scaleflex's File Explorer capabilities:
|
|
212
|
+
|
|
213
|
+
- [**Progress Panel**](https://www.npmjs.com/package/@scaleflex/widget-progress-panel/#scaleflexwidgetprogress-panel): displays upload, download, video activities and other processes status in a progress panel.
|
|
214
|
+
|
|
215
|
+
- [**Informer**](https://www.npmjs.com/package/@scaleflex/widget-informer/#scaleflexwidgetinformer): displays pop-up messages/statuses related to file operations.
|
|
216
|
+
|
|
217
|
+
- [**Scaleflex Image Editor**](https://www.npmjs.com/package/@scaleflex/widget-image-editor/#scaleflexwidgetimage-editor): inline image editor with functionalities such as `filters, crop, resizing, watermark, collages, etc...`. Also used by other features of the Widget such as the variant generator and export function.
|
|
218
|
+
|
|
219
|
+
- [**Pre-Upload Image Processor**](https://www.npmjs.com/package/@scaleflex/widget-preupload-processors/#scaleflexwidgetpreupload-processors): ability to resize a large image into the storage container before upload.
|
|
220
|
+
|
|
221
|
+
### Upload connectors
|
|
222
|
+
|
|
223
|
+
- [**Google Drive**](https://www.npmjs.com/package/@scaleflex/widget-google-drive/#scaleflexwidgetgoogle-drive): import files from Google Drive.
|
|
224
|
+
|
|
225
|
+
- [**Dropbox**](https://www.npmjs.com/package/@scaleflex/widget-dropbox/#scaleflexwidgetdropbox): import files from Dropbox.
|
|
226
|
+
|
|
227
|
+
- [**Box**](https://www.npmjs.com/package/@scaleflex/widget-box/#scaleflexwidgetbox): import files from Box.
|
|
228
|
+
|
|
229
|
+
- [**Instagram**](https://www.npmjs.com/package/@scaleflex/widget-instagram/#scaleflexwidgetinstagram): import images and videos from Instagram.
|
|
230
|
+
|
|
231
|
+
- [**Facebook**](https://www.npmjs.com/package/@scaleflex/widget-facebook/#scaleflexwidgetfacebook): import images and videos from Facebook.
|
|
232
|
+
|
|
233
|
+
- [**OneDrive**](https://www.npmjs.com/package/@scaleflex/widget-onedrive/#scaleflexwidgetonedrive): import files from Microsoft OneDrive.
|
|
234
|
+
|
|
235
|
+
- [**Import From URL**](https://www.npmjs.com/package/@scaleflex/widget-url/#scaleflexwidgeturl): import direct URLs from anywhere on the web.
|
|
236
|
+
|
|
237
|
+
- [**Webcam**](https://www.npmjs.com/package/@scaleflex/widget-webcam/#scaleflexwidgetwebcam): capture photos or videos from the device's camera and upload them to the Scaleflex storage container.
|
|
238
|
+
|
|
239
|
+
- [**Screen Capture**](https://www.npmjs.com/package/@scaleflex/widget-screen-capture/#scaleflexwidgetscreen-capture): device screen recorder.
|
|
240
|
+
|
|
241
|
+
- [**Attach Drag & Drop zone**](https://www.npmjs.com/package/@scaleflex/widget-attach-dnd/#scaleflexwidgetattach-dnd): Plugin for attaching drag & drop zone for some specific HTML element in your page.
|
|
242
|
+
|
|
243
|
+
- [**Pixaforge**](https://www.npmjs.com/package/@scaleflex/widget-pixaforge/#scaleflexwidgetpixaforge): Plugin for importing free images & icons from Pixaforge that contains free gallery for different categories & tags.
|
|
244
|
+
|
|
245
|
+
- [**Canva**](https://www.npmjs.com/package/@scaleflex/widget-canva/#scaleflexwidgetcanva): Create your own design & customize it then upload it through the widget on the go by integrating this plugin inside the widget.
|
|
246
|
+
|
|
247
|
+
- [**Unsplash**](https://www.npmjs.com/package/@scaleflex/widget-unsplash/#scaleflexwidgetunsplash): import files from unsplash.
|
|
248
|
+
|
|
249
|
+
### Destinations
|
|
250
|
+
|
|
251
|
+
- [**XHR Upload**](https://www.npmjs.com/package/@scaleflex/widget-xhr-upload/#scaleflexwidgetxhr-upload): handles multipart file upload.
|
|
252
|
+
|
|
253
|
+
- [**Tus**](https://www.npmjs.com/package/@scaleflex/widget-Tus/#scaleflexwidgettus): applies resumable upload (BE must support that).
|
|
254
|
+
|
|
255
|
+
### Miscellaneous
|
|
256
|
+
|
|
257
|
+
- [**Thumbnail Generator**](https://www.npmjs.com/package/@scaleflex/widget-thumbnail-generator/#scaleflexwidgethumbnail-generator): thumbnail generator for different files to be used as file preview.
|
|
258
|
+
|
|
259
|
+
## Widget modes
|
|
260
|
+
|
|
261
|
+
Go to the [Explorer plugin modes](https://www.npmjs.com/package/@scaleflex/widget-explorer#explorermodes) as it is responsible about utilizing the different modes of the widget.
|
|
262
|
+
|
|
263
|
+
## `@scaleflex/widget-core`
|
|
264
|
+
|
|
265
|
+
The core module of the Scaleflex Media Asset Widget. This module contains all common settings shared across all FMAW plugins and can be used standalone in your upload workflows to interact with Scaleflex DAM.
|
|
266
|
+
|
|
267
|
+
## Usage
|
|
268
|
+
|
|
269
|
+
### NPM
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
npm install --save @scaleflex/widget-core
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### YARN
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
yarn add @scaleflex/widget-core
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
then
|
|
282
|
+
|
|
283
|
+
```js
|
|
284
|
+
import ScaleflexWidget from '@scaleflex/widget-core'
|
|
285
|
+
...
|
|
286
|
+
...
|
|
287
|
+
...
|
|
288
|
+
const scaleflexWidget = ScaleflexWidget(propertiesObject)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### CDN
|
|
292
|
+
|
|
293
|
+
If installed via the [CDN link](../@scaleflex/widget-core#installation), the plugin is inside the `ScaleflexWidget` global object as `ScaleflexWidget.Core`
|
|
294
|
+
|
|
295
|
+
```js
|
|
296
|
+
const scaleflexWidgetCore = window.ScaleflexWidget.Core
|
|
297
|
+
...
|
|
298
|
+
...
|
|
299
|
+
...
|
|
300
|
+
const scaleflexWidget = scaleflexWidgetCore(propertiesObject)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Module's styles
|
|
304
|
+
|
|
305
|
+
```js
|
|
306
|
+
import "@scaleflex/widget-core/dist/style.css";
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
or via the minified versions
|
|
310
|
+
|
|
311
|
+
```js
|
|
312
|
+
import "@scaleflex/widget-core/dist/style.min.css";
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
> The Core's styles must be imported before the scaleflexWidget's plugins' styles.
|
|
316
|
+
|
|
317
|
+
## Properties
|
|
318
|
+
|
|
319
|
+
Required attributes are marked with **_(Required)_**.
|
|
320
|
+
|
|
321
|
+
### `container`
|
|
322
|
+
|
|
323
|
+
<u>Type:</u> `string` **_Required_**.
|
|
324
|
+
|
|
325
|
+
<u>Default:</u> `undefined`
|
|
326
|
+
|
|
327
|
+
The container token (Scaleflex token) that will be used in all the widget's modes & plugins ex. (listing files/folders, uploading, renaming, deleting...etc.). Register for an account at [scaleflex.com](www.scaleflex.com) to obtain a token.
|
|
328
|
+
|
|
329
|
+
### `securityTemplateId`
|
|
330
|
+
|
|
331
|
+
**PREVIOUSLY**: `securityTemplateID`
|
|
332
|
+
|
|
333
|
+
<u>Type:</u> `string` **_Required_**.
|
|
334
|
+
|
|
335
|
+
<u>Default:</u> `undefined`
|
|
336
|
+
|
|
337
|
+
The Security Template Id is used for the the FMAW to request session-specific API access keys, also known as SASS key. [Security Templates](https://docs.filerobot.com/go/filerobot-documentation/en/dam-api/api-authentication/security-templates#85e64ad9266588659bf160f345eb46ca87ab1362) are created in the Scaleflex Asset Hub and define permissions and validity for SASS keys. They work similar to oAuth2 tokens.
|
|
338
|
+
|
|
339
|
+
### `id`
|
|
340
|
+
|
|
341
|
+
<u>Type:</u> `string`.
|
|
342
|
+
|
|
343
|
+
<u>Default:</u> `'scaleflexWidget'`
|
|
344
|
+
|
|
345
|
+
The unique identifier used for identifying the widget's instance (# in HTML selector).
|
|
346
|
+
|
|
347
|
+
### `dev`
|
|
348
|
+
|
|
349
|
+
<u>Type:</u> `boolean`.
|
|
350
|
+
|
|
351
|
+
<u>Default:</u> `false`.
|
|
352
|
+
|
|
353
|
+
Enables the development mode which sends all requests to development server, otherwise all the endpoints defaults to the production server.
|
|
354
|
+
|
|
355
|
+
> Note: enabling development mode, will show some features that won't work (they're hidden in production mode) with u cause of the generated sass key permissions (that is generated through the security template id).
|
|
356
|
+
|
|
357
|
+
### `theme`
|
|
358
|
+
|
|
359
|
+
<u>Type:</u> `object`.
|
|
360
|
+
|
|
361
|
+
<u>Default:</u>
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
{
|
|
365
|
+
palette: {...},
|
|
366
|
+
breakpoints: {...},
|
|
367
|
+
typography: {...}
|
|
368
|
+
shadows: {...}
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
> You can check default values for each property here:
|
|
373
|
+
|
|
374
|
+
- [color palette](https://github.com/scaleflex/ui/blob/master/packages/ui/src/theme/roots/palette/entity/default-palette.ts)
|
|
375
|
+
- [typography](https://github.com/scaleflex/ui/blob/master/packages/ui/src/theme/roots/typography/entity/default-typography.ts)
|
|
376
|
+
- [breakpoints](https://github.com/scaleflex/ui/blob/master/packages/ui/src/theme/roots/breakpoints/entity/default-breakpoints.ts)
|
|
377
|
+
- [shadows](https://github.com/scaleflex/ui/blob/master/packages/ui/src/theme/roots/shadows/entity/default-shadows.ts)
|
|
378
|
+
|
|
379
|
+
We are using [**@scaleflex/ui**](https://github.com/scaleflex/ui/tree/master/packages/ui/src/theme) theme system to have global theme wrapping the project and you can customize it by overriding the default theme values.
|
|
380
|
+
|
|
381
|
+
You can check the values you can override for each property:
|
|
382
|
+
|
|
383
|
+
- For color palette you can select the property key from this [**list**](https://github.com/scaleflex/ui/blob/master/packages/ui/src/utils/types/palette/color.ts#L1)
|
|
384
|
+
- For typography, you can change [**font variant**](https://github.com/scaleflex/ui/blob/master/packages/ui/src/utils/types/typography/font-variant.ts) and [**font weight**](https://github.com/scaleflex/ui/blob/master/packages/ui/src/utils/types/typography/font-weight.ts)
|
|
385
|
+
- For breakpoints [**list**](https://github.com/scaleflex/ui/blob/master/packages/ui/src/utils/types/css/breakpoint.ts)
|
|
386
|
+
- For Shadows [**list**](https://github.com/scaleflex/ui/blob/master/packages/ui/src/utils/types/shadows/shadows.ts)
|
|
387
|
+
|
|
388
|
+
```
|
|
389
|
+
theme: {
|
|
390
|
+
palette: {
|
|
391
|
+
"accent-primary": "#479898",
|
|
392
|
+
"accent-primary-hover": "#479898",
|
|
393
|
+
"accent-primary-active": "#479898",
|
|
394
|
+
"accent-stateless": "#479898",
|
|
395
|
+
"link-pressed": "#479898",
|
|
396
|
+
"border-active-bottom": "#479898"
|
|
397
|
+
},
|
|
398
|
+
typography: {
|
|
399
|
+
"title-h6": {
|
|
400
|
+
fontWeight: FontWeight.Medium, // 500
|
|
401
|
+
fontSize: '12px',
|
|
402
|
+
lineHeight: '18px',
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
breakpoints: {
|
|
406
|
+
values: {
|
|
407
|
+
xs: 0,
|
|
408
|
+
md: 900,
|
|
409
|
+
xl: 1400
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
shadows: {
|
|
413
|
+
"shadow-sm": '6px -4px 12px 0px rgba(146, 166, 188, 0.14)'
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
> NOTE: You must import the font family from your side in 2 weights (Normal === 400, Medium === 500) to have fonts work properly and show text as expected, which means `Roboto` is not included in the plugin by default so you must import it from your side too if you have provided another font family value through theme don't forget to import it from your side too.
|
|
419
|
+
|
|
420
|
+
### `autoProceed`
|
|
421
|
+
|
|
422
|
+
<u>Type:</u> `boolean`.
|
|
423
|
+
|
|
424
|
+
<u>Default:</u> `false`.
|
|
425
|
+
|
|
426
|
+
If set to `true`, the upload process of one or multiple assets will start automatically after drag and drop in the upload area or selection from the user's local explorer. If set to `false`, the pre-upload features will be available to the user before starting the upload via the **Upload** button.
|
|
427
|
+
|
|
428
|
+
> Note: this won't open the progress-panel automatically.
|
|
429
|
+
|
|
430
|
+
### `allowMultipleUploads`
|
|
431
|
+
|
|
432
|
+
<u>Type:</u> `boolean`.
|
|
433
|
+
|
|
434
|
+
<u>Default:</u> `true`.
|
|
435
|
+
|
|
436
|
+
If set to `false`, only one upload will be possible simultaneously.
|
|
437
|
+
|
|
438
|
+
### `debug`
|
|
439
|
+
|
|
440
|
+
<u>Type:</u> `boolean`.
|
|
441
|
+
|
|
442
|
+
<u>Default:</u> `false`.
|
|
443
|
+
|
|
444
|
+
Turns on the debug mode by exposing the plugin's debug information to the global window object and turns on the logger.
|
|
445
|
+
|
|
446
|
+
### `logger`
|
|
447
|
+
|
|
448
|
+
<u>Type:</u> `object`.
|
|
449
|
+
|
|
450
|
+
<u>Default:</u>
|
|
451
|
+
|
|
452
|
+
```js
|
|
453
|
+
errorsLogger = {
|
|
454
|
+
debug: (...args) => {},
|
|
455
|
+
warn: (...args) => {},
|
|
456
|
+
error: (...args) => console.error(`[Scaleflex] [${getTimeStamp()}]`, ...args),
|
|
457
|
+
};
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### `restrictions`
|
|
461
|
+
|
|
462
|
+
<u>Type:</u> `object`.
|
|
463
|
+
|
|
464
|
+
<u>Default:</u>
|
|
465
|
+
|
|
466
|
+
```js
|
|
467
|
+
{
|
|
468
|
+
maxFileSize: null,
|
|
469
|
+
maxNumberOfFiles: null,
|
|
470
|
+
minNumberOfFiles: null,
|
|
471
|
+
allowedFileTypes: null,
|
|
472
|
+
maxItemsSizeForCompression: null,
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
Upload restrictions:
|
|
477
|
+
|
|
478
|
+
| Property | Type | Default | Description |
|
|
479
|
+
| ------------------------------ | ------------------- | ------- | -------------------------------------------------------------------------- |
|
|
480
|
+
| **`maxFileSize`** | `number` \| `null` | `null` | maximum file size in bytes |
|
|
481
|
+
| **`maxTotalFilesSize`** | `number` \| `null` | `null` | maximum files size in megabyte |
|
|
482
|
+
| **`totalUploadedFilesSize`** | `number` \| `null` | `null` | total uploaded files size in megabyte |
|
|
483
|
+
| **`hideRestrictionsInformer`** | `boolean` \| `null` | `null` | hide restrictions informer message |
|
|
484
|
+
| **`maxNumberOfFiles`** | `number` \| `null` | `null` | maximum number of files to be uploaded simultaneously |
|
|
485
|
+
| **`minNumberOfFiles`** | `number` \| `null` | `null` | minimum number of files before upload can star |
|
|
486
|
+
| **`allowedFileTypes`** | `array` \| `null` | `null` | accepted file types or extensions, eg. `['image/*', 'image/jpeg', '.jpg']` |
|
|
487
|
+
|
|
488
|
+
Upload restrictions can also be governed in the backend by the [Security Template](#securitytemplateid) configured.
|
|
489
|
+
|
|
490
|
+
Download restrictions:
|
|
491
|
+
|
|
492
|
+
| Property | Type | Default | Description |
|
|
493
|
+
| -------------------------------- | ------------------ | ------- | ------------------------------------------- |
|
|
494
|
+
| **`maxItemsSizeForCompression`** | `number` \| `null` | `null` | maximum items size for compression in bytes |
|
|
495
|
+
|
|
496
|
+
### `onBeforeFileAdded`
|
|
497
|
+
|
|
498
|
+
<u>Type:</u> `function`.
|
|
499
|
+
|
|
500
|
+
<u>Default:</u> `(currentFile, files) => currentFile`
|
|
501
|
+
|
|
502
|
+
Gives the possibility to do some checks before adding the file to the state's object,
|
|
503
|
+
|
|
504
|
+
- if the function returns `true`, the file is added to the state.
|
|
505
|
+
- if the function returns a modified `file` object the returned object would be added to the state.
|
|
506
|
+
- if the function returns `false`, the file is not added to the state.
|
|
507
|
+
|
|
508
|
+
### `onBeforeUpload`
|
|
509
|
+
|
|
510
|
+
<u>Type:</u> `function`.
|
|
511
|
+
|
|
512
|
+
<u>Default:</u> `onBeforeUpload: (files) => files`
|
|
513
|
+
|
|
514
|
+
Gives the possibility to do some checks before starting the upload process
|
|
515
|
+
|
|
516
|
+
- if the function returned `true` the upload would start.
|
|
517
|
+
- if returned `files` object the returned object would be processed.
|
|
518
|
+
- if returned `false` the uploading process won't start.
|
|
519
|
+
|
|
520
|
+
### `language`
|
|
521
|
+
|
|
522
|
+
<u>Type:</u> `string`.
|
|
523
|
+
|
|
524
|
+
<u>Default:</u>`'en'`
|
|
525
|
+
|
|
526
|
+
Used to determine which language to use from the widget's backend translated languages.
|
|
527
|
+
|
|
528
|
+
### `locale`
|
|
529
|
+
|
|
530
|
+
<u>Type:</u> `object`.
|
|
531
|
+
|
|
532
|
+
<u>Default:</u> default locales inside `lib/defaultLocale.js`
|
|
533
|
+
|
|
534
|
+
You can override some labels by specifying a translation object here, such as:
|
|
535
|
+
|
|
536
|
+
````js
|
|
537
|
+
{
|
|
538
|
+
strings: {
|
|
539
|
+
loaderLoadingLabel: 'Loading'
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
## Methods
|
|
544
|
+
|
|
545
|
+
### `scaleflexWidget.getId()`
|
|
546
|
+
|
|
547
|
+
Gets the Scaleflex Media Asset Widget's instance id.
|
|
548
|
+
|
|
549
|
+
### `scaleflexWidget.use(plugin, pluignOptions)`
|
|
550
|
+
|
|
551
|
+
Adds a plugin to the Scaleflex Media Asset Widget's instance:
|
|
552
|
+
|
|
553
|
+
```js
|
|
554
|
+
import ScaleflexWidget from '@scaleflex/widget-core'
|
|
555
|
+
import Explorer from '@scaleflex/widget-explorer'
|
|
556
|
+
|
|
557
|
+
const scaleflexWidget = ScaleflexWidget()
|
|
558
|
+
scaleflexWidget.use(Explorer, {...})
|
|
559
|
+
````
|
|
560
|
+
|
|
561
|
+
Refer to the individual plugin's documentation page for available configuration and customization options.
|
|
562
|
+
|
|
563
|
+
### `scaleflexWidget.getPlugin(pluginId)`
|
|
564
|
+
|
|
565
|
+
Returns the plugin's instance with the provided id for accessing its methods & state.
|
|
566
|
+
|
|
567
|
+
### `scaleflexWidget.removePlugin(pluginInstance)`
|
|
568
|
+
|
|
569
|
+
Removes a currently initialized plugin by passing the plugin's instance retrieved from the [getPlugin](#scaleflexwidgetgetpluginpluginid) method.
|
|
570
|
+
|
|
571
|
+
### `scaleflexWidget.setOptions(options)`
|
|
572
|
+
|
|
573
|
+
Passes [Properties](#properties) to the Widget to change properties set during initialization:
|
|
574
|
+
|
|
575
|
+
```js
|
|
576
|
+
import ScaleflexWidget from "@scaleflex/widget-core";
|
|
577
|
+
|
|
578
|
+
const scaleflexWidget = ScaleflexWidget();
|
|
579
|
+
scaleflexWidget.setOptions({
|
|
580
|
+
autoProceed: true,
|
|
581
|
+
});
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
Individual plugin options can also be changed by using [getPlugin](#scaleflexwidgetgetpluginpluginid)
|
|
585
|
+
|
|
586
|
+
```js
|
|
587
|
+
import Scaleflex from "@scaleflex/widget-core";
|
|
588
|
+
|
|
589
|
+
const scaleflexWidget = ScaleflexWidget();
|
|
590
|
+
scaleflexWidget.use(Explorer, { id: "Explorer" });
|
|
591
|
+
scaleflexWidget.getPlugin("Explorer").setOptions({
|
|
592
|
+
animateOpenClose: false,
|
|
593
|
+
});
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### `scaleflexWidget.addFile(fileObject)`
|
|
597
|
+
|
|
598
|
+
Adds a file into the widget's state and returns the temporary generated id for that file.
|
|
599
|
+
|
|
600
|
+
> [restrictions](#restrictions) are checked and [onBeforeFileAdded](#onbeforefileadded) called before adding the file.
|
|
601
|
+
|
|
602
|
+
### `scaleflexWidget.getFile(fileId)`
|
|
603
|
+
|
|
604
|
+
Gets the file object using its id.
|
|
605
|
+
|
|
606
|
+
### `scaleflexWidget.removeFile(fileId)`
|
|
607
|
+
|
|
608
|
+
Removes a file from the widget's state via its id.
|
|
609
|
+
|
|
610
|
+
### `scaleflexWidget.getFiles()`
|
|
611
|
+
|
|
612
|
+
Returns all the file objects currently loaded in the widget.
|
|
613
|
+
|
|
614
|
+
### `scaleflexWidget.upload(files, callback)`
|
|
615
|
+
|
|
616
|
+
An async function that starts uploading files, returns a promise resolved with an object `result: { successful, failed }` containing:
|
|
617
|
+
|
|
618
|
+
- `successful`: array with file objects successfully uploaded.
|
|
619
|
+
- `failed`: array with files objects for which upload failed.
|
|
620
|
+
|
|
621
|
+
### `scaleflexWidget.retryAll()` _Deprecated_
|
|
622
|
+
|
|
623
|
+
Retries all the failed uploads.
|
|
624
|
+
|
|
625
|
+
### `scaleflexWidget.retryUpload(fileId)`
|
|
626
|
+
|
|
627
|
+
Retries a failed upload for a file referenced by its id.
|
|
628
|
+
|
|
629
|
+
### `scaleflexWidget.cancelUploads()`
|
|
630
|
+
|
|
631
|
+
emit [cancel-uploads](#cancel-uploads) event and cancel uploads.
|
|
632
|
+
|
|
633
|
+
### `scaleflexWidget.setCoreCommonState(object)`
|
|
634
|
+
|
|
635
|
+
Updates the internal state of the widget's core common state.
|
|
636
|
+
|
|
637
|
+
### `scaleflexWidget.getGlobalState()`
|
|
638
|
+
|
|
639
|
+
Returns the internal state/store of the widget's.
|
|
640
|
+
|
|
641
|
+
### `scaleflexWidget.setUploadPanelFileState(fileId, state)` _Deprecated_ - changed to setFileStateBeforeUpload
|
|
642
|
+
|
|
643
|
+
updates the state of a file inside the uploads panel before triggering upload.
|
|
644
|
+
|
|
645
|
+
### `scaleflexWidget.setProgressPanelFileState(fileId, state)` _Deprecated_ - use [`setFileUploadingState`](#setFileUploadingState) instead
|
|
646
|
+
|
|
647
|
+
updates the state of a file inside the [Progress Panel](../@scaleflex/widget-progress-panel/#scaleflexwidgetprogress-panel).
|
|
648
|
+
|
|
649
|
+
### `scaleflexWidget.setFileUploadingState(fileId, state)`
|
|
650
|
+
|
|
651
|
+
updates the state of a file uploading.
|
|
652
|
+
|
|
653
|
+
### `scaleflexWidget.getFileUploading(fileId)`
|
|
654
|
+
|
|
655
|
+
Returns a file that is uploading.
|
|
656
|
+
|
|
657
|
+
### `scaleflexWidget.setFilesInfoMetaTags(fileIds, filesInfoMetaTagsData, forceUpdate)`
|
|
658
|
+
|
|
659
|
+
Updates the info and/or meta object(s) of the passed files that would be uploaded with the provided `info` and `meta` objects parameters received from `filesInfoMetaTagsData` object in the following format `{ info: {}, meta: {}, tags: {} }`, `forceUpdate` means replace the current tags instead of deep merging with the current ones.
|
|
660
|
+
|
|
661
|
+
### `scaleflexWidget.reset()` _Deprecated_
|
|
662
|
+
|
|
663
|
+
Returns everything to the initial state of the widget ex. stops all the files uploading, reset their progress and removes all of them.
|
|
664
|
+
|
|
665
|
+
### `scaleflexWidget.close()`
|
|
666
|
+
|
|
667
|
+
Removes all the installed plugins & closes the current widget's instance.
|
|
668
|
+
|
|
669
|
+
### `scaleflexWidget.on('event', handler)`
|
|
670
|
+
|
|
671
|
+
Adds/Subscribe a handler/callback function to be called on emitting/firing the specified `scaleflexWidget event`, [full list of available events](#events).
|
|
672
|
+
|
|
673
|
+
### `scaleflexWidget.once('event', handler)`
|
|
674
|
+
|
|
675
|
+
Same as `scaleflexWidget.on` but the handler is removed after being called once.
|
|
676
|
+
|
|
677
|
+
### `scaleflexWidget.off('event', handler)`
|
|
678
|
+
|
|
679
|
+
Un-subscribe/Removes the specified handler for scaleflexWidget's event.
|
|
680
|
+
|
|
681
|
+
### `scaleflexWidget.info(message, type, timeout)`
|
|
682
|
+
|
|
683
|
+
Shows an informer with the specified message to the user:
|
|
684
|
+
|
|
685
|
+
| Property | Type | Default | Description |
|
|
686
|
+
| ------------- | --------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
687
|
+
| **`message`** | `string` \| `object` _*Required*_ | `undefined` | Defines the message to be shown to the user, either a string ex. `Some message` or `{ message: 'Some headline message', details: 'Detailed message would be shown on hovering the informer' }` |
|
|
688
|
+
| **`type`** | `string` | `info` | choses the type of the informer whether `info, warning or success` |
|
|
689
|
+
| **`timeout`** | `number` | `3000` | The duration which the message would still be shown for in milliseconds |
|
|
690
|
+
|
|
691
|
+
#### `scaleflexWidget.log(message, type)`
|
|
692
|
+
|
|
693
|
+
Logs a message in the [`logger`](#logger):
|
|
694
|
+
|
|
695
|
+
| Property | Type | Default | Description |
|
|
696
|
+
| ------------- | --------------------- | ----------- | ---------------------------------------------------------------------- |
|
|
697
|
+
| **`message`** | `string` _*Required*_ | `undefined` | the message would be logged/added/shown in the logger. |
|
|
698
|
+
| **`type`** | `string` | `debug` | the type of that logged message whether `debug/info, warning or error` |
|
|
699
|
+
|
|
700
|
+
## Events
|
|
701
|
+
|
|
702
|
+
The widget 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:
|
|
703
|
+
|
|
704
|
+
### `file-added`
|
|
705
|
+
|
|
706
|
+
Emitted when a file has been added to the selected files for uploading.
|
|
707
|
+
|
|
708
|
+
`params`:
|
|
709
|
+
|
|
710
|
+
- `file`: The file object whom thumbnail is generated.
|
|
711
|
+
|
|
712
|
+
example
|
|
713
|
+
|
|
714
|
+
```js
|
|
715
|
+
scaleflexWidget.on("file-added", (newFile) => {
|
|
716
|
+
console.log("The new file object which is added:", newFile);
|
|
717
|
+
});
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
### `file-removed`
|
|
721
|
+
|
|
722
|
+
Emitted when a file has been removed from the selected files for uploading.
|
|
723
|
+
|
|
724
|
+
`params`:
|
|
725
|
+
|
|
726
|
+
- `file`: The file object removed.
|
|
727
|
+
- `deletionReason`: The reason for deleting the file or from where the deletion has done might be provided or not.
|
|
728
|
+
|
|
729
|
+
example
|
|
730
|
+
|
|
731
|
+
```js
|
|
732
|
+
scaleflexWidget.on("file-removed", (removedFile, reason) => {
|
|
733
|
+
console.log(
|
|
734
|
+
`The file ${removedFile.name} is removed because ${reason}, file's object:`,
|
|
735
|
+
removedFile
|
|
736
|
+
);
|
|
737
|
+
});
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
### `upload`
|
|
741
|
+
|
|
742
|
+
Emitted on creating a new upload process.
|
|
743
|
+
|
|
744
|
+
`params`:
|
|
745
|
+
|
|
746
|
+
- `object`: An object contains both the uploading process id and the the files ids for files to be uploaded, ex. `{ id: uploadId, filesIds: fileIds, files }`.
|
|
747
|
+
|
|
748
|
+
example
|
|
749
|
+
|
|
750
|
+
```js
|
|
751
|
+
scaleflexWidget.on("upload", (uploadProcess) => {
|
|
752
|
+
console.log("Upload started with upload id: ", uploadProcess.id);
|
|
753
|
+
console.log("Contains the following file ids", uploadProcess.filesIds);
|
|
754
|
+
});
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
### `restriction-failed`
|
|
758
|
+
|
|
759
|
+
Emitted when the restriction checking is failed and there is a file doesn't meet the restrictions.
|
|
760
|
+
|
|
761
|
+
`params`:
|
|
762
|
+
|
|
763
|
+
- `file`: The file object that has failed the check.
|
|
764
|
+
- `error`: The error faced/fired during the check.
|
|
765
|
+
|
|
766
|
+
example
|
|
767
|
+
|
|
768
|
+
```js
|
|
769
|
+
scaleflexWidget.on("restriction-failed", (file, error) => {
|
|
770
|
+
console.log("Couldnt process the following file object", file);
|
|
771
|
+
console.log("As the following error fired:", error);
|
|
772
|
+
});
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
### `upload-started`
|
|
776
|
+
|
|
777
|
+
Emitted when upload is started.
|
|
778
|
+
|
|
779
|
+
`params`:
|
|
780
|
+
|
|
781
|
+
- `file`: The file object that started uploading.
|
|
782
|
+
- `started`: An object contains upload Id, ex. `{ uploadId: upload id assigned to current file }`.
|
|
783
|
+
|
|
784
|
+
### `upload-progress`
|
|
785
|
+
|
|
786
|
+
Emitted when there is a progress of some file uploading in the upload process.
|
|
787
|
+
|
|
788
|
+
`params`:
|
|
789
|
+
|
|
790
|
+
- `file`: The file object that has some progress in its uploading.
|
|
791
|
+
- `progress`: An object contains the progress of the file being uploaded, ex. `{ filerobot: plugin's instance, bytesFinished: 1500, bytesTotal: 3500, uploadId: upload id assigned to current file }`.
|
|
792
|
+
|
|
793
|
+
example
|
|
794
|
+
|
|
795
|
+
```js
|
|
796
|
+
scaleflexWidget.on("upload-progress", (file, progress) => {
|
|
797
|
+
console.log("The following file object progressed", file);
|
|
798
|
+
console.log("The progress object is as following", progress);
|
|
799
|
+
});
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
### `upload-success`
|
|
803
|
+
|
|
804
|
+
Emitted when a file is successfully uploaded.
|
|
805
|
+
|
|
806
|
+
`params`:
|
|
807
|
+
|
|
808
|
+
- `file`: The file object that has uploaded.
|
|
809
|
+
- `response`: The upload request response received.
|
|
810
|
+
- `options`: object that contains the uploadId
|
|
811
|
+
|
|
812
|
+
example
|
|
813
|
+
|
|
814
|
+
```js
|
|
815
|
+
scaleflexWidget.on("upload-success", (file, response, { uploadId }) => {
|
|
816
|
+
console.log(
|
|
817
|
+
`The ${file.name} with the object ${file} is uploaded ${uploadId} and the whole response`,
|
|
818
|
+
response
|
|
819
|
+
);
|
|
820
|
+
});
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
### `upload-error`
|
|
824
|
+
|
|
825
|
+
Emitted when a file faced some error/issue while uploading.
|
|
826
|
+
|
|
827
|
+
`params`:
|
|
828
|
+
|
|
829
|
+
- `file`: The file object which fired the error.
|
|
830
|
+
- `error`: object that contains error details, upload response and uploadId that was assigned to current file.
|
|
831
|
+
- `options`: object that contains the upload response and uploadId
|
|
832
|
+
|
|
833
|
+
example
|
|
834
|
+
|
|
835
|
+
```js
|
|
836
|
+
scaleflexWidget.on("upload-error", (file, error, { response, uploadId }) => {
|
|
837
|
+
console.log(
|
|
838
|
+
"File faced that error while uploading",
|
|
839
|
+
file,
|
|
840
|
+
error,
|
|
841
|
+
response,
|
|
842
|
+
uploadId
|
|
843
|
+
);
|
|
844
|
+
});
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
### `upload-retry`
|
|
848
|
+
|
|
849
|
+
Emitted on some file uploading is retried.
|
|
850
|
+
|
|
851
|
+
`params`:
|
|
852
|
+
|
|
853
|
+
- `fileId`: The id of the file which its upload process is retried.
|
|
854
|
+
|
|
855
|
+
example
|
|
856
|
+
|
|
857
|
+
```js
|
|
858
|
+
scaleflexWidget.on("upload-retry", (fileId) => {
|
|
859
|
+
console.log("The following file id is being re-uploaded:", fileId);
|
|
860
|
+
});
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
### `progress`
|
|
864
|
+
|
|
865
|
+
Emitted on having a progress of an upload process's total progress.
|
|
866
|
+
|
|
867
|
+
`params`:
|
|
868
|
+
|
|
869
|
+
- `totalProgress`: The total progress value of the current uploading process.
|
|
870
|
+
|
|
871
|
+
example
|
|
872
|
+
|
|
873
|
+
```js
|
|
874
|
+
scaleflexWidget.on("progress", (totalProgress) => {
|
|
875
|
+
console.log("The uploading total progress for now: ", totalProgress);
|
|
876
|
+
});
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
### `cancel-uploads`
|
|
880
|
+
|
|
881
|
+
Emitted when the whole upload process is canceled (all files uploading are canceled).
|
|
882
|
+
|
|
883
|
+
`params`: No params returned.
|
|
884
|
+
|
|
885
|
+
example
|
|
886
|
+
|
|
887
|
+
```js
|
|
888
|
+
scaleflexWidget.on("cancel-uploads", () => {
|
|
889
|
+
console.log("The upload is canceled");
|
|
890
|
+
});
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
### `complete`
|
|
894
|
+
|
|
895
|
+
Emitted when the whole upload process done and completed.
|
|
896
|
+
|
|
897
|
+
`params`:
|
|
898
|
+
|
|
899
|
+
- `completionObject`: An object contains the results of the completed upload process, ex. `{ failed: failedFiles, uploadId: ..., successful: uploadedFiles }`.
|
|
900
|
+
|
|
901
|
+
example
|
|
902
|
+
|
|
903
|
+
```js
|
|
904
|
+
scaleflexWidget.on("complete", ({ failed, uploadId, successful }) => {
|
|
905
|
+
console.log(
|
|
906
|
+
`The upload ${uploadId} is completed with following results success then failed files`,
|
|
907
|
+
successful,
|
|
908
|
+
failed
|
|
909
|
+
);
|
|
910
|
+
});
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
### `items-deleted`
|
|
914
|
+
|
|
915
|
+
Emitted when files/folders are deleted.
|
|
916
|
+
|
|
917
|
+
`params`:
|
|
918
|
+
|
|
919
|
+
- `detailsObject`: An object contains details of removed items, ex. `{ removedFolders: [...], removedFiles: [...] }`.
|
|
920
|
+
|
|
921
|
+
example
|
|
922
|
+
|
|
923
|
+
```js
|
|
924
|
+
scaleflexWidget.on("items-deleted", ({ removedFolders, removedFiles }) => {
|
|
925
|
+
console.log("Items deleted:");
|
|
926
|
+
console.log("Removed folders:", removedFolders);
|
|
927
|
+
console.log("Removed files:", removedFiles);
|
|
928
|
+
});
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
### `error`
|
|
932
|
+
|
|
933
|
+
Emitted when the whole upload process faced an error.
|
|
934
|
+
|
|
935
|
+
`params`:
|
|
936
|
+
|
|
937
|
+
- `filesIds`: files ids that have an error.
|
|
938
|
+
- `error`: The error shown of the uploading process.
|
|
939
|
+
- `uploadId`: The id of the errored uploading process.
|
|
940
|
+
|
|
941
|
+
example
|
|
942
|
+
|
|
943
|
+
```js
|
|
944
|
+
scaleflexWidget.on("error", (filesIds, error, { uploadId }) => {
|
|
945
|
+
console.log(
|
|
946
|
+
`The upload with id ${uploadId} faced this error while uploading`,
|
|
947
|
+
error
|
|
948
|
+
);
|
|
949
|
+
});
|
|
950
|
+
```
|
|
951
|
+
|
|
952
|
+
### `reset-progress`
|
|
953
|
+
|
|
954
|
+
Emitted when the upload's progress is reset to 0.
|
|
955
|
+
|
|
956
|
+
`params`: No params returned.
|
|
957
|
+
|
|
958
|
+
example
|
|
959
|
+
|
|
960
|
+
```js
|
|
961
|
+
scaleflexWidget.on("reset-progress", () => {
|
|
962
|
+
console.log("The progress is reset");
|
|
963
|
+
});
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
### `info-visible`
|
|
967
|
+
|
|
968
|
+
Emitted on showing an `info` message to the user.
|
|
969
|
+
|
|
970
|
+
`params`: No params returned.
|
|
971
|
+
|
|
972
|
+
example
|
|
973
|
+
|
|
974
|
+
```js
|
|
975
|
+
scaleflexWidget.on("info-visible", () => {
|
|
976
|
+
console.log("inFo message shown.");
|
|
977
|
+
});
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
### `info-hidden`
|
|
981
|
+
|
|
982
|
+
Emitted on hiding an `info` message that were shown to the user.
|
|
983
|
+
|
|
984
|
+
`params`: No params returned.
|
|
985
|
+
|
|
986
|
+
example
|
|
987
|
+
|
|
988
|
+
```js
|
|
989
|
+
scaleflexWidget.on("info-hidden", () => {
|
|
990
|
+
console.log("The progress is hidden.");
|
|
991
|
+
});
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
### `explorer:modal-open`
|
|
995
|
+
|
|
996
|
+
Emitted on opening the widget in a modal through the [explorer](../@scaleflex/widget-explorer) plugin.
|
|
997
|
+
|
|
998
|
+
`params`: No params returned.
|
|
999
|
+
|
|
1000
|
+
example
|
|
1001
|
+
|
|
1002
|
+
```js
|
|
1003
|
+
scaleflexWidget.on("explorer:modal-open", () => {
|
|
1004
|
+
console.log("The widget's explorer modal is opened .");
|
|
1005
|
+
});
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
### `explorer:modal-close`
|
|
1009
|
+
|
|
1010
|
+
Emitted on closing the widget's main modal.
|
|
1011
|
+
|
|
1012
|
+
`params`: No params returned.
|
|
1013
|
+
|
|
1014
|
+
example
|
|
1015
|
+
|
|
1016
|
+
```js
|
|
1017
|
+
scaleflexWidget.on("explorer:modal-close", () => {
|
|
1018
|
+
console.log("The widget's modal is closed.");
|
|
1019
|
+
});
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
### `export`
|
|
1023
|
+
|
|
1024
|
+
emitted when the user downloads a file.
|
|
1025
|
+
|
|
1026
|
+
`params`:
|
|
1027
|
+
|
|
1028
|
+
- `files`: An array of files checked/selected for exporting.
|
|
1029
|
+
- `popupExportSucessMsgFn`: A function if called will show exported successfully pop-up to the user.
|
|
1030
|
+
- `downloadFilesPackagedFn`: A function if called will download files (the files passed in the first argument if nothing passed then the files exported will be used) as ZIP and show download progress in widget (item's Uuid is used & must exists on backend's side -- NOT FULLY WORKING --).
|
|
1031
|
+
- `downloadFileFn`: A function if called will download one file (the file passed as first argument if nothing passed then the first file in exported files will be used) directly without packaging/zipping it and show download progress in widget (`file.url.download` link is used in download and fallbacks to `file.url.permalink`).
|
|
1032
|
+
|
|
1033
|
+
example
|
|
1034
|
+
|
|
1035
|
+
```js
|
|
1036
|
+
scaleflexWidget.on(
|
|
1037
|
+
"export",
|
|
1038
|
+
(files, popupExportSucessMsgFn, downloadFilesPackagedFn, downloadFileFn) => {
|
|
1039
|
+
console.log("The following files are chosen to be exported", files);
|
|
1040
|
+
popupExportSucessMsgFn(); // shows exported successfully message as pop-up.
|
|
1041
|
+
downloadFilesPackagedFn(files.slice(1).map(({ file }) => file)); // no need to pass file.slice(1) if u would download all exported files.
|
|
1042
|
+
const { file } = file[0];
|
|
1043
|
+
downloadFileFn({ ...file, url: { ...file.url, download: files[0].link } }); // no need to pass file[0] if u would download the first file of exported files.
|
|
1044
|
+
}
|
|
1045
|
+
);
|
|
1046
|
+
```
|
|
1047
|
+
|
|
1048
|
+
### `url-modified`
|
|
1049
|
+
|
|
1050
|
+
Emitted when the user uses the [image editor plugin](../@scaleflex/widget-image-editor) in cloudimage mode and changes the url.
|
|
1051
|
+
|
|
1052
|
+
`params`:
|
|
1053
|
+
|
|
1054
|
+
- `modifiedUrl`: The modified url for the image.
|
|
1055
|
+
- `designState`: The image editor's design state object.
|
|
1056
|
+
- `info`: the function that gives you possibility to show a [`@scaleflex/widget-informer`](../@scaleflex/widget-informer/#scaleflexwidgetinformer) message.
|
|
1057
|
+
|
|
1058
|
+
example
|
|
1059
|
+
|
|
1060
|
+
```
|
|
1061
|
+
scaleflexWidget.on('modified-url', (modifiedUrl, designState, info) => {
|
|
1062
|
+
console.log('The new url is', modifiedUrl)
|
|
1063
|
+
console.log('Image editor design state:', designState)
|
|
1064
|
+
info('Url has changed', 'success', 3000)
|
|
1065
|
+
})
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
<!-- Variables -->
|
|
1069
|
+
|
|
1070
|
+
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-core
|
|
1071
|
+
[license-url]: https://opensource.org/licenses/MIT
|
|
1072
|
+
[sfx-url]: https://www.scaleflex.com/
|
|
1073
|
+
[version-url-latest]: https://www.npmjs.com/package/@scaleflex/widget-core
|
|
1074
|
+
[version-url-stable]: https://www.npmjs.com/package/@scaleflex/widget-core/v/stable
|
|
1075
|
+
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-core
|
|
1076
|
+
[codeSandbox-url]: https://codesandbox.io/s/filerobot-widget-v3-c5l9th
|
|
1077
|
+
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
1078
|
+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
1079
|
+
[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
|
|
1080
|
+
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
1081
|
+
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
1082
|
+
[filerobot-version-latest]: https://img.shields.io/npm/v/@scaleflex/widget-core?label=latest&style=for-the-badge&logo=npm
|
|
1083
|
+
[filerobot-version-stable]: https://img.shields.io/npm/v/@scaleflex/widget-core/stable?label=stable&style=for-the-badge&logo=npm
|
|
1084
|
+
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-core?label=Version&style=for-the-badge&logo=npm
|
|
1085
|
+
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
|
1086
|
+
|
|
1087
|
+
## License
|
|
1088
|
+
|
|
1089
|
+
The Scaleflex Media Asset Widget (FMAW) is provided under the [MIT License](https://opensource.org/licenses/MIT)
|