@widgetic/editor 3.10.55 → 3.11.2

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.
@@ -1,189 +1,14 @@
1
- <Service ref:Uploads
2
- service="Uploads"
3
- on:update="_onUpdate(event)"
4
- on:complete="_onUploadComplete(event)"
5
- />
6
-
7
- <svg style="position: absolute; width: 0; height: 0; overflow: hidden" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
8
- <symbol id="icon-upload" viewBox="0 0 32 32">
9
- <title>upload</title>
10
- <path d="M30.038 19.938c-0.706 0-1.275 0.569-1.275 1.275v7.544h-25.525v-7.544c0-0.706-0.569-1.275-1.275-1.275s-1.275 0.569-1.275 1.275v8.825c0 0.706 0.569 1.275 1.275 1.275h28.075c0.706 0 1.275-0.569 1.275-1.275v-8.825c0-0.706-0.569-1.275-1.275-1.275z"></path>
11
- <path d="M9.137 10.625l5.588-5.581v16.194c0 0.706 0.569 1.275 1.275 1.275s1.275-0.569 1.275-1.275v-16.194l5.587 5.581c0.769 0.713 1.556 0.25 1.806 0 0.5-0.5 0.5-1.306 0-1.806l-7.769-7.756c-0.5-0.5-1.306-0.5-1.806 0l-7.756 7.756c-0.5 0.5-0.5 1.306 0 1.806 0.494 0.5 1.306 0.5 1.8 0z"></path>
12
- </symbol>
13
- <symbol id="icon-error" viewBox="0 0 21.9 21.9">
14
- <title>error</title>
15
- <path d="M14.1 11.3c-.2-.2-.2-.5 0-.7l7.5-7.5c.2-.2.3-.5.3-.7s-.1-.5-.3-.7L20.2.3c-.2-.2-.5-.3-.7-.3-.3 0-.5.1-.7.3l-7.5 7.5c-.2.2-.5.2-.7 0L3.1.3C2.9.1 2.6 0 2.4 0s-.5.1-.7.3L.3 1.7c-.2.2-.3.5-.3.7s.1.5.3.7l7.5 7.5c.2.2.2.5 0 .7L.3 18.8c-.2.2-.3.5-.3.7s.1.5.3.7l1.4 1.4c.2.2.5.3.7.3s.5-.1.7-.3l7.5-7.5c.2-.2.5-.2.7 0l7.5 7.5c.2.2.5.3.7.3s.5-.1.7-.3l1.4-1.4c.2-.2.3-.5.3-.7s-.1-.5-.3-.7l-7.5-7.5z" fill="#de2618"/>
16
- </symbol>
17
- </svg>
18
-
19
- {{#if !loading}}
20
- {{#if error}}
21
- <div class="error-panel">
22
- <h2 class="blogvio-browser-title">Failed to load uploaded files.</h2>
23
- <p>{{ error.message }}</p>
24
- <a href="#" on:click="refresh( event )">Click here to try again</a><br/>
25
- <span>or <a href="mailto:support@widgetic.com">contact support</a> if the error persists.</span>
26
- </div>
27
- {{else}}
28
- <div class="browser-nav">
29
- {{#if deleteMode}}
30
- <div class="browser-logout" data-tooltip-text="Permanently remove selected files from server (action cannot be undone)" data-tooltip-position="80% 3%" data-icon="✓" on:click="deleteSelected()"></div>
31
- <div class="browser-logout" data-tooltip-text="Cancel action" data-icon="x" on:click="set({ deleteMode: false, selectedForDeletion: [] })"></div>
32
- {{#if selectedForDeletion.length}}
33
- <span>{{selectedForDeletion.length}} files selected for removal</span>
34
- {{else}}
35
- <span>Select files to be removed from the server</span>
36
- {{/if}}
37
- {{else}}
38
- {{#if allowDelete}}
39
- <div class="browser-logout" data-tooltip-text="Permanently remove files from server" data-tooltip-position="80% 3%" data-icon="⏍" on:click="set({ deleteMode: true })"></div>
40
- {{/if}}
41
- {{#if allowClear}}
42
- <div class="browser-logout clear-content" data-tooltip-text="Clear Content" on:click="fire('clearContent')"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M490.667 85.333h-64v-64C426.667 9.551 417.115 0 405.333 0h-384C9.551 0 0 9.551 0 21.333V448c0 11.782 9.551 21.333 21.333 21.333h64v21.333c0 11.782 9.551 21.333 21.333 21.333h384c11.782 0 21.333-9.551 21.333-21.333v-384c.001-11.781-9.55-21.333-21.332-21.333zm-448 341.334v-384H384v42.667H106.667c-11.782 0-21.333 9.551-21.333 21.333v320H42.667zm426.666 42.666H128V128h341.333v341.333z"/><path d="M389.176 208.158c-8.331-8.331-21.839-8.331-30.17 0l-60.339 60.339-60.339-60.339c-8.331-8.331-21.839-8.331-30.17 0s-8.331 21.839 0 30.17l60.339 60.339-60.339 60.339c-8.331 8.331-8.331 21.839 0 30.17s21.839 8.331 30.17 0l60.339-60.339 60.339 60.339c8.331 8.331 21.839 8.331 30.17 0s8.331-21.839 0-30.17l-60.339-60.339 60.339-60.339c8.331-8.332 8.331-21.839 0-30.17z"/></svg></div>
43
- {{/if}}
44
- {{/if}}
45
- </div>
46
- <section class="{{ dragging ? 'dropzone--dragging' : '' }}">
47
-
48
- <!-- Uploaded Content List -->
49
- {{#if files.length}}
50
- <ScrollPane ref:scrollPane class="content-list">
51
- {{#each files as file}}
52
- <File
53
- file="{{file}}"
54
- on:select="toggle( event )"
55
- selected="{{ isSelected(file.id, deleteMode, selected, selectedForDeletion) }}"
56
- selectedIcon="{{ deleteMode ? 'delete' : 'check' }}">
57
- </File>
58
- {{/each}}
59
- </ScrollPane>
60
- {{else}}
61
- <div class="error-panel" style="height: 100%">
62
- <h2 class="blogvio-browser-title">Hey there!</h2>
63
- <h3>You haven't uploaded any {{ filetypes }} files yet.</h3>
64
- <span>Drag some over or click below!</span>
65
- </div>
66
- {{/if}}
67
-
68
- <!-- Dropzone -->
69
- <div class="dropzone_plchldr {{ !files.length ? 'dropzone--large' : '' }}">
70
- <Dropzone
71
- ref:dropzone
72
- on:new="_onDropZoneNewUpload(event)"
73
- on:upload="_onDropZoneUpload( event )"
74
- on:dragging="set({ dragging: event })"
75
- on:error="fire( 'error', event )"
76
- filetypes="{{ filetypes }}/*"
77
- maxFilesize="{{ maxFilesize }}"
78
- instanceId="{{ instanceId }}"
79
- ></Dropzone>
80
- </div>
81
- </section>
82
- {{/if}}
83
- {{/if}}
84
-
85
- <style>
86
- section {
87
- display: flex;
88
- flex-direction: column;
89
- padding-left: 20px;
90
- height: calc(100% - 25px);
91
- color: #665b68;
92
- }
93
-
94
- a:focus {
95
- outline: none;
96
- }
97
-
98
- .error-panel {
99
- position: relative;
100
- top: 50%;
101
- transform: translateY(-50%);
102
- text-align: center;
103
- padding-right: 20px;
104
- }
105
-
106
- .browser-nav {
107
- position: static;
108
-
109
- font-family: ProximaNova-Regular;
110
- font-size: 16px;
111
- color: #0055FF;
112
- }
113
-
114
- .blogvio-browser-title {
115
- margin-top: 0;
116
- font: 30px/60px "ProximaNova-Regular";
117
- color: #0055FF;
118
- }
119
-
120
- .nano {
121
- flex: 1;
122
- }
123
-
124
- strong {
125
- color: #0055FF;
126
- }
127
-
128
- .dropzone_plchldr {
129
- position: relative;
130
- margin: 20px 20px 20px 0;
131
- height: 75px;
132
- }
133
-
134
- .dropzone {
135
- position: absolute;
136
- top: 0;
137
- left: 0;
138
- right: 0;
139
- bottom: 0;
140
- }
141
-
142
- .scrolling-container {
143
- transition: opacity 200ms ease-in;
144
- }
145
-
146
- .dropzone--dragging .scrolling-container {
147
- opacity: 0.4;
148
- }
149
-
150
- .dropzone--dragging .dropzone {
151
- top: -100px;
152
- }
153
-
154
- .dropzone--large .dropzone,
155
- .dropzone--dragging .dropzone--large .dropzone {
156
- top: -200px;
157
- }
158
-
159
- .icon {
160
- display: inline-block;
161
- width: 1em;
162
- height: 1em;
163
- stroke-width: 0;
164
- stroke: currentColor;
165
- fill: currentColor
166
- }
167
-
168
- .clear-content svg {
169
- width: 14px;
170
- fill: #a0a0a0;
171
- position: relative;
172
- top: 1px;
173
- right: 2px;
174
- }
175
-
176
- .clear-content:hover svg {
177
- fill: #665b68;
178
- }
179
- </style>
180
-
181
1
  <script>
182
2
  import Dropzone from './dropzone.html';
183
3
  import ScrollPane from './scroll-pane.html';
184
4
  import File from './file.html';
185
5
  import Service from './service.html'; // actually imports services/uploads.js
186
6
 
7
+ // Third party libraries imports
8
+ import * as tus from 'tus-js-client';
9
+
10
+ const parseType = type => type.indexOf('/') > 0 ? type.slice(0, type.indexOf('/')) : type;
11
+
187
12
  let instanceId = 0;
188
13
 
189
14
  export default {
@@ -200,9 +25,9 @@ export default {
200
25
  deleteMode: false,
201
26
  selected: [],
202
27
  selectedForDeletion: [],
203
- maxFilesize: 10,
204
28
  allowDelete: true,
205
29
  allowClear: true,
30
+ uploadProgress: 0, // Upload Progress percentage
206
31
  };
207
32
  },
208
33
 
@@ -215,8 +40,14 @@ export default {
215
40
  },
216
41
 
217
42
  oncreate() {
43
+ // create a reference to the Uploads service
218
44
  this.Uploads = this.refs.Uploads.instance();
45
+
46
+ // read the max file size from the Uploads service
219
47
  this.set({ maxFilesize: this.Uploads.getMaxFileSize() });
48
+
49
+ // read the chunkSize from the Uploads service
50
+ this.set({ chunkSize: this.Uploads.getChunkSize() });
220
51
 
221
52
  // load uploaded files
222
53
  this.refresh();
@@ -337,9 +168,7 @@ export default {
337
168
  this.set({ deleteMode: false, selectedForDeletion: [] });
338
169
  },
339
170
 
340
- /**
341
- * options { afterUpload: boolean }
342
- */
171
+ /*** options { afterUpload: boolean } */
343
172
  _toggleSelect(file, options) {
344
173
  this.fire('toggle', { file, options });
345
174
  },
@@ -375,11 +204,11 @@ export default {
375
204
  },
376
205
 
377
206
  /**
378
- * DROPZONE HANDLERS
207
+ * UPLOAD DROPZONE HANDLERS
379
208
  */
380
209
 
381
- _onDropZoneNewUpload(event) {
382
- // console.log("on DropZone New Upload:", event);
210
+ _onDropZoneUploadStart(event) {
211
+ // console.log("Editor Dropzone onUploadStart:", event);
383
212
 
384
213
  // scroll the list to the bottom
385
214
  this.scrollToListBottom();
@@ -391,31 +220,223 @@ export default {
391
220
  this.refs.scrollPane && this.refs.scrollPane.scrollBottom();
392
221
  },
393
222
 
394
- _onDropZoneUpload(event) {
395
- // console.log("on DropZone Upload:", event);
223
+ _onDropZoneUploadToggle(event) {
224
+ console.log("Editor DropZone Upload Toggle:", event);
225
+
396
226
  this.toggle( event );
397
227
  },
398
228
 
399
229
  /**
400
- * BROWSER HANDLERS
230
+ * UPLOAD SERVICE HANDLERS
401
231
  */
402
232
 
403
- _onUpdate(event) {
404
- // console.log("on Update Content:", event);
233
+ _onUploadsUpdate(event) {
234
+ // console.log("Editor Upload Service onUploadsUpdate:", event);
405
235
 
406
- // re-load uploaded files
236
+ // refresh uploaded files list
407
237
  this.refresh();
408
238
  },
409
239
 
410
240
  _onUploadComplete([file, instanceId]) {
411
- // console.log("on Upload Complete:", file, instanceId);
241
+ // console.log("Editor Upload Service Complete:", file, instanceId);
412
242
 
413
243
  // toggle the file only if it's upload originated from this instance
414
244
  if (instanceId === this.get('instanceId')) this._toggleSelect(file, { afterUpload: true });
415
245
 
416
- // reload files by upload date
246
+ // reload list of files
417
247
  // this.refresh();
418
248
  },
419
249
  },
420
250
  };
421
251
  </script>
252
+
253
+
254
+ <Service ref:Uploads
255
+ service="Uploads"
256
+ on:update="_onUploadsUpdate(event)"
257
+ on:complete="_onUploadComplete(event)"
258
+ />
259
+
260
+ <svg style="position: absolute; width: 0; height: 0; overflow: hidden" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
261
+ <symbol id="icon-upload" viewBox="0 0 32 32">
262
+ <title>upload</title>
263
+ <path d="M30.038 19.938c-0.706 0-1.275 0.569-1.275 1.275v7.544h-25.525v-7.544c0-0.706-0.569-1.275-1.275-1.275s-1.275 0.569-1.275 1.275v8.825c0 0.706 0.569 1.275 1.275 1.275h28.075c0.706 0 1.275-0.569 1.275-1.275v-8.825c0-0.706-0.569-1.275-1.275-1.275z"></path>
264
+ <path d="M9.137 10.625l5.588-5.581v16.194c0 0.706 0.569 1.275 1.275 1.275s1.275-0.569 1.275-1.275v-16.194l5.587 5.581c0.769 0.713 1.556 0.25 1.806 0 0.5-0.5 0.5-1.306 0-1.806l-7.769-7.756c-0.5-0.5-1.306-0.5-1.806 0l-7.756 7.756c-0.5 0.5-0.5 1.306 0 1.806 0.494 0.5 1.306 0.5 1.8 0z"></path>
265
+ </symbol>
266
+ <symbol id="icon-error" viewBox="0 0 21.9 21.9">
267
+ <title>error</title>
268
+ <path d="M14.1 11.3c-.2-.2-.2-.5 0-.7l7.5-7.5c.2-.2.3-.5.3-.7s-.1-.5-.3-.7L20.2.3c-.2-.2-.5-.3-.7-.3-.3 0-.5.1-.7.3l-7.5 7.5c-.2.2-.5.2-.7 0L3.1.3C2.9.1 2.6 0 2.4 0s-.5.1-.7.3L.3 1.7c-.2.2-.3.5-.3.7s.1.5.3.7l7.5 7.5c.2.2.2.5 0 .7L.3 18.8c-.2.2-.3.5-.3.7s.1.5.3.7l1.4 1.4c.2.2.5.3.7.3s.5-.1.7-.3l7.5-7.5c.2-.2.5-.2.7 0l7.5 7.5c.2.2.5.3.7.3s.5-.1.7-.3l1.4-1.4c.2-.2.3-.5.3-.7s-.1-.5-.3-.7l-7.5-7.5z" fill="#de2618"/>
269
+ </symbol>
270
+ </svg>
271
+
272
+ {{#if !loading}}
273
+ {{#if error}}
274
+ <div class="error-panel">
275
+ <h2 class="blogvio-browser-title">Failed to load uploaded files.</h2>
276
+ <p>{{ error.message }}</p>
277
+ <a href="#" on:click="refresh( event )">Click here to try again</a><br/>
278
+ <span>or <a href="mailto:support@widgetic.com">contact support</a> if the error persists.</span>
279
+ </div>
280
+ {{else}}
281
+ <div class="browser-nav">
282
+ {{#if deleteMode}}
283
+ <div class="browser-logout" data-tooltip-text="Permanently remove selected files from server (action cannot be undone)" data-tooltip-position="80% 3%" data-icon="✓" on:click="deleteSelected()"></div>
284
+ <div class="browser-logout" data-tooltip-text="Cancel action" data-icon="x" on:click="set({ deleteMode: false, selectedForDeletion: [] })"></div>
285
+ {{#if selectedForDeletion.length}}
286
+ <span>{{selectedForDeletion.length}} files selected for removal</span>
287
+ {{else}}
288
+ <span>Select files to be removed from the server</span>
289
+ {{/if}}
290
+ {{else}}
291
+ {{#if allowDelete}}
292
+ <div class="browser-logout" data-tooltip-text="Permanently remove files from server" data-tooltip-position="80% 3%" data-icon="⏍" on:click="set({ deleteMode: true })"></div>
293
+ {{/if}}
294
+ {{#if allowClear}}
295
+ <div class="browser-logout clear-content" data-tooltip-text="Clear Content" on:click="fire('clearContent')"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M490.667 85.333h-64v-64C426.667 9.551 417.115 0 405.333 0h-384C9.551 0 0 9.551 0 21.333V448c0 11.782 9.551 21.333 21.333 21.333h64v21.333c0 11.782 9.551 21.333 21.333 21.333h384c11.782 0 21.333-9.551 21.333-21.333v-384c.001-11.781-9.55-21.333-21.332-21.333zm-448 341.334v-384H384v42.667H106.667c-11.782 0-21.333 9.551-21.333 21.333v320H42.667zm426.666 42.666H128V128h341.333v341.333z"/><path d="M389.176 208.158c-8.331-8.331-21.839-8.331-30.17 0l-60.339 60.339-60.339-60.339c-8.331-8.331-21.839-8.331-30.17 0s-8.331 21.839 0 30.17l60.339 60.339-60.339 60.339c-8.331 8.331-8.331 21.839 0 30.17s21.839 8.331 30.17 0l60.339-60.339 60.339 60.339c8.331 8.331 21.839 8.331 30.17 0s8.331-21.839 0-30.17l-60.339-60.339 60.339-60.339c8.331-8.332 8.331-21.839 0-30.17z"/></svg></div>
296
+ {{/if}}
297
+ {{/if}}
298
+ </div>
299
+ <section class="{{ dragging ? 'dropzone--dragging' : '' }}">
300
+
301
+ <!-- Uploaded Content List -->
302
+ {{#if files.length}}
303
+ <ScrollPane ref:scrollPane class="content-list">
304
+ {{#each files as file}}
305
+ <File
306
+ file="{{file}}"
307
+ on:select="toggle( event )"
308
+ selected="{{ isSelected(file.id, deleteMode, selected, selectedForDeletion) }}"
309
+ selectedIcon="{{ deleteMode ? 'delete' : 'check' }}">
310
+ </File>
311
+ {{/each}}
312
+ </ScrollPane>
313
+ {{else}}
314
+ <div class="error-panel" style="height: 100%">
315
+ <h2 class="blogvio-browser-title">Hey there!</h2>
316
+ <h3>You haven't uploaded any {{ filetypes }} files yet.</h3>
317
+ <span>Drag some over or click below!</span>
318
+ </div>
319
+ {{/if}}
320
+
321
+
322
+ <!-- Dropzone Holder -->
323
+ <div class="dropzone_plchldr {{ !files.length ? 'dropzone--large' : '' }}">
324
+
325
+ <!-- Dropzone Component -->
326
+ <Dropzone
327
+ ref:dropzone
328
+ on:new="_onDropZoneUploadStart(event)"
329
+ on:upload="_onDropZoneUploadToggle( event )"
330
+ on:dragging="set({ dragging: event })"
331
+ on:error="fire( 'error', event )"
332
+ filetypes="{{ filetypes }}/*"
333
+ maxFilesize="{{ maxFilesize }}"
334
+ chunkSize="{{ chunkSize }}"
335
+ instanceId="{{ instanceId }}"
336
+ ></Dropzone>
337
+
338
+ </div>
339
+
340
+
341
+ </section>
342
+ {{/if}}
343
+ {{/if}}
344
+
345
+ <style>
346
+ section {
347
+ display: flex;
348
+ flex-direction: column;
349
+ padding-left: 20px;
350
+ height: calc(100% - 25px);
351
+ color: #665b68;
352
+ }
353
+
354
+ a:focus {
355
+ outline: none;
356
+ }
357
+
358
+ .error-panel {
359
+ position: relative;
360
+ top: 50%;
361
+ transform: translateY(-50%);
362
+ text-align: center;
363
+ padding-right: 20px;
364
+ }
365
+
366
+ .browser-nav {
367
+ position: static;
368
+
369
+ font-family: ProximaNova-Regular;
370
+ font-size: 16px;
371
+ color: #0055FF;
372
+ }
373
+
374
+ .blogvio-browser-title {
375
+ margin-top: 0;
376
+ font: 30px/60px "ProximaNova-Regular";
377
+ color: #0055FF;
378
+ }
379
+
380
+ .nano {
381
+ flex: 1;
382
+ }
383
+
384
+ strong {
385
+ color: #0055FF;
386
+ }
387
+
388
+ .dropzone_plchldr {
389
+ position: relative;
390
+ margin: 20px 20px 20px 0;
391
+ height: 75px;
392
+ }
393
+
394
+ .dropzone {
395
+ position: absolute;
396
+ top: 0;
397
+ left: 0;
398
+ right: 0;
399
+ bottom: 22px;
400
+ }
401
+ .upload-input {
402
+
403
+ }
404
+
405
+ .scrolling-container {
406
+ transition: opacity 200ms ease-in;
407
+ }
408
+
409
+ .dropzone--dragging .scrolling-container {
410
+ opacity: 0.4;
411
+ }
412
+
413
+ .dropzone--dragging .dropzone {
414
+ top: -100px;
415
+ }
416
+
417
+ .dropzone--large .dropzone,
418
+ .dropzone--dragging .dropzone--large .dropzone {
419
+ top: -200px;
420
+ }
421
+
422
+ .icon {
423
+ display: inline-block;
424
+ width: 1em;
425
+ height: 1em;
426
+ stroke-width: 0;
427
+ stroke: currentColor;
428
+ fill: currentColor
429
+ }
430
+
431
+ .clear-content svg {
432
+ width: 14px;
433
+ fill: #a0a0a0;
434
+ position: relative;
435
+ top: 1px;
436
+ right: 2px;
437
+ }
438
+
439
+ .clear-content:hover svg {
440
+ fill: #665b68;
441
+ }
442
+ </style>