markdown-flow-ui 0.2.32 → 0.2.34

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