@esfaenza/extensions 11.2.45 → 11.2.48

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.
@@ -462,7 +462,27 @@
462
462
  "Error during Clipboard content copy operation": {
463
463
  'en-US': "Error during Clipboard content copy operation",
464
464
  'it-IT': "Errore nella scrittura del contenuto nella Clipboard"
465
- }
465
+ },
466
+ "Please insert your clipboard content": {
467
+ 'en-US': "Please insert your clipboard content",
468
+ 'it-IT': "Si prega di incollare il contenuto della Clipboard"
469
+ },
470
+ "User input required": {
471
+ 'en-US': "User input required",
472
+ 'it-IT': "Richiesto Input utente"
473
+ },
474
+ "Your current browser does not support reading from the clipboard directly. Please paste your clipboard's content in this Input field and confirm the operation": {
475
+ 'en-US': "Your current browser does not support reading from the clipboard directly. Please paste your clipboard's content in this Input field and confirm the operation",
476
+ 'it-IT': "Il browser corrente non supporta la lettura diretta dei dati della Clipboard, si prega di effettuare un'incolla (CTRL + V) nella casella di testo e confermare l'operazione"
477
+ },
478
+ "Confirm": {
479
+ 'en-US': "Confirm",
480
+ 'it-IT': "Conferma"
481
+ },
482
+ "Cancel": {
483
+ 'en-US': "Cancel",
484
+ 'it-IT': "Annulla"
485
+ },
466
486
  };
467
487
  }
468
488
  /**
@@ -474,21 +494,40 @@
474
494
  */
475
495
  ClipboardService.prototype.getClipboard = function (style, valueFoundCallback) {
476
496
  var _this = this;
477
- var _a;
497
+ var _a, _b, _c, _d;
478
498
  if (navigator.userAgent.indexOf("Firefox") != -1) {
479
- //https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText
480
- this.msgService.simpleError(this.loc["Unfortunately Firefox doesn't yet support direct Clipboard access if not via extensions, Please use Chrome to do this operation"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT']);
499
+ swal__default['default'].fire({
500
+ title: this.loc["User input required"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'],
501
+ text: this.loc["Your current browser does not support reading from the clipboard directly. Please paste your clipboard's content in this Input field and confirm the operation"][(_b = this.LOCALE) !== null && _b !== void 0 ? _b : 'it-IT'],
502
+ input: 'textarea',
503
+ icon: "warning",
504
+ confirmButtonText: this.loc["Confirm"][(_c = this.LOCALE) !== null && _c !== void 0 ? _c : 'it-IT'],
505
+ cancelButtonText: this.loc["Cancel"][(_d = this.LOCALE) !== null && _d !== void 0 ? _d : 'it-IT'],
506
+ showCancelButton: true,
507
+ customClass: {
508
+ confirmButton: "btn btn-primary",
509
+ cancelButton: "btn btn-secondary app-margin-right-15",
510
+ container: "app-wrap",
511
+ },
512
+ reverseButtons: true,
513
+ allowOutsideClick: false,
514
+ inputValidator: function (value) {
515
+ var _a;
516
+ if (!value)
517
+ return _this.loc["Please insert your clipboard content"][(_a = _this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'];
518
+ }
519
+ }).then(function (t) {
520
+ if (t.isConfirmed) {
521
+ console.log("[@esfaenza/extensions] Retrieving input data from user input");
522
+ _this.doClipboardDataGet(t.value, style, valueFoundCallback);
523
+ }
524
+ });
481
525
  return;
482
526
  }
483
527
  if (window.clipboardData) {
484
528
  console.log("[@esfaenza/extensions] Found clipboardData");
485
529
  var data = window.clipboardData.getData("Text");
486
- console.log("[@esfaenza/extensions] Retrieved clipboard values: " + data);
487
- var value = style == "array" ? this.getClipboardLines(data) :
488
- style == "matrix" ? this.getClipboardMatrix(data) : [];
489
- console.log("[@esfaenza/extensions] Adapted for " + style + ": " + JSON.stringify(value));
490
- if (valueFoundCallback)
491
- valueFoundCallback(value);
530
+ this.doClipboardDataGet(data, style, valueFoundCallback);
492
531
  }
493
532
  else if (window.navigator.clipboard) {
494
533
  console.log("[@esfaenza/extensions] Found navigator clipboard");
@@ -501,21 +540,20 @@
501
540
  }
502
541
  console.log("[@esfaenza/extensions] Clipboard permission granted, retrieving values");
503
542
  window.navigator.clipboard.readText()
504
- .then(function (t) {
505
- console.log("[@esfaenza/extensions] Retrieved clipboard values: " + t);
506
- var value = style == "array" ? _this.getClipboardLines(t) :
507
- style == "matrix" ? _this.getClipboardMatrix(t) : [];
508
- console.log("[@esfaenza/extensions] Adapted for " + style + ": " + JSON.stringify(value));
509
- if (valueFoundCallback)
510
- valueFoundCallback(value);
511
- })
512
- .catch(function (err) {
513
- var _a;
514
- _this.msgService.simpleError(_this.loc["Error during Clipboard content read operation"][(_a = _this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'] + ": " + err);
515
- });
543
+ .then(function (t) { return _this.doClipboardDataGet(t, style, valueFoundCallback); })
544
+ .catch(function (err) { var _a; return _this.msgService.simpleError(_this.loc["Error during Clipboard content read operation"][(_a = _this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'] + ": " + err); });
516
545
  });
517
546
  }
518
547
  };
548
+ /** @ignore */
549
+ ClipboardService.prototype.doClipboardDataGet = function (clipboardText, style, valueFoundCallback) {
550
+ console.log("[@esfaenza/extensions] Retrieved clipboard values: " + clipboardText);
551
+ var value = style == "array" ? this.getClipboardLines(clipboardText) :
552
+ style == "matrix" ? this.getClipboardMatrix(clipboardText) : [];
553
+ console.log("[@esfaenza/extensions] Adapted for " + style + ": " + JSON.stringify(value));
554
+ if (valueFoundCallback)
555
+ valueFoundCallback(value);
556
+ };
519
557
  /**
520
558
  * Ottiene il contenuto della clipboard diviso per righe (separate da newline)
521
559
  *
@@ -524,7 +562,10 @@
524
562
  * @returns {string[]} Array contenente il testo preso dalla clipboard diviso per riga
525
563
  */
526
564
  ClipboardService.prototype.getClipboardLines = function (data) {
527
- return data.trim().split("\r\n");
565
+ var trimmedData = data.trim();
566
+ if (!trimmedData.includes("\r\n") && trimmedData.includes("\n"))
567
+ return trimmedData.split("\n");
568
+ return trimmedData.split("\r\n");
528
569
  };
529
570
  /**
530
571
  * Ottiene il contenuto della clipboard diviso per righe (separate da newline) e colonne (separate da tab)
@@ -535,7 +576,7 @@
535
576
  */
536
577
  ClipboardService.prototype.getClipboardMatrix = function (data) {
537
578
  var ret = [];
538
- var rows = data.split("\r\n");
579
+ var rows = !data.includes("\r\n") && data.includes("\n") ? data.split("\n") : data.split("\r\n");
539
580
  // A quanto pare ogni valore è separato da un \t... spero che sia uno standard di quando si copia da excel altrimenti ciao
540
581
  for (var i = 0; i < rows.length; i++)
541
582
  ret.push(rows[i].split('\t').map(function (t) { return t.trim(); }));