@limcpf/everything-is-a-markdown 0.6.4 → 0.6.5
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/package.json +1 -1
- package/src/runtime/app.css +13 -0
- package/src/runtime/app.js +36 -0
package/package.json
CHANGED
package/src/runtime/app.css
CHANGED
|
@@ -67,6 +67,8 @@
|
|
|
67
67
|
--content-heading-accent-soft: rgba(136, 57, 239, 0.32);
|
|
68
68
|
--content-heading-subtle: var(--latte-subtext1);
|
|
69
69
|
--content-visual-max-width: 720px;
|
|
70
|
+
--mermaid-wide-max-width: 640px;
|
|
71
|
+
--mermaid-tall-max-height: 560px;
|
|
70
72
|
--desktop-sidebar-default: 420px;
|
|
71
73
|
--desktop-sidebar-min: 320px;
|
|
72
74
|
--desktop-viewer-min: 680px;
|
|
@@ -1102,6 +1104,9 @@ body.mobile-toggle-left .mobile-menu-toggle {
|
|
|
1102
1104
|
.viewer-content .mermaid-block {
|
|
1103
1105
|
margin: 1.5rem 0;
|
|
1104
1106
|
padding: 16px 18px;
|
|
1107
|
+
max-width: min(100%, var(--content-visual-max-width));
|
|
1108
|
+
margin-left: auto;
|
|
1109
|
+
margin-right: auto;
|
|
1105
1110
|
border-radius: 12px;
|
|
1106
1111
|
border: 1px solid var(--latte-surface0);
|
|
1107
1112
|
background: linear-gradient(180deg, var(--latte-base), var(--latte-mantle));
|
|
@@ -1142,6 +1147,14 @@ body.mobile-toggle-left .mobile-menu-toggle {
|
|
|
1142
1147
|
margin: 0 auto;
|
|
1143
1148
|
}
|
|
1144
1149
|
|
|
1150
|
+
.viewer-content .mermaid-block.is-wide pre.mermaid[data-mermaid-rendered="true"] svg {
|
|
1151
|
+
max-width: min(100%, var(--mermaid-wide-max-width));
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
.viewer-content .mermaid-block.is-tall pre.mermaid[data-mermaid-rendered="true"] svg {
|
|
1155
|
+
max-height: min(var(--mermaid-tall-max-height), 68vh);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1145
1158
|
.viewer-content .mermaid-block .mermaid-render-error {
|
|
1146
1159
|
margin: 12px 0 0;
|
|
1147
1160
|
padding: 10px 12px;
|
package/src/runtime/app.js
CHANGED
|
@@ -22,6 +22,10 @@ const MERMAID_SELECTOR = "pre.mermaid";
|
|
|
22
22
|
const MERMAID_ERROR_CLASS = "mermaid-render-error";
|
|
23
23
|
const MERMAID_THEME_VALIDATION_RE = /^[a-zA-Z][a-zA-Z0-9._-]*$/;
|
|
24
24
|
const MERMAID_URL_VALIDATION_RE = /^(https?:\/\/|\/|\.{1,2}\/)[^\s"'<>]+$/;
|
|
25
|
+
const MERMAID_WIDE_RATIO = 2.4;
|
|
26
|
+
const MERMAID_TALL_RATIO = 0.85;
|
|
27
|
+
const MERMAID_BLOCK_WIDE_CLASS = "is-wide";
|
|
28
|
+
const MERMAID_BLOCK_TALL_CLASS = "is-tall";
|
|
25
29
|
const mermaidRuntime = {
|
|
26
30
|
initialized: false,
|
|
27
31
|
loadingPromise: null,
|
|
@@ -109,16 +113,47 @@ function normalizeRenderedMermaidSvg(block) {
|
|
|
109
113
|
return;
|
|
110
114
|
}
|
|
111
115
|
|
|
116
|
+
const container = block.parentElement instanceof HTMLElement ? block.parentElement : null;
|
|
112
117
|
const svg = block.querySelector("svg");
|
|
113
118
|
if (!(svg instanceof SVGElement)) {
|
|
114
119
|
return;
|
|
115
120
|
}
|
|
116
121
|
|
|
122
|
+
if (container) {
|
|
123
|
+
container.classList.remove(MERMAID_BLOCK_WIDE_CLASS, MERMAID_BLOCK_TALL_CLASS);
|
|
124
|
+
}
|
|
125
|
+
|
|
117
126
|
svg.style.display = "block";
|
|
118
127
|
svg.style.width = "auto";
|
|
119
128
|
svg.style.height = "auto";
|
|
120
129
|
svg.style.margin = "0 auto";
|
|
121
130
|
svg.style.maxWidth = "min(100%, var(--content-visual-max-width, 720px))";
|
|
131
|
+
svg.style.removeProperty("max-height");
|
|
132
|
+
|
|
133
|
+
const viewBox = svg.viewBox?.baseVal;
|
|
134
|
+
const intrinsicWidth =
|
|
135
|
+
viewBox && Number.isFinite(viewBox.width) && viewBox.width > 0
|
|
136
|
+
? viewBox.width
|
|
137
|
+
: Number.parseFloat(svg.getAttribute("width") ?? "");
|
|
138
|
+
const intrinsicHeight =
|
|
139
|
+
viewBox && Number.isFinite(viewBox.height) && viewBox.height > 0
|
|
140
|
+
? viewBox.height
|
|
141
|
+
: Number.parseFloat(svg.getAttribute("height") ?? "");
|
|
142
|
+
|
|
143
|
+
if (!(intrinsicWidth > 0) || !(intrinsicHeight > 0)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const aspectRatio = intrinsicWidth / intrinsicHeight;
|
|
148
|
+
if (container && aspectRatio >= MERMAID_WIDE_RATIO) {
|
|
149
|
+
container.classList.add(MERMAID_BLOCK_WIDE_CLASS);
|
|
150
|
+
svg.style.maxWidth = "min(100%, var(--mermaid-wide-max-width, 640px))";
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (container && aspectRatio <= MERMAID_TALL_RATIO) {
|
|
154
|
+
container.classList.add(MERMAID_BLOCK_TALL_CLASS);
|
|
155
|
+
svg.style.maxHeight = "min(var(--mermaid-tall-max-height, 560px), 68vh)";
|
|
156
|
+
}
|
|
122
157
|
}
|
|
123
158
|
|
|
124
159
|
function parseMermaidNodes() {
|
|
@@ -134,6 +169,7 @@ function resetMermaidNodes(nodes) {
|
|
|
134
169
|
for (const node of nodes) {
|
|
135
170
|
node.removeAttribute("data-mermaid-rendered");
|
|
136
171
|
if (node.parentElement instanceof HTMLElement) {
|
|
172
|
+
node.parentElement.classList.remove(MERMAID_BLOCK_WIDE_CLASS, MERMAID_BLOCK_TALL_CLASS);
|
|
137
173
|
removeMermaidErrorMessage(node.parentElement);
|
|
138
174
|
}
|
|
139
175
|
}
|