markdown-flow-ui 0.1.70-beta.1 → 0.1.71-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js +1 -1
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.js +1 -1
- package/dist/_virtual/index10.js +2 -2
- package/dist/_virtual/index5.js +3 -5
- package/dist/_virtual/index5.js.map +1 -1
- package/dist/_virtual/index6.js +4 -4
- package/dist/_virtual/index7.js +5 -3
- package/dist/_virtual/index7.js.map +1 -1
- package/dist/_virtual/index9.js +2 -2
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +10 -16
- package/dist/components/ContentRender/ContentRender.js +102 -125
- package/dist/components/ContentRender/ContentRender.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.stories.d.ts +1 -12
- package/dist/components/ContentRender/index.d.ts +0 -1
- package/dist/components/ContentRender/plugins/MermaidChart.js +7 -1
- package/dist/components/ContentRender/plugins/MermaidChart.js.map +1 -1
- package/dist/components/ContentRender/utils/mermaid-parse.d.ts +0 -4
- package/dist/components/ContentRender/utils/mermaid-parse.js +65 -112
- package/dist/components/ContentRender/utils/mermaid-parse.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +0 -7
- package/dist/components/MarkdownFlow/MarkdownFlow.js +21 -28
- package/dist/components/MarkdownFlow/MarkdownFlow.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.stories.d.ts +1 -3
- package/dist/components/ui/tooltip.js +2 -2
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/package.json +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/fullscreen.js +0 -19
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/fullscreen.js.map +0 -1
- package/dist/components/ContentRender/ContentBlackboard.d.ts +0 -9
- package/dist/components/ContentRender/ContentBlackboard.js +0 -126
- package/dist/components/ContentRender/ContentBlackboard.js.map +0 -1
- package/dist/components/ContentRender/ContentHtml.d.ts +0 -22
- package/dist/components/ContentRender/ContentHtml.js +0 -108
- package/dist/components/ContentRender/ContentHtml.js.map +0 -1
- package/dist/components/ContentRender/utils/content-html-stream.d.ts +0 -8
- package/dist/components/ContentRender/utils/content-html-stream.js +0 -18
- package/dist/components/ContentRender/utils/content-html-stream.js.map +0 -1
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import e from "../createLucideIcon.js";
|
|
2
|
-
/**
|
|
3
|
-
* @license lucide-react v0.525.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
const a = [
|
|
9
|
-
["path", { d: "M3 7V5a2 2 0 0 1 2-2h2", key: "aa7l1z" }],
|
|
10
|
-
["path", { d: "M17 3h2a2 2 0 0 1 2 2v2", key: "4qcy5o" }],
|
|
11
|
-
["path", { d: "M21 17v2a2 2 0 0 1-2 2h-2", key: "6vwrx8" }],
|
|
12
|
-
["path", { d: "M7 21H5a2 2 0 0 1-2-2v-2", key: "ioqczr" }],
|
|
13
|
-
["rect", { width: "10", height: "8", x: "7", y: "8", rx: "1", key: "vys8me" }]
|
|
14
|
-
], c = e("fullscreen", a);
|
|
15
|
-
export {
|
|
16
|
-
a as __iconNode,
|
|
17
|
-
c as default
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=fullscreen.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fullscreen.js","sources":["../../../../../../../../../../../../node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/fullscreen.js"],"sourcesContent":["/**\n * @license lucide-react v0.525.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M3 7V5a2 2 0 0 1 2-2h2\", key: \"aa7l1z\" }],\n [\"path\", { d: \"M17 3h2a2 2 0 0 1 2 2v2\", key: \"4qcy5o\" }],\n [\"path\", { d: \"M21 17v2a2 2 0 0 1-2 2h-2\", key: \"6vwrx8\" }],\n [\"path\", { d: \"M7 21H5a2 2 0 0 1-2-2v-2\", key: \"ioqczr\" }],\n [\"rect\", { width: \"10\", height: \"8\", x: \"7\", y: \"8\", rx: \"1\", key: \"vys8me\" }]\n];\nconst Fullscreen = createLucideIcon(\"fullscreen\", __iconNode);\n\nexport { __iconNode, Fullscreen as default };\n//# sourceMappingURL=fullscreen.js.map\n"],"names":["__iconNode","Fullscreen","createLucideIcon"],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASK,MAACA,IAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,0BAA0B,KAAK,SAAQ,CAAE;AAAA,EACvD,CAAC,QAAQ,EAAE,GAAG,2BAA2B,KAAK,SAAQ,CAAE;AAAA,EACxD,CAAC,QAAQ,EAAE,GAAG,6BAA6B,KAAK,SAAQ,CAAE;AAAA,EAC1D,CAAC,QAAQ,EAAE,GAAG,4BAA4B,KAAK,SAAQ,CAAE;AAAA,EACzD,CAAC,QAAQ,EAAE,OAAO,MAAM,QAAQ,KAAK,GAAG,KAAK,GAAG,KAAK,IAAI,KAAK,KAAK,SAAQ,CAAE;AAC/E,GACMC,IAAaC,EAAiB,cAAcF,CAAU;","x_google_ignoreList":[0]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
type ContentBlackboardProps = {
|
|
3
|
-
payload?: string;
|
|
4
|
-
renderNarrationAsCaption?: boolean;
|
|
5
|
-
maxVisibleStepNumber?: number;
|
|
6
|
-
visibleStepNumber?: number;
|
|
7
|
-
};
|
|
8
|
-
declare const ContentBlackboard: React.FC<ContentBlackboardProps>;
|
|
9
|
-
export default ContentBlackboard;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { j as f } from "../../_virtual/jsx-runtime.js";
|
|
2
|
-
import { useState as y, useRef as j, useEffect as u, useMemo as w } from "react";
|
|
3
|
-
import { parseContentHtmlStreamChunk as v } from "./utils/content-html-stream.js";
|
|
4
|
-
const k = (o) => o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), I = ({
|
|
5
|
-
payload: o,
|
|
6
|
-
renderNarrationAsCaption: c = !1,
|
|
7
|
-
maxVisibleStepNumber: l,
|
|
8
|
-
visibleStepNumber: i
|
|
9
|
-
}) => {
|
|
10
|
-
const [n, m] = y(
|
|
11
|
-
[]
|
|
12
|
-
), d = j(null);
|
|
13
|
-
u(() => {
|
|
14
|
-
if (typeof o > "u") {
|
|
15
|
-
m([]);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const e = o.trim();
|
|
19
|
-
if (!e) {
|
|
20
|
-
m([]);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const t = v(e);
|
|
24
|
-
t && m((r) => {
|
|
25
|
-
const a = `${t.blockIndex}-${t.stepNumber}`;
|
|
26
|
-
return [
|
|
27
|
-
...r.filter((s) => s.id !== a),
|
|
28
|
-
{
|
|
29
|
-
id: a,
|
|
30
|
-
stepNumber: t.stepNumber,
|
|
31
|
-
html: t.html,
|
|
32
|
-
narration: t.narration
|
|
33
|
-
}
|
|
34
|
-
].sort((s, H) => s.stepNumber - H.stepNumber);
|
|
35
|
-
});
|
|
36
|
-
}, [o]);
|
|
37
|
-
const h = w(() => n.length === 0 ? "" : (typeof i == "number" ? n.filter(
|
|
38
|
-
(t) => t.stepNumber === i
|
|
39
|
-
) : typeof l == "number" ? n.filter(
|
|
40
|
-
(t) => t.stepNumber <= l
|
|
41
|
-
) : n).map((t) => {
|
|
42
|
-
const r = !c && t.narration ? `<p class="content-render-html-stream-narration">${k(
|
|
43
|
-
t.narration
|
|
44
|
-
)}</p>` : "";
|
|
45
|
-
return `${t.html}${r}`;
|
|
46
|
-
}).join(""), [l, c, n]), x = w(() => `
|
|
47
|
-
<!DOCTYPE html>
|
|
48
|
-
<html lang="zh-CN">
|
|
49
|
-
<head>
|
|
50
|
-
<meta charset="UTF-8" />
|
|
51
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
52
|
-
<link
|
|
53
|
-
rel="stylesheet"
|
|
54
|
-
href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css"
|
|
55
|
-
/>
|
|
56
|
-
<style>
|
|
57
|
-
:root { color-scheme: light; }
|
|
58
|
-
body {
|
|
59
|
-
margin: 0;
|
|
60
|
-
padding: 16px;
|
|
61
|
-
color: #0f172a;
|
|
62
|
-
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
63
|
-
line-height: 1.6;
|
|
64
|
-
}
|
|
65
|
-
.content-render-html-stream-narration {
|
|
66
|
-
margin-top: 10px;
|
|
67
|
-
color: #4b5563;
|
|
68
|
-
font-size: 14px;
|
|
69
|
-
}
|
|
70
|
-
</style>
|
|
71
|
-
</head>
|
|
72
|
-
<body>
|
|
73
|
-
<div id="content-container"></div>
|
|
74
|
-
</body>
|
|
75
|
-
</html>
|
|
76
|
-
`.trim(), []), [p, b] = y(!1);
|
|
77
|
-
return u(() => {
|
|
78
|
-
const e = d.current;
|
|
79
|
-
if (!e) return;
|
|
80
|
-
const t = () => {
|
|
81
|
-
b(!0);
|
|
82
|
-
};
|
|
83
|
-
return e.addEventListener("load", t), () => {
|
|
84
|
-
e.removeEventListener("load", t);
|
|
85
|
-
};
|
|
86
|
-
}, []), u(() => {
|
|
87
|
-
if (!p) return;
|
|
88
|
-
const e = d.current;
|
|
89
|
-
if (!e) return;
|
|
90
|
-
const t = e.contentDocument;
|
|
91
|
-
if (!t) return;
|
|
92
|
-
const r = t.getElementById("content-container");
|
|
93
|
-
r && (r.innerHTML = h);
|
|
94
|
-
const a = () => {
|
|
95
|
-
try {
|
|
96
|
-
const s = t.body?.scrollHeight || 0;
|
|
97
|
-
e.style.height = `${Math.max(s, 100)}px`;
|
|
98
|
-
} catch {
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
a();
|
|
102
|
-
const g = window.setTimeout(a, 60);
|
|
103
|
-
return () => {
|
|
104
|
-
window.clearTimeout(g);
|
|
105
|
-
};
|
|
106
|
-
}, [h, p]), /* @__PURE__ */ f.jsxs("div", { className: "content-render-html content-render-html-stream", children: [
|
|
107
|
-
/* @__PURE__ */ f.jsx(
|
|
108
|
-
"iframe",
|
|
109
|
-
{
|
|
110
|
-
ref: d,
|
|
111
|
-
className: "content-render-html-stream-iframe",
|
|
112
|
-
sandbox: "allow-same-origin allow-scripts",
|
|
113
|
-
loading: "lazy",
|
|
114
|
-
title: "content-render-html-stream",
|
|
115
|
-
srcDoc: x
|
|
116
|
-
}
|
|
117
|
-
),
|
|
118
|
-
c && n.length > 0 && /* @__PURE__ */ f.jsx("div", { className: "content-render-html-stream-caption", children: typeof i == "number" && n.find(
|
|
119
|
-
(t) => t.stepNumber === i
|
|
120
|
-
)?.narration || n[n.length - 1].narration })
|
|
121
|
-
] });
|
|
122
|
-
};
|
|
123
|
-
export {
|
|
124
|
-
I as default
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=ContentBlackboard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentBlackboard.js","sources":["../../../src/components/ContentRender/ContentBlackboard.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n ContentHtmlStreamChunk,\n parseContentHtmlStreamChunk,\n} from \"./utils/content-html-stream\";\n\ntype ContentBlackboardProps = {\n payload?: string;\n renderNarrationAsCaption?: boolean;\n maxVisibleStepNumber?: number;\n visibleStepNumber?: number;\n};\n\ntype ContentHtmlStreamStep = {\n id: string;\n stepNumber: number;\n html: string;\n narration?: string;\n};\n\nconst escapeHtml = (value: string) =>\n value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n\nconst ContentBlackboard: React.FC<ContentBlackboardProps> = ({\n payload,\n renderNarrationAsCaption = false,\n maxVisibleStepNumber,\n visibleStepNumber,\n}) => {\n const [streamingSteps, setStreamingSteps] = useState<ContentHtmlStreamStep[]>(\n []\n );\n const iframeRef = useRef<HTMLIFrameElement>(null);\n\n useEffect(() => {\n if (typeof payload === \"undefined\") {\n setStreamingSteps([]);\n return;\n }\n\n const trimmed = payload.trim();\n if (!trimmed) {\n setStreamingSteps([]);\n return;\n }\n\n const chunk: ContentHtmlStreamChunk | null =\n parseContentHtmlStreamChunk(trimmed);\n if (!chunk) return;\n\n setStreamingSteps((prev) => {\n const id = `${chunk.blockIndex}-${chunk.stepNumber}`;\n const filtered = prev.filter((item) => item.id !== id);\n return [\n ...filtered,\n {\n id,\n stepNumber: chunk.stepNumber,\n html: chunk.html,\n narration: chunk.narration,\n },\n ].sort((a, b) => a.stepNumber - b.stepNumber);\n });\n }, [payload]);\n\n const combinedHtml = useMemo(() => {\n if (streamingSteps.length === 0) return \"\";\n const filtered = (() => {\n if (typeof visibleStepNumber === \"number\") {\n return streamingSteps.filter(\n (step) => step.stepNumber === visibleStepNumber\n );\n }\n if (typeof maxVisibleStepNumber === \"number\") {\n return streamingSteps.filter(\n (step) => step.stepNumber <= maxVisibleStepNumber\n );\n }\n return streamingSteps;\n })();\n return filtered\n .map((step) => {\n const narrationHtml =\n !renderNarrationAsCaption && step.narration\n ? `<p class=\"content-render-html-stream-narration\">${escapeHtml(\n step.narration\n )}</p>`\n : \"\";\n return `${step.html}${narrationHtml}`;\n })\n .join(\"\");\n }, [maxVisibleStepNumber, renderNarrationAsCaption, streamingSteps]);\n\n const templateHtml = useMemo(() => {\n return `\n<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <link\n rel=\"stylesheet\"\n href=\"https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css\"\n />\n <style>\n :root { color-scheme: light; }\n body {\n margin: 0;\n padding: 16px;\n color: #0f172a;\n font-family: \"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n line-height: 1.6;\n }\n .content-render-html-stream-narration {\n margin-top: 10px;\n color: #4b5563;\n font-size: 14px;\n }\n </style>\n</head>\n<body>\n <div id=\"content-container\"></div>\n</body>\n</html>\n `.trim();\n }, []);\n\n const [isLoaded, setIsLoaded] = useState(false);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return;\n\n const handleLoad = () => {\n setIsLoaded(true);\n };\n\n iframe.addEventListener(\"load\", handleLoad);\n return () => {\n iframe.removeEventListener(\"load\", handleLoad);\n };\n }, []);\n\n useEffect(() => {\n if (!isLoaded) return;\n const iframe = iframeRef.current;\n if (!iframe) return;\n const doc = iframe.contentDocument;\n if (!doc) return;\n\n const container = doc.getElementById(\"content-container\");\n if (container) {\n container.innerHTML = combinedHtml;\n }\n\n const updateHeight = () => {\n try {\n const height = doc.body?.scrollHeight || 0;\n iframe.style.height = `${Math.max(height, 100)}px`;\n } catch {\n // ignore cross-origin issues\n }\n };\n\n updateHeight();\n // re-measure after a short delay to allow for rendering (e.g. images)\n const timer = window.setTimeout(updateHeight, 60);\n return () => {\n window.clearTimeout(timer);\n };\n }, [combinedHtml, isLoaded]);\n\n return (\n <div className=\"content-render-html content-render-html-stream\">\n <iframe\n ref={iframeRef}\n className=\"content-render-html-stream-iframe\"\n sandbox=\"allow-same-origin allow-scripts\"\n loading=\"lazy\"\n title=\"content-render-html-stream\"\n srcDoc={templateHtml}\n />\n {renderNarrationAsCaption && streamingSteps.length > 0 && (\n <div className=\"content-render-html-stream-caption\">\n {(() => {\n if (typeof visibleStepNumber === \"number\") {\n const target = streamingSteps.find(\n (step) => step.stepNumber === visibleStepNumber\n );\n return (\n target?.narration ||\n streamingSteps[streamingSteps.length - 1].narration\n );\n }\n return streamingSteps[streamingSteps.length - 1].narration;\n })()}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentBlackboard;\n"],"names":["escapeHtml","value","ContentBlackboard","payload","renderNarrationAsCaption","maxVisibleStepNumber","visibleStepNumber","streamingSteps","setStreamingSteps","useState","iframeRef","useRef","useEffect","trimmed","chunk","parseContentHtmlStreamChunk","prev","id","item","a","b","combinedHtml","useMemo","step","narrationHtml","templateHtml","isLoaded","setIsLoaded","iframe","handleLoad","doc","container","updateHeight","height","timer","jsxs","jsx"],"mappings":";;;AAoBA,MAAMA,IAAa,CAACC,MAClBA,EACG,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,OAAO,GAEpBC,IAAsD,CAAC;AAAA,EAC3D,SAAAC;AAAA,EACA,0BAAAC,IAA2B;AAAA,EAC3B,sBAAAC;AAAA,EACA,mBAAAC;AACF,MAAM;AACJ,QAAM,CAACC,GAAgBC,CAAiB,IAAIC;AAAA,IAC1C,CAAA;AAAA,EAAC,GAEGC,IAAYC,EAA0B,IAAI;AAEhD,EAAAC,EAAU,MAAM;AACd,QAAI,OAAOT,IAAY,KAAa;AAClC,MAAAK,EAAkB,CAAA,CAAE;AACpB;AAAA,IACF;AAEA,UAAMK,IAAUV,EAAQ,KAAA;AACxB,QAAI,CAACU,GAAS;AACZ,MAAAL,EAAkB,CAAA,CAAE;AACpB;AAAA,IACF;AAEA,UAAMM,IACJC,EAA4BF,CAAO;AACrC,IAAKC,KAELN,EAAkB,CAACQ,MAAS;AAC1B,YAAMC,IAAK,GAAGH,EAAM,UAAU,IAAIA,EAAM,UAAU;AAElD,aAAO;AAAA,QACL,GAFeE,EAAK,OAAO,CAACE,MAASA,EAAK,OAAOD,CAAE;AAAA,QAGnD;AAAA,UACE,IAAAA;AAAA,UACA,YAAYH,EAAM;AAAA,UAClB,MAAMA,EAAM;AAAA,UACZ,WAAWA,EAAM;AAAA,QAAA;AAAA,MACnB,EACA,KAAK,CAACK,GAAGC,MAAMD,EAAE,aAAaC,EAAE,UAAU;AAAA,IAC9C,CAAC;AAAA,EACH,GAAG,CAACjB,CAAO,CAAC;AAEZ,QAAMkB,IAAeC,EAAQ,MACvB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AMW,IAAe,MAAM;AACzB,UAAI;AACF,cAAMC,IAASH,EAAI,MAAM,gBAAgB;AACzC,QAAAF,EAAO,MAAM,SAAS,GAAG,KAAK,IAAIK,GAAQ,GAAG,CAAC;AAAA,MAChD,QAAQ;AAAA,MAER;AAAA,IACF;AAEA,IAAAD,EAAA;AAEA,UAAME,IAAQ,OAAO,WAAWF,GAAc,EAAE;AAChD,WAAO,MAAM;AACX,aAAO,aAAaE,CAAK;AAAA,IAC3B;AAAA,EACF,GAAG,CAACb,GAAcK,CAAQ,CAAC,GAGzBS,gBAAAA,EAAAA,KAAC,OAAA,EAAI,WAAU,kDACb,UAAA;AAAA,IAAAC,gBAAAA,EAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK1B;AAAA,QACL,WAAU;AAAA,QACV,SAAQ;AAAA,QACR,SAAQ;AAAA,QACR,OAAM;AAAA,QACN,QAAQe;AAAA,MAAA;AAAA,IAAA;AAAA,IAETrB,KAA4BG,EAAe,SAAS,2BAClD,OAAA,EAAI,WAAU,sCACX,UACI,OAAOD,KAAsB,YAChBC,EAAe;AAAA,MAC5B,CAACgB,MAASA,EAAK,eAAejB;AAAA,IAAA,GAGtB,aACRC,EAAeA,EAAe,SAAS,CAAC,EAAE,UAI7C,CACL;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
export type ContentHtmlMeta = {
|
|
3
|
-
title: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
};
|
|
6
|
-
export type ContentHtmlProps = {
|
|
7
|
-
html?: string;
|
|
8
|
-
payload?: string;
|
|
9
|
-
fullscreenButtonText?: string;
|
|
10
|
-
};
|
|
11
|
-
declare const parseContentHtmlMeta: (payload: string) => ContentHtmlMeta | null;
|
|
12
|
-
declare const isLikelyHtmlDocument: (value: string) => boolean;
|
|
13
|
-
declare const HtmlBlockInIframe: React.FC<{
|
|
14
|
-
html: string;
|
|
15
|
-
fullscreenButtonText?: string;
|
|
16
|
-
}>;
|
|
17
|
-
declare const HtmlBlockLoading: React.FC<{
|
|
18
|
-
meta: ContentHtmlMeta;
|
|
19
|
-
}>;
|
|
20
|
-
declare const ContentHtml: React.FC<ContentHtmlProps>;
|
|
21
|
-
export { ContentHtml, HtmlBlockInIframe, HtmlBlockLoading, isLikelyHtmlDocument, parseContentHtmlMeta, };
|
|
22
|
-
export default ContentHtml;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { j as e } from "../../_virtual/jsx-runtime.js";
|
|
2
|
-
import { useState as a, useEffect as h } from "react";
|
|
3
|
-
import f from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/fullscreen.js";
|
|
4
|
-
const p = (n) => {
|
|
5
|
-
try {
|
|
6
|
-
const t = JSON.parse(n), s = t?.title, r = t?.description;
|
|
7
|
-
return typeof s != "string" || s.trim().length === 0 ? null : {
|
|
8
|
-
title: s.trim(),
|
|
9
|
-
description: typeof r == "string" ? r : void 0
|
|
10
|
-
};
|
|
11
|
-
} catch {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
}, x = (n) => {
|
|
15
|
-
const t = n.trim();
|
|
16
|
-
return /^<!doctype html/i.test(t) || /^<html[\s\S]*?>/i.test(t) || /^<head[\s\S]*?>/i.test(t) || /^<body[\s\S]*?>/i.test(t);
|
|
17
|
-
}, m = ({ html: n, fullscreenButtonText: t }) => {
|
|
18
|
-
const s = () => {
|
|
19
|
-
try {
|
|
20
|
-
const r = new Blob([n], { type: "text/html" }), o = URL.createObjectURL(r);
|
|
21
|
-
window.open(o, "_blank", "noopener,noreferrer"), window.setTimeout(() => URL.revokeObjectURL(o), 3e4);
|
|
22
|
-
} catch (r) {
|
|
23
|
-
console.error("Failed to open HTML in new window", r);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
return /* @__PURE__ */ e.jsxs("div", { className: "content-render-html", children: [
|
|
27
|
-
/* @__PURE__ */ e.jsx("div", { className: "content-render-html-toolbar", children: /* @__PURE__ */ e.jsxs(
|
|
28
|
-
"button",
|
|
29
|
-
{
|
|
30
|
-
type: "button",
|
|
31
|
-
className: "content-render-html-fullscreen",
|
|
32
|
-
onClick: s,
|
|
33
|
-
children: [
|
|
34
|
-
/* @__PURE__ */ e.jsx(
|
|
35
|
-
f,
|
|
36
|
-
{
|
|
37
|
-
size: 12,
|
|
38
|
-
className: "content-render-html-fullscreen-icon"
|
|
39
|
-
}
|
|
40
|
-
),
|
|
41
|
-
/* @__PURE__ */ e.jsx("span", { className: "content-render-html-fullscreen-text", children: t || "Fullscreen" })
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
) }),
|
|
45
|
-
/* @__PURE__ */ e.jsx(
|
|
46
|
-
"iframe",
|
|
47
|
-
{
|
|
48
|
-
className: "content-render-html-iframe",
|
|
49
|
-
sandbox: "allow-same-origin allow-scripts",
|
|
50
|
-
loading: "lazy",
|
|
51
|
-
title: "content-render-html",
|
|
52
|
-
srcDoc: n
|
|
53
|
-
}
|
|
54
|
-
)
|
|
55
|
-
] });
|
|
56
|
-
}, j = ({ meta: n }) => /* @__PURE__ */ e.jsx("div", { className: "content-render-html content-render-html-loading", children: /* @__PURE__ */ e.jsxs("div", { className: "content-render-html-loading-body", children: [
|
|
57
|
-
/* @__PURE__ */ e.jsx("p", { className: "content-render-html-loading-title", children: n.title }),
|
|
58
|
-
n.description ? /* @__PURE__ */ e.jsx("p", { className: "content-render-html-loading-description", children: n.description }) : null,
|
|
59
|
-
/* @__PURE__ */ e.jsx("div", { className: "content-render-html-loading-bar", children: /* @__PURE__ */ e.jsx("span", { className: "content-render-html-loading-bar-fill" }) })
|
|
60
|
-
] }) }), N = ({
|
|
61
|
-
html: n,
|
|
62
|
-
payload: t,
|
|
63
|
-
fullscreenButtonText: s
|
|
64
|
-
}) => {
|
|
65
|
-
const [r, o] = a(), [c, l] = a();
|
|
66
|
-
return h(() => {
|
|
67
|
-
if (typeof t > "u") {
|
|
68
|
-
o(void 0), l(void 0);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const i = t.trim();
|
|
72
|
-
if (!i) {
|
|
73
|
-
o(void 0), l(void 0);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const d = p(i);
|
|
77
|
-
if (d) {
|
|
78
|
-
o(d), l(void 0);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (x(i)) {
|
|
82
|
-
l(i), o((u) => u);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
o(void 0), l(void 0);
|
|
86
|
-
}, [t]), n ? /* @__PURE__ */ e.jsx(
|
|
87
|
-
m,
|
|
88
|
-
{
|
|
89
|
-
html: n,
|
|
90
|
-
fullscreenButtonText: s
|
|
91
|
-
}
|
|
92
|
-
) : typeof t > "u" ? null : c ? /* @__PURE__ */ e.jsx(
|
|
93
|
-
m,
|
|
94
|
-
{
|
|
95
|
-
html: c,
|
|
96
|
-
fullscreenButtonText: s
|
|
97
|
-
}
|
|
98
|
-
) : r ? /* @__PURE__ */ e.jsx(j, { meta: r }) : null;
|
|
99
|
-
};
|
|
100
|
-
export {
|
|
101
|
-
N as ContentHtml,
|
|
102
|
-
m as HtmlBlockInIframe,
|
|
103
|
-
j as HtmlBlockLoading,
|
|
104
|
-
N as default,
|
|
105
|
-
x as isLikelyHtmlDocument,
|
|
106
|
-
p as parseContentHtmlMeta
|
|
107
|
-
};
|
|
108
|
-
//# sourceMappingURL=ContentHtml.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentHtml.js","sources":["../../../src/components/ContentRender/ContentHtml.tsx"],"sourcesContent":["import { Fullscreen } from \"lucide-react\";\nimport React, { useEffect, useState } from \"react\";\n\nexport type ContentHtmlMeta = {\n title: string;\n description?: string;\n};\n\nexport type ContentHtmlProps = {\n html?: string;\n payload?: string;\n fullscreenButtonText?: string;\n};\n\nconst parseContentHtmlMeta = (payload: string): ContentHtmlMeta | null => {\n try {\n const parsed = JSON.parse(payload);\n const maybeTitle = parsed?.title;\n const maybeDescription = parsed?.description;\n if (typeof maybeTitle !== \"string\" || maybeTitle.trim().length === 0) {\n return null;\n }\n return {\n title: maybeTitle.trim(),\n description:\n typeof maybeDescription === \"string\" ? maybeDescription : undefined,\n };\n } catch {\n return null;\n }\n};\n\nconst isLikelyHtmlDocument = (value: string) => {\n const trimmed = value.trim();\n return (\n /^<!doctype html/i.test(trimmed) ||\n /^<html[\\s\\S]*?>/i.test(trimmed) ||\n /^<head[\\s\\S]*?>/i.test(trimmed) ||\n /^<body[\\s\\S]*?>/i.test(trimmed)\n );\n};\n\nconst HtmlBlockInIframe: React.FC<{\n html: string;\n fullscreenButtonText?: string;\n}> = ({ html, fullscreenButtonText }) => {\n const handleOpenFullscreen = () => {\n try {\n const blob = new Blob([html], { type: \"text/html\" });\n const url = URL.createObjectURL(blob);\n window.open(url, \"_blank\", \"noopener,noreferrer\");\n window.setTimeout(() => URL.revokeObjectURL(url), 30000);\n } catch (error) {\n console.error(\"Failed to open HTML in new window\", error);\n }\n };\n\n return (\n <div className=\"content-render-html\">\n <div className=\"content-render-html-toolbar\">\n <button\n type=\"button\"\n className=\"content-render-html-fullscreen\"\n onClick={handleOpenFullscreen}\n >\n <Fullscreen\n size={12}\n className=\"content-render-html-fullscreen-icon\"\n />\n <span className=\"content-render-html-fullscreen-text\">\n {fullscreenButtonText || \"Fullscreen\"}\n </span>\n </button>\n </div>\n <iframe\n className=\"content-render-html-iframe\"\n sandbox=\"allow-same-origin allow-scripts\"\n loading=\"lazy\"\n title=\"content-render-html\"\n srcDoc={html}\n />\n </div>\n );\n};\n\nconst HtmlBlockLoading: React.FC<{ meta: ContentHtmlMeta }> = ({ meta }) => {\n return (\n <div className=\"content-render-html content-render-html-loading\">\n <div className=\"content-render-html-loading-body\">\n <p className=\"content-render-html-loading-title\">{meta.title}</p>\n {meta.description ? (\n <p className=\"content-render-html-loading-description\">\n {meta.description}\n </p>\n ) : null}\n <div className=\"content-render-html-loading-bar\">\n <span className=\"content-render-html-loading-bar-fill\" />\n </div>\n </div>\n </div>\n );\n};\n\nconst ContentHtml: React.FC<ContentHtmlProps> = ({\n html,\n payload,\n fullscreenButtonText,\n}) => {\n const [meta, setMeta] = useState<ContentHtmlMeta>();\n const [documentHtml, setDocumentHtml] = useState<string>();\n\n useEffect(() => {\n if (typeof payload === \"undefined\") {\n setMeta(undefined);\n setDocumentHtml(undefined);\n return;\n }\n\n const trimmedPayload = payload.trim();\n if (!trimmedPayload) {\n setMeta(undefined);\n setDocumentHtml(undefined);\n return;\n }\n\n const parsedMeta = parseContentHtmlMeta(trimmedPayload);\n if (parsedMeta) {\n setMeta(parsedMeta);\n setDocumentHtml(undefined);\n return;\n }\n\n if (isLikelyHtmlDocument(trimmedPayload)) {\n setDocumentHtml(trimmedPayload);\n setMeta((prev) => prev);\n return;\n }\n\n setMeta(undefined);\n setDocumentHtml(undefined);\n }, [payload]);\n\n if (html) {\n return (\n <HtmlBlockInIframe\n html={html}\n fullscreenButtonText={fullscreenButtonText}\n />\n );\n }\n\n if (typeof payload === \"undefined\") {\n return null;\n }\n\n if (documentHtml) {\n return (\n <HtmlBlockInIframe\n html={documentHtml}\n fullscreenButtonText={fullscreenButtonText}\n />\n );\n }\n\n if (meta) {\n return <HtmlBlockLoading meta={meta} />;\n }\n\n return null;\n};\n\nexport {\n ContentHtml,\n HtmlBlockInIframe,\n HtmlBlockLoading,\n isLikelyHtmlDocument,\n parseContentHtmlMeta,\n};\n\nexport default ContentHtml;\n"],"names":["parseContentHtmlMeta","payload","parsed","maybeTitle","maybeDescription","isLikelyHtmlDocument","value","trimmed","HtmlBlockInIframe","html","fullscreenButtonText","handleOpenFullscreen","blob","url","error","jsxs","jsx","Fullscreen","HtmlBlockLoading","meta","ContentHtml","setMeta","useState","documentHtml","setDocumentHtml","useEffect","trimmedPayload","parsedMeta","prev"],"mapp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d,MAAAN,EAAQM,CAAU,GAClBH,EAAgB,MAAS;AACzB;AAAA,IACF;AAEA,QAAInB,EAAqBqB,CAAc,GAAG;AACxC,MAAAF,EAAgBE,CAAc,GAC9BL,EAAQ,CAACO,MAASA,CAAI;AACtB;AAAA,IACF;AAEA,IAAAP,EAAQ,MAAS,GACjBG,EAAgB,MAAS;AAAA,EAC3B,GAAG,CAACvB,CAAO,CAAC,GAERQ,IAEAO,gBAAAA,EAAAA;AAAAA,IAACR;AAAA,IAAA;AAAA,MACC,MAAAC;AAAA,MACA,sBAAAC;AAAA,IAAA;AAAA,EAAA,IAKF,OAAOT,IAAY,MACd,OAGLsB,IAEAP,gBAAAA,EAAAA;AAAAA,IAACR;AAAA,IAAA;AAAA,MACC,MAAMe;AAAA,MACN,sBAAAb;AAAA,IAAA;AAAA,EAAA,IAKFS,IACKH,gBAAAA,MAACE,KAAiB,MAAAC,GAAY,IAGhC;AACT;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const p = (c) => {
|
|
2
|
-
try {
|
|
3
|
-
const n = JSON.parse(c), e = typeof n == "object" && n !== null ? n : null, t = typeof e?.data == "object" && e?.data !== null ? e.data : e, r = t?.html, o = t?.narration, a = t?.step_number ?? t?.stepNumber, s = t?.is_complete ?? t?.isComplete, l = t?.block_index ?? t?.blockIndex ?? 0;
|
|
4
|
-
return typeof r != "string" || typeof a != "number" || typeof s != "boolean" || typeof l != "number" ? null : {
|
|
5
|
-
html: r,
|
|
6
|
-
narration: typeof o == "string" && o.trim() ? o : void 0,
|
|
7
|
-
stepNumber: a,
|
|
8
|
-
isComplete: s,
|
|
9
|
-
blockIndex: l
|
|
10
|
-
};
|
|
11
|
-
} catch {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
p as parseContentHtmlStreamChunk
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=content-html-stream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-html-stream.js","sources":["../../../../src/components/ContentRender/utils/content-html-stream.ts"],"sourcesContent":["export type ContentHtmlStreamChunk = {\n html: string;\n narration?: string;\n stepNumber: number;\n isComplete: boolean;\n blockIndex: number;\n};\n\nexport const parseContentHtmlStreamChunk = (\n payload: string\n): ContentHtmlStreamChunk | null => {\n try {\n const parsed = JSON.parse(payload);\n const source =\n typeof parsed === \"object\" && parsed !== null ? parsed : null;\n const maybeData =\n typeof source?.data === \"object\" && source?.data !== null\n ? source.data\n : source;\n\n const html = maybeData?.html;\n const narration = maybeData?.narration;\n const stepNumber = maybeData?.step_number ?? maybeData?.stepNumber;\n const isComplete = maybeData?.is_complete ?? maybeData?.isComplete;\n const blockIndex = maybeData?.block_index ?? maybeData?.blockIndex ?? 0;\n\n if (\n typeof html !== \"string\" ||\n typeof stepNumber !== \"number\" ||\n typeof isComplete !== \"boolean\" ||\n typeof blockIndex !== \"number\"\n ) {\n return null;\n }\n\n return {\n html,\n narration:\n typeof narration === \"string\" && narration.trim()\n ? narration\n : undefined,\n stepNumber,\n isComplete,\n blockIndex,\n };\n } catch {\n return null;\n }\n};\n"],"names":["parseContentHtmlStreamChunk","payload","parsed","source","maybeData","html","narration","stepNumber","isComplete","blockIndex"],"mappings":"AAQO,MAAMA,IAA8B,CACzCC,MACkC;AAClC,MAAI;AACF,UAAMC,IAAS,KAAK,MAAMD,CAAO,GAC3BE,IACJ,OAAOD,KAAW,YAAYA,MAAW,OAAOA,IAAS,MACrDE,IACJ,OAAOD,GAAQ,QAAS,YAAYA,GAAQ,SAAS,OACjDA,EAAO,OACPA,GAEAE,IAAOD,GAAW,MAClBE,IAAYF,GAAW,WACvBG,IAAaH,GAAW,eAAeA,GAAW,YAClDI,IAAaJ,GAAW,eAAeA,GAAW,YAClDK,IAAaL,GAAW,eAAeA,GAAW,cAAc;AAEtE,WACE,OAAOC,KAAS,YAChB,OAAOE,KAAe,YACtB,OAAOC,KAAe,aACtB,OAAOC,KAAe,WAEf,OAGF;AAAA,MACL,MAAAJ;AAAA,MACA,WACE,OAAOC,KAAc,YAAYA,EAAU,KAAA,IACvCA,IACA;AAAA,MACN,YAAAC;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,IAAA;AAAA,EAEJ,QAAQ;AACN,WAAO;AAAA,EACT;AACF;"}
|