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

Wait for mathjax message to disappear #70

Closed
wants to merge 5 commits into from
Closed
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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');
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 24 additions & 6 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,6 +50,26 @@
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
|----------------------------------------------------------------------------*/
Expand Down
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;
}
}
28 changes: 20 additions & 8 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 @@ -91,6 +86,11 @@
box-shadow: inset 0 0 1px var(--jp-inverse-layout-color0);
}

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

/**
* Isolated output.
*/
Expand Down Expand Up @@ -198,6 +198,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 @@ -267,8 +268,19 @@ 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;
}
}

/*-----------------------------------------------------------------------------
Expand Down
Loading