markdown-flow-ui 0.2.34 → 0.2.35-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/_virtual/index.es10.js +2 -3
- package/dist/_virtual/index.es10.js.map +1 -1
- package/dist/_virtual/index.es11.js +3 -2
- package/dist/_virtual/index.es11.js.map +1 -1
- package/dist/_virtual/index.es7.js +5 -2
- package/dist/_virtual/index.es7.js.map +1 -1
- package/dist/_virtual/index.es8.js +2 -5
- package/dist/_virtual/index.es8.js.map +1 -1
- package/dist/_virtual/index10.cjs +1 -1
- package/dist/_virtual/index11.cjs +1 -1
- package/dist/_virtual/index7.cjs +1 -1
- package/dist/_virtual/index8.cjs +1 -1
- package/dist/components/ContentRender/IframeSandbox.cjs +3 -3
- package/dist/components/ContentRender/IframeSandbox.cjs.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.es.js +199 -196
- 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 +26 -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/dist/node_modules/classnames/index.cjs +1 -1
- package/dist/node_modules/classnames/index.es.js +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/node_modules/rc-util/es/ref.cjs +1 -1
- package/dist/node_modules/rc-util/es/ref.es.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.cjs +1 -1
- package/dist/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/package.json +1 -1
|
@@ -1,92 +1,93 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import j, { useRef as o, useCallback as
|
|
3
|
-
import { createRoot as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
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";
|
|
14
15
|
let ye = null;
|
|
15
|
-
const
|
|
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
21
|
(l, f, G = "") => {
|
|
21
22
|
const x = G.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
|
|
22
23
|
if (!x)
|
|
23
24
|
return l;
|
|
24
|
-
const
|
|
25
|
-
return
|
|
25
|
+
const B = Yt(x[2]);
|
|
26
|
+
return B === x[2] ? l : `${f}${G.replace(
|
|
26
27
|
x[0],
|
|
27
|
-
`class=${x[1]}${
|
|
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
35
|
locale: f,
|
|
35
36
|
lang: G,
|
|
36
37
|
dir: x,
|
|
37
|
-
loadingText:
|
|
38
|
-
styleLoadingText:
|
|
39
|
-
scriptLoadingText:
|
|
40
|
-
fullScreenButtonText:
|
|
41
|
-
exitFullScreenButtonText:
|
|
42
|
-
hideFullScreen:
|
|
38
|
+
loadingText: B,
|
|
39
|
+
styleLoadingText: Me,
|
|
40
|
+
scriptLoadingText: Ee,
|
|
41
|
+
fullScreenButtonText: it,
|
|
42
|
+
exitFullScreenButtonText: ct,
|
|
43
|
+
hideFullScreen: Te = !1,
|
|
43
44
|
mode: a = "content",
|
|
44
|
-
replaceRootScreenHeightWithFull:
|
|
45
|
-
enableScaling:
|
|
45
|
+
replaceRootScreenHeightWithFull: st = !1,
|
|
46
|
+
enableScaling: lt = !1,
|
|
46
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
|
-
|
|
54
|
+
), { resolvedDirection: ht } = rt(
|
|
55
|
+
De,
|
|
55
56
|
R
|
|
56
|
-
),
|
|
57
|
-
|
|
58
|
-
const [
|
|
57
|
+
), Ie = R ?? ce, Oe = o(R);
|
|
58
|
+
Oe.current = R;
|
|
59
|
+
const [ft, mt] = A();
|
|
59
60
|
let Y;
|
|
60
|
-
R === "auto" && (Y = ce, r === "sandbox" ? Y =
|
|
61
|
-
const
|
|
62
|
-
}), [
|
|
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
66
|
), c = j.useMemo(
|
|
66
|
-
() =>
|
|
67
|
+
() => Ut(
|
|
67
68
|
K,
|
|
68
69
|
O
|
|
69
70
|
),
|
|
70
71
|
[K, O]
|
|
71
|
-
),
|
|
72
|
-
() => O ?
|
|
72
|
+
), We = j.useMemo(
|
|
73
|
+
() => O ? tt(K) : Dt,
|
|
73
74
|
[K, O]
|
|
74
75
|
), me = j.useMemo(
|
|
75
|
-
() => O &&
|
|
76
|
+
() => O && We.hasFullViewportHeight,
|
|
76
77
|
[
|
|
77
|
-
|
|
78
|
+
We.hasFullViewportHeight,
|
|
78
79
|
O
|
|
79
80
|
]
|
|
80
|
-
), [J, ze] =
|
|
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 - Ve.current <
|
|
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
|
|
@@ -94,49 +95,49 @@ const rt = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Pt = /<
|
|
|
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
100
|
const e = () => be("click");
|
|
100
101
|
return t.addEventListener("click", e), () => t.removeEventListener("click", e);
|
|
101
102
|
}, [be, a, r]);
|
|
102
103
|
const we = () => {
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
|
|
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
|
-
we(),
|
|
110
|
+
we(), Rt();
|
|
110
111
|
},
|
|
111
112
|
[]
|
|
112
113
|
), H(() => {
|
|
113
|
-
const t =
|
|
114
|
-
|
|
115
|
-
const e = !!t && c.length > t.length && c.startsWith(t), u =
|
|
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
119
|
if (!(e && u)) {
|
|
119
120
|
we(), ge.current = c, ze(c);
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
|
-
ge.current = c, we(),
|
|
123
|
-
ze(ge.current),
|
|
124
|
-
},
|
|
123
|
+
ge.current = c, we(), $.current = window.setTimeout(() => {
|
|
124
|
+
ze(ge.current), $.current = null;
|
|
125
|
+
}, jt);
|
|
125
126
|
}, [c]);
|
|
126
|
-
const Q = j.useMemo(() =>
|
|
127
|
+
const Q = j.useMemo(() => z ? tt(J).viewportHeightCss : null, [J, z]);
|
|
127
128
|
H(() => {
|
|
128
129
|
qe.current = Q;
|
|
129
130
|
}, [Q]);
|
|
130
|
-
const pe = !!Q,
|
|
131
|
+
const pe = !!Q, q = v && r === "sandbox" ? S || me ? "100%" : Q ?? `${gt}px` : void 0;
|
|
131
132
|
H(() => {
|
|
132
133
|
if (a !== "blackboard") {
|
|
133
134
|
fe.current = c;
|
|
134
135
|
return;
|
|
135
136
|
}
|
|
136
137
|
const t = fe.current;
|
|
137
|
-
!(t && c.startsWith(t)) && t &&
|
|
138
|
+
!(t && c.startsWith(t)) && t && Ht((u) => u + 1), fe.current = c;
|
|
138
139
|
}, [a, c]), H(() => {
|
|
139
|
-
const t =
|
|
140
|
+
const t = C.current;
|
|
140
141
|
if (!t) return;
|
|
141
142
|
const e = t.contentDocument;
|
|
142
143
|
if (!e) return;
|
|
@@ -147,7 +148,7 @@ const rt = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Pt = /<
|
|
|
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
153
|
html, body { margin: 0; padding: 0; overflow: ${S ? "hidden auto" : a === "blackboard" ? "auto" : "hidden"}; }
|
|
153
154
|
*, *::before, *::after { box-sizing: border-box; }
|
|
@@ -163,94 +164,96 @@ const rt = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Pt = /<
|
|
|
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 u =
|
|
167
|
-
u && e.addEventListener("click",
|
|
168
|
-
const
|
|
169
|
-
if (!
|
|
170
|
-
const N =
|
|
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(_);
|
|
171
172
|
U.current = N;
|
|
172
173
|
let m = !1;
|
|
173
|
-
const
|
|
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
187
|
if (b !== null)
|
|
187
188
|
return Math.ceil(b);
|
|
188
|
-
const
|
|
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
|
+
return ne !== null ? Math.ceil(ne) : null;
|
|
216
217
|
}, xe = () => {
|
|
217
|
-
if (!
|
|
218
|
-
if (!
|
|
218
|
+
if (!C.current || !e.body) return;
|
|
219
|
+
if (!v) {
|
|
219
220
|
if (ae.current) {
|
|
220
221
|
ue.current = !0;
|
|
221
222
|
return;
|
|
222
223
|
}
|
|
223
224
|
ae.current = !0;
|
|
224
|
-
const
|
|
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;
|
|
225
228
|
if (w > 0) {
|
|
226
|
-
const
|
|
227
|
-
g.style.height =
|
|
229
|
+
const P = Math.round(w * 9 / 16), ne = Math.max(8192, w * 20);
|
|
230
|
+
g.style.height = P + "px", e.body.offsetHeight;
|
|
228
231
|
let h = e.body.scrollHeight;
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
231
|
-
const L = (
|
|
232
|
+
const Ke = e.defaultView;
|
|
233
|
+
if (Ke) {
|
|
234
|
+
const L = (T) => {
|
|
232
235
|
let p = 0;
|
|
233
|
-
const
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
+
const Je = (k) => {
|
|
237
|
+
const Qe = Ke.getComputedStyle(k);
|
|
238
|
+
if (Qe.position === "fixed" && (p = Math.max(
|
|
236
239
|
p,
|
|
237
|
-
Math.ceil(
|
|
238
|
-
)),
|
|
239
|
-
const re =
|
|
240
|
+
Math.ceil(k.getBoundingClientRect().bottom)
|
|
241
|
+
)), k !== T && k.scrollHeight > k.clientHeight + 1) {
|
|
242
|
+
const re = Qe.overflowY;
|
|
240
243
|
if (re === "auto" || re === "scroll") {
|
|
241
|
-
const
|
|
242
|
-
|
|
244
|
+
const Ze = k.getBoundingClientRect();
|
|
245
|
+
Ze.top >= 0 && (p = Math.max(
|
|
243
246
|
p,
|
|
244
|
-
Math.ceil(
|
|
247
|
+
Math.ceil(Ze.top + k.scrollHeight)
|
|
245
248
|
));
|
|
246
249
|
}
|
|
247
250
|
}
|
|
248
|
-
for (const re of
|
|
251
|
+
for (const re of k.children) Je(re);
|
|
249
252
|
};
|
|
250
|
-
return
|
|
253
|
+
return Je(T), p;
|
|
251
254
|
};
|
|
252
255
|
h = Math.max(h, L(e.body));
|
|
253
|
-
for (let
|
|
256
|
+
for (let T = 0; T < 8 && h > P; T++) {
|
|
254
257
|
g.style.height = h + "px", e.body.offsetHeight;
|
|
255
258
|
const p = Math.max(
|
|
256
259
|
e.body.scrollHeight,
|
|
@@ -260,101 +263,101 @@ const rt = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Pt = /<
|
|
|
260
263
|
h = p;
|
|
261
264
|
}
|
|
262
265
|
}
|
|
263
|
-
g.style.height =
|
|
264
|
-
const
|
|
265
|
-
return L ===
|
|
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;
|
|
266
269
|
});
|
|
267
270
|
}
|
|
268
271
|
setTimeout(() => {
|
|
269
|
-
ae.current = !1, ue.current && (ue.current = !1,
|
|
272
|
+
ae.current = !1, ue.current && (ue.current = !1, D());
|
|
270
273
|
}, 50);
|
|
271
274
|
return;
|
|
272
275
|
}
|
|
273
276
|
if (S) return;
|
|
274
|
-
const n = e.body.scrollHeight, s = e.documentElement?.scrollHeight || 0, b =
|
|
275
|
-
if (
|
|
276
|
-
const
|
|
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(
|
|
277
280
|
200,
|
|
278
|
-
|
|
281
|
+
E ?? Math.ceil(I)
|
|
279
282
|
);
|
|
280
|
-
|
|
281
|
-
(
|
|
283
|
+
bt(
|
|
284
|
+
(w) => w === g ? w : g
|
|
282
285
|
);
|
|
283
286
|
}
|
|
284
|
-
},
|
|
287
|
+
}, D = () => {
|
|
285
288
|
requestAnimationFrame(() => {
|
|
286
289
|
m || xe();
|
|
287
290
|
});
|
|
288
291
|
};
|
|
289
|
-
W.current =
|
|
290
|
-
m || (n(e), S &&
|
|
291
|
-
m ||
|
|
292
|
+
W.current = D, xe(), D(), he && ot().then(({ injectBlackboardLibraries: n }) => {
|
|
293
|
+
m || (n(e), S && Bt(e), requestAnimationFrame(() => {
|
|
294
|
+
m || D();
|
|
292
295
|
}));
|
|
293
296
|
}).catch(() => {
|
|
294
|
-
m ||
|
|
297
|
+
m || D();
|
|
295
298
|
});
|
|
296
|
-
const d =
|
|
299
|
+
const d = F.current;
|
|
297
300
|
let Re = !!(d && (d.clientWidth <= 0 || d.clientHeight <= 0)), Z = !1, ee = null, te = null;
|
|
298
|
-
const
|
|
301
|
+
const je = () => {
|
|
299
302
|
if (m) return;
|
|
300
|
-
|
|
301
|
-
},
|
|
302
|
-
!he || !d || !Re || Z || !
|
|
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 }) => {
|
|
303
306
|
m || (ee = window.requestAnimationFrame(() => {
|
|
304
307
|
ee = null, Z = !1;
|
|
305
308
|
const s = e.querySelector(".sandbox-container");
|
|
306
|
-
m || !
|
|
307
|
-
te = null,
|
|
309
|
+
m || !Ce() || !s?.childNodes.length || !n(e) || (Re = !1, je(), te = window.setTimeout(() => {
|
|
310
|
+
te = null, je();
|
|
308
311
|
}, 100));
|
|
309
312
|
}));
|
|
310
313
|
}).catch(() => {
|
|
311
314
|
Z = !1;
|
|
312
315
|
}));
|
|
313
|
-
},
|
|
314
|
-
const s = n[0]?.contentRect, b = s?.width ?? d.clientWidth,
|
|
315
|
-
b > 0 &&
|
|
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();
|
|
316
319
|
}) : null;
|
|
317
|
-
|
|
318
|
-
const Se =
|
|
319
|
-
Se?.observe(e.body),
|
|
320
|
+
ve && d && ve.observe(d);
|
|
321
|
+
const Se = Ye ? new ResizeObserver(() => xe()) : null;
|
|
322
|
+
Se?.observe(e.body), _ && Se?.observe(_);
|
|
320
323
|
const Mt = () => {
|
|
321
|
-
if (r !== "sandbox" ||
|
|
324
|
+
if (r !== "sandbox" || Oe.current !== "auto")
|
|
322
325
|
return;
|
|
323
326
|
const n = e.querySelector(".sandbox-wrapper"), s = e.defaultView;
|
|
324
327
|
if (!n || !s) return;
|
|
325
328
|
const b = s.getComputedStyle(n).direction === "rtl" ? "rtl" : "ltr";
|
|
326
|
-
|
|
327
|
-
(
|
|
329
|
+
mt(
|
|
330
|
+
(I) => I === b ? I : b
|
|
328
331
|
);
|
|
329
|
-
},
|
|
330
|
-
if (Mt(),
|
|
332
|
+
}, Ue = new MutationObserver(() => {
|
|
333
|
+
if (Mt(), D(), !Ce()) {
|
|
331
334
|
Re = !0;
|
|
332
335
|
return;
|
|
333
336
|
}
|
|
334
|
-
|
|
337
|
+
Ge();
|
|
335
338
|
});
|
|
336
|
-
return
|
|
339
|
+
return Ue.observe(e.body, {
|
|
337
340
|
childList: !0,
|
|
338
341
|
characterData: !0,
|
|
339
342
|
subtree: !0,
|
|
340
343
|
attributes: !0,
|
|
341
344
|
attributeFilter: ["style", "class", "dir"]
|
|
342
345
|
}), () => {
|
|
343
|
-
m = !0,
|
|
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 = () => {
|
|
344
347
|
}), setTimeout(() => {
|
|
345
348
|
N.unmount();
|
|
346
349
|
}, 0);
|
|
347
350
|
};
|
|
348
351
|
}, []), H(() => {
|
|
349
352
|
const t = () => {
|
|
350
|
-
|
|
353
|
+
xt(!!document.fullscreenElement);
|
|
351
354
|
};
|
|
352
355
|
return document.addEventListener("fullscreenchange", t), () => document.removeEventListener("fullscreenchange", t);
|
|
353
356
|
}, []), H(() => {
|
|
354
|
-
const t =
|
|
357
|
+
const t = F.current;
|
|
355
358
|
if (!t) return;
|
|
356
|
-
const e =
|
|
357
|
-
|
|
359
|
+
const e = Ae.current, u = () => {
|
|
360
|
+
pt(
|
|
358
361
|
e ? Math.ceil(e.offsetTop + e.offsetHeight) : 0
|
|
359
362
|
);
|
|
360
363
|
};
|
|
@@ -362,25 +365,25 @@ const rt = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Pt = /<
|
|
|
362
365
|
le(t.clientWidth), u();
|
|
363
366
|
return;
|
|
364
367
|
}
|
|
365
|
-
const
|
|
366
|
-
const N =
|
|
368
|
+
const M = new ResizeObserver((_) => {
|
|
369
|
+
const N = _.find((m) => m.target === t);
|
|
367
370
|
N && le(N.contentRect.width), u();
|
|
368
371
|
});
|
|
369
|
-
return
|
|
370
|
-
}, [
|
|
371
|
-
const He =
|
|
372
|
-
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)
|
|
373
376
|
return;
|
|
374
377
|
const t = Math.round(X * 9 / 16);
|
|
375
|
-
return { height: Math.max(se ?? t,
|
|
378
|
+
return { height: Math.max(se ?? t, Ne) };
|
|
376
379
|
}, [
|
|
377
|
-
|
|
380
|
+
v,
|
|
378
381
|
X,
|
|
379
382
|
se,
|
|
380
383
|
de,
|
|
381
|
-
|
|
382
|
-
]),
|
|
383
|
-
const t =
|
|
384
|
+
Ne
|
|
385
|
+
]), Ct = He ? Math.max(Math.round(X * 9 / 16), se ?? 0) : void 0, vt = () => {
|
|
386
|
+
const t = F.current || C.current;
|
|
384
387
|
if (t) {
|
|
385
388
|
if (document.fullscreenElement) {
|
|
386
389
|
document.exitFullscreen().catch(() => {
|
|
@@ -395,76 +398,76 @@ const rt = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Pt = /<
|
|
|
395
398
|
const t = U.current;
|
|
396
399
|
if (!t) return;
|
|
397
400
|
t.render(
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
|
|
401
|
+
/* @__PURE__ */ V(
|
|
402
|
+
At,
|
|
400
403
|
{
|
|
401
404
|
html: J,
|
|
402
405
|
locale: f,
|
|
403
|
-
dir:
|
|
404
|
-
lang:
|
|
405
|
-
loadingText:
|
|
406
|
-
styleLoadingText:
|
|
407
|
-
scriptLoadingText:
|
|
406
|
+
dir: Ie,
|
|
407
|
+
lang: Fe,
|
|
408
|
+
loadingText: B,
|
|
409
|
+
styleLoadingText: Me,
|
|
410
|
+
scriptLoadingText: Ee,
|
|
408
411
|
disableLoadingOverlay: oe,
|
|
409
|
-
resetToken:
|
|
412
|
+
resetToken: Be,
|
|
410
413
|
hasRootVhHeight: pe,
|
|
411
414
|
mode: a,
|
|
412
415
|
stretchRootHeight: me,
|
|
413
416
|
enableScaling: S
|
|
414
417
|
}
|
|
415
418
|
)
|
|
416
|
-
),
|
|
417
|
-
W.current?.(), S &&
|
|
419
|
+
), y.current = window.requestAnimationFrame(() => {
|
|
420
|
+
W.current?.(), S && C.current?.contentWindow?.__mdf_triggerFitContent?.(), y.current = null;
|
|
418
421
|
});
|
|
419
422
|
const e = setTimeout(() => W.current?.(), 100), u = setTimeout(() => W.current?.(), 500);
|
|
420
423
|
return () => {
|
|
421
|
-
|
|
424
|
+
y.current !== null && (window.cancelAnimationFrame(y.current), y.current = null), clearTimeout(e), clearTimeout(u);
|
|
422
425
|
};
|
|
423
426
|
}, [
|
|
424
427
|
J,
|
|
425
428
|
f,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
+
Ie,
|
|
430
|
+
Fe,
|
|
431
|
+
B,
|
|
432
|
+
Me,
|
|
429
433
|
Ee,
|
|
430
|
-
|
|
431
|
-
We,
|
|
434
|
+
Be,
|
|
432
435
|
oe,
|
|
433
436
|
pe,
|
|
434
437
|
a,
|
|
435
438
|
me,
|
|
436
439
|
S
|
|
437
440
|
]);
|
|
438
|
-
const
|
|
441
|
+
const St = [
|
|
439
442
|
`w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${r}`,
|
|
440
|
-
|
|
443
|
+
v ? "h-full overflow-auto flex flex-col" : He ? "overflow-hidden" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
|
|
441
444
|
].filter(Boolean).join(" ");
|
|
442
|
-
return /* @__PURE__ */
|
|
445
|
+
return /* @__PURE__ */ Et(
|
|
443
446
|
"div",
|
|
444
447
|
{
|
|
445
|
-
ref:
|
|
448
|
+
ref: F,
|
|
446
449
|
dir: R,
|
|
447
450
|
lang: ie,
|
|
448
451
|
"data-root-vh": pe ? "true" : "false",
|
|
449
|
-
className:
|
|
450
|
-
style:
|
|
451
|
-
height:
|
|
452
|
-
minHeight:
|
|
452
|
+
className: St,
|
|
453
|
+
style: q ? {
|
|
454
|
+
height: q,
|
|
455
|
+
minHeight: q
|
|
453
456
|
} : He,
|
|
454
457
|
children: [
|
|
455
|
-
!
|
|
458
|
+
!Te && /* @__PURE__ */ V(
|
|
456
459
|
"button",
|
|
457
460
|
{
|
|
458
|
-
ref:
|
|
461
|
+
ref: Ae,
|
|
459
462
|
type: "button",
|
|
460
463
|
dir: Y,
|
|
461
464
|
onClick: vt,
|
|
462
465
|
className: "absolute top-2 end-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",
|
|
463
|
-
children: de ?
|
|
466
|
+
children: de ? ut : at
|
|
464
467
|
}
|
|
465
468
|
),
|
|
466
|
-
a === "blackboard" && r === "markdown" ? /* @__PURE__ */
|
|
467
|
-
|
|
469
|
+
a === "blackboard" && r === "markdown" ? /* @__PURE__ */ V("div", { ref: dt, children: /* @__PURE__ */ V(
|
|
470
|
+
_t,
|
|
468
471
|
{
|
|
469
472
|
content: i,
|
|
470
473
|
locale: f,
|
|
@@ -472,17 +475,17 @@ const rt = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Pt = /<
|
|
|
472
475
|
lang: ie,
|
|
473
476
|
disableSandboxLoadingOverlay: oe
|
|
474
477
|
}
|
|
475
|
-
) }) : /* @__PURE__ */
|
|
478
|
+
) }) : /* @__PURE__ */ V(
|
|
476
479
|
"iframe",
|
|
477
480
|
{
|
|
478
|
-
ref:
|
|
481
|
+
ref: C,
|
|
479
482
|
sandbox: "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",
|
|
480
483
|
allow: "fullscreen",
|
|
481
484
|
allowFullScreen: !0,
|
|
482
485
|
className: [l, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
|
|
483
486
|
style: {
|
|
484
|
-
height:
|
|
485
|
-
minHeight:
|
|
487
|
+
height: q ?? Ct ?? "100%",
|
|
488
|
+
minHeight: q,
|
|
486
489
|
margin: "auto"
|
|
487
490
|
}
|
|
488
491
|
}
|
|
@@ -490,11 +493,11 @@ const rt = () => (ye || (ye = import("./blackboard-vendor.es.js")), ye), Pt = /<
|
|
|
490
493
|
]
|
|
491
494
|
}
|
|
492
495
|
);
|
|
493
|
-
},
|
|
496
|
+
}, dn = (i) => {
|
|
494
497
|
const r = i.mode ?? "content", l = !!(i.enableScaling && r === "blackboard" && i.type === "sandbox"), f = `${i.type}:${r}:${l ? "scaled" : "unscaled"}`;
|
|
495
|
-
return /* @__PURE__ */
|
|
498
|
+
return /* @__PURE__ */ V(Xt, { ...i }, f);
|
|
496
499
|
};
|
|
497
500
|
export {
|
|
498
|
-
|
|
501
|
+
dn as default
|
|
499
502
|
};
|
|
500
503
|
//# sourceMappingURL=IframeSandbox.es.js.map
|