()
| 201 | } |
| 202 | |
| 203 | apply() { |
| 204 | const origBorder = this.input.style.border; |
| 205 | const origOutline = this.input.style.outline; |
| 206 | const scale = this.main.getScale(); |
| 207 | |
| 208 | this.input.style.border = 'none'; |
| 209 | const domToImageConfig = { |
| 210 | style: { |
| 211 | 'transform-origin': 'top left', |
| 212 | transform: `scale(${scale})`, |
| 213 | 'overflow-wrap': 'break-word', |
| 214 | 'word-wrap': 'break-word', |
| 215 | 'white-space': 'pre-wrap', |
| 216 | overflow: 'hidden', |
| 217 | width: this.input.clientWidth + 'px', |
| 218 | height: this.input.clientHeight + 'px', |
| 219 | }, |
| 220 | width: this.input.clientWidth * (scale < 1 ? (1 / scale) : scale), |
| 221 | height: this.input.clientHeight * (scale < 1 ? (1 / scale) : scale), |
| 222 | }; |
| 223 | domtoimage.toPng(this.input, domToImageConfig) |
| 224 | .then((dataUrl) => { |
| 225 | const img = new Image(); |
| 226 | img.src = dataUrl; |
| 227 | img.onload = () => { |
| 228 | this.ctx.drawImage(img, this.scaledCord[0], this.scaledCord[1]); |
| 229 | this.input.style.border = origBorder; |
| 230 | this.input.style.outline = origOutline; |
| 231 | this.close(); |
| 232 | this.main.worklog.captureState(); |
| 233 | this.main.closeActiveTool(); |
| 234 | }; |
| 235 | }) |
| 236 | .catch(function (error) { |
| 237 | console.error('oops, something went wrong!', error); |
| 238 | }); |
| 239 | } |
| 240 | |
| 241 | close() { |
| 242 | this.active = false; |
no test coverage detected