markdown-flow-ui 0.1.83-beta.3 → 0.1.83-beta.5

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 (33) 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/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.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.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/chunk-S3R3BYOJ.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-TZMSLE5B.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/ganttDiagram-LVOFAZNH.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/sequenceDiagram-WL72ISMW.js +1 -1
  8. 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.js +1 -1
  9. 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.js +1 -1
  10. 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.js +1 -1
  11. 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.js +1 -1
  12. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/index.js +1 -1
  13. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.js +1 -1
  14. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.js +1 -1
  15. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.js +1 -1
  16. package/dist/_virtual/index2.js +2 -5
  17. package/dist/_virtual/index2.js.map +1 -1
  18. package/dist/_virtual/index3.js +4 -2
  19. package/dist/_virtual/index3.js.map +1 -1
  20. package/dist/_virtual/index4.js +5 -4
  21. package/dist/_virtual/index4.js.map +1 -1
  22. package/dist/_virtual/index5.js +3 -5
  23. package/dist/_virtual/index5.js.map +1 -1
  24. package/dist/_virtual/index7.js +5 -2
  25. package/dist/_virtual/index7.js.map +1 -1
  26. package/dist/_virtual/index8.js +2 -3
  27. package/dist/_virtual/index8.js.map +1 -1
  28. package/dist/components/ContentRender/IframeSandbox.js +6 -4
  29. package/dist/components/ContentRender/IframeSandbox.js.map +1 -1
  30. package/dist/components/ContentRender/utils/split-content.js +26 -21
  31. package/dist/components/ContentRender/utils/split-content.js.map +1 -1
  32. package/dist/components/ui/inputGroup/textarea.js +1 -1
  33. 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/index8.js";
2
2
  import { __require as v } from "./constants.js";
3
3
  var m;
4
4
  function g() {
@@ -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/index7.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/index5.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/index5.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/index5.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/index5.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/index5.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) {
@@ -2,7 +2,7 @@ import $ from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
2
2
  import oe from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/extends.js";
3
3
  import r from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/defineProperty.js";
4
4
  import te from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/typeof.js";
5
- import d from "../../../../../../../../../_virtual/index2.js";
5
+ import d from "../../../../../../../../../_virtual/index4.js";
6
6
  import l, { useRef as q, cloneElement as ie } from "react";
7
7
  import { hasPrefixSuffix as re, hasAddon as de } from "./utils/commonUtils.js";
8
8
  var xe = /* @__PURE__ */ l.forwardRef(function(e, z) {
@@ -4,7 +4,7 @@ import w from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
4
4
  import J from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/typeof.js";
5
5
  import s from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/slicedToArray.js";
6
6
  import K from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js";
7
- import Q from "../../../../../../../../../_virtual/index2.js";
7
+ import Q from "../../../../../../../../../_virtual/index4.js";
8
8
  import ee from "../../../../rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
9
9
  import M from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.js";
10
10
  import te from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useMergedState.js";
@@ -4,7 +4,7 @@ import d from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
4
4
  import Ae from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js";
5
5
  import x from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/slicedToArray.js";
6
6
  import Fe from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js";
7
- import h from "../../../../../../../../../_virtual/index2.js";
7
+ import h from "../../../../../../../../../_virtual/index4.js";
8
8
  import Ne from "../../../../rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.js";
9
9
  import Te from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useMergedState.js";
10
10
  import o, { useRef as Y, useImperativeHandle as $e, useEffect as Ie } from "react";
@@ -1,5 +1,5 @@
1
1
  import t from "./TextArea.js";
2
- import "../../../../../../../../../_virtual/index2.js";
2
+ import "../../../../../../../../../_virtual/index4.js";
3
3
  import "../../../../rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
4
4
  import "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.js";
5
5
  import "react";
@@ -1,4 +1,4 @@
1
- import { __exports as e } from "../../../../../../../../../_virtual/index3.js";
1
+ import { __exports as e } from "../../../../../../../../../_virtual/index2.js";
2
2
  import { __require as _ } from "./remark-custom-variable.js";
3
3
  import { __require as m } from "./remark-flow.js";
4
4
  import { __require as f } from "./remark-interaction.js";
@@ -1,5 +1,5 @@
1
1
  import { __exports as a } from "../../../../../../../../../_virtual/remark-custom-variable.js";
2
- import g from "../../../../../../../../../_virtual/index4.js";
2
+ import g from "../../../../../../../../../_virtual/index3.js";
3
3
  import { __require as h } from "./interaction-parser.js";
4
4
  var m;
5
5
  function C() {
@@ -1,5 +1,5 @@
1
1
  import { __exports as n } from "../../../../../../../../../_virtual/remark-interaction.js";
2
- import I from "../../../../../../../../../_virtual/index4.js";
2
+ import I from "../../../../../../../../../_virtual/index3.js";
3
3
  import { __require as g } from "./interaction-parser.js";
4
4
  var m;
5
5
  function k() {
@@ -1,4 +1,4 @@
1
- import { __exports as r } from "../../../../../../../../../_virtual/index7.js";
1
+ import { __exports as r } from "../../../../../../../../../_virtual/index10.js";
2
2
  import { __require as p } from "../../../../inline-style-parser@0.2.4/node_modules/inline-style-parser/index.js";
3
3
  var f;
4
4
  function q() {
@@ -1,8 +1,5 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
- import { __require as s } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
3
- var e = s();
4
- const t = /* @__PURE__ */ r(e);
1
+ var r = {};
5
2
  export {
6
- t as default
3
+ r as __exports
7
4
  };
8
5
  //# sourceMappingURL=index2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +1,7 @@
1
- var r = {};
1
+ import { getAugmentedNamespace as e } from "./_commonjsHelpers.js";
2
+ import * as r from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js";
3
+ const m = /* @__PURE__ */ e(r);
2
4
  export {
3
- r as __exports
5
+ m as default
4
6
  };
5
7
  //# sourceMappingURL=index3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -1,7 +1,8 @@
1
- import { getAugmentedNamespace as e } from "./_commonjsHelpers.js";
2
- import * as r from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js";
3
- const m = /* @__PURE__ */ e(r);
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
+ import { __require as s } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
3
+ var e = s();
4
+ const t = /* @__PURE__ */ r(e);
4
5
  export {
5
- m as default
6
+ t as default
6
7
  };
7
8
  //# sourceMappingURL=index4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,8 +1,6 @@
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
+ 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();
5
3
  export {
6
- a as default
4
+ i as d
7
5
  };
8
6
  //# 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,5 +1,8 @@
1
- var r = {};
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);
2
5
  export {
3
- r as __exports
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,5 @@
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
+ var r = {};
3
2
  export {
4
- i as d
3
+ r as __exports
5
4
  };
6
5
  //# sourceMappingURL=index8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -4,7 +4,7 @@ import { createRoot as P } from "react-dom/client";
4
4
  import W from "./SandboxApp.js";
5
5
  import { splitContentSegments as Y } from "./utils/split-content.js";
6
6
  import $ from "./ContentRender.js";
7
- const V = ({
7
+ const U = ({
8
8
  content: i,
9
9
  type: H,
10
10
  className: j,
@@ -57,8 +57,10 @@ const V = ({
57
57
  f.current = b, b();
58
58
  const g = new ResizeObserver(() => b());
59
59
  return g.observe(t.body), n && g.observe(n), () => {
60
- g.disconnect(), o.unmount(), m.current = null, w.current = null, f.current = () => {
61
- };
60
+ g.disconnect(), setTimeout(() => {
61
+ o.unmount(), m.current = null, w.current = null, f.current = () => {
62
+ };
63
+ }, 0);
62
64
  };
63
65
  }, []), a(() => {
64
66
  const e = () => {
@@ -154,6 +156,6 @@ const V = ({
154
156
  );
155
157
  };
156
158
  export {
157
- V as default
159
+ U as default
158
160
  };
159
161
  //# 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 (!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 root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\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 />\n );\n requestAnimationFrame(() => updateHeightRef.current?.());\n }, [\n content,\n htmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n ]);\n\n return (\n <div\n ref={containerRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n overflow: \"auto\",\n position: \"relative\",\n }}\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n zIndex: 5,\n padding: \"6px 10px\",\n background: \"rgba(0, 0, 0, 0.75)\",\n color: \"#fff\",\n border: \"none\",\n borderRadius: 6,\n 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}\n style={{\n width: \"100%\",\n height: `${height}px`,\n // margin: \"16px 0\",\n }}\n title=\"HTML Sandbox\"\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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YACC,KAAKpC;AAAA,YACL,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,iBAAe;AAAA,YACf,WAAAT;AAAA,YACA,OAAO;AAAA,cACL,OAAO;AAAA,cACP,QAAQ,GAAGa,CAAM;AAAA;AAAA,YAAA;AAAA,YAGnB,OAAM;AAAA,UAAA;AAAA,QAAA;AAAA,MACR;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 />\n );\n requestAnimationFrame(() => updateHeightRef.current?.());\n }, [\n content,\n htmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n ]);\n\n return (\n <div\n ref={containerRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n overflow: \"auto\",\n position: \"relative\",\n }}\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n zIndex: 5,\n padding: \"6px 10px\",\n background: \"rgba(0, 0, 0, 0.75)\",\n color: \"#fff\",\n border: \"none\",\n borderRadius: 6,\n 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}\n style={{\n width: \"100%\",\n height: `${height}px`,\n // margin: \"16px 0\",\n }}\n title=\"HTML Sandbox\"\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,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,CAAC3B,GAASQ,CAAI,CAAC;AAElB,EAAAoB,EAAU,MAAM;AACd,QAAIpB,MAAS,cAAc;AACzB,MAAAc,EAAY,UAAUC;AACtB;AAAA,IACF;AACA,UAAMM,IAAOP,EAAY;AAEzB,IAAI,EADmBO,KAAQN,EAAY,WAAWM,CAAI,MACnCA,KACrBV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AO;AAAA,cACL,UAAU;AAAA,cACV,KAAK;AAAA,cACL,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,QAAQ;AAAA,YAAA;AAAA,YAGT,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,WAAAT;AAAA,YACA,OAAO;AAAA,cACL,OAAO;AAAA,cACP,QAAQ,GAAGa,CAAM;AAAA;AAAA,YAAA;AAAA,YAGnB,OAAM;AAAA,UAAA;AAAA,QAAA;AAAA,MACR;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -1,35 +1,40 @@
1
- const h = /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\s>]/i, u = [
1
+ const f = /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\s>]/i, g = [
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
- ], d = /<\/[a-z][^>]*>\s*\n(?=[^\s<])/gi, f = (n, e) => {
7
- let s = n.length, t;
8
- for (d.lastIndex = 0; t = d.exec(n); )
9
- if (!(t.index <= e)) {
10
- s = t.index + t[0].length;
6
+ ], u = /<\/[a-z][^>]*>\s*\n(?=[^\s<])/gi, v = (t, e) => {
7
+ let s = t.length, n;
8
+ for (u.lastIndex = 0; n = u.exec(t); )
9
+ if (!(n.index <= e)) {
10
+ s = n.index + n[0].length;
11
11
  break;
12
12
  }
13
13
  return s;
14
- }, x = (n) => {
14
+ }, x = (t) => {
15
15
  let e = null;
16
- return u.forEach((s) => {
17
- const t = s.exec(n);
18
- if (!t || typeof t.index != "number") return;
19
- const i = t.index, c = t.index + t[0].length;
16
+ return g.forEach((s) => {
17
+ const n = s.exec(t);
18
+ if (!n || typeof n.index != "number") return;
19
+ const i = n.index, c = n.index + n[0].length;
20
20
  (!e || i < e.start) && (e = { start: i, end: c });
21
21
  }), e;
22
- }, b = (n, e = !1) => {
23
- const s = n.search(h), t = x(n);
24
- if (s === -1 && !t)
25
- return e && n.trim() ? [{ type: "text", value: n }] : [];
26
- const i = !!t && (s === -1 || t.start < s), c = i ? t.start : s, l = i ? t.end : f(n, c), o = [], a = n.slice(0, c), m = n.slice(c, l), r = n.slice(l);
27
- return e && a.trim() && o.push({ type: "text", value: a }), o.push({
28
- type: i ? "markdown" : "sandbox",
29
- value: m
30
- }), r.trim() && o.push(...b(r, e)), o;
22
+ }, p = (t, e = !1) => {
23
+ const s = t.search(/<svg\b/i);
24
+ if (s !== -1 && t.indexOf("</svg>", s) === -1)
25
+ return [{ type: "markdown", value: t }];
26
+ if (t.match(/<svg[\s\S]*?<\/svg>/i) && e)
27
+ return t.trim().toLowerCase().endsWith("</svg>") ? [{ type: "markdown", value: t }] : [{ type: "markdown", value: `${t}</svg>` }];
28
+ const i = t.search(f), c = x(t);
29
+ if (i === -1 && !c)
30
+ return e && t.trim() ? [{ type: "text", value: t }] : [];
31
+ const l = !!c && (i === -1 || c.start < i), a = l ? c.start : i, d = l ? c.end : v(t, a), o = [], r = t.slice(0, a), h = t.slice(a, d), m = t.slice(d);
32
+ return e && r.trim() && o.push({ type: "text", value: r }), o.push({
33
+ type: l ? "markdown" : "sandbox",
34
+ value: h
35
+ }), m.trim() && o.push(...p(m, e)), o;
31
36
  };
32
37
  export {
33
- b as splitContentSegments
38
+ p as splitContentSegments
34
39
  };
35
40
  //# 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\n// Split incoming markdown content into markdown and sandbox HTML segments\nexport const splitContentSegments = (\n raw: string,\n keepText = false\n): RenderSegment[] => {\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","splitContentSegments","keepText","sandboxStartIndex","inlineMatch","shouldUseInline","segments","before","matchedBlock","after"],"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,GAGaI,IAAuB,CAClCT,GACAU,IAAW,OACS;AACpB,QAAMC,IAAoBX,EAAI,OAAOJ,CAAqB,GACpDgB,IAAcR,EAAuBJ,CAAG;AAE9C,MAAIW,MAAsB,MAAM,CAACC;AAC/B,WAAIF,KAAYV,EAAI,SACX,CAAC,EAAE,MAAM,QAAQ,OAAOA,GAAK,IAE/B,CAAA;AAGT,QAAMa,IACJ,CAAC,CAACD,MACDD,MAAsB,MAAMC,EAAY,QAAQD,IAE7CV,IAAaY,IAAkBD,EAAa,QAAQD,GACpDT,IAAWW,IACbD,EAAa,MACbb,EAAiBC,GAAKC,CAAU,GAE9Ba,IAA4B,CAAA,GAC5BC,IAASf,EAAI,MAAM,GAAGC,CAAU,GAChCe,IAAehB,EAAI,MAAMC,GAAYC,CAAQ,GAC7Ce,IAAQjB,EAAI,MAAME,CAAQ;AAEhC,SAAIQ,KAAYK,EAAO,UACrBD,EAAS,KAAK,EAAE,MAAM,QAAQ,OAAOC,GAAQ,GAG/CD,EAAS,KAAK;AAAA,IACZ,MAAMD,IAAkB,aAAa;AAAA,IACrC,OAAOG;AAAA,EAAA,CACR,GAEGC,EAAM,UACRH,EAAS,KAAK,GAAGL,EAAqBQ,GAAOP,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\n// Split incoming markdown content into markdown and sandbox HTML segments\nexport const splitContentSegments = (\n raw: string,\n keepText = false\n): RenderSegment[] => {\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 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","splitContentSegments","keepText","svgOpenIndex","sandboxStartIndex","inlineMatch","shouldUseInline","segments","before","matchedBlock","after"],"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,GAGaI,IAAuB,CAClCT,GACAU,IAAW,OACS;AACpB,QAAMC,IAAeX,EAAI,OAAO,SAAS;AACzC,MAAIW,MAAiB,MAAMX,EAAI,QAAQ,UAAUW,CAAY,MAAM;AACjE,WAAO,CAAC,EAAE,MAAM,YAAY,OAAOX,GAAK;AAI1C,MADyBA,EAAI,MAAM,sBAAsB,KACjCU;AACtB,WAAKV,EAAI,KAAA,EAAO,cAAc,SAAS,QAAQ,IAGxC,CAAC,EAAE,MAAM,YAAY,OAAOA,GAAK,IAF/B,CAAC,EAAE,MAAM,YAAY,OAAO,GAAGA,CAAG,UAAU;AAKvD,QAAMY,IAAoBZ,EAAI,OAAOJ,CAAqB,GACpDiB,IAAcT,EAAuBJ,CAAG;AAE9C,MAAIY,MAAsB,MAAM,CAACC;AAC/B,WAAIH,KAAYV,EAAI,SACX,CAAC,EAAE,MAAM,QAAQ,OAAOA,GAAK,IAE/B,CAAA;AAGT,QAAMc,IACJ,CAAC,CAACD,MACDD,MAAsB,MAAMC,EAAY,QAAQD,IAE7CX,IAAaa,IAAkBD,EAAa,QAAQD,GACpDV,IAAWY,IACbD,EAAa,MACbd,EAAiBC,GAAKC,CAAU,GAE9Bc,IAA4B,CAAA,GAC5BC,IAAShB,EAAI,MAAM,GAAGC,CAAU,GAChCgB,IAAejB,EAAI,MAAMC,GAAYC,CAAQ,GAC7CgB,IAAQlB,EAAI,MAAME,CAAQ;AAEhC,SAAIQ,KAAYM,EAAO,UACrBD,EAAS,KAAK,EAAE,MAAM,QAAQ,OAAOC,GAAQ,GAG/CD,EAAS,KAAK;AAAA,IACZ,MAAMD,IAAkB,aAAa;AAAA,IACrC,OAAOG;AAAA,EAAA,CACR,GAEGC,EAAM,UACRH,EAAS,KAAK,GAAGN,EAAqBS,GAAOR,CAAQ,CAAC,GAGjDK;AACT;"}
@@ -1,7 +1,7 @@
1
1
  import { j as i } from "../../../_virtual/jsx-runtime.js";
2
2
  import * as d from "react";
3
3
  import n from "../../../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.js";
4
- import "../../../_virtual/index2.js";
4
+ import "../../../_virtual/index4.js";
5
5
  import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
6
6
  import "../../../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/hooks/useLayoutEffect.js";
7
7
  import "../../../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/raf.js";
package/package.json CHANGED
@@ -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.3",
152
+ "version": "0.1.83-beta.5",
153
153
  "type": "module",
154
154
  "exports": {
155
155
  ".": {