-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdom2image.js
More file actions
33 lines (30 loc) · 874 Bytes
/
dom2image.js
File metadata and controls
33 lines (30 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { snapdom } from './lib/snapdom.min.mjs'
export async function getUrl(selector, options = {}) {
let data = null;
const el = document.querySelector(selector);
if (el) {
const result = await snapdom(el, options);
data = result.url;
}
return data;
}
export async function getStream(selector, options = {}) {
let data = null;
const el = document.querySelector(selector);
if (el) {
const result = await snapdom(el, options);
data = result.toBlob();
}
return data;
}
export async function downloadAsync(selector, filename, format, backgroundColor, options) {
const el = document.querySelector(selector);
if (el) {
const result = await snapdom(el, options);
await result.download({
format,
filename,
backgroundColor
});
}
}