Skip to content

Commit c0d3da7

Browse files
committed
Format assets.
1 parent 6637652 commit c0d3da7

File tree

2 files changed

+48
-45
lines changed

2 files changed

+48
-45
lines changed

assets/packs/mermaid/main.css

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#contents button#download {
2+
position: absolute;
3+
display: none;
4+
}
5+
6+
#contents:hover button#download {
7+
display: inline;
8+
right: 0;
9+
}
10+
111
#figure {
212
display: flex;
313
flex-direction: column;
@@ -6,22 +16,11 @@
616
}
717

818
#figure figcaption {
9-
border-radius: .5rem;
19+
border-radius: 0.5rem;
1020
background-color: rgb(240 245 249);
1121
padding: 0.5rem;
12-
font-size: .875rem;
22+
font-size: 0.875rem;
1323
line-height: 1.25rem;
1424
font-weight: 500;
1525
color: rgb(97 117 138);
1626
}
17-
18-
#contents button#download {
19-
position: absolute;
20-
display: none;
21-
}
22-
23-
#contents:hover button#download {
24-
display: inline;
25-
right: 0;
26-
}
27-

assets/packs/mermaid/main.js

+36-32
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,60 @@ import "./main.css";
33

44
mermaid.initialize({ startOnLoad: false });
55

6-
export function init(ctx, {diagram, caption, download}) {
7-
ctx.importCSS("main.css")
8-
6+
export function init(ctx, { diagram, caption, download }) {
7+
ctx.importCSS("main.css");
8+
99
function render() {
1010
mermaid.render("diagram", diagram).then(({ svg, bindFunctions }) => {
1111
// Fix for: https://github.com/mermaid-js/mermaid/issues/1766
12-
const renderedSvg = svg.replace(/<br>/gi, "<br />")
13-
12+
const renderedSvg = svg.replace(/<br>/gi, "<br />");
13+
1414
let contents = document.createElement("div");
1515
contents.id = "contents";
1616
ctx.root.appendChild(contents);
17-
17+
1818
let figure = document.createElement("figure");
1919
figure.id = "figure";
2020
figure.innerHTML = renderedSvg;
2121
contents.appendChild(figure);
22-
22+
2323
if (caption) {
2424
let figcaption = document.createElement("figcaption");
2525
figcaption.textContent = caption;
2626
figure.appendChild(figcaption);
2727
}
28-
28+
2929
if (download) {
3030
let downloadButton = document.createElement("button");
31-
downloadButton.id = "download"
32-
downloadButton.title = `Download ${download.title}`
33-
downloadButton.textContent = "⇩"
31+
downloadButton.id = "download";
32+
downloadButton.title = `Download ${download.title}`;
33+
downloadButton.textContent = "⇩";
3434
contents.prepend(downloadButton);
35-
36-
contents.querySelector("#download").addEventListener("click", (event) => {
37-
var downloadData = [];
38-
downloadData.push(renderedSvg);
39-
const downloadBlob = URL.createObjectURL(new Blob(downloadData, {type: "image/svg+xml"}));
40-
41-
const downloadLink = document.createElement("a");
42-
downloadLink.href = downloadBlob;
43-
downloadLink.download = download.filename;
44-
contents.appendChild(downloadLink);
45-
46-
downloadLink.dispatchEvent(
47-
new MouseEvent('click', {
48-
bubbles: true,
49-
cancelable: true,
50-
view: window
51-
})
52-
);
53-
54-
contents.removeChild(downloadLink);
55-
});
35+
36+
contents
37+
.querySelector("#download")
38+
.addEventListener("click", (event) => {
39+
var downloadData = [];
40+
downloadData.push(renderedSvg);
41+
const downloadBlob = URL.createObjectURL(
42+
new Blob(downloadData, { type: "image/svg+xml" })
43+
);
44+
45+
const downloadLink = document.createElement("a");
46+
downloadLink.href = downloadBlob;
47+
downloadLink.download = download.filename;
48+
contents.appendChild(downloadLink);
49+
50+
downloadLink.dispatchEvent(
51+
new MouseEvent("click", {
52+
bubbles: true,
53+
cancelable: true,
54+
view: window,
55+
})
56+
);
57+
58+
contents.removeChild(downloadLink);
59+
});
5660
}
5761

5862
if (bindFunctions) {

0 commit comments

Comments
 (0)