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