pushfeedback 0.0.9 → 0.0.10

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,5 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
- import domtoimage from 'dom-to-image';
2
+ import html2canvas from 'html2canvas';
3
3
  export class FeedbackModal {
4
4
  constructor() {
5
5
  this.handleSubmit = async (event) => {
@@ -8,14 +8,6 @@ export class FeedbackModal {
8
8
  this.showScreenshotMode = false;
9
9
  this.showModal = false;
10
10
  this.sending = true;
11
- let encodedScreenshot = "";
12
- if (this.encodedScreenshot) {
13
- await this.encodedScreenshot.then((data) => {
14
- encodedScreenshot = data;
15
- }).catch((error) => {
16
- console.log(error);
17
- });
18
- }
19
11
  try {
20
12
  const res = await fetch('https://app.pushfeedback.com/api/feedback/', {
21
13
  method: 'POST',
@@ -24,7 +16,7 @@ export class FeedbackModal {
24
16
  message: this.formMessage,
25
17
  email: this.formEmail,
26
18
  project: this.project,
27
- screenshot: encodedScreenshot
19
+ screenshot: this.encodedScreenshot
28
20
  }),
29
21
  headers: {
30
22
  'Content-Type': 'application/json'
@@ -130,27 +122,26 @@ export class FeedbackModal {
130
122
  };
131
123
  this.handleMouseClickedSelectedElement = (event) => {
132
124
  event.preventDefault();
133
- if (this.elementSelected)
125
+ if (this.elementSelected) {
134
126
  this.elementSelected.classList.add('feedback-modal-element-selected');
127
+ }
135
128
  let top = this.elementSelected.getBoundingClientRect().top;
136
- this.elementSelected.style.top = `${top + window.pageYOffset}px`;
129
+ this.elementSelected.style.top = `${top + window.scrollY}px`;
137
130
  const clonedElementSelected = this.elementSelected.cloneNode(true);
138
131
  document.body.appendChild(clonedElementSelected);
139
132
  this.elementSelected.style.top = `${top}px`;
140
- this.encodedScreenshot = domtoimage.toPng(document.body, { cacheBust: true })
141
- .then(function (dataUrl) {
133
+ html2canvas(document.body).then((canvas) => {
134
+ this.encodedScreenshot = canvas.toDataURL();
142
135
  document.body.removeChild(clonedElementSelected);
143
- return dataUrl;
144
- })
145
- .catch(function (error) {
136
+ const page = document.getElementsByTagName('html')[0];
137
+ page.style.overflow = 'hidden';
138
+ this.hasSelectedElement = true;
139
+ this.overlay.style.display = 'block';
140
+ this.showModal = true;
141
+ }).catch((error) => {
146
142
  console.log(error);
147
143
  return "";
148
144
  });
149
- const page = document.getElementsByTagName('html')[0];
150
- page.style.overflow = 'hidden';
151
- this.hasSelectedElement = true;
152
- this.overlay.style.display = 'block';
153
- this.showModal = true;
154
145
  };
155
146
  this.sending = false;
156
147
  this.formMessage = '';