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