markdown-flow-ui 0.1.120 → 0.1.121
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/_virtual/index.cjs11.js +1 -1
- package/dist/_virtual/index.cjs12.js +1 -1
- package/dist/_virtual/index.cjs4.js +1 -1
- package/dist/_virtual/index.cjs5.js +1 -1
- package/dist/_virtual/index.cjs6.js +1 -1
- package/dist/_virtual/index.cjs8.js +1 -1
- package/dist/_virtual/index.cjs9.js +1 -1
- package/dist/_virtual/index.es10.js +2 -2
- package/dist/_virtual/index.es11.js +3 -3
- package/dist/_virtual/index.es12.js +2 -2
- package/dist/_virtual/index.es4.js +4 -4
- package/dist/_virtual/index.es5.js +4 -4
- package/dist/_virtual/index.es6.js +5 -5
- package/dist/_virtual/index.es8.js +3 -2
- package/dist/_virtual/index.es8.js.map +1 -1
- package/dist/_virtual/index.es9.js +2 -3
- package/dist/_virtual/index.es9.js.map +1 -1
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +10 -1
- package/dist/components/ContentRender/ContentRender.es.js +221 -175
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.stories.d.ts +1 -3
- package/dist/components/ContentRender/index.d.ts +1 -2
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +0 -3
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js +21 -29
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs.js +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.es.js +50 -51
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/utils/runStreamFixture.d.ts +2 -0
- package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/package.json +2 -3
- package/dist/components/ContentRender/useTypewriter.d.ts +0 -19
- package/dist/components/ContentRender/useTypewriterStateMachine.cjs.js +0 -2
- package/dist/components/ContentRender/useTypewriterStateMachine.cjs.js.map +0 -1
- package/dist/components/ContentRender/useTypewriterStateMachine.d.ts +0 -19
- package/dist/components/ContentRender/useTypewriterStateMachine.es.js +0 -180
- package/dist/components/ContentRender/useTypewriterStateMachine.es.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentRender.es.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport React, { useEffect, useMemo, useRef } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport { stripSvgTextLineBreaks } from \"./utils/strip-svg-text-line-breaks\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport CodeBlock from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart from \"./plugins/MermaidChart\";\nimport useTypewriterStateMachine from \"./useTypewriterStateMachine\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\n\nconst SANDBOX_TAG_HINT_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\\b/i;\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n /**\n * Callback invoked when the custom button after content is clicked.\n * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n * @example\n * ```tsx\n * <ContentRender\n * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n * />\n * ```\n */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n userInput?: string;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n onTypeFinished?: () => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Disable sandbox loading overlays when upper layers have already entered an error state\n disableSandboxLoadingOverlay?: boolean;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n const cleanedSvg = stripSvgTextLineBreaks(svg);\n template.innerHTML = cleanedSvg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\nconst remarkPlugins = [remarkGfm, remarkMath, remarkFlow, remarkBreaks];\n\nconst rehypePlugins = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n);\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n customRenderBar,\n onSend,\n typingSpeed = 30,\n enableTypewriter = false,\n userInput,\n interactionDefaultValueOptions,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n onTypeFinished,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n disableSandboxLoadingOverlay = false,\n sandboxFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(content),\n [content]\n );\n\n const interactionDefaults = useMemo(\n () =>\n getInteractionDefaultValues(\n content,\n userInput,\n interactionDefaultValueOptions\n ),\n [content, interactionDefaultValueOptions, userInput]\n );\n\n const resolvedDefaultButtonText =\n defaultButtonText?.trim() || interactionDefaults.buttonText;\n const resolvedDefaultInputText =\n defaultInputText?.trim() || interactionDefaults.inputText;\n const fallbackSelectedValues = useMemo(\n () =>\n userInput\n ? userInput\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined,\n [userInput]\n );\n const resolvedDefaultSelectedValues = defaultSelectedValues?.length\n ? defaultSelectedValues\n : interactionDefaults.selectedValues || fallbackSelectedValues;\n\n // Use custom Hook to handle typewriter effect\n const components: CustomComponents = {\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={onClickCustomButtonAfterContent}\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={readonly}\n defaultButtonText={resolvedDefaultButtonText}\n defaultInputText={resolvedDefaultInputText}\n defaultSelectedValues={resolvedDefaultSelectedValues}\n onSend={onSend}\n beforeSend={beforeSend}\n confirmButtonText={confirmButtonText}\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: (props) => {\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(content, chartContent);\n return <MermaidChart chart={chartContent} frozen={frozen} />;\n }\n\n return (\n <code className={className} {...rest}>\n {children}\n </code>\n );\n },\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n />\n ),\n };\n\n const { displayContent, isComplete } = useTypewriterStateMachine({\n // processMarkdownText will let code block printf(\"You win!\\n\") become printf(\"You win!<br/>\");\n // content: processMarkdownText(content),\n content: normalizedContent,\n typingSpeed,\n disabled: !enableTypewriter,\n });\n // Render the full content synchronously when typewriter is disabled\n // to avoid a first-paint flash where content appears after helper actions.\n const resolvedDisplayContent = enableTypewriter\n ? displayContent\n : normalizedContent;\n\n const hasPotentialSandboxTags = useMemo(\n () => SANDBOX_TAG_HINT_PATTERN.test(content),\n [content]\n );\n\n const renderSegments = useMemo(\n () => (hasPotentialSandboxTags ? splitContentSegments(content, true) : []),\n [content, hasPotentialSandboxTags]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(resolvedDisplayContent),\n [resolvedDisplayContent]\n );\n\n const hasCompleted = useRef(false);\n\n useEffect(() => {\n if (hasSandbox) return;\n if (isComplete && !hasCompleted.current) {\n hasCompleted.current = true; // Mark as completed\n onTypeFinished?.(); // Call the passed callback\n }\n }, [hasSandbox, isComplete, onTypeFinished]);\n\n useEffect(() => {\n if (hasSandbox) return;\n hasCompleted.current = false; // Reset completion status when content changes\n }, [hasSandbox, content]);\n\n const renderMarkdownSegments = (raw: string, keyPrefix: string) => {\n const normalized = normalizeInlineHtml(raw);\n const parsed = parseMarkdownSegments(normalized);\n\n return parsed.map((seg, index) => {\n const key = `${keyPrefix}-${seg.type}-${index}`;\n\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={key}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart key={key} chart={seg.value} frozen={!seg.complete} />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div className=\"content-render markdown-body\">\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n type=\"sandbox\"\n content={segment.value}\n className=\"content-render-iframe\"\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n disableLoadingOverlay={disableSandboxLoadingOverlay}\n fullScreenButtonText={sandboxFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render markdown-body\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={index}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SANDBOX_TAG_HINT_PATTERN","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","mergeNonSandboxSegments","segments","merged","segment","last","ContentRender","content","customRenderBar","onSend","typingSpeed","enableTypewriter","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","onTypeFinished","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","normalizedContent","useMemo","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","children","props","CustomButtonInputVariable","className","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","displayContent","isComplete","useTypewriterStateMachine","resolvedDisplayContent","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","hasCompleted","renderMarkdownSegments","raw","keyPrefix","seg","index","key","idx","IframeSandbox","React","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAMA,KACJ,mGAoDIC,IAA8C,CAAC,EAAE,KAAAC,QAAU;AAC/D,QAAMC,IAAUC,EAAuB,IAAI;AAE3C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,EAAQ;AACrB,QAAI,CAACG,EAAM;AACX,UAAMC,IAAaD,EAAK,cAAcA,EAAK,aAAa,EAAE,MAAM,QAAQ,GAClEE,IAAU;AAChB,QAAIC,IAAUF,EAAW,eAAeC,CAAO;AAE/C,IAAKC,MACHA,IAAU,SAAS,cAAc,OAAO,GACxCA,EAAQ,KAAKD,GAEbC,EAAQ,cAAc;AAAA;AAAA;AAAA;AAAA,SAKtBF,EAAW,YAAYE,CAAO,IAGV,MAAM,KAAKF,EAAW,UAAU,EAAE;AAAA,MACtD,CAACG,MAASA,MAASD;AAAA,IAAA,EAEP,QAAQ,CAACC,MAASH,EAAW,YAAYG,CAAI,CAAC;AAE5D,UAAMC,IAAW,SAAS,cAAc,UAAU,GAC5CC,IAAaC,GAAuBX,CAAG;AAC7C,IAAAS,EAAS,YAAYC,GACrBL,EAAW,OAAOI,EAAS,QAAQ,UAAU,EAAI,CAAC;AAElD,QAAIG,IAAmB,IACnBC,IAAc;AAElB,IAAAR,EAAW,iBAAiB,KAAK,EAAE,QAAQ,CAACS,MAAU;AAEpD,YAAMC,IAAUD,EAAM,aAAa,SAAS;AAC5C,UAAI,CAACC,EAAS;AAEd,YAAMC,IAAaD,EAChB,KAAA,EACA,MAAM,QAAQ,EACd,IAAI,CAACE,MAAU,OAAOA,CAAK,CAAC;AAE/B,UAAID,EAAW,WAAW,KAAKA,EAAW,KAAK,OAAO,KAAK,EAAG;AAE9D,YA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EAAI;AAAA,UAAA;AAAA,UAFRC;AAAA,QAAA;AAOX,UAAID,EAAI,SAAS;AACf,eACEjF,gBAAAA,EAAAA;AAAAA,UAACiE;AAAA,UAAA;AAAA,YAEC,OAAOgB,EAAI;AAAA,YACX,QAAQ,CAACA,EAAI;AAAA,UAAA;AAAA,UAFRC;AAAA,QAAA;AAOX,UAAID,EAAI,SAAS;AACf,eAAOjF,gBAAAA,EAAAA,IAAClC,GAAA,EAA6B,KAAKmH,EAAI,SAAhBC,CAAuB;AAAA,IAEzD,CAAC;AAAA,IAEAxD,KACC1B,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,6BACZ,UAAAsF,EAAM,cAAc5D,GAAiB;AAAA,MACpC,SAAAD;AAAA,MACA,gBAAA0C;AAAA,MACA,QAAAxC;AAAA,IAAA,CACD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ContentRender.es.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport { stripSvgTextLineBreaks } from \"./utils/strip-svg-text-line-breaks\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport CodeBlock from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart from \"./plugins/MermaidChart\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\n\nconst SANDBOX_TAG_HINT_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\\b/i;\n\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n contentType?: string;\n /**\n * Callback invoked when the custom button after content is clicked.\n * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n * @example\n * ```tsx\n * <ContentRender\n * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n * />\n * ```\n */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onTypeFinished?: () => void;\n onTypewriterStateChange?: (state: ContentRenderTypewriterState) => void;\n userInput?: string;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Disable sandbox loading overlays when upper layers have already entered an error state\n disableSandboxLoadingOverlay?: boolean;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\nexport interface ContentRenderTypewriterState {\n isTypewriterEnabled: boolean;\n isTyping: boolean;\n isComplete: boolean;\n renderedLength: number;\n totalLength: number;\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n const cleanedSvg = stripSvgTextLineBreaks(svg);\n template.innerHTML = cleanedSvg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\nconst remarkPlugins = [remarkGfm, remarkMath, remarkFlow, remarkBreaks];\n\nconst rehypePlugins = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n);\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst splitTextByCharacterChunk = (value: string, chunkSize: number) => {\n const safeChunkSize = Math.max(1, chunkSize);\n const characters = Array.from(value);\n\n return {\n chunk: characters.slice(0, safeChunkSize).join(\"\"),\n rest: characters.slice(safeChunkSize).join(\"\"),\n };\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n customRenderBar,\n onSend,\n typingSpeed = 40,\n enableTypewriter = false,\n onTypeFinished,\n onTypewriterStateChange,\n userInput,\n interactionDefaultValueOptions,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n disableSandboxLoadingOverlay = false,\n sandboxFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const shouldApplyTypewriterByContentType =\n !contentType || contentType === \"text\";\n const isTypewriterEnabled =\n Boolean(enableTypewriter) && shouldApplyTypewriterByContentType;\n const typewriterChunkSize = 2;\n const typewriterTickMs = Math.max(0, typingSpeed);\n const [displayContent, setDisplayContent] = useState(() =>\n isTypewriterEnabled ? \"\" : content\n );\n const pendingContentRef = useRef(\"\");\n const previousTypewriterEnabledRef = useRef(isTypewriterEnabled);\n const hasReportedTypeFinishedRef = useRef(false);\n\n useEffect(() => {\n const wasTypewriterEnabled = previousTypewriterEnabledRef.current;\n previousTypewriterEnabledRef.current = isTypewriterEnabled;\n hasReportedTypeFinishedRef.current = false;\n\n if (!isTypewriterEnabled) {\n pendingContentRef.current = \"\";\n setDisplayContent(content);\n return;\n }\n\n setDisplayContent((current) => {\n const shouldRestartTyping = !wasTypewriterEnabled;\n const canContinueTyping = content.startsWith(current);\n\n if (!shouldRestartTyping && !canContinueTyping) {\n pendingContentRef.current = \"\";\n return content;\n }\n\n const nextVisibleContent =\n shouldRestartTyping || !canContinueTyping ? \"\" : current;\n\n pendingContentRef.current = content.slice(nextVisibleContent.length);\n return nextVisibleContent;\n });\n }, [content, isTypewriterEnabled]);\n\n useEffect(() => {\n if (!isTypewriterEnabled) {\n return;\n }\n\n if (\n hasReportedTypeFinishedRef.current ||\n pendingContentRef.current ||\n displayContent !== content\n ) {\n return;\n }\n\n hasReportedTypeFinishedRef.current = true;\n onTypeFinished?.();\n }, [content, displayContent, isTypewriterEnabled, onTypeFinished]);\n\n useEffect(() => {\n if (!isTypewriterEnabled || !pendingContentRef.current) {\n return undefined;\n }\n\n const typewriterTimer = window.setTimeout(() => {\n setDisplayContent((current) => {\n const { chunk, rest } = splitTextByCharacterChunk(\n pendingContentRef.current,\n typewriterChunkSize\n );\n\n if (!chunk) {\n return current;\n }\n\n pendingContentRef.current = rest;\n return `${current}${chunk}`;\n });\n }, typewriterTickMs);\n\n return () => window.clearTimeout(typewriterTimer);\n }, [\n content,\n displayContent,\n isTypewriterEnabled,\n typewriterChunkSize,\n typewriterTickMs,\n ]);\n\n const typewriterState = useMemo<ContentRenderTypewriterState>(\n () => ({\n isTypewriterEnabled,\n isTyping: isTypewriterEnabled && displayContent !== content,\n isComplete: displayContent === content,\n renderedLength: displayContent.length,\n totalLength: content.length,\n }),\n [content, displayContent, isTypewriterEnabled]\n );\n\n useEffect(() => {\n onTypewriterStateChange?.(typewriterState);\n }, [onTypewriterStateChange, typewriterState]);\n\n const renderContent = isTypewriterEnabled ? displayContent : content;\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(renderContent),\n [renderContent]\n );\n\n const interactionDefaults = useMemo(\n () =>\n getInteractionDefaultValues(\n renderContent,\n userInput,\n interactionDefaultValueOptions\n ),\n [interactionDefaultValueOptions, renderContent, userInput]\n );\n\n const resolvedDefaultButtonText =\n defaultButtonText?.trim() || interactionDefaults.buttonText;\n const resolvedDefaultInputText =\n defaultInputText?.trim() || interactionDefaults.inputText;\n const fallbackSelectedValues = useMemo(\n () =>\n userInput\n ? userInput\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined,\n [userInput]\n );\n const resolvedDefaultSelectedValues = defaultSelectedValues?.length\n ? defaultSelectedValues\n : interactionDefaults.selectedValues || fallbackSelectedValues;\n\n const components: CustomComponents = {\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={onClickCustomButtonAfterContent}\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={readonly}\n defaultButtonText={resolvedDefaultButtonText}\n defaultInputText={resolvedDefaultInputText}\n defaultSelectedValues={resolvedDefaultSelectedValues}\n onSend={onSend}\n beforeSend={beforeSend}\n confirmButtonText={confirmButtonText}\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: (props) => {\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(renderContent, chartContent);\n return <MermaidChart chart={chartContent} frozen={frozen} />;\n }\n\n return (\n <code className={className} {...rest}>\n {children}\n </code>\n );\n },\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n />\n ),\n };\n\n const hasPotentialSandboxTags = useMemo(\n () => SANDBOX_TAG_HINT_PATTERN.test(renderContent),\n [renderContent]\n );\n\n const renderSegments = useMemo(\n () =>\n hasPotentialSandboxTags ? splitContentSegments(renderContent, true) : [],\n [renderContent, hasPotentialSandboxTags]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(normalizedContent),\n [normalizedContent]\n );\n\n const renderMarkdownSegments = (raw: string, keyPrefix: string) => {\n const normalized = normalizeInlineHtml(raw);\n const parsed = parseMarkdownSegments(normalized);\n\n return parsed.map((seg, index) => {\n const key = `${keyPrefix}-${seg.type}-${index}`;\n\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={key}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart key={key} chart={seg.value} frozen={!seg.complete} />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div className=\"content-render markdown-body\">\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n type=\"sandbox\"\n content={segment.value}\n className=\"content-render-iframe\"\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n disableLoadingOverlay={disableSandboxLoadingOverlay}\n fullScreenButtonText={sandboxFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render markdown-body\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={index}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent: normalizedContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SANDBOX_TAG_HINT_PATTERN","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","ContentRender","content","contentType","customRenderBar","onSend","typingSpeed","enableTypewriter","onTypeFinished","onTypewriterStateChange","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","isTypewriterEnabled","typewriterChunkSize","typewriterTickMs","displayContent","setDisplayContent","useState","pendingContentRef","previousTypewriterEnabledRef","hasReportedTypeFinishedRef","wasTypewriterEnabled","current","shouldRestartTyping","canContinueTyping","nextVisibleContent","typewriterTimer","chunk","rest","typewriterState","useMemo","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","children","props","CustomButtonInputVariable","className","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","index","key","idx","IframeSandbox","React","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAMA,KACJ,mGA+DIC,KAA8C,CAAC,EAAE,KAAAC,QAAU;AAC/D,QAAMC,IAAUC,EAAuB,IAAI;AAE3C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,EAAQ;AACrB,QAAI,CAACG,EAAM;AACX,UAAMC,IAAaD,EAAK,cAAcA,EAAK,aAAa,EAAE,MAAM,QAAQ,GAClEE,IAAU;AAChB,QAAIC,IAAUF,EAAW,eAAeC,CAAO;AAE/C,IAAKC,MACHA,IAAU,SAAS,cAAc,OAAO,GACxCA,EAAQ,KAAKD,GAEbC,EAAQ,cAAc;AAAA;AAAA;AAAA;AAAA,SAKtBF,EAAW,YAAYE,CAAO,IAGV,MAAM,KAAKF,EAAW,UAAU,EAAE;AAAA,MACtD,CAACG,MAASA,MAASD;AAAA,IAAA,EAEP,QAAQ,CAACC,MAASH,EAAW,YAAYG,CAAI,CAAC;AAE5D,UAAMC,IAAW,SAAS,cAAc,UAAU,GAC5CC,IAAaC,GAAuBX,CAAG;AAC7C,IAAAS,E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/B,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,6BACZ,UAAAyG,EAAM,cAAc1E,GAAiB;AAAA,MACpC,SAAAF;AAAA,MACA,gBAAgB6C;AAAA,MAChB,QAAA1C;AAAA,IAAA,CACD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -19,14 +19,11 @@ declare const meta: {
|
|
|
19
19
|
export default meta;
|
|
20
20
|
type Story = StoryObj<typeof meta>;
|
|
21
21
|
export declare const ComprehensiveMarkdownSyntax: Story;
|
|
22
|
-
export declare const MarkdownSyntaxWithTypewriter: Story;
|
|
23
22
|
export declare const MathAndMermaidDemo: Story;
|
|
24
|
-
export declare const MermaidWithTypewriter: Story;
|
|
25
23
|
export declare const ContentRenderMathAndMermaid: Story;
|
|
26
24
|
export declare const CustomButtonAfterContentDemo: Story;
|
|
27
25
|
export declare const MermaidErrorHandlingTest: Story;
|
|
28
26
|
export declare const MultiSelectExamples: Story;
|
|
29
|
-
export declare const MultiSelectWithTypewriter: Story;
|
|
30
27
|
export declare const InteractiveMultiSelectDemo: Story;
|
|
31
28
|
export declare const ChineseMultiSelectDemo: Story;
|
|
32
29
|
export declare const NativeHtmlElements: Story;
|
|
@@ -36,3 +33,4 @@ export declare const SVGDemo: Story;
|
|
|
36
33
|
export declare const HTMLDemo: Story;
|
|
37
34
|
export declare const HTMLDemoIframeOnly: Story;
|
|
38
35
|
export declare const ReadingModeAppendedAskBlocks: Story;
|
|
36
|
+
export declare const TypewriterStreamingChineseText: Story;
|
|
@@ -6,7 +6,6 @@ export type { SandboxAppProps } from './SandboxApp';
|
|
|
6
6
|
export type { RenderSegment } from './utils/split-content';
|
|
7
7
|
export { splitContentSegments } from './utils/split-content';
|
|
8
8
|
export { default as ContentRender } from './ContentRender';
|
|
9
|
+
export type { ContentRenderProps } from './ContentRender';
|
|
9
10
|
export { default as MarkdownFlowInput } from './MarkdownFlowInput';
|
|
10
|
-
export { default as useTypewriter } from './useTypewriter';
|
|
11
|
-
export { default as useTypewriterStateMachine } from './useTypewriterStateMachine';
|
|
12
11
|
export type { MarkdownFlowInputProps } from './MarkdownFlowInput';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js"),x=require("../ContentRender/ContentRender.cjs.js");require("react");require("react-dom/client");require("../ui/inputGroup/input-group.cjs.js");;/* empty css */const p=({initialContentList:r=[],customRenderBar:u,onSend:s,confirmButtonText:d,copyButtonText:i,copiedButtonText:a,beforeSend:n,interactionDefaultValueOptions:l})=>t.jsxRuntimeExports.jsx("div",{className:"markdown-flow",children:r.map((e,o)=>{const m=e.isFinished??!1?void 0:s,c=n??(()=>!0);return t.jsxRuntimeExports.jsx(x.default,{content:e.content,userInput:e.userInput,defaultInputText:e.defaultInputText,defaultButtonText:e.defaultButtonText,defaultSelectedValues:e.defaultSelectedValues,readonly:e.readonly,customRenderBar:e.customRenderBar||u,onSend:m,beforeSend:c,interactionDefaultValueOptions:l,onClickCustomButtonAfterContent:e.onClickCustomButtonAfterContent,confirmButtonText:d,copyButtonText:i,copiedButtonText:a,dynamicInteractionFormat:e.dynamicInteractionFormat},o)})});exports.default=p;
|
|
2
2
|
//# sourceMappingURL=MarkdownFlow.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownFlow.cjs.js","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport ContentRender from \"../ContentRender\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport \"./markdownFlow.css\";\n\nexport interface MarkdownFlowProps {\n initialContentList?: {\n content: string;\n isFinished?: boolean;\n userInput?: string;\n defaultInputText?: string;\n defaultButtonText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n
|
|
1
|
+
{"version":3,"file":"MarkdownFlow.cjs.js","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport ContentRender from \"../ContentRender\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport \"./markdownFlow.css\";\n\nexport interface MarkdownFlowProps {\n initialContentList?: {\n content: string;\n isFinished?: boolean;\n userInput?: string;\n defaultInputText?: string;\n defaultButtonText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text for code blocks\n copyButtonText?: string;\n // Copied state text for code blocks\n copiedButtonText?: string;\n beforeSend?: (content: OnSendContentParams) => boolean;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n}\n\nconst MarkdownFlow: React.FC<MarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend: onSendProp,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n interactionDefaultValueOptions,\n}) => {\n return (\n <div className=\"markdown-flow\">\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const onSend = isFinished ? undefined : onSendProp;\n const beforeSend = beforeSendProp ?? (() => true);\n return (\n <ContentRender\n key={index}\n content={contentInfo.content}\n userInput={contentInfo.userInput}\n defaultInputText={contentInfo.defaultInputText}\n defaultButtonText={contentInfo.defaultButtonText}\n defaultSelectedValues={contentInfo.defaultSelectedValues}\n readonly={contentInfo.readonly}\n customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n beforeSend={beforeSend}\n interactionDefaultValueOptions={interactionDefaultValueOptions}\n onClickCustomButtonAfterContent={\n contentInfo.onClickCustomButtonAfterContent\n }\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n dynamicInteractionFormat={contentInfo.dynamicInteractionFormat}\n />\n );\n })}\n </div>\n );\n};\n\nexport default MarkdownFlow;\n"],"names":["MarkdownFlow","initialContentList","customRenderBar","onSendProp","confirmButtonText","copyButtonText","copiedButtonText","beforeSendProp","interactionDefaultValueOptions","jsx","contentInfo","index","onSend","beforeSend","ContentRender"],"mappings":"qVA+BA,MAAMA,EAA4C,CAAC,CACjD,mBAAAC,EAAqB,CAAA,EACrB,gBAAAC,EACA,OAAQC,EACR,kBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,WAAYC,EACZ,+BAAAC,CACF,IAEIC,wBAAC,OAAI,UAAU,gBACZ,WAAmB,IAAI,CAACC,EAAaC,IAAU,CAE9C,MAAMC,EADaF,EAAY,YAAc,GACjB,OAAYP,EAClCU,EAAaN,IAAmB,IAAM,IAC5C,OACEE,EAAAA,kBAAAA,IAACK,EAAAA,QAAA,CAEC,QAASJ,EAAY,QACrB,UAAWA,EAAY,UACvB,iBAAkBA,EAAY,iBAC9B,kBAAmBA,EAAY,kBAC/B,sBAAuBA,EAAY,sBACnC,SAAUA,EAAY,SACtB,gBAAiBA,EAAY,iBAAmBR,EAChD,OAAAU,EACA,WAAAC,EACA,+BAAAL,EACA,gCACEE,EAAY,gCAEd,kBAAAN,EACA,eAAAC,EACA,iBAAAC,EACA,yBAA0BI,EAAY,wBAAA,EAjBjCC,CAAA,CAoBX,CAAC,CAAA,CACH"}
|
|
@@ -16,9 +16,6 @@ export interface MarkdownFlowProps {
|
|
|
16
16
|
}[];
|
|
17
17
|
customRenderBar?: CustomRenderBarProps;
|
|
18
18
|
onSend?: (content: OnSendContentParams) => void;
|
|
19
|
-
typingSpeed?: number;
|
|
20
|
-
enableTypewriter?: boolean;
|
|
21
|
-
onBlockComplete?: (blockIndex: number) => void;
|
|
22
19
|
confirmButtonText?: string;
|
|
23
20
|
copyButtonText?: string;
|
|
24
21
|
copiedButtonText?: string;
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import
|
|
1
|
+
import { j as t } from "../../_virtual/jsx-runtime.es.js";
|
|
2
|
+
import c from "../ContentRender/ContentRender.es.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "react-dom/client";
|
|
5
5
|
import "../ui/inputGroup/input-group.es.js";
|
|
6
6
|
/* empty css */
|
|
7
7
|
const j = ({
|
|
8
|
-
initialContentList:
|
|
8
|
+
initialContentList: r = [],
|
|
9
9
|
customRenderBar: d,
|
|
10
|
-
onSend:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const t = e.isFinished ?? !1, x = !t && i, S = t ? void 0 : n, f = t ? void 0 : s, B = c ?? (() => !0);
|
|
21
|
-
return /* @__PURE__ */ o.jsx(
|
|
22
|
-
C,
|
|
10
|
+
onSend: a,
|
|
11
|
+
confirmButtonText: s,
|
|
12
|
+
copyButtonText: u,
|
|
13
|
+
copiedButtonText: o,
|
|
14
|
+
beforeSend: i,
|
|
15
|
+
interactionDefaultValueOptions: n
|
|
16
|
+
}) => /* @__PURE__ */ t.jsx("div", { className: "markdown-flow", children: r.map((e, l) => {
|
|
17
|
+
const m = e.isFinished ?? !1 ? void 0 : a, p = i ?? (() => !0);
|
|
18
|
+
return /* @__PURE__ */ t.jsx(
|
|
19
|
+
c,
|
|
23
20
|
{
|
|
24
21
|
content: e.content,
|
|
25
22
|
userInput: e.userInput,
|
|
@@ -27,22 +24,17 @@ const j = ({
|
|
|
27
24
|
defaultButtonText: e.defaultButtonText,
|
|
28
25
|
defaultSelectedValues: e.defaultSelectedValues,
|
|
29
26
|
readonly: e.readonly,
|
|
30
|
-
enableTypewriter: x,
|
|
31
27
|
customRenderBar: e.customRenderBar || d,
|
|
32
|
-
onSend:
|
|
33
|
-
beforeSend:
|
|
34
|
-
interactionDefaultValueOptions:
|
|
28
|
+
onSend: m,
|
|
29
|
+
beforeSend: p,
|
|
30
|
+
interactionDefaultValueOptions: n,
|
|
35
31
|
onClickCustomButtonAfterContent: e.onClickCustomButtonAfterContent,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
dynamicInteractionFormat: e.dynamicInteractionFormat,
|
|
41
|
-
onTypeFinished: () => {
|
|
42
|
-
u?.(r);
|
|
43
|
-
}
|
|
32
|
+
confirmButtonText: s,
|
|
33
|
+
copyButtonText: u,
|
|
34
|
+
copiedButtonText: o,
|
|
35
|
+
dynamicInteractionFormat: e.dynamicInteractionFormat
|
|
44
36
|
},
|
|
45
|
-
|
|
37
|
+
l
|
|
46
38
|
);
|
|
47
39
|
}) });
|
|
48
40
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownFlow.es.js","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport ContentRender from \"../ContentRender\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport \"./markdownFlow.css\";\n\nexport interface MarkdownFlowProps {\n initialContentList?: {\n content: string;\n isFinished?: boolean;\n userInput?: string;\n defaultInputText?: string;\n defaultButtonText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n
|
|
1
|
+
{"version":3,"file":"MarkdownFlow.es.js","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport ContentRender from \"../ContentRender\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport \"./markdownFlow.css\";\n\nexport interface MarkdownFlowProps {\n initialContentList?: {\n content: string;\n isFinished?: boolean;\n userInput?: string;\n defaultInputText?: string;\n defaultButtonText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text for code blocks\n copyButtonText?: string;\n // Copied state text for code blocks\n copiedButtonText?: string;\n beforeSend?: (content: OnSendContentParams) => boolean;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n}\n\nconst MarkdownFlow: React.FC<MarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend: onSendProp,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n interactionDefaultValueOptions,\n}) => {\n return (\n <div className=\"markdown-flow\">\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const onSend = isFinished ? undefined : onSendProp;\n const beforeSend = beforeSendProp ?? (() => true);\n return (\n <ContentRender\n key={index}\n content={contentInfo.content}\n userInput={contentInfo.userInput}\n defaultInputText={contentInfo.defaultInputText}\n defaultButtonText={contentInfo.defaultButtonText}\n defaultSelectedValues={contentInfo.defaultSelectedValues}\n readonly={contentInfo.readonly}\n customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n beforeSend={beforeSend}\n interactionDefaultValueOptions={interactionDefaultValueOptions}\n onClickCustomButtonAfterContent={\n contentInfo.onClickCustomButtonAfterContent\n }\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n dynamicInteractionFormat={contentInfo.dynamicInteractionFormat}\n />\n );\n })}\n </div>\n );\n};\n\nexport default MarkdownFlow;\n"],"names":["MarkdownFlow","initialContentList","customRenderBar","onSendProp","confirmButtonText","copyButtonText","copiedButtonText","beforeSendProp","interactionDefaultValueOptions","jsx","contentInfo","index","onSend","beforeSend","ContentRender"],"mappings":";;;;;;AA+BA,MAAMA,IAA4C,CAAC;AAAA,EACjD,oBAAAC,IAAqB,CAAA;AAAA,EACrB,iBAAAC;AAAA,EACA,QAAQC;AAAA,EACR,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,gCAAAC;AACF,MAEIC,gBAAAA,MAAC,SAAI,WAAU,iBACZ,YAAmB,IAAI,CAACC,GAAaC,MAAU;AAE9C,QAAMC,IADaF,EAAY,cAAc,KACjB,SAAYP,GAClCU,IAAaN,MAAmB,MAAM;AAC5C,SACEE,gBAAAA,EAAAA;AAAAA,IAACK;AAAA,IAAA;AAAA,MAEC,SAASJ,EAAY;AAAA,MACrB,WAAWA,EAAY;AAAA,MACvB,kBAAkBA,EAAY;AAAA,MAC9B,mBAAmBA,EAAY;AAAA,MAC/B,uBAAuBA,EAAY;AAAA,MACnC,UAAUA,EAAY;AAAA,MACtB,iBAAiBA,EAAY,mBAAmBR;AAAA,MAChD,QAAAU;AAAA,MACA,YAAAC;AAAA,MACA,gCAAAL;AAAA,MACA,iCACEE,EAAY;AAAA,MAEd,mBAAAN;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,0BAA0BI,EAAY;AAAA,IAAA;AAAA,IAjBjCC;AAAA,EAAA;AAoBX,CAAC,EAAA,CACH;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),fn=require("../../lib/sandboxInteraction.cjs.js"),z=require("../../lib/utils.cjs.js"),mn=require("../ui/loading-overlay-card.cjs.js"),pn=require("../ContentRender/ContentRender.cjs.js"),St=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");const yt=require("../../lib/interaction-defaults.cjs.js"),Se=require("../../lib/mobileDevice.cjs.js"),hn=require("./Player.cjs.js"),xn=require("./SubtitleOverlay.cjs.js"),bn=require("./useSlide.cjs.js"),vn=require("./useWakePlayerFromIframe.cjs.js"),le=require("./utils/mobileScreenMode.cjs.js"),En=require("./utils/interactionPlayback.cjs.js"),Sn=require("./utils/appendedMarkerAdvance.cjs.js"),yn=require("./utils/playbackSequence.cjs.js"),gt=require("./utils/playerCustomActions.cjs.js"),gn=require("./utils/playbackTimeStore.cjs.js"),An=require("./utils/playerToggleMode.cjs.js");;/* empty css */const Rn=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs.js"),In=2e3,wn=300,_n=160,Cn=16,qe="waitingForAudio",At={waitingForAudio:"Waiting for current slide audio...",loadingAudio:"Loading current slide audio...",waitingForMoreAudio:"Waiting for more current slide audio..."},Mn=(h,E)=>typeof h=="string"?h:h[E]??h[qe]??At[E],kn=(h,E)=>E?h!=="loadingAudio":!1,Rt=t.memo(({content:h,title:E,defaultButtonText:S,defaultInputText:$,defaultSelectedValues:y,confirmButtonText:N,copyButtonText:Y,copiedButtonText:ye,onSend:ge,readonly:q=!1})=>r.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[r.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:r.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:E})}),r.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:r.jsxRuntimeExports.jsx(pn.default,{content:h,defaultButtonText:S,defaultInputText:$,defaultSelectedValues:y,confirmButtonText:N,copyButtonText:Y,copiedButtonText:ye,onSend:ge,readonly:q,enableTypewriter:!1,sandboxMode:"content"})})]}));Rt.displayName="InteractionOverlayCard";const Tn=(h,E)=>h.length===E.length&&h.every((S,$)=>{const y=E[$];return S.sequence_number===y?.sequence_number&&S.type===y?.type&&S.content===y?.content}),Pn=({elementList:h=[],showPlayer:E=!0,playerAlwaysVisible:S=!1,playerClassName:$,fullscreenHeader:y,playerCustomActions:N,playerCustomActionPauseOnActive:Y=!0,bufferingText:ye=At,interactionTitle:ge,interactionTexts:q,playerTexts:It,playerAutoHideDelay:Ae=3e3,markerAutoAdvanceDelay:Oe=In,interactionDefaultValueOptions:ie,onSend:Le,onPlayerVisibilityChange:Re,onMobileViewModeChange:Ve,onStepChange:De,enableIframeScaling:wt=!0,disableLoadingOverlay:R=!1,className:_t,onPointerDown:Ke,...Ct})=>{const ce=t.useRef(null),Ue=t.useRef(null),Ie=t.useRef(null),We=t.useRef(null),X=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),Z=t.useRef(null),Ge=t.useRef(null),He=t.useRef([]),ae=t.useRef(!1),O=t.useRef(null),ze=t.useRef(null),$e=t.useRef({markerCount:0,currentIndex:-1,canGoNext:!1}),{currentElementList:k,stepElementLists:Ye,slideElementList:T,currentIndex:c,audioList:d,currentAudioSequenceIndexes:de,currentStepHasSpeakableElement:x,currentInteractionElement:i,canGoPrev:Mt,canGoNext:v,handlePrev:Xe,handleNext:I}=bn.default(h),ee=t.useMemo(()=>{if(!(c<0))return T[c]},[c,T]),kt=T.filter(e=>e.is_renderable!==!1).length===1,g=E&&(T.length>0||d.length>0||!!i),w=t.useMemo(()=>de.map(e=>d[e]?.audioKey).filter(e=>!!e),[d,de]),[Je,fe]=t.useState(!0),[me,te]=t.useState(!1),[ne,Qe]=t.useState(!0),[f,L]=t.useState(null),[Tt,m]=t.useState(!1),[Pt,we]=t.useState(qe),[_,Ze]=t.useState(!1),[jt,_e]=t.useState(!1),[et,Ft]=t.useState(!0),[Ce,Me]=t.useState(!1),[s,ke]=t.useState(),[pe,he]=t.useState(!1),[Bt,re]=t.useState(0),[tt,Nt]=t.useState(!1),P=t.useMemo(()=>Se.isMobileDevice(),[]),[xe,Te]=t.useState(le.DEFAULT_MOBILE_VIEW_MODE),[nt,Pe]=t.useState(!1),[qt,rt]=t.useState(()=>P?Se.isLandscapeViewport():!1),V=t.useMemo(()=>gn.createPlaybackTimeStore(),[]),{effectiveMobileViewMode:D,isImmersiveMobileFullscreen:K,isNativeMobileFullscreen:st,shouldRotateFullscreenViewport:Ot}=t.useMemo(()=>le.resolveMobileViewModeState({hasManualMobileViewMode:nt,isMobileDevice:P,mobileViewMode:xe}),[nt,P,qt,xe]),Lt=t.useRef(D),C=g&&(S||Je),Vt=K&&C,Dt=K&&C,Kt=K||st,ot=tt&&!P,Ut=t.useCallback(e=>{Pe(!0),Te(e)},[]),ut=t.useCallback(()=>{Pe(!1),Te(le.DEFAULT_MOBILE_VIEW_MODE)},[]),Wt=t.useCallback(()=>{ut(),y?.onBack?.()},[y,ut]),lt=t.useCallback(e=>{Me(e)},[]),it=t.useCallback(()=>{Me(e=>!e)},[]),{mountedStepStates:Gt,currentMountedStateIndex:Ht}=t.useMemo(()=>{const e=[],n=new Map;return Ye.forEach((u,a)=>{const o=e.findIndex(l=>Tn(l.elementList,u));if(o>=0){e[o]?.sourceStepIndexes.push(a),n.set(a,o);return}e.push({elementList:u,sourceStepIndexes:[a]}),n.set(a,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:c>=0?n.get(c)??-1:-1}},[c,Ye]),ct=t.useMemo(()=>String(c),[c]),p=t.useMemo(()=>f?d.findIndex(e=>(e.audioKey??"")===f):-1,[d,f]),je=t.useMemo(()=>p>=0?d[p]:void 0,[d,p]),zt=je?.element?.subtitle_cues??[],be=t.useMemo(()=>w[0]??"none",[w]),Fe=t.useMemo(()=>({currentElement:gt.resolvePlayerCustomActionElement({currentAudioIndex:p,currentAudioSequenceIndexes:de,audioList:d,currentInteractionElement:s,currentStepElement:ee}),currentIndex:c,currentStepElement:ee,isActive:Ce,setActive:lt,toggleActive:it}),[s,d,p,de,c,ee,Ce,lt,it]),Be=t.useMemo(()=>gt.getPlayerCustomActionCount(N,Fe),[Fe,N]),$t=t.useMemo(()=>({"--slide-player-custom-action-count":String(Be),"--slide-player-mobile-control-count":String(Be+4)}),[Be]),at=w.length>0,dt=t.useMemo(()=>i?`${i.sequence_number??"none"}:${String(i.content??"")}`:"none",[i]),se=t.useMemo(()=>[ct,dt].join("|"),[dt,ct]),Yt=t.useMemo(()=>[se,je?.audioKey??"none",String(p)].join("|"),[p,je?.audioKey,se]),ft=!!t.useMemo(()=>!be||be==="none"?"":d.find(n=>n.audioKey===be)?.audioUrl?.trim()??"",[d,be]),F=Y&&!!N&&Ce,oe=t.useMemo(()=>An.shouldUseAutoAdvanceToggle({canGoNext:v,currentAudioIndex:p,currentStepHasSpeakableElement:x,hasInteraction:!!i}),[v,p,i,x]),B=t.useCallback(()=>{X.current!==null&&(window.clearTimeout(X.current),X.current=null)},[]),j=t.useCallback(()=>{Q.current!==null&&(window.clearTimeout(Q.current),Q.current=null)},[]),M=t.useCallback(()=>{Z.current!==null&&(window.clearTimeout(Z.current),Z.current=null)},[]),U=t.useCallback(()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},[]),W=t.useCallback(()=>{U(),j(),M(),L(null),V.reset(),m(!1),we(qe),Ze(!1),_e(!1),ke(void 0),he(!1),re(0)},[U,j,M,V]),G=t.useCallback(()=>{const e=w[0];return e?(L(e),!0):!1},[w]),ve=t.useCallback(()=>{j(),M(),he(!1),re(0),!G()&&v&&I()},[v,j,M,I,G]),mt=t.useCallback(e=>{if(M(),!e)return;const n=()=>{Z.current=null,re(_n),he(!0),O.current=null};Z.current=window.setTimeout(n,wn)},[M]),b=t.useCallback((e=me)=>{g&&(fe(!0),B(),!(S||!e||Ae<=0)&&(X.current=window.setTimeout(()=>{fe(!1),X.current=null},Ae)))},[B,me,S,Ae,g]),ue=!!(i?.readonly||i?.user_input?.trim()),H=!!i&&!ue;t.useEffect(()=>{Qe(!0),Y&&Me(!1)},[c,Y]),t.useEffect(()=>()=>{U(),B(),j(),M()},[U,j,M,B]),t.useEffect(()=>(Re?.(C),()=>{Re?.(!1)}),[Re,C]),t.useEffect(()=>{P||xe===le.DEFAULT_MOBILE_VIEW_MODE||(Pe(!1),Te(le.DEFAULT_MOBILE_VIEW_MODE))},[P,xe]),t.useEffect(()=>{if(!P){rt(!1);return}const e=()=>{rt(Se.isLandscapeViewport())};return e(),Se.subscribeMobileDeviceChange(e)},[P]),t.useEffect(()=>{Ve?.(D)},[D,Ve]),t.useEffect(()=>{Lt.current=D},[D]),t.useEffect(()=>{De?.(ee,c)},[c,ee,De]),t.useEffect(()=>{const e=$e.current,n=Sn.shouldAutoAdvanceIntoAppendedMarker({previousMarkerCount:e.markerCount,nextMarkerCount:T.length,previousIndex:e.currentIndex,previousCanGoNext:e.canGoNext,nextCanGoNext:v,currentAudioKey:f,hasCompletedCurrentStepAudio:_,hasResolvedCurrentInteraction:ue,currentStepHasSpeakableElement:x,currentInteractionElement:i,isAutoAdvanceEnabled:ne,shouldUseSilentStepAutoAdvanceToggle:oe});$e.current={markerCount:T.length,currentIndex:c,canGoNext:v},n&&I()},[v,f,c,i,x,I,_,ue,ne,oe,T.length]),t.useEffect(()=>{if(!g){B(),fe(!1);return}if(S){B(),fe(!0);return}me||b(!0)},[B,me,S,g,b]),t.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.origin===window.location.origin&&fn.isSandboxInteractionMessage(n.data)&&n.data.eventType==="click"&&g&&(te(!0),b(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[g,b]),vn.default({sectionRef:ce,enabled:g,onWake:()=>{te(!0),b(!0)}}),t.useEffect(()=>{const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:n}=yn.getPlaybackSequenceTransition({previousResetKey:ze.current,nextResetKey:se,currentAudioKey:f,hasCompletedCurrentStepAudio:_});ze.current=se;const u=O.current===c&&!!i,a=En.shouldPresentInteractionOverlay({hasInteraction:!!i,shouldBlockPlaybackForInteraction:H,shouldOpenInteractionOverlayAfterAudio:u,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:ue,currentStepHasSpeakableElement:x});if(e&&W(),!(k.length===0&&!i)&&!F){if(i&&ke(i),a){mt(i);return}if(M(),O.current=null,!!n&&!G()){if(x){if(R){m(!1);return}m(!0);return}if(v&&!(oe&&!ne))return J.current=window.setTimeout(()=>{J.current=null,I()},Oe),()=>{U()}}}},[v,U,k.length,i,f,se,x,Oe,I,_,R,ne,ue,H,M,W,mt,G,F,oe]),t.useEffect(()=>{if(R||F||!x||H){m(!1);return}if(_){m(!1);return}if(at){m(!1);return}we("waitingForAudio"),m(!0)},[at,x,_,R,F,H]),t.useEffect(()=>{f||w.length===0||F||!x||H||_||G()},[f,w,x,_,F,H,G]),t.useEffect(()=>{!f||p>=0||L(null)},[p,f]),t.useEffect(()=>{p>=0||V.reset()},[p,V]),t.useEffect(()=>{_e(!1)},[Yt]);const pt=t.useMemo(()=>{if(!s)return{};const e=!!s.user_input?.trim();return yt.getInteractionDefaultValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:ie)},[s,ie]),Xt=t.useMemo(()=>{if(!s)return;const e=!!s.user_input?.trim();return yt.getInteractionDefaultSelectedValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:ie)},[s,ie]),ht=!!s?.user_input?.trim(),xt=!!s?.readonly||ht,bt=xt||ht,Ne=!!s&&pe,Jt=t.useCallback(e=>{const u=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");ke(a=>!a||!u?a:{...a,user_input:u}),Le?.(e,s),ve()},[s,ve,Le]);t.useEffect(()=>{const e=()=>{Nt(document.fullscreenElement===ce.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{if(!Ne){re(0);return}const e=Ge.current;if(!e)return;const n=()=>{const a=Math.ceil(e.getBoundingClientRect().height);re(a+Cn)};if(n(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(()=>{n()});return u.observe(e),()=>{u.disconnect()}},[Ne]),t.useEffect(()=>{if(j(),!(!pe||!bt))return Q.current=window.setTimeout(()=>{Q.current=null,ve()},2e3),()=>{j()}},[j,ve,pe,bt]);const Qt=(e,n={})=>e?e.type==="slot"?r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?r.jsxRuntimeExports.jsx(St.default,{className:"content-render-iframe",disableLoadingOverlay:R,hideFullScreen:!0,mode:"blackboard",replaceRootScreenHeightWithFull:n.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content,enableScaling:wt}):r.jsxRuntimeExports.jsx(St.default,{className:"content-render-iframe",disableLoadingOverlay:R,hideFullScreen:!0,mode:"blackboard",type:"markdown",content:e.content}):null,Zt=(e=[],n=!1)=>{if(e.length===0)return null;const u=e.filter(o=>o.is_renderable!==!1).length,a=e.reduce((o,l,A)=>l.is_renderable!==!1?A:o,-1);return r.jsxRuntimeExports.jsx("div",{className:"slide-stage__content flex w-full flex-col gap-4",children:e.map((o,l)=>{const A=o.type==="html"&&o.is_renderable===!1;return r.jsxRuntimeExports.jsx("div",{ref:n&&l===a?We:null,"aria-hidden":A||void 0,className:z.cn("w-full shrink-0",u===1&&o.is_renderable!==!1&&"slide-element--single",A?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:Qt(o,{replaceRootScreenHeightWithFull:u===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${l}`)})})},en=t.useCallback(()=>{const e=ce.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),vt=t.useCallback(()=>{const e=Ie.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),tn=t.useCallback(()=>{ae.current=!0,O.current=null,te(!0),m(!1),b(!0),W(),Xe()},[Xe,W,b]),nn=t.useCallback(()=>{ae.current=!0,O.current=null,te(!0),m(!1),b(!0),W(),I()},[I,W,b]),rn=t.useCallback(({loading:e,reason:n})=>{if(R){m(!1);return}if(!x||_){m(!1);return}e&&n&&we(n),m(kn(n,e))},[x,_,R]);t.useEffect(()=>{R&&m(!1)},[R]);const sn=t.useCallback(e=>{const n=d[e]?.audioKey;if(!n||!f||n!==f)return;const u=w.findIndex(l=>l===n);if(u<0){L(null);return}const a=u+1,o=w[a];if(o){L(o);return}if(L(null),Ze(!0),m(!1),v){const l=c+1,A=T[l];ft&&A?.type==="interaction"&&(O.current=l),I();return}},[d,v,c,f,w,I,ft,T]),on=t.useCallback(()=>{s&&he(e=>!e)},[s]),Et=t.useCallback(e=>{e.stopPropagation(),C&&b(!0)},[Je,b]),un=t.useCallback(e=>{Ke?.(e)},[Ke]),ln=t.useCallback(()=>{te(!0),b(!0)},[b]),Ee=t.useMemo(()=>k.map((e,n)=>`${e.sequence_number??`${e.type}-${n}`}:${String(e.is_new??"")}`),[k]);return t.useEffect(()=>{const e=He.current,a=(e.length>0&&e.length<Ee.length&&e.every((l,A)=>l===Ee[A])?k.slice(e.length):[]).some(l=>l.is_new===!1);if(He.current=Ee,!a)return;const o=window.requestAnimationFrame(()=>{const l=Ie.current,A=We.current;if(!l||!A)return;const cn=l.getBoundingClientRect(),an=A.getBoundingClientRect(),dn=l.scrollTop+(an.top-cn.top);l.scrollTo({top:Math.max(dn,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(o)}},[k,Ee]),t.useEffect(()=>{if(!ae.current||(ae.current=!1,k.length===0))return;const e=window.requestAnimationFrame(()=>{vt()});return()=>{window.cancelAnimationFrame(e)}},[k,vt]),r.jsxRuntimeExports.jsxs("section",{ref:ce,className:z.cn("relative h-full w-full",P&&"slide--mobile-device",ot&&"slide--browser-fullscreen",K&&"slide--mobile-landscape",st&&"slide--mobile-landscape-native",_t),onClick:ln,onPointerDown:un,...Ct,children:[Kt?r.jsxRuntimeExports.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,r.jsxRuntimeExports.jsxs("div",{ref:Ue,className:z.cn("slide__viewport relative h-full min-h-0 w-full",K&&"slide__viewport--mobile-landscape",K&&!Ot&&"slide__viewport--mobile-landscape-native"),children:[Vt?r.jsxRuntimeExports.jsxs("div",{className:"slide-landscape-header",children:[r.jsxRuntimeExports.jsx("button",{"aria-label":y?.backAriaLabel??"Back",className:"slide-landscape-header__back",onClick:Wt,type:"button",children:r.jsxRuntimeExports.jsx(Rn.default,{className:"slide-landscape-header__icon h-6 w-6",strokeWidth:2.25})}),y?.content?r.jsxRuntimeExports.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:y.content}):null]}):null,r.jsxRuntimeExports.jsx("div",{className:z.cn("h-full min-h-0 w-full",Dt&&"slide__viewport-content--with-header",kt?"slide-content--single":"grid gap-4"),children:k.length>0?r.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:r.jsxRuntimeExports.jsx("div",{ref:Ie,className:"slide-stage__layer w-full",children:Gt.map((e,n)=>{const u=n===Ht;return r.jsxRuntimeExports.jsx("div",{"aria-hidden":!u||void 0,className:"w-full h-full",style:{display:u?void 0:"none"},children:Zt(e.elementList,u)},e.sourceStepIndexes[0]??n)})})}):null}),Tt?r.jsxRuntimeExports.jsx(mn.default,{message:Mn(ye,Pt),className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,r.jsxRuntimeExports.jsx(xn.default,{extraBottomOffset:Bt,hasPlayerGap:C,isEnabled:et&&jt,isPlayerHidden:g&&!C,playbackTimeStore:V,subtitleCues:zt}),Ne?r.jsxRuntimeExports.jsx("div",{ref:Ge,className:z.cn("slide-interaction-overlay",C&&g?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone"),onClick:Et,onPointerDown:Et,style:$t,children:r.jsxRuntimeExports.jsx(Rt,{content:String(s?.content??""),defaultButtonText:pt.buttonText??"",defaultInputText:pt.inputText??"",defaultSelectedValues:Xt,confirmButtonText:q?.confirmButtonText,copyButtonText:q?.copyButtonText,copiedButtonText:q?.copiedButtonText,onSend:Jt,readonly:xt,title:q?.title??ge??"Submit the content below to continue."})}):null,g?r.jsxRuntimeExports.jsx(hn.default,{audioList:d,className:z.cn("absolute left-1/2 z-[2] -translate-x-1/2",ot?"bottom-3":"-bottom-3",$,!C&&"pointer-events-none opacity-0"),currentAudioIndex:p,defaultPlaying:!0,isPlaybackPaused:F,isAutoAdvanceEnabled:ne,hasInteraction:!!s,isInteractionOpen:pe,isSubtitleEnabled:et,onAutoAdvanceToggle:Qe,onLoadingChange:rn,onPlaybackStarted:()=>{_e(!0)},onPlaybackTimeChange:V.setTime,onSubtitleToggle:()=>{Ft(e=>!e)},nextDisabled:!v,onEnded:sn,onFullscreen:en,isFullscreen:tt,mobileViewMode:D,settingsPortalContainer:Ue.current,onMobileViewModeChange:Ut,onInteractionToggle:on,onNext:nn,onPrev:tn,prevDisabled:!Mt,showControls:C,texts:It,customActionContext:Fe,customActions:N,useAutoAdvanceToggle:oe}):null]})]})};exports.default=Pn;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),fn=require("../../lib/sandboxInteraction.cjs.js"),z=require("../../lib/utils.cjs.js"),mn=require("../ui/loading-overlay-card.cjs.js"),pn=require("../ContentRender/ContentRender.cjs.js"),St=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");const yt=require("../../lib/interaction-defaults.cjs.js"),Se=require("../../lib/mobileDevice.cjs.js"),hn=require("./Player.cjs.js"),xn=require("./SubtitleOverlay.cjs.js"),bn=require("./useSlide.cjs.js"),vn=require("./useWakePlayerFromIframe.cjs.js"),le=require("./utils/mobileScreenMode.cjs.js"),En=require("./utils/interactionPlayback.cjs.js"),Sn=require("./utils/appendedMarkerAdvance.cjs.js"),yn=require("./utils/playbackSequence.cjs.js"),gt=require("./utils/playerCustomActions.cjs.js"),gn=require("./utils/playbackTimeStore.cjs.js"),An=require("./utils/playerToggleMode.cjs.js");;/* empty css */const Rn=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs.js"),In=2e3,wn=300,_n=160,Cn=16,qe="waitingForAudio",At={waitingForAudio:"Waiting for current slide audio...",loadingAudio:"Loading current slide audio...",waitingForMoreAudio:"Waiting for more current slide audio..."},Mn=(h,E)=>typeof h=="string"?h:h[E]??h[qe]??At[E],kn=(h,E)=>E?h!=="loadingAudio":!1,Rt=t.memo(({content:h,title:E,defaultButtonText:S,defaultInputText:$,defaultSelectedValues:y,confirmButtonText:N,copyButtonText:Y,copiedButtonText:ye,onSend:ge,readonly:q=!1})=>r.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[r.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:r.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:E})}),r.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:r.jsxRuntimeExports.jsx(pn.default,{content:h,defaultButtonText:S,defaultInputText:$,defaultSelectedValues:y,confirmButtonText:N,copyButtonText:Y,copiedButtonText:ye,onSend:ge,readonly:q,sandboxMode:"content"})})]}));Rt.displayName="InteractionOverlayCard";const Tn=(h,E)=>h.length===E.length&&h.every((S,$)=>{const y=E[$];return S.sequence_number===y?.sequence_number&&S.type===y?.type&&S.content===y?.content}),Pn=({elementList:h=[],showPlayer:E=!0,playerAlwaysVisible:S=!1,playerClassName:$,fullscreenHeader:y,playerCustomActions:N,playerCustomActionPauseOnActive:Y=!0,bufferingText:ye=At,interactionTitle:ge,interactionTexts:q,playerTexts:It,playerAutoHideDelay:Ae=3e3,markerAutoAdvanceDelay:Oe=In,interactionDefaultValueOptions:ie,onSend:Le,onPlayerVisibilityChange:Re,onMobileViewModeChange:Ve,onStepChange:De,enableIframeScaling:wt=!0,disableLoadingOverlay:R=!1,className:_t,onPointerDown:Ke,...Ct})=>{const ce=t.useRef(null),Ue=t.useRef(null),Ie=t.useRef(null),We=t.useRef(null),X=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),Z=t.useRef(null),Ge=t.useRef(null),He=t.useRef([]),ae=t.useRef(!1),O=t.useRef(null),ze=t.useRef(null),$e=t.useRef({markerCount:0,currentIndex:-1,canGoNext:!1}),{currentElementList:k,stepElementLists:Ye,slideElementList:T,currentIndex:c,audioList:d,currentAudioSequenceIndexes:de,currentStepHasSpeakableElement:x,currentInteractionElement:i,canGoPrev:Mt,canGoNext:v,handlePrev:Xe,handleNext:I}=bn.default(h),ee=t.useMemo(()=>{if(!(c<0))return T[c]},[c,T]),kt=T.filter(e=>e.is_renderable!==!1).length===1,g=E&&(T.length>0||d.length>0||!!i),w=t.useMemo(()=>de.map(e=>d[e]?.audioKey).filter(e=>!!e),[d,de]),[Je,fe]=t.useState(!0),[me,te]=t.useState(!1),[ne,Qe]=t.useState(!0),[f,L]=t.useState(null),[Tt,m]=t.useState(!1),[Pt,we]=t.useState(qe),[_,Ze]=t.useState(!1),[jt,_e]=t.useState(!1),[et,Ft]=t.useState(!0),[Ce,Me]=t.useState(!1),[s,ke]=t.useState(),[pe,he]=t.useState(!1),[Bt,re]=t.useState(0),[tt,Nt]=t.useState(!1),P=t.useMemo(()=>Se.isMobileDevice(),[]),[xe,Te]=t.useState(le.DEFAULT_MOBILE_VIEW_MODE),[nt,Pe]=t.useState(!1),[qt,rt]=t.useState(()=>P?Se.isLandscapeViewport():!1),V=t.useMemo(()=>gn.createPlaybackTimeStore(),[]),{effectiveMobileViewMode:D,isImmersiveMobileFullscreen:K,isNativeMobileFullscreen:st,shouldRotateFullscreenViewport:Ot}=t.useMemo(()=>le.resolveMobileViewModeState({hasManualMobileViewMode:nt,isMobileDevice:P,mobileViewMode:xe}),[nt,P,qt,xe]),Lt=t.useRef(D),C=g&&(S||Je),Vt=K&&C,Dt=K&&C,Kt=K||st,ot=tt&&!P,Ut=t.useCallback(e=>{Pe(!0),Te(e)},[]),ut=t.useCallback(()=>{Pe(!1),Te(le.DEFAULT_MOBILE_VIEW_MODE)},[]),Wt=t.useCallback(()=>{ut(),y?.onBack?.()},[y,ut]),lt=t.useCallback(e=>{Me(e)},[]),it=t.useCallback(()=>{Me(e=>!e)},[]),{mountedStepStates:Gt,currentMountedStateIndex:Ht}=t.useMemo(()=>{const e=[],n=new Map;return Ye.forEach((u,a)=>{const o=e.findIndex(l=>Tn(l.elementList,u));if(o>=0){e[o]?.sourceStepIndexes.push(a),n.set(a,o);return}e.push({elementList:u,sourceStepIndexes:[a]}),n.set(a,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:c>=0?n.get(c)??-1:-1}},[c,Ye]),ct=t.useMemo(()=>String(c),[c]),p=t.useMemo(()=>f?d.findIndex(e=>(e.audioKey??"")===f):-1,[d,f]),je=t.useMemo(()=>p>=0?d[p]:void 0,[d,p]),zt=je?.element?.subtitle_cues??[],be=t.useMemo(()=>w[0]??"none",[w]),Fe=t.useMemo(()=>({currentElement:gt.resolvePlayerCustomActionElement({currentAudioIndex:p,currentAudioSequenceIndexes:de,audioList:d,currentInteractionElement:s,currentStepElement:ee}),currentIndex:c,currentStepElement:ee,isActive:Ce,setActive:lt,toggleActive:it}),[s,d,p,de,c,ee,Ce,lt,it]),Be=t.useMemo(()=>gt.getPlayerCustomActionCount(N,Fe),[Fe,N]),$t=t.useMemo(()=>({"--slide-player-custom-action-count":String(Be),"--slide-player-mobile-control-count":String(Be+4)}),[Be]),at=w.length>0,dt=t.useMemo(()=>i?`${i.sequence_number??"none"}:${String(i.content??"")}`:"none",[i]),se=t.useMemo(()=>[ct,dt].join("|"),[dt,ct]),Yt=t.useMemo(()=>[se,je?.audioKey??"none",String(p)].join("|"),[p,je?.audioKey,se]),ft=!!t.useMemo(()=>!be||be==="none"?"":d.find(n=>n.audioKey===be)?.audioUrl?.trim()??"",[d,be]),F=Y&&!!N&&Ce,oe=t.useMemo(()=>An.shouldUseAutoAdvanceToggle({canGoNext:v,currentAudioIndex:p,currentStepHasSpeakableElement:x,hasInteraction:!!i}),[v,p,i,x]),B=t.useCallback(()=>{X.current!==null&&(window.clearTimeout(X.current),X.current=null)},[]),j=t.useCallback(()=>{Q.current!==null&&(window.clearTimeout(Q.current),Q.current=null)},[]),M=t.useCallback(()=>{Z.current!==null&&(window.clearTimeout(Z.current),Z.current=null)},[]),U=t.useCallback(()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},[]),W=t.useCallback(()=>{U(),j(),M(),L(null),V.reset(),m(!1),we(qe),Ze(!1),_e(!1),ke(void 0),he(!1),re(0)},[U,j,M,V]),G=t.useCallback(()=>{const e=w[0];return e?(L(e),!0):!1},[w]),ve=t.useCallback(()=>{j(),M(),he(!1),re(0),!G()&&v&&I()},[v,j,M,I,G]),mt=t.useCallback(e=>{if(M(),!e)return;const n=()=>{Z.current=null,re(_n),he(!0),O.current=null};Z.current=window.setTimeout(n,wn)},[M]),b=t.useCallback((e=me)=>{g&&(fe(!0),B(),!(S||!e||Ae<=0)&&(X.current=window.setTimeout(()=>{fe(!1),X.current=null},Ae)))},[B,me,S,Ae,g]),ue=!!(i?.readonly||i?.user_input?.trim()),H=!!i&&!ue;t.useEffect(()=>{Qe(!0),Y&&Me(!1)},[c,Y]),t.useEffect(()=>()=>{U(),B(),j(),M()},[U,j,M,B]),t.useEffect(()=>(Re?.(C),()=>{Re?.(!1)}),[Re,C]),t.useEffect(()=>{P||xe===le.DEFAULT_MOBILE_VIEW_MODE||(Pe(!1),Te(le.DEFAULT_MOBILE_VIEW_MODE))},[P,xe]),t.useEffect(()=>{if(!P){rt(!1);return}const e=()=>{rt(Se.isLandscapeViewport())};return e(),Se.subscribeMobileDeviceChange(e)},[P]),t.useEffect(()=>{Ve?.(D)},[D,Ve]),t.useEffect(()=>{Lt.current=D},[D]),t.useEffect(()=>{De?.(ee,c)},[c,ee,De]),t.useEffect(()=>{const e=$e.current,n=Sn.shouldAutoAdvanceIntoAppendedMarker({previousMarkerCount:e.markerCount,nextMarkerCount:T.length,previousIndex:e.currentIndex,previousCanGoNext:e.canGoNext,nextCanGoNext:v,currentAudioKey:f,hasCompletedCurrentStepAudio:_,hasResolvedCurrentInteraction:ue,currentStepHasSpeakableElement:x,currentInteractionElement:i,isAutoAdvanceEnabled:ne,shouldUseSilentStepAutoAdvanceToggle:oe});$e.current={markerCount:T.length,currentIndex:c,canGoNext:v},n&&I()},[v,f,c,i,x,I,_,ue,ne,oe,T.length]),t.useEffect(()=>{if(!g){B(),fe(!1);return}if(S){B(),fe(!0);return}me||b(!0)},[B,me,S,g,b]),t.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.origin===window.location.origin&&fn.isSandboxInteractionMessage(n.data)&&n.data.eventType==="click"&&g&&(te(!0),b(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[g,b]),vn.default({sectionRef:ce,enabled:g,onWake:()=>{te(!0),b(!0)}}),t.useEffect(()=>{const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:n}=yn.getPlaybackSequenceTransition({previousResetKey:ze.current,nextResetKey:se,currentAudioKey:f,hasCompletedCurrentStepAudio:_});ze.current=se;const u=O.current===c&&!!i,a=En.shouldPresentInteractionOverlay({hasInteraction:!!i,shouldBlockPlaybackForInteraction:H,shouldOpenInteractionOverlayAfterAudio:u,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:ue,currentStepHasSpeakableElement:x});if(e&&W(),!(k.length===0&&!i)&&!F){if(i&&ke(i),a){mt(i);return}if(M(),O.current=null,!!n&&!G()){if(x){if(R){m(!1);return}m(!0);return}if(v&&!(oe&&!ne))return J.current=window.setTimeout(()=>{J.current=null,I()},Oe),()=>{U()}}}},[v,U,k.length,i,f,se,x,Oe,I,_,R,ne,ue,H,M,W,mt,G,F,oe]),t.useEffect(()=>{if(R||F||!x||H){m(!1);return}if(_){m(!1);return}if(at){m(!1);return}we("waitingForAudio"),m(!0)},[at,x,_,R,F,H]),t.useEffect(()=>{f||w.length===0||F||!x||H||_||G()},[f,w,x,_,F,H,G]),t.useEffect(()=>{!f||p>=0||L(null)},[p,f]),t.useEffect(()=>{p>=0||V.reset()},[p,V]),t.useEffect(()=>{_e(!1)},[Yt]);const pt=t.useMemo(()=>{if(!s)return{};const e=!!s.user_input?.trim();return yt.getInteractionDefaultValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:ie)},[s,ie]),Xt=t.useMemo(()=>{if(!s)return;const e=!!s.user_input?.trim();return yt.getInteractionDefaultSelectedValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:ie)},[s,ie]),ht=!!s?.user_input?.trim(),xt=!!s?.readonly||ht,bt=xt||ht,Ne=!!s&&pe,Jt=t.useCallback(e=>{const u=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");ke(a=>!a||!u?a:{...a,user_input:u}),Le?.(e,s),ve()},[s,ve,Le]);t.useEffect(()=>{const e=()=>{Nt(document.fullscreenElement===ce.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{if(!Ne){re(0);return}const e=Ge.current;if(!e)return;const n=()=>{const a=Math.ceil(e.getBoundingClientRect().height);re(a+Cn)};if(n(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(()=>{n()});return u.observe(e),()=>{u.disconnect()}},[Ne]),t.useEffect(()=>{if(j(),!(!pe||!bt))return Q.current=window.setTimeout(()=>{Q.current=null,ve()},2e3),()=>{j()}},[j,ve,pe,bt]);const Qt=(e,n={})=>e?e.type==="slot"?r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?r.jsxRuntimeExports.jsx(St.default,{className:"content-render-iframe",disableLoadingOverlay:R,hideFullScreen:!0,mode:"blackboard",replaceRootScreenHeightWithFull:n.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content,enableScaling:wt}):r.jsxRuntimeExports.jsx(St.default,{className:"content-render-iframe",disableLoadingOverlay:R,hideFullScreen:!0,mode:"blackboard",type:"markdown",content:e.content}):null,Zt=(e=[],n=!1)=>{if(e.length===0)return null;const u=e.filter(o=>o.is_renderable!==!1).length,a=e.reduce((o,l,A)=>l.is_renderable!==!1?A:o,-1);return r.jsxRuntimeExports.jsx("div",{className:"slide-stage__content flex w-full flex-col gap-4",children:e.map((o,l)=>{const A=o.type==="html"&&o.is_renderable===!1;return r.jsxRuntimeExports.jsx("div",{ref:n&&l===a?We:null,"aria-hidden":A||void 0,className:z.cn("w-full shrink-0",u===1&&o.is_renderable!==!1&&"slide-element--single",A?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:Qt(o,{replaceRootScreenHeightWithFull:u===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${l}`)})})},en=t.useCallback(()=>{const e=ce.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),vt=t.useCallback(()=>{const e=Ie.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),tn=t.useCallback(()=>{ae.current=!0,O.current=null,te(!0),m(!1),b(!0),W(),Xe()},[Xe,W,b]),nn=t.useCallback(()=>{ae.current=!0,O.current=null,te(!0),m(!1),b(!0),W(),I()},[I,W,b]),rn=t.useCallback(({loading:e,reason:n})=>{if(R){m(!1);return}if(!x||_){m(!1);return}e&&n&&we(n),m(kn(n,e))},[x,_,R]);t.useEffect(()=>{R&&m(!1)},[R]);const sn=t.useCallback(e=>{const n=d[e]?.audioKey;if(!n||!f||n!==f)return;const u=w.findIndex(l=>l===n);if(u<0){L(null);return}const a=u+1,o=w[a];if(o){L(o);return}if(L(null),Ze(!0),m(!1),v){const l=c+1,A=T[l];ft&&A?.type==="interaction"&&(O.current=l),I();return}},[d,v,c,f,w,I,ft,T]),on=t.useCallback(()=>{s&&he(e=>!e)},[s]),Et=t.useCallback(e=>{e.stopPropagation(),C&&b(!0)},[Je,b]),un=t.useCallback(e=>{Ke?.(e)},[Ke]),ln=t.useCallback(()=>{te(!0),b(!0)},[b]),Ee=t.useMemo(()=>k.map((e,n)=>`${e.sequence_number??`${e.type}-${n}`}:${String(e.is_new??"")}`),[k]);return t.useEffect(()=>{const e=He.current,a=(e.length>0&&e.length<Ee.length&&e.every((l,A)=>l===Ee[A])?k.slice(e.length):[]).some(l=>l.is_new===!1);if(He.current=Ee,!a)return;const o=window.requestAnimationFrame(()=>{const l=Ie.current,A=We.current;if(!l||!A)return;const cn=l.getBoundingClientRect(),an=A.getBoundingClientRect(),dn=l.scrollTop+(an.top-cn.top);l.scrollTo({top:Math.max(dn,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(o)}},[k,Ee]),t.useEffect(()=>{if(!ae.current||(ae.current=!1,k.length===0))return;const e=window.requestAnimationFrame(()=>{vt()});return()=>{window.cancelAnimationFrame(e)}},[k,vt]),r.jsxRuntimeExports.jsxs("section",{ref:ce,className:z.cn("relative h-full w-full",P&&"slide--mobile-device",ot&&"slide--browser-fullscreen",K&&"slide--mobile-landscape",st&&"slide--mobile-landscape-native",_t),onClick:ln,onPointerDown:un,...Ct,children:[Kt?r.jsxRuntimeExports.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,r.jsxRuntimeExports.jsxs("div",{ref:Ue,className:z.cn("slide__viewport relative h-full min-h-0 w-full",K&&"slide__viewport--mobile-landscape",K&&!Ot&&"slide__viewport--mobile-landscape-native"),children:[Vt?r.jsxRuntimeExports.jsxs("div",{className:"slide-landscape-header",children:[r.jsxRuntimeExports.jsx("button",{"aria-label":y?.backAriaLabel??"Back",className:"slide-landscape-header__back",onClick:Wt,type:"button",children:r.jsxRuntimeExports.jsx(Rn.default,{className:"slide-landscape-header__icon h-6 w-6",strokeWidth:2.25})}),y?.content?r.jsxRuntimeExports.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:y.content}):null]}):null,r.jsxRuntimeExports.jsx("div",{className:z.cn("h-full min-h-0 w-full",Dt&&"slide__viewport-content--with-header",kt?"slide-content--single":"grid gap-4"),children:k.length>0?r.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:r.jsxRuntimeExports.jsx("div",{ref:Ie,className:"slide-stage__layer w-full",children:Gt.map((e,n)=>{const u=n===Ht;return r.jsxRuntimeExports.jsx("div",{"aria-hidden":!u||void 0,className:"w-full h-full",style:{display:u?void 0:"none"},children:Zt(e.elementList,u)},e.sourceStepIndexes[0]??n)})})}):null}),Tt?r.jsxRuntimeExports.jsx(mn.default,{message:Mn(ye,Pt),className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,r.jsxRuntimeExports.jsx(xn.default,{extraBottomOffset:Bt,hasPlayerGap:C,isEnabled:et&&jt,isPlayerHidden:g&&!C,playbackTimeStore:V,subtitleCues:zt}),Ne?r.jsxRuntimeExports.jsx("div",{ref:Ge,className:z.cn("slide-interaction-overlay",C&&g?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone"),onClick:Et,onPointerDown:Et,style:$t,children:r.jsxRuntimeExports.jsx(Rt,{content:String(s?.content??""),defaultButtonText:pt.buttonText??"",defaultInputText:pt.inputText??"",defaultSelectedValues:Xt,confirmButtonText:q?.confirmButtonText,copyButtonText:q?.copyButtonText,copiedButtonText:q?.copiedButtonText,onSend:Jt,readonly:xt,title:q?.title??ge??"Submit the content below to continue."})}):null,g?r.jsxRuntimeExports.jsx(hn.default,{audioList:d,className:z.cn("absolute left-1/2 z-[2] -translate-x-1/2",ot?"bottom-3":"-bottom-3",$,!C&&"pointer-events-none opacity-0"),currentAudioIndex:p,defaultPlaying:!0,isPlaybackPaused:F,isAutoAdvanceEnabled:ne,hasInteraction:!!s,isInteractionOpen:pe,isSubtitleEnabled:et,onAutoAdvanceToggle:Qe,onLoadingChange:rn,onPlaybackStarted:()=>{_e(!0)},onPlaybackTimeChange:V.setTime,onSubtitleToggle:()=>{Ft(e=>!e)},nextDisabled:!v,onEnded:sn,onFullscreen:en,isFullscreen:tt,mobileViewMode:D,settingsPortalContainer:Ue.current,onMobileViewModeChange:Ut,onInteractionToggle:on,onNext:nn,onPrev:tn,prevDisabled:!Mt,showControls:C,texts:It,customActionContext:Fe,customActions:N,useAutoAdvanceToggle:oe}):null]})]})};exports.default=Pn;
|
|
2
2
|
//# sourceMappingURL=Slide.cjs.js.map
|