@progress/kendo-spreadsheet-common 1.1.2-develop.1 → 1.1.2-develop.3

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/dist/index-esm.js CHANGED
@@ -25019,7 +25019,7 @@ class SaveAsCommand extends Command {
25019
25019
  exec() {
25020
25020
  let fileName = this.options.name + this.options.extension;
25021
25021
  if (this.options.extension === ".xlsx") {
25022
- this.options.workbook.saveAsExcel({
25022
+ return this.options.workbook.saveAsExcel({
25023
25023
  fileName: fileName
25024
25024
  });
25025
25025
  } else if (this.options.extension === ".pdf") {
@@ -25660,6 +25660,11 @@ async function loadSheets(items, workbook) {
25660
25660
  for (let i = 0; i < items.length; i++) {
25661
25661
  const ctx = items[i];
25662
25662
  let sheet = workbook.insertSheet(ctx.options);
25663
+
25664
+ if (!sheet) {
25665
+ continue;
25666
+ }
25667
+
25663
25668
  sheet.suspendChanges(true);
25664
25669
  await readSheet(ctx.zip, ctx.file, sheet, ctx.strings, ctx.styles);
25665
25670
  }
@@ -27447,29 +27452,47 @@ class Workbook extends Observable {
27447
27452
  });
27448
27453
  let count = ids.length;
27449
27454
  let images = count ? {} : null;
27455
+ const promises = [];
27456
+
27450
27457
  if (count) {
27451
27458
  ids.forEach(function(id) {
27452
27459
  let img = self._images[id];
27460
+
27453
27461
  if (img.blob) {
27454
- let reader = new FileReader();
27455
- reader.onload = function() {
27456
- images[id] = {
27457
- type: img.blob.type,
27458
- name: img.blob.name,
27459
- data: reader.result
27462
+ const promise = new Promise((resolve) => {
27463
+ let reader = new FileReader();
27464
+ reader.onload = function() {
27465
+ images[id] = {
27466
+ type: img.blob.type,
27467
+ name: img.blob.name,
27468
+ data: reader.result
27469
+ };
27470
+
27471
+ count--;
27472
+ resolve();
27460
27473
  };
27461
- next();
27462
- };
27463
- reader.readAsArrayBuffer(img.blob);
27474
+ reader.readAsArrayBuffer(img.blob);
27475
+ });
27476
+
27477
+ promises.push(promise);
27464
27478
  } else {
27465
- loadBinary(img.url, function(data, type) {
27466
- images[id] = { type: type, data: data };
27467
- next();
27479
+ const promise = new Promise((resolve) => {
27480
+ loadBinary(img.url, function(data, type) {
27481
+ images[id] = { type: type, data: data };
27482
+ count--;
27483
+ resolve();
27484
+ });
27468
27485
  });
27486
+ promises.push(promise);
27469
27487
  }
27470
27488
  });
27489
+
27490
+ return Promise.all(promises)
27491
+ .then(() => {
27492
+ return next();
27493
+ });
27471
27494
  } else {
27472
- next();
27495
+ return next();
27473
27496
  }
27474
27497
 
27475
27498
  function next() {
@@ -27477,13 +27500,20 @@ class Workbook extends Observable {
27477
27500
  data.images = images;
27478
27501
  let workbook = new options.Workbook(data);
27479
27502
  const promise = options.forceProxy ? workbook.toDataURL() : workbook.toBlob();
27480
- promise.then(blob => {
27503
+
27504
+ if (!options.saveAs) {
27505
+ return promise;
27506
+ }
27507
+
27508
+ return promise.then(blob => {
27481
27509
  options.saveAs(blob, data.fileName || options.fileName, {
27482
27510
  proxyURL: options.proxyURL,
27483
27511
  forceProxy: options.forceProxy
27484
27512
  });
27485
27513
  });
27486
27514
  }
27515
+
27516
+ return Promise.resolve();
27487
27517
  }
27488
27518
  }
27489
27519
 
@@ -28026,7 +28056,7 @@ class SpreadsheetWidget extends Widget {
28026
28056
  }
28027
28057
 
28028
28058
  saveAsExcel(options) {
28029
- this._workbook.saveAsExcel(options);
28059
+ return this._workbook.saveAsExcel(options);
28030
28060
  }
28031
28061
 
28032
28062
  draw(options, callback) {
@@ -28169,7 +28199,7 @@ class SpreadsheetWidget extends Widget {
28169
28199
  // kendo.ui.progress(this.element, e.toggle);
28170
28200
  }
28171
28201
 
28172
- _onContextMenu(e) {
28202
+ _onContextMenu(e) {
28173
28203
  this.trigger("contextmenu", e);
28174
28204
  }
28175
28205
 
package/dist/index.js CHANGED
@@ -25020,7 +25020,7 @@
25020
25020
  exec() {
25021
25021
  let fileName = this.options.name + this.options.extension;
25022
25022
  if (this.options.extension === ".xlsx") {
25023
- this.options.workbook.saveAsExcel({
25023
+ return this.options.workbook.saveAsExcel({
25024
25024
  fileName: fileName
25025
25025
  });
25026
25026
  } else if (this.options.extension === ".pdf") {
@@ -25661,6 +25661,11 @@
25661
25661
  for (let i = 0; i < items.length; i++) {
25662
25662
  const ctx = items[i];
25663
25663
  let sheet = workbook.insertSheet(ctx.options);
25664
+
25665
+ if (!sheet) {
25666
+ continue;
25667
+ }
25668
+
25664
25669
  sheet.suspendChanges(true);
25665
25670
  await readSheet(ctx.zip, ctx.file, sheet, ctx.strings, ctx.styles);
25666
25671
  }
@@ -27448,29 +27453,47 @@
27448
27453
  });
27449
27454
  let count = ids.length;
27450
27455
  let images = count ? {} : null;
27456
+ const promises = [];
27457
+
27451
27458
  if (count) {
27452
27459
  ids.forEach(function(id) {
27453
27460
  let img = self._images[id];
27461
+
27454
27462
  if (img.blob) {
27455
- let reader = new FileReader();
27456
- reader.onload = function() {
27457
- images[id] = {
27458
- type: img.blob.type,
27459
- name: img.blob.name,
27460
- data: reader.result
27463
+ const promise = new Promise((resolve) => {
27464
+ let reader = new FileReader();
27465
+ reader.onload = function() {
27466
+ images[id] = {
27467
+ type: img.blob.type,
27468
+ name: img.blob.name,
27469
+ data: reader.result
27470
+ };
27471
+
27472
+ count--;
27473
+ resolve();
27461
27474
  };
27462
- next();
27463
- };
27464
- reader.readAsArrayBuffer(img.blob);
27475
+ reader.readAsArrayBuffer(img.blob);
27476
+ });
27477
+
27478
+ promises.push(promise);
27465
27479
  } else {
27466
- loadBinary(img.url, function(data, type) {
27467
- images[id] = { type: type, data: data };
27468
- next();
27480
+ const promise = new Promise((resolve) => {
27481
+ loadBinary(img.url, function(data, type) {
27482
+ images[id] = { type: type, data: data };
27483
+ count--;
27484
+ resolve();
27485
+ });
27469
27486
  });
27487
+ promises.push(promise);
27470
27488
  }
27471
27489
  });
27490
+
27491
+ return Promise.all(promises)
27492
+ .then(() => {
27493
+ return next();
27494
+ });
27472
27495
  } else {
27473
- next();
27496
+ return next();
27474
27497
  }
27475
27498
 
27476
27499
  function next() {
@@ -27478,13 +27501,20 @@
27478
27501
  data.images = images;
27479
27502
  let workbook = new options.Workbook(data);
27480
27503
  const promise = options.forceProxy ? workbook.toDataURL() : workbook.toBlob();
27481
- promise.then(blob => {
27504
+
27505
+ if (!options.saveAs) {
27506
+ return promise;
27507
+ }
27508
+
27509
+ return promise.then(blob => {
27482
27510
  options.saveAs(blob, data.fileName || options.fileName, {
27483
27511
  proxyURL: options.proxyURL,
27484
27512
  forceProxy: options.forceProxy
27485
27513
  });
27486
27514
  });
27487
27515
  }
27516
+
27517
+ return Promise.resolve();
27488
27518
  }
27489
27519
  }
27490
27520
 
@@ -28027,7 +28057,7 @@
28027
28057
  }
28028
28058
 
28029
28059
  saveAsExcel(options) {
28030
- this._workbook.saveAsExcel(options);
28060
+ return this._workbook.saveAsExcel(options);
28031
28061
  }
28032
28062
 
28033
28063
  draw(options, callback) {
@@ -28170,7 +28200,7 @@
28170
28200
  // kendo.ui.progress(this.element, e.toggle);
28171
28201
  }
28172
28202
 
28173
- _onContextMenu(e) {
28203
+ _onContextMenu(e) {
28174
28204
  this.trigger("contextmenu", e);
28175
28205
  }
28176
28206
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-spreadsheet-common",
3
3
  "description": "Kendo UI platform-independent Spreadsheet library",
4
- "version": "1.1.2-develop.1",
4
+ "version": "1.1.2-develop.3",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],
package/src/index.d.ts CHANGED
@@ -754,7 +754,7 @@ export class SpreadsheetWidget {
754
754
  * Note: Calling this method may trigger the built-in popup blocker of the browser.
755
755
  * To avoid that, always call it as a response to an end-user action, for example, a button click.
756
756
  */
757
- saveAsExcel(options: any): void;
757
+ saveAsExcel(options: any): Promise<Blob | string>;
758
758
 
759
759
  /**
760
760
  * Gets or sets the active sheet.