markdown-flow-ui 0.2.33 → 0.2.35-dev.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/README.md +12 -0
- package/dist/components/ContentRender/IframeSandbox.cjs +4 -4
- package/dist/components/ContentRender/IframeSandbox.cjs.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.es.js +299 -279
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/utils/content-viewport-min-height.cjs +2 -0
- package/dist/components/ContentRender/utils/content-viewport-min-height.cjs.map +1 -0
- package/dist/components/ContentRender/utils/content-viewport-min-height.d.ts +2 -0
- package/dist/components/ContentRender/utils/content-viewport-min-height.es.js +22 -0
- package/dist/components/ContentRender/utils/content-viewport-min-height.es.js.map +1 -0
- package/dist/components/ContentRender/utils/content-viewport-min-height.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,142 +1,143 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { createRoot as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { jsx as V, jsxs as Et } from "react/jsx-runtime";
|
|
2
|
+
import j, { useRef as o, useCallback as et, useState as A, useEffect as H, useMemo as Tt } from "react";
|
|
3
|
+
import { createRoot as kt } from "react-dom/client";
|
|
4
|
+
import At from "./SandboxApp.es.js";
|
|
5
|
+
import { normalizeContentViewportMinHeight as Ft } from "./utils/content-viewport-min-height.es.js";
|
|
6
|
+
import _t from "./ContentRender.es.js";
|
|
7
|
+
import { inspectViewportHeightFromHtmlRootString as tt, EMPTY_ROOT_HEIGHT_META as Dt, parseExplicitHeight as nt, inspectViewportHeightFromNodeChain as It, resolveExplicitHeightFromNodeChain as Ot } from "./utils/iframe-viewport-height.es.js";
|
|
8
|
+
import { SANDBOX_INTERACTION_MESSAGE_TYPE as Nt, SANDBOX_INTERACTION_MESSAGE_SOURCE as Vt } from "../../lib/sandboxInteraction.es.js";
|
|
9
|
+
import { injectScalingSystem as Bt } from "./utils/iframe-scaling.es.js";
|
|
10
|
+
import { getMarkdownFlowDirection as Wt, getMarkdownFlowLanguage as zt } from "../../lib/locale.es.js";
|
|
11
|
+
import { useDetachedLanguage as $t } from "../../lib/useDetachedLanguage.es.js";
|
|
12
|
+
import { useResolvedDirection as rt } from "../../lib/useResolvedDirection.es.js";
|
|
13
|
+
import { getContentRenderLocaleTexts as qt } from "./contentRenderI18n.es.js";
|
|
14
|
+
import { CJK_SAFE_SANS_FONT_FAMILY as Pt } from "./cjkFontFamily.es.js";
|
|
15
|
+
let ye = null;
|
|
16
|
+
const ot = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Lt = /<img\b[^>]*>/i, jt = 180, Gt = 240, Yt = (i) => i.split(/\s+/).filter(Boolean).map((r) => {
|
|
16
17
|
const l = r.split(":");
|
|
17
18
|
return l[l.length - 1] !== "h-screen" && l[l.length - 1] !== "min-h-screen" ? r : (l[l.length - 1] = "h-full", l.join(":"));
|
|
18
|
-
}).join(" "),
|
|
19
|
+
}).join(" "), Ut = (i, r) => !r || !i.trim() ? i : i.replace(
|
|
19
20
|
/^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,
|
|
20
|
-
(l,
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
21
|
+
(l, f, G = "") => {
|
|
22
|
+
const x = G.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
|
|
23
|
+
if (!x)
|
|
23
24
|
return l;
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
`class=${
|
|
25
|
+
const B = Yt(x[2]);
|
|
26
|
+
return B === x[2] ? l : `${f}${G.replace(
|
|
27
|
+
x[0],
|
|
28
|
+
`class=${x[1]}${B}${x[1]}`
|
|
28
29
|
)}>`;
|
|
29
30
|
}
|
|
30
|
-
),
|
|
31
|
+
), Xt = ({
|
|
31
32
|
content: i,
|
|
32
33
|
type: r,
|
|
33
34
|
className: l,
|
|
34
|
-
locale:
|
|
35
|
-
lang:
|
|
36
|
-
dir:
|
|
37
|
-
loadingText:
|
|
38
|
-
styleLoadingText:
|
|
35
|
+
locale: f,
|
|
36
|
+
lang: G,
|
|
37
|
+
dir: x,
|
|
38
|
+
loadingText: B,
|
|
39
|
+
styleLoadingText: Me,
|
|
39
40
|
scriptLoadingText: Ee,
|
|
40
|
-
fullScreenButtonText:
|
|
41
|
-
exitFullScreenButtonText:
|
|
42
|
-
hideFullScreen:
|
|
41
|
+
fullScreenButtonText: it,
|
|
42
|
+
exitFullScreenButtonText: ct,
|
|
43
|
+
hideFullScreen: Te = !1,
|
|
43
44
|
mode: a = "content",
|
|
44
|
-
replaceRootScreenHeightWithFull:
|
|
45
|
-
enableScaling:
|
|
46
|
-
disableLoadingOverlay:
|
|
45
|
+
replaceRootScreenHeightWithFull: st = !1,
|
|
46
|
+
enableScaling: lt = !1,
|
|
47
|
+
disableLoadingOverlay: oe = !1
|
|
47
48
|
}) => {
|
|
48
|
-
const
|
|
49
|
+
const ke = qt(f), R = x ?? Wt(f), ie = G ?? zt(f), at = it || ke.sandboxFullscreenButtonText, ut = ct || ke.sandboxExitFullscreenButtonText, F = o(null), Ae = o(null), Fe = $t(F, ie), { resolvedDirection: ce } = rt(F, R), _e = o(null), De = o(null), dt = et(
|
|
49
50
|
(t) => {
|
|
50
|
-
|
|
51
|
+
_e.current = t, De.current = t?.querySelector(".content-render") ?? null;
|
|
51
52
|
},
|
|
52
53
|
[]
|
|
53
|
-
), { resolvedDirection:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
),
|
|
57
|
-
|
|
58
|
-
const [
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
}), [
|
|
54
|
+
), { resolvedDirection: ht } = rt(
|
|
55
|
+
De,
|
|
56
|
+
R
|
|
57
|
+
), Ie = R ?? ce, Oe = o(R);
|
|
58
|
+
Oe.current = R;
|
|
59
|
+
const [ft, mt] = A();
|
|
60
|
+
let Y;
|
|
61
|
+
R === "auto" && (Y = ce, r === "sandbox" ? Y = ft ?? ce : a === "blackboard" && (Y = ht));
|
|
62
|
+
const C = o(null), U = o(null), W = o(() => {
|
|
63
|
+
}), [gt, bt] = A(480), [se, wt] = A(null), [X, le] = A(0), [Ne, pt] = A(0), ae = o(!1), ue = o(!1), Ve = o(0), [Be, Ht] = A(0), [de, xt] = A(!1), he = r === "sandbox", v = a === "blackboard", S = lt && v && r === "sandbox", z = v && r === "sandbox", O = z && st, fe = o(""), K = j.useMemo(
|
|
63
64
|
() => r === "sandbox" ? i : "",
|
|
64
65
|
[i, r]
|
|
65
|
-
), c =
|
|
66
|
-
() =>
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
), c = j.useMemo(
|
|
67
|
+
() => Ut(
|
|
68
|
+
K,
|
|
69
|
+
O
|
|
69
70
|
),
|
|
70
|
-
[
|
|
71
|
-
),
|
|
72
|
-
() =>
|
|
73
|
-
[
|
|
74
|
-
),
|
|
75
|
-
() =>
|
|
71
|
+
[K, O]
|
|
72
|
+
), We = j.useMemo(
|
|
73
|
+
() => O ? tt(K) : Dt,
|
|
74
|
+
[K, O]
|
|
75
|
+
), me = j.useMemo(
|
|
76
|
+
() => O && We.hasFullViewportHeight,
|
|
76
77
|
[
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
We.hasFullViewportHeight,
|
|
79
|
+
O
|
|
79
80
|
]
|
|
80
|
-
), [
|
|
81
|
+
), [J, ze] = A(
|
|
81
82
|
c
|
|
82
|
-
),
|
|
83
|
+
), $e = o(c), ge = o(c), $ = o(null), y = o(null), qe = o(null), be = et((t) => {
|
|
83
84
|
if (typeof window > "u")
|
|
84
85
|
return;
|
|
85
86
|
const e = Date.now();
|
|
86
|
-
e -
|
|
87
|
+
e - Ve.current < Gt || (Ve.current = e, window.postMessage(
|
|
87
88
|
{
|
|
88
|
-
source:
|
|
89
|
-
type:
|
|
89
|
+
source: Vt,
|
|
90
|
+
type: Nt,
|
|
90
91
|
eventType: t
|
|
91
92
|
},
|
|
92
93
|
window.location.origin
|
|
93
94
|
));
|
|
94
95
|
}, []);
|
|
95
|
-
|
|
96
|
+
H(() => {
|
|
96
97
|
if (r !== "markdown" || a !== "blackboard") return;
|
|
97
|
-
const t =
|
|
98
|
+
const t = _e.current;
|
|
98
99
|
if (!t) return;
|
|
99
|
-
const e = () =>
|
|
100
|
+
const e = () => be("click");
|
|
100
101
|
return t.addEventListener("click", e), () => t.removeEventListener("click", e);
|
|
101
|
-
}, [
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
|
|
102
|
+
}, [be, a, r]);
|
|
103
|
+
const we = () => {
|
|
104
|
+
$.current !== null && (window.clearTimeout($.current), $.current = null);
|
|
105
|
+
}, Rt = () => {
|
|
106
|
+
y.current !== null && (window.cancelAnimationFrame(y.current), y.current = null);
|
|
106
107
|
};
|
|
107
|
-
|
|
108
|
+
H(
|
|
108
109
|
() => () => {
|
|
109
|
-
|
|
110
|
+
we(), Rt();
|
|
110
111
|
},
|
|
111
112
|
[]
|
|
112
|
-
),
|
|
113
|
-
const t =
|
|
114
|
-
|
|
115
|
-
const e = !!t && c.length > t.length && c.startsWith(t),
|
|
113
|
+
), H(() => {
|
|
114
|
+
const t = $e.current;
|
|
115
|
+
$e.current = c;
|
|
116
|
+
const e = !!t && c.length > t.length && c.startsWith(t), u = Lt.test(
|
|
116
117
|
c
|
|
117
118
|
);
|
|
118
|
-
if (!(e &&
|
|
119
|
-
|
|
119
|
+
if (!(e && u)) {
|
|
120
|
+
we(), ge.current = c, ze(c);
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
},
|
|
123
|
+
ge.current = c, we(), $.current = window.setTimeout(() => {
|
|
124
|
+
ze(ge.current), $.current = null;
|
|
125
|
+
}, jt);
|
|
125
126
|
}, [c]);
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}, [
|
|
130
|
-
const
|
|
131
|
-
|
|
127
|
+
const Q = j.useMemo(() => z ? tt(J).viewportHeightCss : null, [J, z]);
|
|
128
|
+
H(() => {
|
|
129
|
+
qe.current = Q;
|
|
130
|
+
}, [Q]);
|
|
131
|
+
const pe = !!Q, q = v && r === "sandbox" ? S || me ? "100%" : Q ?? `${gt}px` : void 0;
|
|
132
|
+
H(() => {
|
|
132
133
|
if (a !== "blackboard") {
|
|
133
|
-
|
|
134
|
+
fe.current = c;
|
|
134
135
|
return;
|
|
135
136
|
}
|
|
136
|
-
const t =
|
|
137
|
-
!(t && c.startsWith(t)) && t &&
|
|
138
|
-
}, [a, c]),
|
|
139
|
-
const t =
|
|
137
|
+
const t = fe.current;
|
|
138
|
+
!(t && c.startsWith(t)) && t && Ht((u) => u + 1), fe.current = c;
|
|
139
|
+
}, [a, c]), H(() => {
|
|
140
|
+
const t = C.current;
|
|
140
141
|
if (!t) return;
|
|
141
142
|
const e = t.contentDocument;
|
|
142
143
|
if (!e) return;
|
|
@@ -147,9 +148,9 @@ const Ze = () => (Ce || (Ce = import("./blackboard-vendor.es.js")), Ce), Vt = /<
|
|
|
147
148
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
148
149
|
<style>
|
|
149
150
|
:root { color-scheme: light; }
|
|
150
|
-
html, body, #root { width: 100%; font-family: ${
|
|
151
|
+
html, body, #root { width: 100%; font-family: ${Pt}; }
|
|
151
152
|
${a === "blackboard" ? "html, body, #root { height: 100%; }" : ""}
|
|
152
|
-
html, body { margin: 0; padding: 0; overflow: ${
|
|
153
|
+
html, body { margin: 0; padding: 0; overflow: ${S ? "hidden auto" : a === "blackboard" ? "auto" : "hidden"}; }
|
|
153
154
|
*, *::before, *::after { box-sizing: border-box; }
|
|
154
155
|
${a !== "blackboard" ? `
|
|
155
156
|
.h-screen { height: auto !important; }
|
|
@@ -163,208 +164,226 @@ const Ze = () => (Ce || (Ce = import("./blackboard-vendor.es.js")), Ce), Vt = /<
|
|
|
163
164
|
<div id="root"></div>
|
|
164
165
|
</body>
|
|
165
166
|
</html>`), e.close(), e.documentElement.setAttribute("data-theme", "light"), e.documentElement.style.colorScheme = "light", e.body?.style.setProperty("color-scheme", "light");
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
let
|
|
173
|
-
const
|
|
167
|
+
const u = v && r === "sandbox", M = () => be("click");
|
|
168
|
+
u && e.addEventListener("click", M, !0);
|
|
169
|
+
const _ = e.getElementById("root");
|
|
170
|
+
if (!_) return;
|
|
171
|
+
const N = kt(_);
|
|
172
|
+
U.current = N;
|
|
173
|
+
let m = !1;
|
|
174
|
+
const Pe = (n) => ({
|
|
174
175
|
heightAttrValue: n.getAttribute("height"),
|
|
175
176
|
styleAttrValue: n.getAttribute("style"),
|
|
176
177
|
classAttrValue: n.getAttribute("class")
|
|
177
|
-
}),
|
|
178
|
+
}), Le = (n) => {
|
|
178
179
|
const s = Array.from(n.children);
|
|
179
180
|
return s.length === 1 ? s[0] : null;
|
|
180
|
-
},
|
|
181
|
-
if (!
|
|
182
|
-
const n =
|
|
181
|
+
}, yt = () => {
|
|
182
|
+
if (!z || !C.current || !e.body) return null;
|
|
183
|
+
const n = C.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, s = qe.current, b = s ? nt(
|
|
183
184
|
s,
|
|
184
185
|
n
|
|
185
186
|
) : null;
|
|
186
|
-
if (
|
|
187
|
-
return Math.ceil(
|
|
188
|
-
const
|
|
187
|
+
if (b !== null)
|
|
188
|
+
return Math.ceil(b);
|
|
189
|
+
const E = e.body.querySelector(
|
|
189
190
|
".sandbox-wrapper"
|
|
190
191
|
)?.firstElementChild;
|
|
191
|
-
if (!
|
|
192
|
-
const
|
|
193
|
-
|
|
192
|
+
if (!E) return null;
|
|
193
|
+
const g = Array.from(E.children), w = g.length === 1 ? g[0] : null, P = It(
|
|
194
|
+
w,
|
|
194
195
|
{
|
|
195
|
-
getNode:
|
|
196
|
-
getSingleChild:
|
|
196
|
+
getNode: Pe,
|
|
197
|
+
getSingleChild: Le
|
|
197
198
|
}
|
|
198
199
|
).viewportHeightCss;
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
|
|
200
|
+
if (P) {
|
|
201
|
+
const h = nt(
|
|
202
|
+
P,
|
|
202
203
|
n
|
|
203
204
|
);
|
|
204
|
-
if (
|
|
205
|
-
return Math.ceil(
|
|
205
|
+
if (h !== null)
|
|
206
|
+
return Math.ceil(h);
|
|
206
207
|
}
|
|
207
|
-
const
|
|
208
|
-
|
|
208
|
+
const ne = Ot(
|
|
209
|
+
w,
|
|
209
210
|
n,
|
|
210
211
|
{
|
|
211
|
-
getNode:
|
|
212
|
-
getSingleChild:
|
|
212
|
+
getNode: Pe,
|
|
213
|
+
getSingleChild: Le
|
|
213
214
|
}
|
|
214
215
|
);
|
|
215
|
-
return
|
|
216
|
-
},
|
|
217
|
-
if (!
|
|
218
|
-
if (!
|
|
219
|
-
if (
|
|
220
|
-
|
|
216
|
+
return ne !== null ? Math.ceil(ne) : null;
|
|
217
|
+
}, xe = () => {
|
|
218
|
+
if (!C.current || !e.body) return;
|
|
219
|
+
if (!v) {
|
|
220
|
+
if (ae.current) {
|
|
221
|
+
ue.current = !0;
|
|
221
222
|
return;
|
|
222
223
|
}
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
224
|
+
ae.current = !0;
|
|
225
|
+
const E = e.body.querySelector(".sandbox-container");
|
|
226
|
+
E && Ft(E);
|
|
227
|
+
const g = C.current, w = F.current?.clientWidth || 0, Xe = g.style.height;
|
|
228
|
+
if (w > 0) {
|
|
229
|
+
const P = Math.round(w * 9 / 16), ne = Math.max(8192, w * 20);
|
|
230
|
+
g.style.height = P + "px", e.body.offsetHeight;
|
|
231
|
+
let h = e.body.scrollHeight;
|
|
232
|
+
const Ke = e.defaultView;
|
|
233
|
+
if (Ke) {
|
|
234
|
+
const L = (T) => {
|
|
235
|
+
let p = 0;
|
|
236
|
+
const Je = (k) => {
|
|
237
|
+
const Qe = Ke.getComputedStyle(k);
|
|
238
|
+
if (Qe.position === "fixed" && (p = Math.max(
|
|
239
|
+
p,
|
|
240
|
+
Math.ceil(k.getBoundingClientRect().bottom)
|
|
241
|
+
)), k !== T && k.scrollHeight > k.clientHeight + 1) {
|
|
242
|
+
const re = Qe.overflowY;
|
|
243
|
+
if (re === "auto" || re === "scroll") {
|
|
244
|
+
const Ze = k.getBoundingClientRect();
|
|
245
|
+
Ze.top >= 0 && (p = Math.max(
|
|
246
|
+
p,
|
|
247
|
+
Math.ceil(Ze.top + k.scrollHeight)
|
|
241
248
|
));
|
|
242
249
|
}
|
|
243
250
|
}
|
|
244
|
-
for (const
|
|
251
|
+
for (const re of k.children) Je(re);
|
|
245
252
|
};
|
|
246
|
-
return
|
|
253
|
+
return Je(T), p;
|
|
247
254
|
};
|
|
248
|
-
|
|
249
|
-
for (let
|
|
250
|
-
|
|
251
|
-
const
|
|
255
|
+
h = Math.max(h, L(e.body));
|
|
256
|
+
for (let T = 0; T < 8 && h > P; T++) {
|
|
257
|
+
g.style.height = h + "px", e.body.offsetHeight;
|
|
258
|
+
const p = Math.max(
|
|
252
259
|
e.body.scrollHeight,
|
|
253
|
-
|
|
260
|
+
L(e.body)
|
|
254
261
|
);
|
|
255
|
-
if (
|
|
256
|
-
|
|
262
|
+
if (p <= h + 1 || p >= h * 1.5) break;
|
|
263
|
+
h = p;
|
|
257
264
|
}
|
|
258
265
|
}
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
return
|
|
266
|
+
g.style.height = Xe, wt((L) => {
|
|
267
|
+
const T = Math.min(ne, Math.max(1, Math.ceil(h)));
|
|
268
|
+
return L === T ? L : T;
|
|
262
269
|
});
|
|
263
270
|
}
|
|
264
271
|
setTimeout(() => {
|
|
265
|
-
|
|
272
|
+
ae.current = !1, ue.current && (ue.current = !1, D());
|
|
266
273
|
}, 50);
|
|
267
274
|
return;
|
|
268
275
|
}
|
|
269
|
-
if (
|
|
270
|
-
const n = e.body.scrollHeight, s = e.documentElement?.scrollHeight || 0,
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
276
|
+
if (S) return;
|
|
277
|
+
const n = e.body.scrollHeight, s = e.documentElement?.scrollHeight || 0, b = _?.scrollHeight || 0, I = Math.max(n, s, b);
|
|
278
|
+
if (z) {
|
|
279
|
+
const E = yt(), g = Math.max(
|
|
273
280
|
200,
|
|
274
|
-
|
|
281
|
+
E ?? Math.ceil(I)
|
|
275
282
|
);
|
|
276
|
-
|
|
277
|
-
(
|
|
283
|
+
bt(
|
|
284
|
+
(w) => w === g ? w : g
|
|
278
285
|
);
|
|
279
286
|
}
|
|
280
|
-
},
|
|
287
|
+
}, D = () => {
|
|
281
288
|
requestAnimationFrame(() => {
|
|
282
|
-
|
|
289
|
+
m || xe();
|
|
283
290
|
});
|
|
284
291
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
292
|
+
W.current = D, xe(), D(), he && ot().then(({ injectBlackboardLibraries: n }) => {
|
|
293
|
+
m || (n(e), S && Bt(e), requestAnimationFrame(() => {
|
|
294
|
+
m || D();
|
|
288
295
|
}));
|
|
289
296
|
}).catch(() => {
|
|
290
|
-
|
|
297
|
+
m || D();
|
|
291
298
|
});
|
|
292
|
-
const
|
|
293
|
-
let
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
},
|
|
298
|
-
!
|
|
299
|
-
|
|
300
|
-
|
|
299
|
+
const d = F.current;
|
|
300
|
+
let Re = !!(d && (d.clientWidth <= 0 || d.clientHeight <= 0)), Z = !1, ee = null, te = null;
|
|
301
|
+
const je = () => {
|
|
302
|
+
if (m) return;
|
|
303
|
+
D(), t.contentWindow?.__mdf_triggerFitContent?.();
|
|
304
|
+
}, Ce = () => !!(d && d.clientWidth > 0 && d.clientHeight > 0), Ge = () => {
|
|
305
|
+
!he || !d || !Re || Z || !Ce() || (Z = !0, ot().then(({ refreshTailwindRuntime: n }) => {
|
|
306
|
+
m || (ee = window.requestAnimationFrame(() => {
|
|
307
|
+
ee = null, Z = !1;
|
|
301
308
|
const s = e.querySelector(".sandbox-container");
|
|
302
|
-
|
|
303
|
-
|
|
309
|
+
m || !Ce() || !s?.childNodes.length || !n(e) || (Re = !1, je(), te = window.setTimeout(() => {
|
|
310
|
+
te = null, je();
|
|
304
311
|
}, 100));
|
|
305
312
|
}));
|
|
306
313
|
}).catch(() => {
|
|
307
|
-
|
|
314
|
+
Z = !1;
|
|
308
315
|
}));
|
|
309
|
-
},
|
|
310
|
-
const s = n[0]?.contentRect,
|
|
311
|
-
|
|
316
|
+
}, Ye = typeof ResizeObserver < "u", ve = he && d && Ye ? new ResizeObserver((n) => {
|
|
317
|
+
const s = n[0]?.contentRect, b = s?.width ?? d.clientWidth, I = s?.height ?? d.clientHeight;
|
|
318
|
+
b > 0 && I > 0 && Ge();
|
|
312
319
|
}) : null;
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
if (r !== "sandbox" ||
|
|
320
|
+
ve && d && ve.observe(d);
|
|
321
|
+
const Se = Ye ? new ResizeObserver(() => xe()) : null;
|
|
322
|
+
Se?.observe(e.body), _ && Se?.observe(_);
|
|
323
|
+
const Mt = () => {
|
|
324
|
+
if (r !== "sandbox" || Oe.current !== "auto")
|
|
318
325
|
return;
|
|
319
326
|
const n = e.querySelector(".sandbox-wrapper"), s = e.defaultView;
|
|
320
327
|
if (!n || !s) return;
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
(
|
|
328
|
+
const b = s.getComputedStyle(n).direction === "rtl" ? "rtl" : "ltr";
|
|
329
|
+
mt(
|
|
330
|
+
(I) => I === b ? I : b
|
|
324
331
|
);
|
|
325
|
-
},
|
|
326
|
-
if (
|
|
327
|
-
|
|
332
|
+
}, Ue = new MutationObserver(() => {
|
|
333
|
+
if (Mt(), D(), !Ce()) {
|
|
334
|
+
Re = !0;
|
|
328
335
|
return;
|
|
329
336
|
}
|
|
330
|
-
|
|
337
|
+
Ge();
|
|
331
338
|
});
|
|
332
|
-
return
|
|
339
|
+
return Ue.observe(e.body, {
|
|
333
340
|
childList: !0,
|
|
334
341
|
characterData: !0,
|
|
335
342
|
subtree: !0,
|
|
336
343
|
attributes: !0,
|
|
337
344
|
attributeFilter: ["style", "class", "dir"]
|
|
338
345
|
}), () => {
|
|
339
|
-
|
|
346
|
+
m = !0, ve?.disconnect(), Se?.disconnect(), Ue.disconnect(), ee !== null && window.cancelAnimationFrame(ee), te !== null && window.clearTimeout(te), S && t.contentWindow?.__mdf_cleanupScaling?.(), u && e.removeEventListener("click", M, !0), U.current === N && (U.current = null, W.current = () => {
|
|
340
347
|
}), setTimeout(() => {
|
|
341
|
-
|
|
348
|
+
N.unmount();
|
|
342
349
|
}, 0);
|
|
343
350
|
};
|
|
344
|
-
}, []),
|
|
351
|
+
}, []), H(() => {
|
|
345
352
|
const t = () => {
|
|
346
|
-
|
|
353
|
+
xt(!!document.fullscreenElement);
|
|
347
354
|
};
|
|
348
355
|
return document.addEventListener("fullscreenchange", t), () => document.removeEventListener("fullscreenchange", t);
|
|
349
|
-
}, []),
|
|
350
|
-
const t =
|
|
356
|
+
}, []), H(() => {
|
|
357
|
+
const t = F.current;
|
|
351
358
|
if (!t) return;
|
|
359
|
+
const e = Ae.current, u = () => {
|
|
360
|
+
pt(
|
|
361
|
+
e ? Math.ceil(e.offsetTop + e.offsetHeight) : 0
|
|
362
|
+
);
|
|
363
|
+
};
|
|
352
364
|
if (typeof ResizeObserver > "u") {
|
|
353
|
-
|
|
365
|
+
le(t.clientWidth), u();
|
|
354
366
|
return;
|
|
355
367
|
}
|
|
356
|
-
const
|
|
357
|
-
|
|
368
|
+
const M = new ResizeObserver((_) => {
|
|
369
|
+
const N = _.find((m) => m.target === t);
|
|
370
|
+
N && le(N.contentRect.width), u();
|
|
358
371
|
});
|
|
359
|
-
return
|
|
360
|
-
}, []);
|
|
361
|
-
const
|
|
362
|
-
if (
|
|
372
|
+
return M.observe(t), e && M.observe(e), le(t.clientWidth), u(), () => M.disconnect();
|
|
373
|
+
}, [Te]);
|
|
374
|
+
const He = Tt(() => {
|
|
375
|
+
if (v || X === 0 || de)
|
|
363
376
|
return;
|
|
364
|
-
const t = Math.round(
|
|
365
|
-
return { height: Math.max(t,
|
|
366
|
-
}, [
|
|
367
|
-
|
|
377
|
+
const t = Math.round(X * 9 / 16);
|
|
378
|
+
return { height: Math.max(se ?? t, Ne) };
|
|
379
|
+
}, [
|
|
380
|
+
v,
|
|
381
|
+
X,
|
|
382
|
+
se,
|
|
383
|
+
de,
|
|
384
|
+
Ne
|
|
385
|
+
]), Ct = He ? Math.max(Math.round(X * 9 / 16), se ?? 0) : void 0, vt = () => {
|
|
386
|
+
const t = F.current || C.current;
|
|
368
387
|
if (t) {
|
|
369
388
|
if (document.fullscreenElement) {
|
|
370
389
|
document.exitFullscreen().catch(() => {
|
|
@@ -375,97 +394,98 @@ const Ze = () => (Ce || (Ce = import("./blackboard-vendor.es.js")), Ce), Vt = /<
|
|
|
375
394
|
});
|
|
376
395
|
}
|
|
377
396
|
};
|
|
378
|
-
|
|
379
|
-
const t =
|
|
397
|
+
H(() => {
|
|
398
|
+
const t = U.current;
|
|
380
399
|
if (!t) return;
|
|
381
400
|
t.render(
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
|
|
401
|
+
/* @__PURE__ */ V(
|
|
402
|
+
At,
|
|
384
403
|
{
|
|
385
|
-
html:
|
|
386
|
-
locale:
|
|
387
|
-
dir:
|
|
388
|
-
lang:
|
|
389
|
-
loadingText:
|
|
390
|
-
styleLoadingText:
|
|
404
|
+
html: J,
|
|
405
|
+
locale: f,
|
|
406
|
+
dir: Ie,
|
|
407
|
+
lang: Fe,
|
|
408
|
+
loadingText: B,
|
|
409
|
+
styleLoadingText: Me,
|
|
391
410
|
scriptLoadingText: Ee,
|
|
392
|
-
disableLoadingOverlay:
|
|
393
|
-
resetToken:
|
|
394
|
-
hasRootVhHeight:
|
|
411
|
+
disableLoadingOverlay: oe,
|
|
412
|
+
resetToken: Be,
|
|
413
|
+
hasRootVhHeight: pe,
|
|
395
414
|
mode: a,
|
|
396
|
-
stretchRootHeight:
|
|
397
|
-
enableScaling:
|
|
415
|
+
stretchRootHeight: me,
|
|
416
|
+
enableScaling: S
|
|
398
417
|
}
|
|
399
418
|
)
|
|
400
|
-
),
|
|
401
|
-
|
|
419
|
+
), y.current = window.requestAnimationFrame(() => {
|
|
420
|
+
W.current?.(), S && C.current?.contentWindow?.__mdf_triggerFitContent?.(), y.current = null;
|
|
402
421
|
});
|
|
403
|
-
const e = setTimeout(() =>
|
|
422
|
+
const e = setTimeout(() => W.current?.(), 100), u = setTimeout(() => W.current?.(), 500);
|
|
404
423
|
return () => {
|
|
405
|
-
|
|
424
|
+
y.current !== null && (window.cancelAnimationFrame(y.current), y.current = null), clearTimeout(e), clearTimeout(u);
|
|
406
425
|
};
|
|
407
426
|
}, [
|
|
408
|
-
|
|
409
|
-
|
|
427
|
+
J,
|
|
428
|
+
f,
|
|
429
|
+
Ie,
|
|
410
430
|
Fe,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
ye,
|
|
431
|
+
B,
|
|
432
|
+
Me,
|
|
414
433
|
Ee,
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
434
|
+
Be,
|
|
435
|
+
oe,
|
|
436
|
+
pe,
|
|
418
437
|
a,
|
|
419
|
-
|
|
420
|
-
|
|
438
|
+
me,
|
|
439
|
+
S
|
|
421
440
|
]);
|
|
422
|
-
const
|
|
441
|
+
const St = [
|
|
423
442
|
`w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${r}`,
|
|
424
|
-
|
|
443
|
+
v ? "h-full overflow-auto flex flex-col" : He ? "overflow-hidden" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
|
|
425
444
|
].filter(Boolean).join(" ");
|
|
426
|
-
return /* @__PURE__ */
|
|
445
|
+
return /* @__PURE__ */ Et(
|
|
427
446
|
"div",
|
|
428
447
|
{
|
|
429
|
-
ref:
|
|
430
|
-
dir:
|
|
431
|
-
lang:
|
|
432
|
-
"data-root-vh":
|
|
433
|
-
className:
|
|
434
|
-
style:
|
|
435
|
-
height:
|
|
436
|
-
minHeight:
|
|
437
|
-
} :
|
|
448
|
+
ref: F,
|
|
449
|
+
dir: R,
|
|
450
|
+
lang: ie,
|
|
451
|
+
"data-root-vh": pe ? "true" : "false",
|
|
452
|
+
className: St,
|
|
453
|
+
style: q ? {
|
|
454
|
+
height: q,
|
|
455
|
+
minHeight: q
|
|
456
|
+
} : He,
|
|
438
457
|
children: [
|
|
439
|
-
!
|
|
458
|
+
!Te && /* @__PURE__ */ V(
|
|
440
459
|
"button",
|
|
441
460
|
{
|
|
461
|
+
ref: Ae,
|
|
442
462
|
type: "button",
|
|
443
|
-
dir:
|
|
444
|
-
onClick:
|
|
463
|
+
dir: Y,
|
|
464
|
+
onClick: vt,
|
|
445
465
|
className: "absolute top-2 end-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",
|
|
446
|
-
children:
|
|
466
|
+
children: de ? ut : at
|
|
447
467
|
}
|
|
448
468
|
),
|
|
449
|
-
a === "blackboard" && r === "markdown" ? /* @__PURE__ */
|
|
450
|
-
|
|
469
|
+
a === "blackboard" && r === "markdown" ? /* @__PURE__ */ V("div", { ref: dt, children: /* @__PURE__ */ V(
|
|
470
|
+
_t,
|
|
451
471
|
{
|
|
452
472
|
content: i,
|
|
453
|
-
locale:
|
|
454
|
-
dir:
|
|
455
|
-
lang:
|
|
456
|
-
disableSandboxLoadingOverlay:
|
|
473
|
+
locale: f,
|
|
474
|
+
dir: R,
|
|
475
|
+
lang: ie,
|
|
476
|
+
disableSandboxLoadingOverlay: oe
|
|
457
477
|
}
|
|
458
|
-
) }) : /* @__PURE__ */
|
|
478
|
+
) }) : /* @__PURE__ */ V(
|
|
459
479
|
"iframe",
|
|
460
480
|
{
|
|
461
|
-
ref:
|
|
481
|
+
ref: C,
|
|
462
482
|
sandbox: "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",
|
|
463
483
|
allow: "fullscreen",
|
|
464
484
|
allowFullScreen: !0,
|
|
465
485
|
className: [l, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
|
|
466
486
|
style: {
|
|
467
|
-
height:
|
|
468
|
-
minHeight:
|
|
487
|
+
height: q ?? Ct ?? "100%",
|
|
488
|
+
minHeight: q,
|
|
469
489
|
margin: "auto"
|
|
470
490
|
}
|
|
471
491
|
}
|
|
@@ -473,11 +493,11 @@ const Ze = () => (Ce || (Ce = import("./blackboard-vendor.es.js")), Ce), Vt = /<
|
|
|
473
493
|
]
|
|
474
494
|
}
|
|
475
495
|
);
|
|
476
|
-
},
|
|
477
|
-
const r = i.mode ?? "content", l = !!(i.enableScaling && r === "blackboard" && i.type === "sandbox"),
|
|
478
|
-
return /* @__PURE__ */
|
|
496
|
+
}, dn = (i) => {
|
|
497
|
+
const r = i.mode ?? "content", l = !!(i.enableScaling && r === "blackboard" && i.type === "sandbox"), f = `${i.type}:${r}:${l ? "scaled" : "unscaled"}`;
|
|
498
|
+
return /* @__PURE__ */ V(Xt, { ...i }, f);
|
|
479
499
|
};
|
|
480
500
|
export {
|
|
481
|
-
|
|
501
|
+
dn as default
|
|
482
502
|
};
|
|
483
503
|
//# sourceMappingURL=IframeSandbox.es.js.map
|