comark-ui 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-Bjd6VcGQ.mjs +241 -0
- package/dist/client.d.mts +11 -1
- package/dist/client.mjs +3 -26
- package/dist/html.d.mts +7 -1
- package/dist/html.mjs +26 -8
- package/dist/{index-B0YvApci.d.mts → index-jkwx6SyG.d.mts} +4 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.mjs +18 -4
- package/dist/skills/comark-ui/SKILL.md +1 -1
- package/dist/skills/comark-ui/references/diagrams.md +7 -1
- package/dist/skills/comark-ui/references/outline.md +9 -1
- package/dist/svelte/Mermaid.svelte +16 -0
- package/dist/svelte/index.js +3 -7
- package/dist/{typeset-css-DPB0S1bV.mjs → typeset-css-5aJ7cSmh.mjs} +14 -0
- package/dist/vue.d.mts +1 -1
- package/dist/vue.mjs +31 -4
- package/package.json +44 -44
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { theme } from "comark-zoom/theme";
|
|
2
|
+
//#region src/script.ts
|
|
3
|
+
/**
|
|
4
|
+
* Starts the Copy image and Copy source buttons of every `.cmm` Mermaid diagram on the page and returns a function that
|
|
5
|
+
* stops them. Every caller shares one set of listeners, which stop with the last caller. The function is
|
|
6
|
+
* self-contained: the HTML renderer inlines its source as a script, so it must not use anything from outside its body.
|
|
7
|
+
*/
|
|
8
|
+
function start() {
|
|
9
|
+
const running = window.__comarkMermaid;
|
|
10
|
+
if (running) {
|
|
11
|
+
running.users++;
|
|
12
|
+
return running.stop;
|
|
13
|
+
}
|
|
14
|
+
const listeners = new AbortController();
|
|
15
|
+
const signal = listeners.signal;
|
|
16
|
+
document.documentElement.setAttribute("data-mermaid-ready", "");
|
|
17
|
+
const links = /* @__PURE__ */ new Set();
|
|
18
|
+
const PROPERTIES = [
|
|
19
|
+
"fill",
|
|
20
|
+
"fill-opacity",
|
|
21
|
+
"stroke",
|
|
22
|
+
"stroke-opacity",
|
|
23
|
+
"stroke-width",
|
|
24
|
+
"stroke-dasharray",
|
|
25
|
+
"stroke-linecap",
|
|
26
|
+
"stroke-linejoin",
|
|
27
|
+
"opacity",
|
|
28
|
+
"color",
|
|
29
|
+
"rx",
|
|
30
|
+
"ry",
|
|
31
|
+
"font-family",
|
|
32
|
+
"font-size",
|
|
33
|
+
"font-weight",
|
|
34
|
+
"font-style",
|
|
35
|
+
"letter-spacing",
|
|
36
|
+
"text-anchor",
|
|
37
|
+
"dominant-baseline",
|
|
38
|
+
"paint-order"
|
|
39
|
+
];
|
|
40
|
+
function background(from) {
|
|
41
|
+
const probe = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
|
|
42
|
+
for (let at = from; at && probe; at = at.parentElement) {
|
|
43
|
+
const color = getComputedStyle(at).backgroundColor;
|
|
44
|
+
probe.clearRect(0, 0, 1, 1);
|
|
45
|
+
probe.fillStyle = color;
|
|
46
|
+
probe.fillRect(0, 0, 1, 1);
|
|
47
|
+
if (probe.getImageData(0, 0, 1, 1).data[3] === 255) return color;
|
|
48
|
+
}
|
|
49
|
+
return "#fff";
|
|
50
|
+
}
|
|
51
|
+
function png(root) {
|
|
52
|
+
const svg = root.querySelector(".pele-diagram>svg");
|
|
53
|
+
if (!svg) return Promise.reject(/* @__PURE__ */ new Error("no diagram"));
|
|
54
|
+
const width = Number(svg.getAttribute("width")) || svg.viewBox.baseVal.width;
|
|
55
|
+
const height = Number(svg.getAttribute("height")) || svg.viewBox.baseVal.height;
|
|
56
|
+
if (!(width > 0 && height > 0)) return Promise.reject(/* @__PURE__ */ new Error("no size"));
|
|
57
|
+
const copy = svg.cloneNode(true);
|
|
58
|
+
if (!(copy instanceof SVGSVGElement)) return Promise.reject(/* @__PURE__ */ new Error("no diagram"));
|
|
59
|
+
const from = [svg, ...svg.querySelectorAll("*")];
|
|
60
|
+
const to = [copy, ...copy.querySelectorAll("*")];
|
|
61
|
+
from.forEach((node, index) => {
|
|
62
|
+
const into = to[index];
|
|
63
|
+
if (!(into instanceof SVGElement)) return;
|
|
64
|
+
const style = getComputedStyle(node);
|
|
65
|
+
for (const property of PROPERTIES) into.style.setProperty(property, style.getPropertyValue(property));
|
|
66
|
+
});
|
|
67
|
+
copy.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
68
|
+
copy.setAttribute("width", String(width));
|
|
69
|
+
copy.setAttribute("height", String(height));
|
|
70
|
+
copy.style.maxWidth = "none";
|
|
71
|
+
copy.style.width = `${width}px`;
|
|
72
|
+
copy.style.height = `${height}px`;
|
|
73
|
+
const scale = Math.min(2, 4096 / width, 4096 / height);
|
|
74
|
+
const canvas = document.createElement("canvas");
|
|
75
|
+
canvas.width = Math.max(1, Math.round(width * scale));
|
|
76
|
+
canvas.height = Math.max(1, Math.round(height * scale));
|
|
77
|
+
const fill = background(svg.parentElement ?? root);
|
|
78
|
+
const image = new Image();
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
image.onerror = () => reject(/* @__PURE__ */ new Error("not drawn"));
|
|
81
|
+
image.onload = () => {
|
|
82
|
+
const context = canvas.getContext("2d");
|
|
83
|
+
if (!context) return reject(/* @__PURE__ */ new Error("no canvas"));
|
|
84
|
+
context.fillStyle = fill;
|
|
85
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
86
|
+
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
87
|
+
canvas.toBlob((blob) => blob ? resolve(blob) : reject(/* @__PURE__ */ new Error("no image")), "image/png");
|
|
88
|
+
};
|
|
89
|
+
image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(copy))}`;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const part = (root, selector) => root.querySelector(`:scope>.cmm-bar>${selector}`);
|
|
93
|
+
function say(root, button, message, state) {
|
|
94
|
+
const status = part(root, ".cmm-status");
|
|
95
|
+
if (!status) return;
|
|
96
|
+
button.setAttribute("data-state", state);
|
|
97
|
+
status.textContent = message;
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
if (status.textContent !== message) return;
|
|
100
|
+
button.removeAttribute("data-state");
|
|
101
|
+
status.textContent = "";
|
|
102
|
+
}, state === "done" ? 1500 : 6e3);
|
|
103
|
+
}
|
|
104
|
+
function copyImage(root, button) {
|
|
105
|
+
const open = part(root, ".cmm-open");
|
|
106
|
+
if (open) open.hidden = true;
|
|
107
|
+
const image = png(root);
|
|
108
|
+
image.catch(() => {});
|
|
109
|
+
const clipboard = navigator.clipboard;
|
|
110
|
+
(clipboard && "ClipboardItem" in window ? clipboard.write([new ClipboardItem({ "image/png": image })]) : Promise.reject(/* @__PURE__ */ new Error("no clipboard"))).then(() => say(root, button, "Image copied", "done"), () => image.then((blob) => {
|
|
111
|
+
if (!open) return;
|
|
112
|
+
if (open.href) {
|
|
113
|
+
URL.revokeObjectURL(open.href);
|
|
114
|
+
links.delete(open.href);
|
|
115
|
+
}
|
|
116
|
+
open.href = URL.createObjectURL(blob);
|
|
117
|
+
links.add(open.href);
|
|
118
|
+
open.hidden = false;
|
|
119
|
+
say(root, button, "Couldn't copy the image. Open the PNG to save it.", "failed");
|
|
120
|
+
}, () => say(root, button, "Couldn't draw the image. Copy the source instead.", "failed")));
|
|
121
|
+
}
|
|
122
|
+
function copySource(root, button) {
|
|
123
|
+
const source = (root.getAttribute("data-source") ?? "").replace(/\n$/, "");
|
|
124
|
+
const longest = Math.max(2, ...(source.match(/`+/g) ?? []).map((run) => run.length));
|
|
125
|
+
const fence = "`".repeat(longest + 1);
|
|
126
|
+
const markdown = `${fence}mermaid\n${source}\n${fence}`;
|
|
127
|
+
const shown = root.querySelector(":scope>.cmm-markdown");
|
|
128
|
+
const failed = () => {
|
|
129
|
+
const pre = shown ?? document.createElement("pre");
|
|
130
|
+
pre.className = "cmm-markdown";
|
|
131
|
+
pre.textContent = markdown;
|
|
132
|
+
if (!shown) root.append(pre);
|
|
133
|
+
const range = document.createRange();
|
|
134
|
+
range.selectNodeContents(pre);
|
|
135
|
+
const selection = getSelection();
|
|
136
|
+
selection?.removeAllRanges();
|
|
137
|
+
selection?.addRange(range);
|
|
138
|
+
say(root, button, "Couldn't copy, so the source is selected. Press Ctrl+C or ⌘C.", "failed");
|
|
139
|
+
};
|
|
140
|
+
const clipboard = navigator.clipboard;
|
|
141
|
+
if (!clipboard) return failed();
|
|
142
|
+
clipboard.writeText(markdown).then(() => {
|
|
143
|
+
shown?.remove();
|
|
144
|
+
say(root, button, "Source copied", "done");
|
|
145
|
+
}, failed);
|
|
146
|
+
}
|
|
147
|
+
document.addEventListener("click", (event) => {
|
|
148
|
+
const button = event.target instanceof Element ? event.target.closest(".cmm>.cmm-bar>button") : null;
|
|
149
|
+
const root = button?.parentElement?.parentElement;
|
|
150
|
+
if (!button || !root) return;
|
|
151
|
+
if (button.classList.contains("cmm-image")) copyImage(root, button);
|
|
152
|
+
else if (button.classList.contains("cmm-source")) copySource(root, button);
|
|
153
|
+
}, { signal });
|
|
154
|
+
const state = {
|
|
155
|
+
users: 1,
|
|
156
|
+
stop: () => {
|
|
157
|
+
if (--state.users > 0) return;
|
|
158
|
+
listeners.abort();
|
|
159
|
+
for (const link of links) URL.revokeObjectURL(link);
|
|
160
|
+
document.documentElement.removeAttribute("data-mermaid-ready");
|
|
161
|
+
window.__comarkMermaid = void 0;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
window.__comarkMermaid = state;
|
|
165
|
+
return state.stop;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/client.ts
|
|
169
|
+
/**
|
|
170
|
+
* comark-pele's diagrams on the shared `--comark-*` tokens, on a card like comark-diagrams'. Pele paints with its
|
|
171
|
+
* `--pele-*` variables, so setting them on the wrapper themes every diagram, light and dark, without drawing it
|
|
172
|
+
* again. The rules sit in the `comark` layer, so host `--pele-*` values are preserved and win over these fallbacks.
|
|
173
|
+
*/
|
|
174
|
+
const mermaidCss = `@layer comark{${[
|
|
175
|
+
theme(".cmm,.pele-diagram"),
|
|
176
|
+
theme(":root"),
|
|
177
|
+
`:where(:root){--pele-bg:var(--_comark-background);--pele-fg:var(--_comark-foreground);--pele-muted:var(--_comark-muted);--pele-line:var(--_comark-muted);--pele-surface:var(--_comark-accent);--pele-surface-alt:color-mix(in srgb,var(--_comark-accent),var(--_comark-foreground) 6%);--pele-border:var(--_comark-border);--pele-accent:var(--ui-primary,var(--primary,var(--_comark-foreground)));--pele-critical:var(--ui-error,var(--destructive,#dc2626));--pele-error:var(--ui-error,var(--destructive,#dc2626));--pele-font:var(--_comark-font);--pele-radius:calc(var(--_comark-radius) - 4px);--pele-series-1:var(--comark-chart-1,var(--ui-chart-1,var(--chart-1,#3b82f6)));--pele-series-2:var(--comark-chart-2,var(--ui-chart-2,var(--chart-2,#f97316)));--pele-series-3:var(--comark-chart-3,var(--ui-chart-3,var(--chart-3,#10b981)));--pele-series-4:var(--comark-chart-4,var(--ui-chart-4,var(--chart-4,#a855f7)));--pele-series-5:var(--comark-chart-5,var(--ui-chart-5,var(--chart-5,#f43f5e)));--pele-series-6:var(--comark-chart-6,var(--ui-chart-6,var(--chart-6,#eab308)));--pele-series-7:var(--comark-chart-7,var(--ui-chart-7,var(--chart-7,#06b6d4)));--pele-series-8:var(--comark-chart-8,var(--ui-chart-8,var(--chart-8,#ec4899)))}`,
|
|
178
|
+
".pele-diagram{box-sizing:border-box;margin-block:1.5rem;padding:1rem;overflow-x:auto;border:1px solid var(--_comark-border);border-radius:var(--_comark-radius);background:var(--_comark-background);color:var(--_comark-foreground);text-align:center}",
|
|
179
|
+
".pele-diagram>svg{min-width:min(28rem,var(--cmm-svg,28rem))}",
|
|
180
|
+
".pele-source{margin:0;color:var(--_comark-muted);text-align:left}",
|
|
181
|
+
".cmm{--comark-wide-width:calc(var(--cmm-svg) + 2rem + 2px);--pele-zoom-top:auto;--pele-zoom-bottom:.5rem;position:relative;margin-block:1.5rem}",
|
|
182
|
+
".cmm>.pele-diagram{margin-block:0}",
|
|
183
|
+
".cmm-bar{position:absolute;top:.375rem;right:.375rem;z-index:1;display:flex;align-items:center;gap:.125rem;padding:.125rem;border-radius:calc(var(--_comark-radius) - 2px);background:var(--_comark-background);opacity:0;transition:opacity .15s}",
|
|
184
|
+
"html:not([data-mermaid-ready]) .cmm-bar{display:none}",
|
|
185
|
+
".cmm:is(:hover,:focus-within)>.cmm-bar,.cmm-bar:has(.cmm-status:not(:empty),.cmm-open:not([hidden])){opacity:1}",
|
|
186
|
+
"@media (hover:none){.cmm-bar{opacity:1}}",
|
|
187
|
+
".cmm:has(>.pele-diagram[data-error]) .cmm-image{display:none}",
|
|
188
|
+
".cmm-bar>button{display:inline-flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;margin:0;padding:0;border:1px solid transparent;border-radius:calc(var(--_comark-radius) - 2px);background:transparent;color:var(--_comark-muted);position:relative;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background-color .15s ease,color .15s ease}",
|
|
189
|
+
"@media (hover:hover){.cmm-bar>button:hover{background:var(--_comark-accent);color:var(--_comark-foreground)}}",
|
|
190
|
+
"@media (prefers-reduced-motion:no-preference){.cmm-bar>button{transition:background-color .15s ease,color .15s ease,scale .15s ease-out}.cmm-bar>button:active{scale:.96}}",
|
|
191
|
+
".cmm-bar>button:focus-visible{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--_comark-ring) 50%,transparent)}",
|
|
192
|
+
".cmm-bar svg{width:.75rem;height:.75rem;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}",
|
|
193
|
+
".cmm-done,.cmm-bar>[data-state=done] .cmm-idle{display:none}",
|
|
194
|
+
".cmm-bar>[data-state=done] .cmm-done{display:block}",
|
|
195
|
+
".cmm-open{padding:0 .375rem;color:var(--_comark-foreground);font:500 .75rem/1.5rem var(--_comark-font);text-decoration:underline;text-underline-offset:2px}",
|
|
196
|
+
".cmm-open[hidden]{display:none}",
|
|
197
|
+
".cmm-status{position:absolute;top:calc(100% + .25rem);right:0;width:max-content;max-width:18rem;padding:.25rem .5rem;border-radius:calc(var(--_comark-radius) - 4px);background:var(--_comark-foreground);color:var(--_comark-background);font:.75rem/1.25rem var(--_comark-font);text-align:left;pointer-events:none}",
|
|
198
|
+
".cmm-status:empty{display:none}",
|
|
199
|
+
".cmm-markdown{margin:.5rem 0 0;padding:.75rem 1rem;overflow-x:auto;border:1px solid var(--_comark-border);border-radius:var(--_comark-radius);background:var(--_comark-accent);color:var(--_comark-foreground);font:.8125rem/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre}",
|
|
200
|
+
".cz-item>.pele-diagram>svg{min-width:0}",
|
|
201
|
+
"@media print{.pele-diagram{break-inside:avoid}.cmm-bar{display:none}}"
|
|
202
|
+
].join("")}}`;
|
|
203
|
+
/** Sizes Mermaid cards after Pele draws them in Vue, React, and Svelte, and adds the styles to the page once. */
|
|
204
|
+
function addMermaidStyles() {
|
|
205
|
+
for (const card of document.querySelectorAll(".pele-diagram")) {
|
|
206
|
+
const svg = card.querySelector(":scope > svg");
|
|
207
|
+
const width = Number(svg?.getAttribute("width"));
|
|
208
|
+
const block = card.parentElement?.classList.contains("cmm") ? card.parentElement : card;
|
|
209
|
+
if (Number.isFinite(width) && width > 0 && !card.querySelector(":scope > .pele-error")) {
|
|
210
|
+
block.dataset.wide = "";
|
|
211
|
+
block.style.setProperty("--cmm-svg", `${Math.ceil(width)}px`);
|
|
212
|
+
} else {
|
|
213
|
+
delete block.dataset.wide;
|
|
214
|
+
block.style.removeProperty("--cmm-svg");
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (document.querySelector("style[data-comark-mermaid]")) return;
|
|
218
|
+
const style = document.createElement("style");
|
|
219
|
+
style.dataset.comarkMermaid = "";
|
|
220
|
+
style.textContent = mermaidCss;
|
|
221
|
+
document.head.append(style);
|
|
222
|
+
}
|
|
223
|
+
const icon = (name, path) => `<svg class="cmm-${name}" viewBox="0 0 24 24" aria-hidden="true">${path}</svg>`;
|
|
224
|
+
const done = icon("done", "<path d=\"M20 6 9 17l-5-5\"/>");
|
|
225
|
+
/**
|
|
226
|
+
* The inside of a diagram's bar, the same in every renderer: Copy image, Copy source, the link to the PNG for when the
|
|
227
|
+
* clipboard refuses it, and the status line that says whether the copy worked.
|
|
228
|
+
*/
|
|
229
|
+
function mermaidBar() {
|
|
230
|
+
return `<button type="button" class="cmm-image" aria-label="Copy image" title="Copy image">` + icon("idle", "<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"9\" cy=\"9\" r=\"2\"/><path d=\"m21 15-5-5L5 21\"/>") + `${done}</button><button type="button" class="cmm-source" aria-label="Copy source" title="Copy source">` + icon("idle", "<path d=\"m16 18 6-6-6-6\"/><path d=\"m8 6-6 6 6 6\"/>") + `${done}</button><a class="cmm-open" target="_blank" rel="noopener" hidden>Open PNG</a><span class="cmm-status" role="status"></span>`;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Adds the Mermaid styles and starts the buttons of every diagram on the page, and returns a function that stops them.
|
|
234
|
+
* The Vue, React, and Svelte diagrams call it on mount and stop it on unmount.
|
|
235
|
+
*/
|
|
236
|
+
function startMermaid() {
|
|
237
|
+
addMermaidStyles();
|
|
238
|
+
return start();
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
export { start as a, startMermaid as i, mermaidBar as n, mermaidCss as r, addMermaidStyles as t };
|
package/dist/client.d.mts
CHANGED
|
@@ -6,7 +6,17 @@ import { t as typesetCss } from "./typeset-css-DdOGL7WF.mjs";
|
|
|
6
6
|
* again. The rules sit in the `comark` layer, so host `--pele-*` values are preserved and win over these fallbacks.
|
|
7
7
|
*/
|
|
8
8
|
export declare const mermaidCss: string;
|
|
9
|
-
/**
|
|
9
|
+
/** Sizes Mermaid cards after Pele draws them in Vue, React, and Svelte, and adds the styles to the page once. */
|
|
10
10
|
export declare function addMermaidStyles(): void;
|
|
11
|
+
/**
|
|
12
|
+
* The inside of a diagram's bar, the same in every renderer: Copy image, Copy source, the link to the PNG for when the
|
|
13
|
+
* clipboard refuses it, and the status line that says whether the copy worked.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mermaidBar(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Adds the Mermaid styles and starts the buttons of every diagram on the page, and returns a function that stops them.
|
|
18
|
+
* The Vue, React, and Svelte diagrams call it on mount and stop it on unmount.
|
|
19
|
+
*/
|
|
20
|
+
export declare function startMermaid(): () => void;
|
|
11
21
|
//#endregion
|
|
12
22
|
export { typesetCss };
|
package/dist/client.mjs
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
import { t as typesetCss } from "./typeset-css-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* comark-pele's diagrams on the shared `--comark-*` tokens, on a card like comark-diagrams'. Pele paints with its
|
|
6
|
-
* `--pele-*` variables, so setting them on the wrapper themes every diagram, light and dark, without drawing it
|
|
7
|
-
* again. The rules sit in the `comark` layer, so host `--pele-*` values are preserved and win over these fallbacks.
|
|
8
|
-
*/
|
|
9
|
-
const mermaidCss = `@layer comark{${[
|
|
10
|
-
theme(".pele-diagram"),
|
|
11
|
-
theme(":root"),
|
|
12
|
-
`:where(:root){--pele-bg:var(--_comark-background);--pele-fg:var(--_comark-foreground);--pele-muted:var(--_comark-muted);--pele-line:var(--_comark-muted);--pele-surface:var(--_comark-accent);--pele-surface-alt:color-mix(in srgb,var(--_comark-accent),var(--_comark-foreground) 6%);--pele-border:var(--_comark-border);--pele-accent:var(--ui-primary,var(--primary,var(--_comark-foreground)));--pele-critical:var(--ui-error,var(--destructive,#dc2626));--pele-error:var(--ui-error,var(--destructive,#dc2626));--pele-font:var(--_comark-font);--pele-radius:calc(var(--_comark-radius) - 4px);--pele-series-1:var(--comark-chart-1,var(--ui-chart-1,var(--chart-1,#3b82f6)));--pele-series-2:var(--comark-chart-2,var(--ui-chart-2,var(--chart-2,#f97316)));--pele-series-3:var(--comark-chart-3,var(--ui-chart-3,var(--chart-3,#10b981)));--pele-series-4:var(--comark-chart-4,var(--ui-chart-4,var(--chart-4,#a855f7)));--pele-series-5:var(--comark-chart-5,var(--ui-chart-5,var(--chart-5,#f43f5e)));--pele-series-6:var(--comark-chart-6,var(--ui-chart-6,var(--chart-6,#eab308)));--pele-series-7:var(--comark-chart-7,var(--ui-chart-7,var(--chart-7,#06b6d4)));--pele-series-8:var(--comark-chart-8,var(--ui-chart-8,var(--chart-8,#ec4899)))}`,
|
|
13
|
-
".pele-diagram{margin:1.5rem 0;padding:1rem;overflow-x:auto;border:1px solid var(--_comark-border);border-radius:var(--_comark-radius);background:var(--_comark-background);color:var(--_comark-foreground);text-align:center}",
|
|
14
|
-
".pele-source{margin:0;color:var(--_comark-muted);text-align:left}",
|
|
15
|
-
"@media print{.pele-diagram{break-inside:avoid}}"
|
|
16
|
-
].join("")}}`;
|
|
17
|
-
/** Adds the Mermaid styles to the page once. The Vue, React, and Svelte diagrams call it when Pele draws them. */
|
|
18
|
-
function addMermaidStyles() {
|
|
19
|
-
if (document.querySelector("style[data-comark-mermaid]")) return;
|
|
20
|
-
const style = document.createElement("style");
|
|
21
|
-
style.dataset.comarkMermaid = "";
|
|
22
|
-
style.textContent = mermaidCss;
|
|
23
|
-
document.head.append(style);
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
export { addMermaidStyles, mermaidCss, typesetCss };
|
|
1
|
+
import { t as typesetCss } from "./typeset-css-5aJ7cSmh.mjs";
|
|
2
|
+
import { i as startMermaid, n as mermaidBar, r as mermaidCss, t as addMermaidStyles } from "./client-Bjd6VcGQ.mjs";
|
|
3
|
+
export { addMermaidStyles, mermaidBar, mermaidCss, startMermaid, typesetCss };
|
package/dist/html.d.mts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { a as criticCss, n as Preset, r as PresetOptions } from "./index-
|
|
1
|
+
import { a as criticCss, n as Preset, r as PresetOptions } from "./index-jkwx6SyG.mjs";
|
|
2
2
|
import { NodeHandler } from "comark";
|
|
3
3
|
//#region src/html.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The text of the inline `<script>` that runs the Mermaid diagrams' Copy image and Copy source buttons. It's the same on
|
|
6
|
+
* every render and changes only between versions, so a page with a strict Content Security Policy can allow it by its
|
|
7
|
+
* hash without rendering a document first.
|
|
8
|
+
*/
|
|
9
|
+
export declare const mermaidScript: string;
|
|
4
10
|
/** Every plugin for `@comark/html`, with the `components` to render them. */
|
|
5
11
|
declare const _default: (options?: PresetOptions) => Preset<NodeHandler>;
|
|
6
12
|
//#endregion
|
package/dist/html.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { t as typesetCss } from "./typeset-css-
|
|
1
|
+
import { t as typesetCss } from "./typeset-css-5aJ7cSmh.mjs";
|
|
2
2
|
import { n as preset, t as criticCss } from "./src-DROB05U6.mjs";
|
|
3
|
-
import { mermaidCss } from "./client.mjs";
|
|
3
|
+
import { a as start, n as mermaidBar, r as mermaidCss } from "./client-Bjd6VcGQ.mjs";
|
|
4
|
+
import { escapeHtml } from "comark/utils";
|
|
4
5
|
import * as annotate from "comark-annotate/html";
|
|
5
6
|
import * as badge from "comark-badge/html";
|
|
6
7
|
import * as cards from "comark-cards/html";
|
|
@@ -38,14 +39,31 @@ import * as tests from "comark-tests/html";
|
|
|
38
39
|
import * as zoom from "comark-zoom/html";
|
|
39
40
|
//#region src/html.ts
|
|
40
41
|
const styled = /* @__PURE__ */ new WeakSet();
|
|
41
|
-
|
|
42
|
+
/**
|
|
43
|
+
* The text of the inline `<script>` that runs the Mermaid diagrams' Copy image and Copy source buttons. It's the same on
|
|
44
|
+
* every render and changes only between versions, so a page with a strict Content Security Policy can allow it by its
|
|
45
|
+
* hash without rendering a document first.
|
|
46
|
+
*/
|
|
47
|
+
const mermaidScript = `(${start.toString()})()`;
|
|
48
|
+
const attr = (value) => escapeHtml(value, { "\"": """ });
|
|
49
|
+
/**
|
|
50
|
+
* Wraps Pele's card in `.cmm` with the bar of buttons and the source they copy. The wrapper is a wide block with the
|
|
51
|
+
* diagram's own width, so a page that gives wide blocks room shows a long flowchart at its size rather than shrinking
|
|
52
|
+
* its labels to fit the column. A drawn diagram zooms with comark-zoom unless the preset turns zoom off.
|
|
53
|
+
*/
|
|
54
|
+
const mermaid = (zooms) => ({
|
|
42
55
|
default: pele,
|
|
43
56
|
components: { pele: ((node, state) => {
|
|
44
|
-
const
|
|
57
|
+
const first = !styled.has(state.context);
|
|
45
58
|
styled.add(state.context);
|
|
46
|
-
|
|
59
|
+
const card = Pele(node);
|
|
60
|
+
const source = node[1].content;
|
|
61
|
+
const width = /^<div[^>]*><svg[^>]* width="([\d.]+)"/.exec(card)?.[1];
|
|
62
|
+
const wide = width ? ` data-wide style="--cmm-svg:${Math.ceil(Number(width))}px"` : "";
|
|
63
|
+
const zoomed = zooms && width ? card.replace(/^<div/, "<div data-zoom tabindex=\"0\"") : card;
|
|
64
|
+
return (first ? `<style data-comark-mermaid>${mermaidCss}</style>` : "") + `<div class="cmm"${wide} data-source="${attr(source)}">${zoomed}<div class="cmm-bar">${mermaidBar()}</div>${first ? `<script>${mermaidScript}<\/script>` : ""}${zooms && width ? zoom.runtime(state) : ""}</div>`;
|
|
47
65
|
}) }
|
|
48
|
-
};
|
|
66
|
+
});
|
|
49
67
|
const typeset = () => `<style data-comark-typeset>${typesetCss}</style>`;
|
|
50
68
|
/** Every plugin for `@comark/html`, with the `components` to render them. */
|
|
51
69
|
var html_default = (options) => preset({
|
|
@@ -72,7 +90,7 @@ var html_default = (options) => preset({
|
|
|
72
90
|
mark,
|
|
73
91
|
math,
|
|
74
92
|
media,
|
|
75
|
-
mermaid,
|
|
93
|
+
mermaid: mermaid(options?.zoom !== false),
|
|
76
94
|
metrics,
|
|
77
95
|
outline,
|
|
78
96
|
properties,
|
|
@@ -87,4 +105,4 @@ var html_default = (options) => preset({
|
|
|
87
105
|
zoom
|
|
88
106
|
}, options);
|
|
89
107
|
//#endregion
|
|
90
|
-
export { criticCss, html_default as default };
|
|
108
|
+
export { criticCss, html_default as default, mermaidScript };
|
|
@@ -19,6 +19,7 @@ import { CalloutsOptions, ReferencesOptions } from "comark-github";
|
|
|
19
19
|
import { AnchorsOptions, ExternalOptions } from "comark-links";
|
|
20
20
|
import { MathOptions } from "comark-mathml";
|
|
21
21
|
import { MediaOptions } from "comark-media";
|
|
22
|
+
import { OutlineOptions } from "comark-outline";
|
|
22
23
|
import { PeleConfig } from "comark-pele";
|
|
23
24
|
import { PropertiesOptions } from "comark-properties";
|
|
24
25
|
import { QuizOptions } from "comark-quiz";
|
|
@@ -94,7 +95,8 @@ type PresetOptions = {
|
|
|
94
95
|
steps?: boolean;
|
|
95
96
|
readingTime?: ReadingTimeOptions | boolean;
|
|
96
97
|
tabs?: TabsOptions | boolean;
|
|
97
|
-
outline
|
|
98
|
+
/** `{ rail: true }` adds a side outline beside the text of every document with two headings or more. Off by default. */
|
|
99
|
+
outline?: OutlineOptions | boolean;
|
|
98
100
|
xref?: XrefOptions | boolean;
|
|
99
101
|
/** Reads no JUnit reports unless you pass `{ root }` or `{ read }`; inline reports render either way. */
|
|
100
102
|
tests?: TestsOptions | boolean;
|
|
@@ -155,7 +157,7 @@ type Renderer<C> = {
|
|
|
155
157
|
sources: Part<C>;
|
|
156
158
|
steps: Part<C>;
|
|
157
159
|
tabs: Part<C, TabsOptions>;
|
|
158
|
-
outline: Part<C>;
|
|
160
|
+
outline: Part<C, OutlineOptions>;
|
|
159
161
|
tests: Part<C, TestsOptions>;
|
|
160
162
|
zoom: Part<C, ZoomOptions>;
|
|
161
163
|
code: Part<C, CodeOptions>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as typesetCss } from "./typeset-css-DdOGL7WF.mjs";
|
|
2
|
-
import { a as criticCss, c as typeset, i as Renderer, n as Preset, o as preset, r as PresetOptions, s as TYPESET_TAG, t as AnyPlugin } from "./index-
|
|
2
|
+
import { a as criticCss, c as typeset, i as Renderer, n as Preset, o as preset, r as PresetOptions, s as TYPESET_TAG, t as AnyPlugin } from "./index-jkwx6SyG.mjs";
|
|
3
3
|
export { AnyPlugin, Preset, PresetOptions, Renderer, TYPESET_TAG, criticCss, preset, typeset, typesetCss };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as typesetCss } from "./typeset-css-
|
|
1
|
+
import { t as typesetCss } from "./typeset-css-5aJ7cSmh.mjs";
|
|
2
2
|
import { i as typeset, n as preset, r as TYPESET_TAG, t as criticCss } from "./src-DROB05U6.mjs";
|
|
3
3
|
export { TYPESET_TAG, criticCss, preset, typeset, typesetCss };
|
package/dist/react.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as criticCss, n as Preset, r as PresetOptions } from "./index-
|
|
1
|
+
import { a as criticCss, n as Preset, r as PresetOptions } from "./index-jkwx6SyG.mjs";
|
|
2
2
|
import { ComponentType } from "react";
|
|
3
3
|
//#region src/react.d.ts
|
|
4
4
|
type AnyComponent = ComponentType<any>;
|
package/dist/react.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as typesetCss } from "./typeset-css-
|
|
1
|
+
import { t as typesetCss } from "./typeset-css-5aJ7cSmh.mjs";
|
|
2
2
|
import { n as preset, t as criticCss } from "./src-DROB05U6.mjs";
|
|
3
|
-
import { addMermaidStyles } from "./client.mjs";
|
|
4
|
-
import { createElement } from "react";
|
|
3
|
+
import { i as startMermaid, n as mermaidBar, t as addMermaidStyles } from "./client-Bjd6VcGQ.mjs";
|
|
4
|
+
import { createElement, useEffect } from "react";
|
|
5
5
|
import * as badge from "comark-badge/react";
|
|
6
6
|
import * as cards from "comark-cards/react";
|
|
7
7
|
import * as carousel from "comark-carousel/react";
|
|
@@ -35,9 +35,23 @@ import * as tabs from "comark-tabs/react";
|
|
|
35
35
|
import * as tests from "comark-tests/react";
|
|
36
36
|
import * as zoom from "comark-zoom/react";
|
|
37
37
|
//#region src/react.ts
|
|
38
|
+
const Pele = createPeleComponent({
|
|
39
|
+
onRender: addMermaidStyles,
|
|
40
|
+
onError: addMermaidStyles
|
|
41
|
+
});
|
|
42
|
+
function Mermaid(props) {
|
|
43
|
+
useEffect(() => startMermaid(), []);
|
|
44
|
+
return createElement("div", {
|
|
45
|
+
className: "cmm",
|
|
46
|
+
"data-source": props.content
|
|
47
|
+
}, createElement(Pele, props), createElement("div", {
|
|
48
|
+
className: "cmm-bar",
|
|
49
|
+
dangerouslySetInnerHTML: { __html: mermaidBar() }
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
38
52
|
const mermaid = {
|
|
39
53
|
default: pele,
|
|
40
|
-
components: { pele:
|
|
54
|
+
components: { pele: Mermaid }
|
|
41
55
|
};
|
|
42
56
|
const typeset = () => createElement("style", {
|
|
43
57
|
"data-comark-typeset": "",
|
|
@@ -55,7 +55,7 @@ Read the reference for each block you use before you write it. Mix the blocks fr
|
|
|
55
55
|
| A change on screen, before and after | `::compare` | [annotate](references/annotate.md) |
|
|
56
56
|
| A command's output, such as a test run or a build, as colored text | `::cast` | [cast](references/cast.md) |
|
|
57
57
|
| Numbers, such as sizes, timings, before/after metrics, a trend, or a timeline | `::chart` | [charts](references/charts.md) |
|
|
58
|
-
| A flow, a sequence, an architecture, or a schema as a diagram | a `d2`, `dot`, `plantuml`, `dbml`, `goat`, or `svgbob` fence | [diagrams](references/diagrams.md) |
|
|
58
|
+
| A flow, a sequence, an architecture, or a schema as a diagram | a `mermaid`, `d2`, `dot`, `plantuml`, `dbml`, `goat`, or `svgbob` fence | [diagrams](references/diagrams.md) |
|
|
59
59
|
| Links and `@mentions` with the site's favicon or the person's avatar | links, `@user`, `:chip` | [chips](references/chips.md) |
|
|
60
60
|
| Colors, such as design tokens before and after, or a palette | a color in inline code, `::palette` | [colors](references/colors.md) |
|
|
61
61
|
| A suggested change to one file, before and after | `::diff` | [diff](references/diff.md) |
|
|
@@ -21,10 +21,16 @@ queue -> map: pigeon pin
|
|
|
21
21
|
| `goat` or `svgbob` | ASCII art, as lines and arrows |
|
|
22
22
|
|
|
23
23
|
- The title in brackets after the language goes under the diagram and names it for screen readers. Give every diagram one.
|
|
24
|
-
- Every other fence stays code, `mermaid
|
|
24
|
+
- Every other fence stays code, except `mermaid`, which comark-ui draws with comark-pele (see Mermaid below).
|
|
25
25
|
- A diagram Kroki can't draw stays code, and `meta.issues` quotes the tool's error. So does one drawn while the server can't be reached; the next parse tries again.
|
|
26
26
|
- The plugin drops anything that could run from the SVG: scripts, event handlers, embedded HTML, and animations. Write labels as plain text. A D2 Markdown label (`|md … |`) is embedded HTML, so it comes out empty, and nothing reports it.
|
|
27
27
|
|
|
28
|
+
## Mermaid
|
|
29
|
+
|
|
30
|
+
Through comark-ui, a ` ```mermaid ` fence is drawn as SVG by comark-pele while rendering, with no network, and themed with the other blocks. A diagram Pele can't draw shows its source, and nothing goes in `meta.issues`, so check it in a render.
|
|
31
|
+
|
|
32
|
+
With `comark-ui/html`, a click, `Enter`, or `Space` zooms the diagram, and its buttons copy it as a PNG on the page's background or as its ` ```mermaid ` fence. The Vue, React, and Svelte entries draw the same buttons, and Pele zooms the diagram in place there. `zoom: false` in `comarkUi()` turns the zoom off; the buttons stay. A host with a strict Content Security Policy allows the buttons' script by the hash of `mermaidScript` from `comark-ui/html`, and Copy image needs `img-src data:`.
|
|
33
|
+
|
|
28
34
|
## Check each diagram
|
|
29
35
|
|
|
30
36
|
Send an internal architecture or a schema with sensitive names only to the host's own Kroki server. With the default `server`, each diagram's source goes to `https://kroki.io`, a public service.
|
|
@@ -30,7 +30,15 @@ The redesign moves the filters into one row and adds an empty state.
|
|
|
30
30
|
- Every `::toc` lists the whole document, wherever it sits. With no heading from h2 to `depth`, it renders nothing, and the plugin reports it.
|
|
31
31
|
- Write `::toc` where other tools use `[[toc]]`, which Comark reads as a span.
|
|
32
32
|
|
|
33
|
+
## Side outline
|
|
34
|
+
|
|
35
|
+
The `rail` option adds an "On this page" outline beside the text of every document with two headings or more to list, and marks the section being read. It isn't Markdown: a document can't turn it on, and `::toc` still works beside it. Write short h2 and h3 headings, since they become its links.
|
|
36
|
+
|
|
37
|
+
- Options: `rail: true`, or `{ title, depth }` (default "On this page" and 3).
|
|
38
|
+
- The page sets `--comark-inset-end` on `:root` for a panel that covers its right edge. While the outline keeps a column beside wide blocks, it sets `data-comark-rail` and `--comark-rail-width` on `<html>`, and the page shrinks `--comark-wide-end` by it, so wide blocks move toward the room before the text.
|
|
39
|
+
- It hides where it doesn't fit, and rather than narrow a diagram.
|
|
40
|
+
|
|
33
41
|
## Register
|
|
34
42
|
|
|
35
|
-
- In `comark-ui`: on in every entry
|
|
43
|
+
- In `comark-ui`: on in every entry; `outline: { rail: true }` adds the side outline.
|
|
36
44
|
- Alone: `pnpm add comark @comark/html comark-outline`, then `createHtmlRenderer({ plugins: [outline()], components })` with both from `comark-outline/html`. `comark-outline/vue`, `/react`, and `/svelte` render it too. It reads the headings itself, so it works in any plugin order and without Comark's toc plugin, which only fills `meta.toc` for a sidebar. The npm name is `comark-outline` because npm refused `comark-toc`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- Pele's card in `.cmm` with the bar of buttons, as `comark-ui/html` draws it. In the browser Pele's own `mount()`
|
|
2
|
+
zooms the diagram in place, so it doesn't zoom with comark-zoom. -->
|
|
3
|
+
<script>
|
|
4
|
+
import { onMount } from "svelte";
|
|
5
|
+
import { createPeleComponent } from "comark-pele/svelte";
|
|
6
|
+
import { addMermaidStyles, mermaidBar, startMermaid } from "comark-ui/client";
|
|
7
|
+
|
|
8
|
+
const Pele = createPeleComponent({ onRender: addMermaidStyles, onError: addMermaidStyles });
|
|
9
|
+
let { content = "", ...rest } = $props();
|
|
10
|
+
onMount(() => startMermaid());
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class="cmm" data-source={content}>
|
|
14
|
+
<Pele {content} {...rest} />
|
|
15
|
+
<div class="cmm-bar">{@html mermaidBar()}</div>
|
|
16
|
+
</div>
|
package/dist/svelte/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Every plugin with components for `@comark/svelte`, which leaves out annotate, diff, and quiz.
|
|
2
2
|
import { preset } from "comark-ui";
|
|
3
|
-
import { addMermaidStyles } from "comark-ui/client";
|
|
4
3
|
import * as badge from "comark-badge/svelte";
|
|
5
4
|
import * as cards from "comark-cards/svelte";
|
|
6
5
|
import * as carousel from "comark-carousel/svelte";
|
|
@@ -22,7 +21,7 @@ import * as magicMove from "comark-magic-move/svelte";
|
|
|
22
21
|
import * as mark from "comark-mark/svelte";
|
|
23
22
|
import * as math from "comark-mathml/svelte";
|
|
24
23
|
import * as media from "comark-media/svelte";
|
|
25
|
-
import pele
|
|
24
|
+
import pele from "comark-pele/svelte";
|
|
26
25
|
import * as metrics from "comark-metrics/svelte";
|
|
27
26
|
import * as outline from "comark-outline/svelte";
|
|
28
27
|
import * as properties from "comark-properties/svelte";
|
|
@@ -33,15 +32,12 @@ import * as table from "comark-table/svelte";
|
|
|
33
32
|
import * as tabs from "comark-tabs/svelte";
|
|
34
33
|
import * as tests from "comark-tests/svelte";
|
|
35
34
|
import * as zoom from "comark-zoom/svelte";
|
|
35
|
+
import Mermaid from "./Mermaid.svelte";
|
|
36
36
|
import typeset from "./Typeset.svelte";
|
|
37
37
|
|
|
38
38
|
export { criticCss } from "comark-ui";
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
const mermaid = {
|
|
42
|
-
default: pele,
|
|
43
|
-
components: { pele: createPeleComponent({ onRender: addMermaidStyles }) },
|
|
44
|
-
};
|
|
40
|
+
const mermaid = { default: pele, components: { pele: Mermaid } };
|
|
45
41
|
|
|
46
42
|
export default (options) =>
|
|
47
43
|
preset(
|
|
@@ -181,6 +181,20 @@ const rules = `
|
|
|
181
181
|
.shiki:not(:where(.light *)) span[style*="--shiki-dark:"] { color: var(--shiki-dark) !important; }
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/* A block marked data-wide, such as a before/after comparison or a diagram wider than the text, grows past the column
|
|
185
|
+
into the room the page gives it on each side, --comark-wide-start and --comark-wide-end, up to its own width
|
|
186
|
+
(--comark-wide-width) and --comark-wide-max. It stays centered on the column while both sides have room, and moves
|
|
187
|
+
toward the side that has more when one doesn't. Without room set, it keeps to the column. Only the document's own
|
|
188
|
+
blocks grow, not one inside a list or tabs. */
|
|
189
|
+
:scope > [data-wide] {
|
|
190
|
+
/* Room a page works out from the window can come out negative on a phone, where the column fills it: none, then. */
|
|
191
|
+
--_ty-start: max(0px, var(--comark-wide-start, 0px));
|
|
192
|
+
--_ty-end: max(0px, var(--comark-wide-end, 0px));
|
|
193
|
+
--_ty-wide: max(100%, min(var(--comark-wide-width, 100vw), var(--comark-wide-max, 72rem), 100% + var(--_ty-start) + var(--_ty-end)));
|
|
194
|
+
width: var(--_ty-wide);
|
|
195
|
+
margin-inline: clamp(-1 * var(--_ty-start), (100% - var(--_ty-wide)) / 2, 100% + var(--_ty-end) - var(--_ty-wide)) 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
184
198
|
/* The first child adds no space above. Last, so it wins ties. */
|
|
185
199
|
:scope > :where(:first-child):not(${own}),
|
|
186
200
|
:scope > :where(:first-child) > :where(:first-child):not(${own}),
|
package/dist/vue.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as criticCss, n as Preset, r as PresetOptions } from "./index-
|
|
1
|
+
import { a as criticCss, n as Preset, r as PresetOptions } from "./index-jkwx6SyG.mjs";
|
|
2
2
|
import { Component } from "vue";
|
|
3
3
|
//#region src/vue.d.ts
|
|
4
4
|
/** Every plugin with components for `@comark/vue`, which leaves out annotate, diff, and quiz. */
|
package/dist/vue.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as typesetCss } from "./typeset-css-
|
|
1
|
+
import { t as typesetCss } from "./typeset-css-5aJ7cSmh.mjs";
|
|
2
2
|
import { n as preset, t as criticCss } from "./src-DROB05U6.mjs";
|
|
3
|
-
import { addMermaidStyles } from "./client.mjs";
|
|
4
|
-
import { defineComponent, h } from "vue";
|
|
3
|
+
import { i as startMermaid, n as mermaidBar, t as addMermaidStyles } from "./client-Bjd6VcGQ.mjs";
|
|
4
|
+
import { defineComponent, h, onBeforeUnmount, onMounted } from "vue";
|
|
5
5
|
import * as badge from "comark-badge/vue";
|
|
6
6
|
import * as cards from "comark-cards/vue";
|
|
7
7
|
import * as carousel from "comark-carousel/vue";
|
|
@@ -35,9 +35,36 @@ import * as tabs from "comark-tabs/vue";
|
|
|
35
35
|
import * as tests from "comark-tests/vue";
|
|
36
36
|
import * as zoom from "comark-zoom/vue";
|
|
37
37
|
//#region src/vue.ts
|
|
38
|
+
const Pele = createPeleComponent({
|
|
39
|
+
onRender: addMermaidStyles,
|
|
40
|
+
onError: addMermaidStyles
|
|
41
|
+
});
|
|
42
|
+
const Mermaid = defineComponent({
|
|
43
|
+
name: "ComarkMermaid",
|
|
44
|
+
inheritAttrs: false,
|
|
45
|
+
props: { content: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: ""
|
|
48
|
+
} },
|
|
49
|
+
setup(props, { attrs }) {
|
|
50
|
+
let stop = () => {};
|
|
51
|
+
onMounted(() => stop = startMermaid());
|
|
52
|
+
onBeforeUnmount(() => stop());
|
|
53
|
+
return () => h("div", {
|
|
54
|
+
class: "cmm",
|
|
55
|
+
"data-source": props.content
|
|
56
|
+
}, [h(Pele, {
|
|
57
|
+
...attrs,
|
|
58
|
+
content: props.content
|
|
59
|
+
}), h("div", {
|
|
60
|
+
class: "cmm-bar",
|
|
61
|
+
innerHTML: mermaidBar()
|
|
62
|
+
})]);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
38
65
|
const mermaid = {
|
|
39
66
|
default: pele,
|
|
40
|
-
components: { pele:
|
|
67
|
+
components: { pele: Mermaid }
|
|
41
68
|
};
|
|
42
69
|
const typeset = defineComponent({
|
|
43
70
|
name: "ComarkTypeset",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comark-ui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Every comark-ui block in one install: annotated screenshots, charts, diffs, tabs, zoom, and more, registered in the order they need with shared icons. Turn any of them off or pass its options.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"comark",
|
|
@@ -47,49 +47,49 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"comark-pele": "^1.1.0",
|
|
50
|
-
"comark-
|
|
51
|
-
"comark-
|
|
52
|
-
"comark-
|
|
53
|
-
"comark-
|
|
54
|
-
"comark-cast": "^0.7.
|
|
55
|
-
"comark-charts": "^0.7.
|
|
56
|
-
"comark-chips": "^0.7.
|
|
57
|
-
"comark-
|
|
58
|
-
"comark-code": "^0.7.
|
|
59
|
-
"comark-
|
|
60
|
-
"comark-
|
|
61
|
-
"comark-
|
|
62
|
-
"comark-
|
|
63
|
-
"comark-details": "^0.7.
|
|
64
|
-
"comark-
|
|
65
|
-
"comark-
|
|
66
|
-
"comark-
|
|
67
|
-
"comark-figure": "^0.7.
|
|
68
|
-
"comark-
|
|
69
|
-
"comark-
|
|
70
|
-
"comark-
|
|
71
|
-
"comark-icon": "^0.7.
|
|
72
|
-
"comark-include": "^0.7.
|
|
73
|
-
"comark-keys": "^0.7.
|
|
74
|
-
"comark-
|
|
75
|
-
"comark-
|
|
76
|
-
"comark-
|
|
77
|
-
"comark-
|
|
78
|
-
"comark-
|
|
79
|
-
"comark-
|
|
80
|
-
"comark-metrics": "^0.7.
|
|
81
|
-
"comark-
|
|
82
|
-
"comark-
|
|
83
|
-
"comark-
|
|
84
|
-
"comark-
|
|
85
|
-
"comark-
|
|
86
|
-
"comark-
|
|
87
|
-
"comark-table": "^0.7.
|
|
88
|
-
"comark-
|
|
89
|
-
"comark-
|
|
90
|
-
"comark-
|
|
91
|
-
"comark-xref": "^0.7.
|
|
92
|
-
"comark-zoom": "^0.7.
|
|
50
|
+
"comark-annotate": "^0.7.2",
|
|
51
|
+
"comark-badge": "^0.7.2",
|
|
52
|
+
"comark-carousel": "^0.7.2",
|
|
53
|
+
"comark-cards": "^0.7.2",
|
|
54
|
+
"comark-cast": "^0.7.2",
|
|
55
|
+
"comark-charts": "^0.7.2",
|
|
56
|
+
"comark-chips": "^0.7.2",
|
|
57
|
+
"comark-code": "^0.7.2",
|
|
58
|
+
"comark-code-notes": "^0.7.2",
|
|
59
|
+
"comark-colors": "^0.7.2",
|
|
60
|
+
"comark-cjk": "^0.7.2",
|
|
61
|
+
"comark-deflist": "^0.7.2",
|
|
62
|
+
"comark-critic": "^0.7.2",
|
|
63
|
+
"comark-details": "^0.7.2",
|
|
64
|
+
"comark-diagrams": "^0.7.2",
|
|
65
|
+
"comark-fields": "^0.7.2",
|
|
66
|
+
"comark-embed": "^0.7.2",
|
|
67
|
+
"comark-figure": "^0.7.2",
|
|
68
|
+
"comark-diff": "^0.7.2",
|
|
69
|
+
"comark-file-tree": "^0.7.2",
|
|
70
|
+
"comark-github": "^0.7.2",
|
|
71
|
+
"comark-icon": "^0.7.2",
|
|
72
|
+
"comark-include": "^0.7.2",
|
|
73
|
+
"comark-keys": "^0.7.2",
|
|
74
|
+
"comark-footnotes": "^0.7.2",
|
|
75
|
+
"comark-links": "^0.7.2",
|
|
76
|
+
"comark-mark": "^0.7.2",
|
|
77
|
+
"comark-mathml": "^0.7.2",
|
|
78
|
+
"comark-media": "^0.7.2",
|
|
79
|
+
"comark-magic-move": "^0.7.2",
|
|
80
|
+
"comark-metrics": "^0.7.2",
|
|
81
|
+
"comark-outline": "^0.7.2",
|
|
82
|
+
"comark-qr": "^0.7.2",
|
|
83
|
+
"comark-quiz": "^0.7.2",
|
|
84
|
+
"comark-reading-time": "^0.7.2",
|
|
85
|
+
"comark-properties": "^0.7.2",
|
|
86
|
+
"comark-steps": "^0.7.2",
|
|
87
|
+
"comark-table": "^0.7.2",
|
|
88
|
+
"comark-tabs": "^0.7.2",
|
|
89
|
+
"comark-tests": "^0.7.2",
|
|
90
|
+
"comark-sources": "^0.7.2",
|
|
91
|
+
"comark-xref": "^0.7.2",
|
|
92
|
+
"comark-zoom": "^0.7.2"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@comark/html": "^0.8.1",
|