markdown-flow-ui 0.2.1 → 0.2.2

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