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.
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/_virtual/index.cjs3.js +1 -1
- package/dist/_virtual/index.cjs4.js +1 -1
- package/dist/_virtual/index.es3.js +4 -5
- package/dist/_virtual/index.es3.js.map +1 -1
- package/dist/_virtual/index.es4.js +5 -4
- package/dist/_virtual/index.es4.js.map +1 -1
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +13 -10
- package/dist/components/ContentRender/ContentRender.es.js +184 -160
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.cjs.js +5 -4
- package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.d.ts +1 -0
- package/dist/components/ContentRender/IframeSandbox.es.js +307 -210
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.cjs.js +3 -3
- package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.d.ts +4 -0
- package/dist/components/ContentRender/SandboxApp.es.js +87 -80
- package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
- package/dist/components/ContentRender/index.cjs.js +1 -1
- package/dist/components/ContentRender/index.es.js +5 -6
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.es.js +68 -64
- package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +3 -0
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js +21 -18
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
- package/dist/components/Slide/Player.cjs.js +1 -1
- package/dist/components/Slide/Player.cjs.js.map +1 -1
- package/dist/components/Slide/Player.d.ts +3 -2
- package/dist/components/Slide/Player.es.js +228 -170
- package/dist/components/Slide/Player.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs.js +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.d.ts +10 -0
- package/dist/components/Slide/Slide.es.js +422 -270
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/Slide.stories.d.ts +27 -1
- package/dist/components/Slide/index.d.ts +3 -3
- package/dist/components/Slide/types.d.ts +5 -6
- package/dist/components/Slide/useSlide.cjs.js +1 -1
- package/dist/components/Slide/useSlide.cjs.js.map +1 -1
- package/dist/components/Slide/useSlide.d.ts +4 -1
- package/dist/components/Slide/useSlide.es.js +125 -83
- package/dist/components/Slide/useSlide.es.js.map +1 -1
- package/dist/components/Slide/useWakePlayerFromIframe.cjs.js +2 -0
- package/dist/components/Slide/useWakePlayerFromIframe.cjs.js.map +1 -0
- package/dist/components/Slide/useWakePlayerFromIframe.d.ts +7 -0
- package/dist/components/Slide/useWakePlayerFromIframe.es.js +89 -0
- package/dist/components/Slide/useWakePlayerFromIframe.es.js.map +1 -0
- package/dist/components/Slide/utils/playerCustomActions.cjs.js +2 -0
- package/dist/components/Slide/utils/playerCustomActions.cjs.js.map +1 -0
- package/dist/components/Slide/utils/playerCustomActions.d.ts +3 -0
- package/dist/components/Slide/utils/playerCustomActions.es.js +7 -0
- package/dist/components/Slide/utils/playerCustomActions.es.js.map +1 -0
- package/dist/components/index.d.ts +4 -2
- package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +24 -22
- package/dist/lib/interaction-defaults.cjs.js +2 -0
- package/dist/lib/interaction-defaults.cjs.js.map +1 -0
- package/dist/lib/interaction-defaults.es.js +106 -0
- package/dist/lib/interaction-defaults.es.js.map +1 -0
- package/dist/lib/sandboxInteraction.cjs.js +2 -0
- package/dist/lib/sandboxInteraction.cjs.js.map +1 -0
- package/dist/lib/sandboxInteraction.d.ts +8 -0
- package/dist/lib/sandboxInteraction.es.js +12 -0
- package/dist/lib/sandboxInteraction.es.js.map +1 -0
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/renderer.cjs.js +1 -1
- package/dist/renderer.d.ts +5 -3
- package/dist/renderer.es.js +18 -16
- package/package.json +17 -2
- package/dist/components/Slide/interaction-defaults.cjs.js +0 -2
- package/dist/components/Slide/interaction-defaults.cjs.js.map +0 -1
- package/dist/components/Slide/interaction-defaults.es.js +0 -85
- package/dist/components/Slide/interaction-defaults.es.js.map +0 -1
- package/dist/lib/browserUserActivation.cjs.js +0 -2
- package/dist/lib/browserUserActivation.cjs.js.map +0 -1
- package/dist/lib/browserUserActivation.es.js +0 -13
- package/dist/lib/browserUserActivation.es.js.map +0 -1
- /package/dist/{components/Slide → lib}/interaction-defaults.d.ts +0 -0
|
@@ -1,123 +1,220 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import
|
|
3
|
-
import { createRoot as
|
|
4
|
-
import
|
|
5
|
-
import { splitContentSegments as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
let
|
|
9
|
-
const
|
|
10
|
-
(
|
|
11
|
-
)),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 (
|
|
35
|
+
if (e.includes("h-svh") || e.includes("min-h-svh"))
|
|
24
36
|
return "100svh";
|
|
25
|
-
if (
|
|
37
|
+
if (e.includes("h-lvh") || e.includes("min-h-lvh"))
|
|
26
38
|
return "100lvh";
|
|
27
|
-
const
|
|
28
|
-
(
|
|
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
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
45
|
-
}), [
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
}, [
|
|
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
|
|
55
|
-
|
|
162
|
+
const r = Date.now();
|
|
163
|
+
r - J.current < _e || (J.current = r, window.postMessage(
|
|
56
164
|
{
|
|
57
|
-
source:
|
|
58
|
-
type:
|
|
59
|
-
eventType:
|
|
165
|
+
source: Fe,
|
|
166
|
+
type: Ve,
|
|
167
|
+
eventType: o
|
|
60
168
|
},
|
|
61
169
|
window.location.origin
|
|
62
170
|
));
|
|
63
|
-
}, []),
|
|
64
|
-
|
|
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
|
-
|
|
176
|
+
y(
|
|
67
177
|
() => () => {
|
|
68
|
-
|
|
178
|
+
oe(), He();
|
|
69
179
|
},
|
|
70
180
|
[]
|
|
71
|
-
),
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
}, [
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
201
|
+
P.current = c;
|
|
106
202
|
return;
|
|
107
203
|
}
|
|
108
|
-
const
|
|
109
|
-
!(
|
|
110
|
-
}, [
|
|
111
|
-
const
|
|
112
|
-
if (!
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
115
|
-
|
|
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>`),
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
let
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
140
|
-
const
|
|
141
|
-
return Number.isNaN(
|
|
142
|
-
},
|
|
143
|
-
if (!
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
return
|
|
147
|
-
const
|
|
148
|
-
(
|
|
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 (!
|
|
151
|
-
const
|
|
152
|
-
if (!
|
|
153
|
-
const
|
|
154
|
-
return Number.isNaN(
|
|
155
|
-
},
|
|
156
|
-
if (!E.current || !
|
|
157
|
-
const
|
|
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
|
-
)?.
|
|
160
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
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
|
-
|
|
275
|
+
x ?? Math.ceil(f)
|
|
176
276
|
);
|
|
177
|
-
|
|
178
|
-
},
|
|
277
|
+
pe(H);
|
|
278
|
+
}, O = () => {
|
|
179
279
|
requestAnimationFrame(() => {
|
|
180
|
-
|
|
280
|
+
M || G();
|
|
181
281
|
});
|
|
182
282
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
189
|
-
}) :
|
|
190
|
-
const
|
|
191
|
-
return
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
}, []),
|
|
198
|
-
const
|
|
199
|
-
|
|
297
|
+
}, []), y(() => {
|
|
298
|
+
const o = () => {
|
|
299
|
+
ve(!!document.fullscreenElement);
|
|
200
300
|
};
|
|
201
|
-
return document.addEventListener("fullscreenchange",
|
|
301
|
+
return document.addEventListener("fullscreenchange", o), () => document.removeEventListener("fullscreenchange", o);
|
|
202
302
|
}, []);
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
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
|
-
|
|
311
|
+
o.requestFullscreen && o.requestFullscreen().catch(() => {
|
|
212
312
|
});
|
|
213
313
|
}
|
|
214
314
|
};
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
/* @__PURE__ */
|
|
219
|
-
|
|
315
|
+
y(() => {
|
|
316
|
+
const o = $.current;
|
|
317
|
+
o && (o.render(
|
|
318
|
+
/* @__PURE__ */ b.jsx(
|
|
319
|
+
Te,
|
|
220
320
|
{
|
|
221
321
|
html: k,
|
|
222
|
-
loadingText:
|
|
223
|
-
styleLoadingText:
|
|
224
|
-
scriptLoadingText:
|
|
225
|
-
fullScreenButtonText:
|
|
226
|
-
hideFullScreen:
|
|
227
|
-
resetToken:
|
|
228
|
-
hasRootVhHeight:
|
|
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(() =>
|
|
333
|
+
), R.current = window.requestAnimationFrame(() => {
|
|
334
|
+
j.current?.(), R.current = null;
|
|
335
|
+
}));
|
|
233
336
|
}, [
|
|
234
337
|
k,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
h
|
|
241
|
-
L
|
|
338
|
+
s,
|
|
339
|
+
i,
|
|
340
|
+
l,
|
|
341
|
+
m,
|
|
342
|
+
K,
|
|
343
|
+
h
|
|
242
344
|
]);
|
|
243
|
-
const
|
|
345
|
+
const Se = [
|
|
244
346
|
"w-full relative content-render-iframe-sandbox",
|
|
245
|
-
|
|
246
|
-
].filter(Boolean).join(" ")
|
|
247
|
-
return /* @__PURE__ */
|
|
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:
|
|
251
|
-
"data-root-vh":
|
|
252
|
-
className:
|
|
253
|
-
style:
|
|
254
|
-
height:
|
|
255
|
-
minHeight:
|
|
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
|
-
!
|
|
360
|
+
!C && /* @__PURE__ */ b.jsx(
|
|
259
361
|
"button",
|
|
260
362
|
{
|
|
261
363
|
type: "button",
|
|
262
|
-
onClick:
|
|
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:
|
|
366
|
+
children: we ? "退出全屏" : m || "全屏浏览"
|
|
265
367
|
}
|
|
266
368
|
),
|
|
267
|
-
h === "blackboard" &&
|
|
369
|
+
h === "blackboard" && e === "markdown" ? /* @__PURE__ */ b.jsx(
|
|
268
370
|
"div",
|
|
269
371
|
{
|
|
270
|
-
onMouseDown: () =>
|
|
271
|
-
onPointerDown: () =>
|
|
272
|
-
onTouchStart: () =>
|
|
273
|
-
children: /* @__PURE__ */
|
|
372
|
+
onMouseDown: () => S("mousedown"),
|
|
373
|
+
onPointerDown: () => S("pointerdown"),
|
|
374
|
+
onTouchStart: () => S("touchstart"),
|
|
375
|
+
children: /* @__PURE__ */ b.jsx(Ne, { content: t })
|
|
274
376
|
}
|
|
275
|
-
) : /* @__PURE__ */
|
|
276
|
-
|
|
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: [
|
|
386
|
+
className: [n, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
|
|
284
387
|
style: {
|
|
285
|
-
height:
|
|
286
|
-
minHeight:
|
|
388
|
+
height: T ?? "100%",
|
|
389
|
+
minHeight: T,
|
|
287
390
|
margin: "auto",
|
|
288
|
-
visibility:
|
|
391
|
+
visibility: "visible"
|
|
289
392
|
}
|
|
290
393
|
}
|
|
291
394
|
),
|
|
292
|
-
|
|
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
|
-
|
|
402
|
+
Ke as default
|
|
306
403
|
};
|
|
307
404
|
//# sourceMappingURL=IframeSandbox.es.js.map
|