@solidpepper/solidpepper-solidgeneration 0.2.4 → 0.2.6

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,10 +1,11 @@
1
1
  import JsBarcode from 'jsbarcode';
2
2
  import QrCodeStyling from 'qr-code-styling';
3
+ import * as i2 from '@solidpepper/solidpepper-service';
4
+ import { PublicationDataType } from '@solidpepper/solidpepper-service';
3
5
  import { firstValueFrom } from 'rxjs';
4
6
  import * as i0 from '@angular/core';
5
7
  import { Injectable } from '@angular/core';
6
8
  import * as i1 from '@angular/common/http';
7
- import * as i2 from '@solidpepper/solidpepper-service';
8
9
  import * as i3 from 'ngx-toastr';
9
10
  import * as i4 from '@ngx-translate/core';
10
11
  import * as i5 from '@angular/platform-browser';
@@ -60,6 +61,7 @@ class DataSheet {
60
61
  this.backgrounds = [];
61
62
  this.defaultBackgroundGuid = null;
62
63
  this.marketing = [];
64
+ this.callouts = {};
63
65
  this.preview = true;
64
66
  this.imageFastPreview = true;
65
67
  this.bleedMargin = false;
@@ -364,6 +366,7 @@ class DataSheetSingleton {
364
366
  this.gabarits = {};
365
367
  this.backgrounds = {};
366
368
  this.marketing = {};
369
+ this.callouts = {};
367
370
  //console.log('[DataSheetSingleton] Constructor called. instanceId:', this.instanceId);
368
371
  }
369
372
  static getInstance() {
@@ -393,16 +396,25 @@ class DataSheetSingleton {
393
396
  setMarketing(templateGuid, list) {
394
397
  this.marketing[templateGuid] = [...list];
395
398
  }
399
+ getCallouts(templateGuid) {
400
+ const cached = this.callouts[templateGuid];
401
+ return cached ? [...cached] : null;
402
+ }
403
+ setCallouts(templateGuid, list) {
404
+ this.callouts[templateGuid] = [...list];
405
+ }
396
406
  clearTemplatesCache(templateGuid) {
397
407
  if (templateGuid) {
398
408
  delete this.gabarits[templateGuid];
399
409
  delete this.backgrounds[templateGuid];
400
410
  delete this.marketing[templateGuid];
411
+ delete this.callouts[templateGuid];
401
412
  }
402
413
  else {
403
414
  this.gabarits = {};
404
415
  this.backgrounds = {};
405
416
  this.marketing = {};
417
+ this.callouts = {};
406
418
  }
407
419
  }
408
420
  async getAttributesByType(attributeType, attributeGroup = '') {
@@ -574,16 +586,35 @@ class DataSheetSVG {
574
586
  // pour jObject dans lstSkus
575
587
  const gabaritDimCache = new Map();
576
588
  const getBlockDimensionsAndMarginsCached = (jObj) => {
577
- let defaultGabarit = this.DataSheet.gabarits.find((gabarit) => gabarit.guid == this.DataSheet.defaultGabaritGuid);
578
- let gabaritName = jObj.gabaritName + '.svg';
579
- let gabarit = this.DataSheet.gabarits.find((gabarit) => gabarit.name == gabaritName);
580
- if (gabarit == undefined || gabarit == null) {
581
- gabarit = defaultGabarit;
589
+ let gabarit = null;
590
+ if (jObj.type === PublicationDataType.CALLOUT) {
591
+ const calloutGuid = jObj.publicationDataCallout;
592
+ const calloutsList = this.DataSheet.callouts?.[calloutGuid] ||
593
+ DataSheetSingleton.getInstance().getCallouts(calloutGuid) ||
594
+ [];
595
+ const gName = (jObj.gabaritName || '').endsWith('.svg')
596
+ ? jObj.gabaritName
597
+ : jObj.gabaritName + '.svg';
598
+ gabarit = calloutsList.find((c) => c.name === gName ||
599
+ c.name === jObj.gabaritName ||
600
+ c.guid === jObj.gabaritName);
601
+ if (!gabarit && calloutsList.length > 0) {
602
+ gabarit =
603
+ calloutsList.find((c) => c.isDefault) || calloutsList[0];
604
+ }
582
605
  }
583
- if (gabarit == null || gabarit == undefined) {
584
- gabarit = this.DataSheet.gabarits[0];
606
+ else {
607
+ let defaultGabarit = (this.DataSheet.gabarits || []).find((gabarit) => gabarit.guid == this.DataSheet.defaultGabaritGuid);
608
+ let gabaritName = (jObj.gabaritName || '') + '.svg';
609
+ gabarit = (this.DataSheet.gabarits || []).find((gabarit) => gabarit.name == gabaritName || gabarit.name == jObj.gabaritName);
610
+ if (gabarit == undefined || gabarit == null) {
611
+ gabarit = defaultGabarit;
612
+ }
613
+ if (gabarit == null || gabarit == undefined) {
614
+ gabarit = (this.DataSheet.gabarits || [])[0];
615
+ }
585
616
  }
586
- if (!gabarit) {
617
+ if (!gabarit || !gabarit.svgImage) {
587
618
  return {
588
619
  width: 0,
589
620
  height: 0,
@@ -593,7 +624,9 @@ class DataSheetSVG {
593
624
  marginRight: 0,
594
625
  };
595
626
  }
596
- const cacheKey = gabarit.guid || gabarit.name || '';
627
+ const cacheKey = (jObj.type === PublicationDataType.CALLOUT
628
+ ? 'callout_'
629
+ : 'gabarit_') + (gabarit.guid || gabarit.name || '');
597
630
  if (gabaritDimCache.has(cacheKey)) {
598
631
  return gabaritDimCache.get(cacheKey);
599
632
  }
@@ -613,18 +646,24 @@ class DataSheetSVG {
613
646
  if (!jObj ||
614
647
  jObj === '{}' ||
615
648
  (jObj.sku == null &&
616
- jObj.type !== 'LINEBREAK' &&
617
- jObj.type !== 'PAGEBREAK')) {
649
+ jObj.type !== PublicationDataType.LINEBREAK &&
650
+ jObj.type !== PublicationDataType.PAGEBREAK &&
651
+ jObj.type !== PublicationDataType.CALLOUT)) {
618
652
  idx++;
619
653
  continue;
620
654
  }
621
- if (jObj.type === 'LINEBREAK' || jObj.type === 'PAGEBREAK') {
655
+ if (jObj.type === PublicationDataType.LINEBREAK ||
656
+ jObj.type === PublicationDataType.PAGEBREAK) {
622
657
  if (blocksInRow.length === 0) {
623
658
  idx++;
624
659
  }
625
660
  break;
626
661
  }
627
662
  let dim = getBlockDimensionsAndMarginsCached(jObj);
663
+ if (dim.width === 0 && dim.height === 0) {
664
+ idx++;
665
+ continue;
666
+ }
628
667
  let blockWidth = dim.width;
629
668
  let gMarginLeft = dim.marginLeft;
630
669
  let gMarginRight = dim.marginRight;
@@ -669,9 +708,10 @@ class DataSheetSVG {
669
708
  if (jObject != null &&
670
709
  jObject != '{}' &&
671
710
  (jObject.sku != null ||
672
- jObject.type === 'LINEBREAK' ||
673
- jObject.type === 'PAGEBREAK')) {
674
- if (jObject.type === 'PAGEBREAK') {
711
+ jObject.type === PublicationDataType.LINEBREAK ||
712
+ jObject.type === PublicationDataType.PAGEBREAK ||
713
+ jObject.type === PublicationDataType.CALLOUT)) {
714
+ if (jObject.type === PublicationDataType.PAGEBREAK) {
675
715
  AllTplProductsBlock += tplRowProductsBlocks;
676
716
  tplRowProductsBlocks = '';
677
717
  AllTplProductsBlock += this.addCuttingLine() + '</svg>';
@@ -714,7 +754,7 @@ class DataSheetSVG {
714
754
  currentIdx++;
715
755
  continue;
716
756
  }
717
- if (jObject.type === 'LINEBREAK') {
757
+ if (jObject.type === PublicationDataType.LINEBREAK) {
718
758
  if (nbBlockInRow > 0) {
719
759
  AllTplProductsBlock += tplRowProductsBlocks;
720
760
  tplRowProductsBlocks = '';
@@ -739,14 +779,45 @@ class DataSheetSVG {
739
779
  currentIdx++;
740
780
  continue;
741
781
  }
742
- let defaultGabarit = this.DataSheet.gabarits.find((gabarit) => gabarit.guid == this.DataSheet.defaultGabaritGuid);
743
- let gabaritName = jObject.gabaritName + '.svg';
744
- let gabarit = this.DataSheet.gabarits.find((gabarit) => gabarit.name == gabaritName);
745
- if (gabarit == undefined || gabarit == null) {
746
- gabarit = defaultGabarit;
782
+ let gabarit = null;
783
+ if (jObject.type === PublicationDataType.CALLOUT) {
784
+ const calloutGuid = jObject.publicationDataCallout ||
785
+ jObject.PublicationDataCallout;
786
+ const calloutsList = this.DataSheet.callouts?.[calloutGuid] ||
787
+ DataSheetSingleton.getInstance().getCallouts(calloutGuid) ||
788
+ [];
789
+ const gName = (jObject.gabaritName || '').endsWith('.svg')
790
+ ? jObject.gabaritName
791
+ : jObject.gabaritName + '.svg';
792
+ gabarit = calloutsList.find((c) => c.name === gName ||
793
+ c.name === jObject.gabaritName ||
794
+ c.guid === jObject.gabaritName);
795
+ if (!gabarit && calloutsList.length > 0) {
796
+ gabarit =
797
+ calloutsList.find((c) => c.isDefault) || calloutsList[0];
798
+ }
747
799
  }
748
- if (gabarit == null || gabarit == undefined) {
749
- gabarit = this.DataSheet.gabarits[0];
800
+ else {
801
+ let defaultGabarit = (this.DataSheet.gabarits || []).find((gabarit) => gabarit.guid == this.DataSheet.defaultGabaritGuid);
802
+ let gabaritName = (jObject.gabaritName || '') + '.svg';
803
+ gabarit = (this.DataSheet.gabarits || []).find((gabarit) => gabarit.name == gabaritName ||
804
+ gabarit.name == jObject.gabaritName);
805
+ if (gabarit == undefined || gabarit == null) {
806
+ gabarit = defaultGabarit;
807
+ }
808
+ if (gabarit == null || gabarit == undefined) {
809
+ gabarit = (this.DataSheet.gabarits || [])[0];
810
+ }
811
+ }
812
+ if (!gabarit || !gabarit.svgImage) {
813
+ console.warn('[SOLIDGENERATION] Skipping block with missing/invalid gabarit:', jObject);
814
+ this.DataSheet.progress +=
815
+ (50 / this.DataSheet.maxSections) *
816
+ 0.8 *
817
+ (1 / this.DataSheet.maxSkusSection);
818
+ this.DataSheet.nbSkusSection++;
819
+ currentIdx++;
820
+ continue;
750
821
  }
751
822
  let firstRowTopMargin = 0;
752
823
  let blockY = 0;
@@ -1024,7 +1095,7 @@ class DataSheetSVG {
1024
1095
  }
1025
1096
  }
1026
1097
  else {
1027
- console.log('[ERROR] RowTotalWidth is 0, this should not happen.');
1098
+ console.error('[ERROR] RowTotalWidth is 0, this should not happen.');
1028
1099
  }
1029
1100
  }
1030
1101
  }
@@ -1148,7 +1219,7 @@ class DataSheetSVG {
1148
1219
  }
1149
1220
  }
1150
1221
  else {
1151
- console.log('[ERROR] RowTotalWidth is 0, this should not happen.');
1222
+ console.error('[ERROR] RowTotalWidth is 0, this should not happen.');
1152
1223
  }
1153
1224
  }
1154
1225
  // Save for variant table (very useful)
@@ -1204,16 +1275,34 @@ class DataSheetSVG {
1204
1275
  }
1205
1276
  }
1206
1277
  getBlockDimensionsAndMargins(jObject) {
1207
- let defaultGabarit = this.DataSheet.gabarits.find((gabarit) => gabarit.guid == this.DataSheet.defaultGabaritGuid);
1208
- let gabaritName = jObject.gabaritName + '.svg';
1209
- let gabarit = this.DataSheet.gabarits.find((gabarit) => gabarit.name == gabaritName);
1210
- if (gabarit == undefined || gabarit == null) {
1211
- gabarit = defaultGabarit;
1278
+ let gabarit = null;
1279
+ if (jObject.type === PublicationDataType.CALLOUT) {
1280
+ const calloutGuid = jObject.publicationDataCallout || jObject.PublicationDataCallout;
1281
+ const calloutsList = this.DataSheet.callouts?.[calloutGuid] ||
1282
+ DataSheetSingleton.getInstance().getCallouts(calloutGuid) ||
1283
+ [];
1284
+ const gName = (jObject.gabaritName || '').endsWith('.svg')
1285
+ ? jObject.gabaritName
1286
+ : jObject.gabaritName + '.svg';
1287
+ gabarit = calloutsList.find((c) => c.name === gName ||
1288
+ c.name === jObject.gabaritName ||
1289
+ c.guid === jObject.gabaritName);
1290
+ if (!gabarit && calloutsList.length > 0) {
1291
+ gabarit = calloutsList.find((c) => c.isDefault) || calloutsList[0];
1292
+ }
1212
1293
  }
1213
- if (gabarit == null || gabarit == undefined) {
1214
- gabarit = this.DataSheet.gabarits[0];
1294
+ else {
1295
+ let defaultGabarit = (this.DataSheet.gabarits || []).find((gabarit) => gabarit.guid == this.DataSheet.defaultGabaritGuid);
1296
+ let gabaritName = (jObject.gabaritName || '') + '.svg';
1297
+ gabarit = (this.DataSheet.gabarits || []).find((gabarit) => gabarit.name == gabaritName || gabarit.name == jObject.gabaritName);
1298
+ if (gabarit == undefined || gabarit == null) {
1299
+ gabarit = defaultGabarit;
1300
+ }
1301
+ if (gabarit == null || gabarit == undefined) {
1302
+ gabarit = (this.DataSheet.gabarits || [])[0];
1303
+ }
1215
1304
  }
1216
- if (!gabarit) {
1305
+ if (!gabarit || !gabarit.svgImage) {
1217
1306
  return {
1218
1307
  width: 0,
1219
1308
  height: 0,
@@ -1367,34 +1456,63 @@ class DataSheetSVG {
1367
1456
  if (!skuRef) {
1368
1457
  skuRef = this.getAttributeFromSvg(gabarit?.svgImage, 'data-sku');
1369
1458
  }
1370
- let templateGuid = gabarit?.templateGuid || '';
1371
- if (!templateGuid ||
1372
- templateGuid === '00000000-0000-0000-0000-000000000000') {
1373
- templateGuid = this.DataSheet?.publicationTemplateTemplateGuid || '';
1459
+ const isCallout = jObject?.type === PublicationDataType.CALLOUT ||
1460
+ gabarit?.type?.toLowerCase() === 'callout' ||
1461
+ gabarit?.assetType?.toLowerCase() === 'callout';
1462
+ let templateGuid = '';
1463
+ if (isCallout) {
1464
+ templateGuid =
1465
+ jObject?.publicationDataCallout ||
1466
+ gabarit?.templateGuid ||
1467
+ gabarit?.publicationTemplateTemplateGuid ||
1468
+ '';
1469
+ if (!templateGuid ||
1470
+ templateGuid === '00000000-0000-0000-0000-000000000000') {
1471
+ templateGuid =
1472
+ this.getAttributeFromSvg(gabarit?.svgImage, 'data-templateGuid') ||
1473
+ this.getAttributeFromSvg(gabarit?.svgImage, 'data-assetGuid');
1474
+ }
1374
1475
  }
1375
- if (!templateGuid ||
1376
- templateGuid === '00000000-0000-0000-0000-000000000000') {
1377
- templateGuid = this.getAttributeFromSvg(gabarit?.svgImage, 'data-templateGuid');
1476
+ else {
1477
+ templateGuid = gabarit?.templateGuid || '';
1478
+ if (!templateGuid ||
1479
+ templateGuid === '00000000-0000-0000-0000-000000000000') {
1480
+ templateGuid = this.DataSheet?.publicationTemplateTemplateGuid || '';
1481
+ }
1482
+ if (!templateGuid ||
1483
+ templateGuid === '00000000-0000-0000-0000-000000000000') {
1484
+ templateGuid = this.getAttributeFromSvg(gabarit?.svgImage, 'data-templateGuid');
1485
+ }
1378
1486
  }
1379
- let assetGuid = gabarit?.templateGuid || '';
1380
- if (!assetGuid || assetGuid === '00000000-0000-0000-0000-000000000000') {
1381
- assetGuid = this.DataSheet?.publicationTemplateTemplateGuid || '';
1487
+ let assetGuid = '';
1488
+ if (isCallout) {
1489
+ assetGuid =
1490
+ jObject?.publicationDataCallout || gabarit?.templateGuid || '';
1491
+ if (!assetGuid || assetGuid === '00000000-0000-0000-0000-000000000000') {
1492
+ assetGuid =
1493
+ this.getAttributeFromSvg(gabarit?.svgImage, 'data-assetGuid') ||
1494
+ this.getAttributeFromSvg(gabarit?.svgImage, 'data-templateGuid');
1495
+ }
1382
1496
  }
1383
- if (!assetGuid || assetGuid === '00000000-0000-0000-0000-000000000000') {
1384
- assetGuid = this.getAttributeFromSvg(gabarit?.svgImage, 'data-assetGuid');
1497
+ else {
1498
+ assetGuid = gabarit?.templateGuid || '';
1499
+ if (!assetGuid || assetGuid === '00000000-0000-0000-0000-000000000000') {
1500
+ assetGuid = this.DataSheet?.publicationTemplateTemplateGuid || '';
1501
+ }
1502
+ if (!assetGuid || assetGuid === '00000000-0000-0000-0000-000000000000') {
1503
+ assetGuid = this.getAttributeFromSvg(gabarit?.svgImage, 'data-assetGuid');
1504
+ }
1385
1505
  }
1386
1506
  let blockGuid = gabarit?.guid || '';
1387
1507
  if (!blockGuid || blockGuid === '00000000-0000-0000-0000-000000000000') {
1388
1508
  blockGuid = this.getAttributeFromSvg(gabarit?.svgImage, 'data-blockGuid');
1389
1509
  }
1390
- const sanitizedRef = (skuRef || '')
1391
- .toString()
1392
- .trim()
1393
- .replace(/[\s\W]+/g, '-');
1510
+ const sanitizedRef = (skuRef || '').toString().trim();
1394
1511
  const groupId = sanitizedRef
1395
- ? `group_${nbBlock + 1}_${sanitizedRef}`
1396
- : `group_${nbBlock + 1}`;
1397
- return `<g data-type="template" id="${groupId}" data-skuGuid="${skuGuid}" data-sku="${skuRef}" data-assetGuid="${assetGuid}" data-templateGuid="${templateGuid}" data-blockGuid="${blockGuid}">${tplGroup}</g>`;
1512
+ ? `group(${nbBlock + 1}) - ${sanitizedRef}`
1513
+ : `group(${nbBlock + 1})`;
1514
+ const dataType = isCallout ? 'callout' : 'template';
1515
+ return `<g data-type="${dataType}" id="${groupId}" data-skuGuid="${skuGuid}" data-sku="${skuRef}" data-assetGuid="${assetGuid}" data-templateGuid="${templateGuid}" data-blockGuid="${blockGuid}">${tplGroup}</g>`;
1398
1516
  }
1399
1517
  CleanMissingFilters(svgContent) {
1400
1518
  const filterRegex = /filter="url\(#([^"]+)\)"/g;
@@ -2413,10 +2531,6 @@ class DataSheetSVG {
2413
2531
  let fieldObject = this.DataSheet.fields[i];
2414
2532
  if (fieldToSearch.includes('[') && fieldToSearch.includes(']')) {
2415
2533
  let name = fieldToSearch.substring(fieldToSearch.indexOf('[') + 1, fieldToSearch.length - 1 - fieldToSearch.indexOf('[') - 1);
2416
- // Debug case for new functionnality
2417
- if (fieldToSearch.indexOf('CLASSIFICATION') == -1) {
2418
- console.log('[INFO] Field not currently managed : ' + fieldToSearch);
2419
- }
2420
2534
  }
2421
2535
  if (fieldObject['fieldsGroup']['key'].toString() !== 'p_categories') {
2422
2536
  let fieldObjectFields = fieldObject['fields'];
@@ -3027,7 +3141,7 @@ class DataSheetSVG {
3027
3141
  }
3028
3142
  catch (e) {
3029
3143
  val = '';
3030
- console.log('[ERROR QR] ' + e);
3144
+ console.error('[ERROR QR] ', e);
3031
3145
  }
3032
3146
  }
3033
3147
  // Gestion Barcode
@@ -3042,7 +3156,7 @@ class DataSheetSVG {
3042
3156
  }
3043
3157
  catch (e) {
3044
3158
  val = '';
3045
- console.log('[ERROR Barcode] ' + e);
3159
+ console.error('[ERROR Barcode] ', e);
3046
3160
  }
3047
3161
  }
3048
3162
  val =
@@ -3558,7 +3672,6 @@ class DataSheetSVG {
3558
3672
  }
3559
3673
  else if (idVal.toLowerCase().includes('sku images')) {
3560
3674
  // TODO
3561
- console.log('todo');
3562
3675
  }
3563
3676
  else if (field.includes('skuDiscount')) {
3564
3677
  let priceStart = null;
@@ -4257,7 +4370,7 @@ class DataSheetSVG {
4257
4370
  newVal = await this.GenerateBarcode(tag, newVal);
4258
4371
  }
4259
4372
  catch (e) {
4260
- console.log('[ERROR] Error generating Barcode: ' + e);
4373
+ console.error('[ERROR] Error generating Barcode: ', e);
4261
4374
  newVal = '';
4262
4375
  }
4263
4376
  }
@@ -4281,7 +4394,7 @@ class DataSheetSVG {
4281
4394
  newVal = await this.GenerateQRCode(tag, newVal);
4282
4395
  }
4283
4396
  catch (e) {
4284
- console.log('[ERROR] Error generating QRCode: ' + e);
4397
+ console.error('[ERROR] Error generating QRCode: ', e);
4285
4398
  newVal = '';
4286
4399
  }
4287
4400
  }
@@ -4296,7 +4409,7 @@ class DataSheetSVG {
4296
4409
  newVal = await this.GenerateQRCode(tag, newVal);
4297
4410
  }
4298
4411
  catch (e) {
4299
- console.log('[ERROR] Error generating QRCode: ' + e);
4412
+ console.error('[ERROR] Error generating QRCode: ', e);
4300
4413
  newVal = '';
4301
4414
  }
4302
4415
  }
@@ -4315,7 +4428,7 @@ class DataSheetSVG {
4315
4428
  newVal = await this.GenerateQRCode(tag, newVal);
4316
4429
  }
4317
4430
  catch (e) {
4318
- console.log('[ERROR] Error generating QRCode: ' + e);
4431
+ console.error('[ERROR] Error generating QRCode: ', e);
4319
4432
  newVal = '';
4320
4433
  }
4321
4434
  }
@@ -4421,10 +4534,13 @@ class DataSheetSVG {
4421
4534
  return false;
4422
4535
  if (image.assetName === newVal || image.assetGuid === newVal)
4423
4536
  return true;
4424
- if (image.assetName && this.getCleanFilename(image.assetName).toLowerCase() === cleanNewVal.toLowerCase()) {
4537
+ if (image.assetName &&
4538
+ this.getCleanFilename(image.assetName).toLowerCase() ===
4539
+ cleanNewVal.toLowerCase()) {
4425
4540
  return true;
4426
4541
  }
4427
- if (image.assetName && this.getFileNameWithoutExt(image.assetName).toLowerCase() === cleanNewValNoExt) {
4542
+ if (image.assetName &&
4543
+ this.getFileNameWithoutExt(image.assetName).toLowerCase() === cleanNewValNoExt) {
4428
4544
  return true;
4429
4545
  }
4430
4546
  const urls = [
@@ -4436,19 +4552,25 @@ class DataSheetSVG {
4436
4552
  for (const url of urls) {
4437
4553
  if (url === newVal)
4438
4554
  return true;
4439
- if (this.getCleanFilename(url).toLowerCase() === cleanNewVal.toLowerCase())
4555
+ if (this.getCleanFilename(url).toLowerCase() ===
4556
+ cleanNewVal.toLowerCase())
4440
4557
  return true;
4441
- if (this.getFileNameWithoutExt(url).toLowerCase() === cleanNewValNoExt)
4558
+ if (this.getFileNameWithoutExt(url).toLowerCase() ===
4559
+ cleanNewValNoExt)
4442
4560
  return true;
4443
4561
  }
4444
4562
  return false;
4445
4563
  });
4446
4564
  }
4447
- if (skuImagesDetail.length === 0 && jRowSku && jRowSku['skuDefaultImage']) {
4565
+ if (skuImagesDetail.length === 0 &&
4566
+ jRowSku &&
4567
+ jRowSku['skuDefaultImage']) {
4448
4568
  const defaultImg = jRowSku['skuDefaultImage'];
4449
4569
  const cleanNewValNoExt = this.getFileNameWithoutExt(newVal).toLowerCase();
4450
4570
  const defaultNameNoExt = this.getFileNameWithoutExt(defaultImg.assetName || defaultImg.assetUrlOriginal || '').toLowerCase();
4451
- if (!cleanNewValNoExt || cleanNewValNoExt === defaultNameNoExt || defaultImg.assetGuid === newVal) {
4571
+ if (!cleanNewValNoExt ||
4572
+ cleanNewValNoExt === defaultNameNoExt ||
4573
+ defaultImg.assetGuid === newVal) {
4452
4574
  skuImagesDetail = [defaultImg];
4453
4575
  }
4454
4576
  }
@@ -4456,27 +4578,65 @@ class DataSheetSVG {
4456
4578
  const matchedAsset = skuImagesDetail[0];
4457
4579
  if (this.DataSheet.preview &&
4458
4580
  this.DataSheet.imageFastPreview == true) {
4459
- newVal = matchedAsset.assetUrlSmall || matchedAsset.assetUrlMedium || matchedAsset.assetUrlBig || matchedAsset.assetUrlOriginal || newVal;
4460
- urlHD = matchedAsset.assetUrlOriginal || matchedAsset.assetUrlBig || matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || newVal;
4581
+ newVal =
4582
+ matchedAsset.assetUrlSmall ||
4583
+ matchedAsset.assetUrlMedium ||
4584
+ matchedAsset.assetUrlBig ||
4585
+ matchedAsset.assetUrlOriginal ||
4586
+ newVal;
4587
+ urlHD =
4588
+ matchedAsset.assetUrlOriginal ||
4589
+ matchedAsset.assetUrlBig ||
4590
+ matchedAsset.assetUrlMedium ||
4591
+ matchedAsset.assetUrlSmall ||
4592
+ newVal;
4461
4593
  }
4462
4594
  else if (this.DataSheet.highDefinition == false) {
4463
- newVal = matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || matchedAsset.assetUrlBig || matchedAsset.assetUrlOriginal || newVal;
4464
- urlHD = matchedAsset.assetUrlOriginal || matchedAsset.assetUrlBig || matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || newVal;
4595
+ newVal =
4596
+ matchedAsset.assetUrlMedium ||
4597
+ matchedAsset.assetUrlSmall ||
4598
+ matchedAsset.assetUrlBig ||
4599
+ matchedAsset.assetUrlOriginal ||
4600
+ newVal;
4601
+ urlHD =
4602
+ matchedAsset.assetUrlOriginal ||
4603
+ matchedAsset.assetUrlBig ||
4604
+ matchedAsset.assetUrlMedium ||
4605
+ matchedAsset.assetUrlSmall ||
4606
+ newVal;
4465
4607
  }
4466
4608
  else {
4467
- newVal = matchedAsset.assetUrlOriginal || matchedAsset.assetUrlBig || matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || newVal;
4468
- urlHD = matchedAsset.assetUrlOriginal || matchedAsset.assetUrlBig || matchedAsset.assetUrlMedium || matchedAsset.assetUrlSmall || newVal;
4609
+ newVal =
4610
+ matchedAsset.assetUrlOriginal ||
4611
+ matchedAsset.assetUrlBig ||
4612
+ matchedAsset.assetUrlMedium ||
4613
+ matchedAsset.assetUrlSmall ||
4614
+ newVal;
4615
+ urlHD =
4616
+ matchedAsset.assetUrlOriginal ||
4617
+ matchedAsset.assetUrlBig ||
4618
+ matchedAsset.assetUrlMedium ||
4619
+ matchedAsset.assetUrlSmall ||
4620
+ newVal;
4469
4621
  }
4470
4622
  }
4471
4623
  else {
4472
4624
  let urlBase = this.getUrlBase(jRowSku);
4473
- if (urlBase && typeof newVal === 'string' && !newVal.startsWith('http://') && !newVal.startsWith('https://') && !newVal.startsWith('data:') && !newVal.startsWith('/')) {
4625
+ if (urlBase &&
4626
+ typeof newVal === 'string' &&
4627
+ !newVal.startsWith('http://') &&
4628
+ !newVal.startsWith('https://') &&
4629
+ !newVal.startsWith('data:') &&
4630
+ !newVal.startsWith('/')) {
4474
4631
  newVal = urlBase + newVal;
4475
4632
  }
4476
4633
  urlHD = newVal;
4477
4634
  if (typeof newVal === 'string' &&
4478
- (this.DataSheet.highDefinition == false || (this.DataSheet.preview && this.DataSheet.imageFastPreview == true))) {
4479
- if (this.DataSheet.preview && this.DataSheet.imageFastPreview == true) {
4635
+ (this.DataSheet.highDefinition == false ||
4636
+ (this.DataSheet.preview &&
4637
+ this.DataSheet.imageFastPreview == true))) {
4638
+ if (this.DataSheet.preview &&
4639
+ this.DataSheet.imageFastPreview == true) {
4480
4640
  newVal = newVal
4481
4641
  .replace(/\/original\//i, '/small/')
4482
4642
  .replace(/\.[a-zA-Z0-9]+(?=\?|#|$)/i, '.webp');
@@ -4710,9 +4870,6 @@ class DataSheetSVG {
4710
4870
  let domObjects = dom.querySelectorAll('*');
4711
4871
  tag.XmlTag = domObjects[0];
4712
4872
  }
4713
- else {
4714
- console.log('[DEBUG] Error during newVal for VariantsTable');
4715
- }
4716
4873
  }
4717
4874
  else if (tag.Barcode == true || tag.QRCode == true) {
4718
4875
  if (newVal != '') {
@@ -4765,7 +4922,8 @@ class DataSheetSVG {
4765
4922
  newVal = await this.deleteBlock(newVal);
4766
4923
  newVal = await this.deleteLine(newVal);
4767
4924
  tag.XmlTag.innerHTML = newVal;
4768
- if (tag.XmlTag.getAttribute('data-type') === 'text') {
4925
+ if (tag.XmlTag.getAttribute('data-type') === 'text' ||
4926
+ tag.XmlTag.querySelector('.fake-textarea')) {
4769
4927
  this.optimizeTextElement(tag.XmlTag, tpl);
4770
4928
  }
4771
4929
  if (tag.XmlTag.hasAttribute('data-type') &&
@@ -4844,7 +5002,7 @@ class DataSheetSVG {
4844
5002
  }
4845
5003
  }
4846
5004
  else {
4847
- console.log('[ERROR] Getting a parameters' + newVal);
5005
+ console.error('[ERROR] Getting a parameters', newVal);
4848
5006
  tag.XmlTag = null;
4849
5007
  }
4850
5008
  }
@@ -5037,6 +5195,55 @@ class DataSheetSVG {
5037
5195
  }
5038
5196
  }
5039
5197
  }
5198
+ else if (element.nodeName.toLowerCase() === 'foreignobject') {
5199
+ let tag = this.SetAllInfos(element);
5200
+ let tagToUpdate = allTags.find((tagToUpdate) => tagToUpdate.IdTag == tag.IdTag);
5201
+ if (tagToUpdate != null) {
5202
+ if (tagToUpdate.XmlTag == null) {
5203
+ element.remove();
5204
+ }
5205
+ else if (tagToUpdate.VariantsTable == true) {
5206
+ element.outerHTML = tagToUpdate.XmlTag.outerHTML;
5207
+ }
5208
+ else if (tagToUpdate.ProductTable == true) {
5209
+ element.outerHTML = tagToUpdate.XmlTag.outerHTML;
5210
+ }
5211
+ else if (tagToUpdate.Image == true) {
5212
+ element.innerHTML = tagToUpdate.XmlTag.innerHTML;
5213
+ if (element.getAttribute('data-type') === 'dynamicImage') {
5214
+ element.setAttribute('data-type', 'image');
5215
+ }
5216
+ }
5217
+ else {
5218
+ element.innerHTML = tagToUpdate.XmlTag.innerHTML;
5219
+ if (tagToUpdate.XmlTag.getAttribute('data-type') === 'text' ||
5220
+ tagToUpdate.XmlTag.querySelector('.fake-textarea')) {
5221
+ if (tagToUpdate.XmlTag.hasAttribute('x')) {
5222
+ element.setAttribute('x', tagToUpdate.XmlTag.getAttribute('x'));
5223
+ element.removeAttribute('transform');
5224
+ }
5225
+ if (tagToUpdate.XmlTag.hasAttribute('y')) {
5226
+ element.setAttribute('y', tagToUpdate.XmlTag.getAttribute('y'));
5227
+ element.removeAttribute('transform');
5228
+ }
5229
+ if (tagToUpdate.XmlTag.hasAttribute('width')) {
5230
+ const w = tagToUpdate.XmlTag.getAttribute('width');
5231
+ element.setAttribute('width', w);
5232
+ if (element.style && element.style.width) {
5233
+ element.style.width = w + 'px';
5234
+ }
5235
+ }
5236
+ if (tagToUpdate.XmlTag.hasAttribute('height')) {
5237
+ const h = tagToUpdate.XmlTag.getAttribute('height');
5238
+ element.setAttribute('height', h);
5239
+ if (element.style && element.style.height) {
5240
+ element.style.height = h + 'px';
5241
+ }
5242
+ }
5243
+ }
5244
+ }
5245
+ }
5246
+ }
5040
5247
  else if (group == true) {
5041
5248
  if (element.parentNode ? element.parentNode.nodeName == 'g' : false) {
5042
5249
  let tag = this.SetAllInfos(element);
@@ -5059,12 +5266,31 @@ class DataSheetSVG {
5059
5266
  }
5060
5267
  else {
5061
5268
  element.innerHTML = tagToUpdate.XmlTag.innerHTML;
5062
- if (tagToUpdate.XmlTag.getAttribute('data-type') === 'text') {
5269
+ if (tagToUpdate.XmlTag.getAttribute('data-type') === 'text' ||
5270
+ tagToUpdate.XmlTag.querySelector('.fake-textarea')) {
5271
+ if (tagToUpdate.XmlTag.hasAttribute('x')) {
5272
+ element.setAttribute('x', tagToUpdate.XmlTag.getAttribute('x'));
5273
+ element.removeAttribute('transform');
5274
+ }
5275
+ if (tagToUpdate.XmlTag.hasAttribute('y')) {
5276
+ element.setAttribute('y', tagToUpdate.XmlTag.getAttribute('y'));
5277
+ element.removeAttribute('transform');
5278
+ }
5063
5279
  if (tagToUpdate.XmlTag.hasAttribute('width')) {
5064
- element.setAttribute('width', tagToUpdate.XmlTag.getAttribute('width'));
5280
+ const w = tagToUpdate.XmlTag.getAttribute('width');
5281
+ element.setAttribute('width', w);
5282
+ if (element.style &&
5283
+ element.style.width) {
5284
+ element.style.width = w + 'px';
5285
+ }
5065
5286
  }
5066
5287
  if (tagToUpdate.XmlTag.hasAttribute('height')) {
5067
- element.setAttribute('height', tagToUpdate.XmlTag.getAttribute('height'));
5288
+ const h = tagToUpdate.XmlTag.getAttribute('height');
5289
+ element.setAttribute('height', h);
5290
+ if (element.style &&
5291
+ element.style.height) {
5292
+ element.style.height = h + 'px';
5293
+ }
5068
5294
  }
5069
5295
  }
5070
5296
  }
@@ -5132,7 +5358,8 @@ class DataSheetSVG {
5132
5358
  let attrName = element.getAttribute('data-hide-if-attribute') || '';
5133
5359
  let op = element.getAttribute('data-hide-if-operator') || 'is_null';
5134
5360
  let compareVal = element.getAttribute('data-hide-if-value') || '';
5135
- let variantAttr = element.getAttribute('data-hide-if-variant') || element.getAttribute('data-variant');
5361
+ let variantAttr = element.getAttribute('data-hide-if-variant') ||
5362
+ element.getAttribute('data-variant');
5136
5363
  let rowToUse = jRowSku;
5137
5364
  let variantExists = false;
5138
5365
  if (variantAttr != null && variantAttr !== '') {
@@ -5163,7 +5390,9 @@ class DataSheetSVG {
5163
5390
  let cleanCompare = cleanValueForHide(compareVal).toLowerCase();
5164
5391
  // Vérifier si l'attribut est de type multiSelect
5165
5392
  const normAttr = attrName.toLowerCase().trim();
5166
- const allAttrs = (this.DataSheet && this.DataSheet.attributes) || DataSheetSingleton.getInstance().attributes || [];
5393
+ const allAttrs = (this.DataSheet && this.DataSheet.attributes) ||
5394
+ DataSheetSingleton.getInstance().attributes ||
5395
+ [];
5167
5396
  const getAttrString = (val) => {
5168
5397
  if (!val)
5169
5398
  return '';
@@ -5176,12 +5405,19 @@ class DataSheetSVG {
5176
5405
  const matchedAttr = allAttrs.find((a) => (a && a.id && getAttrString(a.id) === normAttr) ||
5177
5406
  (a && a.attributeId && getAttrString(a.attributeId) === normAttr) ||
5178
5407
  (a && a.guid && getAttrString(a.guid) === normAttr) ||
5179
- (a && a.attributeGuid && getAttrString(a.attributeGuid) === normAttr) ||
5180
- (a && a.attributeName && getAttrString(a.attributeName) === normAttr) ||
5408
+ (a &&
5409
+ a.attributeGuid &&
5410
+ getAttrString(a.attributeGuid) === normAttr) ||
5411
+ (a &&
5412
+ a.attributeName &&
5413
+ getAttrString(a.attributeName) === normAttr) ||
5181
5414
  (a && a.code && getAttrString(a.code) === normAttr) ||
5182
- (a && a.attributeCode && getAttrString(a.attributeCode) === normAttr));
5415
+ (a &&
5416
+ a.attributeCode &&
5417
+ getAttrString(a.attributeCode) === normAttr));
5183
5418
  const isMultiSelectAttr = !!(matchedAttr &&
5184
- (matchedAttr.attributeType === 'multiSelect' || matchedAttr.type === 'multiSelect'));
5419
+ (matchedAttr.attributeType === 'multiSelect' ||
5420
+ matchedAttr.type === 'multiSelect'));
5185
5421
  let actualValues = [];
5186
5422
  if (isMultiSelectAttr) {
5187
5423
  if (Array.isArray(actualValue)) {
@@ -5240,7 +5476,9 @@ class DataSheetSVG {
5240
5476
  const isFixed = locked === 'true';
5241
5477
  const isWidth = locked === 'width';
5242
5478
  const isHeight = locked !== 'true' && locked !== 'width';
5243
- if (isFixed) {
5479
+ const isMinimize = textarea.getAttribute('data-minimize') === 'true' ||
5480
+ foEl.getAttribute('data-minimize') === 'true';
5481
+ if (isFixed && !isMinimize) {
5244
5482
  return;
5245
5483
  }
5246
5484
  const foWidth = parseFloat(foEl.getAttribute('width')) || 0;
@@ -5274,151 +5512,129 @@ class DataSheetSVG {
5274
5512
  const textareaElement = tempDiv.querySelector(`#${textareaId}`);
5275
5513
  if (textareaElement) {
5276
5514
  let parentFo = textareaElement.closest('foreignObject');
5277
- const splitDivAtBr = (div) => {
5278
- const br = div.querySelector('br');
5279
- if (!br || !div.parentNode)
5280
- return false;
5281
- const nextDiv = div.cloneNode(true);
5282
- let currInDiv = div.querySelector('br');
5283
- while (currInDiv && currInDiv !== div) {
5284
- const parent = currInDiv.parentNode;
5285
- if (!parent)
5286
- break;
5287
- while (currInDiv.nextSibling) {
5288
- parent.removeChild(currInDiv.nextSibling);
5289
- }
5290
- const toRemove = currInDiv;
5291
- currInDiv = parent;
5292
- if (toRemove.nodeName.toLowerCase() === 'br') {
5293
- parent.removeChild(toRemove);
5294
- }
5515
+ const direction = textarea.getAttribute('data-direction') ||
5516
+ foEl.getAttribute('data-direction') ||
5517
+ (isWidth ? 'ltr' : 'ttb');
5518
+ const [initialYStr, initialXStr] = this.GetXY(foEl);
5519
+ const initialX = initialXStr !== '' && initialXStr !== null
5520
+ ? parseFloat(initialXStr)
5521
+ : parseFloat(foEl.getAttribute('x')) || 0;
5522
+ const initialY = initialYStr !== '' && initialYStr !== null
5523
+ ? parseFloat(initialYStr)
5524
+ : parseFloat(foEl.getAttribute('y')) || 0;
5525
+ if (isWidth) {
5526
+ if (parentFo) {
5527
+ parentFo.setAttribute('width', '99999');
5528
+ parentFo.setAttribute('height', foHeight.toString());
5295
5529
  }
5296
- let currInNext = nextDiv.querySelector('br');
5297
- while (currInNext && currInNext !== nextDiv) {
5298
- const parent = currInNext.parentNode;
5299
- if (!parent)
5300
- break;
5301
- while (currInNext.previousSibling) {
5302
- parent.removeChild(currInNext.previousSibling);
5303
- }
5304
- const toRemove = currInNext;
5305
- currInNext = parent;
5306
- if (toRemove.nodeName.toLowerCase() === 'br') {
5307
- parent.removeChild(toRemove);
5308
- }
5530
+ textareaElement.style.setProperty('width', 'max-content', 'important');
5531
+ textareaElement.style.setProperty('max-width', 'none', 'important');
5532
+ textareaElement.style.setProperty('height', 'auto', 'important');
5533
+ textareaElement.style.setProperty('min-height', '0', 'important');
5534
+ textareaElement.style.display = 'inline-block';
5535
+ const rect = textareaElement.getBoundingClientRect();
5536
+ const naturalWidth = Math.ceil(rect.width);
5537
+ const naturalHeight = Math.ceil(rect.height);
5538
+ const newWidth = naturalWidth + 4;
5539
+ if (direction === 'rtl') {
5540
+ const deltaW = newWidth - foWidth;
5541
+ const newX = initialX - deltaW;
5542
+ foEl.setAttribute('x', newX.toString());
5543
+ foEl.removeAttribute('transform');
5309
5544
  }
5310
- div.parentNode.insertBefore(nextDiv, div.nextSibling);
5311
- if (!nextDiv.textContent || !nextDiv.textContent.trim()) {
5312
- nextDiv.remove();
5545
+ foEl.setAttribute('width', newWidth.toString());
5546
+ if (isMinimize) {
5547
+ foEl.setAttribute('height', Math.min(foHeight, naturalHeight + 4).toString());
5313
5548
  }
5314
- return true;
5315
- };
5316
- let hasBr = true;
5317
- while (hasBr) {
5318
- hasBr = false;
5319
- const divsWithBr = Array.from(textareaElement.querySelectorAll('div')).filter((d) => d.querySelector('br') !== null);
5320
- for (const d of divsWithBr) {
5321
- if (splitDivAtBr(d)) {
5322
- hasBr = true;
5323
- break;
5324
- }
5549
+ else {
5550
+ foEl.setAttribute('height', Math.max(foHeight, naturalHeight + 4).toString());
5325
5551
  }
5326
5552
  }
5327
- // Split long text wrapping into separate divs to prevent overlap and highlight blockiness
5328
- const lineDivs = Array.from(textareaElement.querySelectorAll('div')).filter((d) => {
5329
- return d.querySelectorAll('div').length === 0;
5330
- });
5331
- const findTextNode = (node) => {
5332
- if (node.nodeType === Node.TEXT_NODE &&
5333
- node.textContent?.trim() !== '') {
5334
- return node;
5335
- }
5336
- for (let child of Array.from(node.childNodes)) {
5337
- const found = findTextNode(child);
5338
- if (found)
5339
- return found;
5340
- }
5341
- return null;
5342
- };
5343
- let domChanged = false;
5344
- lineDivs.forEach((lineDiv) => {
5345
- const text = lineDiv.textContent || '';
5346
- if (!text.trim())
5347
- return;
5348
- const computedStyle = window.getComputedStyle(lineDiv);
5349
- const fontFamily = computedStyle.fontFamily || 'sans-serif';
5350
- const fontSize = computedStyle.fontSize || '24px';
5351
- const canvas = document.createElement('canvas');
5352
- const ctx = canvas.getContext('2d');
5353
- if (!ctx)
5354
- return;
5355
- ctx.font = `${fontSize} ${fontFamily}`;
5356
- const textWidth = ctx.measureText(text).width;
5357
- if (foWidth > 0 && textWidth > foWidth) {
5358
- const words = text.split(' ');
5359
- const linesOfText = [];
5360
- let currentLine = '';
5361
- for (let word of words) {
5362
- const testLine = currentLine ? currentLine + ' ' + word : word;
5363
- const testWidth = ctx.measureText(testLine).width;
5364
- if (testWidth > foWidth && currentLine) {
5365
- linesOfText.push(currentLine);
5366
- currentLine = word;
5367
- }
5368
- else {
5369
- currentLine = testLine;
5370
- }
5371
- }
5372
- if (currentLine) {
5373
- linesOfText.push(currentLine);
5374
- }
5375
- if (linesOfText.length > 1) {
5376
- domChanged = true;
5377
- let previousLine = lineDiv;
5378
- for (let i = 0; i < linesOfText.length; i++) {
5379
- if (i === 0) {
5380
- const textNode = findTextNode(lineDiv);
5381
- if (textNode) {
5382
- textNode.textContent = linesOfText[0];
5383
- }
5384
- }
5385
- else {
5386
- const clone = lineDiv.cloneNode(true);
5387
- const textNode = findTextNode(clone);
5388
- if (textNode) {
5389
- textNode.textContent = linesOfText[i];
5390
- }
5391
- lineDiv.parentNode.insertBefore(clone, previousLine.nextSibling);
5392
- previousLine = clone;
5393
- }
5394
- }
5395
- }
5396
- }
5397
- });
5398
- if (domChanged) {
5399
- const originalTextarea = foEl.querySelector('.fake-textarea');
5400
- if (originalTextarea) {
5401
- originalTextarea.innerHTML = textareaElement.innerHTML;
5553
+ else if (isHeight) {
5554
+ if (parentFo) {
5555
+ parentFo.setAttribute('width', foWidth.toString());
5556
+ parentFo.setAttribute('height', 'auto');
5402
5557
  }
5403
- }
5404
- if (isWidth) {
5405
- textareaElement.style.width = 'max-content';
5406
- textareaElement.style.whiteSpace = 'nowrap';
5558
+ textareaElement.style.setProperty('width', 'max-content', 'important');
5559
+ textareaElement.style.setProperty('max-width', foWidth + 'px', 'important');
5560
+ textareaElement.style.setProperty('height', 'auto', 'important');
5561
+ textareaElement.style.setProperty('min-height', '0', 'important');
5562
+ textareaElement.style.setProperty('max-height', 'none', 'important');
5407
5563
  textareaElement.style.display = 'inline-block';
5564
+ textareaElement.style.wordBreak = 'break-word';
5565
+ textareaElement.style.overflowWrap = 'break-word';
5566
+ if (textarea) {
5567
+ textarea.style.wordBreak = 'break-word';
5568
+ textarea.style.overflowWrap = 'break-word';
5569
+ }
5408
5570
  const rect = textareaElement.getBoundingClientRect();
5409
5571
  const naturalWidth = Math.ceil(rect.width);
5410
- foEl.setAttribute('width', (naturalWidth + 4).toString());
5411
- }
5412
- else if (isHeight) {
5572
+ const naturalHeight = Math.ceil(rect.height);
5573
+ const newHeight = naturalHeight + 4;
5574
+ if (direction === 'btt') {
5575
+ const deltaH = newHeight - foHeight;
5576
+ const newY = initialY - deltaH;
5577
+ foEl.setAttribute('y', newY.toString());
5578
+ foEl.removeAttribute('transform');
5579
+ }
5580
+ foEl.setAttribute('height', newHeight.toString());
5581
+ if (isMinimize) {
5582
+ const newWidth = Math.min(foWidth, naturalWidth + 4);
5583
+ if (direction === 'rtl') {
5584
+ const deltaW = newWidth - foWidth;
5585
+ const newX = initialX - deltaW;
5586
+ foEl.setAttribute('x', newX.toString());
5587
+ foEl.removeAttribute('transform');
5588
+ }
5589
+ foEl.setAttribute('width', newWidth.toString());
5590
+ }
5591
+ }
5592
+ else if (isFixed && isMinimize) {
5413
5593
  if (parentFo) {
5414
5594
  parentFo.setAttribute('width', foWidth.toString());
5415
- parentFo.removeAttribute('height');
5595
+ parentFo.setAttribute('height', foHeight.toString());
5596
+ }
5597
+ textareaElement.style.setProperty('width', 'max-content', 'important');
5598
+ textareaElement.style.setProperty('max-width', foWidth + 'px', 'important');
5599
+ textareaElement.style.setProperty('height', 'auto', 'important');
5600
+ textareaElement.style.setProperty('min-height', '0', 'important');
5601
+ textareaElement.style.setProperty('max-height', foHeight + 'px', 'important');
5602
+ textareaElement.style.display = 'inline-block';
5603
+ textareaElement.style.wordBreak = 'break-word';
5604
+ textareaElement.style.overflowWrap = 'break-word';
5605
+ if (textarea) {
5606
+ textarea.style.wordBreak = 'break-word';
5607
+ textarea.style.overflowWrap = 'break-word';
5416
5608
  }
5417
- textareaElement.style.width = foWidth + 'px';
5418
- textareaElement.style.height = 'auto';
5419
5609
  const rect = textareaElement.getBoundingClientRect();
5610
+ const naturalWidth = Math.ceil(rect.width);
5420
5611
  const naturalHeight = Math.ceil(rect.height);
5421
- foEl.setAttribute('height', (naturalHeight + 4).toString());
5612
+ const newWidth = Math.min(foWidth, naturalWidth + 4);
5613
+ const newHeight = Math.min(foHeight, naturalHeight + 4);
5614
+ if (direction === 'rtl') {
5615
+ const deltaW = newWidth - foWidth;
5616
+ const newX = initialX - deltaW;
5617
+ foEl.setAttribute('x', newX.toString());
5618
+ foEl.removeAttribute('transform');
5619
+ }
5620
+ if (direction === 'btt') {
5621
+ const deltaH = newHeight - foHeight;
5622
+ const newY = initialY - deltaH;
5623
+ foEl.setAttribute('y', newY.toString());
5624
+ foEl.removeAttribute('transform');
5625
+ }
5626
+ foEl.setAttribute('width', newWidth.toString());
5627
+ foEl.setAttribute('height', newHeight.toString());
5628
+ }
5629
+ if (textarea) {
5630
+ textarea.setAttribute('locked', 'true');
5631
+ textarea.style.width = '100%';
5632
+ textarea.style.height = '100%';
5633
+ textarea.style.wordBreak = 'break-word';
5634
+ textarea.style.overflowWrap = 'break-word';
5635
+ textarea.style.whiteSpace = 'normal';
5636
+ textarea.style.maxHeight = 'none';
5637
+ textarea.style.maxWidth = 'none';
5422
5638
  }
5423
5639
  }
5424
5640
  }
@@ -5689,7 +5905,8 @@ class DataSheetSVG {
5689
5905
  }
5690
5906
  }
5691
5907
  getBackgroundSectionForPreview(section) {
5692
- if (!this.DataSheet.backgrounds || this.DataSheet.backgrounds.length === 0) {
5908
+ if (!this.DataSheet.backgrounds ||
5909
+ this.DataSheet.backgrounds.length === 0) {
5693
5910
  return null;
5694
5911
  }
5695
5912
  let defaultBackground = this.DataSheet.backgrounds.find((background) => background.guid == this.DataSheet.defaultBackgroundGuid);
@@ -5792,7 +6009,9 @@ class DataSheetSVG {
5792
6009
  return background;
5793
6010
  }
5794
6011
  getMarketingSectionForPreview(section) {
5795
- if (!this.DataSheet.marketing || this.DataSheet.marketing.length === 0 || !section) {
6012
+ if (!this.DataSheet.marketing ||
6013
+ this.DataSheet.marketing.length === 0 ||
6014
+ !section) {
5796
6015
  return null;
5797
6016
  }
5798
6017
  const identifier = section.gabaritName ||
@@ -5800,7 +6019,9 @@ class DataSheetSVG {
5800
6019
  section.gabaritGuid ||
5801
6020
  section.guid ||
5802
6021
  section.name;
5803
- if (!identifier || typeof identifier !== 'string' || identifier.trim() === '') {
6022
+ if (!identifier ||
6023
+ typeof identifier !== 'string' ||
6024
+ identifier.trim() === '') {
5804
6025
  return null;
5805
6026
  }
5806
6027
  const idLower = identifier.trim().toLowerCase();
@@ -5812,7 +6033,9 @@ class DataSheetSVG {
5812
6033
  if (mGuidLower && (mGuidLower === idLower || mGuidLower === idClean)) {
5813
6034
  return true;
5814
6035
  }
5815
- const mMarketingNameLower = (m.marketingName || '').toString().toLowerCase();
6036
+ const mMarketingNameLower = (m.marketingName || '')
6037
+ .toString()
6038
+ .toLowerCase();
5816
6039
  const mMarketingClean = mMarketingNameLower.replace(/\.svg$/i, '');
5817
6040
  if (mMarketingNameLower &&
5818
6041
  (mMarketingNameLower === idLower ||
@@ -6135,9 +6358,10 @@ class DataSheetSVG {
6135
6358
  getActualBlockHeight(svgContent, initialBlockHeight, blockY = 0) {
6136
6359
  if (!svgContent)
6137
6360
  return { actualHeight: initialBlockHeight, updatedSvg: svgContent };
6138
- const hasVariantTable = /id=["']tableVariant["']/i.test(svgContent) ||
6139
- /data-info=["']variantTable["']/i.test(svgContent);
6140
- if (!hasVariantTable) {
6361
+ const hasDynamicElements = /id=["']tableVariant["']/i.test(svgContent) ||
6362
+ /data-info=["']variantTable["']/i.test(svgContent) ||
6363
+ /<foreignObject/i.test(svgContent);
6364
+ if (!hasDynamicElements) {
6141
6365
  return { actualHeight: initialBlockHeight, updatedSvg: svgContent };
6142
6366
  }
6143
6367
  let maxBottom = 0;
@@ -6384,7 +6608,7 @@ class DataSheetSVG {
6384
6608
  return null;
6385
6609
  }
6386
6610
  catch (e) {
6387
- console.log('[ERROR] An error occured during getting url');
6611
+ console.error('[ERROR] An error occured during getting url', e);
6388
6612
  return null;
6389
6613
  }
6390
6614
  }
@@ -6691,6 +6915,9 @@ class DataSheetSku {
6691
6915
  this.DataSheet = dataSheet;
6692
6916
  this.DataSheetSVG = dataSheetSVG;
6693
6917
  }
6918
+ async setDataSheetsController(dataSheetsController) {
6919
+ this.dataSheetsController = dataSheetsController;
6920
+ }
6694
6921
  async setPublicationsService(publicationsService) {
6695
6922
  if (!publicationsService) {
6696
6923
  throw new Error('PublicationsService instance is required');
@@ -6708,6 +6935,7 @@ class DataSheetSku {
6708
6935
  }
6709
6936
  let lstSkuObjects = res?.sku || [];
6710
6937
  if (lstSkuObjects == null || lstSkuObjects.length === 0) {
6938
+ console.error('[DATASHEET-GENERATION][DataSheetSku] lstSkuObjects is null or empty for SKU:', sourceId);
6711
6939
  this.DataSheet.currentStep = 99;
6712
6940
  return [];
6713
6941
  }
@@ -6736,6 +6964,9 @@ class DataSheetSku {
6736
6964
  let pages = [];
6737
6965
  let background = this.DataSheetSVG.getBackgroundSectionForPreview(section);
6738
6966
  let backgroundTpl = background?.svgImage || '';
6967
+ if (!background || !backgroundTpl) {
6968
+ console.error('[DATASHEET-GENERATION][DataSheetSku] Background or SVG image is missing for section:', section, 'background object:', background);
6969
+ }
6739
6970
  let allBackgroundTags = this.DataSheetSVG.GetSvgGroupToReplace(backgroundTpl);
6740
6971
  let allElements = this.DataSheetSVG.GetAllTags(backgroundTpl);
6741
6972
  let group = false;
@@ -6863,20 +7094,53 @@ class DataSheetSku {
6863
7094
  const pageConfig = pagesConfigs[p];
6864
7095
  let currentBackgroundTpl = backgroundTpl;
6865
7096
  if (pageConfig) {
6866
- if (pageConfig.backgroundGuid) {
6867
- const bg = this.DataSheet.backgrounds.find((b) => b.guid === pageConfig.backgroundGuid);
7097
+ const bgGuid = pageConfig.backgroundGuid || pageConfig.background;
7098
+ let bg = null;
7099
+ if (bgGuid) {
7100
+ const cleanBg = String(bgGuid).trim().toLowerCase();
7101
+ bg = (this.DataSheet.backgrounds || []).find((b) => (b.guid && String(b.guid).toLowerCase() === cleanBg) ||
7102
+ (b.name && String(b.name).toLowerCase() === cleanBg) ||
7103
+ (b.nameNoSvg && String(b.nameNoSvg).toLowerCase() === cleanBg) ||
7104
+ (b.name && String(b.name).toLowerCase().replace('.svg', '') === cleanBg.replace('.svg', '')));
6868
7105
  if (bg && bg.svgImage) {
6869
7106
  currentBackgroundTpl = bg.svgImage;
6870
7107
  }
6871
7108
  }
6872
- if (pageConfig.gabaritGuid) {
6873
- this.DataSheet.defaultGabaritGuid = pageConfig.gabaritGuid;
7109
+ const gabGuid = pageConfig.gabaritGuid || pageConfig.gabarit;
7110
+ let gab = null;
7111
+ if (gabGuid) {
7112
+ const cleanGab = String(gabGuid).trim().toLowerCase();
7113
+ gab = (this.DataSheet.gabarits || []).find((g) => (g.guid && String(g.guid).toLowerCase() === cleanGab) ||
7114
+ (g.name && String(g.name).toLowerCase() === cleanGab) ||
7115
+ (g.nameNoSvg && String(g.nameNoSvg).toLowerCase() === cleanGab) ||
7116
+ (g.name && String(g.name).toLowerCase().replace('.svg', '') === cleanGab.replace('.svg', '')));
7117
+ if (gab) {
7118
+ this.DataSheet.defaultGabaritGuid = gab.guid || gab.name;
7119
+ }
7120
+ else {
7121
+ this.DataSheet.defaultGabaritGuid = gabGuid;
7122
+ }
6874
7123
  }
6875
7124
  }
6876
7125
  let i = 0;
6877
7126
  for (const jObject of lstSkus) {
6878
7127
  let aJobject = [];
6879
7128
  aJobject.push(jObject);
7129
+ if (jObject && jObject.type === PublicationDataType.CALLOUT) {
7130
+ const cGuid = jObject.publicationDataCallout ||
7131
+ jObject.PublicationDataCallout;
7132
+ const needForce = !this.DataSheet.preview;
7133
+ if (cGuid && (!this.DataSheet.callouts?.[cGuid] || needForce)) {
7134
+ let loaded = [];
7135
+ if (this.dataSheetsController) {
7136
+ loaded =
7137
+ await this.dataSheetsController.updateCalloutsList(cGuid, needForce);
7138
+ }
7139
+ if (!this.DataSheet.callouts)
7140
+ this.DataSheet.callouts = {};
7141
+ this.DataSheet.callouts[cGuid] = loaded;
7142
+ }
7143
+ }
6880
7144
  const newFiles = await this.DataSheetSVG.GenerateSvgFiles(aJobject, currentBackgroundTpl, currentBackgroundTpl, fileIndex.toString());
6881
7145
  if (newFiles) {
6882
7146
  files = files.concat(newFiles);
@@ -6893,7 +7157,7 @@ class DataSheetSku {
6893
7157
  return arrayFiles;
6894
7158
  }
6895
7159
  catch (e) {
6896
- console.log('[ERROR] Error in GenerateAllInOneExportFile:', e);
7160
+ console.error('[ERROR] Error in GenerateAllInOneExportFile:', e);
6897
7161
  return null;
6898
7162
  }
6899
7163
  }
@@ -6913,6 +7177,9 @@ class DataSheetPublication {
6913
7177
  this.sectionActiveObject = sectionActiveObject;
6914
7178
  this.skusSection = skusSection;
6915
7179
  }
7180
+ async setDataSheetsController(dataSheetsController) {
7181
+ this.dataSheetsController = dataSheetsController;
7182
+ }
6916
7183
  async setPublicationsService(publicationsService) {
6917
7184
  if (!publicationsService) {
6918
7185
  throw new Error('PublicationsService instance is required');
@@ -6947,7 +7214,6 @@ class DataSheetPublication {
6947
7214
  else {
6948
7215
  sections = [];
6949
7216
  if (sections.length == 0) {
6950
- console.log('[PUBLICATIONS] No pages detected try to get pages');
6951
7217
  if (!this.publicationsService) {
6952
7218
  throw new Error('PublicationsService instance is required');
6953
7219
  }
@@ -7001,7 +7267,7 @@ class DataSheetPublication {
7001
7267
  .toPromise();
7002
7268
  let skus = res?.['skus'];
7003
7269
  if (!Array.isArray(skus)) {
7004
- console.log('[ERROR] No SKUs found for this page:', section.pageId);
7270
+ console.error('[ERROR] No SKUs found for this page:', section.pageId);
7005
7271
  skus = [];
7006
7272
  }
7007
7273
  for (let sku of skus) {
@@ -7350,9 +7616,22 @@ class DataSheetPublication {
7350
7616
  let background = this.DataSheetSVG.getBackgroundSectionForPreview(section);
7351
7617
  let backgroundTpl = background?.svgImage || '';
7352
7618
  let allBackgroundTags = this.DataSheetSVG.GetSvgGroupToReplace(backgroundTpl);
7353
- // Get the backgroundTpl left page (= 1st g) and right page (= 2nd g if exist else the first g) for double page layout, the idea is to remove left/right g for each page
7354
- let backgroundTplLeft = this.DataSheetSVG.keepOnlySideRegex(backgroundTpl, 'left');
7355
- let backgroundTplRight = this.DataSheetSVG.keepOnlySideRegex(backgroundTpl, 'right');
7619
+ const hasDataSide = backgroundTpl.includes('data-side');
7620
+ const isDoublePage = backgroundTpl.includes('data-double-page="true"') ||
7621
+ backgroundTpl.includes("data-double-page='true'");
7622
+ let backgroundTplLeft = backgroundTpl;
7623
+ let backgroundTplRight = backgroundTpl;
7624
+ if (hasDataSide) {
7625
+ if (isDoublePage) {
7626
+ backgroundTplLeft = this.DataSheetSVG.keepOnlySideRegex(backgroundTpl, 'left');
7627
+ backgroundTplRight = this.DataSheetSVG.keepOnlySideRegex(backgroundTpl, 'right');
7628
+ }
7629
+ else {
7630
+ const onlyRight = this.DataSheetSVG.keepOnlySideRegex(backgroundTpl, 'right');
7631
+ backgroundTplLeft = onlyRight;
7632
+ backgroundTplRight = onlyRight;
7633
+ }
7634
+ }
7356
7635
  let allElements = this.DataSheetSVG.GetAllTags(backgroundTplLeft);
7357
7636
  let group = false;
7358
7637
  if (allElements) {
@@ -7478,6 +7757,24 @@ class DataSheetPublication {
7478
7757
  else {
7479
7758
  lstSkus = [...lstSkuObjects];
7480
7759
  }
7760
+ if (lstSkus && lstSkus.length > 0) {
7761
+ for (const item of lstSkus) {
7762
+ if (item && item.type === PublicationDataType.CALLOUT) {
7763
+ const cGuid = item.publicationDataCallout ||
7764
+ item.PublicationDataCallout;
7765
+ const needForce = !this.DataSheet.preview;
7766
+ if (cGuid && (!this.DataSheet.callouts?.[cGuid] || needForce)) {
7767
+ let loaded = [];
7768
+ if (this.dataSheetsController) {
7769
+ loaded = await this.dataSheetsController.updateCalloutsList(cGuid, needForce);
7770
+ }
7771
+ if (!this.DataSheet.callouts)
7772
+ this.DataSheet.callouts = {};
7773
+ this.DataSheet.callouts[cGuid] = loaded;
7774
+ }
7775
+ }
7776
+ }
7777
+ }
7481
7778
  files = await this.DataSheetSVG.GenerateSvgFiles(lstSkus, backgroundTplLeft, backgroundTplRight, section.pageId.toString());
7482
7779
  lstBackgroundTags = [];
7483
7780
  }
@@ -7487,7 +7784,7 @@ class DataSheetPublication {
7487
7784
  return arrayFiles;
7488
7785
  }
7489
7786
  catch (e) {
7490
- console.log('[ERROR] Error in GenerateAllInOneExportFilePublication:', e);
7787
+ console.error('[ERROR] Error in GenerateAllInOneExportFilePublication:', e);
7491
7788
  return null;
7492
7789
  }
7493
7790
  }
@@ -7657,18 +7954,29 @@ class DataSheetController {
7657
7954
  }
7658
7955
  let publication = null;
7659
7956
  let templateGuid = '00000000-0000-0000-0000-000000000000';
7660
- if (source == 2) {
7957
+ if (source == 2 || source == 7) {
7958
+ const pubGuid = source == 2 ? json.sourceGuid : json.publicationGuid;
7661
7959
  publication = json.publication;
7662
7960
  if (publication == null || publication == undefined) {
7663
- const res = await this._publicationsService
7664
- .getPublication(json.sourceGuid)
7665
- .toPromise();
7666
- publication = res?.['publication'];
7961
+ try {
7962
+ const res = await this._publicationsService
7963
+ .getPublication(pubGuid)
7964
+ .toPromise();
7965
+ publication = res?.['publication'];
7966
+ }
7967
+ catch (e) {
7968
+ console.error('Error fetching publication info for datasheet generation:', e);
7969
+ }
7667
7970
  }
7668
7971
  if (publication) {
7669
- dataSheet.currentObjectName = publication.publicationName;
7670
- startPageNumber = publication.startPageNumber || 1;
7671
- dataSheet.leftPage = publication.publicationPageStartLeft === true;
7972
+ if (!dataSheet.productSheetGuid && (publication.publicationProductSheetAssetGuid || publication.publicationproductsheetassetguid)) {
7973
+ dataSheet.productSheetGuid = publication.publicationProductSheetAssetGuid || publication.publicationproductsheetassetguid;
7974
+ }
7975
+ if (source == 2) {
7976
+ dataSheet.currentObjectName = publication.publicationName;
7977
+ startPageNumber = publication.startPageNumber || 1;
7978
+ dataSheet.leftPage = publication.publicationPageStartLeft === true;
7979
+ }
7672
7980
  if (dataSheet.language == null ||
7673
7981
  dataSheet.language === '' ||
7674
7982
  dataSheet.language === undefined) {
@@ -7687,16 +7995,21 @@ class DataSheetController {
7687
7995
  dataSheet.priceListGuid = '00000000-0000-0000-0000-000000000000';
7688
7996
  }
7689
7997
  }
7998
+ if (publication.publicationTemplateGuid) {
7999
+ templateGuid = publication.publicationTemplateGuid;
8000
+ }
8001
+ const pubPages = publication.publicationPages || publication.PublicationPages || publication._publicationPages || [];
8002
+ if ((!dataSheet.pagesSettings || dataSheet.pagesSettings.length === 0) && pubPages.length > 0) {
8003
+ dataSheet.pagesSettings = pubPages.map((page) => ({
8004
+ backgroundGuid: page.background || page.publicationpagebackground || page.backgroundGuid,
8005
+ gabaritGuid: page.gabarit || page.publicationpagedefaultgabarit || page.gabaritGuid,
8006
+ order: page.order || page.publicationpageorder || 0
8007
+ }));
8008
+ }
7690
8009
  }
7691
- // Template
7692
- templateGuid =
7693
- publication.publicationTemplateGuid ||
7694
- '00000000-0000-0000-0000-000000000000';
7695
8010
  }
7696
- else {
7697
- if (json.templateGuid) {
7698
- templateGuid = json.templateGuid;
7699
- }
8011
+ if (json.templateGuid) {
8012
+ templateGuid = json.templateGuid;
7700
8013
  }
7701
8014
  dataSheet.publicationTemplateTemplateGuid = templateGuid;
7702
8015
  if (dataSheet.defaultGabaritGuid == null ||
@@ -7735,12 +8048,14 @@ class DataSheetController {
7735
8048
  if (dataSheet.gabarits == null ||
7736
8049
  dataSheet.gabarits == undefined ||
7737
8050
  dataSheet.gabarits.length === 0) {
8051
+ console.error('[DATASHEET-GENERATION][ERROR] Gabarits is empty for templateGuid:', templateGuid);
7738
8052
  dataSheet.currentStep = 99;
7739
8053
  return [];
7740
8054
  }
7741
8055
  if (dataSheet.backgrounds == null ||
7742
8056
  dataSheet.backgrounds == undefined ||
7743
8057
  dataSheet.backgrounds.length === 0) {
8058
+ console.error('[DATASHEET-GENERATION][ERROR] Backgrounds is empty for templateGuid:', templateGuid);
7744
8059
  dataSheet.currentStep = 99;
7745
8060
  return [];
7746
8061
  }
@@ -7803,6 +8118,7 @@ class DataSheetController {
7803
8118
  case 2: // Publication
7804
8119
  //console.log("Generate SVG for publication");
7805
8120
  let dataSheetPublication = new DataSheetPublication(dataSheetSVG, dataSheet, publication, json.sectionActiveObject, json.skusSection);
8121
+ dataSheetPublication.setDataSheetsController(this);
7806
8122
  dataSheetPublication.setPublicationsService(this._publicationsService);
7807
8123
  dataSheetPublication.setDamAssetsService(this._damAssets);
7808
8124
  dataSheetPublication.setDocumentsService(this._documents);
@@ -7812,14 +8128,23 @@ class DataSheetController {
7812
8128
  case 3: // SKUs
7813
8129
  //console.log('Generate SVG for SKUs');
7814
8130
  let dataSheetSku = new DataSheetSku(dataSheetSVG, dataSheet);
8131
+ dataSheetSku.setDataSheetsController(this);
7815
8132
  dataSheetSku.setPublicationsService(this._publicationsService);
7816
8133
  files = await dataSheetSku.GenerateAllInOneExportFile(json.sourceGuid, json.option1PerPage, displayModeVariant, json.multiColumns);
7817
8134
  dataSheetSku = null;
7818
8135
  break;
8136
+ case 7: // Datasheet (Publication Datasheet SKU)
8137
+ let dataSheet7 = new DataSheetSku(dataSheetSVG, dataSheet);
8138
+ dataSheet7.setDataSheetsController(this);
8139
+ dataSheet7.setPublicationsService(this._publicationsService);
8140
+ files = await dataSheet7.GenerateAllInOneExportFile(json.sourceGuid, json.option1PerPage, displayModeVariant, json.multiColumns);
8141
+ dataSheet7 = null;
8142
+ break;
7819
8143
  case 4: // Variants
7820
8144
  for (let sourceGuid of sourceGuids) {
7821
8145
  dataSheet.progress = 25;
7822
8146
  let dataSheetSku = new DataSheetSku(dataSheetSVG, dataSheet);
8147
+ dataSheetSku.setDataSheetsController(this);
7823
8148
  dataSheetSku.setPublicationsService(this._publicationsService);
7824
8149
  let files2 = await dataSheetSku.GenerateAllInOneExportFile(sourceGuid, json.option1PerPage, displayModeVariant, json.multiColumns);
7825
8150
  dataSheetSku = null;
@@ -7834,7 +8159,7 @@ class DataSheetController {
7834
8159
  dataSheet.currentStep = 3;
7835
8160
  if (files == null || files == undefined || files.length === 0) {
7836
8161
  dataSheet.currentStep = 99;
7837
- console.log('[ERROR] Files is null or undefined or empty');
8162
+ console.error('[ERROR] Files is null or undefined or empty');
7838
8163
  return [];
7839
8164
  }
7840
8165
  if (dataSheet.preview) {
@@ -7978,6 +8303,29 @@ class DataSheetController {
7978
8303
  return [];
7979
8304
  }
7980
8305
  }
8306
+ async updateCalloutsList(templateGuid, forceRefresh = false) {
8307
+ const singleton = DataSheetSingleton.getInstance();
8308
+ const cached = singleton.getCallouts(templateGuid);
8309
+ if (!forceRefresh && cached && cached.length > 0) {
8310
+ return cached;
8311
+ }
8312
+ try {
8313
+ const res = await this._publicationsTemplates
8314
+ .getTemplateCallouts(templateGuid)
8315
+ .toPromise();
8316
+ const rawCallouts = res?.['callouts'] ||
8317
+ res?.['productBlocks'] ||
8318
+ res ||
8319
+ [];
8320
+ const callouts = await this.loadGabaritsSvg(Array.isArray(rawCallouts) ? rawCallouts : []);
8321
+ singleton.setCallouts(templateGuid, callouts);
8322
+ return callouts;
8323
+ }
8324
+ catch (e) {
8325
+ console.error('Erreur dans updateCalloutsList :', e);
8326
+ return [];
8327
+ }
8328
+ }
7981
8329
  async updateBackgroundsList(templateGuid, forceRefresh = false) {
7982
8330
  const singleton = DataSheetSingleton.getInstance();
7983
8331
  const cached = singleton.getBackgrounds(templateGuid);
@@ -8048,6 +8396,9 @@ class DataSheetController {
8048
8396
  return [];
8049
8397
  }
8050
8398
  }
8399
+ clearTemplatesCache(templateGuid) {
8400
+ DataSheetSingleton.getInstance().clearTemplatesCache(templateGuid);
8401
+ }
8051
8402
  async loadGabaritsSvg(gabarits) {
8052
8403
  const loadedGabarits = [];
8053
8404
  for (let template of gabarits) {