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