markdown-flow-ui 0.1.100-beta.4 → 0.1.100-beta.40

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