next-blurhash-previews 0.0.3-beta45 → 0.0.3-beta48
Sign up to get free protection for your applications and to get access to all the features.
package/bin/remark-plugin.js
CHANGED
@@ -10,7 +10,7 @@ export const blurhashPlugin = publicPath => () => {
|
|
10
10
|
let outstanding = 0;
|
11
11
|
|
12
12
|
visitParents(tree, "image", async (node, ancestors) => {
|
13
|
-
let { url: imagePath, alt } = node;
|
13
|
+
let { url: imagePath, alt = "" } = node;
|
14
14
|
|
15
15
|
const originalImg = imagePath;
|
16
16
|
if (!/http/.test(imagePath)) {
|
@@ -28,6 +28,8 @@ export const blurhashPlugin = publicPath => () => {
|
|
28
28
|
|
29
29
|
const blurHash = await getBlurhash(imagePath);
|
30
30
|
|
31
|
+
const { w, h } = blurHash;
|
32
|
+
|
31
33
|
console.log(
|
32
34
|
colors.green(`Finished processing ${imagePath}\n\t`, blurHash)
|
33
35
|
);
|
@@ -37,7 +39,7 @@ export const blurhashPlugin = publicPath => () => {
|
|
37
39
|
|
38
40
|
const newNode = `
|
39
41
|
<blurhash-image url="${originalImg}" preview='${JSON.stringify(blurHash)}'>
|
40
|
-
<img alt="${alt
|
42
|
+
<img alt="${alt}" width="${w}" src="${originalImg}" slot="image" />
|
41
43
|
<canvas width="${blurHash.w}" height="${blurHash.h}" slot="preview"></canvas>
|
42
44
|
</blurhash-image>`.trim();
|
43
45
|
|
@@ -53,7 +53,9 @@ class ImageWithPreview extends HTMLElement {
|
|
53
53
|
}
|
54
54
|
|
55
55
|
#imgLoad = () => {
|
56
|
-
|
56
|
+
setTimeout(() => {
|
57
|
+
this.sd.innerHTML = `<slot name="image"></slot>`;
|
58
|
+
}, 19000);
|
57
59
|
};
|
58
60
|
|
59
61
|
attributeChangedCallback(name) {
|
package/imagePreviewBootstrap.js
CHANGED
@@ -44,7 +44,9 @@ class ImageWithPreview extends HTMLElement {
|
|
44
44
|
}
|
45
45
|
}
|
46
46
|
#imgLoad = () => {
|
47
|
-
|
47
|
+
setTimeout(() => {
|
48
|
+
this.sd.innerHTML = \`<slot name="image"></slot>\`;
|
49
|
+
}, 19e3);
|
48
50
|
};
|
49
51
|
attributeChangedCallback(name) {
|
50
52
|
if (this.#canvasEl && name === "preview") {
|