markstream-react 0.0.56-beta.4 → 0.1.0-beta.3
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 +17 -20
- package/dist/Tooltip-Bs7FyYvs.js +189 -0
- package/dist/codeBlockExtraProps-C_3No_qp.js +8 -0
- package/dist/{index-BQgUvQrW.js → index-uI922Np4.js} +46 -44
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/markstream-react.css +1 -1
- package/dist/next.d.ts +67 -126
- package/dist/next.js +1 -1
- package/dist/server.d.ts +66 -122
- package/dist/server.js +1 -1
- package/dist/tailwind.cjs +1 -1
- package/dist/tailwind.js +1 -1
- package/dist/types/components/CodeBlockNode/PreCodeNode.d.ts +1 -1
- package/dist/types/components/CodeBlockNode/codeTypography.d.ts +4 -3
- package/dist/types/components/CodeBlockNode/streamDiffs.d.ts +2 -0
- package/dist/types/components/NodeRenderer/preloadStreamDiffs.d.ts +1 -0
- package/dist/types/index.d.ts +1 -3
- package/dist/types/next.d.ts +0 -5
- package/dist/types/server-renderer/index.d.ts +0 -2
- package/dist/types/server.d.ts +0 -2
- package/dist/types/types/component-props.d.ts +53 -66
- package/dist/types/types.d.ts +13 -24
- package/dist/types/utils/languageIcon.d.ts +1 -1
- package/package.json +20 -30
- package/dist/Tooltip-DygdyBfV.js +0 -205
- package/dist/codeBlockExtraProps-B08PlQGP.js +0 -8
- package/dist/types/components/CodeBlockNode/monaco.d.ts +0 -1
- package/dist/types/components/CodeBlockNode/monacoThemeRegistry.d.ts +0 -7
- package/dist/types/components/CodeBlockNode/monacoThemeScheduler.d.ts +0 -4
- package/dist/types/components/MarkdownCodeBlockNode/MarkdownCodeBlockNode.d.ts +0 -34
- package/dist/types/components/NodeRenderer/preloadMonaco.d.ts +0 -1
package/README.md
CHANGED
|
@@ -4,6 +4,14 @@ React/Next.js streaming Markdown renderer for AI chat, SSE/WebSocket output, lon
|
|
|
4
4
|
|
|
5
5
|
`markstream-react` is the React renderer in the Markstream family. It renders raw Markdown strings with `content`, and it can also accept pre-parsed `nodes` when a worker or store already owns parsing.
|
|
6
6
|
|
|
7
|
+
The coordinated 2.0 family beta will use `markstream-react@next`. Before installing, verify that `npm view markstream-react@next version` reports `0.1.0-beta.1`. It removes the Monaco and Shiki code-block APIs in favor of `stream-diffs`; read the [coordinated 2.0 family migration guide](https://markstream.simonhe.me/guide/migration-2-0) before upgrading.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add markstream-react@next stream-diffs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This beta requires both `react` and `react-dom` 18 or newer.
|
|
14
|
+
|
|
7
15
|
## Install
|
|
8
16
|
|
|
9
17
|
```bash
|
|
@@ -127,9 +135,7 @@ export default function Page() {
|
|
|
127
135
|
|
|
128
136
|
| Feature | Package |
|
|
129
137
|
| --- | --- |
|
|
130
|
-
| Shiki code blocks | `stream-markdown` |
|
|
131
138
|
| Enhanced code blocks (recommended) | `stream-diffs` |
|
|
132
|
-
| Monaco editor code blocks | `stream-monaco` (fallback) |
|
|
133
139
|
| Mermaid diagrams | `mermaid` |
|
|
134
140
|
| KaTeX math | `katex` |
|
|
135
141
|
| D2 diagrams | `@terrastruct/d2` |
|
|
@@ -143,20 +149,18 @@ import 'katex/dist/katex.min.css'
|
|
|
143
149
|
|
|
144
150
|
## Enhanced Code Blocks
|
|
145
151
|
|
|
146
|
-
|
|
152
|
+
`stream-diffs` powers enhanced code blocks across all Markstream packages (smaller runtime, no `monaco-editor`); a plain `<pre>` is rendered when it is not installed.
|
|
147
153
|
|
|
148
|
-
Install the
|
|
154
|
+
Install the runtime:
|
|
149
155
|
|
|
150
156
|
```bash
|
|
151
157
|
pnpm add stream-diffs
|
|
152
|
-
# or, to keep the legacy Monaco surface as the fallback:
|
|
153
|
-
pnpm add stream-monaco
|
|
154
158
|
```
|
|
155
159
|
|
|
156
160
|
`CodeBlockNode` renders a single code block with the header, toolbar, and a `stream-diffs` File / FileDiff surface. Use it directly for one-off blocks, or let `MarkdownRender` resolve it automatically for code blocks in your Markdown:
|
|
157
161
|
|
|
158
162
|
```tsx
|
|
159
|
-
import type {
|
|
163
|
+
import type { CodeBlockOptions } from 'markstream-react'
|
|
160
164
|
import { CodeBlockNode } from 'markstream-react'
|
|
161
165
|
|
|
162
166
|
const node = {
|
|
@@ -166,25 +170,18 @@ const node = {
|
|
|
166
170
|
raw: 'const answer = 42',
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
lineHeight: 21,
|
|
174
|
-
tabSize: 4,
|
|
175
|
-
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
|
176
|
-
wordWrap: 'off',
|
|
177
|
-
theme: 'vitesse-dark',
|
|
178
|
-
renderSideBySide: true,
|
|
179
|
-
MAX_HEIGHT: 640,
|
|
173
|
+
const codeBlockOptions: CodeBlockOptions = {
|
|
174
|
+
overflow: 'wrap',
|
|
175
|
+
diffStyle: 'unified',
|
|
176
|
+
enableLineSelection: true,
|
|
180
177
|
}
|
|
181
178
|
|
|
182
179
|
export function CodeBlock() {
|
|
183
|
-
return <CodeBlockNode node={node}
|
|
180
|
+
return <CodeBlockNode node={node} codeBlockOptions={codeBlockOptions} isDark showHeader />
|
|
184
181
|
}
|
|
185
182
|
```
|
|
186
183
|
|
|
187
|
-
|
|
184
|
+
Direct `CodeBlockNode` and top-level `MarkdownRender` both accept `codeBlockOptions`. The shared `CodeBlockOptions` type covers host-managed typography/layout plus supported File/FileDiff, interaction, annotation, and callback fields; `maxHeight` and the single symmetric `padding` value use numeric CSS pixels. Keep header/toolbar controls in `codeBlockProps`. Theme values are registered names: use `darkTheme` / `lightTheme` for the active names and `themes` for the `[dark, light]` pair to preload. An old Monaco JSON theme is not accepted directly: first convert it to a Shiki `ThemeRegistration`, then call `registerCustomTheme(name, loader)` from `stream-diffs/pierre`; see the [coordinated 2.0 family migration guide](https://markstream.simonhe.me/guide/migration-2-0).
|
|
188
185
|
|
|
189
186
|
## Tailwind
|
|
190
187
|
|