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