fix "copy image to clipboard" button

This commit is contained in:
azivner 2018-11-19 12:12:58 +01:00
parent 30249a353e
commit 77a89d85c8
2 changed files with 7 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import infoService from "./info.js";
import server from "./server.js"; import server from "./server.js";
const $component = $('#note-detail-image'); const $component = $('#note-detail-image');
const $imageWrapper = $('#note-detail-image-wrapper');
const $imageView = $('#note-detail-image-view'); const $imageView = $('#note-detail-image-view');
const $imageDownloadButton = $("#image-download"); const $imageDownloadButton = $("#image-download");
@ -39,10 +40,10 @@ function selectImage(element) {
} }
$copyToClipboardButton.click(() => { $copyToClipboardButton.click(() => {
$component.attr('contenteditable','true'); $imageWrapper.attr('contenteditable','true');
try { try {
selectImage($component.get(0)); selectImage($imageWrapper.get(0));
const success = document.execCommand('copy'); const success = document.execCommand('copy');
@ -55,7 +56,7 @@ $copyToClipboardButton.click(() => {
} }
finally { finally {
window.getSelection().removeAllRanges(); window.getSelection().removeAllRanges();
$component.removeAttr('contenteditable'); $imageWrapper.removeAttr('contenteditable');
} }
}); });

View File

@ -22,5 +22,7 @@
<br/><br/> <br/><br/>
<div id="note-detail-image-wrapper">
<img id="note-detail-image-view" /> <img id="note-detail-image-view" />
</div>
</div> </div>