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.
Files changed (42) hide show
  1. package/dist/_virtual/index6.cjs +1 -1
  2. package/dist/_virtual/index6.es.js +3 -5
  3. package/dist/_virtual/index6.es.js.map +1 -1
  4. package/dist/_virtual/index7.cjs +1 -1
  5. package/dist/_virtual/index7.es.js +5 -3
  6. package/dist/_virtual/index7.es.js.map +1 -1
  7. package/dist/components/ContentRender/ContentRender.cjs +2 -2
  8. package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
  9. package/dist/components/ContentRender/ContentRender.d.ts +0 -2
  10. package/dist/components/ContentRender/ContentRender.es.js +361 -365
  11. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  12. package/dist/components/ContentRender/IframeSandbox.cjs +4 -4
  13. package/dist/components/ContentRender/IframeSandbox.cjs.map +1 -1
  14. package/dist/components/ContentRender/IframeSandbox.d.ts +0 -2
  15. package/dist/components/ContentRender/IframeSandbox.es.js +299 -296
  16. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  17. package/dist/components/ContentRender/SandboxApp.cjs +2 -2
  18. package/dist/components/ContentRender/SandboxApp.cjs.map +1 -1
  19. package/dist/components/ContentRender/SandboxApp.d.ts +4 -3
  20. package/dist/components/ContentRender/SandboxApp.es.js +110 -141
  21. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  22. package/dist/components/ContentRender/contentRenderI18n.cjs.map +1 -1
  23. package/dist/components/ContentRender/contentRenderI18n.d.ts +0 -2
  24. package/dist/components/ContentRender/contentRenderI18n.es.js.map +1 -1
  25. package/dist/components/ContentRender/locales/contentRender.json.cjs +1 -1
  26. package/dist/components/ContentRender/locales/contentRender.json.d.ts +0 -22
  27. package/dist/components/ContentRender/locales/contentRender.json.es.js +11 -11
  28. package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
  29. package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
  30. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-6MUBBAK2.cjs +1 -1
  31. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-6MUBBAK2.es.js +1 -1
  32. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-HFQBQIA3.cjs +1 -1
  33. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-HFQBQIA3.es.js +1 -1
  34. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-MALGAFMO.cjs +1 -1
  35. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-MALGAFMO.es.js +1 -1
  36. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-23REXITY.cjs +1 -1
  37. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-23REXITY.es.js +1 -1
  38. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-5NDRBG5M.cjs +1 -1
  39. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-5NDRBG5M.es.js +1 -1
  40. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-OMPLPG4O.cjs +1 -1
  41. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-OMPLPG4O.es.js +1 -1
  42. package/package.json +1 -1
@@ -1,142 +1,147 @@
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 { EMPTY_ROOT_HEIGHT_META as Dt, inspectViewportHeightFromHtmlRootString as tt, 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";
15
- let ye = null;
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) => {
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(" "), Ut = (i, r) => !r || !i.trim() ? i : i.replace(
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
- (l, f, G = "") => {
22
- const x = G.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
23
- if (!x)
24
- return l;
25
- const B = Yt(x[2]);
26
- return B === x[2] ? l : `${f}${G.replace(
27
- x[0],
28
- `class=${x[1]}${B}${x[1]}`
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
- ), Xt = ({
31
+ ), Jt = ({
32
32
  content: i,
33
33
  type: r,
34
- className: l,
35
- locale: f,
36
- lang: G,
37
- dir: x,
38
- loadingText: B,
39
- styleLoadingText: Me,
40
- scriptLoadingText: Ee,
41
- fullScreenButtonText: it,
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: st = !1,
46
- enableScaling: lt = !1,
47
- disableLoadingOverlay: oe = !1
43
+ replaceRootScreenHeightWithFull: ut = !1,
44
+ enableScaling: dt = !1,
45
+ disableLoadingOverlay: ie = !1
48
46
  }) => {
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(
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: ht } = rt(
52
+ ), { resolvedDirection: gt } = ot(
55
53
  De,
56
- R
57
- ), Ie = R ?? ce, Oe = o(R);
58
- Oe.current = R;
59
- const [ft, mt] = A();
60
- let Y;
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(
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
- ), c = j.useMemo(
67
- () => Ut(
68
- K,
64
+ ), u = Y.useMemo(
65
+ () => Kt(
66
+ Q,
69
67
  O
70
68
  ),
71
- [K, O]
72
- ), We = j.useMemo(
73
- () => O ? tt(K) : Dt,
74
- [K, O]
75
- ), me = j.useMemo(
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
- ), [J, ze] = A(
82
- c
83
- ), $e = o(c), ge = o(c), $ = o(null), y = o(null), qe = o(null), be = et((t) => {
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 < Gt || (Ve.current = e, window.postMessage(
85
+ e - Ve.current < Ut || (Ve.current = e, window.postMessage(
88
86
  {
89
- source: Vt,
90
- type: Nt,
87
+ source: Lt,
88
+ type: zt,
91
89
  eventType: t
92
90
  },
93
91
  window.location.origin
94
92
  ));
95
93
  }, []);
96
- H(() => {
94
+ S(() => {
97
95
  if (r !== "markdown" || a !== "blackboard") return;
98
96
  const t = _e.current;
99
97
  if (!t) return;
100
- const e = () => be("click");
98
+ const e = () => we("click");
101
99
  return t.addEventListener("click", e), () => t.removeEventListener("click", e);
102
- }, [be, a, r]);
103
- const we = () => {
104
- $.current !== null && (window.clearTimeout($.current), $.current = null);
105
- }, Rt = () => {
106
- y.current !== null && (window.cancelAnimationFrame(y.current), y.current = null);
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
- H(
108
+ S(
109
109
  () => () => {
110
- we(), Rt();
110
+ He(), qe(), Ct();
111
111
  },
112
112
  []
113
- ), H(() => {
114
- const t = $e.current;
115
- $e.current = c;
116
- const e = !!t && c.length > t.length && c.startsWith(t), u = Lt.test(
117
- c
118
- );
119
- if (!(e && u)) {
120
- we(), ge.current = c, ze(c);
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
- ge.current = c, we(), $.current = window.setTimeout(() => {
124
- ze(ge.current), $.current = null;
125
- }, jt);
126
- }, [c]);
127
- const Q = j.useMemo(() => z ? tt(J).viewportHeightCss : null, [J, z]);
128
- H(() => {
129
- qe.current = Q;
130
- }, [Q]);
131
- const pe = !!Q, q = v && r === "sandbox" ? S || me ? "100%" : Q ?? `${gt}px` : void 0;
132
- H(() => {
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
- fe.current = c;
139
+ me.current = u;
135
140
  return;
136
141
  }
137
- const t = fe.current;
138
- !(t && c.startsWith(t)) && t && Ht((u) => u + 1), fe.current = c;
139
- }, [a, c]), H(() => {
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: ${Pt}; }
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: ${S ? "hidden auto" : a === "blackboard" ? "auto" : "hidden"}; }
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 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(_);
172
- U.current = N;
173
- let m = !1;
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
- }), Le = (n) => {
179
- const s = Array.from(n.children);
180
- return s.length === 1 ? s[0] : null;
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(
184
- s,
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 (b !== null)
188
- return Math.ceil(b);
189
- const E = e.body.querySelector(
192
+ if (w !== null)
193
+ return Math.ceil(w);
194
+ const A = e.body.querySelector(
190
195
  ".sandbox-wrapper"
191
196
  )?.firstElementChild;
192
- if (!E) return null;
193
- const g = Array.from(E.children), w = g.length === 1 ? g[0] : null, P = It(
194
- w,
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: Le
202
+ getSingleChild: je
198
203
  }
199
204
  ).viewportHeightCss;
200
- if (P) {
201
- const h = nt(
202
- P,
205
+ if (j) {
206
+ const f = rt(
207
+ j,
203
208
  n
204
209
  );
205
- if (h !== null)
206
- return Math.ceil(h);
210
+ if (f !== null)
211
+ return Math.ceil(f);
207
212
  }
208
- const ne = Ot(
209
- w,
213
+ const re = Wt(
214
+ H,
210
215
  n,
211
216
  {
212
217
  getNode: Pe,
213
- getSingleChild: Le
218
+ getSingleChild: je
214
219
  }
215
220
  );
216
- return ne !== null ? Math.ceil(ne) : null;
217
- }, xe = () => {
221
+ return re !== null ? Math.ceil(re) : null;
222
+ }, Re = () => {
218
223
  if (!C.current || !e.body) return;
219
- if (!v) {
220
- if (ae.current) {
221
- ue.current = !0;
224
+ if (!y) {
225
+ if (ue.current) {
226
+ de.current = !0;
222
227
  return;
223
228
  }
224
- ae.current = !0;
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;
228
- if (w > 0) {
229
- const P = Math.round(w * 9 / 16), ne = Math.max(8192, w * 20);
230
- g.style.height = P + "px", e.body.offsetHeight;
231
- let h = e.body.scrollHeight;
232
- const Ke = e.defaultView;
233
- if (Ke) {
234
- const L = (T) => {
235
- let p = 0;
236
- const Je = (k) => {
237
- const Qe = Ke.getComputedStyle(k);
238
- if (Qe.position === "fixed" && (p = Math.max(
239
- p,
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 !== T && k.scrollHeight > k.clientHeight + 1) {
242
- const re = Qe.overflowY;
243
- if (re === "auto" || re === "scroll") {
244
- const Ze = k.getBoundingClientRect();
245
- Ze.top >= 0 && (p = Math.max(
246
- p,
247
- Math.ceil(Ze.top + k.scrollHeight)
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 re of k.children) Je(re);
256
+ for (const oe of k.children) Qe(oe);
252
257
  };
253
- return Je(T), p;
258
+ return Qe(F), x;
254
259
  };
255
- h = Math.max(h, L(e.body));
256
- for (let T = 0; T < 8 && h > P; T++) {
257
- g.style.height = h + "px", e.body.offsetHeight;
258
- const p = Math.max(
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
- L(e.body)
265
+ G(e.body)
261
266
  );
262
- if (p <= h + 1 || p >= h * 1.5) break;
263
- h = p;
267
+ if (x <= f + 1 || x >= f * 1.5) break;
268
+ f = x;
264
269
  }
265
270
  }
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;
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
- ae.current = !1, ue.current && (ue.current = !1, D());
277
+ ue.current = !1, de.current && (de.current = !1, I());
273
278
  }, 50);
274
279
  return;
275
280
  }
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 = yt(), g = Math.max(
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
- E ?? Math.ceil(I)
286
+ A ?? Math.ceil(N)
282
287
  );
283
- bt(
284
- (w) => w === g ? w : g
288
+ Ht(
289
+ (H) => H === p ? H : p
285
290
  );
286
291
  }
287
- }, D = () => {
292
+ }, I = () => {
288
293
  requestAnimationFrame(() => {
289
- m || xe();
294
+ b || Re();
290
295
  });
291
296
  };
292
- W.current = D, xe(), D(), he && ot().then(({ injectBlackboardLibraries: n }) => {
293
- m || (n(e), S && Bt(e), requestAnimationFrame(() => {
294
- m || D();
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
- m || D();
302
+ b || I();
298
303
  });
299
- const d = F.current;
300
- let Re = !!(d && (d.clientWidth <= 0 || d.clientHeight <= 0)), Z = !1, ee = null, te = null;
301
- const je = () => {
302
- if (m) return;
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 }) => {
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, je(), te = window.setTimeout(() => {
310
- te = null, je();
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
- Z = !1;
319
+ ee = !1;
315
320
  }));
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();
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
- ve && d && ve.observe(d);
321
- const Se = Ye ? new ResizeObserver(() => xe()) : null;
322
- Se?.observe(e.body), _ && Se?.observe(_);
323
- const Mt = () => {
324
- if (r !== "sandbox" || Oe.current !== "auto")
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"), s = e.defaultView;
327
- if (!n || !s) return;
328
- const b = s.getComputedStyle(n).direction === "rtl" ? "rtl" : "ltr";
329
- mt(
330
- (I) => I === b ? I : b
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
- }, Ue = new MutationObserver(() => {
333
- if (Mt(), D(), !Ce()) {
334
- Re = !0;
337
+ }, Xe = new MutationObserver(() => {
338
+ if (At(), I(), !Ce()) {
339
+ ve = !0;
335
340
  return;
336
341
  }
337
- Ge();
342
+ Ye();
338
343
  });
339
- return Ue.observe(e.body, {
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
- 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 = () => {
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
- N.unmount();
353
+ g.unmount();
349
354
  }, 0);
350
355
  };
351
- }, []), H(() => {
356
+ }, []), S(() => {
352
357
  const t = () => {
353
- xt(!!document.fullscreenElement);
358
+ vt(!!document.fullscreenElement);
354
359
  };
355
360
  return document.addEventListener("fullscreenchange", t), () => document.removeEventListener("fullscreenchange", t);
356
- }, []), H(() => {
357
- const t = F.current;
361
+ }, []), S(() => {
362
+ const t = D.current;
358
363
  if (!t) return;
359
- const e = Ae.current, u = () => {
360
- pt(
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
- le(t.clientWidth), u();
370
+ ae(t.clientWidth), d();
366
371
  return;
367
372
  }
368
- const M = new ResizeObserver((_) => {
369
- const N = _.find((m) => m.target === t);
370
- N && le(N.contentRect.width), u();
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 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)
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(X * 9 / 16);
378
- return { height: Math.max(se ?? t, Ne) };
382
+ const t = Math.round(J * 9 / 16);
383
+ return { height: Math.max(le ?? t, Oe) };
379
384
  }, [
380
- v,
381
- X,
382
- se,
383
- de,
384
- Ne
385
- ]), Ct = He ? Math.max(Math.round(X * 9 / 16), se ?? 0) : void 0, vt = () => {
386
- const t = F.current || C.current;
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
- H(() => {
398
- const t = U.current;
402
+ S(() => {
403
+ const t = K.current;
399
404
  if (!t) return;
400
405
  t.render(
401
- /* @__PURE__ */ V(
402
- At,
406
+ /* @__PURE__ */ B(
407
+ Dt,
403
408
  {
404
- html: J,
405
- locale: f,
409
+ html: $,
410
+ locale: m,
406
411
  dir: Ie,
407
- lang: Fe,
408
- loadingText: B,
409
- styleLoadingText: Me,
410
- scriptLoadingText: Ee,
411
- disableLoadingOverlay: oe,
412
+ lang: ke,
413
+ loadingText: W,
414
+ disableLoadingOverlay: ie,
412
415
  resetToken: Be,
413
- hasRootVhHeight: pe,
416
+ hasRootVhHeight: xe,
414
417
  mode: a,
415
- stretchRootHeight: me,
416
- enableScaling: S
418
+ stretchRootHeight: ge,
419
+ enableScaling: T,
420
+ deferScripts: be
417
421
  }
418
422
  )
419
- ), y.current = window.requestAnimationFrame(() => {
420
- W.current?.(), S && C.current?.contentWindow?.__mdf_triggerFitContent?.(), y.current = null;
423
+ ), M.current = window.requestAnimationFrame(() => {
424
+ z.current?.(), T && C.current?.contentWindow?.__mdf_triggerFitContent?.(), M.current = null;
421
425
  });
422
- const e = setTimeout(() => W.current?.(), 100), u = setTimeout(() => W.current?.(), 500);
426
+ const e = setTimeout(() => z.current?.(), 100), d = setTimeout(() => z.current?.(), 500);
423
427
  return () => {
424
- y.current !== null && (window.cancelAnimationFrame(y.current), y.current = null), clearTimeout(e), clearTimeout(u);
428
+ M.current !== null && (window.cancelAnimationFrame(M.current), M.current = null), clearTimeout(e), clearTimeout(d);
425
429
  };
426
430
  }, [
427
- J,
428
- f,
431
+ $,
432
+ m,
429
433
  Ie,
430
- Fe,
431
- B,
432
- Me,
433
- Ee,
434
+ ke,
435
+ W,
434
436
  Be,
435
- oe,
436
- pe,
437
+ ie,
438
+ xe,
437
439
  a,
438
- me,
439
- S
440
+ ge,
441
+ T,
442
+ be
440
443
  ]);
441
- const St = [
444
+ const Mt = [
442
445
  `w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${r}`,
443
- v ? "h-full overflow-auto flex flex-col" : He ? "overflow-hidden" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
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__ */ Et(
448
+ return /* @__PURE__ */ Ft(
446
449
  "div",
447
450
  {
448
- ref: F,
449
- dir: R,
450
- lang: ie,
451
- "data-root-vh": pe ? "true" : "false",
452
- className: St,
453
- style: q ? {
454
- height: q,
455
- minHeight: q
456
- } : He,
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
- !Te && /* @__PURE__ */ V(
461
+ !Ee && /* @__PURE__ */ B(
459
462
  "button",
460
463
  {
461
- ref: Ae,
464
+ ref: Fe,
462
465
  type: "button",
463
- dir: Y,
464
- onClick: vt,
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: de ? ut : at
469
+ children: he ? ft : ht
467
470
  }
468
471
  ),
469
- a === "blackboard" && r === "markdown" ? /* @__PURE__ */ V("div", { ref: dt, children: /* @__PURE__ */ V(
470
- _t,
472
+ a === "blackboard" && r === "markdown" ? /* @__PURE__ */ B("div", { ref: mt, children: /* @__PURE__ */ B(
473
+ Ot,
471
474
  {
472
475
  content: i,
473
- locale: f,
474
- dir: R,
475
- lang: ie,
476
- disableSandboxLoadingOverlay: oe
476
+ locale: m,
477
+ dir: v,
478
+ lang: ce,
479
+ disableSandboxLoadingOverlay: ie
477
480
  }
478
- ) }) : /* @__PURE__ */ V(
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: [l, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
488
+ className: [s, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
486
489
  style: {
487
- height: q ?? Ct ?? "100%",
488
- minHeight: q,
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
- }, dn = (i) => {
497
- const r = i.mode ?? "content", l = !!(i.enableScaling && r === "blackboard" && i.type === "sandbox"), f = `${i.type}:${r}:${l ? "scaled" : "unscaled"}`;
498
- return /* @__PURE__ */ V(Xt, { ...i }, f);
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
- dn as default
504
+ fn as default
502
505
  };
503
506
  //# sourceMappingURL=IframeSandbox.es.js.map