@ai-react-markdown/core 1.1.0 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brian Lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @ai-react-markdown/core
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@ai-react-markdown/core)](https://www.npmjs.com/package/@ai-react-markdown/core)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@ai-react-markdown/core)](https://www.npmjs.com/package/@ai-react-markdown/core)
5
+ [![license](https://img.shields.io/npm/l/@ai-react-markdown/core)](../../LICENSE)
6
+
3
7
  A batteries-included React component for rendering AI-generated markdown with first-class support for LaTeX math, GFM, CJK text, and streaming content.
4
8
 
5
9
  ## Features
@@ -81,7 +85,7 @@ function StreamingChat({ content, isStreaming }: { content: string; isStreaming:
81
85
  | ---------------------- | -------------------------------- | ------------------------------- | ---------------------------------------------------------------------- |
82
86
  | `content` | `string` | **(required)** | Raw markdown content to render. |
83
87
  | `streaming` | `boolean` | `false` | Whether content is actively being streamed (e.g. from an LLM). |
84
- | `fontSize` | `number \| string` | `'0.875rem'` | Base font size. Numbers are treated as pixels. |
88
+ | `fontSize` | `number \| string` | `'0.9375rem'` | Base font size. Numbers are treated as pixels. |
85
89
  | `variant` | `AIMarkdownVariant` | `'default'` | Typography variant name. |
86
90
  | `colorScheme` | `AIMarkdownColorScheme` | `'light'` | Color scheme name (`'light'`, `'dark'`, or custom). |
87
91
  | `config` | `PartialDeep<TConfig>` | `undefined` | Partial render config, deep-merged with defaults. |
@@ -209,7 +213,7 @@ The `<AIMarkdown>` component wraps its content in a typography component that co
209
213
  The built-in `DefaultTypography` renders a `<div>` with CSS class names for the active variant and color scheme:
210
214
 
211
215
  ```html
212
- <div class="aim-typography-root default light" style="width: 100%; font-size: 0.875rem">
216
+ <div class="aim-typography-root default light" style="width: 100%; font-size: 0.9375rem">
213
217
  <!-- markdown content -->
214
218
  </div>
215
219
  ```
@@ -222,14 +226,14 @@ import '@ai-react-markdown/core/typography/default.css';
222
226
 
223
227
  ### Custom Typography Component
224
228
 
225
- Replace the typography wrapper by passing a custom component:
229
+ Replace the typography wrapper by passing a custom component. The `style` prop carries CSS custom properties injected by the core renderer — **merge it onto your root element** so that descendant CSS can reference these variables:
226
230
 
227
231
  ```tsx
228
232
  import type { AIMarkdownTypographyProps } from '@ai-react-markdown/core';
229
233
 
230
- function MyTypography({ children, fontSize, variant, colorScheme }: AIMarkdownTypographyProps) {
234
+ function MyTypography({ children, fontSize, variant, colorScheme, style }: AIMarkdownTypographyProps) {
231
235
  return (
232
- <div className={`my-markdown ${colorScheme}`} style={{ fontSize }}>
236
+ <div className={`my-markdown ${colorScheme}`} style={{ fontSize, ...style }}>
233
237
  {children}
234
238
  </div>
235
239
  );
@@ -238,6 +242,16 @@ function MyTypography({ children, fontSize, variant, colorScheme }: AIMarkdownTy
238
242
  <AIMarkdown content={markdown} Typography={MyTypography} />;
239
243
  ```
240
244
 
245
+ #### Injected CSS Custom Properties
246
+
247
+ The core renderer injects the following CSS custom properties via the Typography `style` prop:
248
+
249
+ | Variable | Value | Purpose |
250
+ | ---------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
251
+ | `--aim-font-size-root` | `fontSize` prop | Absolute font-size anchor for the component instance. Inner CSS can use `var(--aim-font-size-root)` to bypass `em` compounding in deeply nested markdown structures (e.g. code inside blockquotes). |
252
+
253
+ **Why `--aim-font-size-root`?** Markdown content frequently nests elements that use relative `em` units — blockquotes, lists, code blocks. Each nesting level compounds the effective size: a `0.875em` code span inside a `1.125em` blockquote resolves to `0.984em` of the parent, not `0.875em` of the root. This variable provides a stable, absolute reference that inner CSS rules can use to opt out of compounding when a fixed size is needed.
254
+
241
255
  ### Extra Styles Wrapper
242
256
 
243
257
  The `ExtraStyles` prop accepts a component rendered between the typography wrapper and the markdown content. Useful for injecting additional CSS scope or theme providers: