markdown-flow-ui 0.3.9 → 0.3.11

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