markdown-flow-ui 0.1.129 → 0.2.1
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/_virtual/index.cjs8.js +1 -1
- package/dist/_virtual/index.cjs9.js +1 -1
- package/dist/_virtual/index.es8.js +2 -2
- package/dist/_virtual/index.es9.js +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +4 -0
- package/dist/components/ContentRender/ContentRender.es.js +217 -211
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.stories.d.ts +1 -0
- package/dist/components/ContentRender/IframeSandbox.cjs.js +4 -4
- package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.d.ts +3 -0
- package/dist/components/ContentRender/IframeSandbox.es.js +210 -196
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.cjs.js +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.cjs.js.map +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.d.ts +3 -0
- package/dist/components/ContentRender/MarkdownFlowInput.es.js +35 -32
- package/dist/components/ContentRender/MarkdownFlowInput.es.js.map +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.stories.d.ts +6 -0
- package/dist/components/ContentRender/SandboxApp.cjs.js +2 -2
- package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.d.ts +3 -0
- package/dist/components/ContentRender/SandboxApp.es.js +117 -104
- package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
- package/dist/components/ContentRender/blackboard-vendor.cjs.js +1 -1
- package/dist/components/ContentRender/blackboard-vendor.cjs.js.map +1 -1
- package/dist/components/ContentRender/blackboard-vendor.es.js +14 -9
- package/dist/components/ContentRender/blackboard-vendor.es.js.map +1 -1
- package/dist/components/ContentRender/cjkFontFamily.cjs.js +2 -0
- package/dist/components/ContentRender/cjkFontFamily.cjs.js.map +1 -0
- package/dist/components/ContentRender/cjkFontFamily.d.ts +5 -0
- package/dist/components/ContentRender/cjkFontFamily.es.js +45 -0
- package/dist/components/ContentRender/cjkFontFamily.es.js.map +1 -0
- package/dist/components/ContentRender/cjkFontFamily.test.d.ts +1 -0
- package/dist/components/ContentRender/contentRenderI18n.cjs.js +2 -0
- package/dist/components/ContentRender/contentRenderI18n.cjs.js.map +1 -0
- package/dist/components/ContentRender/contentRenderI18n.d.ts +15 -0
- package/dist/components/ContentRender/contentRenderI18n.es.js +59 -0
- package/dist/components/ContentRender/contentRenderI18n.es.js.map +1 -0
- package/dist/components/ContentRender/index.cjs.js +1 -1
- package/dist/components/ContentRender/index.d.ts +1 -0
- package/dist/components/ContentRender/index.es.js +1 -0
- package/dist/components/ContentRender/index.es.js.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.d.ts +3 -1
- package/dist/components/ContentRender/plugins/CustomVariable.es.js +131 -124
- package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
- package/dist/components/ContentRender/plugins/MermaidChart.cjs.js +1 -1
- package/dist/components/ContentRender/plugins/MermaidChart.cjs.js.map +1 -1
- package/dist/components/ContentRender/plugins/MermaidChart.es.js +19 -18
- package/dist/components/ContentRender/plugins/MermaidChart.es.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +3 -0
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js +18 -15
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.stories.d.ts +6 -0
- package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.d.ts +1 -0
- package/dist/components/MarkdownFlow/index.cjs.js +1 -1
- package/dist/components/MarkdownFlow/index.es.js +1 -0
- package/dist/components/MarkdownFlow/index.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.js +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.d.ts +2 -2
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +23 -22
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.stories.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/editorI18n.cjs.js +1 -1
- package/dist/components/MarkdownFlowEditor/editorI18n.cjs.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/editorI18n.d.ts +0 -2
- package/dist/components/MarkdownFlowEditor/editorI18n.es.js +12 -24
- package/dist/components/MarkdownFlowEditor/editorI18n.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/index.d.ts +1 -1
- package/dist/components/Slide/Player.cjs.js +1 -1
- package/dist/components/Slide/Player.cjs.js.map +1 -1
- package/dist/components/Slide/Player.d.ts +14 -30
- package/dist/components/Slide/Player.es.js +395 -383
- package/dist/components/Slide/Player.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs.js +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.d.ts +22 -4
- package/dist/components/Slide/Slide.es.js +701 -659
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/Slide.stories.d.ts +19 -20
- package/dist/components/Slide/constants.d.ts +0 -24
- package/dist/components/Slide/index.d.ts +2 -1
- package/dist/components/Slide/slideI18n.cjs.js +2 -0
- package/dist/components/Slide/slideI18n.cjs.js.map +1 -0
- package/dist/components/Slide/slideI18n.d.ts +44 -0
- package/dist/components/Slide/slideI18n.es.js +158 -0
- package/dist/components/Slide/slideI18n.es.js.map +1 -0
- package/dist/components/Slide/slideI18n.test.d.ts +1 -0
- package/dist/components/Slide/utils/playerVisibility.cjs.js +2 -0
- package/dist/components/Slide/utils/playerVisibility.cjs.js.map +1 -0
- package/dist/components/Slide/utils/playerVisibility.d.ts +10 -0
- package/dist/components/Slide/utils/playerVisibility.es.js +11 -0
- package/dist/components/Slide/utils/playerVisibility.es.js.map +1 -0
- package/dist/components/Slide/utils/playerVisibility.test.d.ts +1 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/editor.d.ts +3 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +14 -13
- package/dist/index.es.js.map +1 -1
- package/dist/lib/locale.cjs.js +2 -0
- package/dist/lib/locale.cjs.js.map +1 -0
- package/dist/lib/locale.d.ts +4 -0
- package/dist/lib/locale.es.js +19 -0
- package/dist/lib/locale.es.js.map +1 -0
- package/dist/lib/localeTextMap.cjs.js +2 -0
- package/dist/lib/localeTextMap.cjs.js.map +1 -0
- package/dist/lib/localeTextMap.d.ts +4 -0
- package/dist/lib/localeTextMap.es.js +5 -0
- package/dist/lib/localeTextMap.es.js.map +1 -0
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/node_modules/classnames/index.cjs.js +1 -1
- package/dist/node_modules/classnames/index.es.js +1 -1
- package/dist/renderer.cjs.js +1 -1
- package/dist/renderer.d.ts +1 -0
- package/dist/renderer.es.js +15 -14
- package/dist/renderer.es.js.map +1 -1
- package/dist/slide.d.ts +1 -0
- package/package.json +1 -1
- package/dist/components/Slide/constants.cjs.js +0 -2
- package/dist/components/Slide/constants.cjs.js.map +0 -1
- package/dist/components/Slide/constants.es.js +0 -28
- package/dist/components/Slide/constants.es.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { j as R } from "../../_virtual/jsx-runtime.es.js";
|
|
2
|
+
import { useRef as f, useState as q, useEffect as N } from "react";
|
|
3
|
+
import oe from "../ui/loading-overlay-card.es.js";
|
|
4
|
+
import { getContentRenderLocaleTexts as ae } from "./contentRenderI18n.es.js";
|
|
5
|
+
const ce = [
|
|
5
6
|
"src",
|
|
6
7
|
"srcset",
|
|
7
8
|
"sizes",
|
|
@@ -15,53 +16,55 @@ const Z = [
|
|
|
15
16
|
"crossorigin",
|
|
16
17
|
"referrerpolicy",
|
|
17
18
|
"fetchpriority"
|
|
18
|
-
],
|
|
19
|
-
(
|
|
20
|
-
).join("|"),
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
}),
|
|
26
|
-
},
|
|
27
|
-
const
|
|
28
|
-
|
|
19
|
+
], J = (o) => ce.map(
|
|
20
|
+
(n) => `${n}:${o.getAttribute(n) || ""}`
|
|
21
|
+
).join("|"), ie = (o) => {
|
|
22
|
+
const n = /* @__PURE__ */ new Map();
|
|
23
|
+
return o.querySelectorAll("img").forEach((i) => {
|
|
24
|
+
const l = i, r = J(l), c = n.get(r) || [];
|
|
25
|
+
c.push(l), n.set(r, c);
|
|
26
|
+
}), n;
|
|
27
|
+
}, le = (o, n) => {
|
|
28
|
+
const i = Array.from(o.attributes), l = new Set(
|
|
29
|
+
i.map((r) => r.name)
|
|
29
30
|
);
|
|
30
|
-
Array.from(
|
|
31
|
-
|
|
32
|
-
}),
|
|
33
|
-
|
|
31
|
+
Array.from(n.attributes).forEach((r) => {
|
|
32
|
+
l.has(r.name) || n.removeAttribute(r.name);
|
|
33
|
+
}), i.forEach((r) => {
|
|
34
|
+
n.setAttribute(r.name, r.value);
|
|
34
35
|
});
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
p && (
|
|
36
|
+
}, ue = (o, n) => {
|
|
37
|
+
n.size && o.querySelectorAll("img").forEach((i) => {
|
|
38
|
+
const l = i, r = J(l), c = n.get(r), p = c?.shift();
|
|
39
|
+
p && (le(l, p), l.replaceWith(p), c && c.length === 0 && n.delete(r));
|
|
39
40
|
});
|
|
40
|
-
},
|
|
41
|
-
html:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
}, ye = ({
|
|
42
|
+
html: o,
|
|
43
|
+
locale: n,
|
|
44
|
+
loadingText: i,
|
|
45
|
+
styleLoadingText: l,
|
|
46
|
+
scriptLoadingText: r,
|
|
47
|
+
resetToken: c = 0,
|
|
48
|
+
mode: p = "content",
|
|
49
|
+
hasRootVhHeight: P = !1,
|
|
50
|
+
stretchRootHeight: X = !1,
|
|
51
|
+
enableScaling: z = !1,
|
|
52
|
+
disableLoadingOverlay: j = !1
|
|
50
53
|
}) => {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
54
|
+
const T = ae(n), L = f(null), [Y, S] = q(!1), [Z, C] = q(!1), [ee, M] = q(!1), _ = f([]), k = f([]), F = f(0), U = f(0), y = f(null), g = f(null), b = f(!1), x = f(!1), W = f(c), te = 200, d = (t) => {
|
|
55
|
+
t.current && (clearTimeout(t.current), t.current = null);
|
|
56
|
+
}, B = (t, a, u, D) => {
|
|
57
|
+
const m = performance.now() - u.current, I = Math.max(0, te - m);
|
|
58
|
+
d(a), a.current = window.setTimeout(() => {
|
|
59
|
+
t(!1), D?.(), a.current = null;
|
|
60
|
+
}, I);
|
|
58
61
|
};
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
62
|
+
N(() => {
|
|
63
|
+
const t = L.current?.ownerDocument;
|
|
64
|
+
if (!t) return;
|
|
62
65
|
const a = "sandbox-spinner-style";
|
|
63
|
-
let
|
|
64
|
-
|
|
66
|
+
let u = t.getElementById(a);
|
|
67
|
+
u || (u = t.createElement("style"), u.id = a, t.head?.appendChild(u)), u.textContent = `
|
|
65
68
|
.sandbox-wrapper { align-items: center; }
|
|
66
69
|
.sandbox-container { position: relative; width: 100%; }
|
|
67
70
|
.sandbox-container svg,
|
|
@@ -81,117 +84,127 @@ const Z = [
|
|
|
81
84
|
}
|
|
82
85
|
.overflow-y-auto { overflow-y: visible !important; }
|
|
83
86
|
`;
|
|
84
|
-
}, []),
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
88
|
-
const a =
|
|
89
|
-
if (!
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
Array.from(
|
|
87
|
+
}, []), N(() => {
|
|
88
|
+
c !== W.current && (M(!1), W.current = c), d(y), d(g), b.current = !1, x.current = !1;
|
|
89
|
+
const t = L.current;
|
|
90
|
+
if (!t) return;
|
|
91
|
+
const a = t.ownerDocument, u = a?.body;
|
|
92
|
+
if (!u) return;
|
|
93
|
+
const D = ie(t);
|
|
94
|
+
_.current.forEach((e) => e.remove()), _.current = [], k.current.forEach((e) => e.remove()), k.current = [], S(!1), C(!1);
|
|
95
|
+
const m = a.createElement("div");
|
|
96
|
+
m.innerHTML = o;
|
|
97
|
+
const I = (o.match(/<script[\s>]/gi) || []).length, se = (o.match(/<\/script>/gi) || []).length, V = I > 0 && I === se, w = [];
|
|
98
|
+
Array.from(m.querySelectorAll("style, script")).forEach((e) => {
|
|
96
99
|
if (e.tagName.toLowerCase() === "style") {
|
|
97
100
|
const s = a.createElement("style");
|
|
98
|
-
s.textContent = e.textContent || "", Array.from(e.attributes).forEach((
|
|
99
|
-
s.setAttribute(
|
|
100
|
-
}),
|
|
101
|
+
s.textContent = e.textContent || "", Array.from(e.attributes).forEach((h) => {
|
|
102
|
+
s.setAttribute(h.name, h.value);
|
|
103
|
+
}), w.push(s);
|
|
101
104
|
} else {
|
|
102
105
|
const s = a.createElement("script");
|
|
103
|
-
Array.from(e.attributes).forEach((
|
|
104
|
-
s.setAttribute(
|
|
105
|
-
}), s.textContent = e.textContent || "",
|
|
106
|
+
Array.from(e.attributes).forEach((h) => {
|
|
107
|
+
s.setAttribute(h.name, h.value);
|
|
108
|
+
}), s.textContent = e.textContent || "", w.push(s);
|
|
106
109
|
}
|
|
107
110
|
e.remove();
|
|
108
|
-
}),
|
|
109
|
-
const
|
|
111
|
+
}), ue(m, D);
|
|
112
|
+
const O = w.some(
|
|
110
113
|
(e) => e.tagName.toLowerCase() === "style"
|
|
111
|
-
),
|
|
114
|
+
), G = w.some(
|
|
112
115
|
(e) => e.tagName.toLowerCase() === "script"
|
|
113
116
|
);
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
+
O && (b.current = !0, F.current = performance.now(), d(y), S(!0)), G && (x.current = !0, U.current = performance.now(), d(g), C(!0));
|
|
118
|
+
const $ = Array.from(m.childNodes), K = $.length > 0;
|
|
119
|
+
M(K), t.replaceChildren(...$);
|
|
120
|
+
let v = null;
|
|
121
|
+
const Q = () => t.childNodes.length === 0 ? !1 : (M(!0), v?.disconnect(), v = null, !0);
|
|
122
|
+
return !K && G && V && (v = new MutationObserver(() => {
|
|
123
|
+
Q();
|
|
124
|
+
}), v.observe(t, {
|
|
125
|
+
childList: !0,
|
|
126
|
+
subtree: !0
|
|
127
|
+
})), w.forEach((e) => {
|
|
117
128
|
if (e.tagName.toLowerCase() === "style") {
|
|
118
|
-
a.head?.appendChild(e),
|
|
129
|
+
a.head?.appendChild(e), _.current.push(e);
|
|
119
130
|
return;
|
|
120
131
|
}
|
|
121
|
-
if (
|
|
122
|
-
const s = e,
|
|
132
|
+
if (V) {
|
|
133
|
+
const s = e, h = s.textContent || "";
|
|
123
134
|
if (!s.src)
|
|
124
135
|
try {
|
|
125
|
-
new Function(
|
|
136
|
+
new Function(h);
|
|
126
137
|
} catch {
|
|
127
138
|
s.remove();
|
|
128
139
|
return;
|
|
129
140
|
}
|
|
130
141
|
try {
|
|
131
|
-
|
|
142
|
+
u.appendChild(s), k.current.push(s);
|
|
132
143
|
} catch {
|
|
133
144
|
s.remove();
|
|
134
145
|
}
|
|
135
146
|
} else
|
|
136
147
|
e.remove();
|
|
137
|
-
}),
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
}), Q(), z && t.ownerDocument?.defaultView?.__mdf_triggerFitContent?.(), requestAnimationFrame(() => {
|
|
149
|
+
O && B(
|
|
150
|
+
S,
|
|
140
151
|
y,
|
|
141
|
-
|
|
152
|
+
F,
|
|
142
153
|
() => {
|
|
143
154
|
b.current = !1;
|
|
144
155
|
}
|
|
145
|
-
),
|
|
146
|
-
|
|
156
|
+
), G && B(
|
|
157
|
+
C,
|
|
147
158
|
g,
|
|
148
|
-
|
|
159
|
+
U,
|
|
149
160
|
() => {
|
|
150
|
-
|
|
161
|
+
x.current = !1;
|
|
151
162
|
}
|
|
152
163
|
);
|
|
153
|
-
})
|
|
154
|
-
|
|
164
|
+
}), () => {
|
|
165
|
+
v?.disconnect();
|
|
166
|
+
};
|
|
167
|
+
}, [o, c, z]), N(
|
|
155
168
|
() => () => {
|
|
156
|
-
|
|
169
|
+
d(y), d(g);
|
|
157
170
|
},
|
|
158
171
|
[]
|
|
159
|
-
),
|
|
160
|
-
|
|
161
|
-
}, [
|
|
162
|
-
const E =
|
|
172
|
+
), N(() => {
|
|
173
|
+
j && (d(y), d(g), b.current = !1, x.current = !1, S(!1), C(!1));
|
|
174
|
+
}, [j]);
|
|
175
|
+
const E = j ? null : Z || x.current ? r || i || T.sandboxScriptLoadingText : Y || b.current ? l || i || T.sandboxStyleLoadingText : ee ? null : i || T.sandboxLoadingText, H = p === "blackboard", A = H && X, ne = {
|
|
163
176
|
position: "relative",
|
|
164
177
|
width: "100%",
|
|
165
178
|
height: "100%",
|
|
166
179
|
display: "flex",
|
|
167
180
|
flexDirection: "column",
|
|
168
181
|
// Keep blackboard scroll behavior while centering content in non-blackboard mode
|
|
169
|
-
justifyContent:
|
|
170
|
-
},
|
|
182
|
+
justifyContent: A ? "flex-start" : H ? "space-around" : "flex-start"
|
|
183
|
+
}, re = {
|
|
171
184
|
pointerEvents: E ? "none" : void 0,
|
|
172
|
-
margin:
|
|
185
|
+
margin: H ? void 0 : "auto 0",
|
|
173
186
|
width: "100%",
|
|
174
|
-
height:
|
|
175
|
-
minHeight:
|
|
176
|
-
flex:
|
|
187
|
+
height: A ? "100%" : void 0,
|
|
188
|
+
minHeight: A ? 0 : void 0,
|
|
189
|
+
flex: A ? "1 1 auto" : void 0
|
|
177
190
|
};
|
|
178
|
-
return /* @__PURE__ */
|
|
191
|
+
return /* @__PURE__ */ R.jsxs(
|
|
179
192
|
"div",
|
|
180
193
|
{
|
|
181
|
-
"data-root-vh":
|
|
194
|
+
"data-root-vh": P ? "true" : "false",
|
|
182
195
|
className: "sandbox-wrapper",
|
|
183
|
-
style:
|
|
196
|
+
style: ne,
|
|
184
197
|
"aria-busy": !!E,
|
|
185
198
|
children: [
|
|
186
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ R.jsx(
|
|
187
200
|
"div",
|
|
188
201
|
{
|
|
189
|
-
ref:
|
|
202
|
+
ref: L,
|
|
190
203
|
className: "sandbox-container",
|
|
191
|
-
style:
|
|
204
|
+
style: re
|
|
192
205
|
}
|
|
193
206
|
),
|
|
194
|
-
E && /* @__PURE__ */
|
|
207
|
+
E && /* @__PURE__ */ R.jsx(
|
|
195
208
|
"div",
|
|
196
209
|
{
|
|
197
210
|
style: {
|
|
@@ -203,7 +216,7 @@ const Z = [
|
|
|
203
216
|
justifyContent: "center",
|
|
204
217
|
pointerEvents: "none"
|
|
205
218
|
},
|
|
206
|
-
children: /* @__PURE__ */
|
|
219
|
+
children: /* @__PURE__ */ R.jsx(oe, { message: E })
|
|
207
220
|
}
|
|
208
221
|
)
|
|
209
222
|
]
|
|
@@ -211,6 +224,6 @@ const Z = [
|
|
|
211
224
|
);
|
|
212
225
|
};
|
|
213
226
|
export {
|
|
214
|
-
|
|
227
|
+
ye as default
|
|
215
228
|
};
|
|
216
229
|
//# sourceMappingURL=SandboxApp.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxApp.es.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\nimport type { ScalingWindow } from \"./utils/iframe-scaling\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n enableScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"fetchpriority\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n enableScaling = false,\n disableLoadingOverlay = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { position: relative; width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n /* Hide scroll UI without removing scroll semantics. Content roots with\n inline style=\"height:100vh; overflow-y:auto\" are the signal that\n IframeSandbox.getInnerScrollableHeight relies on to grow the iframe\n when content exceeds the viewport. We must not change overflow-y,\n but sub-pixel rounding (1px below the +1 detection threshold) can\n still surface a phantom scrollbar on content that visually fits.\n Hide the scrollbar UI globally; when content truly overflows the\n iframe is resized and no scrollbar would render anyway. */\n .sandbox-container *::-webkit-scrollbar { display: none; }\n .sandbox-container * { scrollbar-width: none; -ms-overflow-style: none; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n .overflow-y-auto { overflow-y: visible !important; }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n // const hasRenderedBefore = hasRenderedContentRef.current;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.replaceChildren(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n if (enableScaling) {\n const win = container.ownerDocument?.defaultView as ScalingWindow | null;\n win?.__mdf_triggerFitContent?.();\n }\n\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken, enableScaling]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n useEffect(() => {\n if (!disableLoadingOverlay) {\n return;\n }\n\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n }, [disableLoadingOverlay]);\n\n const overlayMessage = (() => {\n if (disableLoadingOverlay) {\n return null;\n }\n\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n zIndex: 20,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <LoadingOverlayCard message={overlayMessage} />\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","enableScaling","disableLoadingOverlay","containerRef","useRef","isGeneratingStyles","setIsGeneratingStyles","useState","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWr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AA;AAAA,EAAA;AAIR;"}
|
|
1
|
+
{"version":3,"file":"SandboxApp.es.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport type { ScalingWindow } from \"./utils/iframe-scaling\";\n\nexport interface SandboxAppProps {\n html: string;\n locale?: MarkdownFlowLocale;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n enableScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"fetchpriority\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n locale,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n enableScaling = false,\n disableLoadingOverlay = false,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const containerRef = useRef<HTMLDivElement>(null);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const [hasRenderedContent, setHasRenderedContent] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { position: relative; width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n /* Hide scroll UI without removing scroll semantics. Content roots with\n inline style=\"height:100vh; overflow-y:auto\" are the signal that\n IframeSandbox.getInnerScrollableHeight relies on to grow the iframe\n when content exceeds the viewport. We must not change overflow-y,\n but sub-pixel rounding (1px below the +1 detection threshold) can\n still surface a phantom scrollbar on content that visually fits.\n Hide the scrollbar UI globally; when content truly overflows the\n iframe is resized and no scrollbar would render anyway. */\n .sandbox-container *::-webkit-scrollbar { display: none; }\n .sandbox-container * { scrollbar-width: none; -ms-overflow-style: none; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n .overflow-y-auto { overflow-y: visible !important; }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n setHasRenderedContent(false);\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n const hasInitialContent = contentNodes.length > 0;\n setHasRenderedContent(hasInitialContent);\n container.replaceChildren(...contentNodes);\n\n let scriptContentObserver: MutationObserver | null = null;\n const markRenderedContentFromContainer = () => {\n if (container.childNodes.length === 0) {\n return false;\n }\n\n setHasRenderedContent(true);\n scriptContentObserver?.disconnect();\n scriptContentObserver = null;\n return true;\n };\n if (!hasInitialContent && hasScripts && shouldExecuteScripts) {\n scriptContentObserver = new MutationObserver(() => {\n markRenderedContentFromContainer();\n });\n scriptContentObserver.observe(container, {\n childList: true,\n subtree: true,\n });\n }\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n markRenderedContentFromContainer();\n if (enableScaling) {\n const win = container.ownerDocument?.defaultView as ScalingWindow | null;\n win?.__mdf_triggerFitContent?.();\n }\n\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n\n return () => {\n scriptContentObserver?.disconnect();\n };\n }, [html, resetToken, enableScaling]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n useEffect(() => {\n if (!disableLoadingOverlay) {\n return;\n }\n\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n }, [disableLoadingOverlay]);\n\n const overlayMessage = (() => {\n if (disableLoadingOverlay) {\n return null;\n }\n\n if (isGeneratingScripts || hasScriptsRef.current)\n return (\n scriptLoadingText || loadingText || localeTexts.sandboxScriptLoadingText\n );\n if (isGeneratingStyles || hasStylesRef.current)\n return (\n styleLoadingText || loadingText || localeTexts.sandboxStyleLoadingText\n );\n if (!hasRenderedContent)\n return loadingText || localeTexts.sandboxLoadingText;\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n zIndex: 20,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <LoadingOverlayCard message={overlayMessage} />\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","locale","loadingText","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","enableScaling","disableLoadingOverlay","localeTexts","getContentRenderLocaleTexts","containerRef","useRef","isGeneratingStyles","setIsGeneratingStyles","useState","isGeneratingScripts","setIsGeneratingScripts","hasRenderedContent","setHasRenderedContent","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","contentNodes","hasInitialContent","scriptContentObserver","markRenderedContentFromContainer","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","LoadingOverlayCard"],"mappings":";;;;AAoBA,MAAMA,KAAyB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAmB,CAACC,MACxBF,GAAuB;AAAA,EACrB,CAACG,MAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,KAAK,EAAE;AACpE,EAAE,KAAK,GAAG,GAENC,KAAwB,CAACC,MAAqB;AAClD,QAAMC,wBAAe,IAAA;AACrB,SAAAD,EAAK,iBAAiB,KAAK,EAAE,QAAQ,CAACE,MAAS;AAC7C,UAAML,IAAQK,GACRC,IAAMP,EAAiBC,CAAK,GAC5BO,IAASH,EAAS,IAAIE,CAAG,KAAK,CAAA;AACpC,IAAAC,EAAO,KAAKP,CAAK,GACjBI,EAAS,IAAIE,GAAKC,CAAM;AAAA,EAC1B,CAAC,GACMH;AACT,GAEMI,KAAsB,CAC1BC,GACAC,MACG;AACH,QAAMC,IAAmB,MAAM,KAAKF,EAAY,UAAU,GACpDG,IAAuB,IAAI;AAAA,IAC/BD,EAAiB,IAAI,CA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V,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,eAAe;AAAA;AAAA,IAEf,gBAAgBD,IACZ,eACAD,IACE,iBACA;AAAA,EAAA,GAEFG,KAA6C;AAAA,IACjD,eAAeJ,IAAiB,SAAS;AAAA,IACzC,QAAQC,IAAe,SAAY;AAAA,IACnC,OAAO;AAAA,IACP,QAAQC,IAA0B,SAAS;AAAA,IAC3C,WAAWA,IAA0B,IAAI;AAAA,IACzC,MAAMA,IAA0B,aAAa;AAAA,EAAA;AAG/C,SACEG,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,gBAAc7D,IAAkB,SAAS;AAAA,MACzC,WAAU;AAAA,MACV,OAAO2D;AAAA,MACP,aAAW,CAAC,CAACH;AAAA,MAEb,UAAA;AAAA,QAAAM,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAKxD;AAAA,YACL,WAAU;AAAA,YACV,OAAOsD;AAAA,UAAA;AAAA,QAAA;AAAA,QAERJ,KACCM,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,eAAe;AAAA,YAAA;AAAA,YAGjB,UAAAA,gBAAAA,EAAAA,IAACC,IAAA,EAAmB,SAASP,EAAA,CAAgB;AAAA,UAAA;AAAA,QAAA;AAAA,MAC/C;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./vendor/tailwindcss-v3.min.cjs.js"),r=require("./vendor/daisyui-v4.min.css.cjs.js"),s=require("./vendor/gsap-v3.min.cjs.js"),d=require("./cjkFontFamily.cjs.js");function c(e){const i=e.createElement("script");i.textContent=l.default,e.head.appendChild(i);const t=e.defaultView?.tailwind;t&&(t.config=d.addCjkSafeSansToTailwindConfig(t.config));const n=e.createElement("style");n.textContent=r.default,e.head.appendChild(n);const a=e.createElement("script");a.textContent=s.default,e.head.appendChild(a)}exports.injectBlackboardLibraries=c;
|
|
2
2
|
//# sourceMappingURL=blackboard-vendor.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blackboard-vendor.cjs.js","sources":["../../../src/components/ContentRender/blackboard-vendor.ts"],"sourcesContent":["import tailwindScript from \"./vendor/tailwindcss-v3.min.js?raw\";\nimport daisyuiCss from \"./vendor/daisyui-v4.min.css?raw\";\nimport gsapScript from \"./vendor/gsap-v3.min.js?raw\";\n\n/**\n * Inject blackboard-mode libraries (Tailwind CSS, DaisyUI, GSAP)\n * into an iframe document using DOM API to avoid template-string escaping issues.\n */\nexport function injectBlackboardLibraries(doc: Document): void {\n // 1. Tailwind CSS v3 (JIT compiler, must load first)\n const tailwindEl = doc.createElement(\"script\");\n tailwindEl.textContent = tailwindScript;\n doc.head.appendChild(tailwindEl);\n\n // 2. DaisyUI v4 CSS\n const daisyuiEl = doc.createElement(\"style\");\n daisyuiEl.textContent = daisyuiCss;\n doc.head.appendChild(daisyuiEl);\n\n // 3. GSAP v3\n const gsapEl = doc.createElement(\"script\");\n gsapEl.textContent = gsapScript;\n doc.head.appendChild(gsapEl);\n}\n"],"names":["injectBlackboardLibraries","doc","tailwindEl","tailwindScript","daisyuiEl","daisyuiCss","gsapEl","gsapScript"],"mappings":"
|
|
1
|
+
{"version":3,"file":"blackboard-vendor.cjs.js","sources":["../../../src/components/ContentRender/blackboard-vendor.ts"],"sourcesContent":["import tailwindScript from \"./vendor/tailwindcss-v3.min.js?raw\";\nimport daisyuiCss from \"./vendor/daisyui-v4.min.css?raw\";\nimport gsapScript from \"./vendor/gsap-v3.min.js?raw\";\nimport { addCjkSafeSansToTailwindConfig } from \"./cjkFontFamily\";\n\ninterface TailwindRuntimeWindow extends Window {\n tailwind?: {\n config?: unknown;\n };\n}\n\n/**\n * Inject blackboard-mode libraries (Tailwind CSS, DaisyUI, GSAP)\n * into an iframe document using DOM API to avoid template-string escaping issues.\n */\nexport function injectBlackboardLibraries(doc: Document): void {\n // 1. Tailwind CSS v3 (JIT compiler, must load first)\n const tailwindEl = doc.createElement(\"script\");\n tailwindEl.textContent = tailwindScript;\n // The Play CDN script replaces window.tailwind with its Proxy during execution,\n // so configure that runtime only after the synchronous append completes.\n doc.head.appendChild(tailwindEl);\n const tailwindRuntime = (doc.defaultView as TailwindRuntimeWindow | null)\n ?.tailwind;\n if (tailwindRuntime) {\n tailwindRuntime.config = addCjkSafeSansToTailwindConfig(\n tailwindRuntime.config\n );\n }\n\n // 2. DaisyUI v4 CSS\n const daisyuiEl = doc.createElement(\"style\");\n daisyuiEl.textContent = daisyuiCss;\n doc.head.appendChild(daisyuiEl);\n\n // 3. GSAP v3\n const gsapEl = doc.createElement(\"script\");\n gsapEl.textContent = gsapScript;\n doc.head.appendChild(gsapEl);\n}\n"],"names":["injectBlackboardLibraries","doc","tailwindEl","tailwindScript","tailwindRuntime","addCjkSafeSansToTailwindConfig","daisyuiEl","daisyuiCss","gsapEl","gsapScript"],"mappings":"mQAeO,SAASA,EAA0BC,EAAqB,CAE7D,MAAMC,EAAaD,EAAI,cAAc,QAAQ,EAC7CC,EAAW,YAAcC,EAAAA,QAGzBF,EAAI,KAAK,YAAYC,CAAU,EAC/B,MAAME,EAAmBH,EAAI,aACzB,SACAG,IACFA,EAAgB,OAASC,EAAAA,+BACvBD,EAAgB,MAAA,GAKpB,MAAME,EAAYL,EAAI,cAAc,OAAO,EAC3CK,EAAU,YAAcC,EAAAA,QACxBN,EAAI,KAAK,YAAYK,CAAS,EAG9B,MAAME,EAASP,EAAI,cAAc,QAAQ,EACzCO,EAAO,YAAcC,EAAAA,QACrBR,EAAI,KAAK,YAAYO,CAAM,CAC7B"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import r from "./vendor/tailwindcss-v3.min.es.js";
|
|
2
|
+
import l from "./vendor/daisyui-v4.min.css.es.js";
|
|
3
3
|
import p from "./vendor/gsap-v3.min.es.js";
|
|
4
|
-
|
|
4
|
+
import { addCjkSafeSansToTailwindConfig as o } from "./cjkFontFamily.es.js";
|
|
5
|
+
function c(t) {
|
|
5
6
|
const e = t.createElement("script");
|
|
6
|
-
e.textContent =
|
|
7
|
-
const i = t.
|
|
8
|
-
i.
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
e.textContent = r, t.head.appendChild(e);
|
|
8
|
+
const i = t.defaultView?.tailwind;
|
|
9
|
+
i && (i.config = o(
|
|
10
|
+
i.config
|
|
11
|
+
));
|
|
12
|
+
const n = t.createElement("style");
|
|
13
|
+
n.textContent = l, t.head.appendChild(n);
|
|
14
|
+
const a = t.createElement("script");
|
|
15
|
+
a.textContent = p, t.head.appendChild(a);
|
|
11
16
|
}
|
|
12
17
|
export {
|
|
13
|
-
|
|
18
|
+
c as injectBlackboardLibraries
|
|
14
19
|
};
|
|
15
20
|
//# sourceMappingURL=blackboard-vendor.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blackboard-vendor.es.js","sources":["../../../src/components/ContentRender/blackboard-vendor.ts"],"sourcesContent":["import tailwindScript from \"./vendor/tailwindcss-v3.min.js?raw\";\nimport daisyuiCss from \"./vendor/daisyui-v4.min.css?raw\";\nimport gsapScript from \"./vendor/gsap-v3.min.js?raw\";\n\n/**\n * Inject blackboard-mode libraries (Tailwind CSS, DaisyUI, GSAP)\n * into an iframe document using DOM API to avoid template-string escaping issues.\n */\nexport function injectBlackboardLibraries(doc: Document): void {\n // 1. Tailwind CSS v3 (JIT compiler, must load first)\n const tailwindEl = doc.createElement(\"script\");\n tailwindEl.textContent = tailwindScript;\n doc.head.appendChild(tailwindEl);\n\n // 2. DaisyUI v4 CSS\n const daisyuiEl = doc.createElement(\"style\");\n daisyuiEl.textContent = daisyuiCss;\n doc.head.appendChild(daisyuiEl);\n\n // 3. GSAP v3\n const gsapEl = doc.createElement(\"script\");\n gsapEl.textContent = gsapScript;\n doc.head.appendChild(gsapEl);\n}\n"],"names":["injectBlackboardLibraries","doc","tailwindEl","tailwindScript","daisyuiEl","daisyuiCss","gsapEl","gsapScript"],"mappings":"
|
|
1
|
+
{"version":3,"file":"blackboard-vendor.es.js","sources":["../../../src/components/ContentRender/blackboard-vendor.ts"],"sourcesContent":["import tailwindScript from \"./vendor/tailwindcss-v3.min.js?raw\";\nimport daisyuiCss from \"./vendor/daisyui-v4.min.css?raw\";\nimport gsapScript from \"./vendor/gsap-v3.min.js?raw\";\nimport { addCjkSafeSansToTailwindConfig } from \"./cjkFontFamily\";\n\ninterface TailwindRuntimeWindow extends Window {\n tailwind?: {\n config?: unknown;\n };\n}\n\n/**\n * Inject blackboard-mode libraries (Tailwind CSS, DaisyUI, GSAP)\n * into an iframe document using DOM API to avoid template-string escaping issues.\n */\nexport function injectBlackboardLibraries(doc: Document): void {\n // 1. Tailwind CSS v3 (JIT compiler, must load first)\n const tailwindEl = doc.createElement(\"script\");\n tailwindEl.textContent = tailwindScript;\n // The Play CDN script replaces window.tailwind with its Proxy during execution,\n // so configure that runtime only after the synchronous append completes.\n doc.head.appendChild(tailwindEl);\n const tailwindRuntime = (doc.defaultView as TailwindRuntimeWindow | null)\n ?.tailwind;\n if (tailwindRuntime) {\n tailwindRuntime.config = addCjkSafeSansToTailwindConfig(\n tailwindRuntime.config\n );\n }\n\n // 2. DaisyUI v4 CSS\n const daisyuiEl = doc.createElement(\"style\");\n daisyuiEl.textContent = daisyuiCss;\n doc.head.appendChild(daisyuiEl);\n\n // 3. GSAP v3\n const gsapEl = doc.createElement(\"script\");\n gsapEl.textContent = gsapScript;\n doc.head.appendChild(gsapEl);\n}\n"],"names":["injectBlackboardLibraries","doc","tailwindEl","tailwindScript","tailwindRuntime","addCjkSafeSansToTailwindConfig","daisyuiEl","daisyuiCss","gsapEl","gsapScript"],"mappings":";;;;AAeO,SAASA,EAA0BC,GAAqB;AAE7D,QAAMC,IAAaD,EAAI,cAAc,QAAQ;AAC7C,EAAAC,EAAW,cAAcC,GAGzBF,EAAI,KAAK,YAAYC,CAAU;AAC/B,QAAME,IAAmBH,EAAI,aACzB;AACJ,EAAIG,MACFA,EAAgB,SAASC;AAAA,IACvBD,EAAgB;AAAA,EAAA;AAKpB,QAAME,IAAYL,EAAI,cAAc,OAAO;AAC3C,EAAAK,EAAU,cAAcC,GACxBN,EAAI,KAAK,YAAYK,CAAS;AAG9B,QAAME,IAASP,EAAI,cAAc,QAAQ;AACzC,EAAAO,EAAO,cAAcC,GACrBR,EAAI,KAAK,YAAYO,CAAM;AAC7B;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=["system-ui","-apple-system","BlinkMacSystemFont",'"Segoe UI"',"Roboto","Oxygen","Ubuntu","Cantarell",'"Open Sans"','"Helvetica Neue"','"PingFang SC"','"Hiragino Sans GB"','"Microsoft YaHei"','"Source Han Sans SC"','"Noto Sans CJK SC"','"Noto Sans SC"',"Arial",'"Apple Color Emoji"','"Segoe UI Emoji"','"Segoe UI Symbol"','"Noto Color Emoji"',"sans-serif"],i=n.join(", "),e=o=>typeof o=="object"&&o!==null&&!Array.isArray(o)?o:{},r=o=>{const t=e(o),S=e(t.theme),a=e(S.extend),s=e(a.fontFamily);return{...t,theme:{...S,extend:{...a,fontFamily:{...s,sans:[...n]}}}}};exports.CJK_SAFE_SANS_FONT_FAMILIES=n;exports.CJK_SAFE_SANS_FONT_FAMILY=i;exports.addCjkSafeSansToTailwindConfig=r;
|
|
2
|
+
//# sourceMappingURL=cjkFontFamily.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cjkFontFamily.cjs.js","sources":["../../../src/components/ContentRender/cjkFontFamily.ts"],"sourcesContent":["export const CJK_SAFE_SANS_FONT_FAMILIES = [\n \"system-ui\",\n \"-apple-system\",\n \"BlinkMacSystemFont\",\n '\"Segoe UI\"',\n \"Roboto\",\n \"Oxygen\",\n \"Ubuntu\",\n \"Cantarell\",\n '\"Open Sans\"',\n '\"Helvetica Neue\"',\n '\"PingFang SC\"',\n '\"Hiragino Sans GB\"',\n '\"Microsoft YaHei\"',\n '\"Source Han Sans SC\"',\n '\"Noto Sans CJK SC\"',\n '\"Noto Sans SC\"',\n \"Arial\",\n '\"Apple Color Emoji\"',\n '\"Segoe UI Emoji\"',\n '\"Segoe UI Symbol\"',\n '\"Noto Color Emoji\"',\n \"sans-serif\",\n] as const;\n\nexport const CJK_SAFE_SANS_FONT_FAMILY = CJK_SAFE_SANS_FONT_FAMILIES.join(\", \");\n\ntype UnknownRecord = Record<string, unknown>;\n\nconst asRecord = (value: unknown): UnknownRecord =>\n typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? (value as UnknownRecord)\n : {};\n\nexport const addCjkSafeSansToTailwindConfig = (\n config: unknown\n): UnknownRecord => {\n const rootConfig = asRecord(config);\n const theme = asRecord(rootConfig.theme);\n const extend = asRecord(theme.extend);\n const fontFamily = asRecord(extend.fontFamily);\n\n return {\n ...rootConfig,\n theme: {\n ...theme,\n extend: {\n ...extend,\n fontFamily: {\n ...fontFamily,\n sans: [...CJK_SAFE_SANS_FONT_FAMILIES],\n },\n },\n },\n };\n};\n"],"names":["CJK_SAFE_SANS_FONT_FAMILIES","CJK_SAFE_SANS_FONT_FAMILY","asRecord","value","addCjkSafeSansToTailwindConfig","config","rootConfig","theme","extend","fontFamily"],"mappings":"gFAAO,MAAMA,EAA8B,CACzC,YACA,gBACA,qBACA,aACA,SACA,SACA,SACA,YACA,cACA,mBACA,gBACA,qBACA,oBACA,uBACA,qBACA,iBACA,QACA,sBACA,mBACA,oBACA,qBACA,YACF,EAEaC,EAA4BD,EAA4B,KAAK,IAAI,EAIxEE,EAAYC,GAChB,OAAOA,GAAU,UAAYA,IAAU,MAAQ,CAAC,MAAM,QAAQA,CAAK,EAC9DA,EACD,CAAA,EAEOC,EACXC,GACkB,CAClB,MAAMC,EAAaJ,EAASG,CAAM,EAC5BE,EAAQL,EAASI,EAAW,KAAK,EACjCE,EAASN,EAASK,EAAM,MAAM,EAC9BE,EAAaP,EAASM,EAAO,UAAU,EAE7C,MAAO,CACL,GAAGF,EACH,MAAO,CACL,GAAGC,EACH,OAAQ,CACN,GAAGC,EACH,WAAY,CACV,GAAGC,EACH,KAAM,CAAC,GAAGT,CAA2B,CAAA,CACvC,CACF,CACF,CAEJ"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CJK_SAFE_SANS_FONT_FAMILIES: readonly ["system-ui", "-apple-system", "BlinkMacSystemFont", "\"Segoe UI\"", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "\"Open Sans\"", "\"Helvetica Neue\"", "\"PingFang SC\"", "\"Hiragino Sans GB\"", "\"Microsoft YaHei\"", "\"Source Han Sans SC\"", "\"Noto Sans CJK SC\"", "\"Noto Sans SC\"", "Arial", "\"Apple Color Emoji\"", "\"Segoe UI Emoji\"", "\"Segoe UI Symbol\"", "\"Noto Color Emoji\"", "sans-serif"];
|
|
2
|
+
export declare const CJK_SAFE_SANS_FONT_FAMILY: string;
|
|
3
|
+
type UnknownRecord = Record<string, unknown>;
|
|
4
|
+
export declare const addCjkSafeSansToTailwindConfig: (config: unknown) => UnknownRecord;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const a = [
|
|
2
|
+
"system-ui",
|
|
3
|
+
"-apple-system",
|
|
4
|
+
"BlinkMacSystemFont",
|
|
5
|
+
'"Segoe UI"',
|
|
6
|
+
"Roboto",
|
|
7
|
+
"Oxygen",
|
|
8
|
+
"Ubuntu",
|
|
9
|
+
"Cantarell",
|
|
10
|
+
'"Open Sans"',
|
|
11
|
+
'"Helvetica Neue"',
|
|
12
|
+
'"PingFang SC"',
|
|
13
|
+
'"Hiragino Sans GB"',
|
|
14
|
+
'"Microsoft YaHei"',
|
|
15
|
+
'"Source Han Sans SC"',
|
|
16
|
+
'"Noto Sans CJK SC"',
|
|
17
|
+
'"Noto Sans SC"',
|
|
18
|
+
"Arial",
|
|
19
|
+
'"Apple Color Emoji"',
|
|
20
|
+
'"Segoe UI Emoji"',
|
|
21
|
+
'"Segoe UI Symbol"',
|
|
22
|
+
'"Noto Color Emoji"',
|
|
23
|
+
"sans-serif"
|
|
24
|
+
], i = a.join(", "), n = (o) => typeof o == "object" && o !== null && !Array.isArray(o) ? o : {}, r = (o) => {
|
|
25
|
+
const e = n(o), t = n(e.theme), s = n(t.extend), S = n(s.fontFamily);
|
|
26
|
+
return {
|
|
27
|
+
...e,
|
|
28
|
+
theme: {
|
|
29
|
+
...t,
|
|
30
|
+
extend: {
|
|
31
|
+
...s,
|
|
32
|
+
fontFamily: {
|
|
33
|
+
...S,
|
|
34
|
+
sans: [...a]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
a as CJK_SAFE_SANS_FONT_FAMILIES,
|
|
42
|
+
i as CJK_SAFE_SANS_FONT_FAMILY,
|
|
43
|
+
r as addCjkSafeSansToTailwindConfig
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=cjkFontFamily.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cjkFontFamily.es.js","sources":["../../../src/components/ContentRender/cjkFontFamily.ts"],"sourcesContent":["export const CJK_SAFE_SANS_FONT_FAMILIES = [\n \"system-ui\",\n \"-apple-system\",\n \"BlinkMacSystemFont\",\n '\"Segoe UI\"',\n \"Roboto\",\n \"Oxygen\",\n \"Ubuntu\",\n \"Cantarell\",\n '\"Open Sans\"',\n '\"Helvetica Neue\"',\n '\"PingFang SC\"',\n '\"Hiragino Sans GB\"',\n '\"Microsoft YaHei\"',\n '\"Source Han Sans SC\"',\n '\"Noto Sans CJK SC\"',\n '\"Noto Sans SC\"',\n \"Arial\",\n '\"Apple Color Emoji\"',\n '\"Segoe UI Emoji\"',\n '\"Segoe UI Symbol\"',\n '\"Noto Color Emoji\"',\n \"sans-serif\",\n] as const;\n\nexport const CJK_SAFE_SANS_FONT_FAMILY = CJK_SAFE_SANS_FONT_FAMILIES.join(\", \");\n\ntype UnknownRecord = Record<string, unknown>;\n\nconst asRecord = (value: unknown): UnknownRecord =>\n typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? (value as UnknownRecord)\n : {};\n\nexport const addCjkSafeSansToTailwindConfig = (\n config: unknown\n): UnknownRecord => {\n const rootConfig = asRecord(config);\n const theme = asRecord(rootConfig.theme);\n const extend = asRecord(theme.extend);\n const fontFamily = asRecord(extend.fontFamily);\n\n return {\n ...rootConfig,\n theme: {\n ...theme,\n extend: {\n ...extend,\n fontFamily: {\n ...fontFamily,\n sans: [...CJK_SAFE_SANS_FONT_FAMILIES],\n },\n },\n },\n };\n};\n"],"names":["CJK_SAFE_SANS_FONT_FAMILIES","CJK_SAFE_SANS_FONT_FAMILY","asRecord","value","addCjkSafeSansToTailwindConfig","config","rootConfig","theme","extend","fontFamily"],"mappings":"AAAO,MAAMA,IAA8B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEaC,IAA4BD,EAA4B,KAAK,IAAI,GAIxEE,IAAW,CAACC,MAChB,OAAOA,KAAU,YAAYA,MAAU,QAAQ,CAAC,MAAM,QAAQA,CAAK,IAC9DA,IACD,CAAA,GAEOC,IAAiC,CAC5CC,MACkB;AAClB,QAAMC,IAAaJ,EAASG,CAAM,GAC5BE,IAAQL,EAASI,EAAW,KAAK,GACjCE,IAASN,EAASK,EAAM,MAAM,GAC9BE,IAAaP,EAASM,EAAO,UAAU;AAE7C,SAAO;AAAA,IACL,GAAGF;AAAA,IACH,OAAO;AAAA,MACL,GAAGC;AAAA,MACH,QAAQ;AAAA,QACN,GAAGC;AAAA,QACH,YAAY;AAAA,UACV,GAAGC;AAAA,UACH,MAAM,CAAC,GAAGT,CAA2B;AAAA,QAAA;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../lib/locale.cjs.js"),l=require("../../lib/localeTextMap.cjs.js"),c=["confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","sandboxFullscreenButtonText","sandboxExitFullscreenButtonText","sendButtonLabel","scrollToBottomLabel"],t=e=>l.buildLocaleTexts(c,e),n={"en-US":t(["Submit","Copy","Copied","Loading content...","Building styles...","Building scripts cache...","Fullscreen","Exit fullscreen","Send","Scroll to bottom"]),"fr-FR":t(["Soumettre","Copier","Copié","Chargement du contenu...","Génération des styles...","Génération du cache des scripts...","Plein écran","Quitter le plein écran","Envoyer","Faire défiler jusqu'en bas"]),"zh-CN":t(["提交","复制","已复制","正在加载内容...","正在生成样式...","正在生成脚本缓存...","全屏浏览","退出全屏","发送","滚动到底部"])},r=e=>n[o.normalizeMarkdownFlowLocale(e)];exports.CONTENT_RENDER_LOCALE_TEXTS=n;exports.getContentRenderLocaleTexts=r;
|
|
2
|
+
//# sourceMappingURL=contentRenderI18n.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentRenderI18n.cjs.js","sources":["../../../src/components/ContentRender/contentRenderI18n.ts"],"sourcesContent":["import {\n normalizeMarkdownFlowLocale,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport {\n buildLocaleTexts,\n type LocaleTextValues,\n} from \"../../lib/localeTextMap\";\n\nexport interface ContentRenderLocaleTexts {\n confirmButtonText: string;\n copyButtonText: string;\n copiedButtonText: string;\n sandboxLoadingText: string;\n sandboxStyleLoadingText: string;\n sandboxScriptLoadingText: string;\n sandboxFullscreenButtonText: string;\n sandboxExitFullscreenButtonText: string;\n sendButtonLabel: string;\n scrollToBottomLabel: string;\n}\n\nconst CONTENT_RENDER_TEXT_KEYS = [\n \"confirmButtonText\",\n \"copyButtonText\",\n \"copiedButtonText\",\n \"sandboxLoadingText\",\n \"sandboxStyleLoadingText\",\n \"sandboxScriptLoadingText\",\n \"sandboxFullscreenButtonText\",\n \"sandboxExitFullscreenButtonText\",\n \"sendButtonLabel\",\n \"scrollToBottomLabel\",\n] as const satisfies readonly (keyof ContentRenderLocaleTexts)[];\n\nconst createContentRenderLocaleTexts = (\n values: LocaleTextValues<typeof CONTENT_RENDER_TEXT_KEYS>\n): ContentRenderLocaleTexts =>\n buildLocaleTexts(\n CONTENT_RENDER_TEXT_KEYS,\n values\n ) as ContentRenderLocaleTexts;\n\nexport const CONTENT_RENDER_LOCALE_TEXTS: Record<\n MarkdownFlowLocale,\n ContentRenderLocaleTexts\n> = {\n \"en-US\": createContentRenderLocaleTexts([\n \"Submit\",\n \"Copy\",\n \"Copied\",\n \"Loading content...\",\n \"Building styles...\",\n \"Building scripts cache...\",\n \"Fullscreen\",\n \"Exit fullscreen\",\n \"Send\",\n \"Scroll to bottom\",\n ]),\n \"fr-FR\": createContentRenderLocaleTexts([\n \"Soumettre\",\n \"Copier\",\n \"Copié\",\n \"Chargement du contenu...\",\n \"Génération des styles...\",\n \"Génération du cache des scripts...\",\n \"Plein écran\",\n \"Quitter le plein écran\",\n \"Envoyer\",\n \"Faire défiler jusqu'en bas\",\n ]),\n \"zh-CN\": createContentRenderLocaleTexts([\n \"提交\",\n \"复制\",\n \"已复制\",\n \"正在加载内容...\",\n \"正在生成样式...\",\n \"正在生成脚本缓存...\",\n \"全屏浏览\",\n \"退出全屏\",\n \"发送\",\n \"滚动到底部\",\n ]),\n};\n\nexport const getContentRenderLocaleTexts = (\n locale?: string | null\n): ContentRenderLocaleTexts =>\n CONTENT_RENDER_LOCALE_TEXTS[normalizeMarkdownFlowLocale(locale)];\n"],"names":["CONTENT_RENDER_TEXT_KEYS","createContentRenderLocaleTexts","values","buildLocaleTexts","CONTENT_RENDER_LOCALE_TEXTS","getContentRenderLocaleTexts","locale","normalizeMarkdownFlowLocale"],"mappings":"uKAsBMA,EAA2B,CAC/B,oBACA,iBACA,mBACA,qBACA,0BACA,2BACA,8BACA,kCACA,kBACA,qBACF,EAEMC,EACJC,GAEAC,EAAAA,iBACEH,EACAE,CACF,EAEWE,EAGT,CACF,QAASH,EAA+B,CACtC,SACA,OACA,SACA,qBACA,qBACA,4BACA,aACA,kBACA,OACA,kBAAA,CACD,EACD,QAASA,EAA+B,CACtC,YACA,SACA,QACA,2BACA,2BACA,qCACA,cACA,yBACA,UACA,4BAAA,CACD,EACD,QAASA,EAA+B,CACtC,KACA,KACA,MACA,YACA,YACA,cACA,OACA,OACA,KACA,OAAA,CACD,CACH,EAEaI,EACXC,GAEAF,EAA4BG,EAAAA,4BAA4BD,CAAM,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MarkdownFlowLocale } from '../../lib/locale';
|
|
2
|
+
export interface ContentRenderLocaleTexts {
|
|
3
|
+
confirmButtonText: string;
|
|
4
|
+
copyButtonText: string;
|
|
5
|
+
copiedButtonText: string;
|
|
6
|
+
sandboxLoadingText: string;
|
|
7
|
+
sandboxStyleLoadingText: string;
|
|
8
|
+
sandboxScriptLoadingText: string;
|
|
9
|
+
sandboxFullscreenButtonText: string;
|
|
10
|
+
sandboxExitFullscreenButtonText: string;
|
|
11
|
+
sendButtonLabel: string;
|
|
12
|
+
scrollToBottomLabel: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const CONTENT_RENDER_LOCALE_TEXTS: Record<MarkdownFlowLocale, ContentRenderLocaleTexts>;
|
|
15
|
+
export declare const getContentRenderLocaleTexts: (locale?: string | null) => ContentRenderLocaleTexts;
|