Skip to content

Commit

Permalink
Backport PR jupyterlab#15171: Restore horizontal scrolling of outputs…
Browse files Browse the repository at this point in the history
… for Firefox
  • Loading branch information
fcollonval authored and meeseeksmachine committed Oct 11, 2023
1 parent 6d54faf commit b9b77f8
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 22 deletions.
3 changes: 3 additions & 0 deletions galata/test/jupyterlab/notebook-mobile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ test.describe('Notebook Layout on Mobile', () => {

test('Execute code cell', async ({ page }) => {
await page.sidebar.close('left');
// TODO: calling `setCell` just once leads to very flaky test
// See https://github.com/jupyterlab/jupyterlab/issues/15252 for more information
await page.notebook.setCell(0, 'code', 'print("hello")');
await page.notebook.setCell(0, 'code', 'print("hello")');
await page.notebook.addCell('code', '2 * 3');
await page.notebook.runCellByCell();
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions galata/test/jupyterlab/print.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { expect, test } from '@jupyterlab/galata';
import * as path from 'path';

test.use({ autoGoto: false });

const fileName = 'simple_notebook.ipynb';

test.describe('Print layout', () => {
test('Notebook', async ({ page, tmpPath }) => {
await page.emulateMedia({ media: 'print' });
await page.contents.uploadFile(
path.resolve(__dirname, `./notebooks/${fileName}`),
`${tmpPath}/${fileName}`
);
await page.contents.uploadFile(
path.resolve(__dirname, './notebooks/WidgetArch.png'),
`${tmpPath}/WidgetArch.png`
);

await page.goto();

await page.notebook.openByPath(`${tmpPath}/${fileName}`);

await page.getByText('Python 3 (ipykernel) | Idle').waitFor();

await page.notebook.run();

let printedNotebookURL = '';
await Promise.all([
page.waitForRequest(
async request => {
const url = request.url();
if (url.match(/\/nbconvert\//) !== null) {
printedNotebookURL = url;
return true;
}
return false;
},
{ timeout: 1000 }
),
page.keyboard.press('Control+P')
]);

const newPage = await page.context().newPage();

await newPage.goto(printedNotebookURL, { waitUntil: 'networkidle' });

// Wait until MathJax loading message disappears
const mathJaxMessage = newPage.locator('#MathJax_Message');
await expect(mathJaxMessage).toHaveCount(1);
await mathJaxMessage.waitFor({ state: 'hidden' });

expect(await newPage.screenshot()).toMatchSnapshot('printed-notebook.png');
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 30 additions & 9 deletions packages/cells/style/inputarea.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@

/* All input areas */
.jp-InputArea {
display: table;
table-layout: fixed;
display: flex;
flex-direction: row;
width: 100%;
overflow: hidden;
}

.jp-InputArea-editor {
display: table-cell;
flex: 1 1 auto;
overflow: hidden;
vertical-align: top;

/* This is the non-active, default styling */
border: var(--jp-border-width) solid var(--jp-cell-editor-border-color);
Expand All @@ -27,8 +26,7 @@
}

.jp-InputPrompt {
display: table-cell;
vertical-align: top;
flex: 0 0 var(--jp-cell-prompt-width);
width: var(--jp-cell-prompt-width);
color: var(--jp-cell-inprompt-font-color);
font-family: var(--jp-cell-prompt-font-family);
Expand All @@ -52,17 +50,40 @@
user-select: none;
}

/*-----------------------------------------------------------------------------
| Print
|----------------------------------------------------------------------------*/
@media print {
.jp-InputArea {
display: table;
table-layout: fixed;
}

.jp-InputArea-editor {
display: table-cell;
vertical-align: top;
}

.jp-InputPrompt {
display: table-cell;
vertical-align: top;
}
}

/*-----------------------------------------------------------------------------
| Mobile
|----------------------------------------------------------------------------*/
@media only screen and (width <= 760px) {
.jp-InputArea {
flex-direction: column;
}

.jp-InputArea-editor {
display: table-row;
margin-left: var(--jp-notebook-padding);
margin-left: var(--jp-code-padding);
}

.jp-InputPrompt {
display: table-row;
flex: 0 0 auto;
text-align: left;
}
}
11 changes: 10 additions & 1 deletion packages/cells/style/widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
width: calc(
var(--jp-cell-prompt-width) - var(--jp-private-cell-scrolling-output-offset)
);
flex: 0 0
calc(
var(--jp-cell-prompt-width) -
var(--jp-private-cell-scrolling-output-offset)
);
}

.jp-CodeCell.jp-mod-outputsScrolled .jp-OutputArea-promptOverlay {
Expand All @@ -117,7 +122,7 @@
|----------------------------------------------------------------------------*/

.jp-MarkdownOutput {
display: table-cell;
flex: 1 1 auto;
width: 100%;
margin-top: 0;
margin-bottom: 0;
Expand Down Expand Up @@ -235,4 +240,8 @@ cell outputs.
.jp-Cell-outputWrapper {
display: block;
}

.jp-MarkdownOutput {
display: table-cell;
}
}
10 changes: 10 additions & 0 deletions packages/notebook/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

.jp-Notebook .jp-Cell .jp-InputPrompt {
cursor: move;
float: left;
}

/*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -458,3 +459,12 @@ div.jp-Cell-Placeholder-content-2 {
div.jp-Cell-Placeholder-content-3 {
top: 140px;
}

/*-----------------------------------------------------------------------------
| Printing
|----------------------------------------------------------------------------*/
@media print {
.jp-Notebook .jp-Cell .jp-InputPrompt {
float: none;
}
}
39 changes: 27 additions & 12 deletions packages/outputarea/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
}

.jp-OutputArea-child {
display: table;
table-layout: fixed;
display: flex;
flex-direction: row;
width: 100%;
overflow: hidden;
}

.jp-OutputPrompt {
width: var(--jp-cell-prompt-width);
flex: 0 0 var(--jp-cell-prompt-width);
color: var(--jp-cell-outprompt-font-color);
font-family: var(--jp-cell-prompt-font-family);
padding: var(--jp-code-padding);
Expand All @@ -43,13 +44,7 @@
user-select: none;
}

.jp-OutputArea-prompt {
display: table-cell;
vertical-align: top;
}

.jp-OutputArea-output {
display: table-cell;
width: 100%;
height: auto;
overflow: auto;
Expand Down Expand Up @@ -85,6 +80,11 @@
cursor: zoom-in;
}

.jp-OutputArea-child .jp-OutputArea-output {
flex-grow: 1;
flex-shrink: 1;
}

/**
* Isolated output.
*/
Expand Down Expand Up @@ -192,6 +192,7 @@ body.lm-mod-override-cursor .jp-OutputArea-output.jp-mod-isolated::before {
.jp-OutputArea-output.jp-OutputArea-executeResult {
margin-left: 0;
width: 100%;
flex: 1 1 auto;
}

/* Text output with the Out[] prompt needs a top padding to match the
Expand Down Expand Up @@ -261,22 +262,36 @@ body.lm-mod-override-cursor .jp-OutputArea-output.jp-mod-isolated::before {

@media print {
.jp-OutputArea-child {
display: table;
table-layout: fixed;
break-inside: avoid-page;
}

.jp-OutputArea-prompt {
display: table-cell;
vertical-align: top;
}

.jp-OutputArea-output {
display: table-cell;
}
}

/*-----------------------------------------------------------------------------
| Mobile
|----------------------------------------------------------------------------*/
@media only screen and (width <= 760px) {
.jp-OutputArea-child {
flex-direction: column;
}

.jp-OutputPrompt {
display: table-row;
flex: 0 0 auto;
text-align: left;
}

.jp-OutputArea-child .jp-OutputArea-output {
display: table-row;
margin-left: var(--jp-notebook-padding);
.jp-OutputArea-promptOverlay {
display: none;
}
}

Expand Down

0 comments on commit b9b77f8

Please sign in to comment.