Skip to content

Commit 3290144

Browse files
committed
Updates for JupyterLab 1.0-prelease.
1 parent 1fb12c1 commit 3290144

File tree

5 files changed

+83
-65
lines changed

5 files changed

+83
-65
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ For more advanced usage documentation, see [here](docs/advanced.md).
1717

1818
## Requirements
1919

20-
- JupyterLab 0.35
20+
- JupyterLab 1.0
2121
- Python >= 3.6
2222
- An application that can compile `.tex` files to PDF (e.g., `pdflatex`, `xelatex`; use `pdflatex.exe` on Windows with MiKTeX). This application must be available as a command in the same environment as the notebook server.
2323
- An application that can process `.bib` files for producing bibliographies. As with the LaTeX command, this must be available in the same environment as the notebook server.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jupyterlab/latex",
3-
"version": "0.6.1",
3+
"version": "1.0.0-pre",
44
"description": "JupyterLab extension for running LaTeX",
55
"author": "M Pacer & Ian Rose",
66
"files": [
@@ -34,14 +34,14 @@
3434
"watch": "tsc -w"
3535
},
3636
"dependencies": {
37-
"@jupyterlab/application": "^0.19.1",
38-
"@jupyterlab/apputils": "^0.19.1",
39-
"@jupyterlab/codeeditor": "^0.19.1",
40-
"@jupyterlab/coreutils": "^2.2.1",
41-
"@jupyterlab/docmanager": "^0.19.1",
42-
"@jupyterlab/docregistry": "^0.19.1",
43-
"@jupyterlab/fileeditor": "^0.19.1",
44-
"@jupyterlab/services": "^3.2.1",
37+
"@jupyterlab/application": "^1.0.0-alpha.3",
38+
"@jupyterlab/apputils": "^1.0.0-alpha.3",
39+
"@jupyterlab/codeeditor": "^1.0.0-alpha.3",
40+
"@jupyterlab/coreutils": "^3.0.0-alpha.3",
41+
"@jupyterlab/docmanager": "^1.0.0-alpha.3",
42+
"@jupyterlab/docregistry": "^1.0.0-alpha.3",
43+
"@jupyterlab/fileeditor": "^1.0.0-alpha.3",
44+
"@jupyterlab/services": "^4.0.0-alpha.3",
4545
"@phosphor/coreutils": "^1.3.0",
4646
"@phosphor/disposable": "^1.1.2",
4747
"@phosphor/domutils": "^1.1.2",

src/index.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import {
5+
ILabShell,
56
ILayoutRestorer,
6-
JupyterLab,
7-
JupyterLabPlugin
7+
JupyterFrontEnd,
8+
JupyterFrontEndPlugin
89
} from '@jupyterlab/application';
910

1011
import {
@@ -87,13 +88,14 @@ type ISynctexViewOptions = CodeEditor.IPosition;
8788
type ISynctexEditOptions = PDFJSViewer.IPosition;
8889

8990
/**
90-
* The JupyterLab plugin for the LaTeX extension.
91+
* The JupyterFrontEnd plugin for the LaTeX extension.
9192
*/
92-
const latexPlugin: JupyterLabPlugin<void> = {
93+
const latexPlugin: JupyterFrontEndPlugin<void> = {
9394
id: latexPluginId,
9495
requires: [
9596
IDocumentManager,
9697
IEditorTracker,
98+
ILabShell,
9799
ILayoutRestorer,
98100
IPDFJSTracker,
99101
ISettingRegistry,
@@ -199,9 +201,10 @@ function synctexViewRequest(
199201
* Activate the file browser.
200202
*/
201203
function activateLatexPlugin(
202-
app: JupyterLab,
204+
app: JupyterFrontEnd,
203205
manager: IDocumentManager,
204206
editorTracker: IEditorTracker,
207+
shell: ILabShell,
205208
restorer: ILayoutRestorer,
206209
pdfTracker: IPDFJSTracker,
207210
settingRegistry: ISettingRegistry,
@@ -293,7 +296,7 @@ function activateLatexPlugin(
293296
errorPanel = null;
294297
});
295298
// Add the error panel to the main area.
296-
app.shell.addToMainArea(errorPanel, {
299+
shell.add(errorPanel, 'main', {
297300
ref: widget.id,
298301
mode: 'split-bottom'
299302
});
@@ -330,9 +333,9 @@ function activateLatexPlugin(
330333
// Run an initial latexRequest so that the appropriate files exist,
331334
// then open them.
332335
onFileChanged().then(() => {
333-
if (!errorPanel) {
334-
findOpenOrRevealPDF();
335-
}
336+
if (!errorPanel) {
337+
findOpenOrRevealPDF();
338+
}
336339
});
337340

338341
const cleanupPreviews = () => {
@@ -427,7 +430,7 @@ function activateLatexPlugin(
427430
* Add commands, keyboard shortcuts, and menu items for SyncTeX-related things.
428431
*/
429432
function addSynctexCommands(
430-
app: JupyterLab,
433+
app: JupyterFrontEnd,
431434
editorTracker: IEditorTracker,
432435
pdfTracker: IPDFJSTracker,
433436
serverSettings: ServerConnection.ISettings
@@ -578,7 +581,7 @@ const FACTORY = 'PDFJS';
578581
/**
579582
* The pdf file handler extension.
580583
*/
581-
const pdfjsPlugin: JupyterLabPlugin<IPDFJSTracker> = {
584+
const pdfjsPlugin: JupyterFrontEndPlugin<IPDFJSTracker> = {
582585
activate: activatePDFJS,
583586
id: '@jupyterlab/pdfjs-extension:plugin',
584587
requires: [ILayoutRestorer],
@@ -587,7 +590,7 @@ const pdfjsPlugin: JupyterLabPlugin<IPDFJSTracker> = {
587590
};
588591

589592
function activatePDFJS(
590-
app: JupyterLab,
593+
app: JupyterFrontEnd,
591594
restorer: ILayoutRestorer
592595
): IPDFJSTracker {
593596
const namespace = 'pdfjs-widget';
@@ -631,7 +634,7 @@ function activatePDFJS(
631634
/**
632635
* Export the plugins as default.
633636
*/
634-
const plugins: JupyterLabPlugin<any>[] = [latexPlugin, pdfjsPlugin];
637+
const plugins: JupyterFrontEndPlugin<any>[] = [latexPlugin, pdfjsPlugin];
635638
export default plugins;
636639

637640
/**

src/pagenumber.tsx

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,15 @@
1-
import { ReactElementWidget } from '@jupyterlab/apputils';
1+
import { ReactWidget } from '@jupyterlab/apputils';
22

33
import * as React from 'react';
44

5-
/**
6-
* React properties for page number component.
7-
*/
8-
interface IProps {
9-
/**
10-
* The PDF viewer.
11-
*/
12-
viewer: any;
13-
}
14-
15-
/**
16-
* React state for page number component.
17-
*/
18-
interface IState {
19-
/**
20-
* The label of the current page.
21-
*/
22-
currentPageLabel?: string;
23-
24-
/**
25-
* The index of the current page in the document.
26-
*/
27-
currentPageNumber: number;
28-
29-
/**
30-
* The number of pages of the document.
31-
*/
32-
pagesCount: number;
33-
34-
/**
35-
* The string inserted by user in the input element.
36-
*/
37-
userInput: string | null;
38-
}
39-
405
/**
416
* Page number React component.
427
*/
43-
class PageNumberComponent extends React.Component<IProps, IState> {
44-
public state: IState = {
8+
class PageNumberComponent extends React.Component<
9+
PageNumberComponent.IProps,
10+
PageNumberComponent.IState
11+
> {
12+
public state: PageNumberComponent.IState = {
4513
currentPageNumber: 0,
4614
pagesCount: 0,
4715
userInput: null
@@ -163,11 +131,58 @@ class PageNumberComponent extends React.Component<IProps, IState> {
163131
}
164132
}
165133

134+
/**
135+
* A namespace for PageNumberComponent statics.
136+
*/
137+
export namespace PageNumberComponent {
138+
/**
139+
* React properties for page number component.
140+
*/
141+
export interface IProps {
142+
/**
143+
* The PDF viewer.
144+
*/
145+
viewer: any;
146+
}
147+
148+
/**
149+
* React state for page number component.
150+
*/
151+
export interface IState {
152+
/**
153+
* The label of the current page.
154+
*/
155+
currentPageLabel?: string;
156+
157+
/**
158+
* The index of the current page in the document.
159+
*/
160+
currentPageNumber: number;
161+
162+
/**
163+
* The number of pages of the document.
164+
*/
165+
pagesCount: number;
166+
167+
/**
168+
* The string inserted by user in the input element.
169+
*/
170+
userInput: string | null;
171+
}
172+
}
173+
166174
/**
167175
* Phosphor Widget version of PageNumberComponent.
168176
*/
169-
export class PageNumberWidget extends ReactElementWidget {
170-
constructor(props: IProps) {
171-
super(<PageNumberComponent {...props} />);
177+
export class PageNumberWidget extends ReactWidget {
178+
constructor(props: PageNumberComponent.IProps) {
179+
super();
180+
this._props = props;
172181
}
182+
183+
render() {
184+
return <PageNumberComponent {...this._props} />;
185+
}
186+
187+
private _props: PageNumberComponent.IProps;
173188
}

tslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"check-whitespace"
6161
],
6262
"one-variable-per-declaration": [true, "ignore-for-loop"],
63-
"quotemark": [true, "single", "avoid-escape"],
63+
"quotemark": [true, "single", "avoid-escape", "jsx-double"],
6464
"radix": true,
6565
"semicolon": [true, "always", "ignore-bound-class-methods"],
6666
"switch-default": true,

0 commit comments

Comments
 (0)