@hivegpt/hiveai-angular 0.0.234 → 0.0.235

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.
@@ -1483,36 +1483,39 @@
1483
1483
  // }, 2000); // Reset after 2 seconds
1484
1484
  // });
1485
1485
  // }
1486
+ ChatDrawerComponent.prototype.convertHTMLToPlainText = function (html) {
1487
+ // Create a temporary DOM element to hold the HTML content
1488
+ var tempElement = document.createElement('div');
1489
+ tempElement.innerHTML = html;
1490
+ // Replace <br> tags with newlines
1491
+ tempElement.querySelectorAll('br').forEach(function (br) { return br.replaceWith('\n'); });
1492
+ // Add newlines before and after block elements (like <p>)
1493
+ tempElement.querySelectorAll('p').forEach(function (p) {
1494
+ var _a;
1495
+ var lineBreakBefore = document.createTextNode('\n');
1496
+ var lineBreakAfter = document.createTextNode('\n');
1497
+ (_a = p.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(lineBreakBefore, p);
1498
+ p.appendChild(lineBreakAfter);
1499
+ });
1500
+ // Get the plain text content
1501
+ var plainText = tempElement.innerText;
1502
+ return plainText.trim(); // Trim to remove any leading or trailing whitespace/newlines
1503
+ };
1486
1504
  ChatDrawerComponent.prototype.handleCopyClick = function (index) {
1487
1505
  var _this = this;
1488
1506
  // Copy the message to the clipboard
1489
1507
  var contentToCopy = this.chatLog[index].message;
1490
- var textArea = document.createElement('textarea');
1491
- textArea.style.position = 'fixed';
1492
- textArea.style.opacity = '0';
1493
- textArea.value = contentToCopy;
1494
- // Append the textarea to the body
1495
- document.body.appendChild(textArea);
1496
- // Select the content and copy it to the clipboard
1497
- textArea.select();
1498
- document.execCommand('copy');
1499
- this.chatLog[index].copied = true;
1500
- this.cdr.detectChanges();
1501
- // Reset the copied state after a delay
1502
- setTimeout(function () {
1503
- _this.chatLog[index].copied = false;
1508
+ var resutlt = this.convertHTMLToPlainText(contentToCopy);
1509
+ navigator.clipboard.writeText(resutlt).then(function () {
1510
+ // Indicate that the message was copied
1511
+ _this.chatLog[index].copied = true;
1504
1512
  _this.cdr.detectChanges();
1505
- }, 2000); // Reset after 2 seconds
1506
- // navigator.clipboard.writeText(contentToCopy).then(() => {
1507
- // // Indicate that the message was copied
1508
- // this.chatLog[index].copied = true;
1509
- // this.cdr.detectChanges();
1510
- // // Reset the copied state after a delay
1511
- // setTimeout(() => {
1512
- // this.chatLog[index].copied = false;
1513
- // this.cdr.detectChanges();
1514
- // }, 2000); // Reset after 2 seconds
1515
- // });
1513
+ // Reset the copied state after a delay
1514
+ setTimeout(function () {
1515
+ _this.chatLog[index].copied = false;
1516
+ _this.cdr.detectChanges();
1517
+ }, 2000); // Reset after 2 seconds
1518
+ });
1516
1519
  };
1517
1520
  ChatDrawerComponent.prototype.scrollToBottom = function () {
1518
1521
  var _this = this;