@progress/kendo-spreadsheet-common 1.0.0-develop.6 → 1.0.0-develop.7

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
@@ -22118,8 +22118,10 @@ class FormulaInput extends Widget {
22118
22118
  if (width > element.offsetWidth) {
22119
22119
  element.style.width = width + 'px';
22120
22120
  }
22121
- if (height > element.offsetHeight) {
22122
- element.style.height = height + 'px';
22121
+
22122
+ const activeCellOutlineWidth = 1;
22123
+ if (height - activeCellOutlineWidth > element.offsetHeight) {
22124
+ element.style.height = (height - activeCellOutlineWidth) + 'px';
22123
22125
  }
22124
22126
 
22125
22127
  this._sync();
@@ -26050,7 +26052,7 @@ async function readDrawings(zip, file, sheet) {
26050
26052
  let relationships = await readRelationships(zip, relsFile);
26051
26053
 
26052
26054
  if (relationships.byType.image) {
26053
- await Object.keys(relationships.byId).forEach(async function(id) {
26055
+ for (const id of Object.keys(relationships.byId)) {
26054
26056
  let img = relative_file(file, relationships.byId[id]);
26055
26057
  let type = getContentType(img);
26056
26058
 
@@ -26062,7 +26064,7 @@ async function readDrawings(zip, file, sheet) {
26062
26064
  : new window.Blob([ data ], { type: type });
26063
26065
  relationships.byId[id] = sheet._workbook.addImage(blob);
26064
26066
  }
26065
- });
26067
+ }
26066
26068
  }
26067
26069
 
26068
26070
  let cdr, ref, width, height;
@@ -26757,7 +26759,7 @@ function excelToPixels(val) {
26757
26759
  return val / 9525;
26758
26760
  }
26759
26761
 
26760
- /* eslint-disable no-nested-ternary */
26762
+ /* eslint-disable no-undef */
26761
26763
 
26762
26764
  const events$1 = [
26763
26765
  "cut",
@@ -27263,33 +27265,33 @@ class Workbook extends Observable {
27263
27265
  this._imgID = 0;
27264
27266
  }
27265
27267
 
27266
- // _loadImages() {
27267
- // let self = this;
27268
- // let ids = Object.keys(self._images);
27269
- // let count = ids.length;
27270
- // if (count) {
27271
- // ids.forEach(function(id){
27272
- // let img = self._images[id];
27273
- // if (!img.blob) {
27274
- // loadBinary(img.url, function(data, type) {
27275
- // // XXX: can we do something better in case of error?
27276
- // if (data != null) {
27277
- // img.blob = new Blob([ data ], { type: type });
27278
- // delete img.url;
27279
- // }
27280
- // next();
27281
- // });
27282
- // }
27283
- // });
27284
- // } else {
27285
- // next();
27286
- // }
27287
- // function next() {
27288
- // if (--count <= 0) {
27289
- // self.activeSheet().triggerChange({ layout: true });
27290
- // }
27291
- // }
27292
- // },
27268
+ _loadImages() {
27269
+ let self = this;
27270
+ let ids = Object.keys(self._images);
27271
+ let count = ids.length;
27272
+ if (count) {
27273
+ ids.forEach(function(id){
27274
+ let img = self._images[id];
27275
+ if (!img.blob) {
27276
+ loadBinary(img.url, function(data, type) {
27277
+ // XXX: can we do something better in case of error?
27278
+ if (data != null) {
27279
+ img.blob = new Blob([ data ], { type: type });
27280
+ delete img.url;
27281
+ }
27282
+ next();
27283
+ });
27284
+ }
27285
+ });
27286
+ } else {
27287
+ next();
27288
+ }
27289
+ function next() {
27290
+ if (--count <= 0) {
27291
+ self.activeSheet().triggerChange({ layout: true });
27292
+ }
27293
+ }
27294
+ }
27293
27295
 
27294
27296
  fromJSON(json) {
27295
27297
  if (json.sheets) {
@@ -27307,7 +27309,7 @@ class Workbook extends Observable {
27307
27309
  }
27308
27310
  this._images[id] = { url: json.images[id] };
27309
27311
  }, this);
27310
- // this._loadImages();
27312
+ this._loadImages();
27311
27313
  }
27312
27314
 
27313
27315
  for (let idx = 0; idx < json.sheets.length; idx++) {
@@ -27374,47 +27376,42 @@ class Workbook extends Observable {
27374
27376
  return sheet.toJSON();
27375
27377
  }, this),
27376
27378
  names: names,
27379
+ images: {},
27377
27380
  columnWidth: this.options.columnWidth,
27378
27381
  rowHeight: this.options.rowHeight
27379
27382
  };
27380
27383
  }
27381
27384
 
27382
27385
  saveJSON() {
27383
- // PoC only
27384
- window.console.log('`saveJSON` function not implemented');
27385
- // let self = this;
27386
- // let deferred = new $.Deferred();
27387
- // let data = self.toJSON();
27388
- // let ids = Object.keys(self._images).filter(function(id) {
27389
- // return self.usesImage(id) === 1;
27390
- // });
27391
- // let count = ids.length;
27392
- // data.images = {};
27393
- // if (count) {
27394
- // ids.forEach(function(id) {
27395
- // let img = self._images[id];
27396
- // if (img.blob) {
27397
- // let reader = new FileReader();
27398
- // reader.onload = function() {
27399
- // data.images[id] = reader.result;
27400
- // next();
27401
- // };
27402
- // reader.readAsDataURL(img.blob);
27403
- // } else {
27404
- // data.images[id] = img.url;
27405
- // next();
27406
- // }
27407
- // });
27408
- // } else {
27409
- // next();
27410
- // }
27411
- // return deferred.promise();
27386
+ let self = this;
27387
+ let data = self.toJSON();
27388
+ let ids = Object.keys(self._images).filter(function(id) {
27389
+ return self.usesImage(id) === 1;
27390
+ });
27391
+ let count = ids.length;
27412
27392
 
27413
- // function next() {
27414
- // if (--count <= 0) {
27415
- // deferred.resolve(data);
27416
- // }
27417
- // }
27393
+ const promises = [];
27394
+
27395
+ if (count) {
27396
+ ids.forEach(function(id) {
27397
+ let img = self._images[id];
27398
+ if (img.blob) {
27399
+ const promise = new Promise((resolve) => {
27400
+ let reader = new FileReader();
27401
+ reader.onload = function() {
27402
+ data.images[id] = reader.result;
27403
+ resolve();
27404
+ };
27405
+ reader.readAsDataURL(img.blob);
27406
+ });
27407
+ promises.push(promise);
27408
+ } else {
27409
+ data.images[id] = img.url;
27410
+ }
27411
+ });
27412
+ }
27413
+
27414
+ return Promise.all(promises).then(() => data);
27418
27415
  }
27419
27416
 
27420
27417
  fromFile(file) {
package/dist/index.js CHANGED
@@ -22119,8 +22119,10 @@
22119
22119
  if (width > element.offsetWidth) {
22120
22120
  element.style.width = width + 'px';
22121
22121
  }
22122
- if (height > element.offsetHeight) {
22123
- element.style.height = height + 'px';
22122
+
22123
+ const activeCellOutlineWidth = 1;
22124
+ if (height - activeCellOutlineWidth > element.offsetHeight) {
22125
+ element.style.height = (height - activeCellOutlineWidth) + 'px';
22124
22126
  }
22125
22127
 
22126
22128
  this._sync();
@@ -26051,7 +26053,7 @@
26051
26053
  let relationships = await readRelationships(zip, relsFile);
26052
26054
 
26053
26055
  if (relationships.byType.image) {
26054
- await Object.keys(relationships.byId).forEach(async function(id) {
26056
+ for (const id of Object.keys(relationships.byId)) {
26055
26057
  let img = relative_file(file, relationships.byId[id]);
26056
26058
  let type = getContentType(img);
26057
26059
 
@@ -26063,7 +26065,7 @@
26063
26065
  : new window.Blob([ data ], { type: type });
26064
26066
  relationships.byId[id] = sheet._workbook.addImage(blob);
26065
26067
  }
26066
- });
26068
+ }
26067
26069
  }
26068
26070
 
26069
26071
  let cdr, ref, width, height;
@@ -26758,7 +26760,7 @@
26758
26760
  return val / 9525;
26759
26761
  }
26760
26762
 
26761
- /* eslint-disable no-nested-ternary */
26763
+ /* eslint-disable no-undef */
26762
26764
 
26763
26765
  const events$1 = [
26764
26766
  "cut",
@@ -27264,33 +27266,33 @@
27264
27266
  this._imgID = 0;
27265
27267
  }
27266
27268
 
27267
- // _loadImages() {
27268
- // let self = this;
27269
- // let ids = Object.keys(self._images);
27270
- // let count = ids.length;
27271
- // if (count) {
27272
- // ids.forEach(function(id){
27273
- // let img = self._images[id];
27274
- // if (!img.blob) {
27275
- // loadBinary(img.url, function(data, type) {
27276
- // // XXX: can we do something better in case of error?
27277
- // if (data != null) {
27278
- // img.blob = new Blob([ data ], { type: type });
27279
- // delete img.url;
27280
- // }
27281
- // next();
27282
- // });
27283
- // }
27284
- // });
27285
- // } else {
27286
- // next();
27287
- // }
27288
- // function next() {
27289
- // if (--count <= 0) {
27290
- // self.activeSheet().triggerChange({ layout: true });
27291
- // }
27292
- // }
27293
- // },
27269
+ _loadImages() {
27270
+ let self = this;
27271
+ let ids = Object.keys(self._images);
27272
+ let count = ids.length;
27273
+ if (count) {
27274
+ ids.forEach(function(id){
27275
+ let img = self._images[id];
27276
+ if (!img.blob) {
27277
+ loadBinary(img.url, function(data, type) {
27278
+ // XXX: can we do something better in case of error?
27279
+ if (data != null) {
27280
+ img.blob = new Blob([ data ], { type: type });
27281
+ delete img.url;
27282
+ }
27283
+ next();
27284
+ });
27285
+ }
27286
+ });
27287
+ } else {
27288
+ next();
27289
+ }
27290
+ function next() {
27291
+ if (--count <= 0) {
27292
+ self.activeSheet().triggerChange({ layout: true });
27293
+ }
27294
+ }
27295
+ }
27294
27296
 
27295
27297
  fromJSON(json) {
27296
27298
  if (json.sheets) {
@@ -27308,7 +27310,7 @@
27308
27310
  }
27309
27311
  this._images[id] = { url: json.images[id] };
27310
27312
  }, this);
27311
- // this._loadImages();
27313
+ this._loadImages();
27312
27314
  }
27313
27315
 
27314
27316
  for (let idx = 0; idx < json.sheets.length; idx++) {
@@ -27375,47 +27377,42 @@
27375
27377
  return sheet.toJSON();
27376
27378
  }, this),
27377
27379
  names: names,
27380
+ images: {},
27378
27381
  columnWidth: this.options.columnWidth,
27379
27382
  rowHeight: this.options.rowHeight
27380
27383
  };
27381
27384
  }
27382
27385
 
27383
27386
  saveJSON() {
27384
- // PoC only
27385
- window.console.log('`saveJSON` function not implemented');
27386
- // let self = this;
27387
- // let deferred = new $.Deferred();
27388
- // let data = self.toJSON();
27389
- // let ids = Object.keys(self._images).filter(function(id) {
27390
- // return self.usesImage(id) === 1;
27391
- // });
27392
- // let count = ids.length;
27393
- // data.images = {};
27394
- // if (count) {
27395
- // ids.forEach(function(id) {
27396
- // let img = self._images[id];
27397
- // if (img.blob) {
27398
- // let reader = new FileReader();
27399
- // reader.onload = function() {
27400
- // data.images[id] = reader.result;
27401
- // next();
27402
- // };
27403
- // reader.readAsDataURL(img.blob);
27404
- // } else {
27405
- // data.images[id] = img.url;
27406
- // next();
27407
- // }
27408
- // });
27409
- // } else {
27410
- // next();
27411
- // }
27412
- // return deferred.promise();
27387
+ let self = this;
27388
+ let data = self.toJSON();
27389
+ let ids = Object.keys(self._images).filter(function(id) {
27390
+ return self.usesImage(id) === 1;
27391
+ });
27392
+ let count = ids.length;
27413
27393
 
27414
- // function next() {
27415
- // if (--count <= 0) {
27416
- // deferred.resolve(data);
27417
- // }
27418
- // }
27394
+ const promises = [];
27395
+
27396
+ if (count) {
27397
+ ids.forEach(function(id) {
27398
+ let img = self._images[id];
27399
+ if (img.blob) {
27400
+ const promise = new Promise((resolve) => {
27401
+ let reader = new FileReader();
27402
+ reader.onload = function() {
27403
+ data.images[id] = reader.result;
27404
+ resolve();
27405
+ };
27406
+ reader.readAsDataURL(img.blob);
27407
+ });
27408
+ promises.push(promise);
27409
+ } else {
27410
+ data.images[id] = img.url;
27411
+ }
27412
+ });
27413
+ }
27414
+
27415
+ return Promise.all(promises).then(() => data);
27419
27416
  }
27420
27417
 
27421
27418
  fromFile(file) {
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.0.0-develop.6",
4
+ "version": "1.0.0-develop.7",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],
package/src/index.d.ts CHANGED
@@ -395,6 +395,12 @@ export class Spreadsheet {
395
395
  */
396
396
  toJSON(): DocumentDescriptor;
397
397
 
398
+ /**
399
+ * Serializes the workbook. This method does not return the JSON, but a Promise object which will yield the JSON data when it is available.
400
+ * The method is functionally similar to `toJSON`, but it is also able to save the embedded images (this is the reason why it must be asynchronous).
401
+ */
402
+ saveJSON(): Promise<DocumentDescriptor>;
403
+
398
404
  /**
399
405
  * Clears the Spreadsheet and populates it with data from the specified Excel (.xlsx) file.
400
406
  *