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.
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/_virtual/index.cjs10.js +1 -1
- package/dist/_virtual/index.cjs11.js +1 -1
- package/dist/_virtual/index.cjs12.js +1 -1
- package/dist/_virtual/index.cjs9.js +1 -1
- package/dist/_virtual/index.es10.js +3 -2
- package/dist/_virtual/index.es10.js.map +1 -1
- package/dist/_virtual/index.es11.js +2 -3
- package/dist/_virtual/index.es11.js.map +1 -1
- package/dist/_virtual/index.es12.js +2 -2
- package/dist/_virtual/index.es9.js +3 -3
- package/dist/components/ContentRender/IframeSandbox.cjs.js +4 -4
- package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.es.js +303 -255
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.d.ts +3 -0
- package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
- package/dist/components/Slide/Slide.stories.d.ts +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/package.json +1 -1
|
@@ -1,203 +1,248 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import
|
|
3
|
-
import { createRoot as
|
|
4
|
-
import
|
|
5
|
-
import { splitContentSegments as
|
|
6
|
-
import
|
|
7
|
-
import { SANDBOX_INTERACTION_MESSAGE_TYPE as
|
|
8
|
-
let
|
|
9
|
-
const
|
|
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
|
-
)),
|
|
12
|
-
typeof window < "u" &&
|
|
13
|
-
const
|
|
14
|
-
const t = Array.from(e.matchAll(
|
|
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((
|
|
17
|
+
t.map((n) => n[1]?.trim()).filter((n) => !!n)
|
|
18
18
|
)
|
|
19
19
|
);
|
|
20
|
-
},
|
|
20
|
+
}, qe = (e) => {
|
|
21
21
|
if (!e)
|
|
22
22
|
return Promise.resolve();
|
|
23
|
-
const t =
|
|
23
|
+
const t = fe.get(e);
|
|
24
24
|
if (t)
|
|
25
25
|
return t;
|
|
26
|
-
const
|
|
26
|
+
const n = new Promise((s) => {
|
|
27
27
|
if (typeof window > "u") {
|
|
28
|
-
|
|
28
|
+
$.add(e), s();
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
(typeof
|
|
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
|
-
|
|
36
|
+
$.add(e), s();
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
},
|
|
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
|
|
46
|
-
},
|
|
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
|
|
50
|
-
return
|
|
51
|
-
},
|
|
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 =
|
|
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
|
|
61
|
-
(
|
|
60
|
+
const n = t.find(
|
|
61
|
+
(o) => /^h-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(o)
|
|
62
62
|
);
|
|
63
|
-
if (!
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
},
|
|
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)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
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
|
-
(
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
82
|
-
return
|
|
83
|
-
const
|
|
84
|
-
return
|
|
85
|
-
|
|
86
|
-
`class=${
|
|
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
|
-
),
|
|
147
|
+
), it = ({
|
|
90
148
|
content: e,
|
|
91
149
|
type: t,
|
|
92
|
-
className:
|
|
93
|
-
loadingText:
|
|
94
|
-
styleLoadingText:
|
|
95
|
-
scriptLoadingText:
|
|
96
|
-
fullScreenButtonText:
|
|
97
|
-
hideFullScreen:
|
|
98
|
-
mode:
|
|
99
|
-
replaceRootScreenHeightWithFull:
|
|
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
|
|
102
|
-
}), [
|
|
103
|
-
const
|
|
104
|
-
return (
|
|
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,
|
|
107
|
-
() =>
|
|
108
|
-
|
|
109
|
-
|
|
164
|
+
}, [e, h]), c = R.useMemo(
|
|
165
|
+
() => Ke(
|
|
166
|
+
P,
|
|
167
|
+
F
|
|
110
168
|
),
|
|
111
|
-
[
|
|
112
|
-
),
|
|
113
|
-
() =>
|
|
114
|
-
[
|
|
115
|
-
),
|
|
116
|
-
() =>
|
|
117
|
-
[
|
|
118
|
-
),
|
|
119
|
-
|
|
120
|
-
|
|
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
|
|
124
|
-
|
|
184
|
+
const r = Date.now();
|
|
185
|
+
r - se.current < je || (se.current = r, window.postMessage(
|
|
125
186
|
{
|
|
126
|
-
source:
|
|
127
|
-
type:
|
|
128
|
-
eventType:
|
|
187
|
+
source: Be,
|
|
188
|
+
type: De,
|
|
189
|
+
eventType: i
|
|
129
190
|
},
|
|
130
191
|
window.location.origin
|
|
131
192
|
));
|
|
132
|
-
}, []),
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
I.current !== null && (window.cancelAnimationFrame(I.current), I.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
|
-
|
|
198
|
+
C(
|
|
138
199
|
() => () => {
|
|
139
|
-
|
|
200
|
+
ue(), Te();
|
|
140
201
|
},
|
|
141
202
|
[]
|
|
142
|
-
),
|
|
143
|
-
|
|
144
|
-
}, [
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
),
|
|
150
|
-
(
|
|
151
|
-
),
|
|
152
|
-
if (
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
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 (!
|
|
160
|
-
|
|
220
|
+
if (!O) {
|
|
221
|
+
W(c);
|
|
161
222
|
return;
|
|
162
223
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
}, [
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
|
193
|
-
!(
|
|
194
|
-
}, [
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
197
|
-
const
|
|
198
|
-
if (!
|
|
199
|
-
|
|
200
|
-
<html${
|
|
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>`),
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
if (!
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
let
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
if (!
|
|
224
|
-
const
|
|
225
|
-
return Number.isNaN(
|
|
226
|
-
},
|
|
227
|
-
if (!
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
return
|
|
231
|
-
const
|
|
232
|
-
(
|
|
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
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (
|
|
241
|
-
|
|
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
|
-
)?.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
if (
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
249
|
-
return Math.ceil(
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
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
|
|
255
|
-
},
|
|
256
|
-
if (!
|
|
257
|
-
const
|
|
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
|
-
|
|
307
|
+
E ?? Math.ceil(f)
|
|
260
308
|
);
|
|
261
|
-
|
|
262
|
-
},
|
|
309
|
+
Ce(x);
|
|
310
|
+
}, B = () => {
|
|
263
311
|
requestAnimationFrame(() => {
|
|
264
|
-
|
|
312
|
+
_ || Q();
|
|
265
313
|
});
|
|
266
314
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
315
|
+
G.current = B, Q(), B(), Se ? be().then((a) => {
|
|
316
|
+
_ || (a(r), requestAnimationFrame(() => {
|
|
317
|
+
_ || (q(!0), B());
|
|
270
318
|
}));
|
|
271
319
|
}).catch(() => {
|
|
272
|
-
|
|
320
|
+
_ || (q(!0), B());
|
|
273
321
|
}) : q(!0);
|
|
274
|
-
const
|
|
275
|
-
return
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
}, []),
|
|
282
|
-
const
|
|
283
|
-
|
|
329
|
+
}, []), C(() => {
|
|
330
|
+
const i = () => {
|
|
331
|
+
Re(!!document.fullscreenElement);
|
|
284
332
|
};
|
|
285
|
-
return document.addEventListener("fullscreenchange",
|
|
333
|
+
return document.addEventListener("fullscreenchange", i), () => document.removeEventListener("fullscreenchange", i);
|
|
286
334
|
}, []);
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
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
|
-
|
|
343
|
+
i.requestFullscreen && i.requestFullscreen().catch(() => {
|
|
296
344
|
});
|
|
297
345
|
}
|
|
298
346
|
};
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
/* @__PURE__ */
|
|
303
|
-
|
|
347
|
+
C(() => {
|
|
348
|
+
const i = z.current;
|
|
349
|
+
i && (i.render(
|
|
350
|
+
/* @__PURE__ */ w.jsx(
|
|
351
|
+
Pe,
|
|
304
352
|
{
|
|
305
|
-
html:
|
|
306
|
-
loadingText:
|
|
307
|
-
styleLoadingText:
|
|
308
|
-
scriptLoadingText:
|
|
309
|
-
fullScreenButtonText:
|
|
310
|
-
hideFullScreen:
|
|
311
|
-
resetToken:
|
|
312
|
-
hasRootVhHeight:
|
|
313
|
-
mode:
|
|
314
|
-
stretchRootHeight:
|
|
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
|
-
|
|
366
|
+
G.current?.(), I.current = null;
|
|
319
367
|
}));
|
|
320
368
|
}, [
|
|
321
|
-
|
|
322
|
-
a,
|
|
369
|
+
k,
|
|
323
370
|
s,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
371
|
+
o,
|
|
372
|
+
l,
|
|
373
|
+
m,
|
|
374
|
+
ie,
|
|
375
|
+
h
|
|
328
376
|
]);
|
|
329
|
-
const
|
|
377
|
+
const Ie = [
|
|
330
378
|
"w-full relative content-render-iframe-sandbox",
|
|
331
|
-
|
|
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__ */
|
|
381
|
+
return /* @__PURE__ */ w.jsxs(
|
|
334
382
|
"div",
|
|
335
383
|
{
|
|
336
|
-
ref:
|
|
337
|
-
"data-root-vh":
|
|
338
|
-
className:
|
|
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
|
-
!
|
|
392
|
+
!S && /* @__PURE__ */ w.jsx(
|
|
345
393
|
"button",
|
|
346
394
|
{
|
|
347
395
|
type: "button",
|
|
348
|
-
onClick:
|
|
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:
|
|
398
|
+
children: Ae ? "退出全屏" : m || "全屏浏览"
|
|
351
399
|
}
|
|
352
400
|
),
|
|
353
|
-
|
|
401
|
+
h === "blackboard" && t === "markdown" ? /* @__PURE__ */ w.jsx(
|
|
354
402
|
"div",
|
|
355
403
|
{
|
|
356
|
-
onMouseDown: () =>
|
|
357
|
-
onPointerDown: () =>
|
|
358
|
-
onTouchStart: () =>
|
|
359
|
-
children: /* @__PURE__ */
|
|
404
|
+
onMouseDown: () => A("mousedown"),
|
|
405
|
+
onPointerDown: () => A("pointerdown"),
|
|
406
|
+
onTouchStart: () => A("touchstart"),
|
|
407
|
+
children: /* @__PURE__ */ w.jsx(Oe, { content: e })
|
|
360
408
|
}
|
|
361
|
-
) : /* @__PURE__ */
|
|
409
|
+
) : /* @__PURE__ */ w.jsxs(w.Fragment, { children: [
|
|
362
410
|
null,
|
|
363
|
-
/* @__PURE__ */
|
|
411
|
+
/* @__PURE__ */ w.jsx(
|
|
364
412
|
"iframe",
|
|
365
413
|
{
|
|
366
|
-
ref:
|
|
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: [
|
|
418
|
+
className: [n, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
|
|
371
419
|
style: {
|
|
372
|
-
height:
|
|
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
|
-
|
|
434
|
+
it as default
|
|
387
435
|
};
|
|
388
436
|
//# sourceMappingURL=IframeSandbox.es.js.map
|