Commit d30c2c70 authored by taco@waag.org's avatar taco@waag.org
Browse files

copy img fragment

parent 55de3b2d
......@@ -37,7 +37,6 @@ if (window.hasRun) {
}
}
//renders a copybutton for the fragment
function appendCopyButton(fragment, type, message, signature){
let button = document.createElement('button');
......@@ -48,13 +47,20 @@ if (window.hasRun) {
fragment.appendChild(button);
}
//creates a blockquote for the message that contains the signature as attribute
//creates a blockquote (or img) for the message that contains the signature as attribute
function toClipboard(message,signature,type){
let serialized = btoa(JSON.stringify(signature));
let blockquote = document.createElement('blockquote');
blockquote.textContent = message;
blockquote.setAttribute(type,serialized);
navigator.clipboard.writeText(blockquote.outerHTML);
if(type == 'data-pop-v0-img'){
let img = document.createElement('img');
img.src = message;
img.setAttribute(type,serialized);
navigator.clipboard.writeText(img.outerHTML);
} else {
let blockquote = document.createElement('blockquote');
blockquote.textContent = message;
blockquote.setAttribute(type,serialized);
navigator.clipboard.writeText(blockquote.outerHTML);
}
alert('Copied to clipboard');
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment