@ai-react-markdown/mantine 1.5.1 → 1.6.1
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/README.md +1 -1
- package/dist/index.cjs +45 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +45 -36
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ yarn add @ai-react-markdown/mantine @ai-react-markdown/core
|
|
|
36
36
|
{
|
|
37
37
|
"react": ">=19",
|
|
38
38
|
"react-dom": ">=19",
|
|
39
|
-
"@ai-react-markdown/core": "^1.
|
|
39
|
+
"@ai-react-markdown/core": "^1.6.1",
|
|
40
40
|
"@mantine/core": "^9.0.0",
|
|
41
41
|
"@mantine/code-highlight": "^9.0.0",
|
|
42
42
|
"highlight.js": "^11.11.1"
|
package/dist/index.cjs
CHANGED
|
@@ -88,6 +88,25 @@ var import_core4 = require("@mantine/core");
|
|
|
88
88
|
var import_mermaid = __toESM(require("mermaid"), 1);
|
|
89
89
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
90
90
|
var PRE_STYLE = { cursor: "pointer", overflow: "auto", width: "100%", padding: "0.5rem" };
|
|
91
|
+
var sameView = (a, b) => a.kind === "diagram" && b.kind === "diagram" ? a.chartType === b.chartType : a.kind === b.kind;
|
|
92
|
+
var initializedTheme = null;
|
|
93
|
+
var ensureMermaidInitialized = (isDark) => {
|
|
94
|
+
const theme = isDark ? "dark" : "light";
|
|
95
|
+
if (initializedTheme === theme) return;
|
|
96
|
+
import_mermaid.default.initialize({
|
|
97
|
+
startOnLoad: false,
|
|
98
|
+
securityLevel: "strict",
|
|
99
|
+
theme: isDark ? "dark" : "base",
|
|
100
|
+
darkMode: isDark,
|
|
101
|
+
// Without a svgContainingElement, a draw-phase throw (an error that
|
|
102
|
+
// got past mermaid.parse) leaves mermaid's temp element orphaned in
|
|
103
|
+
// document.body — its error path only cleans up when this flag is
|
|
104
|
+
// set. We render our own error tab anyway, so mermaid's built-in
|
|
105
|
+
// error diagram is dead weight here regardless.
|
|
106
|
+
suppressErrorRendering: true
|
|
107
|
+
});
|
|
108
|
+
initializedTheme = theme;
|
|
109
|
+
};
|
|
91
110
|
var generateMermaidUUID = () => {
|
|
92
111
|
return `mermaid-${(/* @__PURE__ */ new Date()).getTime()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
93
112
|
};
|
|
@@ -109,20 +128,21 @@ var MantineAIMMermaidCode = (0, import_react2.memo)((props) => {
|
|
|
109
128
|
const streaming = renderState.streaming;
|
|
110
129
|
const ref = (0, import_react2.useRef)(null);
|
|
111
130
|
const renderVersionRef = (0, import_react2.useRef)(0);
|
|
112
|
-
const
|
|
131
|
+
const viewRef = (0, import_react2.useRef)({ kind: "source" });
|
|
113
132
|
const prevStreamingRef = (0, import_react2.useRef)(false);
|
|
114
133
|
const needsCorrectiveRef = (0, import_react2.useRef)(false);
|
|
115
|
-
const
|
|
134
|
+
const lastSuccessRef = (0, import_react2.useRef)(null);
|
|
135
|
+
const [view, setViewState] = (0, import_react2.useState)({ kind: "source" });
|
|
116
136
|
const [showOriginalCode, setShowOriginalCode] = (0, import_react2.useState)(false);
|
|
117
|
-
const [renderError, setRenderError] = (0, import_react2.useState)(false);
|
|
118
|
-
const [chartType, setChartType] = (0, import_react2.useState)("unknown");
|
|
119
137
|
(0, import_react2.useEffect)(() => {
|
|
138
|
+
const applyView = (next) => {
|
|
139
|
+
viewRef.current = next;
|
|
140
|
+
setViewState((prev) => sameView(prev, next) ? prev : next);
|
|
141
|
+
};
|
|
120
142
|
if (streaming && !prevStreamingRef.current) {
|
|
121
|
-
hasRenderedRef.current = false;
|
|
122
143
|
needsCorrectiveRef.current = false;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
setChartType("unknown");
|
|
144
|
+
lastSuccessRef.current = null;
|
|
145
|
+
applyView({ kind: "source" });
|
|
126
146
|
if (ref.current) {
|
|
127
147
|
ref.current.innerHTML = "";
|
|
128
148
|
}
|
|
@@ -133,22 +153,15 @@ var MantineAIMMermaidCode = (0, import_react2.memo)((props) => {
|
|
|
133
153
|
if (!props.code || !ref.current || showOriginalCode) {
|
|
134
154
|
return;
|
|
135
155
|
}
|
|
156
|
+
if (lastSuccessRef.current?.code === props.code && lastSuccessRef.current.isDark === isDark) {
|
|
157
|
+
needsCorrectiveRef.current = false;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
136
160
|
const renderVersion = ++renderVersionRef.current;
|
|
137
161
|
let cancelled = false;
|
|
138
162
|
const renderMermaid = async () => {
|
|
139
163
|
try {
|
|
140
|
-
|
|
141
|
-
startOnLoad: false,
|
|
142
|
-
securityLevel: "strict",
|
|
143
|
-
theme: isDark ? "dark" : "base",
|
|
144
|
-
darkMode: isDark,
|
|
145
|
-
// Without a svgContainingElement, a draw-phase throw (an error that
|
|
146
|
-
// got past mermaid.parse) leaves mermaid's temp element orphaned in
|
|
147
|
-
// document.body — its error path only cleans up when this flag is
|
|
148
|
-
// set. We render our own error tab anyway, so mermaid's built-in
|
|
149
|
-
// error diagram is dead weight here regardless.
|
|
150
|
-
suppressErrorRendering: true
|
|
151
|
-
});
|
|
164
|
+
ensureMermaidInitialized(isDark);
|
|
152
165
|
const parseResult = await import_mermaid.default.parse(props.code);
|
|
153
166
|
if (!parseResult) {
|
|
154
167
|
throw new Error("Failed to parse mermaid code");
|
|
@@ -162,11 +175,9 @@ var MantineAIMMermaidCode = (0, import_react2.memo)((props) => {
|
|
|
162
175
|
}
|
|
163
176
|
ref.current.innerHTML = svg;
|
|
164
177
|
bindFunctions?.(ref.current);
|
|
165
|
-
hasRenderedRef.current = true;
|
|
166
178
|
needsCorrectiveRef.current = false;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
setRenderError(false);
|
|
179
|
+
lastSuccessRef.current = { code: props.code, isDark };
|
|
180
|
+
applyView({ kind: "diagram", chartType: diagramType });
|
|
170
181
|
} catch {
|
|
171
182
|
if (cancelled || renderVersion !== renderVersionRef.current) {
|
|
172
183
|
return;
|
|
@@ -176,15 +187,13 @@ var MantineAIMMermaidCode = (0, import_react2.memo)((props) => {
|
|
|
176
187
|
}
|
|
177
188
|
if (needsCorrectiveRef.current) {
|
|
178
189
|
needsCorrectiveRef.current = false;
|
|
179
|
-
|
|
180
|
-
setRenderError(true);
|
|
190
|
+
applyView({ kind: "error" });
|
|
181
191
|
return;
|
|
182
192
|
}
|
|
183
|
-
if (
|
|
193
|
+
if (viewRef.current.kind === "diagram") {
|
|
184
194
|
return;
|
|
185
195
|
}
|
|
186
|
-
|
|
187
|
-
setRenderError(true);
|
|
196
|
+
applyView({ kind: "error" });
|
|
188
197
|
}
|
|
189
198
|
};
|
|
190
199
|
void renderMermaid();
|
|
@@ -195,7 +204,7 @@ var MantineAIMMermaidCode = (0, import_react2.memo)((props) => {
|
|
|
195
204
|
const viewSvgInNewWindow = (0, import_react2.useCallback)(() => {
|
|
196
205
|
handleViewSVGInNewWindow(ref.current?.querySelector("svg"), isDark);
|
|
197
206
|
}, [isDark]);
|
|
198
|
-
const showSourceFallback = showOriginalCode ||
|
|
207
|
+
const showSourceFallback = showOriginalCode || view.kind !== "diagram";
|
|
199
208
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
200
209
|
showSourceFallback && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
201
210
|
import_code_highlight.CodeHighlightTabs,
|
|
@@ -205,7 +214,7 @@ var MantineAIMMermaidCode = (0, import_react2.memo)((props) => {
|
|
|
205
214
|
w: "100%",
|
|
206
215
|
code: [
|
|
207
216
|
{
|
|
208
|
-
fileName:
|
|
217
|
+
fileName: view.kind === "error" ? "Mermaid Render Error" : "mermaid",
|
|
209
218
|
code: props.code,
|
|
210
219
|
language: "mermaid"
|
|
211
220
|
}
|
|
@@ -221,10 +230,10 @@ var MantineAIMMermaidCode = (0, import_react2.memo)((props) => {
|
|
|
221
230
|
// The "Render Mermaid" control only makes sense as the way back
|
|
222
231
|
// from the user-toggled source view. In the error and warm-up
|
|
223
232
|
// fallbacks `showOriginalCode` is already false, so the control
|
|
224
|
-
// would be a no-op — hide it there. (No
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
233
|
+
// would be a no-op — hide it there. (No view-kind conjunct: the
|
|
234
|
+
// toggle is only reachable from the visible diagram view, and
|
|
235
|
+
// while the source view is open the effect early-returns, so
|
|
236
|
+
// showOriginalCode && view.kind === 'error' is unreachable.)
|
|
228
237
|
showOriginalCode ? [
|
|
229
238
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
230
239
|
import_code_highlight.CodeHighlightControl,
|
|
@@ -252,7 +261,7 @@ var MantineAIMMermaidCode = (0, import_react2.memo)((props) => {
|
|
|
252
261
|
} : {},
|
|
253
262
|
children: [
|
|
254
263
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "chart-header", children: [
|
|
255
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "chart-type-tag", children: chartType }),
|
|
264
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "chart-type-tag", children: view.kind === "diagram" ? view.chartType : "unknown" }),
|
|
256
265
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core4.Flex, { align: "center", justify: "flex-end", gap: 0, children: [
|
|
257
266
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core4.Tooltip, { label: "Show Mermaid Code", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
258
267
|
import_core4.ActionIcon,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/MantineAIMarkdown.tsx","../src/components/typography/MantineTypography.tsx","../src/components/extra-styles/DefaultExtraStyles/index.tsx","../src/defs.tsx","../src/components/customized/PreCode.tsx","../src/hooks/useMantineAIMarkdownRenderState.ts","../src/components/customized/MermaidCode/index.tsx","../src/hooks/useMantineAIMarkdownMetadata.ts"],"sourcesContent":["/**\n * Public API surface for `@ai-react-markdown/mantine`.\n *\n * Re-exports the Mantine-integrated AI markdown component, its supporting\n * sub-components, extended types, default configuration, and typed hooks.\n *\n * @packageDocumentation\n */\n\n// --- Components ---\n\n/** Props for the main {@link MantineAIMarkdown} component. */\nexport type { MantineAIMarkdownProps } from './MantineAIMarkdown';\n\n/** Main component -- Mantine-integrated AI markdown renderer (default export). */\nexport { default } from './MantineAIMarkdown';\n\n/** Mantine-themed typography wrapper used by default inside {@link MantineAIMarkdown}. */\nexport { default as MantineAIMarkdownTypography } from './components/typography/MantineTypography';\n\n/** Default extra styles wrapper providing Mantine-compatible CSS scoping and overrides. */\nexport { default as MantineAIMDefaultExtraStyles } from './components/extra-styles/DefaultExtraStyles';\n\n// --- Types, config, and hooks ---\n\n/** Extended render configuration and metadata types for the Mantine integration. */\nexport type { MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata } from './defs';\n\n/** Default Mantine render configuration (frozen). */\nexport { defaultMantineAIMarkdownRenderConfig } from './defs';\n\n/** Typed hook for accessing render state with Mantine-specific config fields. */\nexport { useMantineAIMarkdownRenderState } from './hooks/useMantineAIMarkdownRenderState';\n\n/** Typed hook for accessing metadata within the Mantine AI markdown tree. */\nexport { useMantineAIMarkdownMetadata } from './hooks/useMantineAIMarkdownMetadata';\n","/**\n * Main Mantine integration component for AI markdown rendering.\n *\n * Wraps the core {@link AIMarkdown} component with Mantine-specific defaults:\n * - {@link MantineAIMarkdownTypography} as the typography wrapper\n * - {@link MantineAIMDefaultExtraStyles} as the extra styles wrapper\n * - {@link MantineAIMPreCode} as the default `<pre>` component (with syntax\n * highlighting via Mantine's CodeHighlight and mermaid diagram support)\n * - Automatic color scheme detection via Mantine's `useComputedColorScheme`\n *\n * @module MantineAIMarkdown\n */\n\nimport { memo, useMemo } from 'react';\nimport AIMarkdown from '@ai-react-markdown/core';\nimport { type AIMarkdownProps, type AIMarkdownCustomComponents, useStableValue } from '@ai-react-markdown/core';\nimport MantineAIMarkdownTypography from './components/typography/MantineTypography';\nimport MantineAIMDefaultExtraStyles from './components/extra-styles/DefaultExtraStyles';\nimport { MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata, defaultMantineAIMarkdownRenderConfig } from './defs';\nimport MantineAIMPreCode from './components/customized/PreCode';\nimport { useComputedColorScheme } from '@mantine/core';\n\n/**\n * Props for the {@link MantineAIMarkdown} component.\n *\n * Extends {@link AIMarkdownProps} with Mantine-specific config and metadata generics.\n * All core props (`content`, `streaming`, `fontSize`, `config`, etc.) are inherited.\n *\n * @typeParam TConfig - Render configuration type, defaults to {@link MantineAIMarkdownRenderConfig}.\n * @typeParam TRenderData - Metadata type, defaults to {@link MantineAIMarkdownMetadata}.\n */\nexport interface MantineAIMarkdownProps<\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n TRenderData extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n> extends AIMarkdownProps<TConfig, TRenderData> {}\n\n/**\n * Default custom component overrides applied by the Mantine integration.\n *\n * Overrides the `<pre>` element to extract code blocks and render them via\n * {@link MantineAIMPreCode}, which provides syntax highlighting, expand/collapse,\n * and mermaid diagram support. Falls back to a plain `<pre>` when the child\n * is not a recognized code element.\n */\nconst DefaultCustomComponents: AIMarkdownCustomComponents = {\n pre: ({ node, ...usefulProps }) => {\n const code = node?.children[0] as\n | {\n type: string;\n tagName?: string;\n position?: { start?: { offset?: number } };\n properties?: Record<string, unknown>;\n children: { value?: string }[];\n }\n | undefined;\n if (!code || code.type !== 'element' || code.tagName !== 'code' || !code.position) {\n return <pre {...usefulProps} />;\n }\n const key = `pre-code-${node?.position?.start?.offset || 0}`;\n const detectedLanguage = (code.properties?.className as string[])\n ?.find((className: string) => className.startsWith('language-'))\n ?.substring('language-'.length);\n const codeText = code.children.map((child: { value?: string }) => child.value ?? '').join('\\n');\n return <MantineAIMPreCode key={key} codeText={codeText} existLanguage={detectedLanguage} />;\n },\n};\n\n/**\n * Inner (non-memoized) implementation of the Mantine AI markdown component.\n *\n * Merges caller-provided `customComponents` with the Mantine defaults (the caller's\n * overrides take precedence). Automatically resolves the color scheme from Mantine's\n * `useComputedColorScheme` when no explicit `colorScheme` prop is provided.\n *\n * @typeParam TConfig - Render configuration type.\n * @typeParam TRenderData - Metadata type.\n */\nconst MantineAIMarkdownComponent = <\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n TRenderData extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n>({\n Typography = MantineAIMarkdownTypography,\n ExtraStyles = MantineAIMDefaultExtraStyles,\n defaultConfig = defaultMantineAIMarkdownRenderConfig as TConfig,\n customComponents,\n colorScheme,\n ...props\n}: MantineAIMarkdownProps<TConfig, TRenderData>) => {\n const stableCustomComponents = useStableValue(customComponents);\n\n const usedComponents = useMemo(() => {\n return stableCustomComponents ? { ...DefaultCustomComponents, ...stableCustomComponents } : DefaultCustomComponents;\n }, [stableCustomComponents]);\n\n const computedColorScheme = useComputedColorScheme('light');\n\n return (\n <AIMarkdown<MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata>\n Typography={Typography}\n ExtraStyles={ExtraStyles}\n defaultConfig={defaultConfig}\n customComponents={usedComponents}\n colorScheme={colorScheme ?? computedColorScheme}\n {...props}\n />\n );\n};\n\n/**\n * Mantine-integrated AI markdown renderer.\n *\n * A memoized wrapper around the core `<AIMarkdown>` component that provides\n * Mantine-themed typography, code highlighting (via `@mantine/code-highlight`),\n * mermaid diagram rendering, and automatic color scheme detection.\n *\n * This is the default export of `@ai-react-markdown/mantine`.\n *\n * @example\n * ```tsx\n * import MantineAIMarkdown from '@ai-react-markdown/mantine';\n *\n * function Chat({ content }: { content: string }) {\n * return <MantineAIMarkdown content={content} />;\n * }\n * ```\n */\nexport const MantineAIMarkdown = memo(MantineAIMarkdownComponent);\n\nMantineAIMarkdown.displayName = 'MantineAIMarkdown';\n\nexport default MantineAIMarkdown as typeof MantineAIMarkdownComponent;\n","import { memo } from 'react';\nimport { Typography } from '@mantine/core';\nimport type { AIMarkdownTypographyProps } from '@ai-react-markdown/core';\n\n/**\n * Mantine-themed typography wrapper for AI markdown content.\n *\n * Replaces the core default typography component with Mantine's `<Typography>`\n * element, applying the configured `fontSize` at full width. This ensures all\n * rendered markdown inherits Mantine's font family, line height, and theming.\n *\n * Used as the default `Typography` prop in {@link MantineAIMarkdown}.\n * Can be replaced by passing a custom `Typography` component.\n *\n * @param props - Standard {@link AIMarkdownTypographyProps} from the core package.\n */\nconst MantineAIMarkdownTypography = memo(({ children, fontSize, style }: AIMarkdownTypographyProps) => (\n <Typography w=\"100%\" fz={fontSize} style={style}>\n {children}\n </Typography>\n));\n\nMantineAIMarkdownTypography.displayName = 'MantineAIMarkdownTypography';\n\nexport default MantineAIMarkdownTypography;\n","import React from 'react';\nimport { AIMarkdownExtraStylesComponent } from '@ai-react-markdown/core';\nimport './styles.scss';\n\n/**\n * Default extra styles wrapper for the Mantine integration.\n *\n * Wraps markdown content in a `<div>` with the `aim-mantine-extra-styles` CSS class,\n * which provides Mantine-compatible typography overrides including:\n * - Relative `em`-based Mantine spacing and font-size CSS custom properties\n * - Heading, list, paragraph, blockquote, and code styling\n * - Definition list layout\n *\n * Used as the default `ExtraStyles` prop in {@link MantineAIMarkdown}.\n */\nconst MantineAIMDefaultExtraStyles: AIMarkdownExtraStylesComponent = ({ children }) => {\n return <div className=\"aim-mantine-extra-styles\">{children}</div>;\n};\n\nexport default MantineAIMDefaultExtraStyles;\n","/**\n * Mantine-specific type definitions and default configuration.\n *\n * Extends the core {@link AIMarkdownRenderConfig} and {@link AIMarkdownMetadata}\n * with Mantine-themed options such as uniform heading sizes and code block behavior.\n *\n * @module defs\n */\n\nimport { AIMarkdownRenderConfig, AIMarkdownMetadata, defaultAIMarkdownRenderConfig } from '@ai-react-markdown/core';\n\n/**\n * Extended render configuration for the Mantine integration.\n *\n * Inherits all core config fields (extra syntax, display optimizations) and adds\n * Mantine-specific options for typography sizing and code block behavior.\n */\nexport interface MantineAIMarkdownRenderConfig extends AIMarkdownRenderConfig {\n /** Code block rendering options. */\n codeBlock: {\n /**\n * Whether code blocks start in their expanded state.\n * When `false`, long code blocks are collapsed with an expand button.\n *\n * @default true\n */\n defaultExpanded: boolean;\n\n /**\n * When `true`, uses `highlight.js` auto-detection to determine the language\n * of code blocks that lack an explicit language annotation.\n *\n * @default false\n */\n autoDetectUnknownLanguage: boolean;\n };\n}\n\n/**\n * Default Mantine render configuration.\n *\n * Extends {@link defaultAIMarkdownRenderConfig} with Mantine-specific defaults.\n * Frozen to prevent accidental mutation.\n */\nexport const defaultMantineAIMarkdownRenderConfig: MantineAIMarkdownRenderConfig = Object.freeze({\n ...defaultAIMarkdownRenderConfig,\n codeBlock: Object.freeze({\n defaultExpanded: true,\n autoDetectUnknownLanguage: false,\n }),\n});\n\n/**\n * Metadata type for the Mantine integration.\n *\n * Currently identical to {@link AIMarkdownMetadata}. Exists as an extension point\n * so that consumers can augment metadata in Mantine-specific wrappers without\n * needing to reference the core type directly.\n */\nexport interface MantineAIMarkdownMetadata extends AIMarkdownMetadata {}\n","'use client';\n\nimport { HTMLAttributes, memo, useMemo } from 'react';\nimport { CodeHighlight, CodeHighlightTabs } from '@mantine/code-highlight';\nimport { deepParseJson } from 'deep-parse-json';\nimport hljs from 'highlight.js';\nimport { useMantineAIMarkdownRenderState } from '../../hooks/useMantineAIMarkdownRenderState';\nimport MantineAIMMermaidCode from './MermaidCode';\n\n/**\n * Code languages that receive specialized rendering instead of standard\n * syntax-highlighted code blocks. Adding a new member here automatically\n * marks that language as \"special\" — you only need to add the corresponding\n * rendering branch in the component's return.\n */\nenum SpecialCodeLanguage {\n /** Rendered as interactive diagrams via {@link MantineAIMMermaidCode} */\n Mermaid = 'mermaid',\n}\n\n/** O(1) lookup set, derived from {@link SpecialCodeLanguage}. */\nconst SPECIAL_LANGUAGES = new Set<string>(Object.values(SpecialCodeLanguage));\n\n/**\n * Mantine code block renderer for `<pre>` elements.\n *\n * Replaces the default `<pre>` rendering with Mantine's {@link CodeHighlight} or\n * {@link CodeHighlightTabs} components, providing syntax highlighting, expand/collapse\n * behavior, and file-name tabs.\n *\n * Behavior:\n * - If the code block has an explicit language annotation, uses that language.\n * - If no language is specified and `config.codeBlock.autoDetectUnknownLanguage` is\n * enabled, uses `highlight.js` auto-detection.\n * - Mermaid code blocks (`language-mermaid`) are rendered as interactive diagrams\n * via {@link MantineAIMMermaidCode}.\n * - JSON code blocks are deep-parsed and pretty-printed before display.\n * - Unrecognized languages render as plaintext with an \"unknown\" label using\n * {@link CodeHighlight} (no tabs).\n * - Recognized languages render with {@link CodeHighlightTabs} showing the\n * language name as the tab label.\n *\n * @param props.codeText - The raw text content of the code block.\n * @param props.existLanguage - Language identifier extracted from the `language-*` CSS class, if present.\n */\nconst MantineAIMPreCode = memo(\n (\n props: HTMLAttributes<HTMLPreElement> & {\n codeText: string;\n existLanguage?: string;\n }\n ) => {\n const renderState = useMantineAIMarkdownRenderState();\n\n const codeLanguage = useMemo(() => {\n if (props.existLanguage) return props.existLanguage;\n if (renderState.config.codeBlock.autoDetectUnknownLanguage) {\n return hljs.highlightAuto(props.codeText).language || '';\n }\n return '';\n }, [props.existLanguage, props.codeText, renderState.config.codeBlock.autoDetectUnknownLanguage]);\n\n const [usedCodeLanguage, usedFileName] = useMemo(() => {\n if (!codeLanguage) return ['plaintext', 'unknown'];\n if (!hljs.getLanguage(codeLanguage)) {\n return ['plaintext', codeLanguage];\n }\n return [codeLanguage, codeLanguage];\n }, [codeLanguage]);\n\n const isSpecialCodeBlock = SPECIAL_LANGUAGES.has(codeLanguage);\n\n const normalCodeBlockContent = useMemo(() => {\n if (isSpecialCodeBlock) return null;\n let usedCodeStr = props.codeText;\n if (usedCodeStr && usedCodeLanguage.toLowerCase() === 'json') {\n const deepParsedResult = deepParseJson(usedCodeStr);\n usedCodeStr =\n typeof deepParsedResult === 'string' ? deepParsedResult : JSON.stringify(deepParsedResult, null, 2);\n }\n return usedFileName === 'unknown' ? (\n <CodeHighlight\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={usedCodeStr}\n withBorder\n withExpandButton\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n />\n ) : (\n <CodeHighlightTabs\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={[\n {\n fileName: usedFileName,\n code: usedCodeStr,\n language: usedCodeLanguage,\n },\n ]}\n withBorder\n withExpandButton\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n />\n );\n }, [\n isSpecialCodeBlock,\n props.codeText,\n usedCodeLanguage,\n usedFileName,\n renderState.fontSize,\n renderState.config.codeBlock.defaultExpanded,\n ]);\n\n const specialCodeBlockContent = useMemo(() => {\n switch (codeLanguage) {\n case SpecialCodeLanguage.Mermaid:\n return <MantineAIMMermaidCode code={props.codeText} />;\n default:\n return null;\n }\n }, [codeLanguage, props.codeText]);\n\n return isSpecialCodeBlock ? specialCodeBlockContent : normalCodeBlockContent;\n }\n);\n\nMantineAIMPreCode.displayName = 'MantineAIMPreCode';\n\nexport default MantineAIMPreCode;\n","import { useAIMarkdownRenderState } from '@ai-react-markdown/core';\nimport { MantineAIMarkdownRenderConfig } from '../defs';\n\n/**\n * Typed wrapper around the core {@link useAIMarkdownRenderState} hook.\n *\n * Returns the current {@link AIMarkdownRenderState} defaulting to\n * {@link MantineAIMarkdownRenderConfig}. Accepts an optional generic parameter\n * for further extension, giving consumers direct access to Mantine-specific\n * config fields (`codeBlock`, etc.) without manual annotation.\n *\n * Must be called inside a component rendered within the `<MantineAIMarkdown>` tree.\n * Throws if called outside the provider boundary.\n *\n * @typeParam TConfig - Config type (defaults to {@link MantineAIMarkdownRenderConfig}).\n * @returns The current render state typed with `TConfig`.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { config, streaming, colorScheme } = useMantineAIMarkdownRenderState();\n * const isExpanded = config.codeBlock.defaultExpanded;\n * // ...\n * }\n * ```\n */\nexport const useMantineAIMarkdownRenderState = <\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n>() => {\n return useAIMarkdownRenderState<TConfig>();\n};\n","'use client';\n\nimport React, { memo, useEffect, useRef, useState, useCallback } from 'react';\nimport { CodeHighlightControl, CodeHighlightTabs } from '@mantine/code-highlight';\nimport { ActionIcon, CopyButton, Flex, Tooltip } from '@mantine/core';\nimport mermaid from 'mermaid';\nimport { useMantineAIMarkdownRenderState } from '../../../hooks/useMantineAIMarkdownRenderState';\nimport './styles.scss';\n\n/** Static `<pre>` style for the mermaid container. */\nconst PRE_STYLE = { cursor: 'pointer', overflow: 'auto', width: '100%', padding: '0.5rem' } as const;\n\n/**\n * Generate a unique ID for mermaid SVG rendering.\n * Combines a timestamp with a random suffix to avoid collisions when\n * multiple mermaid diagrams render concurrently.\n *\n * @returns A unique string in the format `mermaid-{timestamp}-{random}`.\n */\nconst generateMermaidUUID = () => {\n return `mermaid-${new Date().getTime()}-${Math.random().toString(36).slice(2, 10)}`;\n};\n\n/**\n * Open the rendered mermaid SVG in a new browser window.\n *\n * Clones the SVG element, applies a background color matching the current\n * color scheme, serializes it to an object URL, and opens it in a new tab.\n * The object URL is revoked after a short delay to free memory.\n *\n * @param svgElement - The rendered SVG element to view, or `null`/`undefined` to no-op.\n * @param isDark - Whether the current color scheme is dark (used for background color).\n */\nconst handleViewSVGInNewWindow = (svgElement: SVGElement | null | undefined, isDark: boolean) => {\n if (!svgElement) return;\n const targetSvg = svgElement.cloneNode(true) as SVGElement;\n targetSvg.style.backgroundColor = isDark ? '#242424' : 'white';\n const text = new XMLSerializer().serializeToString(targetSvg);\n const blob = new Blob([text], { type: 'image/svg+xml' });\n const url = URL.createObjectURL(blob);\n const win = window.open(url);\n if (win) {\n setTimeout(() => URL.revokeObjectURL(url), 5000);\n }\n};\n\n/**\n * Interactive mermaid diagram renderer.\n *\n * Parses and renders mermaid diagram source code into an inline SVG visualization.\n * Automatically adapts to the current Mantine color scheme (light/dark) by\n * re-initializing mermaid with the appropriate theme.\n *\n * Features:\n * - Live SVG rendering with automatic dark/light theme switching\n * - Fallback to raw source code display on parse/render errors\n * - Toggle between rendered diagram and raw mermaid source\n * - Click on the rendered diagram to open the SVG in a new browser window\n * - Copy button for the raw mermaid source code\n * - Chart type label extracted from mermaid's parse result\n * - Preserves the last successful render across transient parse failures\n *\n * ## Streaming contract\n *\n * While `streaming` is true (from render state), the code prop is usually a\n * truncated prefix of the final diagram, so parse failures are *expected*,\n * not exceptional:\n * - Before the first successful render, the raw source is shown as a plain\n * code block (never the error tab).\n * - After a success, the last good SVG stays up; each subsequent chunk is\n * re-attempted and the diagram refreshes only on the next success.\n * - When streaming ends (`streaming` is an effect dep), one corrective pass\n * runs on the final code: success refreshes the diagram, failure surfaces\n * the real error tab — even over a previously rendered mid-stream diagram,\n * because that diagram no longer matches the final source. The pending\n * corrective obligation is tracked by `needsCorrectiveRef` (armed on the\n * streaming→false edge, consumed by the next completed attempt), so ONLY\n * that one pass may clobber a rendered diagram; any later failure (e.g. a\n * transient throw on a theme-flip re-render) falls back to the static rule\n * below.\n * - A streaming→true edge marks a NEW generation (chat \"regenerate\" reuses\n * the same component instance when the block's source offset — and thus\n * its React key — is unchanged). All per-generation state is reset so the\n * warm-up shows the new source instead of the previous generation's stale\n * diagram or error tab.\n *\n * ## Static contract (`streaming` stays false)\n *\n * Without streaming edges, failures follow the original conservative rule:\n * the error tab shows only while nothing has rendered yet. Once a diagram is\n * up, later failures (theme-flip re-render, a not-yet-complete `code` update\n * from a consumer that didn't pass `streaming`) keep the last good diagram\n * instead of clobbering it with an error.\n *\n * @param props.code - Raw mermaid diagram source code to render.\n */\nconst MantineAIMMermaidCode = memo((props: { code: string }) => {\n const renderState = useMantineAIMarkdownRenderState();\n const isDark = renderState.colorScheme === 'dark';\n const streaming = renderState.streaming;\n\n const ref = useRef<HTMLPreElement>(null);\n const renderVersionRef = useRef(0);\n /** Mirrors `hasRendered` for reads inside the async render closure —\n * state reads there can be stale when deps change mid-flight. */\n const hasRenderedRef = useRef(false);\n /** Previous `streaming` value, for edge detection in the effect. */\n const prevStreamingRef = useRef(false);\n /** Armed on the streaming→false edge: the next completed render attempt is\n * the end-of-stream corrective pass, whose failure must surface even over\n * a rendered diagram. Consumed (reset) by that attempt's success OR\n * surfaced failure, so later unrelated failures can't clobber the SVG. */\n const needsCorrectiveRef = useRef(false);\n const [hasRendered, setHasRendered] = useState(false);\n const [showOriginalCode, setShowOriginalCode] = useState(false);\n const [renderError, setRenderError] = useState(false);\n const [chartType, setChartType] = useState('unknown');\n\n useEffect(() => {\n // Streaming edge detection MUST run before any early return — the first\n // chunk of a new stream can arrive while the code is still empty.\n if (streaming && !prevStreamingRef.current) {\n // Rising edge = a new generation is starting on this same instance\n // (same block offset → same React key → no remount on regenerate).\n // Reset all per-generation state so warm-up shows the incoming source,\n // not the previous generation's stale diagram or error tab. Everything\n // here is idempotent — a StrictMode double-run is harmless.\n hasRenderedRef.current = false;\n needsCorrectiveRef.current = false;\n // Deliberate state reset on an input edge (same pattern as a\n // key-less \"derived reset\"); all three are no-ops when already at\n // their initial values, so steady-state chunks don't re-render.\n setHasRendered(false);\n setRenderError(false);\n setChartType('unknown');\n if (ref.current) {\n ref.current.innerHTML = '';\n }\n } else if (!streaming && prevStreamingRef.current) {\n // Falling edge = the stream just ended; arm the corrective pass.\n needsCorrectiveRef.current = true;\n }\n prevStreamingRef.current = streaming;\n if (!props.code || !ref.current || showOriginalCode) {\n return;\n }\n\n const renderVersion = ++renderVersionRef.current;\n let cancelled = false;\n\n const renderMermaid = async () => {\n try {\n mermaid.initialize({\n startOnLoad: false,\n securityLevel: 'strict',\n theme: isDark ? 'dark' : 'base',\n darkMode: isDark,\n // Without a svgContainingElement, a draw-phase throw (an error that\n // got past mermaid.parse) leaves mermaid's temp element orphaned in\n // document.body — its error path only cleans up when this flag is\n // set. We render our own error tab anyway, so mermaid's built-in\n // error diagram is dead weight here regardless.\n suppressErrorRendering: true,\n });\n const parseResult = await mermaid.parse(props.code);\n if (!parseResult) {\n throw new Error('Failed to parse mermaid code');\n }\n\n if (!ref.current || cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n\n // Deliberately NOT passing `ref.current` as mermaid's\n // svgContainingElement: before the first success the host container\n // is hidden with `display: none` (source fallback is showing), and\n // mermaid measures text via getBBox during render — inside a\n // display:none subtree layout never runs, every measurement is 0,\n // and the diagram comes out as a ~16px SVG. With the argument\n // omitted, mermaid renders in a temp element appended to\n // `document.body` (its default path, cleaned up internally), so\n // measurement works no matter what our container is doing. The SVG\n // string is written into our own <pre> below either way.\n const { svg, bindFunctions, diagramType } = await mermaid.render(generateMermaidUUID(), props.code);\n if (!ref.current || cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n\n ref.current.innerHTML = svg;\n bindFunctions?.(ref.current);\n hasRenderedRef.current = true;\n needsCorrectiveRef.current = false;\n setHasRendered(true);\n setChartType(diagramType);\n setRenderError(false);\n } catch {\n if (cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n // Mid-stream failures are expected (truncated code) — keep the last\n // good diagram / source placeholder and wait for more bytes. The\n // corrective pass after streaming ends reports real errors.\n if (streaming) {\n return;\n }\n // End-of-stream corrective pass: the final source no longer renders,\n // so the error must surface even over a mid-stream diagram. Consume\n // the obligation so later unrelated failures don't inherit it.\n if (needsCorrectiveRef.current) {\n needsCorrectiveRef.current = false;\n setChartType('unknown');\n setRenderError(true);\n return;\n }\n // Static rule: never clobber a rendered diagram (theme-flip\n // re-renders, un-flagged code updates from static consumers).\n if (hasRenderedRef.current) {\n return;\n }\n setChartType('unknown');\n setRenderError(true);\n }\n };\n\n void renderMermaid();\n\n return () => {\n cancelled = true;\n };\n // `streaming` in the deps is what drives the end-of-stream corrective\n // pass: the flip to false re-runs this effect on the (unchanged) final\n // code, so the last state reflects the full diagram source.\n }, [props.code, isDark, showOriginalCode, streaming]);\n\n const viewSvgInNewWindow = useCallback(() => {\n handleViewSVGInNewWindow(ref.current?.querySelector('svg'), isDark);\n }, [isDark]);\n\n // Show the raw source instead of the diagram container when the user asked\n // for it, when the (post-stream) render failed, or before the first\n // successful render (SSR output and the streaming warm-up phase). The\n // diagram container below stays MOUNTED throughout — merely hidden — so\n // `ref` is always available for mermaid to render into; unmounting it would\n // make the effect's `!ref.current` guard bail forever.\n const showSourceFallback = showOriginalCode || renderError || !hasRendered;\n\n return (\n <>\n {showSourceFallback && (\n <CodeHighlightTabs\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={[\n {\n fileName: renderError ? 'Mermaid Render Error' : 'mermaid',\n code: props.code,\n language: 'mermaid',\n },\n ]}\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n styles={{\n filesScrollarea: {\n right: '90px',\n },\n }}\n controls={\n // The \"Render Mermaid\" control only makes sense as the way back\n // from the user-toggled source view. In the error and warm-up\n // fallbacks `showOriginalCode` is already false, so the control\n // would be a no-op — hide it there. (No `!renderError` conjunct:\n // the toggle is only reachable from the visible diagram view,\n // and while the source view is open the effect early-returns,\n // so showOriginalCode && renderError is unreachable.)\n showOriginalCode\n ? [\n <CodeHighlightControl\n tooltipLabel=\"Render Mermaid\"\n key=\"gpt\"\n onClick={() => {\n setShowOriginalCode(false);\n }}\n >\n <Flex align=\"center\" justify=\"center\" w={18} h={18}>\n <span className=\"icon-[gravity-ui--logo-mermaid] relative bottom-[1px] text-[16px]\"></span>\n </Flex>\n </CodeHighlightControl>,\n ]\n : []\n }\n withBorder\n withExpandButton\n />\n )}\n <div\n className={`aim-mantine-mermaid-code ${isDark ? 'dark' : ''}`}\n style={\n showSourceFallback\n ? {\n display: 'none',\n }\n : {}\n }\n >\n <div className=\"chart-header\">\n <div className=\"chart-type-tag\">{chartType}</div>\n <Flex align=\"center\" justify=\"flex-end\" gap={0}>\n <Tooltip label=\"Show Mermaid Code\">\n <ActionIcon\n size={28}\n className=\"action-icon\"\n variant=\"transparent\"\n onClick={() => {\n setShowOriginalCode(true);\n }}\n >\n <Flex align=\"center\" justify=\"center\" w={18} h={18}>\n <span className=\"icon-[entypo--code] relative bottom-[0.25px] text-[16px]\"></span>\n </Flex>\n </ActionIcon>\n </Tooltip>\n <CopyButton value={props.code}>\n {({ copied, copy }) => (\n <Tooltip label={copied ? 'Copied' : 'Copy'} withArrow position=\"right\">\n <ActionIcon variant=\"transparent\" size={28} className=\"action-icon\" onClick={copy}>\n {copied ? (\n <span className=\"icon-origin-[lucide--check] text-[18px]\"></span>\n ) : (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n width=\"18px\"\n height=\"18px\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"></path>\n <path d=\"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z\"></path>\n <path d=\"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2\"></path>\n </svg>\n )}\n </ActionIcon>\n </Tooltip>\n )}\n </CopyButton>\n </Flex>\n </div>\n <pre ref={ref} style={PRE_STYLE} onClick={viewSvgInNewWindow} />\n </div>\n </>\n );\n});\n\nMantineAIMMermaidCode.displayName = 'MantineAIMMermaidCode';\n\nexport default MantineAIMMermaidCode;\n","import { useAIMarkdownMetadata } from '@ai-react-markdown/core';\nimport { MantineAIMarkdownMetadata } from '../defs';\n\n/**\n * Typed wrapper around the core {@link useAIMarkdownMetadata} hook.\n *\n * Returns the current metadata defaulting to {@link MantineAIMarkdownMetadata}.\n * Accepts an optional generic parameter for further extension.\n *\n * Metadata lives in a separate React context from the render state, meaning\n * metadata updates do not trigger re-renders in components that only consume\n * render state.\n *\n * Must be called inside a component rendered within the `<MantineAIMarkdown>` tree.\n *\n * @typeParam TMetadata - Metadata type (defaults to {@link MantineAIMarkdownMetadata}).\n * @returns The current metadata, or `undefined` if none was provided.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const metadata = useMantineAIMarkdownMetadata();\n * // Access Mantine-specific metadata fields\n * }\n * ```\n */\nexport const useMantineAIMarkdownMetadata = <\n TMetadata extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n>() => {\n return useAIMarkdownMetadata<TMetadata>();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaA,IAAAA,gBAA8B;AAC9B,IAAAC,eAAuB;AACvB,IAAAA,eAAsF;;;ACftF,mBAAqB;AACrB,kBAA2B;AAgBzB;AADF,IAAM,kCAA8B,mBAAK,CAAC,EAAE,UAAU,UAAU,MAAM,MACpE,4CAAC,0BAAW,GAAE,QAAO,IAAI,UAAU,OAChC,UACH,CACD;AAED,4BAA4B,cAAc;AAE1C,IAAO,4BAAQ;;;ACRN,IAAAC,sBAAA;AADT,IAAM,+BAA+D,CAAC,EAAE,SAAS,MAAM;AACrF,SAAO,6CAAC,SAAI,WAAU,4BAA4B,UAAS;AAC7D;AAEA,IAAO,6BAAQ;;;ACVf,IAAAC,eAA0F;AAmCnF,IAAM,uCAAsE,OAAO,OAAO;AAAA,EAC/F,GAAG;AAAA,EACH,WAAW,OAAO,OAAO;AAAA,IACvB,iBAAiB;AAAA,IACjB,2BAA2B;AAAA,EAC7B,CAAC;AACH,CAAC;;;AChDD,IAAAC,gBAA8C;AAC9C,IAAAC,yBAAiD;AACjD,6BAA8B;AAC9B,uBAAiB;;;ACLjB,IAAAC,eAAyC;AA0BlC,IAAM,kCAAkC,MAExC;AACL,aAAO,uCAAkC;AAC3C;;;AC5BA,IAAAC,gBAA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KAAK,SAAS,aAAa,KAAK,YAAY,UAAU,CAAC,KAAK,UAAU;AACjF,aAAO,6CAAC,SAAK,GAAG,aAAa;AAAA,IAC/B;AACA,UAAM,MAAM,YAAY,MAAM,UAAU,OAAO,UAAU,CAAC;AAC1D,UAAM,mBAAoB,KAAK,YAAY,WACvC,KAAK,CAAC,cAAsB,UAAU,WAAW,WAAW,CAAC,GAC7D,UAAU,YAAY,MAAM;AAChC,UAAM,WAAW,KAAK,SAAS,IAAI,CAAC,UAA8B,MAAM,SAAS,EAAE,EAAE,KAAK,IAAI;AAC9F,WAAO,6CAAC,mBAA4B,UAAoB,eAAe,oBAAxC,GAA0D;AAAA,EAC3F;AACF;AAYA,IAAM,6BAA6B,CAGjC;AAAA,EACA,YAAAC,cAAa;AAAA,EACb,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAoD;AAClD,QAAM,6BAAyB,6BAAe,gBAAgB;AAE9D,QAAM,qBAAiB,uBAAQ,MAAM;AACnC,WAAO,yBAAyB,EAAE,GAAG,yBAAyB,GAAG,uBAAuB,IAAI;AAAA,EAC9F,GAAG,CAAC,sBAAsB,CAAC;AAE3B,QAAM,0BAAsB,qCAAuB,OAAO;AAE1D,SACE;AAAA,IAAC,aAAAC;AAAA,IAAA;AAAA,MACC,YAAYD;AAAA,MACZ;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB,aAAa,eAAe;AAAA,MAC3B,GAAG;AAAA;AAAA,EACN;AAEJ;AAoBO,IAAM,wBAAoB,oBAAK,0BAA0B;AAEhE,kBAAkB,cAAc;AAEhC,IAAO,4BAAQ;;;AOlIf,IAAAE,eAAsC;AA0B/B,IAAM,+BAA+B,MAErC;AACL,aAAO,oCAAiC;AAC1C;","names":["import_react","import_core","import_jsx_runtime","import_core","import_react","import_code_highlight","import_core","import_react","import_core","import_jsx_runtime","mermaid","import_jsx_runtime","SpecialCodeLanguage","hljs","import_core","import_jsx_runtime","Typography","AIMarkdown","import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/MantineAIMarkdown.tsx","../src/components/typography/MantineTypography.tsx","../src/components/extra-styles/DefaultExtraStyles/index.tsx","../src/defs.tsx","../src/components/customized/PreCode.tsx","../src/hooks/useMantineAIMarkdownRenderState.ts","../src/components/customized/MermaidCode/index.tsx","../src/hooks/useMantineAIMarkdownMetadata.ts"],"sourcesContent":["/**\n * Public API surface for `@ai-react-markdown/mantine`.\n *\n * Re-exports the Mantine-integrated AI markdown component, its supporting\n * sub-components, extended types, default configuration, and typed hooks.\n *\n * @packageDocumentation\n */\n\n// --- Components ---\n\n/** Props for the main {@link MantineAIMarkdown} component. */\nexport type { MantineAIMarkdownProps } from './MantineAIMarkdown';\n\n/** Main component -- Mantine-integrated AI markdown renderer (default export). */\nexport { default } from './MantineAIMarkdown';\n\n/** Mantine-themed typography wrapper used by default inside {@link MantineAIMarkdown}. */\nexport { default as MantineAIMarkdownTypography } from './components/typography/MantineTypography';\n\n/** Default extra styles wrapper providing Mantine-compatible CSS scoping and overrides. */\nexport { default as MantineAIMDefaultExtraStyles } from './components/extra-styles/DefaultExtraStyles';\n\n// --- Types, config, and hooks ---\n\n/** Extended render configuration and metadata types for the Mantine integration. */\nexport type { MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata } from './defs';\n\n/** Default Mantine render configuration (frozen). */\nexport { defaultMantineAIMarkdownRenderConfig } from './defs';\n\n/** Typed hook for accessing render state with Mantine-specific config fields. */\nexport { useMantineAIMarkdownRenderState } from './hooks/useMantineAIMarkdownRenderState';\n\n/** Typed hook for accessing metadata within the Mantine AI markdown tree. */\nexport { useMantineAIMarkdownMetadata } from './hooks/useMantineAIMarkdownMetadata';\n","/**\n * Main Mantine integration component for AI markdown rendering.\n *\n * Wraps the core {@link AIMarkdown} component with Mantine-specific defaults:\n * - {@link MantineAIMarkdownTypography} as the typography wrapper\n * - {@link MantineAIMDefaultExtraStyles} as the extra styles wrapper\n * - {@link MantineAIMPreCode} as the default `<pre>` component (with syntax\n * highlighting via Mantine's CodeHighlight and mermaid diagram support)\n * - Automatic color scheme detection via Mantine's `useComputedColorScheme`\n *\n * @module MantineAIMarkdown\n */\n\nimport { memo, useMemo } from 'react';\nimport AIMarkdown from '@ai-react-markdown/core';\nimport { type AIMarkdownProps, type AIMarkdownCustomComponents, useStableValue } from '@ai-react-markdown/core';\nimport MantineAIMarkdownTypography from './components/typography/MantineTypography';\nimport MantineAIMDefaultExtraStyles from './components/extra-styles/DefaultExtraStyles';\nimport { MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata, defaultMantineAIMarkdownRenderConfig } from './defs';\nimport MantineAIMPreCode from './components/customized/PreCode';\nimport { useComputedColorScheme } from '@mantine/core';\n\n/**\n * Props for the {@link MantineAIMarkdown} component.\n *\n * Extends {@link AIMarkdownProps} with Mantine-specific config and metadata generics.\n * All core props (`content`, `streaming`, `fontSize`, `config`, etc.) are inherited.\n *\n * @typeParam TConfig - Render configuration type, defaults to {@link MantineAIMarkdownRenderConfig}.\n * @typeParam TRenderData - Metadata type, defaults to {@link MantineAIMarkdownMetadata}.\n */\nexport interface MantineAIMarkdownProps<\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n TRenderData extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n> extends AIMarkdownProps<TConfig, TRenderData> {}\n\n/**\n * Default custom component overrides applied by the Mantine integration.\n *\n * Overrides the `<pre>` element to extract code blocks and render them via\n * {@link MantineAIMPreCode}, which provides syntax highlighting, expand/collapse,\n * and mermaid diagram support. Falls back to a plain `<pre>` when the child\n * is not a recognized code element.\n */\nconst DefaultCustomComponents: AIMarkdownCustomComponents = {\n pre: ({ node, ...usefulProps }) => {\n const code = node?.children[0] as\n | {\n type: string;\n tagName?: string;\n position?: { start?: { offset?: number } };\n properties?: Record<string, unknown>;\n children: { value?: string }[];\n }\n | undefined;\n if (!code || code.type !== 'element' || code.tagName !== 'code' || !code.position) {\n return <pre {...usefulProps} />;\n }\n const key = `pre-code-${node?.position?.start?.offset || 0}`;\n const detectedLanguage = (code.properties?.className as string[])\n ?.find((className: string) => className.startsWith('language-'))\n ?.substring('language-'.length);\n const codeText = code.children.map((child: { value?: string }) => child.value ?? '').join('\\n');\n return <MantineAIMPreCode key={key} codeText={codeText} existLanguage={detectedLanguage} />;\n },\n};\n\n/**\n * Inner (non-memoized) implementation of the Mantine AI markdown component.\n *\n * Merges caller-provided `customComponents` with the Mantine defaults (the caller's\n * overrides take precedence). Automatically resolves the color scheme from Mantine's\n * `useComputedColorScheme` when no explicit `colorScheme` prop is provided.\n *\n * @typeParam TConfig - Render configuration type.\n * @typeParam TRenderData - Metadata type.\n */\nconst MantineAIMarkdownComponent = <\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n TRenderData extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n>({\n Typography = MantineAIMarkdownTypography,\n ExtraStyles = MantineAIMDefaultExtraStyles,\n defaultConfig = defaultMantineAIMarkdownRenderConfig as TConfig,\n customComponents,\n colorScheme,\n ...props\n}: MantineAIMarkdownProps<TConfig, TRenderData>) => {\n const stableCustomComponents = useStableValue(customComponents);\n\n const usedComponents = useMemo(() => {\n return stableCustomComponents ? { ...DefaultCustomComponents, ...stableCustomComponents } : DefaultCustomComponents;\n }, [stableCustomComponents]);\n\n const computedColorScheme = useComputedColorScheme('light');\n\n return (\n <AIMarkdown<MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata>\n Typography={Typography}\n ExtraStyles={ExtraStyles}\n defaultConfig={defaultConfig}\n customComponents={usedComponents}\n colorScheme={colorScheme ?? computedColorScheme}\n {...props}\n />\n );\n};\n\n/**\n * Mantine-integrated AI markdown renderer.\n *\n * A memoized wrapper around the core `<AIMarkdown>` component that provides\n * Mantine-themed typography, code highlighting (via `@mantine/code-highlight`),\n * mermaid diagram rendering, and automatic color scheme detection.\n *\n * This is the default export of `@ai-react-markdown/mantine`.\n *\n * @example\n * ```tsx\n * import MantineAIMarkdown from '@ai-react-markdown/mantine';\n *\n * function Chat({ content }: { content: string }) {\n * return <MantineAIMarkdown content={content} />;\n * }\n * ```\n */\nexport const MantineAIMarkdown = memo(MantineAIMarkdownComponent);\n\nMantineAIMarkdown.displayName = 'MantineAIMarkdown';\n\nexport default MantineAIMarkdown as typeof MantineAIMarkdownComponent;\n","import { memo } from 'react';\nimport { Typography } from '@mantine/core';\nimport type { AIMarkdownTypographyProps } from '@ai-react-markdown/core';\n\n/**\n * Mantine-themed typography wrapper for AI markdown content.\n *\n * Replaces the core default typography component with Mantine's `<Typography>`\n * element, applying the configured `fontSize` at full width. This ensures all\n * rendered markdown inherits Mantine's font family, line height, and theming.\n *\n * Used as the default `Typography` prop in {@link MantineAIMarkdown}.\n * Can be replaced by passing a custom `Typography` component.\n *\n * @param props - Standard {@link AIMarkdownTypographyProps} from the core package.\n */\nconst MantineAIMarkdownTypography = memo(({ children, fontSize, style }: AIMarkdownTypographyProps) => (\n <Typography w=\"100%\" fz={fontSize} style={style}>\n {children}\n </Typography>\n));\n\nMantineAIMarkdownTypography.displayName = 'MantineAIMarkdownTypography';\n\nexport default MantineAIMarkdownTypography;\n","import React from 'react';\nimport { AIMarkdownExtraStylesComponent } from '@ai-react-markdown/core';\nimport './styles.scss';\n\n/**\n * Default extra styles wrapper for the Mantine integration.\n *\n * Wraps markdown content in a `<div>` with the `aim-mantine-extra-styles` CSS class,\n * which provides Mantine-compatible typography overrides including:\n * - Relative `em`-based Mantine spacing and font-size CSS custom properties\n * - Heading, list, paragraph, blockquote, and code styling\n * - Definition list layout\n *\n * Used as the default `ExtraStyles` prop in {@link MantineAIMarkdown}.\n */\nconst MantineAIMDefaultExtraStyles: AIMarkdownExtraStylesComponent = ({ children }) => {\n return <div className=\"aim-mantine-extra-styles\">{children}</div>;\n};\n\nexport default MantineAIMDefaultExtraStyles;\n","/**\n * Mantine-specific type definitions and default configuration.\n *\n * Extends the core {@link AIMarkdownRenderConfig} and {@link AIMarkdownMetadata}\n * with Mantine-themed options such as uniform heading sizes and code block behavior.\n *\n * @module defs\n */\n\nimport { AIMarkdownRenderConfig, AIMarkdownMetadata, defaultAIMarkdownRenderConfig } from '@ai-react-markdown/core';\n\n/**\n * Extended render configuration for the Mantine integration.\n *\n * Inherits all core config fields (extra syntax, display optimizations) and adds\n * Mantine-specific options for typography sizing and code block behavior.\n */\nexport interface MantineAIMarkdownRenderConfig extends AIMarkdownRenderConfig {\n /** Code block rendering options. */\n codeBlock: {\n /**\n * Whether code blocks start in their expanded state.\n * When `false`, long code blocks are collapsed with an expand button.\n *\n * @default true\n */\n defaultExpanded: boolean;\n\n /**\n * When `true`, uses `highlight.js` auto-detection to determine the language\n * of code blocks that lack an explicit language annotation.\n *\n * @default false\n */\n autoDetectUnknownLanguage: boolean;\n };\n}\n\n/**\n * Default Mantine render configuration.\n *\n * Extends {@link defaultAIMarkdownRenderConfig} with Mantine-specific defaults.\n * Frozen to prevent accidental mutation.\n */\nexport const defaultMantineAIMarkdownRenderConfig: MantineAIMarkdownRenderConfig = Object.freeze({\n ...defaultAIMarkdownRenderConfig,\n codeBlock: Object.freeze({\n defaultExpanded: true,\n autoDetectUnknownLanguage: false,\n }),\n});\n\n/**\n * Metadata type for the Mantine integration.\n *\n * Currently identical to {@link AIMarkdownMetadata}. Exists as an extension point\n * so that consumers can augment metadata in Mantine-specific wrappers without\n * needing to reference the core type directly.\n */\nexport interface MantineAIMarkdownMetadata extends AIMarkdownMetadata {}\n","'use client';\n\nimport { HTMLAttributes, memo, useMemo } from 'react';\nimport { CodeHighlight, CodeHighlightTabs } from '@mantine/code-highlight';\nimport { deepParseJson } from 'deep-parse-json';\nimport hljs from 'highlight.js';\nimport { useMantineAIMarkdownRenderState } from '../../hooks/useMantineAIMarkdownRenderState';\nimport MantineAIMMermaidCode from './MermaidCode';\n\n/**\n * Code languages that receive specialized rendering instead of standard\n * syntax-highlighted code blocks. Adding a new member here automatically\n * marks that language as \"special\" — you only need to add the corresponding\n * rendering branch in the component's return.\n */\nenum SpecialCodeLanguage {\n /** Rendered as interactive diagrams via {@link MantineAIMMermaidCode} */\n Mermaid = 'mermaid',\n}\n\n/** O(1) lookup set, derived from {@link SpecialCodeLanguage}. */\nconst SPECIAL_LANGUAGES = new Set<string>(Object.values(SpecialCodeLanguage));\n\n/**\n * Mantine code block renderer for `<pre>` elements.\n *\n * Replaces the default `<pre>` rendering with Mantine's {@link CodeHighlight} or\n * {@link CodeHighlightTabs} components, providing syntax highlighting, expand/collapse\n * behavior, and file-name tabs.\n *\n * Behavior:\n * - If the code block has an explicit language annotation, uses that language.\n * - If no language is specified and `config.codeBlock.autoDetectUnknownLanguage` is\n * enabled, uses `highlight.js` auto-detection.\n * - Mermaid code blocks (`language-mermaid`) are rendered as interactive diagrams\n * via {@link MantineAIMMermaidCode}.\n * - JSON code blocks are deep-parsed and pretty-printed before display.\n * - Unrecognized languages render as plaintext with an \"unknown\" label using\n * {@link CodeHighlight} (no tabs).\n * - Recognized languages render with {@link CodeHighlightTabs} showing the\n * language name as the tab label.\n *\n * @param props.codeText - The raw text content of the code block.\n * @param props.existLanguage - Language identifier extracted from the `language-*` CSS class, if present.\n */\nconst MantineAIMPreCode = memo(\n (\n props: HTMLAttributes<HTMLPreElement> & {\n codeText: string;\n existLanguage?: string;\n }\n ) => {\n const renderState = useMantineAIMarkdownRenderState();\n\n const codeLanguage = useMemo(() => {\n if (props.existLanguage) return props.existLanguage;\n if (renderState.config.codeBlock.autoDetectUnknownLanguage) {\n return hljs.highlightAuto(props.codeText).language || '';\n }\n return '';\n }, [props.existLanguage, props.codeText, renderState.config.codeBlock.autoDetectUnknownLanguage]);\n\n const [usedCodeLanguage, usedFileName] = useMemo(() => {\n if (!codeLanguage) return ['plaintext', 'unknown'];\n if (!hljs.getLanguage(codeLanguage)) {\n return ['plaintext', codeLanguage];\n }\n return [codeLanguage, codeLanguage];\n }, [codeLanguage]);\n\n const isSpecialCodeBlock = SPECIAL_LANGUAGES.has(codeLanguage);\n\n const normalCodeBlockContent = useMemo(() => {\n if (isSpecialCodeBlock) return null;\n let usedCodeStr = props.codeText;\n if (usedCodeStr && usedCodeLanguage.toLowerCase() === 'json') {\n const deepParsedResult = deepParseJson(usedCodeStr);\n usedCodeStr =\n typeof deepParsedResult === 'string' ? deepParsedResult : JSON.stringify(deepParsedResult, null, 2);\n }\n return usedFileName === 'unknown' ? (\n <CodeHighlight\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={usedCodeStr}\n withBorder\n withExpandButton\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n />\n ) : (\n <CodeHighlightTabs\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={[\n {\n fileName: usedFileName,\n code: usedCodeStr,\n language: usedCodeLanguage,\n },\n ]}\n withBorder\n withExpandButton\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n />\n );\n }, [\n isSpecialCodeBlock,\n props.codeText,\n usedCodeLanguage,\n usedFileName,\n renderState.fontSize,\n renderState.config.codeBlock.defaultExpanded,\n ]);\n\n const specialCodeBlockContent = useMemo(() => {\n switch (codeLanguage) {\n case SpecialCodeLanguage.Mermaid:\n return <MantineAIMMermaidCode code={props.codeText} />;\n default:\n return null;\n }\n }, [codeLanguage, props.codeText]);\n\n return isSpecialCodeBlock ? specialCodeBlockContent : normalCodeBlockContent;\n }\n);\n\nMantineAIMPreCode.displayName = 'MantineAIMPreCode';\n\nexport default MantineAIMPreCode;\n","import { useAIMarkdownRenderState } from '@ai-react-markdown/core';\nimport { MantineAIMarkdownRenderConfig } from '../defs';\n\n/**\n * Typed wrapper around the core {@link useAIMarkdownRenderState} hook.\n *\n * Returns the current {@link AIMarkdownRenderState} defaulting to\n * {@link MantineAIMarkdownRenderConfig}. Accepts an optional generic parameter\n * for further extension, giving consumers direct access to Mantine-specific\n * config fields (`codeBlock`, etc.) without manual annotation.\n *\n * Must be called inside a component rendered within the `<MantineAIMarkdown>` tree.\n * Throws if called outside the provider boundary.\n *\n * @typeParam TConfig - Config type (defaults to {@link MantineAIMarkdownRenderConfig}).\n * @returns The current render state typed with `TConfig`.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { config, streaming, colorScheme } = useMantineAIMarkdownRenderState();\n * const isExpanded = config.codeBlock.defaultExpanded;\n * // ...\n * }\n * ```\n */\nexport const useMantineAIMarkdownRenderState = <\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n>() => {\n return useAIMarkdownRenderState<TConfig>();\n};\n","'use client';\n\nimport React, { memo, useEffect, useRef, useState, useCallback } from 'react';\nimport { CodeHighlightControl, CodeHighlightTabs } from '@mantine/code-highlight';\nimport { ActionIcon, CopyButton, Flex, Tooltip } from '@mantine/core';\nimport mermaid from 'mermaid';\nimport { useMantineAIMarkdownRenderState } from '../../../hooks/useMantineAIMarkdownRenderState';\nimport './styles.scss';\n\n/** Static `<pre>` style for the mermaid container. */\nconst PRE_STYLE = { cursor: 'pointer', overflow: 'auto', width: '100%', padding: '0.5rem' } as const;\n\n/**\n * What the component currently shows. One value instead of separate\n * `hasRendered`/`renderError`/`chartType` fields whose combinations had to\n * be kept coherent by hand:\n * - `source`: warm-up / SSR fallback — raw code as a plain code block\n * (nothing rendered yet this generation).\n * - `diagram`: the last successful SVG is up.\n * - `error`: the error tab — only a post-stream corrective failure or a\n * never-rendered static failure can enter this state.\n *\n * The user's source toggle (`showOriginalCode`) is deliberately NOT a\n * phase: it overlays any view and flipping it back must restore the prior\n * one unchanged.\n */\ntype MermaidView = { kind: 'source' } | { kind: 'diagram'; chartType: string } | { kind: 'error' };\n\n/** Equality used to skip no-op view updates — repeat mid-stream successes\n * of the same chart type must not re-render the host per chunk. */\nconst sameView = (a: MermaidView, b: MermaidView): boolean =>\n a.kind === 'diagram' && b.kind === 'diagram' ? a.chartType === b.chartType : a.kind === b.kind;\n\n/** Theme mermaid.initialize was last called with. mermaid's config is a\n * module-level singleton, so re-asserting an unchanged theme before every\n * render attempt (each streamed chunk re-runs the effect) is pure waste —\n * but instances under providers with DIFFERENT schemes must each\n * re-assert before their own render, so the cache is module-level and\n * checked per attempt rather than hoisted into a per-instance effect. */\nlet initializedTheme: 'dark' | 'light' | null = null;\n\nconst ensureMermaidInitialized = (isDark: boolean) => {\n const theme = isDark ? 'dark' : 'light';\n if (initializedTheme === theme) return;\n mermaid.initialize({\n startOnLoad: false,\n securityLevel: 'strict',\n theme: isDark ? 'dark' : 'base',\n darkMode: isDark,\n // Without a svgContainingElement, a draw-phase throw (an error that\n // got past mermaid.parse) leaves mermaid's temp element orphaned in\n // document.body — its error path only cleans up when this flag is\n // set. We render our own error tab anyway, so mermaid's built-in\n // error diagram is dead weight here regardless.\n suppressErrorRendering: true,\n });\n initializedTheme = theme;\n};\n\n/**\n * Generate a unique ID for mermaid SVG rendering.\n * Combines a timestamp with a random suffix to avoid collisions when\n * multiple mermaid diagrams render concurrently.\n *\n * @returns A unique string in the format `mermaid-{timestamp}-{random}`.\n */\nconst generateMermaidUUID = () => {\n return `mermaid-${new Date().getTime()}-${Math.random().toString(36).slice(2, 10)}`;\n};\n\n/**\n * Open the rendered mermaid SVG in a new browser window.\n *\n * Clones the SVG element, applies a background color matching the current\n * color scheme, serializes it to an object URL, and opens it in a new tab.\n * The object URL is revoked after a short delay to free memory.\n *\n * @param svgElement - The rendered SVG element to view, or `null`/`undefined` to no-op.\n * @param isDark - Whether the current color scheme is dark (used for background color).\n */\nconst handleViewSVGInNewWindow = (svgElement: SVGElement | null | undefined, isDark: boolean) => {\n if (!svgElement) return;\n const targetSvg = svgElement.cloneNode(true) as SVGElement;\n targetSvg.style.backgroundColor = isDark ? '#242424' : 'white';\n const text = new XMLSerializer().serializeToString(targetSvg);\n const blob = new Blob([text], { type: 'image/svg+xml' });\n const url = URL.createObjectURL(blob);\n const win = window.open(url);\n if (win) {\n setTimeout(() => URL.revokeObjectURL(url), 5000);\n }\n};\n\n/**\n * Interactive mermaid diagram renderer.\n *\n * Parses and renders mermaid diagram source code into an inline SVG visualization.\n * Automatically adapts to the current Mantine color scheme (light/dark) by\n * re-initializing mermaid with the appropriate theme.\n *\n * Features:\n * - Live SVG rendering with automatic dark/light theme switching\n * - Fallback to raw source code display on parse/render errors\n * - Toggle between rendered diagram and raw mermaid source\n * - Click on the rendered diagram to open the SVG in a new browser window\n * - Copy button for the raw mermaid source code\n * - Chart type label extracted from mermaid's parse result\n * - Preserves the last successful render across transient parse failures\n *\n * ## Streaming contract\n *\n * While `streaming` is true (from render state), the code prop is usually a\n * truncated prefix of the final diagram, so parse failures are *expected*,\n * not exceptional:\n * - Before the first successful render, the raw source is shown as a plain\n * code block (never the error tab).\n * - After a success, the last good SVG stays up; each subsequent chunk is\n * re-attempted and the diagram refreshes only on the next success.\n * - When streaming ends (`streaming` is an effect dep), one corrective pass\n * runs on the final code: success refreshes the diagram, failure surfaces\n * the real error tab — even over a previously rendered mid-stream diagram,\n * because that diagram no longer matches the final source. The pending\n * corrective obligation is tracked by `needsCorrectiveRef` (armed on the\n * streaming→false edge, consumed by the next completed attempt), so ONLY\n * that one pass may clobber a rendered diagram; any later failure (e.g. a\n * transient throw on a theme-flip re-render) falls back to the static rule\n * below.\n * - A streaming→true edge marks a NEW generation (chat \"regenerate\" reuses\n * the same component instance when the block's source offset — and thus\n * its React key — is unchanged). All per-generation state is reset so the\n * warm-up shows the new source instead of the previous generation's stale\n * diagram or error tab.\n *\n * ## Static contract (`streaming` stays false)\n *\n * Without streaming edges, failures follow the original conservative rule:\n * the error tab shows only while nothing has rendered yet. Once a diagram is\n * up, later failures (theme-flip re-render, a not-yet-complete `code` update\n * from a consumer that didn't pass `streaming`) keep the last good diagram\n * instead of clobbering it with an error.\n *\n * @param props.code - Raw mermaid diagram source code to render.\n */\nconst MantineAIMMermaidCode = memo((props: { code: string }) => {\n const renderState = useMantineAIMarkdownRenderState();\n const isDark = renderState.colorScheme === 'dark';\n const streaming = renderState.streaming;\n\n const ref = useRef<HTMLPreElement>(null);\n const renderVersionRef = useRef(0);\n /** Mirrors `view` for reads inside the async render closure — state reads\n * there can be stale when deps change mid-flight. */\n const viewRef = useRef<MermaidView>({ kind: 'source' });\n /** Previous `streaming` value, for edge detection in the effect. */\n const prevStreamingRef = useRef(false);\n /** Armed on the streaming→false edge: the next completed render attempt is\n * the end-of-stream corrective pass, whose failure must surface even over\n * a rendered diagram. Consumed (reset) by that attempt's success OR\n * surfaced failure, so later unrelated failures can't clobber the SVG. */\n const needsCorrectiveRef = useRef(false);\n /** Inputs of the render whose SVG currently sits in the host `<pre>`.\n * When the effect re-runs with the same (code, theme) pair — the\n * post-stream corrective flip on an already-final diagram, or returning\n * from the source view — the DOM already holds that exact render, so\n * the attempt (and its parse + temp-element render) is skipped. */\n const lastSuccessRef = useRef<{ code: string; isDark: boolean } | null>(null);\n const [view, setViewState] = useState<MermaidView>({ kind: 'source' });\n const [showOriginalCode, setShowOriginalCode] = useState(false);\n\n useEffect(() => {\n // View updates funnel through here so the ref mirror can't desync from\n // the state, and no-op updates are dropped (repeat mid-stream successes\n // and idempotent edge resets must not re-render the host per chunk).\n const applyView = (next: MermaidView) => {\n viewRef.current = next;\n setViewState((prev) => (sameView(prev, next) ? prev : next));\n };\n\n // Streaming edge detection MUST run before any early return — the first\n // chunk of a new stream can arrive while the code is still empty.\n if (streaming && !prevStreamingRef.current) {\n // Rising edge = a new generation is starting on this same instance\n // (same block offset → same React key → no remount on regenerate).\n // Reset all per-generation state so warm-up shows the incoming source,\n // not the previous generation's stale diagram or error tab. Everything\n // here is idempotent — a StrictMode double-run is harmless.\n needsCorrectiveRef.current = false;\n lastSuccessRef.current = null;\n applyView({ kind: 'source' });\n if (ref.current) {\n ref.current.innerHTML = '';\n }\n } else if (!streaming && prevStreamingRef.current) {\n // Falling edge = the stream just ended; arm the corrective pass.\n needsCorrectiveRef.current = true;\n }\n prevStreamingRef.current = streaming;\n if (!props.code || !ref.current || showOriginalCode) {\n return;\n }\n\n // The SVG in the DOM already came from exactly this (code, theme) pair —\n // nothing to recompute. This also SATISFIES a pending corrective\n // obligation: the identical successful render IS the verdict on the\n // final source, so the obligation is consumed, not left armed for some\n // later unrelated failure to inherit.\n if (lastSuccessRef.current?.code === props.code && lastSuccessRef.current.isDark === isDark) {\n needsCorrectiveRef.current = false;\n return;\n }\n\n const renderVersion = ++renderVersionRef.current;\n let cancelled = false;\n\n const renderMermaid = async () => {\n try {\n ensureMermaidInitialized(isDark);\n const parseResult = await mermaid.parse(props.code);\n if (!parseResult) {\n throw new Error('Failed to parse mermaid code');\n }\n\n if (!ref.current || cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n\n // Deliberately NOT passing `ref.current` as mermaid's\n // svgContainingElement: before the first success the host container\n // is hidden with `display: none` (source fallback is showing), and\n // mermaid measures text via getBBox during render — inside a\n // display:none subtree layout never runs, every measurement is 0,\n // and the diagram comes out as a ~16px SVG. With the argument\n // omitted, mermaid renders in a temp element appended to\n // `document.body` (its default path, cleaned up internally), so\n // measurement works no matter what our container is doing. The SVG\n // string is written into our own <pre> below either way.\n const { svg, bindFunctions, diagramType } = await mermaid.render(generateMermaidUUID(), props.code);\n if (!ref.current || cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n\n ref.current.innerHTML = svg;\n bindFunctions?.(ref.current);\n needsCorrectiveRef.current = false;\n lastSuccessRef.current = { code: props.code, isDark };\n applyView({ kind: 'diagram', chartType: diagramType });\n } catch {\n if (cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n // Mid-stream failures are expected (truncated code) — keep the last\n // good diagram / source placeholder and wait for more bytes. The\n // corrective pass after streaming ends reports real errors.\n if (streaming) {\n return;\n }\n // End-of-stream corrective pass: the final source no longer renders,\n // so the error must surface even over a mid-stream diagram. Consume\n // the obligation so later unrelated failures don't inherit it.\n if (needsCorrectiveRef.current) {\n needsCorrectiveRef.current = false;\n applyView({ kind: 'error' });\n return;\n }\n // Static rule: never clobber a rendered diagram (theme-flip\n // re-renders, un-flagged code updates from static consumers).\n if (viewRef.current.kind === 'diagram') {\n return;\n }\n applyView({ kind: 'error' });\n }\n };\n\n void renderMermaid();\n\n return () => {\n cancelled = true;\n };\n // `streaming` in the deps is what drives the end-of-stream corrective\n // pass: the flip to false re-runs this effect on the (unchanged) final\n // code, so the last state reflects the full diagram source.\n }, [props.code, isDark, showOriginalCode, streaming]);\n\n const viewSvgInNewWindow = useCallback(() => {\n handleViewSVGInNewWindow(ref.current?.querySelector('svg'), isDark);\n }, [isDark]);\n\n // Show the raw source instead of the diagram container when the user asked\n // for it, when the (post-stream) render failed, or before the first\n // successful render (SSR output and the streaming warm-up phase). The\n // diagram container below stays MOUNTED throughout — merely hidden — so\n // `ref` is always available for mermaid to render into; unmounting it would\n // make the effect's `!ref.current` guard bail forever.\n const showSourceFallback = showOriginalCode || view.kind !== 'diagram';\n\n return (\n <>\n {showSourceFallback && (\n <CodeHighlightTabs\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={[\n {\n fileName: view.kind === 'error' ? 'Mermaid Render Error' : 'mermaid',\n code: props.code,\n language: 'mermaid',\n },\n ]}\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n styles={{\n filesScrollarea: {\n right: '90px',\n },\n }}\n controls={\n // The \"Render Mermaid\" control only makes sense as the way back\n // from the user-toggled source view. In the error and warm-up\n // fallbacks `showOriginalCode` is already false, so the control\n // would be a no-op — hide it there. (No view-kind conjunct: the\n // toggle is only reachable from the visible diagram view, and\n // while the source view is open the effect early-returns, so\n // showOriginalCode && view.kind === 'error' is unreachable.)\n showOriginalCode\n ? [\n <CodeHighlightControl\n tooltipLabel=\"Render Mermaid\"\n key=\"gpt\"\n onClick={() => {\n setShowOriginalCode(false);\n }}\n >\n <Flex align=\"center\" justify=\"center\" w={18} h={18}>\n <span className=\"icon-[gravity-ui--logo-mermaid] relative bottom-[1px] text-[16px]\"></span>\n </Flex>\n </CodeHighlightControl>,\n ]\n : []\n }\n withBorder\n withExpandButton\n />\n )}\n <div\n className={`aim-mantine-mermaid-code ${isDark ? 'dark' : ''}`}\n style={\n showSourceFallback\n ? {\n display: 'none',\n }\n : {}\n }\n >\n <div className=\"chart-header\">\n <div className=\"chart-type-tag\">{view.kind === 'diagram' ? view.chartType : 'unknown'}</div>\n <Flex align=\"center\" justify=\"flex-end\" gap={0}>\n <Tooltip label=\"Show Mermaid Code\">\n <ActionIcon\n size={28}\n className=\"action-icon\"\n variant=\"transparent\"\n onClick={() => {\n setShowOriginalCode(true);\n }}\n >\n <Flex align=\"center\" justify=\"center\" w={18} h={18}>\n <span className=\"icon-[entypo--code] relative bottom-[0.25px] text-[16px]\"></span>\n </Flex>\n </ActionIcon>\n </Tooltip>\n <CopyButton value={props.code}>\n {({ copied, copy }) => (\n <Tooltip label={copied ? 'Copied' : 'Copy'} withArrow position=\"right\">\n <ActionIcon variant=\"transparent\" size={28} className=\"action-icon\" onClick={copy}>\n {copied ? (\n <span className=\"icon-origin-[lucide--check] text-[18px]\"></span>\n ) : (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n width=\"18px\"\n height=\"18px\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"></path>\n <path d=\"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z\"></path>\n <path d=\"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2\"></path>\n </svg>\n )}\n </ActionIcon>\n </Tooltip>\n )}\n </CopyButton>\n </Flex>\n </div>\n <pre ref={ref} style={PRE_STYLE} onClick={viewSvgInNewWindow} />\n </div>\n </>\n );\n});\n\nMantineAIMMermaidCode.displayName = 'MantineAIMMermaidCode';\n\nexport default MantineAIMMermaidCode;\n","import { useAIMarkdownMetadata } from '@ai-react-markdown/core';\nimport { MantineAIMarkdownMetadata } from '../defs';\n\n/**\n * Typed wrapper around the core {@link useAIMarkdownMetadata} hook.\n *\n * Returns the current metadata defaulting to {@link MantineAIMarkdownMetadata}.\n * Accepts an optional generic parameter for further extension.\n *\n * Metadata lives in a separate React context from the render state, meaning\n * metadata updates do not trigger re-renders in components that only consume\n * render state.\n *\n * Must be called inside a component rendered within the `<MantineAIMarkdown>` tree.\n *\n * @typeParam TMetadata - Metadata type (defaults to {@link MantineAIMarkdownMetadata}).\n * @returns The current metadata, or `undefined` if none was provided.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const metadata = useMantineAIMarkdownMetadata();\n * // Access Mantine-specific metadata fields\n * }\n * ```\n */\nexport const useMantineAIMarkdownMetadata = <\n TMetadata extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n>() => {\n return useAIMarkdownMetadata<TMetadata>();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaA,IAAAA,gBAA8B;AAC9B,IAAAC,eAAuB;AACvB,IAAAA,eAAsF;;;ACftF,mBAAqB;AACrB,kBAA2B;AAgBzB;AADF,IAAM,kCAA8B,mBAAK,CAAC,EAAE,UAAU,UAAU,MAAM,MACpE,4CAAC,0BAAW,GAAE,QAAO,IAAI,UAAU,OAChC,UACH,CACD;AAED,4BAA4B,cAAc;AAE1C,IAAO,4BAAQ;;;ACRN,IAAAC,sBAAA;AADT,IAAM,+BAA+D,CAAC,EAAE,SAAS,MAAM;AACrF,SAAO,6CAAC,SAAI,WAAU,4BAA4B,UAAS;AAC7D;AAEA,IAAO,6BAAQ;;;ACVf,IAAAC,eAA0F;AAmCnF,IAAM,uCAAsE,OAAO,OAAO;AAAA,EAC/F,GAAG;AAAA,EACH,WA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YA,IAAM,6BAA6B,CAGjC;AAAA,EACA,YAAAC,cAAa;AAAA,EACb,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAoD;AAClD,QAAM,6BAAyB,6BAAe,gBAAgB;AAE9D,QAAM,qBAAiB,uBAAQ,MAAM;AACnC,WAAO,yBAAyB,EAAE,GAAG,yBAAyB,GAAG,uBAAuB,IAAI;AAAA,EAC9F,GAAG,CAAC,sBAAsB,CAAC;AAE3B,QAAM,0BAAsB,qCAAuB,OAAO;AAE1D,SACE;AAAA,IAAC,aAAAC;AAAA,IAAA;AAAA,MACC,YAAYD;AAAA,MACZ;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB,aAAa,eAAe;AAAA,MAC3B,GAAG;AAAA;AAAA,EACN;AAEJ;AAoBO,IAAM,wBAAoB,oBAAK,0BAA0B;AAEhE,kBAAkB,cAAc;AAEhC,IAAO,4BAAQ;;;AOlIf,IAAAE,eAAsC;AA0B/B,IAAM,+BAA+B,MAErC;AACL,aAAO,oCAAiC;AAC1C;","names":["import_react","import_core","import_jsx_runtime","import_core","import_react","import_code_highlight","import_core","import_react","import_core","import_jsx_runtime","mermaid","import_jsx_runtime","SpecialCodeLanguage","hljs","import_core","import_jsx_runtime","Typography","AIMarkdown","import_core"]}
|
package/dist/index.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/extra-styles/DefaultExtraStyles/styles.scss","../src/components/extra-styles/DefaultExtraStyles/%3Cinput css y3YOkk%3E","../src/components/customized/MermaidCode/styles.scss","../src/components/customized/MermaidCode/%3Cinput css 0RWA0i%3E"],"sourcesContent":[".aim-mantine-extra-styles {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-items: flex-start;\n align-items: flex-start;\n\n white-space: normal;\n word-wrap: break-word;\n overflow-wrap: break-word;\n word-break: break-word;\n\n text-rendering: optimizeLegibility;\n\n --aim-font-size-mantine-base: calc(var(--aim-font-size-root) * var(--mantine-scale));\n\n --mantine-spacing-xs: calc(var(--aim-font-size-mantine-base) * 0.75);\n --mantine-spacing-sm: calc(var(--aim-font-size-mantine-base) * 0.875);\n --mantine-spacing-md: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-spacing-lg: calc(var(--aim-font-size-mantine-base) * 1.125);\n --mantine-spacing-xl: calc(var(--aim-font-size-mantine-base) * 1.25);\n\n --mantine-font-size-xs: calc(var(--aim-font-size-mantine-base) * 0.75);\n --mantine-font-size-sm: calc(var(--aim-font-size-mantine-base) * 0.875);\n --mantine-font-size-md: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-font-size-lg: calc(var(--aim-font-size-mantine-base) * 1.25);\n --mantine-font-size-xl: calc(var(--aim-font-size-mantine-base) * 2);\n\n --mantine-h1-font-size: calc(var(--aim-font-size-mantine-base) * 2.125);\n --mantine-h2-font-size: calc(var(--aim-font-size-mantine-base) * 1.625);\n --mantine-h3-font-size: calc(var(--aim-font-size-mantine-base) * 1.375);\n --mantine-h4-font-size: calc(var(--aim-font-size-mantine-base) * 1.125);\n --mantine-h5-font-size: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-h6-font-size: calc(var(--aim-font-size-mantine-base) * 0.875);\n\n :first-child {\n margin-top: 0;\n }\n\n :last-child {\n margin-bottom: 0;\n }\n\n ul,\n ol {\n list-style-position: outside;\n\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.55);\n padding-inline-start: calc(var(--aim-font-size-mantine-base) * 1.5);\n\n li {\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.275);\n }\n }\n\n hr {\n width: 100%;\n height: 1px;\n background-color: var(--mantine-color-text);\n }\n\n ul {\n list-style-type: disc;\n }\n\n ul ul {\n list-style-type: circle;\n }\n\n ul ul ul {\n list-style-type: square;\n }\n\n ol {\n list-style-type: decimal;\n }\n\n p {\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.5);\n\n &:last-child {\n margin-bottom: 0;\n }\n }\n\n blockquote {\n font-size: var(--mantine-font-size-md);\n }\n\n table {\n caption {\n font-size: var(--mantine-font-size-md);\n }\n th {\n font-size: var(--mantine-font-size-md);\n }\n }\n\n pre code {\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-wrap: break-word;\n word-break: break-word;\n }\n\n dl {\n display: flex;\n flex-wrap: wrap;\n width: 100%;\n max-width: 670px;\n }\n dl > * {\n padding-top: calc(var(--aim-font-size-mantine-base) * 0.5);\n }\n dt {\n width: 30%;\n font-weight: bold;\n text-align: right;\n }\n dd {\n width: 60%;\n padding-left: calc(var(--aim-font-size-mantine-base) * 0.5);\n margin-left: 0px;\n }\n dd + dd {\n width: 100%;\n padding-left: calc(30% + var(--aim-font-size-mantine-base));\n }\n dt + dt {\n padding-right: 60%;\n }\n dt + dt + dd {\n margin-top: calc(var(--aim-font-size-mantine-base) * -1.625);\n padding-left: calc(30% + var(--aim-font-size-mantine-base));\n }\n}\n",".aim-mantine-extra-styles {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-items: flex-start;\n align-items: flex-start;\n white-space: normal;\n word-wrap: break-word;\n overflow-wrap: break-word;\n word-break: break-word;\n text-rendering: optimizeLegibility;\n --aim-font-size-mantine-base: calc(var(--aim-font-size-root) * var(--mantine-scale));\n --mantine-spacing-xs: calc(var(--aim-font-size-mantine-base) * 0.75);\n --mantine-spacing-sm: calc(var(--aim-font-size-mantine-base) * 0.875);\n --mantine-spacing-md: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-spacing-lg: calc(var(--aim-font-size-mantine-base) * 1.125);\n --mantine-spacing-xl: calc(var(--aim-font-size-mantine-base) * 1.25);\n --mantine-font-size-xs: calc(var(--aim-font-size-mantine-base) * 0.75);\n --mantine-font-size-sm: calc(var(--aim-font-size-mantine-base) * 0.875);\n --mantine-font-size-md: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-font-size-lg: calc(var(--aim-font-size-mantine-base) * 1.25);\n --mantine-font-size-xl: calc(var(--aim-font-size-mantine-base) * 2);\n --mantine-h1-font-size: calc(var(--aim-font-size-mantine-base) * 2.125);\n --mantine-h2-font-size: calc(var(--aim-font-size-mantine-base) * 1.625);\n --mantine-h3-font-size: calc(var(--aim-font-size-mantine-base) * 1.375);\n --mantine-h4-font-size: calc(var(--aim-font-size-mantine-base) * 1.125);\n --mantine-h5-font-size: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-h6-font-size: calc(var(--aim-font-size-mantine-base) * 0.875);\n}\n.aim-mantine-extra-styles :first-child {\n margin-top: 0;\n}\n.aim-mantine-extra-styles :last-child {\n margin-bottom: 0;\n}\n.aim-mantine-extra-styles ul,\n.aim-mantine-extra-styles ol {\n list-style-position: outside;\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.55);\n padding-inline-start: calc(var(--aim-font-size-mantine-base) * 1.5);\n}\n.aim-mantine-extra-styles ul li,\n.aim-mantine-extra-styles ol li {\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.275);\n}\n.aim-mantine-extra-styles hr {\n width: 100%;\n height: 1px;\n background-color: var(--mantine-color-text);\n}\n.aim-mantine-extra-styles ul {\n list-style-type: disc;\n}\n.aim-mantine-extra-styles ul ul {\n list-style-type: circle;\n}\n.aim-mantine-extra-styles ul ul ul {\n list-style-type: square;\n}\n.aim-mantine-extra-styles ol {\n list-style-type: decimal;\n}\n.aim-mantine-extra-styles p {\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.5);\n}\n.aim-mantine-extra-styles p:last-child {\n margin-bottom: 0;\n}\n.aim-mantine-extra-styles blockquote {\n font-size: var(--mantine-font-size-md);\n}\n.aim-mantine-extra-styles table caption {\n font-size: var(--mantine-font-size-md);\n}\n.aim-mantine-extra-styles table th {\n font-size: var(--mantine-font-size-md);\n}\n.aim-mantine-extra-styles pre code {\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-wrap: break-word;\n word-break: break-word;\n}\n.aim-mantine-extra-styles dl {\n display: flex;\n flex-wrap: wrap;\n width: 100%;\n max-width: 670px;\n}\n.aim-mantine-extra-styles dl > * {\n padding-top: calc(var(--aim-font-size-mantine-base) * 0.5);\n}\n.aim-mantine-extra-styles dt {\n width: 30%;\n font-weight: bold;\n text-align: right;\n}\n.aim-mantine-extra-styles dd {\n width: 60%;\n padding-left: calc(var(--aim-font-size-mantine-base) * 0.5);\n margin-left: 0px;\n}\n.aim-mantine-extra-styles dd + dd {\n width: 100%;\n padding-left: calc(30% + var(--aim-font-size-mantine-base));\n}\n.aim-mantine-extra-styles dt + dt {\n padding-right: 60%;\n}\n.aim-mantine-extra-styles dt + dt + dd {\n margin-top: calc(var(--aim-font-size-mantine-base) * -1.625);\n padding-left: calc(30% + var(--aim-font-size-mantine-base));\n}\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy5zY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0VBQ0U7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUVBO0VBQ0E7RUFDQTtFQUNBO0VBRUE7RUFFQTtFQUVBO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7RUFFQTtFQUNBO0VBQ0E7RUFDQTtFQUNBO0VBRUE7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBOztBQUVBO0VBQ0U7O0FBR0Y7RUFDRTs7QUFHRjtBQUFBO0VBRUU7RUFFQTtFQUNBOztBQUVBO0FBQUE7RUFDRTs7QUFJSjtFQUNFO0VBQ0E7RUFDQTs7QUFHRjtFQUNFOztBQUdGO0VBQ0U7O0FBR0Y7RUFDRTs7QUFHRjtFQUNFOztBQUdGO0VBQ0U7O0FBRUE7RUFDRTs7QUFJSjtFQUNFOztBQUlBO0VBQ0U7O0FBRUY7RUFDRTs7QUFJSjtFQUNFO0VBQ0E7RUFDQTtFQUNBOztBQUdGO0VBQ0U7RUFDQTtFQUNBO0VBQ0E7O0FBRUY7RUFDRTs7QUFFR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JSArIHZhcigtLWFpbS1mb250LXNpemUtbWFudGluZS1iYXNlKSk7XG4gIH1cbiAgZHQgKyBkdCB7XG4gICAgcGFkZGluZy1yaWdodDogNjAlO1xuICB9XG4gIGR0ICsgZHQgKyBkZCB7XG4gICAgbWFyZ2luLXRvcDogY2FsYyh2YXIoLS1haW0tZm9udC1zaXplLW1hbnRpbmUtYmFzZSkgKiAtMS42MjUpO1xuICAgIHBhZGRpbmctbGVmdDogY2FsYygzMCUgKyB2YXIoLS1haW0tZm9udC1zaXplLW1hbnRpbmUtYmFzZSkpO1xuICB9XG59XG4iXX0= */",".aim-mantine-mermaid-code {\n width: 100%;\n margin-bottom: 15px;\n background: var(--mantine-color-gray-0);\n border: 1px solid var(--mantine-color-gray-2);\n padding: calc(0.75rem * var(--mantine-scale)) calc(0.625rem * var(--mantine-scale));\n display: flex;\n flex-shrink: 0;\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n\n .chart-header {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-shrink: 0;\n\n .chart-type-tag {\n padding: calc(0.2125rem * var(--mantine-scale)) calc(0.5625rem * var(--mantine-scale));\n color: black;\n border: 1px solid var(--mantine-color-gray-3);\n background: white;\n border-radius: var(--mantine-radius-default);\n font-size: var(--mantine-font-size-xs);\n font-weight: 700;\n }\n\n .action-icon {\n color: var(--mantine-color-text);\n opacity: 0.5;\n\n &:hover {\n color: var(--mantine-color-bright);\n opacity: 1;\n }\n }\n }\n\n & > pre {\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n }\n}\n\n.aim-mantine-mermaid-code.dark {\n background: var(--mantine-color-dark-8);\n border-color: var(--mantine-color-dark-6);\n\n .chart-header {\n .chart-type-tag {\n color: var(--mantine-color-dark-0);\n border-color: var(--mantine-color-dark-6);\n background: var(--mantine-color-dark-8);\n }\n\n .action-icon {\n color: var(--mantine-color-text);\n }\n }\n}\n",".aim-mantine-mermaid-code {\n width: 100%;\n margin-bottom: 15px;\n background: var(--mantine-color-gray-0);\n border: 1px solid var(--mantine-color-gray-2);\n padding: calc(0.75rem * var(--mantine-scale)) calc(0.625rem * var(--mantine-scale));\n display: flex;\n flex-shrink: 0;\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n}\n.aim-mantine-mermaid-code .chart-header {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-shrink: 0;\n}\n.aim-mantine-mermaid-code .chart-header .chart-type-tag {\n padding: calc(0.2125rem * var(--mantine-scale)) calc(0.5625rem * var(--mantine-scale));\n color: black;\n border: 1px solid var(--mantine-color-gray-3);\n background: white;\n border-radius: var(--mantine-radius-default);\n font-size: var(--mantine-font-size-xs);\n font-weight: 700;\n}\n.aim-mantine-mermaid-code .chart-header .action-icon {\n color: var(--mantine-color-text);\n opacity: 0.5;\n}\n.aim-mantine-mermaid-code .chart-header .action-icon:hover {\n color: var(--mantine-color-bright);\n opacity: 1;\n}\n.aim-mantine-mermaid-code > pre {\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n}\n\n.aim-mantine-mermaid-code.dark {\n background: var(--mantine-color-dark-8);\n border-color: var(--mantine-color-dark-6);\n}\n.aim-mantine-mermaid-code.dark .chart-header .chart-type-tag {\n color: var(--mantine-color-dark-0);\n border-color: var(--mantine-color-dark-6);\n background: var(--mantine-color-dark-8);\n}\n.aim-mantine-mermaid-code.dark .chart-header .action-icon {\n color: var(--mantine-color-text);\n}\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy5zY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0VBQ0U7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7O0FBRUE7RUFDRTtFQUNBO0VBQ0E7RUFDQT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8BAAA,EAAA;AACA,gBAAA,KAAA,IAAA,EAAA,IAAA;ACrBJ;;;AChHA,CAAA;AACE,SAAA;AACA,iBAAA;AACA,cAAA,IAAA;AACA,UAAA,IAAA,MAAA,IAAA;AACA,WAAA,KAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,SAAA,EAAA,IAAA;AACA,WAAA;AACA,eAAA;AACA,kBAAA;AACA,mBAAA;AACA,eAAA;ACCF;ADCE,CAZF,yBAYE,CAAA;AACE,SAAA;AACA,WAAA;AACA,kBAAA;AACA,mBAAA;AACA,eAAA;AACA,eAAA;ACCJ;ADCI,CApBJ,yBAoBI,CARF,aAQE,CAAA;AACE,WAAA,KAAA,UAAA,EAAA,IAAA,kBAAA,KAAA,UAAA,EAAA,IAAA;AACA,SAAA;AACA,UAAA,IAAA,MAAA,IAAA;AACA,cAAA;AACA,iBAAA,IAAA;AACA,aAAA,IAAA;AACA,eAAA;ACCN;ADEI,CA9BJ,yBA8BI,CAlBF,aAkBE,CAAA;AACE,SAAA,IAAA;AACA,WAAA;ACAN;ADEM,CAlCN,yBAkCM,CAtBJ,aAsBI,CAJF,WAIE;AACE,SAAA,IAAA;AACA,WAAA;ACAR;ADKE,CAzCF,yBAyCE,EAAA;AACE,eAAA;AACA,WAAA;AACA,kBAAA;AACA,mBAAA;AACA,eAAA;ACHJ;ADOA,CAlDA,wBAkDA,CAAA;AACE,cAAA,IAAA;AACA,gBAAA,IAAA;ACJF;ADOI,CAvDJ,wBAuDI,CALJ,KAKI,CA3CF,aA2CE,CAnCA;AAoCE,SAAA,IAAA;AACA,gBAAA,IAAA;AACA,cAAA,IAAA;ACLN;ADQI,CA7DJ,wBA6DI,CAXJ,KAWI,CAjDF,aAiDE,CA/BA;AAgCE,SAAA,IAAA;ACNN;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/components/extra-styles/DefaultExtraStyles/styles.scss","../src/components/extra-styles/DefaultExtraStyles/%3Cinput css 7J2n0a%3E","../src/components/customized/MermaidCode/styles.scss","../src/components/customized/MermaidCode/%3Cinput css RerYux%3E"],"sourcesContent":[".aim-mantine-extra-styles {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-items: flex-start;\n align-items: flex-start;\n\n white-space: normal;\n word-wrap: break-word;\n overflow-wrap: break-word;\n word-break: break-word;\n\n text-rendering: optimizeLegibility;\n\n --aim-font-size-mantine-base: calc(var(--aim-font-size-root) * var(--mantine-scale));\n\n --mantine-spacing-xs: calc(var(--aim-font-size-mantine-base) * 0.75);\n --mantine-spacing-sm: calc(var(--aim-font-size-mantine-base) * 0.875);\n --mantine-spacing-md: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-spacing-lg: calc(var(--aim-font-size-mantine-base) * 1.125);\n --mantine-spacing-xl: calc(var(--aim-font-size-mantine-base) * 1.25);\n\n --mantine-font-size-xs: calc(var(--aim-font-size-mantine-base) * 0.75);\n --mantine-font-size-sm: calc(var(--aim-font-size-mantine-base) * 0.875);\n --mantine-font-size-md: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-font-size-lg: calc(var(--aim-font-size-mantine-base) * 1.25);\n --mantine-font-size-xl: calc(var(--aim-font-size-mantine-base) * 2);\n\n --mantine-h1-font-size: calc(var(--aim-font-size-mantine-base) * 2.125);\n --mantine-h2-font-size: calc(var(--aim-font-size-mantine-base) * 1.625);\n --mantine-h3-font-size: calc(var(--aim-font-size-mantine-base) * 1.375);\n --mantine-h4-font-size: calc(var(--aim-font-size-mantine-base) * 1.125);\n --mantine-h5-font-size: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-h6-font-size: calc(var(--aim-font-size-mantine-base) * 0.875);\n\n :first-child {\n margin-top: 0;\n }\n\n :last-child {\n margin-bottom: 0;\n }\n\n ul,\n ol {\n list-style-position: outside;\n\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.55);\n padding-inline-start: calc(var(--aim-font-size-mantine-base) * 1.5);\n\n li {\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.275);\n }\n }\n\n hr {\n width: 100%;\n height: 1px;\n background-color: var(--mantine-color-text);\n }\n\n ul {\n list-style-type: disc;\n }\n\n ul ul {\n list-style-type: circle;\n }\n\n ul ul ul {\n list-style-type: square;\n }\n\n ol {\n list-style-type: decimal;\n }\n\n p {\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.5);\n\n &:last-child {\n margin-bottom: 0;\n }\n }\n\n blockquote {\n font-size: var(--mantine-font-size-md);\n }\n\n table {\n caption {\n font-size: var(--mantine-font-size-md);\n }\n th {\n font-size: var(--mantine-font-size-md);\n }\n }\n\n pre code {\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-wrap: break-word;\n word-break: break-word;\n }\n\n dl {\n display: flex;\n flex-wrap: wrap;\n width: 100%;\n max-width: 670px;\n }\n dl > * {\n padding-top: calc(var(--aim-font-size-mantine-base) * 0.5);\n }\n dt {\n width: 30%;\n font-weight: bold;\n text-align: right;\n }\n dd {\n width: 60%;\n padding-left: calc(var(--aim-font-size-mantine-base) * 0.5);\n margin-left: 0px;\n }\n dd + dd {\n width: 100%;\n padding-left: calc(30% + var(--aim-font-size-mantine-base));\n }\n dt + dt {\n padding-right: 60%;\n }\n dt + dt + dd {\n margin-top: calc(var(--aim-font-size-mantine-base) * -1.625);\n padding-left: calc(30% + var(--aim-font-size-mantine-base));\n }\n}\n",".aim-mantine-extra-styles {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-items: flex-start;\n align-items: flex-start;\n white-space: normal;\n word-wrap: break-word;\n overflow-wrap: break-word;\n word-break: break-word;\n text-rendering: optimizeLegibility;\n --aim-font-size-mantine-base: calc(var(--aim-font-size-root) * var(--mantine-scale));\n --mantine-spacing-xs: calc(var(--aim-font-size-mantine-base) * 0.75);\n --mantine-spacing-sm: calc(var(--aim-font-size-mantine-base) * 0.875);\n --mantine-spacing-md: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-spacing-lg: calc(var(--aim-font-size-mantine-base) * 1.125);\n --mantine-spacing-xl: calc(var(--aim-font-size-mantine-base) * 1.25);\n --mantine-font-size-xs: calc(var(--aim-font-size-mantine-base) * 0.75);\n --mantine-font-size-sm: calc(var(--aim-font-size-mantine-base) * 0.875);\n --mantine-font-size-md: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-font-size-lg: calc(var(--aim-font-size-mantine-base) * 1.25);\n --mantine-font-size-xl: calc(var(--aim-font-size-mantine-base) * 2);\n --mantine-h1-font-size: calc(var(--aim-font-size-mantine-base) * 2.125);\n --mantine-h2-font-size: calc(var(--aim-font-size-mantine-base) * 1.625);\n --mantine-h3-font-size: calc(var(--aim-font-size-mantine-base) * 1.375);\n --mantine-h4-font-size: calc(var(--aim-font-size-mantine-base) * 1.125);\n --mantine-h5-font-size: calc(var(--aim-font-size-mantine-base) * 1);\n --mantine-h6-font-size: calc(var(--aim-font-size-mantine-base) * 0.875);\n}\n.aim-mantine-extra-styles :first-child {\n margin-top: 0;\n}\n.aim-mantine-extra-styles :last-child {\n margin-bottom: 0;\n}\n.aim-mantine-extra-styles ul,\n.aim-mantine-extra-styles ol {\n list-style-position: outside;\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.55);\n padding-inline-start: calc(var(--aim-font-size-mantine-base) * 1.5);\n}\n.aim-mantine-extra-styles ul li,\n.aim-mantine-extra-styles ol li {\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.275);\n}\n.aim-mantine-extra-styles hr {\n width: 100%;\n height: 1px;\n background-color: var(--mantine-color-text);\n}\n.aim-mantine-extra-styles ul {\n list-style-type: disc;\n}\n.aim-mantine-extra-styles ul ul {\n list-style-type: circle;\n}\n.aim-mantine-extra-styles ul ul ul {\n list-style-type: square;\n}\n.aim-mantine-extra-styles ol {\n list-style-type: decimal;\n}\n.aim-mantine-extra-styles p {\n margin-bottom: calc(var(--aim-font-size-mantine-base) * 0.5);\n}\n.aim-mantine-extra-styles p:last-child {\n margin-bottom: 0;\n}\n.aim-mantine-extra-styles blockquote {\n font-size: var(--mantine-font-size-md);\n}\n.aim-mantine-extra-styles table caption {\n font-size: var(--mantine-font-size-md);\n}\n.aim-mantine-extra-styles table th {\n font-size: var(--mantine-font-size-md);\n}\n.aim-mantine-extra-styles pre code {\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-wrap: break-word;\n word-break: break-word;\n}\n.aim-mantine-extra-styles dl {\n display: flex;\n flex-wrap: wrap;\n width: 100%;\n max-width: 670px;\n}\n.aim-mantine-extra-styles dl > * {\n padding-top: calc(var(--aim-font-size-mantine-base) * 0.5);\n}\n.aim-mantine-extra-styles dt {\n width: 30%;\n font-weight: bold;\n text-align: right;\n}\n.aim-mantine-extra-styles dd {\n width: 60%;\n padding-left: calc(var(--aim-font-size-mantine-base) * 0.5);\n margin-left: 0px;\n}\n.aim-mantine-extra-styles dd + dd {\n width: 100%;\n padding-left: calc(30% + var(--aim-font-size-mantine-base));\n}\n.aim-mantine-extra-styles dt + dt {\n padding-right: 60%;\n}\n.aim-mantine-extra-styles dt + dt + dd {\n margin-top: calc(var(--aim-font-size-mantine-base) * -1.625);\n padding-left: calc(30% + var(--aim-font-size-mantine-base));\n}\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy5zY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0VBQ0U7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUVBO0VBQ0E7RUFDQTtFQUNBO0VBRUE7RUFFQTtFQUVBO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7RUFFQTtFQUNBO0VBQ0E7RUFDQTtFQUNBO0VBRUE7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBOztBQUVBO0VBQ0U7O0FBR0Y7RUFDRTs7QUFHRjtBQUFBO0VBRUU7RUFFQTtFQUNBOztBQUVBO0FBQUE7RUFDRTs7QUFJSjtFQUNFO0VBQ0E7RUFDQTs7QUFHRjtFQUNFOztBQUdGO0VBQ0U7O0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xuICAgIHBhZGRpbmctbGVmdDogY2FsYyh2YXIoLS1haW0tZm9udC1zaXplLW1hbnRpbmUtYmFzZSkgKiAwLjUpO1xuICAgIG1hcmdpbi1sZWZ0OiAwcHg7XG4gIH1cbiAgZGQgKyBkZCB7XG4gICAgd2lkdGg6IDEwMCU7XG4gICAgcGFkZGluZy1sZWZ0OiBjYWxjKDMwJSArIHZhcigtLWFpbS1mb250LXNpemUtbWFudGluZS1iYXNlKSk7XG4gIH1cbiAgZHQgKyBkdCB7XG4gICAgcGFkZGluZy1yaWdodDogNjAlO1xuICB9XG4gIGR0ICsgZHQgKyBkZCB7XG4gICAgbWFyZ2luLXRvcDogY2FsYyh2YXIoLS1haW0tZm9udC1zaXplLW1hbnRpbmUtYmFzZSkgKiAtMS42MjUpO1xuICAgIHBhZGRpbmctbGVmdDogY2FsYygzMCUgKyB2YXIoLS1haW0tZm9udC1zaXplLW1hbnRpbmUtYmFzZSkpO1xuICB9XG59XG4iXX0= */",".aim-mantine-mermaid-code {\n width: 100%;\n margin-bottom: 15px;\n background: var(--mantine-color-gray-0);\n border: 1px solid var(--mantine-color-gray-2);\n padding: calc(0.75rem * var(--mantine-scale)) calc(0.625rem * var(--mantine-scale));\n display: flex;\n flex-shrink: 0;\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n\n .chart-header {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-shrink: 0;\n\n .chart-type-tag {\n padding: calc(0.2125rem * var(--mantine-scale)) calc(0.5625rem * var(--mantine-scale));\n color: black;\n border: 1px solid var(--mantine-color-gray-3);\n background: white;\n border-radius: var(--mantine-radius-default);\n font-size: var(--mantine-font-size-xs);\n font-weight: 700;\n }\n\n .action-icon {\n color: var(--mantine-color-text);\n opacity: 0.5;\n\n &:hover {\n color: var(--mantine-color-bright);\n opacity: 1;\n }\n }\n }\n\n & > pre {\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n }\n}\n\n.aim-mantine-mermaid-code.dark {\n background: var(--mantine-color-dark-8);\n border-color: var(--mantine-color-dark-6);\n\n .chart-header {\n .chart-type-tag {\n color: var(--mantine-color-dark-0);\n border-color: var(--mantine-color-dark-6);\n background: var(--mantine-color-dark-8);\n }\n\n .action-icon {\n color: var(--mantine-color-text);\n }\n }\n}\n",".aim-mantine-mermaid-code {\n width: 100%;\n margin-bottom: 15px;\n background: var(--mantine-color-gray-0);\n border: 1px solid var(--mantine-color-gray-2);\n padding: calc(0.75rem * var(--mantine-scale)) calc(0.625rem * var(--mantine-scale));\n display: flex;\n flex-shrink: 0;\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n}\n.aim-mantine-mermaid-code .chart-header {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-shrink: 0;\n}\n.aim-mantine-mermaid-code .chart-header .chart-type-tag {\n padding: calc(0.2125rem * var(--mantine-scale)) calc(0.5625rem * var(--mantine-scale));\n color: black;\n border: 1px solid var(--mantine-color-gray-3);\n background: white;\n border-radius: var(--mantine-radius-default);\n font-size: var(--mantine-font-size-xs);\n font-weight: 700;\n}\n.aim-mantine-mermaid-code .chart-header .action-icon {\n color: var(--mantine-color-text);\n opacity: 0.5;\n}\n.aim-mantine-mermaid-code .chart-header .action-icon:hover {\n color: var(--mantine-color-bright);\n opacity: 1;\n}\n.aim-mantine-mermaid-code > pre {\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n}\n\n.aim-mantine-mermaid-code.dark {\n background: var(--mantine-color-dark-8);\n border-color: var(--mantine-color-dark-6);\n}\n.aim-mantine-mermaid-code.dark .chart-header .chart-type-tag {\n color: var(--mantine-color-dark-0);\n border-color: var(--mantine-color-dark-6);\n background: var(--mantine-color-dark-8);\n}\n.aim-mantine-mermaid-code.dark .chart-header .action-icon {\n color: var(--mantine-color-text);\n}\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,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A,IAAA;ACLN;ADQI,CA7DJ,wBA6DI,CAXJ,KAWI,CAjDF,aAiDE,CA/BA;AAgCE,SAAA,IAAA;ACNN;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,25 @@ import { ActionIcon, CopyButton, Flex, Tooltip } from "@mantine/core";
|
|
|
47
47
|
import mermaid from "mermaid";
|
|
48
48
|
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
49
49
|
var PRE_STYLE = { cursor: "pointer", overflow: "auto", width: "100%", padding: "0.5rem" };
|
|
50
|
+
var sameView = (a, b) => a.kind === "diagram" && b.kind === "diagram" ? a.chartType === b.chartType : a.kind === b.kind;
|
|
51
|
+
var initializedTheme = null;
|
|
52
|
+
var ensureMermaidInitialized = (isDark) => {
|
|
53
|
+
const theme = isDark ? "dark" : "light";
|
|
54
|
+
if (initializedTheme === theme) return;
|
|
55
|
+
mermaid.initialize({
|
|
56
|
+
startOnLoad: false,
|
|
57
|
+
securityLevel: "strict",
|
|
58
|
+
theme: isDark ? "dark" : "base",
|
|
59
|
+
darkMode: isDark,
|
|
60
|
+
// Without a svgContainingElement, a draw-phase throw (an error that
|
|
61
|
+
// got past mermaid.parse) leaves mermaid's temp element orphaned in
|
|
62
|
+
// document.body — its error path only cleans up when this flag is
|
|
63
|
+
// set. We render our own error tab anyway, so mermaid's built-in
|
|
64
|
+
// error diagram is dead weight here regardless.
|
|
65
|
+
suppressErrorRendering: true
|
|
66
|
+
});
|
|
67
|
+
initializedTheme = theme;
|
|
68
|
+
};
|
|
50
69
|
var generateMermaidUUID = () => {
|
|
51
70
|
return `mermaid-${(/* @__PURE__ */ new Date()).getTime()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
52
71
|
};
|
|
@@ -68,20 +87,21 @@ var MantineAIMMermaidCode = memo2((props) => {
|
|
|
68
87
|
const streaming = renderState.streaming;
|
|
69
88
|
const ref = useRef(null);
|
|
70
89
|
const renderVersionRef = useRef(0);
|
|
71
|
-
const
|
|
90
|
+
const viewRef = useRef({ kind: "source" });
|
|
72
91
|
const prevStreamingRef = useRef(false);
|
|
73
92
|
const needsCorrectiveRef = useRef(false);
|
|
74
|
-
const
|
|
93
|
+
const lastSuccessRef = useRef(null);
|
|
94
|
+
const [view, setViewState] = useState({ kind: "source" });
|
|
75
95
|
const [showOriginalCode, setShowOriginalCode] = useState(false);
|
|
76
|
-
const [renderError, setRenderError] = useState(false);
|
|
77
|
-
const [chartType, setChartType] = useState("unknown");
|
|
78
96
|
useEffect(() => {
|
|
97
|
+
const applyView = (next) => {
|
|
98
|
+
viewRef.current = next;
|
|
99
|
+
setViewState((prev) => sameView(prev, next) ? prev : next);
|
|
100
|
+
};
|
|
79
101
|
if (streaming && !prevStreamingRef.current) {
|
|
80
|
-
hasRenderedRef.current = false;
|
|
81
102
|
needsCorrectiveRef.current = false;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
setChartType("unknown");
|
|
103
|
+
lastSuccessRef.current = null;
|
|
104
|
+
applyView({ kind: "source" });
|
|
85
105
|
if (ref.current) {
|
|
86
106
|
ref.current.innerHTML = "";
|
|
87
107
|
}
|
|
@@ -92,22 +112,15 @@ var MantineAIMMermaidCode = memo2((props) => {
|
|
|
92
112
|
if (!props.code || !ref.current || showOriginalCode) {
|
|
93
113
|
return;
|
|
94
114
|
}
|
|
115
|
+
if (lastSuccessRef.current?.code === props.code && lastSuccessRef.current.isDark === isDark) {
|
|
116
|
+
needsCorrectiveRef.current = false;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
95
119
|
const renderVersion = ++renderVersionRef.current;
|
|
96
120
|
let cancelled = false;
|
|
97
121
|
const renderMermaid = async () => {
|
|
98
122
|
try {
|
|
99
|
-
|
|
100
|
-
startOnLoad: false,
|
|
101
|
-
securityLevel: "strict",
|
|
102
|
-
theme: isDark ? "dark" : "base",
|
|
103
|
-
darkMode: isDark,
|
|
104
|
-
// Without a svgContainingElement, a draw-phase throw (an error that
|
|
105
|
-
// got past mermaid.parse) leaves mermaid's temp element orphaned in
|
|
106
|
-
// document.body — its error path only cleans up when this flag is
|
|
107
|
-
// set. We render our own error tab anyway, so mermaid's built-in
|
|
108
|
-
// error diagram is dead weight here regardless.
|
|
109
|
-
suppressErrorRendering: true
|
|
110
|
-
});
|
|
123
|
+
ensureMermaidInitialized(isDark);
|
|
111
124
|
const parseResult = await mermaid.parse(props.code);
|
|
112
125
|
if (!parseResult) {
|
|
113
126
|
throw new Error("Failed to parse mermaid code");
|
|
@@ -121,11 +134,9 @@ var MantineAIMMermaidCode = memo2((props) => {
|
|
|
121
134
|
}
|
|
122
135
|
ref.current.innerHTML = svg;
|
|
123
136
|
bindFunctions?.(ref.current);
|
|
124
|
-
hasRenderedRef.current = true;
|
|
125
137
|
needsCorrectiveRef.current = false;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
setRenderError(false);
|
|
138
|
+
lastSuccessRef.current = { code: props.code, isDark };
|
|
139
|
+
applyView({ kind: "diagram", chartType: diagramType });
|
|
129
140
|
} catch {
|
|
130
141
|
if (cancelled || renderVersion !== renderVersionRef.current) {
|
|
131
142
|
return;
|
|
@@ -135,15 +146,13 @@ var MantineAIMMermaidCode = memo2((props) => {
|
|
|
135
146
|
}
|
|
136
147
|
if (needsCorrectiveRef.current) {
|
|
137
148
|
needsCorrectiveRef.current = false;
|
|
138
|
-
|
|
139
|
-
setRenderError(true);
|
|
149
|
+
applyView({ kind: "error" });
|
|
140
150
|
return;
|
|
141
151
|
}
|
|
142
|
-
if (
|
|
152
|
+
if (viewRef.current.kind === "diagram") {
|
|
143
153
|
return;
|
|
144
154
|
}
|
|
145
|
-
|
|
146
|
-
setRenderError(true);
|
|
155
|
+
applyView({ kind: "error" });
|
|
147
156
|
}
|
|
148
157
|
};
|
|
149
158
|
void renderMermaid();
|
|
@@ -154,7 +163,7 @@ var MantineAIMMermaidCode = memo2((props) => {
|
|
|
154
163
|
const viewSvgInNewWindow = useCallback(() => {
|
|
155
164
|
handleViewSVGInNewWindow(ref.current?.querySelector("svg"), isDark);
|
|
156
165
|
}, [isDark]);
|
|
157
|
-
const showSourceFallback = showOriginalCode ||
|
|
166
|
+
const showSourceFallback = showOriginalCode || view.kind !== "diagram";
|
|
158
167
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
159
168
|
showSourceFallback && /* @__PURE__ */ jsx3(
|
|
160
169
|
CodeHighlightTabs,
|
|
@@ -164,7 +173,7 @@ var MantineAIMMermaidCode = memo2((props) => {
|
|
|
164
173
|
w: "100%",
|
|
165
174
|
code: [
|
|
166
175
|
{
|
|
167
|
-
fileName:
|
|
176
|
+
fileName: view.kind === "error" ? "Mermaid Render Error" : "mermaid",
|
|
168
177
|
code: props.code,
|
|
169
178
|
language: "mermaid"
|
|
170
179
|
}
|
|
@@ -180,10 +189,10 @@ var MantineAIMMermaidCode = memo2((props) => {
|
|
|
180
189
|
// The "Render Mermaid" control only makes sense as the way back
|
|
181
190
|
// from the user-toggled source view. In the error and warm-up
|
|
182
191
|
// fallbacks `showOriginalCode` is already false, so the control
|
|
183
|
-
// would be a no-op — hide it there. (No
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
192
|
+
// would be a no-op — hide it there. (No view-kind conjunct: the
|
|
193
|
+
// toggle is only reachable from the visible diagram view, and
|
|
194
|
+
// while the source view is open the effect early-returns, so
|
|
195
|
+
// showOriginalCode && view.kind === 'error' is unreachable.)
|
|
187
196
|
showOriginalCode ? [
|
|
188
197
|
/* @__PURE__ */ jsx3(
|
|
189
198
|
CodeHighlightControl,
|
|
@@ -211,7 +220,7 @@ var MantineAIMMermaidCode = memo2((props) => {
|
|
|
211
220
|
} : {},
|
|
212
221
|
children: [
|
|
213
222
|
/* @__PURE__ */ jsxs("div", { className: "chart-header", children: [
|
|
214
|
-
/* @__PURE__ */ jsx3("div", { className: "chart-type-tag", children: chartType }),
|
|
223
|
+
/* @__PURE__ */ jsx3("div", { className: "chart-type-tag", children: view.kind === "diagram" ? view.chartType : "unknown" }),
|
|
215
224
|
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "flex-end", gap: 0, children: [
|
|
216
225
|
/* @__PURE__ */ jsx3(Tooltip, { label: "Show Mermaid Code", children: /* @__PURE__ */ jsx3(
|
|
217
226
|
ActionIcon,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/MantineAIMarkdown.tsx","../src/components/typography/MantineTypography.tsx","../src/components/extra-styles/DefaultExtraStyles/index.tsx","../src/defs.tsx","../src/components/customized/PreCode.tsx","../src/hooks/useMantineAIMarkdownRenderState.ts","../src/components/customized/MermaidCode/index.tsx","../src/hooks/useMantineAIMarkdownMetadata.ts"],"sourcesContent":["/**\n * Main Mantine integration component for AI markdown rendering.\n *\n * Wraps the core {@link AIMarkdown} component with Mantine-specific defaults:\n * - {@link MantineAIMarkdownTypography} as the typography wrapper\n * - {@link MantineAIMDefaultExtraStyles} as the extra styles wrapper\n * - {@link MantineAIMPreCode} as the default `<pre>` component (with syntax\n * highlighting via Mantine's CodeHighlight and mermaid diagram support)\n * - Automatic color scheme detection via Mantine's `useComputedColorScheme`\n *\n * @module MantineAIMarkdown\n */\n\nimport { memo, useMemo } from 'react';\nimport AIMarkdown from '@ai-react-markdown/core';\nimport { type AIMarkdownProps, type AIMarkdownCustomComponents, useStableValue } from '@ai-react-markdown/core';\nimport MantineAIMarkdownTypography from './components/typography/MantineTypography';\nimport MantineAIMDefaultExtraStyles from './components/extra-styles/DefaultExtraStyles';\nimport { MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata, defaultMantineAIMarkdownRenderConfig } from './defs';\nimport MantineAIMPreCode from './components/customized/PreCode';\nimport { useComputedColorScheme } from '@mantine/core';\n\n/**\n * Props for the {@link MantineAIMarkdown} component.\n *\n * Extends {@link AIMarkdownProps} with Mantine-specific config and metadata generics.\n * All core props (`content`, `streaming`, `fontSize`, `config`, etc.) are inherited.\n *\n * @typeParam TConfig - Render configuration type, defaults to {@link MantineAIMarkdownRenderConfig}.\n * @typeParam TRenderData - Metadata type, defaults to {@link MantineAIMarkdownMetadata}.\n */\nexport interface MantineAIMarkdownProps<\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n TRenderData extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n> extends AIMarkdownProps<TConfig, TRenderData> {}\n\n/**\n * Default custom component overrides applied by the Mantine integration.\n *\n * Overrides the `<pre>` element to extract code blocks and render them via\n * {@link MantineAIMPreCode}, which provides syntax highlighting, expand/collapse,\n * and mermaid diagram support. Falls back to a plain `<pre>` when the child\n * is not a recognized code element.\n */\nconst DefaultCustomComponents: AIMarkdownCustomComponents = {\n pre: ({ node, ...usefulProps }) => {\n const code = node?.children[0] as\n | {\n type: string;\n tagName?: string;\n position?: { start?: { offset?: number } };\n properties?: Record<string, unknown>;\n children: { value?: string }[];\n }\n | undefined;\n if (!code || code.type !== 'element' || code.tagName !== 'code' || !code.position) {\n return <pre {...usefulProps} />;\n }\n const key = `pre-code-${node?.position?.start?.offset || 0}`;\n const detectedLanguage = (code.properties?.className as string[])\n ?.find((className: string) => className.startsWith('language-'))\n ?.substring('language-'.length);\n const codeText = code.children.map((child: { value?: string }) => child.value ?? '').join('\\n');\n return <MantineAIMPreCode key={key} codeText={codeText} existLanguage={detectedLanguage} />;\n },\n};\n\n/**\n * Inner (non-memoized) implementation of the Mantine AI markdown component.\n *\n * Merges caller-provided `customComponents` with the Mantine defaults (the caller's\n * overrides take precedence). Automatically resolves the color scheme from Mantine's\n * `useComputedColorScheme` when no explicit `colorScheme` prop is provided.\n *\n * @typeParam TConfig - Render configuration type.\n * @typeParam TRenderData - Metadata type.\n */\nconst MantineAIMarkdownComponent = <\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n TRenderData extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n>({\n Typography = MantineAIMarkdownTypography,\n ExtraStyles = MantineAIMDefaultExtraStyles,\n defaultConfig = defaultMantineAIMarkdownRenderConfig as TConfig,\n customComponents,\n colorScheme,\n ...props\n}: MantineAIMarkdownProps<TConfig, TRenderData>) => {\n const stableCustomComponents = useStableValue(customComponents);\n\n const usedComponents = useMemo(() => {\n return stableCustomComponents ? { ...DefaultCustomComponents, ...stableCustomComponents } : DefaultCustomComponents;\n }, [stableCustomComponents]);\n\n const computedColorScheme = useComputedColorScheme('light');\n\n return (\n <AIMarkdown<MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata>\n Typography={Typography}\n ExtraStyles={ExtraStyles}\n defaultConfig={defaultConfig}\n customComponents={usedComponents}\n colorScheme={colorScheme ?? computedColorScheme}\n {...props}\n />\n );\n};\n\n/**\n * Mantine-integrated AI markdown renderer.\n *\n * A memoized wrapper around the core `<AIMarkdown>` component that provides\n * Mantine-themed typography, code highlighting (via `@mantine/code-highlight`),\n * mermaid diagram rendering, and automatic color scheme detection.\n *\n * This is the default export of `@ai-react-markdown/mantine`.\n *\n * @example\n * ```tsx\n * import MantineAIMarkdown from '@ai-react-markdown/mantine';\n *\n * function Chat({ content }: { content: string }) {\n * return <MantineAIMarkdown content={content} />;\n * }\n * ```\n */\nexport const MantineAIMarkdown = memo(MantineAIMarkdownComponent);\n\nMantineAIMarkdown.displayName = 'MantineAIMarkdown';\n\nexport default MantineAIMarkdown as typeof MantineAIMarkdownComponent;\n","import { memo } from 'react';\nimport { Typography } from '@mantine/core';\nimport type { AIMarkdownTypographyProps } from '@ai-react-markdown/core';\n\n/**\n * Mantine-themed typography wrapper for AI markdown content.\n *\n * Replaces the core default typography component with Mantine's `<Typography>`\n * element, applying the configured `fontSize` at full width. This ensures all\n * rendered markdown inherits Mantine's font family, line height, and theming.\n *\n * Used as the default `Typography` prop in {@link MantineAIMarkdown}.\n * Can be replaced by passing a custom `Typography` component.\n *\n * @param props - Standard {@link AIMarkdownTypographyProps} from the core package.\n */\nconst MantineAIMarkdownTypography = memo(({ children, fontSize, style }: AIMarkdownTypographyProps) => (\n <Typography w=\"100%\" fz={fontSize} style={style}>\n {children}\n </Typography>\n));\n\nMantineAIMarkdownTypography.displayName = 'MantineAIMarkdownTypography';\n\nexport default MantineAIMarkdownTypography;\n","import React from 'react';\nimport { AIMarkdownExtraStylesComponent } from '@ai-react-markdown/core';\nimport './styles.scss';\n\n/**\n * Default extra styles wrapper for the Mantine integration.\n *\n * Wraps markdown content in a `<div>` with the `aim-mantine-extra-styles` CSS class,\n * which provides Mantine-compatible typography overrides including:\n * - Relative `em`-based Mantine spacing and font-size CSS custom properties\n * - Heading, list, paragraph, blockquote, and code styling\n * - Definition list layout\n *\n * Used as the default `ExtraStyles` prop in {@link MantineAIMarkdown}.\n */\nconst MantineAIMDefaultExtraStyles: AIMarkdownExtraStylesComponent = ({ children }) => {\n return <div className=\"aim-mantine-extra-styles\">{children}</div>;\n};\n\nexport default MantineAIMDefaultExtraStyles;\n","/**\n * Mantine-specific type definitions and default configuration.\n *\n * Extends the core {@link AIMarkdownRenderConfig} and {@link AIMarkdownMetadata}\n * with Mantine-themed options such as uniform heading sizes and code block behavior.\n *\n * @module defs\n */\n\nimport { AIMarkdownRenderConfig, AIMarkdownMetadata, defaultAIMarkdownRenderConfig } from '@ai-react-markdown/core';\n\n/**\n * Extended render configuration for the Mantine integration.\n *\n * Inherits all core config fields (extra syntax, display optimizations) and adds\n * Mantine-specific options for typography sizing and code block behavior.\n */\nexport interface MantineAIMarkdownRenderConfig extends AIMarkdownRenderConfig {\n /** Code block rendering options. */\n codeBlock: {\n /**\n * Whether code blocks start in their expanded state.\n * When `false`, long code blocks are collapsed with an expand button.\n *\n * @default true\n */\n defaultExpanded: boolean;\n\n /**\n * When `true`, uses `highlight.js` auto-detection to determine the language\n * of code blocks that lack an explicit language annotation.\n *\n * @default false\n */\n autoDetectUnknownLanguage: boolean;\n };\n}\n\n/**\n * Default Mantine render configuration.\n *\n * Extends {@link defaultAIMarkdownRenderConfig} with Mantine-specific defaults.\n * Frozen to prevent accidental mutation.\n */\nexport const defaultMantineAIMarkdownRenderConfig: MantineAIMarkdownRenderConfig = Object.freeze({\n ...defaultAIMarkdownRenderConfig,\n codeBlock: Object.freeze({\n defaultExpanded: true,\n autoDetectUnknownLanguage: false,\n }),\n});\n\n/**\n * Metadata type for the Mantine integration.\n *\n * Currently identical to {@link AIMarkdownMetadata}. Exists as an extension point\n * so that consumers can augment metadata in Mantine-specific wrappers without\n * needing to reference the core type directly.\n */\nexport interface MantineAIMarkdownMetadata extends AIMarkdownMetadata {}\n","'use client';\n\nimport { HTMLAttributes, memo, useMemo } from 'react';\nimport { CodeHighlight, CodeHighlightTabs } from '@mantine/code-highlight';\nimport { deepParseJson } from 'deep-parse-json';\nimport hljs from 'highlight.js';\nimport { useMantineAIMarkdownRenderState } from '../../hooks/useMantineAIMarkdownRenderState';\nimport MantineAIMMermaidCode from './MermaidCode';\n\n/**\n * Code languages that receive specialized rendering instead of standard\n * syntax-highlighted code blocks. Adding a new member here automatically\n * marks that language as \"special\" — you only need to add the corresponding\n * rendering branch in the component's return.\n */\nenum SpecialCodeLanguage {\n /** Rendered as interactive diagrams via {@link MantineAIMMermaidCode} */\n Mermaid = 'mermaid',\n}\n\n/** O(1) lookup set, derived from {@link SpecialCodeLanguage}. */\nconst SPECIAL_LANGUAGES = new Set<string>(Object.values(SpecialCodeLanguage));\n\n/**\n * Mantine code block renderer for `<pre>` elements.\n *\n * Replaces the default `<pre>` rendering with Mantine's {@link CodeHighlight} or\n * {@link CodeHighlightTabs} components, providing syntax highlighting, expand/collapse\n * behavior, and file-name tabs.\n *\n * Behavior:\n * - If the code block has an explicit language annotation, uses that language.\n * - If no language is specified and `config.codeBlock.autoDetectUnknownLanguage` is\n * enabled, uses `highlight.js` auto-detection.\n * - Mermaid code blocks (`language-mermaid`) are rendered as interactive diagrams\n * via {@link MantineAIMMermaidCode}.\n * - JSON code blocks are deep-parsed and pretty-printed before display.\n * - Unrecognized languages render as plaintext with an \"unknown\" label using\n * {@link CodeHighlight} (no tabs).\n * - Recognized languages render with {@link CodeHighlightTabs} showing the\n * language name as the tab label.\n *\n * @param props.codeText - The raw text content of the code block.\n * @param props.existLanguage - Language identifier extracted from the `language-*` CSS class, if present.\n */\nconst MantineAIMPreCode = memo(\n (\n props: HTMLAttributes<HTMLPreElement> & {\n codeText: string;\n existLanguage?: string;\n }\n ) => {\n const renderState = useMantineAIMarkdownRenderState();\n\n const codeLanguage = useMemo(() => {\n if (props.existLanguage) return props.existLanguage;\n if (renderState.config.codeBlock.autoDetectUnknownLanguage) {\n return hljs.highlightAuto(props.codeText).language || '';\n }\n return '';\n }, [props.existLanguage, props.codeText, renderState.config.codeBlock.autoDetectUnknownLanguage]);\n\n const [usedCodeLanguage, usedFileName] = useMemo(() => {\n if (!codeLanguage) return ['plaintext', 'unknown'];\n if (!hljs.getLanguage(codeLanguage)) {\n return ['plaintext', codeLanguage];\n }\n return [codeLanguage, codeLanguage];\n }, [codeLanguage]);\n\n const isSpecialCodeBlock = SPECIAL_LANGUAGES.has(codeLanguage);\n\n const normalCodeBlockContent = useMemo(() => {\n if (isSpecialCodeBlock) return null;\n let usedCodeStr = props.codeText;\n if (usedCodeStr && usedCodeLanguage.toLowerCase() === 'json') {\n const deepParsedResult = deepParseJson(usedCodeStr);\n usedCodeStr =\n typeof deepParsedResult === 'string' ? deepParsedResult : JSON.stringify(deepParsedResult, null, 2);\n }\n return usedFileName === 'unknown' ? (\n <CodeHighlight\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={usedCodeStr}\n withBorder\n withExpandButton\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n />\n ) : (\n <CodeHighlightTabs\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={[\n {\n fileName: usedFileName,\n code: usedCodeStr,\n language: usedCodeLanguage,\n },\n ]}\n withBorder\n withExpandButton\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n />\n );\n }, [\n isSpecialCodeBlock,\n props.codeText,\n usedCodeLanguage,\n usedFileName,\n renderState.fontSize,\n renderState.config.codeBlock.defaultExpanded,\n ]);\n\n const specialCodeBlockContent = useMemo(() => {\n switch (codeLanguage) {\n case SpecialCodeLanguage.Mermaid:\n return <MantineAIMMermaidCode code={props.codeText} />;\n default:\n return null;\n }\n }, [codeLanguage, props.codeText]);\n\n return isSpecialCodeBlock ? specialCodeBlockContent : normalCodeBlockContent;\n }\n);\n\nMantineAIMPreCode.displayName = 'MantineAIMPreCode';\n\nexport default MantineAIMPreCode;\n","import { useAIMarkdownRenderState } from '@ai-react-markdown/core';\nimport { MantineAIMarkdownRenderConfig } from '../defs';\n\n/**\n * Typed wrapper around the core {@link useAIMarkdownRenderState} hook.\n *\n * Returns the current {@link AIMarkdownRenderState} defaulting to\n * {@link MantineAIMarkdownRenderConfig}. Accepts an optional generic parameter\n * for further extension, giving consumers direct access to Mantine-specific\n * config fields (`codeBlock`, etc.) without manual annotation.\n *\n * Must be called inside a component rendered within the `<MantineAIMarkdown>` tree.\n * Throws if called outside the provider boundary.\n *\n * @typeParam TConfig - Config type (defaults to {@link MantineAIMarkdownRenderConfig}).\n * @returns The current render state typed with `TConfig`.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { config, streaming, colorScheme } = useMantineAIMarkdownRenderState();\n * const isExpanded = config.codeBlock.defaultExpanded;\n * // ...\n * }\n * ```\n */\nexport const useMantineAIMarkdownRenderState = <\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n>() => {\n return useAIMarkdownRenderState<TConfig>();\n};\n","'use client';\n\nimport React, { memo, useEffect, useRef, useState, useCallback } from 'react';\nimport { CodeHighlightControl, CodeHighlightTabs } from '@mantine/code-highlight';\nimport { ActionIcon, CopyButton, Flex, Tooltip } from '@mantine/core';\nimport mermaid from 'mermaid';\nimport { useMantineAIMarkdownRenderState } from '../../../hooks/useMantineAIMarkdownRenderState';\nimport './styles.scss';\n\n/** Static `<pre>` style for the mermaid container. */\nconst PRE_STYLE = { cursor: 'pointer', overflow: 'auto', width: '100%', padding: '0.5rem' } as const;\n\n/**\n * Generate a unique ID for mermaid SVG rendering.\n * Combines a timestamp with a random suffix to avoid collisions when\n * multiple mermaid diagrams render concurrently.\n *\n * @returns A unique string in the format `mermaid-{timestamp}-{random}`.\n */\nconst generateMermaidUUID = () => {\n return `mermaid-${new Date().getTime()}-${Math.random().toString(36).slice(2, 10)}`;\n};\n\n/**\n * Open the rendered mermaid SVG in a new browser window.\n *\n * Clones the SVG element, applies a background color matching the current\n * color scheme, serializes it to an object URL, and opens it in a new tab.\n * The object URL is revoked after a short delay to free memory.\n *\n * @param svgElement - The rendered SVG element to view, or `null`/`undefined` to no-op.\n * @param isDark - Whether the current color scheme is dark (used for background color).\n */\nconst handleViewSVGInNewWindow = (svgElement: SVGElement | null | undefined, isDark: boolean) => {\n if (!svgElement) return;\n const targetSvg = svgElement.cloneNode(true) as SVGElement;\n targetSvg.style.backgroundColor = isDark ? '#242424' : 'white';\n const text = new XMLSerializer().serializeToString(targetSvg);\n const blob = new Blob([text], { type: 'image/svg+xml' });\n const url = URL.createObjectURL(blob);\n const win = window.open(url);\n if (win) {\n setTimeout(() => URL.revokeObjectURL(url), 5000);\n }\n};\n\n/**\n * Interactive mermaid diagram renderer.\n *\n * Parses and renders mermaid diagram source code into an inline SVG visualization.\n * Automatically adapts to the current Mantine color scheme (light/dark) by\n * re-initializing mermaid with the appropriate theme.\n *\n * Features:\n * - Live SVG rendering with automatic dark/light theme switching\n * - Fallback to raw source code display on parse/render errors\n * - Toggle between rendered diagram and raw mermaid source\n * - Click on the rendered diagram to open the SVG in a new browser window\n * - Copy button for the raw mermaid source code\n * - Chart type label extracted from mermaid's parse result\n * - Preserves the last successful render across transient parse failures\n *\n * ## Streaming contract\n *\n * While `streaming` is true (from render state), the code prop is usually a\n * truncated prefix of the final diagram, so parse failures are *expected*,\n * not exceptional:\n * - Before the first successful render, the raw source is shown as a plain\n * code block (never the error tab).\n * - After a success, the last good SVG stays up; each subsequent chunk is\n * re-attempted and the diagram refreshes only on the next success.\n * - When streaming ends (`streaming` is an effect dep), one corrective pass\n * runs on the final code: success refreshes the diagram, failure surfaces\n * the real error tab — even over a previously rendered mid-stream diagram,\n * because that diagram no longer matches the final source. The pending\n * corrective obligation is tracked by `needsCorrectiveRef` (armed on the\n * streaming→false edge, consumed by the next completed attempt), so ONLY\n * that one pass may clobber a rendered diagram; any later failure (e.g. a\n * transient throw on a theme-flip re-render) falls back to the static rule\n * below.\n * - A streaming→true edge marks a NEW generation (chat \"regenerate\" reuses\n * the same component instance when the block's source offset — and thus\n * its React key — is unchanged). All per-generation state is reset so the\n * warm-up shows the new source instead of the previous generation's stale\n * diagram or error tab.\n *\n * ## Static contract (`streaming` stays false)\n *\n * Without streaming edges, failures follow the original conservative rule:\n * the error tab shows only while nothing has rendered yet. Once a diagram is\n * up, later failures (theme-flip re-render, a not-yet-complete `code` update\n * from a consumer that didn't pass `streaming`) keep the last good diagram\n * instead of clobbering it with an error.\n *\n * @param props.code - Raw mermaid diagram source code to render.\n */\nconst MantineAIMMermaidCode = memo((props: { code: string }) => {\n const renderState = useMantineAIMarkdownRenderState();\n const isDark = renderState.colorScheme === 'dark';\n const streaming = renderState.streaming;\n\n const ref = useRef<HTMLPreElement>(null);\n const renderVersionRef = useRef(0);\n /** Mirrors `hasRendered` for reads inside the async render closure —\n * state reads there can be stale when deps change mid-flight. */\n const hasRenderedRef = useRef(false);\n /** Previous `streaming` value, for edge detection in the effect. */\n const prevStreamingRef = useRef(false);\n /** Armed on the streaming→false edge: the next completed render attempt is\n * the end-of-stream corrective pass, whose failure must surface even over\n * a rendered diagram. Consumed (reset) by that attempt's success OR\n * surfaced failure, so later unrelated failures can't clobber the SVG. */\n const needsCorrectiveRef = useRef(false);\n const [hasRendered, setHasRendered] = useState(false);\n const [showOriginalCode, setShowOriginalCode] = useState(false);\n const [renderError, setRenderError] = useState(false);\n const [chartType, setChartType] = useState('unknown');\n\n useEffect(() => {\n // Streaming edge detection MUST run before any early return — the first\n // chunk of a new stream can arrive while the code is still empty.\n if (streaming && !prevStreamingRef.current) {\n // Rising edge = a new generation is starting on this same instance\n // (same block offset → same React key → no remount on regenerate).\n // Reset all per-generation state so warm-up shows the incoming source,\n // not the previous generation's stale diagram or error tab. Everything\n // here is idempotent — a StrictMode double-run is harmless.\n hasRenderedRef.current = false;\n needsCorrectiveRef.current = false;\n // Deliberate state reset on an input edge (same pattern as a\n // key-less \"derived reset\"); all three are no-ops when already at\n // their initial values, so steady-state chunks don't re-render.\n setHasRendered(false);\n setRenderError(false);\n setChartType('unknown');\n if (ref.current) {\n ref.current.innerHTML = '';\n }\n } else if (!streaming && prevStreamingRef.current) {\n // Falling edge = the stream just ended; arm the corrective pass.\n needsCorrectiveRef.current = true;\n }\n prevStreamingRef.current = streaming;\n if (!props.code || !ref.current || showOriginalCode) {\n return;\n }\n\n const renderVersion = ++renderVersionRef.current;\n let cancelled = false;\n\n const renderMermaid = async () => {\n try {\n mermaid.initialize({\n startOnLoad: false,\n securityLevel: 'strict',\n theme: isDark ? 'dark' : 'base',\n darkMode: isDark,\n // Without a svgContainingElement, a draw-phase throw (an error that\n // got past mermaid.parse) leaves mermaid's temp element orphaned in\n // document.body — its error path only cleans up when this flag is\n // set. We render our own error tab anyway, so mermaid's built-in\n // error diagram is dead weight here regardless.\n suppressErrorRendering: true,\n });\n const parseResult = await mermaid.parse(props.code);\n if (!parseResult) {\n throw new Error('Failed to parse mermaid code');\n }\n\n if (!ref.current || cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n\n // Deliberately NOT passing `ref.current` as mermaid's\n // svgContainingElement: before the first success the host container\n // is hidden with `display: none` (source fallback is showing), and\n // mermaid measures text via getBBox during render — inside a\n // display:none subtree layout never runs, every measurement is 0,\n // and the diagram comes out as a ~16px SVG. With the argument\n // omitted, mermaid renders in a temp element appended to\n // `document.body` (its default path, cleaned up internally), so\n // measurement works no matter what our container is doing. The SVG\n // string is written into our own <pre> below either way.\n const { svg, bindFunctions, diagramType } = await mermaid.render(generateMermaidUUID(), props.code);\n if (!ref.current || cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n\n ref.current.innerHTML = svg;\n bindFunctions?.(ref.current);\n hasRenderedRef.current = true;\n needsCorrectiveRef.current = false;\n setHasRendered(true);\n setChartType(diagramType);\n setRenderError(false);\n } catch {\n if (cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n // Mid-stream failures are expected (truncated code) — keep the last\n // good diagram / source placeholder and wait for more bytes. The\n // corrective pass after streaming ends reports real errors.\n if (streaming) {\n return;\n }\n // End-of-stream corrective pass: the final source no longer renders,\n // so the error must surface even over a mid-stream diagram. Consume\n // the obligation so later unrelated failures don't inherit it.\n if (needsCorrectiveRef.current) {\n needsCorrectiveRef.current = false;\n setChartType('unknown');\n setRenderError(true);\n return;\n }\n // Static rule: never clobber a rendered diagram (theme-flip\n // re-renders, un-flagged code updates from static consumers).\n if (hasRenderedRef.current) {\n return;\n }\n setChartType('unknown');\n setRenderError(true);\n }\n };\n\n void renderMermaid();\n\n return () => {\n cancelled = true;\n };\n // `streaming` in the deps is what drives the end-of-stream corrective\n // pass: the flip to false re-runs this effect on the (unchanged) final\n // code, so the last state reflects the full diagram source.\n }, [props.code, isDark, showOriginalCode, streaming]);\n\n const viewSvgInNewWindow = useCallback(() => {\n handleViewSVGInNewWindow(ref.current?.querySelector('svg'), isDark);\n }, [isDark]);\n\n // Show the raw source instead of the diagram container when the user asked\n // for it, when the (post-stream) render failed, or before the first\n // successful render (SSR output and the streaming warm-up phase). The\n // diagram container below stays MOUNTED throughout — merely hidden — so\n // `ref` is always available for mermaid to render into; unmounting it would\n // make the effect's `!ref.current` guard bail forever.\n const showSourceFallback = showOriginalCode || renderError || !hasRendered;\n\n return (\n <>\n {showSourceFallback && (\n <CodeHighlightTabs\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={[\n {\n fileName: renderError ? 'Mermaid Render Error' : 'mermaid',\n code: props.code,\n language: 'mermaid',\n },\n ]}\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n styles={{\n filesScrollarea: {\n right: '90px',\n },\n }}\n controls={\n // The \"Render Mermaid\" control only makes sense as the way back\n // from the user-toggled source view. In the error and warm-up\n // fallbacks `showOriginalCode` is already false, so the control\n // would be a no-op — hide it there. (No `!renderError` conjunct:\n // the toggle is only reachable from the visible diagram view,\n // and while the source view is open the effect early-returns,\n // so showOriginalCode && renderError is unreachable.)\n showOriginalCode\n ? [\n <CodeHighlightControl\n tooltipLabel=\"Render Mermaid\"\n key=\"gpt\"\n onClick={() => {\n setShowOriginalCode(false);\n }}\n >\n <Flex align=\"center\" justify=\"center\" w={18} h={18}>\n <span className=\"icon-[gravity-ui--logo-mermaid] relative bottom-[1px] text-[16px]\"></span>\n </Flex>\n </CodeHighlightControl>,\n ]\n : []\n }\n withBorder\n withExpandButton\n />\n )}\n <div\n className={`aim-mantine-mermaid-code ${isDark ? 'dark' : ''}`}\n style={\n showSourceFallback\n ? {\n display: 'none',\n }\n : {}\n }\n >\n <div className=\"chart-header\">\n <div className=\"chart-type-tag\">{chartType}</div>\n <Flex align=\"center\" justify=\"flex-end\" gap={0}>\n <Tooltip label=\"Show Mermaid Code\">\n <ActionIcon\n size={28}\n className=\"action-icon\"\n variant=\"transparent\"\n onClick={() => {\n setShowOriginalCode(true);\n }}\n >\n <Flex align=\"center\" justify=\"center\" w={18} h={18}>\n <span className=\"icon-[entypo--code] relative bottom-[0.25px] text-[16px]\"></span>\n </Flex>\n </ActionIcon>\n </Tooltip>\n <CopyButton value={props.code}>\n {({ copied, copy }) => (\n <Tooltip label={copied ? 'Copied' : 'Copy'} withArrow position=\"right\">\n <ActionIcon variant=\"transparent\" size={28} className=\"action-icon\" onClick={copy}>\n {copied ? (\n <span className=\"icon-origin-[lucide--check] text-[18px]\"></span>\n ) : (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n width=\"18px\"\n height=\"18px\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"></path>\n <path d=\"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z\"></path>\n <path d=\"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2\"></path>\n </svg>\n )}\n </ActionIcon>\n </Tooltip>\n )}\n </CopyButton>\n </Flex>\n </div>\n <pre ref={ref} style={PRE_STYLE} onClick={viewSvgInNewWindow} />\n </div>\n </>\n );\n});\n\nMantineAIMMermaidCode.displayName = 'MantineAIMMermaidCode';\n\nexport default MantineAIMMermaidCode;\n","import { useAIMarkdownMetadata } from '@ai-react-markdown/core';\nimport { MantineAIMarkdownMetadata } from '../defs';\n\n/**\n * Typed wrapper around the core {@link useAIMarkdownMetadata} hook.\n *\n * Returns the current metadata defaulting to {@link MantineAIMarkdownMetadata}.\n * Accepts an optional generic parameter for further extension.\n *\n * Metadata lives in a separate React context from the render state, meaning\n * metadata updates do not trigger re-renders in components that only consume\n * render state.\n *\n * Must be called inside a component rendered within the `<MantineAIMarkdown>` tree.\n *\n * @typeParam TMetadata - Metadata type (defaults to {@link MantineAIMarkdownMetadata}).\n * @returns The current metadata, or `undefined` if none was provided.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const metadata = useMantineAIMarkdownMetadata();\n * // Access Mantine-specific metadata fields\n * }\n * ```\n */\nexport const useMantineAIMarkdownMetadata = <\n TMetadata extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n>() => {\n return useAIMarkdownMetadata<TMetadata>();\n};\n"],"mappings":";AAaA,SAAS,QAAAA,OAAM,WAAAC,gBAAe;AAC9B,OAAO,gBAAgB;AACvB,SAAg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AI,CAAC,UAA8B,MAAM,SAAS,EAAE,EAAE,KAAK,IAAI;AAC9F,WAAO,gBAAAA,KAAC,mBAA4B,UAAoB,eAAe,oBAAxC,GAA0D;AAAA,EAC3F;AACF;AAYA,IAAM,6BAA6B,CAGjC;AAAA,EACA,YAAAC,cAAa;AAAA,EACb,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAoD;AAClD,QAAM,yBAAyB,eAAe,gBAAgB;AAE9D,QAAM,iBAAiBC,SAAQ,MAAM;AACnC,WAAO,yBAAyB,EAAE,GAAG,yBAAyB,GAAG,uBAAuB,IAAI;AAAA,EAC9F,GAAG,CAAC,sBAAsB,CAAC;AAE3B,QAAM,sBAAsB,uBAAuB,OAAO;AAE1D,SACE,gBAAAF;AAAA,IAAC;AAAA;AAAA,MACC,YAAYC;AAAA,MACZ;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB,aAAa,eAAe;AAAA,MAC3B,GAAG;AAAA;AAAA,EACN;AAEJ;AAoBO,IAAM,oBAAoBE,MAAK,0BAA0B;AAEhE,kBAAkB,cAAc;AAEhC,IAAO,4BAAQ;;;AOlIf,SAAS,6BAA6B;AA0B/B,IAAM,+BAA+B,MAErC;AACL,SAAO,sBAAiC;AAC1C;","names":["memo","useMemo","jsx","memo","CodeHighlightTabs","memo","jsx","memo","jsx","SpecialCodeLanguage","memo","CodeHighlightTabs","jsx","Typography","useMemo","memo"]}
|
|
1
|
+
{"version":3,"sources":["../src/MantineAIMarkdown.tsx","../src/components/typography/MantineTypography.tsx","../src/components/extra-styles/DefaultExtraStyles/index.tsx","../src/defs.tsx","../src/components/customized/PreCode.tsx","../src/hooks/useMantineAIMarkdownRenderState.ts","../src/components/customized/MermaidCode/index.tsx","../src/hooks/useMantineAIMarkdownMetadata.ts"],"sourcesContent":["/**\n * Main Mantine integration component for AI markdown rendering.\n *\n * Wraps the core {@link AIMarkdown} component with Mantine-specific defaults:\n * - {@link MantineAIMarkdownTypography} as the typography wrapper\n * - {@link MantineAIMDefaultExtraStyles} as the extra styles wrapper\n * - {@link MantineAIMPreCode} as the default `<pre>` component (with syntax\n * highlighting via Mantine's CodeHighlight and mermaid diagram support)\n * - Automatic color scheme detection via Mantine's `useComputedColorScheme`\n *\n * @module MantineAIMarkdown\n */\n\nimport { memo, useMemo } from 'react';\nimport AIMarkdown from '@ai-react-markdown/core';\nimport { type AIMarkdownProps, type AIMarkdownCustomComponents, useStableValue } from '@ai-react-markdown/core';\nimport MantineAIMarkdownTypography from './components/typography/MantineTypography';\nimport MantineAIMDefaultExtraStyles from './components/extra-styles/DefaultExtraStyles';\nimport { MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata, defaultMantineAIMarkdownRenderConfig } from './defs';\nimport MantineAIMPreCode from './components/customized/PreCode';\nimport { useComputedColorScheme } from '@mantine/core';\n\n/**\n * Props for the {@link MantineAIMarkdown} component.\n *\n * Extends {@link AIMarkdownProps} with Mantine-specific config and metadata generics.\n * All core props (`content`, `streaming`, `fontSize`, `config`, etc.) are inherited.\n *\n * @typeParam TConfig - Render configuration type, defaults to {@link MantineAIMarkdownRenderConfig}.\n * @typeParam TRenderData - Metadata type, defaults to {@link MantineAIMarkdownMetadata}.\n */\nexport interface MantineAIMarkdownProps<\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n TRenderData extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n> extends AIMarkdownProps<TConfig, TRenderData> {}\n\n/**\n * Default custom component overrides applied by the Mantine integration.\n *\n * Overrides the `<pre>` element to extract code blocks and render them via\n * {@link MantineAIMPreCode}, which provides syntax highlighting, expand/collapse,\n * and mermaid diagram support. Falls back to a plain `<pre>` when the child\n * is not a recognized code element.\n */\nconst DefaultCustomComponents: AIMarkdownCustomComponents = {\n pre: ({ node, ...usefulProps }) => {\n const code = node?.children[0] as\n | {\n type: string;\n tagName?: string;\n position?: { start?: { offset?: number } };\n properties?: Record<string, unknown>;\n children: { value?: string }[];\n }\n | undefined;\n if (!code || code.type !== 'element' || code.tagName !== 'code' || !code.position) {\n return <pre {...usefulProps} />;\n }\n const key = `pre-code-${node?.position?.start?.offset || 0}`;\n const detectedLanguage = (code.properties?.className as string[])\n ?.find((className: string) => className.startsWith('language-'))\n ?.substring('language-'.length);\n const codeText = code.children.map((child: { value?: string }) => child.value ?? '').join('\\n');\n return <MantineAIMPreCode key={key} codeText={codeText} existLanguage={detectedLanguage} />;\n },\n};\n\n/**\n * Inner (non-memoized) implementation of the Mantine AI markdown component.\n *\n * Merges caller-provided `customComponents` with the Mantine defaults (the caller's\n * overrides take precedence). Automatically resolves the color scheme from Mantine's\n * `useComputedColorScheme` when no explicit `colorScheme` prop is provided.\n *\n * @typeParam TConfig - Render configuration type.\n * @typeParam TRenderData - Metadata type.\n */\nconst MantineAIMarkdownComponent = <\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n TRenderData extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n>({\n Typography = MantineAIMarkdownTypography,\n ExtraStyles = MantineAIMDefaultExtraStyles,\n defaultConfig = defaultMantineAIMarkdownRenderConfig as TConfig,\n customComponents,\n colorScheme,\n ...props\n}: MantineAIMarkdownProps<TConfig, TRenderData>) => {\n const stableCustomComponents = useStableValue(customComponents);\n\n const usedComponents = useMemo(() => {\n return stableCustomComponents ? { ...DefaultCustomComponents, ...stableCustomComponents } : DefaultCustomComponents;\n }, [stableCustomComponents]);\n\n const computedColorScheme = useComputedColorScheme('light');\n\n return (\n <AIMarkdown<MantineAIMarkdownRenderConfig, MantineAIMarkdownMetadata>\n Typography={Typography}\n ExtraStyles={ExtraStyles}\n defaultConfig={defaultConfig}\n customComponents={usedComponents}\n colorScheme={colorScheme ?? computedColorScheme}\n {...props}\n />\n );\n};\n\n/**\n * Mantine-integrated AI markdown renderer.\n *\n * A memoized wrapper around the core `<AIMarkdown>` component that provides\n * Mantine-themed typography, code highlighting (via `@mantine/code-highlight`),\n * mermaid diagram rendering, and automatic color scheme detection.\n *\n * This is the default export of `@ai-react-markdown/mantine`.\n *\n * @example\n * ```tsx\n * import MantineAIMarkdown from '@ai-react-markdown/mantine';\n *\n * function Chat({ content }: { content: string }) {\n * return <MantineAIMarkdown content={content} />;\n * }\n * ```\n */\nexport const MantineAIMarkdown = memo(MantineAIMarkdownComponent);\n\nMantineAIMarkdown.displayName = 'MantineAIMarkdown';\n\nexport default MantineAIMarkdown as typeof MantineAIMarkdownComponent;\n","import { memo } from 'react';\nimport { Typography } from '@mantine/core';\nimport type { AIMarkdownTypographyProps } from '@ai-react-markdown/core';\n\n/**\n * Mantine-themed typography wrapper for AI markdown content.\n *\n * Replaces the core default typography component with Mantine's `<Typography>`\n * element, applying the configured `fontSize` at full width. This ensures all\n * rendered markdown inherits Mantine's font family, line height, and theming.\n *\n * Used as the default `Typography` prop in {@link MantineAIMarkdown}.\n * Can be replaced by passing a custom `Typography` component.\n *\n * @param props - Standard {@link AIMarkdownTypographyProps} from the core package.\n */\nconst MantineAIMarkdownTypography = memo(({ children, fontSize, style }: AIMarkdownTypographyProps) => (\n <Typography w=\"100%\" fz={fontSize} style={style}>\n {children}\n </Typography>\n));\n\nMantineAIMarkdownTypography.displayName = 'MantineAIMarkdownTypography';\n\nexport default MantineAIMarkdownTypography;\n","import React from 'react';\nimport { AIMarkdownExtraStylesComponent } from '@ai-react-markdown/core';\nimport './styles.scss';\n\n/**\n * Default extra styles wrapper for the Mantine integration.\n *\n * Wraps markdown content in a `<div>` with the `aim-mantine-extra-styles` CSS class,\n * which provides Mantine-compatible typography overrides including:\n * - Relative `em`-based Mantine spacing and font-size CSS custom properties\n * - Heading, list, paragraph, blockquote, and code styling\n * - Definition list layout\n *\n * Used as the default `ExtraStyles` prop in {@link MantineAIMarkdown}.\n */\nconst MantineAIMDefaultExtraStyles: AIMarkdownExtraStylesComponent = ({ children }) => {\n return <div className=\"aim-mantine-extra-styles\">{children}</div>;\n};\n\nexport default MantineAIMDefaultExtraStyles;\n","/**\n * Mantine-specific type definitions and default configuration.\n *\n * Extends the core {@link AIMarkdownRenderConfig} and {@link AIMarkdownMetadata}\n * with Mantine-themed options such as uniform heading sizes and code block behavior.\n *\n * @module defs\n */\n\nimport { AIMarkdownRenderConfig, AIMarkdownMetadata, defaultAIMarkdownRenderConfig } from '@ai-react-markdown/core';\n\n/**\n * Extended render configuration for the Mantine integration.\n *\n * Inherits all core config fields (extra syntax, display optimizations) and adds\n * Mantine-specific options for typography sizing and code block behavior.\n */\nexport interface MantineAIMarkdownRenderConfig extends AIMarkdownRenderConfig {\n /** Code block rendering options. */\n codeBlock: {\n /**\n * Whether code blocks start in their expanded state.\n * When `false`, long code blocks are collapsed with an expand button.\n *\n * @default true\n */\n defaultExpanded: boolean;\n\n /**\n * When `true`, uses `highlight.js` auto-detection to determine the language\n * of code blocks that lack an explicit language annotation.\n *\n * @default false\n */\n autoDetectUnknownLanguage: boolean;\n };\n}\n\n/**\n * Default Mantine render configuration.\n *\n * Extends {@link defaultAIMarkdownRenderConfig} with Mantine-specific defaults.\n * Frozen to prevent accidental mutation.\n */\nexport const defaultMantineAIMarkdownRenderConfig: MantineAIMarkdownRenderConfig = Object.freeze({\n ...defaultAIMarkdownRenderConfig,\n codeBlock: Object.freeze({\n defaultExpanded: true,\n autoDetectUnknownLanguage: false,\n }),\n});\n\n/**\n * Metadata type for the Mantine integration.\n *\n * Currently identical to {@link AIMarkdownMetadata}. Exists as an extension point\n * so that consumers can augment metadata in Mantine-specific wrappers without\n * needing to reference the core type directly.\n */\nexport interface MantineAIMarkdownMetadata extends AIMarkdownMetadata {}\n","'use client';\n\nimport { HTMLAttributes, memo, useMemo } from 'react';\nimport { CodeHighlight, CodeHighlightTabs } from '@mantine/code-highlight';\nimport { deepParseJson } from 'deep-parse-json';\nimport hljs from 'highlight.js';\nimport { useMantineAIMarkdownRenderState } from '../../hooks/useMantineAIMarkdownRenderState';\nimport MantineAIMMermaidCode from './MermaidCode';\n\n/**\n * Code languages that receive specialized rendering instead of standard\n * syntax-highlighted code blocks. Adding a new member here automatically\n * marks that language as \"special\" — you only need to add the corresponding\n * rendering branch in the component's return.\n */\nenum SpecialCodeLanguage {\n /** Rendered as interactive diagrams via {@link MantineAIMMermaidCode} */\n Mermaid = 'mermaid',\n}\n\n/** O(1) lookup set, derived from {@link SpecialCodeLanguage}. */\nconst SPECIAL_LANGUAGES = new Set<string>(Object.values(SpecialCodeLanguage));\n\n/**\n * Mantine code block renderer for `<pre>` elements.\n *\n * Replaces the default `<pre>` rendering with Mantine's {@link CodeHighlight} or\n * {@link CodeHighlightTabs} components, providing syntax highlighting, expand/collapse\n * behavior, and file-name tabs.\n *\n * Behavior:\n * - If the code block has an explicit language annotation, uses that language.\n * - If no language is specified and `config.codeBlock.autoDetectUnknownLanguage` is\n * enabled, uses `highlight.js` auto-detection.\n * - Mermaid code blocks (`language-mermaid`) are rendered as interactive diagrams\n * via {@link MantineAIMMermaidCode}.\n * - JSON code blocks are deep-parsed and pretty-printed before display.\n * - Unrecognized languages render as plaintext with an \"unknown\" label using\n * {@link CodeHighlight} (no tabs).\n * - Recognized languages render with {@link CodeHighlightTabs} showing the\n * language name as the tab label.\n *\n * @param props.codeText - The raw text content of the code block.\n * @param props.existLanguage - Language identifier extracted from the `language-*` CSS class, if present.\n */\nconst MantineAIMPreCode = memo(\n (\n props: HTMLAttributes<HTMLPreElement> & {\n codeText: string;\n existLanguage?: string;\n }\n ) => {\n const renderState = useMantineAIMarkdownRenderState();\n\n const codeLanguage = useMemo(() => {\n if (props.existLanguage) return props.existLanguage;\n if (renderState.config.codeBlock.autoDetectUnknownLanguage) {\n return hljs.highlightAuto(props.codeText).language || '';\n }\n return '';\n }, [props.existLanguage, props.codeText, renderState.config.codeBlock.autoDetectUnknownLanguage]);\n\n const [usedCodeLanguage, usedFileName] = useMemo(() => {\n if (!codeLanguage) return ['plaintext', 'unknown'];\n if (!hljs.getLanguage(codeLanguage)) {\n return ['plaintext', codeLanguage];\n }\n return [codeLanguage, codeLanguage];\n }, [codeLanguage]);\n\n const isSpecialCodeBlock = SPECIAL_LANGUAGES.has(codeLanguage);\n\n const normalCodeBlockContent = useMemo(() => {\n if (isSpecialCodeBlock) return null;\n let usedCodeStr = props.codeText;\n if (usedCodeStr && usedCodeLanguage.toLowerCase() === 'json') {\n const deepParsedResult = deepParseJson(usedCodeStr);\n usedCodeStr =\n typeof deepParsedResult === 'string' ? deepParsedResult : JSON.stringify(deepParsedResult, null, 2);\n }\n return usedFileName === 'unknown' ? (\n <CodeHighlight\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={usedCodeStr}\n withBorder\n withExpandButton\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n />\n ) : (\n <CodeHighlightTabs\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={[\n {\n fileName: usedFileName,\n code: usedCodeStr,\n language: usedCodeLanguage,\n },\n ]}\n withBorder\n withExpandButton\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n />\n );\n }, [\n isSpecialCodeBlock,\n props.codeText,\n usedCodeLanguage,\n usedFileName,\n renderState.fontSize,\n renderState.config.codeBlock.defaultExpanded,\n ]);\n\n const specialCodeBlockContent = useMemo(() => {\n switch (codeLanguage) {\n case SpecialCodeLanguage.Mermaid:\n return <MantineAIMMermaidCode code={props.codeText} />;\n default:\n return null;\n }\n }, [codeLanguage, props.codeText]);\n\n return isSpecialCodeBlock ? specialCodeBlockContent : normalCodeBlockContent;\n }\n);\n\nMantineAIMPreCode.displayName = 'MantineAIMPreCode';\n\nexport default MantineAIMPreCode;\n","import { useAIMarkdownRenderState } from '@ai-react-markdown/core';\nimport { MantineAIMarkdownRenderConfig } from '../defs';\n\n/**\n * Typed wrapper around the core {@link useAIMarkdownRenderState} hook.\n *\n * Returns the current {@link AIMarkdownRenderState} defaulting to\n * {@link MantineAIMarkdownRenderConfig}. Accepts an optional generic parameter\n * for further extension, giving consumers direct access to Mantine-specific\n * config fields (`codeBlock`, etc.) without manual annotation.\n *\n * Must be called inside a component rendered within the `<MantineAIMarkdown>` tree.\n * Throws if called outside the provider boundary.\n *\n * @typeParam TConfig - Config type (defaults to {@link MantineAIMarkdownRenderConfig}).\n * @returns The current render state typed with `TConfig`.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { config, streaming, colorScheme } = useMantineAIMarkdownRenderState();\n * const isExpanded = config.codeBlock.defaultExpanded;\n * // ...\n * }\n * ```\n */\nexport const useMantineAIMarkdownRenderState = <\n TConfig extends MantineAIMarkdownRenderConfig = MantineAIMarkdownRenderConfig,\n>() => {\n return useAIMarkdownRenderState<TConfig>();\n};\n","'use client';\n\nimport React, { memo, useEffect, useRef, useState, useCallback } from 'react';\nimport { CodeHighlightControl, CodeHighlightTabs } from '@mantine/code-highlight';\nimport { ActionIcon, CopyButton, Flex, Tooltip } from '@mantine/core';\nimport mermaid from 'mermaid';\nimport { useMantineAIMarkdownRenderState } from '../../../hooks/useMantineAIMarkdownRenderState';\nimport './styles.scss';\n\n/** Static `<pre>` style for the mermaid container. */\nconst PRE_STYLE = { cursor: 'pointer', overflow: 'auto', width: '100%', padding: '0.5rem' } as const;\n\n/**\n * What the component currently shows. One value instead of separate\n * `hasRendered`/`renderError`/`chartType` fields whose combinations had to\n * be kept coherent by hand:\n * - `source`: warm-up / SSR fallback — raw code as a plain code block\n * (nothing rendered yet this generation).\n * - `diagram`: the last successful SVG is up.\n * - `error`: the error tab — only a post-stream corrective failure or a\n * never-rendered static failure can enter this state.\n *\n * The user's source toggle (`showOriginalCode`) is deliberately NOT a\n * phase: it overlays any view and flipping it back must restore the prior\n * one unchanged.\n */\ntype MermaidView = { kind: 'source' } | { kind: 'diagram'; chartType: string } | { kind: 'error' };\n\n/** Equality used to skip no-op view updates — repeat mid-stream successes\n * of the same chart type must not re-render the host per chunk. */\nconst sameView = (a: MermaidView, b: MermaidView): boolean =>\n a.kind === 'diagram' && b.kind === 'diagram' ? a.chartType === b.chartType : a.kind === b.kind;\n\n/** Theme mermaid.initialize was last called with. mermaid's config is a\n * module-level singleton, so re-asserting an unchanged theme before every\n * render attempt (each streamed chunk re-runs the effect) is pure waste —\n * but instances under providers with DIFFERENT schemes must each\n * re-assert before their own render, so the cache is module-level and\n * checked per attempt rather than hoisted into a per-instance effect. */\nlet initializedTheme: 'dark' | 'light' | null = null;\n\nconst ensureMermaidInitialized = (isDark: boolean) => {\n const theme = isDark ? 'dark' : 'light';\n if (initializedTheme === theme) return;\n mermaid.initialize({\n startOnLoad: false,\n securityLevel: 'strict',\n theme: isDark ? 'dark' : 'base',\n darkMode: isDark,\n // Without a svgContainingElement, a draw-phase throw (an error that\n // got past mermaid.parse) leaves mermaid's temp element orphaned in\n // document.body — its error path only cleans up when this flag is\n // set. We render our own error tab anyway, so mermaid's built-in\n // error diagram is dead weight here regardless.\n suppressErrorRendering: true,\n });\n initializedTheme = theme;\n};\n\n/**\n * Generate a unique ID for mermaid SVG rendering.\n * Combines a timestamp with a random suffix to avoid collisions when\n * multiple mermaid diagrams render concurrently.\n *\n * @returns A unique string in the format `mermaid-{timestamp}-{random}`.\n */\nconst generateMermaidUUID = () => {\n return `mermaid-${new Date().getTime()}-${Math.random().toString(36).slice(2, 10)}`;\n};\n\n/**\n * Open the rendered mermaid SVG in a new browser window.\n *\n * Clones the SVG element, applies a background color matching the current\n * color scheme, serializes it to an object URL, and opens it in a new tab.\n * The object URL is revoked after a short delay to free memory.\n *\n * @param svgElement - The rendered SVG element to view, or `null`/`undefined` to no-op.\n * @param isDark - Whether the current color scheme is dark (used for background color).\n */\nconst handleViewSVGInNewWindow = (svgElement: SVGElement | null | undefined, isDark: boolean) => {\n if (!svgElement) return;\n const targetSvg = svgElement.cloneNode(true) as SVGElement;\n targetSvg.style.backgroundColor = isDark ? '#242424' : 'white';\n const text = new XMLSerializer().serializeToString(targetSvg);\n const blob = new Blob([text], { type: 'image/svg+xml' });\n const url = URL.createObjectURL(blob);\n const win = window.open(url);\n if (win) {\n setTimeout(() => URL.revokeObjectURL(url), 5000);\n }\n};\n\n/**\n * Interactive mermaid diagram renderer.\n *\n * Parses and renders mermaid diagram source code into an inline SVG visualization.\n * Automatically adapts to the current Mantine color scheme (light/dark) by\n * re-initializing mermaid with the appropriate theme.\n *\n * Features:\n * - Live SVG rendering with automatic dark/light theme switching\n * - Fallback to raw source code display on parse/render errors\n * - Toggle between rendered diagram and raw mermaid source\n * - Click on the rendered diagram to open the SVG in a new browser window\n * - Copy button for the raw mermaid source code\n * - Chart type label extracted from mermaid's parse result\n * - Preserves the last successful render across transient parse failures\n *\n * ## Streaming contract\n *\n * While `streaming` is true (from render state), the code prop is usually a\n * truncated prefix of the final diagram, so parse failures are *expected*,\n * not exceptional:\n * - Before the first successful render, the raw source is shown as a plain\n * code block (never the error tab).\n * - After a success, the last good SVG stays up; each subsequent chunk is\n * re-attempted and the diagram refreshes only on the next success.\n * - When streaming ends (`streaming` is an effect dep), one corrective pass\n * runs on the final code: success refreshes the diagram, failure surfaces\n * the real error tab — even over a previously rendered mid-stream diagram,\n * because that diagram no longer matches the final source. The pending\n * corrective obligation is tracked by `needsCorrectiveRef` (armed on the\n * streaming→false edge, consumed by the next completed attempt), so ONLY\n * that one pass may clobber a rendered diagram; any later failure (e.g. a\n * transient throw on a theme-flip re-render) falls back to the static rule\n * below.\n * - A streaming→true edge marks a NEW generation (chat \"regenerate\" reuses\n * the same component instance when the block's source offset — and thus\n * its React key — is unchanged). All per-generation state is reset so the\n * warm-up shows the new source instead of the previous generation's stale\n * diagram or error tab.\n *\n * ## Static contract (`streaming` stays false)\n *\n * Without streaming edges, failures follow the original conservative rule:\n * the error tab shows only while nothing has rendered yet. Once a diagram is\n * up, later failures (theme-flip re-render, a not-yet-complete `code` update\n * from a consumer that didn't pass `streaming`) keep the last good diagram\n * instead of clobbering it with an error.\n *\n * @param props.code - Raw mermaid diagram source code to render.\n */\nconst MantineAIMMermaidCode = memo((props: { code: string }) => {\n const renderState = useMantineAIMarkdownRenderState();\n const isDark = renderState.colorScheme === 'dark';\n const streaming = renderState.streaming;\n\n const ref = useRef<HTMLPreElement>(null);\n const renderVersionRef = useRef(0);\n /** Mirrors `view` for reads inside the async render closure — state reads\n * there can be stale when deps change mid-flight. */\n const viewRef = useRef<MermaidView>({ kind: 'source' });\n /** Previous `streaming` value, for edge detection in the effect. */\n const prevStreamingRef = useRef(false);\n /** Armed on the streaming→false edge: the next completed render attempt is\n * the end-of-stream corrective pass, whose failure must surface even over\n * a rendered diagram. Consumed (reset) by that attempt's success OR\n * surfaced failure, so later unrelated failures can't clobber the SVG. */\n const needsCorrectiveRef = useRef(false);\n /** Inputs of the render whose SVG currently sits in the host `<pre>`.\n * When the effect re-runs with the same (code, theme) pair — the\n * post-stream corrective flip on an already-final diagram, or returning\n * from the source view — the DOM already holds that exact render, so\n * the attempt (and its parse + temp-element render) is skipped. */\n const lastSuccessRef = useRef<{ code: string; isDark: boolean } | null>(null);\n const [view, setViewState] = useState<MermaidView>({ kind: 'source' });\n const [showOriginalCode, setShowOriginalCode] = useState(false);\n\n useEffect(() => {\n // View updates funnel through here so the ref mirror can't desync from\n // the state, and no-op updates are dropped (repeat mid-stream successes\n // and idempotent edge resets must not re-render the host per chunk).\n const applyView = (next: MermaidView) => {\n viewRef.current = next;\n setViewState((prev) => (sameView(prev, next) ? prev : next));\n };\n\n // Streaming edge detection MUST run before any early return — the first\n // chunk of a new stream can arrive while the code is still empty.\n if (streaming && !prevStreamingRef.current) {\n // Rising edge = a new generation is starting on this same instance\n // (same block offset → same React key → no remount on regenerate).\n // Reset all per-generation state so warm-up shows the incoming source,\n // not the previous generation's stale diagram or error tab. Everything\n // here is idempotent — a StrictMode double-run is harmless.\n needsCorrectiveRef.current = false;\n lastSuccessRef.current = null;\n applyView({ kind: 'source' });\n if (ref.current) {\n ref.current.innerHTML = '';\n }\n } else if (!streaming && prevStreamingRef.current) {\n // Falling edge = the stream just ended; arm the corrective pass.\n needsCorrectiveRef.current = true;\n }\n prevStreamingRef.current = streaming;\n if (!props.code || !ref.current || showOriginalCode) {\n return;\n }\n\n // The SVG in the DOM already came from exactly this (code, theme) pair —\n // nothing to recompute. This also SATISFIES a pending corrective\n // obligation: the identical successful render IS the verdict on the\n // final source, so the obligation is consumed, not left armed for some\n // later unrelated failure to inherit.\n if (lastSuccessRef.current?.code === props.code && lastSuccessRef.current.isDark === isDark) {\n needsCorrectiveRef.current = false;\n return;\n }\n\n const renderVersion = ++renderVersionRef.current;\n let cancelled = false;\n\n const renderMermaid = async () => {\n try {\n ensureMermaidInitialized(isDark);\n const parseResult = await mermaid.parse(props.code);\n if (!parseResult) {\n throw new Error('Failed to parse mermaid code');\n }\n\n if (!ref.current || cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n\n // Deliberately NOT passing `ref.current` as mermaid's\n // svgContainingElement: before the first success the host container\n // is hidden with `display: none` (source fallback is showing), and\n // mermaid measures text via getBBox during render — inside a\n // display:none subtree layout never runs, every measurement is 0,\n // and the diagram comes out as a ~16px SVG. With the argument\n // omitted, mermaid renders in a temp element appended to\n // `document.body` (its default path, cleaned up internally), so\n // measurement works no matter what our container is doing. The SVG\n // string is written into our own <pre> below either way.\n const { svg, bindFunctions, diagramType } = await mermaid.render(generateMermaidUUID(), props.code);\n if (!ref.current || cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n\n ref.current.innerHTML = svg;\n bindFunctions?.(ref.current);\n needsCorrectiveRef.current = false;\n lastSuccessRef.current = { code: props.code, isDark };\n applyView({ kind: 'diagram', chartType: diagramType });\n } catch {\n if (cancelled || renderVersion !== renderVersionRef.current) {\n return;\n }\n // Mid-stream failures are expected (truncated code) — keep the last\n // good diagram / source placeholder and wait for more bytes. The\n // corrective pass after streaming ends reports real errors.\n if (streaming) {\n return;\n }\n // End-of-stream corrective pass: the final source no longer renders,\n // so the error must surface even over a mid-stream diagram. Consume\n // the obligation so later unrelated failures don't inherit it.\n if (needsCorrectiveRef.current) {\n needsCorrectiveRef.current = false;\n applyView({ kind: 'error' });\n return;\n }\n // Static rule: never clobber a rendered diagram (theme-flip\n // re-renders, un-flagged code updates from static consumers).\n if (viewRef.current.kind === 'diagram') {\n return;\n }\n applyView({ kind: 'error' });\n }\n };\n\n void renderMermaid();\n\n return () => {\n cancelled = true;\n };\n // `streaming` in the deps is what drives the end-of-stream corrective\n // pass: the flip to false re-runs this effect on the (unchanged) final\n // code, so the last state reflects the full diagram source.\n }, [props.code, isDark, showOriginalCode, streaming]);\n\n const viewSvgInNewWindow = useCallback(() => {\n handleViewSVGInNewWindow(ref.current?.querySelector('svg'), isDark);\n }, [isDark]);\n\n // Show the raw source instead of the diagram container when the user asked\n // for it, when the (post-stream) render failed, or before the first\n // successful render (SSR output and the streaming warm-up phase). The\n // diagram container below stays MOUNTED throughout — merely hidden — so\n // `ref` is always available for mermaid to render into; unmounting it would\n // make the effect's `!ref.current` guard bail forever.\n const showSourceFallback = showOriginalCode || view.kind !== 'diagram';\n\n return (\n <>\n {showSourceFallback && (\n <CodeHighlightTabs\n mb={15}\n fz={renderState.fontSize}\n w=\"100%\"\n code={[\n {\n fileName: view.kind === 'error' ? 'Mermaid Render Error' : 'mermaid',\n code: props.code,\n language: 'mermaid',\n },\n ]}\n defaultExpanded={renderState.config.codeBlock.defaultExpanded}\n maxCollapsedHeight=\"320px\"\n styles={{\n filesScrollarea: {\n right: '90px',\n },\n }}\n controls={\n // The \"Render Mermaid\" control only makes sense as the way back\n // from the user-toggled source view. In the error and warm-up\n // fallbacks `showOriginalCode` is already false, so the control\n // would be a no-op — hide it there. (No view-kind conjunct: the\n // toggle is only reachable from the visible diagram view, and\n // while the source view is open the effect early-returns, so\n // showOriginalCode && view.kind === 'error' is unreachable.)\n showOriginalCode\n ? [\n <CodeHighlightControl\n tooltipLabel=\"Render Mermaid\"\n key=\"gpt\"\n onClick={() => {\n setShowOriginalCode(false);\n }}\n >\n <Flex align=\"center\" justify=\"center\" w={18} h={18}>\n <span className=\"icon-[gravity-ui--logo-mermaid] relative bottom-[1px] text-[16px]\"></span>\n </Flex>\n </CodeHighlightControl>,\n ]\n : []\n }\n withBorder\n withExpandButton\n />\n )}\n <div\n className={`aim-mantine-mermaid-code ${isDark ? 'dark' : ''}`}\n style={\n showSourceFallback\n ? {\n display: 'none',\n }\n : {}\n }\n >\n <div className=\"chart-header\">\n <div className=\"chart-type-tag\">{view.kind === 'diagram' ? view.chartType : 'unknown'}</div>\n <Flex align=\"center\" justify=\"flex-end\" gap={0}>\n <Tooltip label=\"Show Mermaid Code\">\n <ActionIcon\n size={28}\n className=\"action-icon\"\n variant=\"transparent\"\n onClick={() => {\n setShowOriginalCode(true);\n }}\n >\n <Flex align=\"center\" justify=\"center\" w={18} h={18}>\n <span className=\"icon-[entypo--code] relative bottom-[0.25px] text-[16px]\"></span>\n </Flex>\n </ActionIcon>\n </Tooltip>\n <CopyButton value={props.code}>\n {({ copied, copy }) => (\n <Tooltip label={copied ? 'Copied' : 'Copy'} withArrow position=\"right\">\n <ActionIcon variant=\"transparent\" size={28} className=\"action-icon\" onClick={copy}>\n {copied ? (\n <span className=\"icon-origin-[lucide--check] text-[18px]\"></span>\n ) : (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n width=\"18px\"\n height=\"18px\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"></path>\n <path d=\"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z\"></path>\n <path d=\"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2\"></path>\n </svg>\n )}\n </ActionIcon>\n </Tooltip>\n )}\n </CopyButton>\n </Flex>\n </div>\n <pre ref={ref} style={PRE_STYLE} onClick={viewSvgInNewWindow} />\n </div>\n </>\n );\n});\n\nMantineAIMMermaidCode.displayName = 'MantineAIMMermaidCode';\n\nexport default MantineAIMMermaidCode;\n","import { useAIMarkdownMetadata } from '@ai-react-markdown/core';\nimport { MantineAIMarkdownMetadata } from '../defs';\n\n/**\n * Typed wrapper around the core {@link useAIMarkdownMetadata} hook.\n *\n * Returns the current metadata defaulting to {@link MantineAIMarkdownMetadata}.\n * Accepts an optional generic parameter for further extension.\n *\n * Metadata lives in a separate React context from the render state, meaning\n * metadata updates do not trigger re-renders in components that only consume\n * render state.\n *\n * Must be called inside a component rendered within the `<MantineAIMarkdown>` tree.\n *\n * @typeParam TMetadata - Metadata type (defaults to {@link MantineAIMarkdownMetadata}).\n * @returns The current metadata, or `undefined` if none was provided.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const metadata = useMantineAIMarkdownMetadata();\n * // Access Mantine-specific metadata fields\n * }\n * ```\n */\nexport const useMantineAIMarkdownMetadata = <\n TMetadata extends MantineAIMarkdownMetadata = MantineAIMarkdownMetadata,\n>() => {\n return useAIMarkdownMetadata<TMetadata>();\n};\n"],"mappings":";AAaA,SAAS,QAAAA,OAAM,WAAAC,gBAAe;AAC9B,OAAO,gBAAgB;AACvB,SAAgE,sBAAsB;;;ACftF,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAgBzB;AADF,IAAM,8BAA8B,KAAK,CAAC,EAAE,UAAU,UAAU,MAAM,MACpE,oBAAC,cAAW,GAAE,QAAO,IAAI,UAAU,OAChC,UACH,CACD;AAED,4BAA4B,cAAc;AAE1C,IAAO,4BAAQ;;;ACRN,gBAAAC,YAAA;AADT,IAAM,+BAA+D,CAAC,EAAE,SAAS,MAAM;AACrF,SAAO,gBAAAA,KAAC,SAAI,WAAU,4BAA4B,UAAS;AAC7D;AAEA,IAAO,6BAAQ;;;ACVf,SAAqD,qCAAqC;AAmCnF,IAAM,uCAAsE,OAAO,OAAO;AAAA,EAC/F,GAAG;AAA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AAC,cAAsB,UAAU,WAAW,WAAW,CAAC,GAC7D,UAAU,YAAY,MAAM;AAChC,UAAM,WAAW,KAAK,SAAS,IAAI,CAAC,UAA8B,MAAM,SAAS,EAAE,EAAE,KAAK,IAAI;AAC9F,WAAO,gBAAAA,KAAC,mBAA4B,UAAoB,eAAe,oBAAxC,GAA0D;AAAA,EAC3F;AACF;AAYA,IAAM,6BAA6B,CAGjC;AAAA,EACA,YAAAC,cAAa;AAAA,EACb,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAoD;AAClD,QAAM,yBAAyB,eAAe,gBAAgB;AAE9D,QAAM,iBAAiBC,SAAQ,MAAM;AACnC,WAAO,yBAAyB,EAAE,GAAG,yBAAyB,GAAG,uBAAuB,IAAI;AAAA,EAC9F,GAAG,CAAC,sBAAsB,CAAC;AAE3B,QAAM,sBAAsB,uBAAuB,OAAO;AAE1D,SACE,gBAAAF;AAAA,IAAC;AAAA;AAAA,MACC,YAAYC;AAAA,MACZ;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB,aAAa,eAAe;AAAA,MAC3B,GAAG;AAAA;AAAA,EACN;AAEJ;AAoBO,IAAM,oBAAoBE,MAAK,0BAA0B;AAEhE,kBAAkB,cAAc;AAEhC,IAAO,4BAAQ;;;AOlIf,SAAS,6BAA6B;AA0B/B,IAAM,+BAA+B,MAErC;AACL,SAAO,sBAAiC;AAC1C;","names":["memo","useMemo","jsx","memo","CodeHighlightTabs","memo","jsx","memo","jsx","SpecialCodeLanguage","memo","CodeHighlightTabs","jsx","Typography","useMemo","memo"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-react-markdown/mantine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Mantine UI integration for ai-react-markdown — themed typography, syntax highlighting via @mantine/code-highlight, Mermaid diagrams, and automatic color scheme detection.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"./styles.css": "./dist/index.css"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@ai-react-markdown/core": "^1.
|
|
54
|
+
"@ai-react-markdown/core": "^1.6.1",
|
|
55
55
|
"@mantine/code-highlight": "^9.0.0",
|
|
56
56
|
"@mantine/core": "^9.0.0",
|
|
57
57
|
"highlight.js": "^11.11.1",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"@mantine/hooks": "^9.4.1",
|
|
69
69
|
"@types/lodash-es": "^4.17.12",
|
|
70
70
|
"@types/node": "^25.9.5",
|
|
71
|
-
"autoprefixer": "^10.5.
|
|
71
|
+
"autoprefixer": "^10.5.4",
|
|
72
72
|
"esbuild-sass-plugin": "^3.7.0",
|
|
73
73
|
"highlight.js": "^11.11.1",
|
|
74
74
|
"lodash-es": "^4.18.0",
|
|
75
|
-
"postcss": "^8.5.
|
|
75
|
+
"postcss": "^8.5.19",
|
|
76
76
|
"tsup": "^8.5.1",
|
|
77
|
-
"@ai-react-markdown/core": "1.
|
|
77
|
+
"@ai-react-markdown/core": "1.6.1"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"build": "tsup",
|