@copilotz/chat-ui 0.1.39 → 0.2.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 +89 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,6 +202,78 @@ import { ChatUI, chatConfigPresets } from '@copilotz/chat-ui';
|
|
|
202
202
|
/>
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
### Markdown Extensions
|
|
206
|
+
|
|
207
|
+
By default, `@copilotz/chat-ui` renders messages with:
|
|
208
|
+
|
|
209
|
+
- `remark-gfm`
|
|
210
|
+
- syntax highlighting for non-streaming code blocks
|
|
211
|
+
- the built-in markdown component overrides used by the chat UI
|
|
212
|
+
|
|
213
|
+
If you need more control, you can extend the markdown pipeline through `config.markdown`.
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import type { Components } from 'react-markdown';
|
|
217
|
+
|
|
218
|
+
const markdownComponents: Components = {
|
|
219
|
+
code: MyCustomCodeBlock,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
<ChatUI
|
|
223
|
+
config={{
|
|
224
|
+
markdown: {
|
|
225
|
+
remarkPlugins: [myRemarkPlugin],
|
|
226
|
+
rehypePlugins: [myRehypePlugin],
|
|
227
|
+
components: markdownComponents,
|
|
228
|
+
},
|
|
229
|
+
}}
|
|
230
|
+
/>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Notes:
|
|
234
|
+
|
|
235
|
+
- `remarkPlugins` and `rehypePlugins` are appended to the built-in defaults.
|
|
236
|
+
- `components` are merged with the built-in markdown component map.
|
|
237
|
+
- This is the recommended way to add Mermaid, custom code blocks, callouts, or project-specific markdown behavior without increasing the core `chat-ui` bundle.
|
|
238
|
+
|
|
239
|
+
Example: Mermaid via a custom `code` renderer
|
|
240
|
+
|
|
241
|
+
````tsx
|
|
242
|
+
function MermaidCodeBlock({ className, children, inline, ...props }) {
|
|
243
|
+
const isMermaid = !inline && /\blanguage-mermaid\b/.test(className || '');
|
|
244
|
+
|
|
245
|
+
if (isMermaid) {
|
|
246
|
+
return <MyMermaidRenderer definition={String(children)} />;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return !inline ? (
|
|
250
|
+
<pre>
|
|
251
|
+
<code className={className} {...props}>
|
|
252
|
+
{children}
|
|
253
|
+
</code>
|
|
254
|
+
</pre>
|
|
255
|
+
) : (
|
|
256
|
+
<code {...props}>{children}</code>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
<ChatUI
|
|
261
|
+
config={{
|
|
262
|
+
markdown: {
|
|
263
|
+
components: {
|
|
264
|
+
code: MermaidCodeBlock,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
}}
|
|
268
|
+
/>
|
|
269
|
+
````
|
|
270
|
+
|
|
271
|
+
Recommended approach for Mermaid:
|
|
272
|
+
|
|
273
|
+
- keep Mermaid project-specific instead of bundling it into every `chat-ui` consumer
|
|
274
|
+
- lazy-load the Mermaid runtime inside your custom renderer
|
|
275
|
+
- render Mermaid only for completed code blocks, not for token-by-token streaming content
|
|
276
|
+
|
|
205
277
|
### Custom Right Sidebar
|
|
206
278
|
|
|
207
279
|
Add a custom component to the right sidebar (e.g., profile info, settings, context):
|
|
@@ -280,6 +352,23 @@ All user interactions are handled through callbacks. This keeps the component pu
|
|
|
280
352
|
| `onInitialInputConsumed` | `() => void` | Called when initial input is modified/sent |
|
|
281
353
|
| `className` | `string` | Additional CSS classes |
|
|
282
354
|
|
|
355
|
+
### ChatConfig Markdown
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
interface ChatMarkdownConfig {
|
|
359
|
+
remarkPlugins?: ReactMarkdownOptions['remarkPlugins'];
|
|
360
|
+
rehypePlugins?: ReactMarkdownOptions['rehypePlugins'];
|
|
361
|
+
components?: Components;
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
interface ChatConfig {
|
|
367
|
+
// ...
|
|
368
|
+
markdown?: ChatMarkdownConfig;
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
283
372
|
### ChatMessage
|
|
284
373
|
|
|
285
374
|
```typescript
|
package/dist/index.cjs
CHANGED
|
@@ -5351,7 +5351,7 @@ var ChatUI = ({
|
|
|
5351
5351
|
children: state.showSidebar && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5352
5352
|
"div",
|
|
5353
5353
|
{
|
|
5354
|
-
className: "
|
|
5354
|
+
className: "h-full overflow-hidden border-l bg-background animate-in slide-in-from-right-4 duration-300",
|
|
5355
5355
|
style: { width: config.customComponent.panelWidth ?? 320 },
|
|
5356
5356
|
children: renderCustomComponent()
|
|
5357
5357
|
}
|
|
@@ -5374,7 +5374,7 @@ var ChatUI = ({
|
|
|
5374
5374
|
{
|
|
5375
5375
|
className: `absolute top-0 right-0 h-full w-full bg-background transform-gpu transition-transform duration-200 ease-out ${isCustomVisible ? "translate-x-0" : "translate-x-full"}`,
|
|
5376
5376
|
style: { willChange: "transform" },
|
|
5377
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-full
|
|
5377
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-full overflow-hidden", children: renderCustomComponent() })
|
|
5378
5378
|
}
|
|
5379
5379
|
)
|
|
5380
5380
|
] }),
|