@pobuca/email-builder 1.2.0 → 1.2.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.
@@ -816,7 +816,7 @@
816
816
  }());
817
817
  var ImageBlock = /** @class */ (function () {
818
818
  function ImageBlock(src, options, state) {
819
- if (src === void 0) { src = 'assets/placeholders/small-image.svg'; }
819
+ if (src === void 0) { src = ''; }
820
820
  if (state === void 0) { state = {
821
821
  disabled: false,
822
822
  message: ''
@@ -903,6 +903,7 @@
903
903
  units: ['px']
904
904
  },
905
905
  align: 'center',
906
+ title: '',
906
907
  padding: {
907
908
  top: 10,
908
909
  right: 25,
@@ -1717,8 +1718,8 @@
1717
1718
  // shareReplay(),
1718
1719
  // tap((isDirty) => console.log('IsDirty', isDirty)),
1719
1720
  );
1720
- this.builderContainerStyles$ = this.generalEmailOptionsAsObservable$.pipe(operators.map(function (_a) {
1721
- var background = _a.background, padding = _a.padding, direction = _a.direction;
1721
+ this.builderContainerStyles$ = this.generalEmailOptionsAsObservable$.pipe(operators.map(function (_c) {
1722
+ var background = _c.background, padding = _c.padding, direction = _c.direction;
1722
1723
  return (Object.assign({ direction: direction, backgroundRepeat: background.repeat, backgroundColor: background.color, backgroundSize: createWidthHeight(background.size), backgroundPosition: 'top center' }, createPadding(padding)));
1723
1724
  }));
1724
1725
  // public readonly emailBodyWidth$ = this.generalEmailOptionsAsObservable$.pipe(map(({ width }) => createWidthHeight(width)));
@@ -1727,11 +1728,20 @@
1727
1728
  this._Template$ = new rxjs.BehaviorSubject('');
1728
1729
  this.templateAsObservable$ = this._Template$.asObservable();
1729
1730
  this._onTemplateCreated$ = new rxjs.Subject();
1730
- this.onTemplateCreated$ = this._onTemplateCreated$.pipe(operators.withLatestFrom(this._Email$, this._Template$, this._Mjml$), operators.map(function (_a) {
1731
- var _b = __read(_a), _ = _b[0], rest = _b.slice(1);
1731
+ this.onTemplateCreated$ = this._onTemplateCreated$.pipe(operators.withLatestFrom(this._Email$, this._Template$, this._Mjml$), operators.map(function (_c) {
1732
+ var _d = __read(_c), _ = _d[0], rest = _d.slice(1);
1732
1733
  return rest;
1733
1734
  }));
1734
1735
  }
1736
+ Object.defineProperty(PbEmailObjectStoreService.prototype, "defaultTemplateThumbPath", {
1737
+ get: function () {
1738
+ var _a, _b;
1739
+ var apiPath = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.apiPath) === null || _b === void 0 ? void 0 : _b.replace(/\/+$/, '');
1740
+ return apiPath + "/images/placeholders/image-placeholder.png";
1741
+ },
1742
+ enumerable: false,
1743
+ configurable: true
1744
+ });
1735
1745
  PbEmailObjectStoreService.prototype.createHTMLTemplate$ = function () {
1736
1746
  var _this = this;
1737
1747
  return this.emailAsObservable$.pipe(operators.switchMap(function (email) {
@@ -1739,13 +1749,13 @@
1739
1749
  throw new Error('Please add some structures and blocks to perform this action.');
1740
1750
  }
1741
1751
  return deferOf(email);
1742
- }), operators.withLatestFrom(rxjs.combineLatest([this.currentEmailHasChanges$, this.templateAsObservable$])), operators.exhaustMap(function (_a) {
1743
- var _b = __read(_a, 2), email = _b[0], _c = __read(_b[1], 2), hasChanges = _c[0], currentHtml = _c[1];
1752
+ }), operators.withLatestFrom(rxjs.combineLatest([this.currentEmailHasChanges$, this.templateAsObservable$])), operators.exhaustMap(function (_c) {
1753
+ var _d = __read(_c, 2), email = _d[0], _e = __read(_d[1], 2), hasChanges = _e[0], currentHtml = _e[1];
1744
1754
  if (hasChanges || !currentHtml) {
1745
1755
  return _this.userMiddleware.createHTMLTemplate(email).pipe(operators.exhaustMap(function (em) { return _this.userRestApi.createHTMLTemplate$(Object.assign(Object.assign({}, em), { googleFonts: _this.googleFonts }), _this.config.apiPath); }), operators.map(function (res) {
1746
1756
  if (res.errors.length) {
1747
- var error = res.errors.map(function (_a) {
1748
- var message = _a.message, tagName = _a.tagName;
1757
+ var error = res.errors.map(function (_c) {
1758
+ var message = _c.message, tagName = _c.tagName;
1749
1759
  return tagName + " > " + message;
1750
1760
  }).join('\n');
1751
1761
  throw new Error(error);
@@ -1767,8 +1777,8 @@
1767
1777
  return res;
1768
1778
  }));
1769
1779
  }
1770
- return rxjs.combineLatest([_this._Mjml$, _this._Template$]).pipe(operators.map(function (_a) {
1771
- var _b = __read(_a, 2), mjml = _b[0], html = _b[1];
1780
+ return rxjs.combineLatest([_this._Mjml$, _this._Template$]).pipe(operators.map(function (_c) {
1781
+ var _d = __read(_c, 2), mjml = _d[0], html = _d[1];
1772
1782
  return ({ html: html, mjml: mjml, errors: [] });
1773
1783
  }));
1774
1784
  }));
@@ -1779,7 +1789,7 @@
1779
1789
  this.pbStorage.addTemplateToLatestUsed(cloneDeep({
1780
1790
  templateData: this.Email,
1781
1791
  title: 'last-edited',
1782
- thumbPath: 'assets/placeholders/image.svg'
1792
+ thumbPath: this.defaultTemplateThumbPath
1783
1793
  }));
1784
1794
  }
1785
1795
  // console.log(getDiff(this.clonedEmail, this.Email));
@@ -1791,9 +1801,9 @@
1791
1801
  this.Email = newEmail;
1792
1802
  this.reset();
1793
1803
  };
1794
- PbEmailObjectStoreService.prototype.addStructure = function (_a) {
1795
- var _b = _a.currentIndex, currentIndex = _b === void 0 ? 0 : _b, item = _a.item;
1796
- var _c = this.Email.structures, structures = _c === void 0 ? [] : _c;
1804
+ PbEmailObjectStoreService.prototype.addStructure = function (_c) {
1805
+ var _d = _c.currentIndex, currentIndex = _d === void 0 ? 0 : _d, item = _c.item;
1806
+ var _e = this.Email.structures, structures = _e === void 0 ? [] : _e;
1797
1807
  var isModule = true;
1798
1808
  if (!item.data.elements.length) {
1799
1809
  isModule = false;
@@ -1804,25 +1814,25 @@
1804
1814
  this.markForCheck();
1805
1815
  return newStructure;
1806
1816
  };
1807
- PbEmailObjectStoreService.prototype.changeStructureOrder = function (_a) {
1808
- var _b = _a.previousIndex, previousIndex = _b === void 0 ? 0 : _b, _c = _a.currentIndex, currentIndex = _c === void 0 ? 0 : _c;
1817
+ PbEmailObjectStoreService.prototype.changeStructureOrder = function (_c) {
1818
+ var _d = _c.previousIndex, previousIndex = _d === void 0 ? 0 : _d, _e = _c.currentIndex, currentIndex = _e === void 0 ? 0 : _e;
1809
1819
  dragDrop.moveItemInArray(this.Email.structures, previousIndex, currentIndex);
1810
1820
  this.markForCheck();
1811
1821
  };
1812
1822
  PbEmailObjectStoreService.prototype.duplicateStructure = function (index) {
1813
- var _a = this.Email.structures, structures = _a === void 0 ? [] : _a;
1823
+ var _c = this.Email.structures, structures = _c === void 0 ? [] : _c;
1814
1824
  var newStructure = cloneDeep(Object.assign(Object.assign({}, structures[index]), { id: Date.now() }));
1815
1825
  structures.splice(index, 0, newStructure);
1816
1826
  this.markForCheck();
1817
1827
  return newStructure;
1818
1828
  };
1819
1829
  PbEmailObjectStoreService.prototype.removeStructure = function (index) {
1820
- var _a = this.Email.structures, structures = _a === void 0 ? [] : _a;
1830
+ var _c = this.Email.structures, structures = _c === void 0 ? [] : _c;
1821
1831
  structures.splice(index, 1);
1822
1832
  this.markForCheck();
1823
1833
  };
1824
- PbEmailObjectStoreService.prototype.addBlock = function (_a, column) {
1825
- var _b = _a.previousIndex, previousIndex = _b === void 0 ? 0 : _b, _c = _a.currentIndex, currentIndex = _c === void 0 ? 0 : _c, item = _a.item, _d = _a.previousContainer, id = _d.id, data = _d.data;
1834
+ PbEmailObjectStoreService.prototype.addBlock = function (_c, column) {
1835
+ var _d = _c.previousIndex, previousIndex = _d === void 0 ? 0 : _d, _e = _c.currentIndex, currentIndex = _e === void 0 ? 0 : _e, item = _c.item, _f = _c.previousContainer, id = _f.id, data = _f.data;
1826
1836
  // console.log(id);
1827
1837
  // console.log(item);
1828
1838
  if (id === 'block-elements') {
@@ -1833,8 +1843,8 @@
1833
1843
  }
1834
1844
  this.markForCheck();
1835
1845
  };
1836
- PbEmailObjectStoreService.prototype.changeBlockOrder = function (_a, column) {
1837
- var _b = _a.previousIndex, previousIndex = _b === void 0 ? 0 : _b, _c = _a.currentIndex, currentIndex = _c === void 0 ? 0 : _c;
1846
+ PbEmailObjectStoreService.prototype.changeBlockOrder = function (_c, column) {
1847
+ var _d = _c.previousIndex, previousIndex = _d === void 0 ? 0 : _d, _e = _c.currentIndex, currentIndex = _e === void 0 ? 0 : _e;
1838
1848
  dragDrop.moveItemInArray(column, previousIndex, currentIndex);
1839
1849
  this.markForCheck();
1840
1850
  };
@@ -3117,6 +3127,11 @@
3117
3127
  _this.imageUploader = imageUploader;
3118
3128
  _this.chRef = chRef;
3119
3129
  _this.ngb = ngb;
3130
+ _this.defaultImageWidth = {
3131
+ value: 110,
3132
+ unit: 'px',
3133
+ auto: false
3134
+ };
3120
3135
  return _this;
3121
3136
  }
3122
3137
  Object.defineProperty(ImageComponent.prototype, "align", {
@@ -3129,7 +3144,14 @@
3129
3144
  });
3130
3145
  Object.defineProperty(ImageComponent.prototype, "src", {
3131
3146
  get: function () {
3132
- return this.block.src || 'assets/placeholders/image.svg';
3147
+ return this.block.src || this.defaultImageSrc;
3148
+ },
3149
+ enumerable: false,
3150
+ configurable: true
3151
+ });
3152
+ Object.defineProperty(ImageComponent.prototype, "defaultImageSrc", {
3153
+ get: function () {
3154
+ return this.ngb.config.apiPath + "/images/placeholders/image-placeholder.png";
3133
3155
  },
3134
3156
  enumerable: false,
3135
3157
  configurable: true
@@ -3153,7 +3175,9 @@
3153
3175
  };
3154
3176
  ImageComponent.prototype.getImageStyles = function () {
3155
3177
  var _a = this.block.options, border = _a.border, width = _a.width, height = _a.height, padding = _a.padding;
3156
- return Object.assign(Object.assign({ width: createWidthHeight(width), height: createWidthHeight(height) }, createPadding(padding)), createBorder(border));
3178
+ var hasPlaceholderImage = !(this.block.src || '').trim();
3179
+ var imageWidth = hasPlaceholderImage ? this.defaultImageWidth : width;
3180
+ return Object.assign(Object.assign({ width: createWidthHeight(imageWidth), height: createWidthHeight(height) }, createPadding(padding)), createBorder(border));
3157
3181
  };
3158
3182
  return ImageComponent;
3159
3183
  }(AbstractBlock));
@@ -3339,10 +3363,14 @@
3339
3363
  _this.chRef = chRef;
3340
3364
  _this.ngb = ngb;
3341
3365
  _this.videoThumbnailService = videoThumbnailService;
3366
+ _this.defaultPosterWidth = {
3367
+ value: 160,
3368
+ unit: 'px',
3369
+ auto: false
3370
+ };
3342
3371
  _this.destroy$ = new rxjs.Subject();
3343
3372
  _this.srcChange$ = new rxjs.Subject();
3344
3373
  _this.previousSrc = '';
3345
- _this.defaultPosterSrc = 'assets/placeholders/video.svg';
3346
3374
  _this.isGeneratingThumbnail = false;
3347
3375
  return _this;
3348
3376
  }
@@ -3367,6 +3395,20 @@
3367
3395
  enumerable: false,
3368
3396
  configurable: true
3369
3397
  });
3398
+ Object.defineProperty(VideoComponent.prototype, "defaultPosterSrc", {
3399
+ get: function () {
3400
+ return this.ngb.config.apiPath + "/images/placeholders/video-placeholder.png";
3401
+ },
3402
+ enumerable: false,
3403
+ configurable: true
3404
+ });
3405
+ Object.defineProperty(VideoComponent.prototype, "errorPosterSrc", {
3406
+ get: function () {
3407
+ return this.ngb.config.apiPath + "/images/placeholders/error-placeholder.png";
3408
+ },
3409
+ enumerable: false,
3410
+ configurable: true
3411
+ });
3370
3412
  Object.defineProperty(VideoComponent.prototype, "videoUrl", {
3371
3413
  get: function () {
3372
3414
  return this.block.src || '';
@@ -3443,7 +3485,7 @@
3443
3485
  case 3:
3444
3486
  error_1 = _a.sent();
3445
3487
  console.error('Error generating thumbnail:', error_1);
3446
- this.block.posterSrc = 'assets/placeholders/error.svg';
3488
+ this.block.posterSrc = this.errorPosterSrc;
3447
3489
  return [3 /*break*/, 5];
3448
3490
  case 4:
3449
3491
  this.isGeneratingThumbnail = false;
@@ -3490,7 +3532,9 @@
3490
3532
  };
3491
3533
  VideoComponent.prototype.getVideoStyles = function () {
3492
3534
  var _a = this.block.options, border = _a.border, width = _a.width, height = _a.height, padding = _a.padding;
3493
- return Object.assign(Object.assign({ width: createWidthHeight(width), height: createWidthHeight(height) }, createPadding(padding)), createBorder(border));
3535
+ var hasPlaceholderPoster = !!(this.block.posterSrc || '').trim();
3536
+ var posterWidth = hasPlaceholderPoster ? width : this.defaultPosterWidth;
3537
+ return Object.assign(Object.assign({ width: createWidthHeight(posterWidth), height: createWidthHeight(height) }, createPadding(padding)), createBorder(border));
3494
3538
  };
3495
3539
  return VideoComponent;
3496
3540
  }(AbstractBlock));