markstream-react 0.0.56-beta.2 → 0.0.56-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 +47 -1
- package/dist/Tooltip-DygdyBfV.js +205 -0
- package/dist/codeBlockExtraProps-B08PlQGP.js +8 -0
- package/dist/{index-D0DspXy9.js → index-BQgUvQrW.js} +41 -41
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/languageIconExtended-DRR7G3nV.js +1 -0
- package/dist/markstream-react.css +1 -1
- package/dist/next.d.ts +2 -0
- package/dist/next.js +1 -1
- package/dist/server.d.ts +3 -1
- 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 +14 -0
- package/dist/types/hooks/useSmoothMarkdownStream.d.ts +18 -1
- package/dist/types/server-renderer/index.d.ts +1 -1
- package/dist/types/types/component-props.d.ts +2 -0
- package/package.json +7 -3
- package/dist/Tooltip-Bx_S1cbE.js +0 -207
- package/dist/codeBlockExtraProps-RaPzFq78.js +0 -3
- package/dist/languageIconExtended-B1nZmPQn.js +0 -1
package/README.md
CHANGED
|
@@ -128,7 +128,8 @@ export default function Page() {
|
|
|
128
128
|
| Feature | Package |
|
|
129
129
|
| --- | --- |
|
|
130
130
|
| Shiki code blocks | `stream-markdown` |
|
|
131
|
-
|
|
|
131
|
+
| Enhanced code blocks (recommended) | `stream-diffs` |
|
|
132
|
+
| Monaco editor code blocks | `stream-monaco` (fallback) |
|
|
132
133
|
| Mermaid diagrams | `mermaid` |
|
|
133
134
|
| KaTeX math | `katex` |
|
|
134
135
|
| D2 diagrams | `@terrastruct/d2` |
|
|
@@ -140,6 +141,51 @@ KaTeX still needs its CSS in your app when math rendering is enabled:
|
|
|
140
141
|
import 'katex/dist/katex.min.css'
|
|
141
142
|
```
|
|
142
143
|
|
|
144
|
+
## Enhanced Code Blocks
|
|
145
|
+
|
|
146
|
+
Code blocks use a dual-runtime loader across all Markstream packages: `stream-diffs` is preferred (smaller, no `monaco-editor`), `stream-monaco` is the automatic fallback, and a plain `<pre>` is rendered when neither is installed.
|
|
147
|
+
|
|
148
|
+
Install the recommended runtime:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pnpm add stream-diffs
|
|
152
|
+
# or, to keep the legacy Monaco surface as the fallback:
|
|
153
|
+
pnpm add stream-monaco
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`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
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import type { CodeBlockMonacoOptions } from 'markstream-react'
|
|
160
|
+
import { CodeBlockNode } from 'markstream-react'
|
|
161
|
+
|
|
162
|
+
const node = {
|
|
163
|
+
type: 'code_block',
|
|
164
|
+
language: 'ts',
|
|
165
|
+
code: 'const answer = 42',
|
|
166
|
+
raw: 'const answer = 42',
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// fontSize / lineHeight / tabSize also drive the streaming <pre> fallback so
|
|
170
|
+
// the enhanced surface swaps in without a visual jump.
|
|
171
|
+
const monacoOptions: CodeBlockMonacoOptions = {
|
|
172
|
+
fontSize: 14,
|
|
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,
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function CodeBlock() {
|
|
183
|
+
return <CodeBlockNode node={node} monacoOptions={monacoOptions} isDark />
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Component-level options: `isDark` / `darkTheme` / `lightTheme` for theming, `showLineNumbers`, `showHeader`, and `stream` / `loading` for streaming states. `monacoOptions` also covers diff blocks (`renderSideBySide`, `diffHunkActionsOnHover`, `onDiffHunkAction`, `diffHideUnchangedRegions`).
|
|
188
|
+
|
|
143
189
|
## Tailwind
|
|
144
190
|
|
|
145
191
|
Non-Tailwind projects should import the precompiled CSS:
|