Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #1104 on branch v3-dev (Fix rendering of code blocks in JupyterLab 4.3.0+) #1105

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/jupyter-ai/src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ export function Chat(props: ChatProps): JSX.Element {
<TelemetryContextProvider telemetryHandler={props.telemetryHandler}>
<UserContextProvider userManager={props.userManager}>
<Box
// Add .jp-ThemedContainer for CSS compatibility in both JL <4.3.0 and >=4.3.0.
// See: https://jupyterlab.readthedocs.io/en/latest/extension/extension_migration.html#css-styling
className="jp-ThemedContainer"
// root box should not include padding as it offsets the vertical
// scrollbar to the left
sx={{
Expand Down
17 changes: 13 additions & 4 deletions packages/jupyter-ai/style/rendermime-markdown.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
.jp-ai-rendermime-markdown .jp-RenderedHTMLCommon {
/*
*
* Selectors must be nested in `.jp-ThemedContainer` to have a higher
* specificity than selectors in rules provided by JupyterLab.
*
* See: https://jupyterlab.readthedocs.io/en/latest/extension/extension_migration.html#css-styling
* See also: https://github.com/jupyterlab/jupyter-ai/issues/1090
*/

.jp-ThemedContainer .jp-ai-rendermime-markdown .jp-RenderedHTMLCommon {
padding-right: 0;
}

.jp-ai-rendermime-markdown pre {
.jp-ThemedContainer .jp-ai-rendermime-markdown pre {
background-color: var(--jp-cell-editor-background);
overflow-x: auto;
white-space: pre;
Expand All @@ -11,12 +20,12 @@
border: var(--jp-border-width) solid var(--jp-cell-editor-border-color);
}

.jp-ai-rendermime-markdown pre > code {
.jp-ThemedContainer .jp-ai-rendermime-markdown pre > code {
background-color: inherit;
overflow-x: inherit;
white-space: inherit;
}

.jp-ai-rendermime-markdown mjx-container {
.jp-ThemedContainer .jp-ai-rendermime-markdown mjx-container {
font-size: 119%;
}
Loading