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

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 (122) 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-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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. package/dist/_virtual/index.cjs10.js +1 -1
  36. package/dist/_virtual/index.cjs11.js +1 -1
  37. package/dist/_virtual/index.cjs12.js +1 -1
  38. package/dist/_virtual/index.cjs3.js +1 -1
  39. package/dist/_virtual/index.cjs4.js +1 -1
  40. package/dist/_virtual/index.cjs9.js +1 -1
  41. package/dist/_virtual/index.es10.js +2 -3
  42. package/dist/_virtual/index.es10.js.map +1 -1
  43. package/dist/_virtual/index.es11.js +3 -2
  44. package/dist/_virtual/index.es11.js.map +1 -1
  45. package/dist/_virtual/index.es12.js +2 -2
  46. package/dist/_virtual/index.es3.js +4 -5
  47. package/dist/_virtual/index.es3.js.map +1 -1
  48. package/dist/_virtual/index.es4.js +5 -4
  49. package/dist/_virtual/index.es4.js.map +1 -1
  50. package/dist/_virtual/index.es9.js +3 -3
  51. package/dist/assets/markdown-flow-ui.css +1 -1
  52. package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
  53. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  54. package/dist/components/ContentRender/ContentRender.d.ts +13 -10
  55. package/dist/components/ContentRender/ContentRender.es.js +175 -158
  56. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  57. package/dist/components/ContentRender/IframeSandbox.cjs.js +4 -4
  58. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  59. package/dist/components/ContentRender/IframeSandbox.d.ts +1 -0
  60. package/dist/components/ContentRender/IframeSandbox.es.js +291 -210
  61. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  62. package/dist/components/ContentRender/SandboxApp.cjs.js +3 -3
  63. package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
  64. package/dist/components/ContentRender/SandboxApp.d.ts +1 -0
  65. package/dist/components/ContentRender/SandboxApp.es.js +144 -111
  66. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  67. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
  68. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
  69. package/dist/components/ContentRender/plugins/CustomVariable.es.js +68 -64
  70. package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
  71. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
  72. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
  73. package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +3 -0
  74. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +19 -16
  75. package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
  76. package/dist/components/Slide/Player.cjs.js +1 -1
  77. package/dist/components/Slide/Player.cjs.js.map +1 -1
  78. package/dist/components/Slide/Player.d.ts +1 -0
  79. package/dist/components/Slide/Player.es.js +208 -168
  80. package/dist/components/Slide/Player.es.js.map +1 -1
  81. package/dist/components/Slide/Slide.cjs.js +1 -1
  82. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  83. package/dist/components/Slide/Slide.d.ts +13 -0
  84. package/dist/components/Slide/Slide.es.js +374 -255
  85. package/dist/components/Slide/Slide.es.js.map +1 -1
  86. package/dist/components/Slide/Slide.stories.d.ts +21 -1
  87. package/dist/components/Slide/index.d.ts +3 -3
  88. package/dist/components/Slide/types.d.ts +6 -6
  89. package/dist/components/Slide/useSlide.cjs.js +1 -1
  90. package/dist/components/Slide/useSlide.cjs.js.map +1 -1
  91. package/dist/components/Slide/useSlide.d.ts +4 -1
  92. package/dist/components/Slide/useSlide.es.js +115 -81
  93. package/dist/components/Slide/useSlide.es.js.map +1 -1
  94. package/dist/components/Slide/useWakePlayerFromIframe.cjs.js +2 -0
  95. package/dist/components/Slide/useWakePlayerFromIframe.cjs.js.map +1 -0
  96. package/dist/components/Slide/useWakePlayerFromIframe.d.ts +7 -0
  97. package/dist/components/Slide/useWakePlayerFromIframe.es.js +89 -0
  98. package/dist/components/Slide/useWakePlayerFromIframe.es.js.map +1 -0
  99. package/dist/components/index.d.ts +4 -2
  100. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  101. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  102. package/dist/index.cjs.js +1 -1
  103. package/dist/index.es.js +24 -22
  104. package/dist/lib/interaction-defaults.cjs.js +2 -0
  105. package/dist/lib/interaction-defaults.cjs.js.map +1 -0
  106. package/dist/lib/interaction-defaults.es.js +106 -0
  107. package/dist/lib/interaction-defaults.es.js.map +1 -0
  108. package/dist/lib/sandboxInteraction.cjs.js +2 -0
  109. package/dist/lib/sandboxInteraction.cjs.js.map +1 -0
  110. package/dist/lib/sandboxInteraction.d.ts +8 -0
  111. package/dist/lib/sandboxInteraction.es.js +12 -0
  112. package/dist/lib/sandboxInteraction.es.js.map +1 -0
  113. package/dist/markdown-flow-ui-lib.css +1 -1
  114. package/dist/renderer.cjs.js +1 -1
  115. package/dist/renderer.d.ts +5 -3
  116. package/dist/renderer.es.js +18 -16
  117. package/package.json +17 -2
  118. package/dist/components/Slide/interaction-defaults.cjs.js +0 -2
  119. package/dist/components/Slide/interaction-defaults.cjs.js.map +0 -1
  120. package/dist/components/Slide/interaction-defaults.es.js +0 -85
  121. package/dist/components/Slide/interaction-defaults.es.js.map +0 -1
  122. /package/dist/{components/Slide → lib}/interaction-defaults.d.ts +0 -0
@@ -1,119 +1,203 @@
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 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(
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));
15
+ return Array.from(
16
+ new Set(
17
+ t.map((r) => r[1]?.trim()).filter((r) => !!r)
18
+ )
19
+ );
20
+ }, Fe = (e) => {
21
+ if (!e)
22
+ return Promise.resolve();
23
+ const t = he.get(e);
24
+ if (t)
25
+ return t;
26
+ const r = new Promise((a) => {
27
+ if (typeof window > "u") {
28
+ z.add(e), a();
29
+ return;
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(() => {
35
+ }) : Promise.resolve()).finally(() => {
36
+ z.add(e), a();
37
+ });
38
+ };
39
+ s.onload = () => {
40
+ u();
41
+ }, s.onerror = () => {
42
+ z.add(e), a();
43
+ }, s.src = e, s.complete && s.naturalWidth > 0 && u();
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) => {
47
+ const t = e.trim().toLowerCase();
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) => {
52
+ if (!e.trim()) return null;
53
+ const t = ee(e);
54
+ if (t.includes("h-screen") || t.includes("h-dvh"))
22
55
  return "100dvh";
23
- if (n.includes("h-svh"))
56
+ if (t.includes("h-svh"))
24
57
  return "100svh";
25
- if (n.includes("h-lvh"))
58
+ if (t.includes("h-lvh"))
26
59
  return "100lvh";
27
- const m = n.find(
28
- (M) => /^h-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(M)
60
+ const r = t.find(
61
+ (s) => /^h-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(s)
29
62
  );
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"
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) => {
67
+ 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(
78
+ /^(\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]}`
87
+ )}>`;
88
+ }
89
+ ), Ke = ({
90
+ content: e,
91
+ 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
43
100
  }) => {
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(`
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(`
50
105
  `)) || "";
51
- }, [s, h]), [k, K] = A(r), Q = d(r), z = d(r), R = d(null), y = ve((t) => {
106
+ }, [e, p]), i = k.useMemo(
107
+ () => qe(
108
+ B,
109
+ D
110
+ ),
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) => {
52
121
  if (typeof window > "u")
53
122
  return;
54
- const e = Date.now();
55
- e - Z.current < Me || (Z.current = e, window.postMessage(
123
+ const n = Date.now();
124
+ n - oe.current < Be || (oe.current = n, window.postMessage(
56
125
  {
57
- source: Te,
58
- type: Ae,
59
- eventType: t
126
+ source: ke,
127
+ type: Pe,
128
+ eventType: o
60
129
  },
61
130
  window.location.origin
62
131
  ));
63
- }, []), $ = () => {
64
- R.current !== null && (window.clearTimeout(R.current), R.current = null);
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);
65
136
  };
66
- C(
137
+ y(
67
138
  () => () => {
68
- $();
139
+ le(), Re();
69
140
  },
70
141
  []
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);
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);
156
+ });
77
157
  return;
78
158
  }
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;
159
+ if (!N) {
160
+ U(i);
161
+ return;
162
+ }
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;
92
176
  }
93
- const S = i.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(
177
+ const m = d.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(
94
178
  /\bheight\s*:\s*([^;]+)/i
95
179
  )?.[1];
96
- if (S) {
97
- const f = ie(S);
98
- if (f) return f;
180
+ if (m) {
181
+ const b = fe(m);
182
+ if (b) return b;
99
183
  }
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(() => {
104
- if (h !== "blackboard") {
105
- F.current = r;
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;
106
190
  return;
107
191
  }
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>
116
- <html${h === "blackboard" ? ' style="height: 100%;"' : ""}>
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%;"' : ""}>
117
201
  <head>
118
202
  <meta charset="utf-8" />
119
203
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -126,182 +210,179 @@ const He = /<img\b[^>]*>/i, Se = 180, Te = "markdown-flow-ui:sandbox", Ae = "int
126
210
  <body>
127
211
  <div id="root"></div>
128
212
  </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)
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)
149
233
  );
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(
234
+ 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(
158
242
  ".sandbox-wrapper"
159
243
  )?.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
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
169
253
  );
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(
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(
174
258
  200,
175
- v ?? Math.ceil(w)
259
+ R ?? Math.ceil(E)
176
260
  );
177
- de(x);
178
- }, N = () => {
261
+ we(A);
262
+ }, j = () => {
179
263
  requestAnimationFrame(() => {
180
- T || P();
264
+ P || J();
181
265
  });
182
266
  };
183
- D.current = N, P(), N(), ne ? ce().then((c) => {
184
- T || (c(e), requestAnimationFrame(() => {
185
- T || (O(!0), N());
267
+ V.current = j, J(), j(), Ee ? pe().then((f) => {
268
+ P || (f(n), requestAnimationFrame(() => {
269
+ P || (q(!0), j());
186
270
  }));
187
271
  }).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 = () => {
272
+ P || (q(!0), j());
273
+ }) : 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 = () => {
194
278
  };
195
279
  }, 0);
196
280
  };
197
- }, []), C(() => {
198
- const t = () => {
199
- fe(!!document.fullscreenElement);
281
+ }, []), y(() => {
282
+ const o = () => {
283
+ Ce(!!document.fullscreenElement);
200
284
  };
201
- return document.addEventListener("fullscreenchange", t), () => document.removeEventListener("fullscreenchange", t);
285
+ return document.addEventListener("fullscreenchange", o), () => document.removeEventListener("fullscreenchange", o);
202
286
  }, []);
203
- const be = () => {
204
- const t = X.current || E.current;
205
- if (t) {
287
+ const Ae = () => {
288
+ const o = ne.current || H.current;
289
+ if (o) {
206
290
  if (document.fullscreenElement) {
207
291
  document.exitFullscreen().catch(() => {
208
292
  });
209
293
  return;
210
294
  }
211
- t.requestFullscreen && t.requestFullscreen().catch(() => {
295
+ o.requestFullscreen && o.requestFullscreen().catch(() => {
212
296
  });
213
297
  }
214
298
  };
215
- C(() => {
216
- const t = _.current;
217
- !t || !L || (t.render(
218
- /* @__PURE__ */ u.jsx(
219
- Ee,
299
+ y(() => {
300
+ const o = L.current;
301
+ o && (o.render(
302
+ /* @__PURE__ */ v.jsx(
303
+ Ie,
220
304
  {
221
- 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
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
230
315
  }
231
316
  )
232
- ), requestAnimationFrame(() => D.current?.()));
317
+ ), I.current = window.requestAnimationFrame(() => {
318
+ V.current?.(), I.current = null;
319
+ }));
233
320
  }, [
234
- k,
235
- p,
236
- M,
237
- U,
238
- j,
239
- J,
240
- h,
241
- L
321
+ $,
322
+ a,
323
+ s,
324
+ u,
325
+ x,
326
+ se,
327
+ p
242
328
  ]);
243
- const pe = [
329
+ const ye = [
244
330
  "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(
331
+ G ? "h-full overflow-auto flex flex-col" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
332
+ ].filter(Boolean).join(" ");
333
+ return /* @__PURE__ */ v.jsxs(
248
334
  "div",
249
335
  {
250
- ref: X,
251
- "data-root-vh": te ? "true" : "false",
252
- className: pe,
253
- style: H ? {
254
- height: H,
255
- minHeight: H
336
+ ref: ne,
337
+ "data-root-vh": ue ? "true" : "false",
338
+ className: ye,
339
+ style: _ ? {
340
+ height: _,
341
+ minHeight: _
256
342
  } : void 0,
257
343
  children: [
258
- !W && /* @__PURE__ */ u.jsx(
344
+ !te && /* @__PURE__ */ v.jsx(
259
345
  "button",
260
346
  {
261
347
  type: "button",
262
- onClick: be,
348
+ onClick: Ae,
263
349
  className: "absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",
264
- children: me ? "退出全屏" : j || "全屏浏览"
350
+ children: xe ? "退出全屏" : x || "全屏浏览"
265
351
  }
266
352
  ),
267
- h === "blackboard" && n === "markdown" ? /* @__PURE__ */ u.jsx(
353
+ p === "blackboard" && t === "markdown" ? /* @__PURE__ */ v.jsx(
268
354
  "div",
269
355
  {
270
- onMouseDown: () => y("mousedown"),
271
- onPointerDown: () => y("pointerdown"),
272
- onTouchStart: () => y("touchstart"),
273
- children: /* @__PURE__ */ u.jsx(Ce, { content: s })
356
+ onMouseDown: () => S("mousedown"),
357
+ onPointerDown: () => S("pointerdown"),
358
+ onTouchStart: () => S("touchstart"),
359
+ children: /* @__PURE__ */ v.jsx(Ne, { content: e })
274
360
  }
275
- ) : /* @__PURE__ */ u.jsxs(u.Fragment, { children: [
276
- /* @__PURE__ */ u.jsx(
361
+ ) : /* @__PURE__ */ v.jsxs(v.Fragment, { children: [
362
+ null,
363
+ /* @__PURE__ */ v.jsx(
277
364
  "iframe",
278
365
  {
279
- ref: E,
366
+ ref: H,
280
367
  sandbox: "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",
281
368
  allow: "fullscreen",
282
369
  allowFullScreen: !0,
283
- className: [m, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
370
+ className: [r, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
284
371
  style: {
285
- height: H ?? "100%",
286
- minHeight: H,
372
+ height: _ ?? "100%",
373
+ minHeight: _,
287
374
  margin: "auto",
288
- visibility: re ? "hidden" : "visible"
375
+ visibility: "visible"
289
376
  }
290
377
  }
291
378
  ),
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
379
+ null
299
380
  ] })
300
381
  ]
301
382
  }
302
383
  );
303
384
  };
304
385
  export {
305
- Oe as default
386
+ Ke as default
306
387
  };
307
388
  //# sourceMappingURL=IframeSandbox.es.js.map