markdown-flow-ui 0.2.34 → 0.2.35-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +5 -2
  2. package/dist/_virtual/index.es10.js +2 -3
  3. package/dist/_virtual/index.es10.js.map +1 -1
  4. package/dist/_virtual/index.es11.js +3 -2
  5. package/dist/_virtual/index.es11.js.map +1 -1
  6. package/dist/_virtual/index.es7.js +5 -2
  7. package/dist/_virtual/index.es7.js.map +1 -1
  8. package/dist/_virtual/index.es8.js +2 -5
  9. package/dist/_virtual/index.es8.js.map +1 -1
  10. package/dist/_virtual/index10.cjs +1 -1
  11. package/dist/_virtual/index11.cjs +1 -1
  12. package/dist/_virtual/index7.cjs +1 -1
  13. package/dist/_virtual/index8.cjs +1 -1
  14. package/dist/components/ContentRender/IframeSandbox.cjs +3 -3
  15. package/dist/components/ContentRender/IframeSandbox.cjs.map +1 -1
  16. package/dist/components/ContentRender/IframeSandbox.es.js +199 -196
  17. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  18. package/dist/components/ContentRender/utils/content-viewport-min-height.cjs +2 -0
  19. package/dist/components/ContentRender/utils/content-viewport-min-height.cjs.map +1 -0
  20. package/dist/components/ContentRender/utils/content-viewport-min-height.d.ts +2 -0
  21. package/dist/components/ContentRender/utils/content-viewport-min-height.es.js +22 -0
  22. package/dist/components/ContentRender/utils/content-viewport-min-height.es.js.map +1 -0
  23. package/dist/components/ContentRender/utils/content-viewport-min-height.test.d.ts +1 -0
  24. package/dist/node_modules/classnames/index.cjs +1 -1
  25. package/dist/node_modules/classnames/index.es.js +1 -1
  26. package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
  27. package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
  28. package/dist/node_modules/rc-util/es/ref.cjs +1 -1
  29. package/dist/node_modules/rc-util/es/ref.es.js +1 -1
  30. package/dist/node_modules/style-to-object/cjs/index.cjs +1 -1
  31. package/dist/node_modules/style-to-object/cjs/index.es.js +1 -1
  32. package/package.json +1 -1
@@ -1,92 +1,93 @@
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";
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 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
+ 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(" "), Gt = (i, r) => !r || !i.trim() ? i : i.replace(
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 V = jt(x[2]);
25
- return V === x[2] ? l : `${f}${G.replace(
25
+ const B = Yt(x[2]);
26
+ return B === x[2] ? l : `${f}${G.replace(
26
27
  x[0],
27
- `class=${x[1]}${V}${x[1]}`
28
+ `class=${x[1]}${B}${x[1]}`
28
29
  )}>`;
29
30
  }
30
- ), Yt = ({
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: V,
38
- styleLoadingText: Ee,
39
- scriptLoadingText: Te,
40
- fullScreenButtonText: ot,
41
- exitFullScreenButtonText: it,
42
- hideFullScreen: ke = !1,
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: ct = !1,
45
- enableScaling: st = !1,
45
+ replaceRootScreenHeightWithFull: st = !1,
46
+ enableScaling: lt = !1,
46
47
  disableLoadingOverlay: oe = !1
47
48
  }) => {
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
+ 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
- De.current = t, Ie.current = t?.querySelector(".content-render") ?? null;
51
+ _e.current = t, De.current = t?.querySelector(".content-render") ?? null;
51
52
  },
52
53
  []
53
- ), { resolvedDirection: dt } = nt(
54
- Ie,
54
+ ), { resolvedDirection: ht } = rt(
55
+ De,
55
56
  R
56
- ), Oe = R ?? ce, Ne = o(R);
57
- Ne.current = R;
58
- const [ht, ft] = k();
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 = 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(
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
- () => Gt(
67
+ () => Ut(
67
68
  K,
68
69
  O
69
70
  ),
70
71
  [K, O]
71
- ), $e = j.useMemo(
72
- () => O ? et(K) : Ft,
72
+ ), We = j.useMemo(
73
+ () => O ? tt(K) : Dt,
73
74
  [K, O]
74
75
  ), me = j.useMemo(
75
- () => O && $e.hasFullViewportHeight,
76
+ () => O && We.hasFullViewportHeight,
76
77
  [
77
- $e.hasFullViewportHeight,
78
+ We.hasFullViewportHeight,
78
79
  O
79
80
  ]
80
- ), [J, ze] = k(
81
+ ), [J, ze] = A(
81
82
  c
82
- ), Pe = o(c), ge = o(c), z = o(null), M = o(null), qe = o(null), be = Ze((t) => {
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 < Lt || (Ve.current = e, window.postMessage(
87
+ e - Ve.current < Gt || (Ve.current = e, window.postMessage(
87
88
  {
88
- source: Ot,
89
- type: It,
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 = De.current;
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
- z.current !== null && (window.clearTimeout(z.current), z.current = null);
104
- }, xt = () => {
105
- M.current !== null && (window.cancelAnimationFrame(M.current), M.current = null);
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(), xt();
110
+ we(), Rt();
110
111
  },
111
112
  []
112
113
  ), H(() => {
113
- const t = Pe.current;
114
- Pe.current = c;
115
- const e = !!t && c.length > t.length && c.startsWith(t), u = Pt.test(
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(), z.current = window.setTimeout(() => {
123
- ze(ge.current), z.current = null;
124
- }, qt);
123
+ ge.current = c, we(), $.current = window.setTimeout(() => {
124
+ ze(ge.current), $.current = null;
125
+ }, jt);
125
126
  }, [c]);
126
- const Q = j.useMemo(() => $ ? et(J).viewportHeightCss : null, [J, $]);
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, P = C && r === "sandbox" ? S || me ? "100%" : Q ?? `${mt}px` : void 0;
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 && pt((u) => u + 1), fe.current = c;
138
+ !(t && c.startsWith(t)) && t && Ht((u) => u + 1), fe.current = c;
138
139
  }, [a, c]), H(() => {
139
- const t = v.current;
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: ${zt}; }
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 = 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);
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 Le = (n) => ({
174
+ const Pe = (n) => ({
174
175
  heightAttrValue: n.getAttribute("height"),
175
176
  styleAttrValue: n.getAttribute("style"),
176
177
  classAttrValue: n.getAttribute("class")
177
- }), je = (n) => {
178
+ }), Le = (n) => {
178
179
  const s = Array.from(n.children);
179
180
  return s.length === 1 ? s[0] : null;
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(
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 g = e.body.querySelector(
189
+ const E = e.body.querySelector(
189
190
  ".sandbox-wrapper"
190
191
  )?.firstElementChild;
191
- if (!g) return null;
192
- const w = Array.from(g.children), I = w.length === 1 ? w[0] : null, ne = _t(
193
- I,
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: Le,
196
- getSingleChild: je
196
+ getNode: Pe,
197
+ getSingleChild: Le
197
198
  }
198
199
  ).viewportHeightCss;
199
- if (ne) {
200
- const q = tt(
201
- ne,
200
+ if (P) {
201
+ const h = nt(
202
+ P,
202
203
  n
203
204
  );
204
- if (q !== null)
205
- return Math.ceil(q);
205
+ if (h !== null)
206
+ return Math.ceil(h);
206
207
  }
207
- const h = Dt(
208
- I,
208
+ const ne = Ot(
209
+ w,
209
210
  n,
210
211
  {
211
- getNode: Le,
212
- getSingleChild: je
212
+ getNode: Pe,
213
+ getSingleChild: Le
213
214
  }
214
215
  );
215
- return h !== null ? Math.ceil(h) : null;
216
+ return ne !== null ? Math.ceil(ne) : null;
216
217
  }, xe = () => {
217
- if (!v.current || !e.body) return;
218
- if (!C) {
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 g = v.current, w = A.current?.clientWidth || 0, I = g.style.height;
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 Me = Math.round(w * 9 / 16), ne = Math.max(8192, w * 20);
227
- g.style.height = Me + "px", e.body.offsetHeight;
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 q = e.defaultView;
230
- if (q) {
231
- const L = (E) => {
232
+ const Ke = e.defaultView;
233
+ if (Ke) {
234
+ const L = (T) => {
232
235
  let p = 0;
233
- const Ke = (T) => {
234
- const Je = q.getComputedStyle(T);
235
- if (Je.position === "fixed" && (p = Math.max(
236
+ const Je = (k) => {
237
+ const Qe = Ke.getComputedStyle(k);
238
+ if (Qe.position === "fixed" && (p = Math.max(
236
239
  p,
237
- Math.ceil(T.getBoundingClientRect().bottom)
238
- )), T !== E && T.scrollHeight > T.clientHeight + 1) {
239
- const re = Je.overflowY;
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 Qe = T.getBoundingClientRect();
242
- Qe.top >= 0 && (p = Math.max(
244
+ const Ze = k.getBoundingClientRect();
245
+ Ze.top >= 0 && (p = Math.max(
243
246
  p,
244
- Math.ceil(Qe.top + T.scrollHeight)
247
+ Math.ceil(Ze.top + k.scrollHeight)
245
248
  ));
246
249
  }
247
250
  }
248
- for (const re of T.children) Ke(re);
251
+ for (const re of k.children) Je(re);
249
252
  };
250
- return Ke(E), p;
253
+ return Je(T), p;
251
254
  };
252
255
  h = Math.max(h, L(e.body));
253
- for (let E = 0; E < 8 && h > Me; E++) {
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 = I, bt((L) => {
264
- const E = Math.min(ne, Math.max(1, Math.ceil(h)));
265
- return L === E ? L : E;
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 = F?.scrollHeight || 0, D = Math.max(n, s, b);
275
- if ($) {
276
- const g = St(), w = Math.max(
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
- g ?? Math.ceil(D)
281
+ E ?? Math.ceil(I)
279
282
  );
280
- gt(
281
- (I) => I === w ? I : w
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 = _, xe(), _(), he && rt().then(({ injectBlackboardLibraries: n }) => {
290
- m || (n(e), S && Nt(e), requestAnimationFrame(() => {
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 = A.current;
299
+ const d = F.current;
297
300
  let Re = !!(d && (d.clientWidth <= 0 || d.clientHeight <= 0)), Z = !1, ee = null, te = null;
298
- const Ge = () => {
301
+ const je = () => {
299
302
  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
+ 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 || !ve() || !s?.childNodes.length || !n(e) || (Re = !1, Ge(), te = window.setTimeout(() => {
307
- te = null, Ge();
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
- }, 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();
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
- Ce && d && Ce.observe(d);
318
- const Se = Ue ? new ResizeObserver(() => xe()) : null;
319
- Se?.observe(e.body), F && Se?.observe(F);
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" || Ne.current !== "auto")
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
- ft(
327
- (D) => D === b ? D : b
329
+ mt(
330
+ (I) => I === b ? I : b
328
331
  );
329
- }, Xe = new MutationObserver(() => {
330
- if (Mt(), _(), !ve()) {
332
+ }, Ue = new MutationObserver(() => {
333
+ if (Mt(), D(), !Ce()) {
331
334
  Re = !0;
332
335
  return;
333
336
  }
334
- Ye();
337
+ Ge();
335
338
  });
336
- return Xe.observe(e.body, {
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, 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 = () => {
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
- Ht(!!document.fullscreenElement);
353
+ xt(!!document.fullscreenElement);
351
354
  };
352
355
  return document.addEventListener("fullscreenchange", t), () => document.removeEventListener("fullscreenchange", t);
353
356
  }, []), H(() => {
354
- const t = A.current;
357
+ const t = F.current;
355
358
  if (!t) return;
356
- const e = Fe.current, u = () => {
357
- wt(
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 y = new ResizeObserver((F) => {
366
- const N = F.find((m) => m.target === t);
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 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)
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, Be) };
378
+ return { height: Math.max(se ?? t, Ne) };
376
379
  }, [
377
- C,
380
+ v,
378
381
  X,
379
382
  se,
380
383
  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;
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__ */ B(
399
- kt,
401
+ /* @__PURE__ */ V(
402
+ At,
400
403
  {
401
404
  html: J,
402
405
  locale: f,
403
- dir: Oe,
404
- lang: _e,
405
- loadingText: V,
406
- styleLoadingText: Ee,
407
- scriptLoadingText: Te,
406
+ dir: Ie,
407
+ lang: Fe,
408
+ loadingText: B,
409
+ styleLoadingText: Me,
410
+ scriptLoadingText: Ee,
408
411
  disableLoadingOverlay: oe,
409
- resetToken: We,
412
+ resetToken: Be,
410
413
  hasRootVhHeight: pe,
411
414
  mode: a,
412
415
  stretchRootHeight: me,
413
416
  enableScaling: S
414
417
  }
415
418
  )
416
- ), M.current = window.requestAnimationFrame(() => {
417
- W.current?.(), S && v.current?.contentWindow?.__mdf_triggerFitContent?.(), M.current = null;
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
- M.current !== null && (window.cancelAnimationFrame(M.current), M.current = null), clearTimeout(e), clearTimeout(u);
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
- Oe,
427
- _e,
428
- V,
429
+ Ie,
430
+ Fe,
431
+ B,
432
+ Me,
429
433
  Ee,
430
- Te,
431
- We,
434
+ Be,
432
435
  oe,
433
436
  pe,
434
437
  a,
435
438
  me,
436
439
  S
437
440
  ]);
438
- const Ct = [
441
+ const St = [
439
442
  `w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${r}`,
440
- C ? "h-full overflow-auto flex flex-col" : He ? "overflow-hidden" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
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__ */ yt(
445
+ return /* @__PURE__ */ Et(
443
446
  "div",
444
447
  {
445
- ref: A,
448
+ ref: F,
446
449
  dir: R,
447
450
  lang: ie,
448
451
  "data-root-vh": pe ? "true" : "false",
449
- className: Ct,
450
- style: P ? {
451
- height: P,
452
- minHeight: P
452
+ className: St,
453
+ style: q ? {
454
+ height: q,
455
+ minHeight: q
453
456
  } : He,
454
457
  children: [
455
- !ke && /* @__PURE__ */ B(
458
+ !Te && /* @__PURE__ */ V(
456
459
  "button",
457
460
  {
458
- ref: Fe,
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 ? at : lt
466
+ children: de ? ut : at
464
467
  }
465
468
  ),
466
- a === "blackboard" && r === "markdown" ? /* @__PURE__ */ B("div", { ref: ut, children: /* @__PURE__ */ B(
467
- At,
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__ */ B(
478
+ ) }) : /* @__PURE__ */ V(
476
479
  "iframe",
477
480
  {
478
- ref: v,
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: P ?? Rt ?? "100%",
485
- minHeight: P,
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
- }, ln = (i) => {
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__ */ B(Yt, { ...i }, f);
498
+ return /* @__PURE__ */ V(Xt, { ...i }, f);
496
499
  };
497
500
  export {
498
- ln as default
501
+ dn as default
499
502
  };
500
503
  //# sourceMappingURL=IframeSandbox.es.js.map