markdown-flow-ui 0.1.100-beta.20 → 0.1.100-beta.21

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/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  2. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  3. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
  4. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js.map +1 -1
  5. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
  6. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
  7. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js.map +1 -1
  8. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
  9. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
  10. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js.map +1 -1
  11. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
  12. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
  13. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js.map +1 -1
  14. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
  15. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
  16. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js.map +1 -1
  17. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
  18. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.cjs.js +1 -1
  19. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.cjs.js.map +1 -1
  20. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.es.js +1 -1
  21. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.cjs.js +1 -1
  22. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.es.js +1 -1
  23. package/dist/_virtual/index.cjs10.js +1 -1
  24. package/dist/_virtual/index.cjs11.js +1 -1
  25. package/dist/_virtual/index.cjs12.js +1 -1
  26. package/dist/_virtual/index.cjs9.js +1 -1
  27. package/dist/_virtual/index.es10.js +3 -2
  28. package/dist/_virtual/index.es10.js.map +1 -1
  29. package/dist/_virtual/index.es11.js +2 -3
  30. package/dist/_virtual/index.es11.js.map +1 -1
  31. package/dist/_virtual/index.es12.js +2 -2
  32. package/dist/_virtual/index.es9.js +3 -3
  33. package/dist/components/ContentRender/IframeSandbox.cjs.js +4 -4
  34. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  35. package/dist/components/ContentRender/IframeSandbox.es.js +303 -255
  36. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  37. package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
  38. package/dist/components/ContentRender/SandboxApp.d.ts +3 -0
  39. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  40. package/dist/components/Slide/Slide.stories.d.ts +1 -1
  41. package/dist/markdown-flow-ui-lib.css +1 -1
  42. package/package.json +1 -1
@@ -1,203 +1,248 @@
1
- import { j as v } from "../../_virtual/jsx-runtime.es.js";
2
- import k, { useRef as l, useState as O, useCallback as Me, useEffect as y } from "react";
3
- import { createRoot as Te } from "react-dom/client";
4
- import Ie from "./SandboxApp.es.js";
5
- import { splitContentSegments as _e } from "./utils/split-content.es.js";
6
- import Ne from "./ContentRender.es.js";
7
- import { SANDBOX_INTERACTION_MESSAGE_TYPE as Pe, SANDBOX_INTERACTION_MESSAGE_SOURCE as ke } from "../../lib/sandboxInteraction.es.js";
8
- let Q = null;
9
- const pe = () => (Q || (Q = import("./blackboard-vendor.es.js").then(
1
+ import { j as w } from "../../_virtual/jsx-runtime.es.js";
2
+ import R, { useRef as d, useState as V, useCallback as Ve, useEffect as C } from "react";
3
+ import { createRoot as Fe } from "react-dom/client";
4
+ import Pe from "./SandboxApp.es.js";
5
+ import { splitContentSegments as ke } from "./utils/split-content.es.js";
6
+ import Oe from "./ContentRender.es.js";
7
+ import { SANDBOX_INTERACTION_MESSAGE_TYPE as De, SANDBOX_INTERACTION_MESSAGE_SOURCE as Be } from "../../lib/sandboxInteraction.es.js";
8
+ let te = null;
9
+ const be = () => (te || (te = import("./blackboard-vendor.es.js").then(
10
10
  (e) => e.injectBlackboardLibraries
11
- )), Q);
12
- typeof window < "u" && pe();
13
- const Oe = /<img\b[^>]*>/i, De = 180, Be = 240, $e = /<img\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi, he = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Set(), je = (e) => {
14
- const t = Array.from(e.matchAll($e));
11
+ )), te);
12
+ typeof window < "u" && be();
13
+ const Le = /<img\b[^>]*>/i, $e = 180, je = 240, ze = /<img\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi, fe = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Set(), Ge = (e) => {
14
+ const t = Array.from(e.matchAll(ze));
15
15
  return Array.from(
16
16
  new Set(
17
- t.map((r) => r[1]?.trim()).filter((r) => !!r)
17
+ t.map((n) => n[1]?.trim()).filter((n) => !!n)
18
18
  )
19
19
  );
20
- }, Fe = (e) => {
20
+ }, qe = (e) => {
21
21
  if (!e)
22
22
  return Promise.resolve();
23
- const t = he.get(e);
23
+ const t = fe.get(e);
24
24
  if (t)
25
25
  return t;
26
- const r = new Promise((a) => {
26
+ const n = new Promise((s) => {
27
27
  if (typeof window > "u") {
28
- z.add(e), a();
28
+ $.add(e), s();
29
29
  return;
30
30
  }
31
- const s = new window.Image();
32
- s.decoding = "sync", s.loading = "eager", s.fetchPriority = "high";
33
- const u = () => {
34
- (typeof s.decode == "function" ? s.decode().catch(() => {
31
+ const o = new window.Image();
32
+ o.decoding = "sync", o.loading = "eager", o.fetchPriority = "high";
33
+ const l = () => {
34
+ (typeof o.decode == "function" ? o.decode().catch(() => {
35
35
  }) : Promise.resolve()).finally(() => {
36
- z.add(e), a();
36
+ $.add(e), s();
37
37
  });
38
38
  };
39
- s.onload = () => {
40
- u();
41
- }, s.onerror = () => {
42
- z.add(e), a();
43
- }, s.src = e, s.complete && s.naturalWidth > 0 && u();
39
+ o.onload = () => {
40
+ l();
41
+ }, o.onerror = () => {
42
+ $.add(e), s();
43
+ }, o.src = e, o.complete && o.naturalWidth > 0 && l();
44
44
  });
45
- return he.set(e, r), r;
46
- }, me = (e = []) => Promise.allSettled(e.map((t) => Fe(t))), ee = (e) => e.split(/\s+/).filter(Boolean).map((t) => t.split(":").pop() || t), fe = (e) => {
45
+ return fe.set(e, n), n;
46
+ }, ge = (e = []) => Promise.allSettled(e.map((t) => qe(t))), we = (e) => e.split(/\s+/).filter(Boolean).map((t) => t.split(":").pop() || t), j = (e) => {
47
47
  const t = e.trim().toLowerCase();
48
48
  if (!t) return null;
49
- const r = t.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);
50
- return r ? `${r[1]}${r[2].toLowerCase()}` : null;
51
- }, ge = (e) => {
49
+ const n = t.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);
50
+ return n ? `${n[1]}${n[2].toLowerCase()}` : null;
51
+ }, ne = (e) => {
52
52
  if (!e.trim()) return null;
53
- const t = ee(e);
53
+ const t = we(e);
54
54
  if (t.includes("h-screen") || t.includes("h-dvh"))
55
55
  return "100dvh";
56
56
  if (t.includes("h-svh"))
57
57
  return "100svh";
58
58
  if (t.includes("h-lvh"))
59
59
  return "100lvh";
60
- const r = t.find(
61
- (s) => /^h-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(s)
60
+ const n = t.find(
61
+ (o) => /^h-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(o)
62
62
  );
63
- if (!r) return null;
64
- const a = r.match(/^h-\[([0-9.]+)(vh|dvh|svh|lvh)\]$/i);
65
- return a ? `${a[1]}${a[2].toLowerCase()}` : null;
66
- }, ze = (e) => {
63
+ if (!n) return null;
64
+ const s = n.match(/^h-\[([0-9.]+)(vh|dvh|svh|lvh)\]$/i);
65
+ return s ? `${s[1]}${s[2].toLowerCase()}` : null;
66
+ }, Xe = /* @__PURE__ */ new Set([
67
+ "base",
68
+ "link",
69
+ "meta",
70
+ "script",
71
+ "style",
72
+ "template",
73
+ "title"
74
+ ]), ve = (e) => !Xe.has(e.tagName.toLowerCase()), Ue = (e) => Array.from(e.childNodes).find(
75
+ (t) => t.nodeType === Node.ELEMENT_NODE && ve(t)
76
+ ) || null, We = (e) => {
77
+ const t = [];
78
+ let n = Ue(e);
79
+ for (; n; ) {
80
+ t.push(n);
81
+ const s = Array.from(n.children).filter(
82
+ (o) => ve(o)
83
+ );
84
+ if (s.length !== 1)
85
+ break;
86
+ n = s[0];
87
+ }
88
+ return t;
89
+ }, Ye = (e) => {
90
+ const t = e.getAttribute("height"), n = t ? j(t) : null;
91
+ if (n)
92
+ return n;
93
+ const s = e.getAttribute("style")?.match(/\bheight\s*:\s*([^;]+)/i)?.[1] || null, o = s ? j(s) : null;
94
+ return o || ne(
95
+ e.getAttribute("class") || ""
96
+ );
97
+ }, He = (e) => e === "100vh" || e === "100dvh" || e === "100svh" || e === "100lvh", Ee = (e) => {
98
+ const t = We(e);
99
+ let n = null, s = !1;
100
+ return t.forEach((o) => {
101
+ const l = Ye(o);
102
+ !n && l && (n = l), He(l) && (s = !0);
103
+ }), {
104
+ viewportHeightCss: n,
105
+ hasFullViewportHeight: s
106
+ };
107
+ }, Ze = (e) => {
67
108
  const t = e.trim();
68
- if (!t) return null;
69
- const r = t.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/);
70
- return r ? r[2]?.match(/\bclass\s*=\s*["']([^"']*)["']/i)?.[1] ?? null : null;
71
- }, Le = (e) => {
72
- const t = ze(e);
73
- return t ? ee(t).includes("h-screen") : !1;
74
- }, Ve = (e) => e.split(/\s+/).filter(Boolean).map((t) => {
75
- const r = t.split(":");
76
- return r[r.length - 1] !== "h-screen" ? t : (r[r.length - 1] = "h-full", r.join(":"));
77
- }).join(" "), qe = (e, t) => !t || !e.trim() ? e : e.replace(
109
+ if (!t)
110
+ return {
111
+ viewportHeightCss: null,
112
+ hasFullViewportHeight: !1
113
+ };
114
+ const s = t.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/)?.[2] || "", o = s.match(/\bheight\s*=\s*["']([^"']+)["']/i)?.[1], m = s.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(
115
+ /\bheight\s*:\s*([^;]+)/i
116
+ )?.[1], S = s.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1], h = (o ? j(o) : null) || (m ? j(m) : null) || (S ? ne(S) : null);
117
+ return {
118
+ viewportHeightCss: h,
119
+ hasFullViewportHeight: He(h)
120
+ };
121
+ }, pe = (e) => {
122
+ const t = e.trim();
123
+ if (!t)
124
+ return {
125
+ viewportHeightCss: null,
126
+ hasFullViewportHeight: !1
127
+ };
128
+ if (typeof document > "u")
129
+ return Ze(t);
130
+ const n = document.createElement("template");
131
+ return n.innerHTML = t, Ee(n.content);
132
+ }, Je = (e) => e.split(/\s+/).filter(Boolean).map((t) => {
133
+ const n = t.split(":");
134
+ return n[n.length - 1] !== "h-screen" ? t : (n[n.length - 1] = "h-full", n.join(":"));
135
+ }).join(" "), Ke = (e, t) => !t || !e.trim() ? e : e.replace(
78
136
  /^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,
79
- (r, a, s = "") => {
80
- const u = s.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
81
- if (!u)
82
- return r;
83
- const x = Ve(u[2]);
84
- return x === u[2] ? r : `${a}${s.replace(
85
- u[0],
86
- `class=${u[1]}${x}${u[1]}`
137
+ (n, s, o = "") => {
138
+ const l = o.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
139
+ if (!l)
140
+ return n;
141
+ const m = Je(l[2]);
142
+ return m === l[2] ? n : `${s}${o.replace(
143
+ l[0],
144
+ `class=${l[1]}${m}${l[1]}`
87
145
  )}>`;
88
146
  }
89
- ), Ke = ({
147
+ ), it = ({
90
148
  content: e,
91
149
  type: t,
92
- className: r,
93
- loadingText: a,
94
- styleLoadingText: s,
95
- scriptLoadingText: u,
96
- fullScreenButtonText: x,
97
- hideFullScreen: te = !1,
98
- mode: p = "content",
99
- replaceRootScreenHeightWithFull: D = !1
150
+ className: n,
151
+ loadingText: s,
152
+ styleLoadingText: o,
153
+ scriptLoadingText: l,
154
+ fullScreenButtonText: m,
155
+ hideFullScreen: S = !1,
156
+ mode: h = "content",
157
+ replaceRootScreenHeightWithFull: F = !1
100
158
  }) => {
101
- const ne = l(null), H = l(null), L = l(null), re = l(null), V = l(() => {
102
- }), [be, we] = O(480), oe = l(0), [se, ve] = O(0), [xe, Ce] = O(!1), [, q] = O(!0), Ee = t === "sandbox", G = p === "blackboard", X = l(""), B = k.useMemo(() => {
103
- const n = _e(e).filter((h) => h.type === "sandbox");
104
- return (p === "blackboard" ? n[n.length - 1]?.value || "" : n.map((h) => h.value).join(`
159
+ const re = d(null), y = d(null), z = d(null), oe = d(null), G = d(() => {
160
+ }), [xe, Ce] = V(480), se = d(0), [ie, ye] = V(0), [Ae, Re] = V(!1), [, q] = V(!0), Se = t === "sandbox", X = h === "blackboard", U = d(""), P = R.useMemo(() => {
161
+ const r = ke(e).filter((p) => p.type === "sandbox");
162
+ return (h === "blackboard" ? r[r.length - 1]?.value || "" : r.map((p) => p.value).join(`
105
163
  `)) || "";
106
- }, [e, p]), i = k.useMemo(
107
- () => qe(
108
- B,
109
- D
164
+ }, [e, h]), c = R.useMemo(
165
+ () => Ke(
166
+ P,
167
+ F
110
168
  ),
111
- [B, D]
112
- ), M = k.useMemo(
113
- () => je(i),
114
- [i]
115
- ), ie = k.useMemo(
116
- () => D && Le(B),
117
- [B, D]
118
- ), [$, U] = O(
119
- i
120
- ), ce = l(i), W = l(i), T = l(null), I = l(null), Y = l(null), Z = l(0), S = Me((o) => {
169
+ [P, F]
170
+ ), T = R.useMemo(
171
+ () => Ge(c),
172
+ [c]
173
+ ), le = R.useMemo(
174
+ () => pe(P),
175
+ [P]
176
+ ), ce = R.useMemo(
177
+ () => F && le.hasFullViewportHeight,
178
+ [le.hasFullViewportHeight, F]
179
+ ), [k, W] = V(
180
+ c
181
+ ), ae = d(c), Y = d(c), M = d(null), I = d(null), Z = d(null), J = d(0), A = Ve((i) => {
121
182
  if (typeof window > "u")
122
183
  return;
123
- const n = Date.now();
124
- n - oe.current < Be || (oe.current = n, window.postMessage(
184
+ const r = Date.now();
185
+ r - se.current < je || (se.current = r, window.postMessage(
125
186
  {
126
- source: ke,
127
- type: Pe,
128
- eventType: o
187
+ source: Be,
188
+ type: De,
189
+ eventType: i
129
190
  },
130
191
  window.location.origin
131
192
  ));
132
- }, []), le = () => {
133
- T.current !== null && (window.clearTimeout(T.current), T.current = null);
134
- }, Re = () => {
135
- I.current !== null && (window.cancelAnimationFrame(I.current), I.current = null), Y.current !== null && (window.cancelAnimationFrame(Y.current), Y.current = null);
193
+ }, []), ue = () => {
194
+ M.current !== null && (window.clearTimeout(M.current), M.current = null);
195
+ }, Te = () => {
196
+ I.current !== null && (window.cancelAnimationFrame(I.current), I.current = null), Z.current !== null && (window.cancelAnimationFrame(Z.current), Z.current = null);
136
197
  };
137
- y(
198
+ C(
138
199
  () => () => {
139
- le(), Re();
200
+ ue(), Te();
140
201
  },
141
202
  []
142
- ), y(() => {
143
- me(M);
144
- }, [M]), y(() => {
145
- const o = ce.current;
146
- ce.current = i;
147
- const n = !!o && i.length > o.length && i.startsWith(o), d = Oe.test(
148
- i
149
- ), h = n && d && M.some(
150
- (m) => !z.has(m)
151
- ), N = n && d;
152
- if (W.current = i, le(), h) {
153
- const m = Z.current + 1;
154
- Z.current = m, me(M).then(() => {
155
- Z.current === m && U(W.current);
203
+ ), C(() => {
204
+ ge(T);
205
+ }, [T]), C(() => {
206
+ const i = ae.current;
207
+ ae.current = c;
208
+ const r = !!i && c.length > i.length && c.startsWith(i), g = Le.test(
209
+ c
210
+ ), p = r && g && T.some(
211
+ (v) => !$.has(v)
212
+ ), O = r && g;
213
+ if (Y.current = c, ue(), p) {
214
+ const v = J.current + 1;
215
+ J.current = v, ge(T).then(() => {
216
+ J.current === v && W(Y.current);
156
217
  });
157
218
  return;
158
219
  }
159
- if (!N) {
160
- U(i);
220
+ if (!O) {
221
+ W(c);
161
222
  return;
162
223
  }
163
- T.current = window.setTimeout(() => {
164
- U(W.current), T.current = null;
165
- }, De);
166
- }, [M, i]);
167
- const ae = k.useMemo(() => {
168
- const o = $.trim();
169
- if (!o) return null;
170
- const n = o.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/);
171
- if (!n) return null;
172
- const d = n[2] || "", h = d.match(/\bheight\s*=\s*["']([^"']+)["']/i);
173
- if (h) {
174
- const b = fe(h[1]);
175
- if (b) return b;
176
- }
177
- const m = d.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(
178
- /\bheight\s*:\s*([^;]+)/i
179
- )?.[1];
180
- if (m) {
181
- const b = fe(m);
182
- if (b) return b;
183
- }
184
- const C = d.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1];
185
- return C ? ge(C) : null;
186
- }, [$]), ue = !!ae, _ = G && t === "sandbox" ? ie ? "100%" : ae ?? `${be}px` : void 0;
187
- y(() => {
188
- if (p !== "blackboard") {
189
- X.current = i;
224
+ M.current = window.setTimeout(() => {
225
+ W(Y.current), M.current = null;
226
+ }, $e);
227
+ }, [T, c]);
228
+ const de = R.useMemo(
229
+ () => pe(k).viewportHeightCss,
230
+ [k]
231
+ ), he = !!de, N = X && t === "sandbox" ? ce ? "100%" : de ?? `${xe}px` : void 0;
232
+ C(() => {
233
+ if (h !== "blackboard") {
234
+ U.current = c;
190
235
  return;
191
236
  }
192
- const o = X.current;
193
- !(o && i.startsWith(o)) && o && ve((d) => d + 1), X.current = i;
194
- }, [p, i]), y(() => {
195
- const o = H.current;
196
- if (!o) return;
197
- const n = o.contentDocument;
198
- if (!n) return;
199
- n.open(), n.write(`<!DOCTYPE html>
200
- <html${p === "blackboard" ? ' style="height: 100%;"' : ""}>
237
+ const i = U.current;
238
+ !(i && c.startsWith(i)) && i && ye((g) => g + 1), U.current = c;
239
+ }, [h, c]), C(() => {
240
+ const i = y.current;
241
+ if (!i) return;
242
+ const r = i.contentDocument;
243
+ if (!r) return;
244
+ r.open(), r.write(`<!DOCTYPE html>
245
+ <html${h === "blackboard" ? ' style="height: 100%;"' : ""}>
201
246
  <head>
202
247
  <meta charset="utf-8" />
203
248
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -210,167 +255,170 @@ const Oe = /<img\b[^>]*>/i, De = 180, Be = 240, $e = /<img\b[^>]*\bsrc\s*=\s*["'
210
255
  <body>
211
256
  <div id="root"></div>
212
257
  </body>
213
- </html>`), n.close(), re.current = n;
214
- const d = G && t === "sandbox", h = () => S("pointerdown"), N = () => S("mousedown"), m = () => S("touchstart");
215
- d && (n.addEventListener("pointerdown", h, !0), n.addEventListener("mousedown", N, !0), n.addEventListener("touchstart", m, !0));
216
- const C = n.getElementById("root");
217
- if (!C) return;
218
- const b = Te(C);
219
- L.current = b;
220
- let P = !1;
221
- const de = (f, w) => {
222
- const c = f.trim().toLowerCase();
223
- if (!c) return null;
224
- const g = Number.parseFloat(c);
225
- return Number.isNaN(g) ? null : /(dvh|svh|lvh|vh)$/i.test(c) ? g / 100 * w : c.endsWith("px") || /^[0-9.]+$/.test(c) ? g : null;
226
- }, He = (f, w) => {
227
- if (!f.trim()) return null;
228
- const c = ge(f);
229
- if (c)
230
- return de(c, w);
231
- const E = ee(f).find(
232
- (F) => /^h-\[[0-9.]+px\]$/i.test(F)
258
+ </html>`), r.close(), oe.current = r;
259
+ const g = X && t === "sandbox", p = () => A("pointerdown"), O = () => A("mousedown"), v = () => A("touchstart");
260
+ g && (r.addEventListener("pointerdown", p, !0), r.addEventListener("mousedown", O, !0), r.addEventListener("touchstart", v, !0));
261
+ const D = r.getElementById("root");
262
+ if (!D) return;
263
+ const me = Fe(D);
264
+ z.current = me;
265
+ let _ = !1;
266
+ const K = (a, b) => {
267
+ const u = a.trim().toLowerCase();
268
+ if (!u) return null;
269
+ const H = Number.parseFloat(u);
270
+ return Number.isNaN(H) ? null : /(dvh|svh|lvh|vh)$/i.test(u) ? H / 100 * b : u.endsWith("px") || /^[0-9.]+$/.test(u) ? H : null;
271
+ }, Ne = (a, b) => {
272
+ if (!a.trim()) return null;
273
+ const u = ne(a);
274
+ if (u)
275
+ return K(u, b);
276
+ const f = we(a).find(
277
+ (L) => /^h-\[[0-9.]+px\]$/i.test(L)
233
278
  );
279
+ if (!f) return null;
280
+ const E = f.match(/^h-\[([0-9.]+)px\]$/i);
234
281
  if (!E) return null;
235
- const R = E.match(/^h-\[([0-9.]+)px\]$/i);
236
- if (!R) return null;
237
- const A = Number.parseFloat(R[1]);
238
- return Number.isNaN(A) ? null : A;
239
- }, Se = () => {
240
- if (!H.current || !n.body) return null;
241
- const w = n.body.querySelector(
282
+ const x = Number.parseFloat(E[1]);
283
+ return Number.isNaN(x) ? null : x;
284
+ }, _e = () => {
285
+ if (!y.current || !r.body) return null;
286
+ const a = y.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, { viewportHeightCss: b } = Ee(r.body), u = b ? K(b, a) : null;
287
+ if (u !== null)
288
+ return Math.ceil(u);
289
+ const f = r.body.querySelector(
242
290
  ".sandbox-wrapper"
243
- )?.firstElementChild;
244
- if (!w) return null;
245
- const c = Array.from(w.children);
246
- if (c.length !== 1) return null;
247
- const g = c[0], E = g.style.height || g.getAttribute("height"), R = H.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, A = E ? de(E, R) : null;
248
- if (A !== null)
249
- return Math.ceil(A);
250
- const F = He(
251
- g.getAttribute("class") || "",
252
- R
291
+ )?.querySelector(
292
+ ".sandbox-container > *"
293
+ );
294
+ if (!f) return null;
295
+ const E = f.style.height || f.getAttribute("height"), x = E ? K(E, a) : null;
296
+ if (x !== null)
297
+ return Math.ceil(x);
298
+ const L = Ne(
299
+ f.getAttribute("class") || "",
300
+ a
253
301
  );
254
- return F !== null ? Math.ceil(F) : null;
255
- }, J = () => {
256
- if (!H.current || !n.body) return;
257
- const f = n.body.getBoundingClientRect(), w = n.documentElement?.getBoundingClientRect(), c = f.height, g = w?.height || 0, E = Math.max(c, g), R = Se(), A = Math.max(
302
+ return L !== null ? Math.ceil(L) : null;
303
+ }, Q = () => {
304
+ if (!y.current || !r.body) return;
305
+ const a = r.body.getBoundingClientRect(), b = r.documentElement?.getBoundingClientRect(), u = a.height, H = b?.height || 0, f = Math.max(u, H), E = _e(), x = Math.max(
258
306
  200,
259
- R ?? Math.ceil(E)
307
+ E ?? Math.ceil(f)
260
308
  );
261
- we(A);
262
- }, j = () => {
309
+ Ce(x);
310
+ }, B = () => {
263
311
  requestAnimationFrame(() => {
264
- P || J();
312
+ _ || Q();
265
313
  });
266
314
  };
267
- V.current = j, J(), j(), Ee ? pe().then((f) => {
268
- P || (f(n), requestAnimationFrame(() => {
269
- P || (q(!0), j());
315
+ G.current = B, Q(), B(), Se ? be().then((a) => {
316
+ _ || (a(r), requestAnimationFrame(() => {
317
+ _ || (q(!0), B());
270
318
  }));
271
319
  }).catch(() => {
272
- P || (q(!0), j());
320
+ _ || (q(!0), B());
273
321
  }) : q(!0);
274
- const K = new ResizeObserver(() => J());
275
- return K.observe(n.body), C && K.observe(C), () => {
276
- P = !0, K.disconnect(), d && (n.removeEventListener("pointerdown", h, !0), n.removeEventListener("mousedown", N, !0), n.removeEventListener("touchstart", m, !0)), setTimeout(() => {
277
- b.unmount(), L.current = null, re.current = null, V.current = () => {
322
+ const ee = new ResizeObserver(() => Q());
323
+ return ee.observe(r.body), D && ee.observe(D), () => {
324
+ _ = !0, ee.disconnect(), g && (r.removeEventListener("pointerdown", p, !0), r.removeEventListener("mousedown", O, !0), r.removeEventListener("touchstart", v, !0)), setTimeout(() => {
325
+ me.unmount(), z.current = null, oe.current = null, G.current = () => {
278
326
  };
279
327
  }, 0);
280
328
  };
281
- }, []), y(() => {
282
- const o = () => {
283
- Ce(!!document.fullscreenElement);
329
+ }, []), C(() => {
330
+ const i = () => {
331
+ Re(!!document.fullscreenElement);
284
332
  };
285
- return document.addEventListener("fullscreenchange", o), () => document.removeEventListener("fullscreenchange", o);
333
+ return document.addEventListener("fullscreenchange", i), () => document.removeEventListener("fullscreenchange", i);
286
334
  }, []);
287
- const Ae = () => {
288
- const o = ne.current || H.current;
289
- if (o) {
335
+ const Me = () => {
336
+ const i = re.current || y.current;
337
+ if (i) {
290
338
  if (document.fullscreenElement) {
291
339
  document.exitFullscreen().catch(() => {
292
340
  });
293
341
  return;
294
342
  }
295
- o.requestFullscreen && o.requestFullscreen().catch(() => {
343
+ i.requestFullscreen && i.requestFullscreen().catch(() => {
296
344
  });
297
345
  }
298
346
  };
299
- y(() => {
300
- const o = L.current;
301
- o && (o.render(
302
- /* @__PURE__ */ v.jsx(
303
- Ie,
347
+ C(() => {
348
+ const i = z.current;
349
+ i && (i.render(
350
+ /* @__PURE__ */ w.jsx(
351
+ Pe,
304
352
  {
305
- html: $,
306
- loadingText: a,
307
- styleLoadingText: s,
308
- scriptLoadingText: u,
309
- fullScreenButtonText: x,
310
- hideFullScreen: te,
311
- resetToken: se,
312
- hasRootVhHeight: ue,
313
- mode: p,
314
- stretchRootHeight: ie
353
+ html: k,
354
+ loadingText: s,
355
+ styleLoadingText: o,
356
+ scriptLoadingText: l,
357
+ fullScreenButtonText: m,
358
+ hideFullScreen: S,
359
+ resetToken: ie,
360
+ hasRootVhHeight: he,
361
+ mode: h,
362
+ stretchRootHeight: ce
315
363
  }
316
364
  )
317
365
  ), I.current = window.requestAnimationFrame(() => {
318
- V.current?.(), I.current = null;
366
+ G.current?.(), I.current = null;
319
367
  }));
320
368
  }, [
321
- $,
322
- a,
369
+ k,
323
370
  s,
324
- u,
325
- x,
326
- se,
327
- p
371
+ o,
372
+ l,
373
+ m,
374
+ ie,
375
+ h
328
376
  ]);
329
- const ye = [
377
+ const Ie = [
330
378
  "w-full relative content-render-iframe-sandbox",
331
- G ? "h-full overflow-auto flex flex-col" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
379
+ X ? "h-full overflow-auto flex flex-col" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
332
380
  ].filter(Boolean).join(" ");
333
- return /* @__PURE__ */ v.jsxs(
381
+ return /* @__PURE__ */ w.jsxs(
334
382
  "div",
335
383
  {
336
- ref: ne,
337
- "data-root-vh": ue ? "true" : "false",
338
- className: ye,
339
- style: _ ? {
340
- height: _,
341
- minHeight: _
384
+ ref: re,
385
+ "data-root-vh": he ? "true" : "false",
386
+ className: Ie,
387
+ style: N ? {
388
+ height: N,
389
+ minHeight: N
342
390
  } : void 0,
343
391
  children: [
344
- !te && /* @__PURE__ */ v.jsx(
392
+ !S && /* @__PURE__ */ w.jsx(
345
393
  "button",
346
394
  {
347
395
  type: "button",
348
- onClick: Ae,
396
+ onClick: Me,
349
397
  className: "absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",
350
- children: xe ? "退出全屏" : x || "全屏浏览"
398
+ children: Ae ? "退出全屏" : m || "全屏浏览"
351
399
  }
352
400
  ),
353
- p === "blackboard" && t === "markdown" ? /* @__PURE__ */ v.jsx(
401
+ h === "blackboard" && t === "markdown" ? /* @__PURE__ */ w.jsx(
354
402
  "div",
355
403
  {
356
- onMouseDown: () => S("mousedown"),
357
- onPointerDown: () => S("pointerdown"),
358
- onTouchStart: () => S("touchstart"),
359
- children: /* @__PURE__ */ v.jsx(Ne, { content: e })
404
+ onMouseDown: () => A("mousedown"),
405
+ onPointerDown: () => A("pointerdown"),
406
+ onTouchStart: () => A("touchstart"),
407
+ children: /* @__PURE__ */ w.jsx(Oe, { content: e })
360
408
  }
361
- ) : /* @__PURE__ */ v.jsxs(v.Fragment, { children: [
409
+ ) : /* @__PURE__ */ w.jsxs(w.Fragment, { children: [
362
410
  null,
363
- /* @__PURE__ */ v.jsx(
411
+ /* @__PURE__ */ w.jsx(
364
412
  "iframe",
365
413
  {
366
- ref: H,
414
+ ref: y,
367
415
  sandbox: "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",
368
416
  allow: "fullscreen",
369
417
  allowFullScreen: !0,
370
- className: [r, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
418
+ className: [n, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
371
419
  style: {
372
- height: _ ?? "100%",
373
- minHeight: _,
420
+ height: N ?? "100%",
421
+ minHeight: N,
374
422
  margin: "auto",
375
423
  visibility: "visible"
376
424
  }
@@ -383,6 +431,6 @@ const Oe = /<img\b[^>]*>/i, De = 180, Be = 240, $e = /<img\b[^>]*\bsrc\s*=\s*["'
383
431
  );
384
432
  };
385
433
  export {
386
- Ke as default
434
+ it as default
387
435
  };
388
436
  //# sourceMappingURL=IframeSandbox.es.js.map