markdown-flow-ui 0.1.83-beta.12 → 0.1.83-beta.13

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 (25) 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.js +1 -1
  2. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js +1 -1
  3. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.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.js +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/chunk-S3R3BYOJ.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-TZMSLE5B.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/ganttDiagram-LVOFAZNH.js +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/sequenceDiagram-WL72ISMW.js +1 -1
  9. 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.js +1 -1
  10. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.js +1 -1
  11. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.js +1 -1
  12. package/dist/_virtual/index10.js +2 -2
  13. package/dist/_virtual/index11.js +3 -3
  14. package/dist/_virtual/index12.js +2 -2
  15. package/dist/_virtual/index5.js +2 -5
  16. package/dist/_virtual/index5.js.map +1 -1
  17. package/dist/_virtual/index6.js +4 -4
  18. package/dist/_virtual/index7.js +5 -2
  19. package/dist/_virtual/index7.js.map +1 -1
  20. package/dist/_virtual/index8.js +3 -3
  21. package/dist/components/ContentRender/IframeSandbox.js +59 -69
  22. package/dist/components/ContentRender/IframeSandbox.js.map +1 -1
  23. package/dist/components/ContentRender/utils/split-content.js +43 -45
  24. package/dist/components/ContentRender/utils/split-content.js.map +1 -1
  25. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { __exports as c } from "../../../../../../../../../../_virtual/index10.js";
1
+ import { __exports as c } from "../../../../../../../../../../_virtual/index12.js";
2
2
  import { __require as v } from "./constants.js";
3
3
  var m;
4
4
  function g() {
@@ -1,4 +1,4 @@
1
- import { __module as s } from "../../../../../../../../_virtual/index7.js";
1
+ import { __module as s } from "../../../../../../../../_virtual/index5.js";
2
2
  /*!
3
3
  Copyright (c) 2018 Jed Watson.
4
4
  Licensed under the MIT License (MIT), see
@@ -2,7 +2,7 @@ import { stringify as w } from "../../../../comma-separated-tokens@2.0.3/node_mo
2
2
  import { ok as u } from "../../../../devlop@1.1.0/node_modules/devlop/lib/default.js";
3
3
  import { svg as m, html as C } from "../../../../property-information@7.1.0/node_modules/property-information/index.js";
4
4
  import { stringify as N } from "../../../../space-separated-tokens@2.0.2/node_modules/space-separated-tokens/index.js";
5
- import S from "../../../../../../../../../_virtual/index5.js";
5
+ import S from "../../../../../../../../../_virtual/index6.js";
6
6
  import { whitespace as j } from "../../../../hast-util-whitespace@3.0.0/node_modules/hast-util-whitespace/lib/index.js";
7
7
  import { name as x } from "../../../../estree-util-is-identifier-name@3.0.0/node_modules/estree-util-is-identifier-name/lib/index.js";
8
8
  import { VFileMessage as h } from "../../../../vfile-message@4.0.3/node_modules/vfile-message/lib/index.js";
@@ -4,7 +4,7 @@ import { setAccDescription as Be, getAccDescription as Ie, getAccTitle as Me, se
4
4
  import { __name as g, log as fe } from "./chunk-AGHRB4JF.js";
5
5
  import "../../../../../../d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/index.js";
6
6
  import "../../../../../../d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js";
7
- import { d as je } from "../../../../../../../../../../../_virtual/index8.js";
7
+ import { d as je } from "../../../../../../../../../../../_virtual/index11.js";
8
8
  import jt from "../../../../../../d3-selection@3.0.0/node_modules/d3-selection/src/select.js";
9
9
  var Ft = (function() {
10
10
  var e = /* @__PURE__ */ g(function(_t, x, m, v) {
@@ -1,6 +1,6 @@
1
1
  import { common_default as b, assignWithDepth_default as E, directiveRegex as $, sanitizeDirective as X, detectType as Y } from "./chunk-ABZYJK2D.js";
2
2
  import { __name as s, log as g } from "./chunk-AGHRB4JF.js";
3
- import { d as G } from "../../../../../../../../../../../_virtual/index8.js";
3
+ import { d as G } from "../../../../../../../../../../../_virtual/index11.js";
4
4
  import "../../../../../../d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/index.js";
5
5
  import "../../../../../../d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js";
6
6
  import w from "../../../../../../lodash-es@4.17.21/node_modules/lodash-es/memoize.js";
@@ -1,6 +1,6 @@
1
1
  import { lineBreakRegex as o } from "./chunk-ABZYJK2D.js";
2
2
  import { __name as n } from "./chunk-AGHRB4JF.js";
3
- import { d as l } from "../../../../../../../../../../../_virtual/index8.js";
3
+ import { d as l } from "../../../../../../../../../../../_virtual/index11.js";
4
4
  var x = /* @__PURE__ */ n((s, t) => {
5
5
  const r = s.append("rect");
6
6
  if (r.attr("x", t.x), r.attr("y", t.y), r.attr("fill", t.fill), r.attr("stroke", t.stroke), r.attr("width", t.width), r.attr("height", t.height), t.name && r.attr("name", t.name), t.rx && r.attr("rx", t.rx), t.ry && r.attr("ry", t.ry), t.attrs !== void 0)
@@ -1,7 +1,7 @@
1
1
  import { utils_default as ie } from "./chunk-S3R3BYOJ.js";
2
2
  import { getAccDescription as se, setAccDescription as ne, getDiagramTitle as ae, setDiagramTitle as oe, getAccTitle as ce, setAccTitle as le, getConfig2 as K, configureSvgSize as ue, common_default as de, clear as fe } from "./chunk-ABZYJK2D.js";
3
3
  import { __name as c, log as mt } from "./chunk-AGHRB4JF.js";
4
- import { d as he } from "../../../../../../../../../../../_virtual/index8.js";
4
+ import { d as he } from "../../../../../../../../../../../_virtual/index11.js";
5
5
  import L from "../../../../../../../../../../../_virtual/dayjs.min.js";
6
6
  import me from "../../../../../../../../../../../_virtual/isoWeek.js";
7
7
  import ke from "../../../../../../../../../../../_virtual/customParseFormat.js";
@@ -6,7 +6,7 @@ import { setConfig2 as ke, getConfig2 as st, configureSvgSize as Pe, assignWithD
6
6
  import { __name as f, log as Q } from "./chunk-AGHRB4JF.js";
7
7
  import "../../../../../../d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/index.js";
8
8
  import "../../../../../../d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js";
9
- import { d as ne } from "../../../../../../../../../../../_virtual/index8.js";
9
+ import { d as ne } from "../../../../../../../../../../../_virtual/index11.js";
10
10
  import Mt from "../../../../../../d3-selection@3.0.0/node_modules/d3-selection/src/select.js";
11
11
  var Ut = (function() {
12
12
  var e = /* @__PURE__ */ f(function(pt, v, A, L) {
@@ -1,6 +1,6 @@
1
1
  import s from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/typeof.js";
2
2
  import { version as c, isValidElement as l } from "react";
3
- import { r as n } from "../../../../../../../../../_virtual/index11.js";
3
+ import { r as n } from "../../../../../../../../../_virtual/index8.js";
4
4
  import m from "./hooks/useMemo.js";
5
5
  import v from "./React/isFragment.js";
6
6
  var R = Number(c.split(".")[0]), y = function(r, t) {
@@ -1,4 +1,4 @@
1
- import { __module as e } from "../../../../../../../../_virtual/index12.js";
1
+ import { __module as e } from "../../../../../../../../_virtual/index10.js";
2
2
  import { __require as o } from "./cjs/react-is.production.min.js";
3
3
  import { __require as t } from "./cjs/react-is.development.js";
4
4
  var r;
@@ -1,5 +1,5 @@
1
1
  import { bail as P } from "../../../../bail@2.0.2/node_modules/bail/index.js";
2
- import y from "../../../../../../../../../_virtual/index6.js";
2
+ import y from "../../../../../../../../../_virtual/index7.js";
3
3
  import z from "../../../../is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js";
4
4
  import { CallableInstance as C } from "./callable-instance.js";
5
5
  import { trough as A } from "../../../../trough@2.2.0/node_modules/trough/lib/index.js";
@@ -1,5 +1,5 @@
1
- var r = {};
1
+ var e = { exports: {} };
2
2
  export {
3
- r as __exports
3
+ e as __module
4
4
  };
5
5
  //# sourceMappingURL=index10.js.map
@@ -1,6 +1,6 @@
1
- import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.js";
2
- var a = r();
1
+ import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.js";
2
+ var i = r();
3
3
  export {
4
- a as r
4
+ i as d
5
5
  };
6
6
  //# sourceMappingURL=index11.js.map
@@ -1,5 +1,5 @@
1
- var e = { exports: {} };
1
+ var r = {};
2
2
  export {
3
- e as __module
3
+ r as __exports
4
4
  };
5
5
  //# sourceMappingURL=index12.js.map
@@ -1,8 +1,5 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
- import { __require as o } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.js";
3
- var t = o();
4
- const a = /* @__PURE__ */ r(t);
1
+ var s = { exports: {} };
5
2
  export {
6
- a as default
3
+ s as __module
7
4
  };
8
5
  //# sourceMappingURL=index5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,7 +1,7 @@
1
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
2
- import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js";
3
- var t = r();
4
- const a = /* @__PURE__ */ e(t);
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
+ import { __require as o } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.js";
3
+ var t = o();
4
+ const a = /* @__PURE__ */ r(t);
5
5
  export {
6
6
  a as default
7
7
  };
@@ -1,5 +1,8 @@
1
- var s = { exports: {} };
1
+ import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
2
+ import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js";
3
+ var t = r();
4
+ const a = /* @__PURE__ */ e(t);
2
5
  export {
3
- s as __module
6
+ a as default
4
7
  };
5
8
  //# sourceMappingURL=index7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,6 +1,6 @@
1
- import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.js";
2
- var i = r();
1
+ import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.js";
2
+ var a = r();
3
3
  export {
4
- i as d
4
+ a as r
5
5
  };
6
6
  //# sourceMappingURL=index8.js.map
@@ -1,35 +1,35 @@
1
1
  import { j as l } from "../../_virtual/jsx-runtime.js";
2
- import _, { useRef as c, useState as R, useEffect as m } from "react";
3
- import { createRoot as P } from "react-dom/client";
4
- import W from "./SandboxApp.js";
5
- import { splitContentSegments as Y } from "./utils/split-content.js";
6
- import $ from "./ContentRender.js";
7
- const X = ({
2
+ import D, { useRef as c, useState as p, useEffect as a } from "react";
3
+ import { createRoot as _ } from "react-dom/client";
4
+ import P from "./SandboxApp.js";
5
+ import { splitContentSegments as W } from "./utils/split-content.js";
6
+ import Y from "./ContentRender.js";
7
+ const V = ({
8
8
  content: u,
9
- type: F,
10
- className: G,
11
- loadingText: y,
12
- styleLoadingText: C,
13
- scriptLoadingText: H,
14
- fullScreenButtonText: d,
15
- hideFullScreen: w = !1,
9
+ type: j,
10
+ className: $,
11
+ loadingText: v,
12
+ styleLoadingText: x,
13
+ scriptLoadingText: R,
14
+ fullScreenButtonText: m,
15
+ hideFullScreen: y = !1,
16
16
  mode: n = "content"
17
17
  }) => {
18
- const k = c(null), a = c(null), h = c(null), g = c(null), b = c(() => {
19
- }), [M, N] = R(480), [E, q] = R(0), [z, I] = R(!1), p = c(""), o = _.useMemo(() => {
20
- const t = Y(u).filter((s) => s.type === "sandbox");
18
+ const C = c(null), i = c(null), f = c(null), w = c(null), d = c(() => {
19
+ }), [k, F] = p(480), [E, H] = p(0), [M, N] = p(!1), h = c(""), o = D.useMemo(() => {
20
+ const t = W(u).filter((s) => s.type === "sandbox");
21
21
  return (n === "blackboard" ? t[t.length - 1]?.value || "" : t.map((s) => s.value).join(`
22
22
  `)) || "";
23
23
  }, [u, n]);
24
- m(() => {
24
+ a(() => {
25
25
  if (n !== "blackboard") {
26
- p.current = o;
26
+ h.current = o;
27
27
  return;
28
28
  }
29
- const e = p.current;
30
- !(e && o.startsWith(e)) && e && q((r) => r + 1), p.current = o;
31
- }, [o, n]), m(() => {
32
- const e = a.current;
29
+ const e = h.current;
30
+ !(e && o.startsWith(e)) && e && H((r) => r + 1), h.current = o;
31
+ }, [o, n]), a(() => {
32
+ const e = i.current;
33
33
  if (!e) return;
34
34
  const t = e.contentDocument;
35
35
  if (!t) return;
@@ -44,42 +44,32 @@ const X = ({
44
44
  <body>
45
45
  <div id="root"></div>
46
46
  </body>
47
- </html>`), t.close(), g.current = t;
47
+ </html>`), t.close(), w.current = t;
48
48
  const r = t.getElementById("root");
49
49
  if (!r) return;
50
- const s = P(r);
51
- h.current = s;
52
- const x = () => {
53
- if (n === "blackboard") return;
54
- const j = g.current;
55
- if (!a.current || !j) return;
56
- const { body: i, documentElement: f } = j, S = i ? Math.max(
57
- i.scrollHeight,
58
- i.offsetHeight,
59
- i.getBoundingClientRect().height
60
- ) : 0, A = f ? Math.max(
61
- f.scrollHeight,
62
- f.offsetHeight,
63
- f.getBoundingClientRect().height
64
- ) : 0, B = Math.max(S, A), D = Math.max(200, Math.ceil(B));
65
- N(D);
50
+ const s = _(r);
51
+ f.current = s;
52
+ const b = () => {
53
+ if (!i.current || !t.body) return;
54
+ const z = t.body.getBoundingClientRect(), I = t.documentElement?.getBoundingClientRect(), O = z.height, S = I?.height || 0, A = Math.max(O, S), B = Math.max(200, Math.ceil(A));
55
+ F(B);
66
56
  };
67
- b.current = x, x();
68
- const v = new ResizeObserver(() => x());
69
- return v.observe(t.body), r && v.observe(r), () => {
70
- v.disconnect(), setTimeout(() => {
71
- s.unmount(), h.current = null, g.current = null, b.current = () => {
57
+ d.current = b, b();
58
+ const g = new ResizeObserver(() => b());
59
+ return g.observe(t.body), r && g.observe(r), () => {
60
+ g.disconnect(), setTimeout(() => {
61
+ s.unmount(), f.current = null, w.current = null, d.current = () => {
72
62
  };
73
63
  }, 0);
74
64
  };
75
- }, []), m(() => {
65
+ }, []), a(() => {
76
66
  const e = () => {
77
- I(!!document.fullscreenElement);
67
+ N(!!document.fullscreenElement);
78
68
  };
79
69
  return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
80
70
  }, []);
81
- const O = () => {
82
- const e = k.current || a.current;
71
+ const q = () => {
72
+ const e = C.current || i.current;
83
73
  if (e) {
84
74
  if (document.fullscreenElement) {
85
75
  document.exitFullscreen().catch(() => {
@@ -90,57 +80,57 @@ const X = ({
90
80
  });
91
81
  }
92
82
  };
93
- return m(() => {
94
- const e = h.current;
83
+ return a(() => {
84
+ const e = f.current;
95
85
  e && (e.render(
96
86
  /* @__PURE__ */ l.jsx(
97
- W,
87
+ P,
98
88
  {
99
89
  html: o,
100
- loadingText: y,
101
- styleLoadingText: C,
102
- scriptLoadingText: H,
103
- fullScreenButtonText: d,
104
- hideFullScreen: w,
90
+ loadingText: v,
91
+ styleLoadingText: x,
92
+ scriptLoadingText: R,
93
+ fullScreenButtonText: m,
94
+ hideFullScreen: y,
105
95
  resetToken: E,
106
96
  mode: n
107
97
  }
108
98
  )
109
- ), requestAnimationFrame(() => b.current?.()));
99
+ ), requestAnimationFrame(() => d.current?.()));
110
100
  }, [
111
101
  u,
112
102
  o,
113
- y,
114
- C,
115
- H,
116
- d,
103
+ v,
104
+ x,
105
+ R,
106
+ m,
117
107
  E,
118
108
  n
119
109
  ]), /* @__PURE__ */ l.jsxs(
120
110
  "div",
121
111
  {
122
- ref: k,
112
+ ref: C,
123
113
  className: "w-full h-full overflow-auto relative flex flex-col justify-center",
124
114
  children: [
125
- !w && /* @__PURE__ */ l.jsx(
115
+ !y && /* @__PURE__ */ l.jsx(
126
116
  "button",
127
117
  {
128
118
  type: "button",
129
- onClick: O,
119
+ onClick: q,
130
120
  className: "absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",
131
- children: z ? "退出全屏" : d || "全屏浏览"
121
+ children: M ? "退出全屏" : m || "全屏浏览"
132
122
  }
133
123
  ),
134
- n === "blackboard" && F === "markdown" ? /* @__PURE__ */ l.jsx($, { content: u }) : /* @__PURE__ */ l.jsx(
124
+ n === "blackboard" && j === "markdown" ? /* @__PURE__ */ l.jsx(Y, { content: u }) : /* @__PURE__ */ l.jsx(
135
125
  "iframe",
136
126
  {
137
- ref: a,
127
+ ref: i,
138
128
  sandbox: "allow-scripts allow-same-origin",
139
129
  allow: "fullscreen",
140
130
  allowFullScreen: !0,
141
131
  className: "w-full",
142
132
  style: {
143
- height: n === "blackboard" ? "100%" : `${M}px`
133
+ height: n === "blackboard" ? "100%" : `${k}px`
144
134
  // height: `${height}px`,
145
135
  // margin: "16px 0",
146
136
  }
@@ -151,6 +141,6 @@ const X = ({
151
141
  );
152
142
  };
153
143
  export {
154
- X as default
144
+ V as default
155
145
  };
156
146
  //# sourceMappingURL=IframeSandbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IframeSandbox.js","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport { splitContentSegments } from \"./utils/split-content\";\nimport ContentRender from \"./ContentRender\";\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n}\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const docRef = useRef<Document | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(() => {\n const segments = splitContentSegments(content);\n // console.log('segments=====', segments);\n const sandboxSegments = segments.filter((seg) => seg.type === \"sandbox\");\n const sandboxContent =\n mode === \"blackboard\"\n ? sandboxSegments[sandboxSegments.length - 1]?.value || \"\"\n : sandboxSegments.map((seg) => seg.value).join(\"\\n\");\n return sandboxContent || \"\";\n }, [content, mode]);\n\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = htmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && htmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = htmlContent;\n }, [htmlContent, mode]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <style>\n html, body { margin: 0; padding: 0; }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n docRef.current = doc;\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n\n const updateHeight = () => {\n if (mode === \"blackboard\") return;\n const docNode = docRef.current;\n if (!iframeRef.current || !docNode) return;\n\n const { body, documentElement } = docNode;\n const bodyHeight = body\n ? Math.max(\n body.scrollHeight,\n body.offsetHeight,\n body.getBoundingClientRect().height\n )\n : 0;\n const htmlHeight = documentElement\n ? Math.max(\n documentElement.scrollHeight,\n documentElement.offsetHeight,\n documentElement.getBoundingClientRect().height\n )\n : 0;\n const contentHeight = Math.max(bodyHeight, htmlHeight);\n const nextHeight = Math.max(200, Math.ceil(contentHeight));\n setHeight(nextHeight);\n };\n updateHeightRef.current = updateHeight;\n\n updateHeight();\n\n const resizeObserver = new ResizeObserver(() => updateHeight());\n resizeObserver.observe(doc.body);\n if (rootEl) {\n resizeObserver.observe(rootEl);\n }\n\n return () => {\n resizeObserver.disconnect();\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\n }, 0);\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={htmlContent}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n fullScreenButtonText={fullScreenButtonText}\n hideFullScreen={hideFullScreen}\n resetToken={resetToken}\n mode={mode}\n />\n );\n requestAnimationFrame(() => updateHeightRef.current?.());\n }, [\n content,\n htmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n mode,\n ]);\n\n return (\n <div\n ref={containerRef}\n className={\n \"w-full h-full overflow-auto relative flex flex-col justify-center\"\n }\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen ? \"退出全屏\" : fullScreenButtonText || \"全屏浏览\"}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <ContentRender content={content} />\n ) : (\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin\"\n allow=\"fullscreen\"\n allowFullScreen\n className={(className, \"w-full\")}\n style={{\n height: mode === \"blackboard\" ? \"100%\" : `${height}px`,\n // height: `${height}px`,\n // margin: \"16px 0\",\n }}\n />\n )}\n </div>\n );\n};\n\nexport default IframeSandbox;\n"],"names":["IframeSandbox","content","type","className","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","hideFullScreen","mode","containerRef","useRef","iframeRef","rootRef","docRef","updateHeightRef","height","setHeight","useState","resetToken","setResetToken","isFullscreen","setIsFullscreen","prevHtmlRef","htmlContent","React","sandboxSegments","splitContentSegments","seg","useEffect","prev","token","iframe","doc","rootEl","root","createRoot","updateHeight","docNode","body","documentElement","bodyHeight","htmlHeight","contentHeight","nextHeight","resizeObserver","onFullscreenChange","toggleFullscreen","target","jsx","SandboxApp","jsxs","ContentRender"],"mappings":";;;;;;AAiBA,MAAMA,IAA8C,CAAC;AAAA,EACnD,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,MAAAC,IAAO;AACT,MAAM;AACJ,QAAMC,IAAeC,EAAuB,IAAI,GAC1CC,IAAYD,EAA0B,IAAI,GAC1CE,IAAUF,EAAoB,IAAI,GAClCG,IAASH,EAAwB,IAAI,GACrCI,IAAkBJ,EAAmB,MAAM;AAAA,EAAC,CAAC,GAC7C,CAACK,GAAQC,CAAS,IAAIC,EAAS,GAAG,GAClC,CAACC,GAAYC,CAAa,IAAIF,EAAS,CAAC,GACxC,CAACG,GAAcC,CAAe,IAAIJ,EAAS,EAAK,GAChDK,IAAcZ,EAAe,EAAE,GAC/Ba,IAAcC,EAAM,QAAQ,MAAM;AAGtC,UAAMC,IAFWC,EAAqB1B,CAAO,EAEZ,OAAO,CAAC2B,MAAQA,EAAI,SAAS,SAAS;AAKvE,YAHEnB,MAAS,eACLiB,EAAgBA,EAAgB,SAAS,CAAC,GAAG,SAAS,KACtDA,EAAgB,IAAI,CAACE,MAAQA,EAAI,KAAK,EAAE,KAAK;AAAA,CAAI,MAC9B;AAAA,EAC3B,GAAG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,EAAgB,WAAW;AAAA,EACzD,GAAG;AAAA,IACDd;AAAA,IACAuB;AAAA,IACApB;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAY;AAAA,IACAV;AAAA,EAAA,CACD,GAGC0C,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKzC;AAAA,MACL,WACE;AAAA,MAGD,UAAA;AAAA,QAAA,CAACF,KACAyC,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,SAASF;AAAA,YACT,WACE;AAAA,YAGD,UAAA1B,IAAe,SAASd,KAAwB;AAAA,UAAA;AAAA,QAAA;AAAA,QAGpDE,MAAS,gBAAgBP,MAAS,aACjC+C,gBAAAA,EAAAA,IAACG,GAAA,EAAc,SAAAnD,GAAkB,IAEjCgD,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAKrC;AAAA,YACL,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,iBAAe;AAAA,YACf,WAAuB;AAAA,YACvB,OAAO;AAAA,cACL,QAAQH,MAAS,eAAe,SAAS,GAAGO,CAAM;AAAA;AAAA;AAAA,YAAA;AAAA,UAGpD;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR;"}
1
+ {"version":3,"file":"IframeSandbox.js","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport { splitContentSegments } from \"./utils/split-content\";\nimport ContentRender from \"./ContentRender\";\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n}\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const docRef = useRef<Document | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(() => {\n const segments = splitContentSegments(content);\n // console.log('segments=====', segments);\n const sandboxSegments = segments.filter((seg) => seg.type === \"sandbox\");\n const sandboxContent =\n mode === \"blackboard\"\n ? sandboxSegments[sandboxSegments.length - 1]?.value || \"\"\n : sandboxSegments.map((seg) => seg.value).join(\"\\n\");\n return sandboxContent || \"\";\n }, [content, mode]);\n\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = htmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && htmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = htmlContent;\n }, [htmlContent, mode]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <style>\n html, body { margin: 0; padding: 0; }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n docRef.current = doc;\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n const bodyRect = doc.body.getBoundingClientRect();\n const htmlRect = doc.documentElement?.getBoundingClientRect();\n const bodyHeight = bodyRect.height;\n const htmlHeight = htmlRect?.height || 0;\n const contentHeight = Math.max(bodyHeight, htmlHeight);\n const nextHeight = Math.max(200, Math.ceil(contentHeight));\n setHeight(nextHeight);\n };\n updateHeightRef.current = updateHeight;\n\n updateHeight();\n\n const resizeObserver = new ResizeObserver(() => updateHeight());\n resizeObserver.observe(doc.body);\n if (rootEl) {\n resizeObserver.observe(rootEl);\n }\n\n return () => {\n resizeObserver.disconnect();\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\n }, 0);\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={htmlContent}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n fullScreenButtonText={fullScreenButtonText}\n hideFullScreen={hideFullScreen}\n resetToken={resetToken}\n mode={mode}\n />\n );\n requestAnimationFrame(() => updateHeightRef.current?.());\n }, [\n content,\n htmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n mode,\n ]);\n\n return (\n <div\n ref={containerRef}\n className={\n \"w-full h-full overflow-auto relative flex flex-col justify-center\"\n }\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen ? \"退出全屏\" : fullScreenButtonText || \"全屏浏览\"}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <ContentRender content={content} />\n ) : (\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin\"\n allow=\"fullscreen\"\n allowFullScreen\n className={(className, \"w-full\")}\n style={{\n height: mode === \"blackboard\" ? \"100%\" : `${height}px`,\n // height: `${height}px`,\n // margin: \"16px 0\",\n }}\n />\n )}\n </div>\n );\n};\n\nexport default IframeSandbox;\n"],"names":["IframeSandbox","content","type","className","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","hideFullScreen","mode","containerRef","useRef","iframeRef","rootRef","docRef","updateHeightRef","height","setHeight","useState","resetToken","setResetToken","isFullscreen","setIsFullscreen","prevHtmlRef","htmlContent","React","sandboxSegments","splitContentSegments","seg","useEffect","prev","token","iframe","doc","rootEl","root","createRoot","updateHeight","bodyRect","htmlRect","bodyHeight","htmlHeight","contentHeight","nextHeight","resizeObserver","onFullscreenChange","toggleFullscreen","target","jsx","SandboxApp","jsxs","ContentRender"],"mappings":";;;;;;AAiBA,MAAMA,IAA8C,CAAC;AAAA,EACnD,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,MAAAC,IAAO;AACT,MAAM;AACJ,QAAMC,IAAeC,EAAuB,IAAI,GAC1CC,IAAYD,EAA0B,IAAI,GAC1CE,IAAUF,EAAoB,IAAI,GAClCG,IAASH,EAAwB,IAAI,GACrCI,IAAkBJ,EAAmB,MAAM;AAAA,EAAC,CAAC,GAC7C,CAACK,GAAQC,CAAS,IAAIC,EAAS,GAAG,GAClC,CAACC,GAAYC,CAAa,IAAIF,EAAS,CAAC,GACxC,CAACG,GAAcC,CAAe,IAAIJ,EAAS,EAAK,GAChDK,IAAcZ,EAAe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UACA,YAAAW;AAAA,UACA,MAAAV;AAAA,QAAA;AAAA,MAAA;AAAA,IACF,GAEF,sBAAsB,MAAMM,EAAgB,WAAW;AAAA,EACzD,GAAG;AAAA,IACDd;AAAA,IACAuB;AAAA,IACApB;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAY;AAAA,IACAV;AAAA,EAAA,CACD,GAGCyC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKxC;AAAA,MACL,WACE;AAAA,MAGD,UAAA;AAAA,QAAA,CAACF,KACAwC,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,SAASF;AAAA,YACT,WACE;AAAA,YAGD,UAAAzB,IAAe,SAASd,KAAwB;AAAA,UAAA;AAAA,QAAA;AAAA,QAGpDE,MAAS,gBAAgBP,MAAS,aACjC8C,gBAAAA,EAAAA,IAACG,GAAA,EAAc,SAAAlD,GAAkB,IAEjC+C,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAKpC;AAAA,YACL,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,iBAAe;AAAA,YACf,WAAuB;AAAA,YACvB,OAAO;AAAA,cACL,QAAQH,MAAS,eAAe,SAAS,GAAGO,CAAM;AAAA;AAAA;AAAA,YAAA;AAAA,UAGpD;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -1,66 +1,64 @@
1
- const S = /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\s>]/i, y = [
1
+ const y = /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\s>]/i, k = [
2
2
  /<svg[\s\S]*?<\/svg>/i,
3
3
  /<img\b[^>]*?>/i,
4
4
  /```mermaid[\s\S]*?```/i,
5
5
  /```[a-zA-Z0-9]+[\s\S]*?```/i
6
- ], p = /<\/[a-z][^>]*>\s*\n(?=[^\s<])/gi, k = (t, e) => {
7
- let i = t.length, n;
8
- for (p.lastIndex = 0; n = p.exec(t); )
9
- if (!(n.index <= e)) {
10
- i = n.index + n[0].length;
6
+ ], v = /<\/[a-z][^>]*>\s*\n(?=[^\s<])/gi, I = (t, n) => {
7
+ let s = t.length, e;
8
+ for (v.lastIndex = 0; e = v.exec(t); )
9
+ if (!(e.index <= n)) {
10
+ s = e.index + e[0].length;
11
11
  break;
12
12
  }
13
- return i;
14
- }, I = (t) => {
15
- let e = null;
16
- return y.forEach((i) => {
17
- const n = i.exec(t);
18
- if (!n || typeof n.index != "number") return;
19
- const s = n.index, r = n.index + n[0].length;
20
- (!e || s < e.start) && (e = { start: s, end: r });
21
- }), e;
13
+ return s;
22
14
  }, B = (t) => {
23
- const e = t.search(/^\s*\|.*\|\s*$/m);
24
- if (e === -1) return null;
25
- const i = t.slice(e).split(`
26
- `);
27
- let n = e;
28
- const s = [];
15
+ let n = null;
16
+ return k.forEach((s) => {
17
+ const e = s.exec(t);
18
+ if (!e || typeof e.index != "number") return;
19
+ const i = e.index, r = e.index + e[0].length;
20
+ (!n || i < n.start) && (n = { start: i, end: r });
21
+ }), n;
22
+ }, E = (t) => {
23
+ const n = t.match(/^\s*\|.+\|\s*$/m);
24
+ if (!n || typeof n.index != "number") return null;
25
+ const s = n[0].match(/^\s*/)?.[0].length ?? 0, e = n.index + s, i = t.slice(e).split(`
26
+ `), r = [];
29
27
  for (const c of i) {
30
28
  if (!c.trim().startsWith("|")) break;
31
- s.push(c), n += c.length + 1;
29
+ r.push(c);
32
30
  }
33
- const r = s.join(`
31
+ const o = r.join(`
34
32
  `);
35
- return { start: e, block: r, end: n - 1 };
36
- }, f = (t, e = !1) => {
37
- const i = t.indexOf("```");
38
- if (e && i !== -1 && t.indexOf("```", i + 3) === -1)
33
+ return { start: e, block: o, end: e + o.length };
34
+ }, u = (t, n = !1) => {
35
+ const s = t.indexOf("```");
36
+ if (n && s !== -1 && t.indexOf("```", s + 3) === -1)
39
37
  return [{ type: "markdown", value: t }];
40
- const n = t.search(/<svg\b/i);
41
- if (n !== -1 && t.indexOf("</svg>", n) === -1)
38
+ const e = t.search(/<svg\b/i);
39
+ if (e !== -1 && t.indexOf("</svg>", e) === -1)
42
40
  return [{ type: "markdown", value: t }];
43
- const s = B(t);
44
- if (s) {
45
- const l = [], b = t.slice(0, s.start);
46
- e && b.trim() && l.push({ type: "text", value: b.trim() }), l.push({ type: "markdown", value: s.block });
47
- const u = t.slice(s.end);
48
- return u.trim() && l.push(
49
- ...e ? f(u, !0) : f(u)
41
+ const i = E(t);
42
+ if (i) {
43
+ const l = [], p = t.slice(0, i.start);
44
+ n && p.trim() && l.push({ type: "text", value: p }), l.push({ type: "markdown", value: i.block });
45
+ const m = t.slice(i.end), S = m.length < t.length;
46
+ return m.trim() && S && l.push(
47
+ ...n ? u(m, !0) : u(m)
50
48
  ), l;
51
49
  }
52
- if (t.match(/<svg[\s\S]*?<\/svg>/i) && e)
50
+ if (t.match(/<svg[\s\S]*?<\/svg>/i) && n && !(e > -1 && t.slice(0, e).trim().length > 0))
53
51
  return t.trim().toLowerCase().endsWith("</svg>") ? [{ type: "markdown", value: t }] : [{ type: "markdown", value: `${t}</svg>` }];
54
- const c = t.search(S), o = I(t);
55
- if (c === -1 && !o)
56
- return e && t.trim() ? [{ type: "text", value: t }] : [];
57
- const d = !!o && (c === -1 || o.start < c), m = d ? o.start : c, h = d ? o.end : k(t, m), a = [], g = t.slice(0, m), x = t.slice(m, h), v = t.slice(h);
58
- return e && g.trim() && a.push({ type: "text", value: g }), a.push({
59
- type: d ? "markdown" : "sandbox",
52
+ const o = t.search(y), c = B(t);
53
+ if (o === -1 && !c)
54
+ return n && t.trim() ? [{ type: "text", value: t }] : [];
55
+ const a = !!c && (o === -1 || c.start < o), h = a ? c.start : o, f = a ? c.end : I(t, h), d = [], g = t.slice(0, h), x = t.slice(h, f), b = t.slice(f);
56
+ return n && g.trim() && d.push({ type: "text", value: g }), d.push({
57
+ type: a ? "markdown" : "sandbox",
60
58
  value: x
61
- }), v.trim() && a.push(...f(v, e)), a;
59
+ }), b.trim() && d.push(...u(b, n)), d;
62
60
  };
63
61
  export {
64
- f as splitContentSegments
62
+ u as splitContentSegments
65
63
  };
66
64
  //# sourceMappingURL=split-content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"split-content.js","sources":["../../../../src/components/ContentRender/utils/split-content.ts"],"sourcesContent":["export type RenderSegment =\n | { type: \"markdown\"; value: string }\n | { type: \"sandbox\"; value: string }\n | { type: \"text\"; value: string };\n\nconst SANDBOX_START_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\\s>]/i;\n\nconst INLINE_SANDBOX_PATTERNS: RegExp[] = [\n /<svg[\\s\\S]*?<\\/svg>/i,\n /<img\\b[^>]*?>/i,\n /```mermaid[\\s\\S]*?```/i,\n /```[a-zA-Z0-9]+[\\s\\S]*?```/i,\n];\n\nconst closingBoundary = /<\\/[a-z][^>]*>\\s*\\n(?=[^\\s<])/gi;\n\ntype MatchResult = { start: number; end: number };\n\nconst findHtmlBlockEnd = (raw: string, startIndex: number) => {\n let blockEnd = raw.length;\n let match: RegExpExecArray | null;\n closingBoundary.lastIndex = 0;\n\n while ((match = closingBoundary.exec(raw))) {\n if (match.index <= startIndex) continue;\n blockEnd = match.index + match[0].length;\n break;\n }\n\n return blockEnd;\n};\n\nconst findInlineSandboxMatch = (raw: string): MatchResult | null => {\n let earliest: MatchResult | null = null;\n\n INLINE_SANDBOX_PATTERNS.forEach((pattern) => {\n const match = pattern.exec(raw);\n if (!match || typeof match.index !== \"number\") return;\n const start = match.index;\n const end = match.index + match[0].length;\n\n if (!earliest || start < earliest.start) {\n earliest = { start, end };\n }\n });\n\n return earliest;\n};\n\nconst extractTableBlock = (\n raw: string\n): { start: number; block: string; end: number } | null => {\n const tableStart = raw.search(/^\\s*\\|.*\\|\\s*$/m);\n if (tableStart === -1) return null;\n\n const lines = raw.slice(tableStart).split(\"\\n\");\n let endIndex = tableStart;\n const tableLines: string[] = [];\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed.startsWith(\"|\")) break;\n tableLines.push(line);\n endIndex += line.length + 1; // include newline\n }\n\n const block = tableLines.join(\"\\n\");\n return { start: tableStart, block, end: endIndex - 1 };\n};\n\n// Split incoming markdown content into markdown and sandbox HTML segments\nexport const splitContentSegments = (\n raw: string,\n keepText = false\n): RenderSegment[] => {\n const fenceStart = raw.indexOf(\"```\");\n if (keepText && fenceStart !== -1) {\n const closingFence = raw.indexOf(\"```\", fenceStart + 3);\n if (closingFence === -1) {\n return [{ type: \"markdown\", value: raw }];\n }\n }\n\n const svgOpenIndex = raw.search(/<svg\\b/i);\n if (svgOpenIndex !== -1 && raw.indexOf(\"</svg>\", svgOpenIndex) === -1) {\n return [{ type: \"markdown\", value: raw }];\n }\n\n const tableBlock = extractTableBlock(raw);\n if (tableBlock) {\n const segments: RenderSegment[] = [];\n const before = raw.slice(0, tableBlock.start);\n if (keepText && before.trim()) {\n segments.push({ type: \"text\", value: before.trim() });\n }\n segments.push({ type: \"markdown\", value: tableBlock.block });\n const after = raw.slice(tableBlock.end);\n if (after.trim()) {\n segments.push(\n ...(keepText\n ? splitContentSegments(after, true)\n : splitContentSegments(after))\n );\n }\n return segments;\n }\n\n const completeSvgMatch = raw.match(/<svg[\\s\\S]*?<\\/svg>/i);\n if (completeSvgMatch && keepText) {\n if (!raw.trim().toLowerCase().endsWith(\"</svg>\")) {\n return [{ type: \"markdown\", value: `${raw}</svg>` }];\n }\n return [{ type: \"markdown\", value: raw }];\n }\n\n const sandboxStartIndex = raw.search(SANDBOX_START_PATTERN);\n const inlineMatch = findInlineSandboxMatch(raw);\n\n if (sandboxStartIndex === -1 && !inlineMatch) {\n if (keepText && raw.trim()) {\n return [{ type: \"text\", value: raw }];\n }\n return [];\n }\n\n const shouldUseInline =\n !!inlineMatch &&\n (sandboxStartIndex === -1 || inlineMatch.start < sandboxStartIndex);\n\n const startIndex = shouldUseInline ? inlineMatch!.start : sandboxStartIndex;\n const blockEnd = shouldUseInline\n ? inlineMatch!.end\n : findHtmlBlockEnd(raw, startIndex);\n\n const segments: RenderSegment[] = [];\n const before = raw.slice(0, startIndex);\n const matchedBlock = raw.slice(startIndex, blockEnd);\n const after = raw.slice(blockEnd);\n\n if (keepText && before.trim()) {\n segments.push({ type: \"text\", value: before });\n }\n\n segments.push({\n type: shouldUseInline ? \"markdown\" : \"sandbox\",\n value: matchedBlock,\n });\n\n if (after.trim()) {\n segments.push(...splitContentSegments(after, keepText));\n }\n\n return segments;\n};\n"],"names":["SANDBOX_START_PATTERN","INLINE_SANDBOX_PATTERNS","closingBoundary","findHtmlBlockEnd","raw","startIndex","blockEnd","match","findInlineSandboxMatch","earliest","pattern","start","end","extractTableBlock","tableStart","lines","endIndex","tableLines","line","block","splitContentSegments","keepText","fenceStart","svgOpenIndex","tableBlock","segments","before","after","sandboxStartIndex","inlineMatch","shouldUseInline","matchedBlock"],"mappings":"AAKA,MAAMA,IACJ,sGAEIC,IAAoC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAkB,mCAIlBC,IAAmB,CAACC,GAAaC,MAAuB;AAC5D,MAAIC,IAAWF,EAAI,QACfG;AAGJ,OAFAL,EAAgB,YAAY,GAEpBK,IAAQL,EAAgB,KAAKE,CAAG;AACtC,QAAI,EAAAG,EAAM,SAASF,IACnB;AAAA,MAAAC,IAAWC,EAAM,QAAQA,EAAM,CAAC,EAAE;AAClC;AAAA;AAGF,SAAOD;AACT,GAEME,IAAyB,CAACJ,MAAoC;AAClE,MAAIK,IAA+B;AAEnC,SAAAR,EAAwB,QAAQ,CAACS,MAAY;AAC3C,UAAMH,IAAQG,EAAQ,KAAKN,CAAG;AAC9B,QAAI,CAACG,KAAS,OAAOA,EAAM,SAAU,SAAU;AAC/C,UAAMI,IAAQJ,EAAM,OACdK,IAAML,EAAM,QAAQA,EAAM,CAAC,EAAE;AAEnC,KAAI,CAACE,KAA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QvB,EAAI,MAAMoB,EAAW,GAAG;AACtC,WAAIG,EAAM,UACRF,EAAS;AAAA,MACP,GAAIJ,IACAD,EAAqBO,GAAO,EAAI,IAChCP,EAAqBO,CAAK;AAAA,IAAA,GAG3BF;AAAAA,EACT;AAGA,MADyBrB,EAAI,MAAM,sBAAsB,KACjCiB;AACtB,WAAKjB,EAAI,KAAA,EAAO,cAAc,SAAS,QAAQ,IAGxC,CAAC,EAAE,MAAM,YAAY,OAAOA,GAAK,IAF/B,CAAC,EAAE,MAAM,YAAY,OAAO,GAAGA,CAAG,UAAU;AAKvD,QAAMwB,IAAoBxB,EAAI,OAAOJ,CAAqB,GACpD6B,IAAcrB,EAAuBJ,CAAG;AAE9C,MAAIwB,MAAsB,MAAM,CAACC;AAC/B,WAAIR,KAAYjB,EAAI,SACX,CAAC,EAAE,MAAM,QAAQ,OAAOA,GAAK,IAE/B,CAAA;AAGT,QAAM0B,IACJ,CAAC,CAACD,MACDD,MAAsB,MAAMC,EAAY,QAAQD,IAE7CvB,IAAayB,IAAkBD,EAAa,QAAQD,GACpDtB,IAAWwB,IACbD,EAAa,MACb1B,EAAiBC,GAAKC,CAAU,GAE9BoB,IAA4B,CAAA,GAC5BC,IAAStB,EAAI,MAAM,GAAGC,CAAU,GAChC0B,IAAe3B,EAAI,MAAMC,GAAYC,CAAQ,GAC7CqB,IAAQvB,EAAI,MAAME,CAAQ;AAEhC,SAAIe,KAAYK,EAAO,UACrBD,EAAS,KAAK,EAAE,MAAM,QAAQ,OAAOC,GAAQ,GAG/CD,EAAS,KAAK;AAAA,IACZ,MAAMK,IAAkB,aAAa;AAAA,IACrC,OAAOC;AAAA,EAAA,CACR,GAEGJ,EAAM,UACRF,EAAS,KAAK,GAAGL,EAAqBO,GAAON,CAAQ,CAAC,GAGjDI;AACT;"}
1
+ {"version":3,"file":"split-content.js","sources":["../../../../src/components/ContentRender/utils/split-content.ts"],"sourcesContent":["export type RenderSegment =\n | { type: \"markdown\"; value: string }\n | { type: \"sandbox\"; value: string }\n | { type: \"text\"; value: string };\n\nconst SANDBOX_START_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\\s>]/i;\n\nconst INLINE_SANDBOX_PATTERNS: RegExp[] = [\n /<svg[\\s\\S]*?<\\/svg>/i,\n /<img\\b[^>]*?>/i,\n /```mermaid[\\s\\S]*?```/i,\n /```[a-zA-Z0-9]+[\\s\\S]*?```/i,\n];\n\nconst closingBoundary = /<\\/[a-z][^>]*>\\s*\\n(?=[^\\s<])/gi;\n\ntype MatchResult = { start: number; end: number };\n\nconst findHtmlBlockEnd = (raw: string, startIndex: number) => {\n let blockEnd = raw.length;\n let match: RegExpExecArray | null;\n closingBoundary.lastIndex = 0;\n\n while ((match = closingBoundary.exec(raw))) {\n if (match.index <= startIndex) continue;\n blockEnd = match.index + match[0].length;\n break;\n }\n\n return blockEnd;\n};\n\nconst findInlineSandboxMatch = (raw: string): MatchResult | null => {\n let earliest: MatchResult | null = null;\n\n INLINE_SANDBOX_PATTERNS.forEach((pattern) => {\n const match = pattern.exec(raw);\n if (!match || typeof match.index !== \"number\") return;\n const start = match.index;\n const end = match.index + match[0].length;\n\n if (!earliest || start < earliest.start) {\n earliest = { start, end };\n }\n });\n\n return earliest;\n};\n\nconst extractTableBlock = (\n raw: string\n): { start: number; block: string; end: number } | null => {\n const tableMatch = raw.match(/^\\s*\\|.+\\|\\s*$/m);\n if (!tableMatch || typeof tableMatch.index !== \"number\") return null;\n\n const leadingSpaces = tableMatch[0].match(/^\\s*/)?.[0].length ?? 0;\n const tableStart = tableMatch.index + leadingSpaces;\n\n const lines = raw.slice(tableStart).split(\"\\n\");\n const tableLines: string[] = [];\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed.startsWith(\"|\")) break;\n tableLines.push(line);\n }\n\n const block = tableLines.join(\"\\n\");\n return { start: tableStart, block, end: tableStart + block.length };\n};\n\n// Split incoming markdown content into markdown and sandbox HTML segments\nexport const splitContentSegments = (\n raw: string,\n keepText = false\n): RenderSegment[] => {\n const fenceStart = raw.indexOf(\"```\");\n if (keepText && fenceStart !== -1) {\n const closingFence = raw.indexOf(\"```\", fenceStart + 3);\n if (closingFence === -1) {\n return [{ type: \"markdown\", value: raw }];\n }\n }\n\n const svgOpenIndex = raw.search(/<svg\\b/i);\n if (svgOpenIndex !== -1 && raw.indexOf(\"</svg>\", svgOpenIndex) === -1) {\n return [{ type: \"markdown\", value: raw }];\n }\n\n const tableBlock = extractTableBlock(raw);\n if (tableBlock) {\n const segments: RenderSegment[] = [];\n const before = raw.slice(0, tableBlock.start);\n if (keepText && before.trim()) {\n segments.push({ type: \"text\", value: before });\n }\n segments.push({ type: \"markdown\", value: tableBlock.block });\n const after = raw.slice(tableBlock.end);\n const hasProgress = after.length < raw.length;\n if (after.trim() && hasProgress) {\n segments.push(\n ...(keepText\n ? splitContentSegments(after, true)\n : splitContentSegments(after))\n );\n }\n return segments;\n }\n\n const completeSvgMatch = raw.match(/<svg[\\s\\S]*?<\\/svg>/i);\n if (completeSvgMatch && keepText) {\n const hasLeadingContent =\n svgOpenIndex > -1 && raw.slice(0, svgOpenIndex).trim().length > 0;\n if (!hasLeadingContent) {\n if (!raw.trim().toLowerCase().endsWith(\"</svg>\")) {\n return [{ type: \"markdown\", value: `${raw}</svg>` }];\n }\n return [{ type: \"markdown\", value: raw }];\n }\n }\n\n const sandboxStartIndex = raw.search(SANDBOX_START_PATTERN);\n const inlineMatch = findInlineSandboxMatch(raw);\n\n if (sandboxStartIndex === -1 && !inlineMatch) {\n if (keepText && raw.trim()) {\n return [{ type: \"text\", value: raw }];\n }\n return [];\n }\n\n const shouldUseInline =\n !!inlineMatch &&\n (sandboxStartIndex === -1 || inlineMatch.start < sandboxStartIndex);\n\n const startIndex = shouldUseInline ? inlineMatch!.start : sandboxStartIndex;\n const blockEnd = shouldUseInline\n ? inlineMatch!.end\n : findHtmlBlockEnd(raw, startIndex);\n\n const segments: RenderSegment[] = [];\n const before = raw.slice(0, startIndex);\n const matchedBlock = raw.slice(startIndex, blockEnd);\n const after = raw.slice(blockEnd);\n\n if (keepText && before.trim()) {\n segments.push({ type: \"text\", value: before });\n }\n\n segments.push({\n type: shouldUseInline ? \"markdown\" : \"sandbox\",\n value: matchedBlock,\n });\n\n if (after.trim()) {\n segments.push(...splitContentSegments(after, keepText));\n }\n\n return segments;\n};\n"],"names":["SANDBOX_START_PATTERN","INLINE_SANDBOX_PATTERNS","closingBoundary","findHtmlBlockEnd","raw","startIndex","blockEnd","match","findInlineSandboxMatch","earliest","pattern","start","end","extractTableBlock","tableMatch","leadingSpaces","tableStart","lines","tableLines","line","block","splitContentSegments","keepText","fenceStart","svgOpenIndex","tableBlock","segments","before","after","hasProgress","sandboxStartIndex","inlineMatch","shouldUseInline","matchedBlock"],"mappings":"AAKA,MAAMA,IACJ,sGAEIC,IAAoC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAkB,mCAIlBC,IAAmB,CAACC,GAAaC,MAAuB;AAC5D,MAAIC,IAAWF,EAAI,QACfG;AAGJ,OAFAL,EAAgB,YAAY,GAEpBK,IAAQL,EAAgB,KAAKE,CAAG;AACtC,QAAI,EAAAG,EAAM,SAASF,IACnB;AAAA,MAAAC,IAAWC,EAAM,QAAQA,EAAM,CAAC,EAAE;AAClC;AAAA;AAGF,SAAOD;AACT,GAEME,IAAyB,CAACJ,MAAoC;AAClE,MAAIK,IAA+B;AAEnC,SAAAR,EAAwB,QAAQ,CAACS,MAAY;AAC3C,UAAMH,IAAQG,EAAQ,KAAKN,CAAG;AAC9B,QAAI,CAACG,KAAS,OAAOA,EAAM,SAAU,SAAU;AAC/C,UAAMI,IAAQJ,EAAM,OACdK,IAAML,EAAM,QAAQA,EAAM,CAAC,EAAE;AAEnC,KAAI,CAACE,KAAYE,IAAQF,EAAS,WAChCA,IAAW,EAAE,OAAAE,GAAO,KAAAC,EAAA;AAAA,EAExB,CAAC,GAEMH;AACT,GAEMI,IAAo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 -149,7 +149,7 @@
149
149
  "storybook": "storybook dev -p 6006",
150
150
  "test": "echo \"No tests specified\" && exit 0"
151
151
  },
152
- "version": "0.1.83-beta.12",
152
+ "version": "0.1.83-beta.13",
153
153
  "type": "module",
154
154
  "exports": {
155
155
  ".": {