Skip to content

Commit 9d524d6

Browse files
Export components from @jupyter/chat (#132)
* Rename RendermimeMarkdown to MarkdownRenderer * Export the chat components from @jupyter/chat * Remove unused component * Automatic application of license header * typo --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent af64776 commit 9d524d6

File tree

13 files changed

+68
-135
lines changed

13 files changed

+68
-135
lines changed

packages/jupyter-chat/src/components/chat-messages.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import clsx from 'clsx';
1717
import React, { useEffect, useState, useRef, forwardRef } from 'react';
1818

1919
import { ChatInput } from './chat-input';
20-
import { RendermimeMarkdown } from './rendermime-markdown';
20+
import { MarkdownRenderer } from './markdown-renderer';
2121
import { ScrollContainer } from './scroll-container';
2222
import { IChatModel } from '../model';
2323
import { IChatMessage, IUser } from '../types';
@@ -391,7 +391,7 @@ export const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>(
391391
hideIncludeSelection={true}
392392
/>
393393
) : (
394-
<RendermimeMarkdown
394+
<MarkdownRenderer
395395
rmRegistry={rmRegistry}
396396
markdownStr={message.body}
397397
model={model}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright (c) Jupyter Development Team.
3+
* Distributed under the terms of the Modified BSD License.
4+
*/
5+
6+
export * from './code-toolbar';
7+
export * from './copy-button';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) Jupyter Development Team.
3+
* Distributed under the terms of the Modified BSD License.
4+
*/
5+
6+
export * from './chat';
7+
export * from './chat-input';
8+
export * from './chat-messages';
9+
export * from './code-blocks';
10+
export * from './input';
11+
export * from './jl-theme-provider';
12+
export * from './markdown-renderer';
13+
export * from './mui-extras';
14+
export * from './scroll-container';
15+
export * from './toolbar';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright (c) Jupyter Development Team.
3+
* Distributed under the terms of the Modified BSD License.
4+
*/
5+
6+
export * from './cancel-button';
7+
export * from './send-button';

packages/jupyter-chat/src/components/rendermime-markdown.tsx renamed to packages/jupyter-chat/src/components/markdown-renderer.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { MessageToolbar } from './toolbar';
1313
import { IChatModel } from '../model';
1414

1515
const MD_MIME_TYPE = 'text/markdown';
16-
const RENDERMIME_MD_CLASS = 'jp-chat-rendermime-markdown';
16+
const MD_RENDERED_CLASS = 'jp-chat-rendered-markdown';
1717

18-
type RendermimeMarkdownProps = {
18+
type MarkdownRendererProps = {
1919
/**
2020
* The string to render.
2121
*/
@@ -62,7 +62,7 @@ function escapeLatexDelimiters(text: string) {
6262
.replace(/\\\]/g, '\\\\]');
6363
}
6464

65-
function RendermimeMarkdownBase(props: RendermimeMarkdownProps): JSX.Element {
65+
function MarkdownRendererBase(props: MarkdownRendererProps): JSX.Element {
6666
const appendContent = props.appendContent || false;
6767
const [renderedContent, setRenderedContent] = useState<HTMLElement | null>(
6868
null
@@ -122,7 +122,7 @@ function RendermimeMarkdownBase(props: RendermimeMarkdownProps): JSX.Element {
122122
}, [props.markdownStr, props.rmRegistry]);
123123

124124
return (
125-
<div className={RENDERMIME_MD_CLASS}>
125+
<div className={MD_RENDERED_CLASS}>
126126
{renderedContent &&
127127
(appendContent ? (
128128
<div ref={node => node && node.appendChild(renderedContent)} />
@@ -146,4 +146,4 @@ function RendermimeMarkdownBase(props: RendermimeMarkdownProps): JSX.Element {
146146
);
147147
}
148148

149-
export const RendermimeMarkdown = React.memo(RendermimeMarkdownBase);
149+
export const MarkdownRenderer = React.memo(MarkdownRendererBase);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright (c) Jupyter Development Team.
3+
* Distributed under the terms of the Modified BSD License.
4+
*/
5+
6+
export * from './contrasting-tooltip';
7+
export * from './tooltipped-button';
8+
export * from './tooltipped-icon-button';

packages/jupyter-chat/src/components/mui-extras/stacking-alert.tsx

Lines changed: 0 additions & 105 deletions
This file was deleted.

packages/jupyter-chat/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
export * from './active-cell-manager';
7+
export * from './components';
78
export * from './icons';
89
export * from './model';
910
export * from './registry';

packages/jupyter-chat/style/chat.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
padding: 0 1em;
1515
}
1616

17-
.jp-chat-rendermime-markdown {
17+
.jp-chat-rendered-markdown {
1818
position: relative;
1919
}
2020

@@ -26,11 +26,11 @@
2626
* See: https://jupyterlab.readthedocs.io/en/latest/extension/extension_migration.html#css-styling
2727
* See also: https://github.com/jupyterlab/jupyter-ai/issues/1090
2828
*/
29-
.jp-ThemedContainer .jp-chat-rendermime-markdown .jp-RenderedHTMLCommon {
29+
.jp-ThemedContainer .jp-chat-rendered-markdown .jp-RenderedHTMLCommon {
3030
padding-right: 0;
3131
}
3232

33-
.jp-ThemedContainer .jp-chat-rendermime-markdown pre {
33+
.jp-ThemedContainer .jp-chat-rendered-markdown pre {
3434
background-color: var(--jp-cell-editor-background);
3535
overflow-x: auto;
3636
white-space: pre;
@@ -39,13 +39,13 @@
3939
border: var(--jp-border-width) solid var(--jp-cell-editor-border-color);
4040
}
4141

42-
.jp-ThemedContainer .jp-chat-rendermime-markdown pre > code {
42+
.jp-ThemedContainer .jp-chat-rendered-markdown pre > code {
4343
background-color: inherit;
4444
overflow-x: inherit;
4545
white-space: inherit;
4646
}
4747

48-
.jp-ThemedContainer .jp-chat-rendermime-markdown mjx-container {
48+
.jp-ThemedContainer .jp-chat-rendered-markdown mjx-container {
4949
font-size: 119%;
5050
}
5151

@@ -58,7 +58,7 @@
5858
color: var(--jp-ui-font-color3);
5959
}
6060

61-
.jp-chat-rendermime-markdown:hover .jp-chat-toolbar {
61+
.jp-chat-rendered-markdown:hover .jp-chat-toolbar {
6262
display: inherit;
6363
}
6464

ui-tests/tests/chat-file.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ test.describe('#outofband', () => {
215215
const updatedContent = 'Content updated';
216216
const chatPanel = await openChat(page, FILENAME);
217217
const messageContent = chatPanel
218-
.locator('.jp-chat-messages-container .jp-chat-rendermime-markdown')
218+
.locator('.jp-chat-messages-container .jp-chat-rendered-markdown')
219219
.first();
220220
const newMsg = { ...msg, body: updatedContent };
221221
const newContent = {
@@ -261,14 +261,14 @@ test.describe('#outofband', () => {
261261

262262
await expect(messages).toHaveCount(2);
263263
await expect(
264-
messages.last().locator('.jp-chat-rendermime-markdown')
264+
messages.last().locator('.jp-chat-rendered-markdown')
265265
).toHaveText(newMsgContent);
266266
});
267267

268268
test('should delete a message from file', async ({ page }) => {
269269
const chatPanel = await openChat(page, FILENAME);
270270
const messageContent = chatPanel
271-
.locator('.jp-chat-messages-container .jp-chat-rendermime-markdown')
271+
.locator('.jp-chat-messages-container .jp-chat-rendered-markdown')
272272
.first();
273273
const newContent = {
274274
messages: [],

0 commit comments

Comments
 (0)