Skip to content

Commit

Permalink
Updates for JupyterLab 1.0-prelease.
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-r-rose committed Feb 7, 2019
1 parent 1fb12c1 commit 3290144
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 65 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ For more advanced usage documentation, see [here](docs/advanced.md).

## Requirements

- JupyterLab 0.35
- JupyterLab 1.0
- Python >= 3.6
- 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.
- 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.
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jupyterlab/latex",
"version": "0.6.1",
"version": "1.0.0-pre",
"description": "JupyterLab extension for running LaTeX",
"author": "M Pacer & Ian Rose",
"files": [
Expand Down Expand Up @@ -34,14 +34,14 @@
"watch": "tsc -w"
},
"dependencies": {
"@jupyterlab/application": "^0.19.1",
"@jupyterlab/apputils": "^0.19.1",
"@jupyterlab/codeeditor": "^0.19.1",
"@jupyterlab/coreutils": "^2.2.1",
"@jupyterlab/docmanager": "^0.19.1",
"@jupyterlab/docregistry": "^0.19.1",
"@jupyterlab/fileeditor": "^0.19.1",
"@jupyterlab/services": "^3.2.1",
"@jupyterlab/application": "^1.0.0-alpha.3",
"@jupyterlab/apputils": "^1.0.0-alpha.3",
"@jupyterlab/codeeditor": "^1.0.0-alpha.3",
"@jupyterlab/coreutils": "^3.0.0-alpha.3",
"@jupyterlab/docmanager": "^1.0.0-alpha.3",
"@jupyterlab/docregistry": "^1.0.0-alpha.3",
"@jupyterlab/fileeditor": "^1.0.0-alpha.3",
"@jupyterlab/services": "^4.0.0-alpha.3",
"@phosphor/coreutils": "^1.3.0",
"@phosphor/disposable": "^1.1.2",
"@phosphor/domutils": "^1.1.2",
Expand Down
29 changes: 16 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Distributed under the terms of the Modified BSD License.

import {
ILabShell,
ILayoutRestorer,
JupyterLab,
JupyterLabPlugin
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';

import {
Expand Down Expand Up @@ -87,13 +88,14 @@ type ISynctexViewOptions = CodeEditor.IPosition;
type ISynctexEditOptions = PDFJSViewer.IPosition;

/**
* The JupyterLab plugin for the LaTeX extension.
* The JupyterFrontEnd plugin for the LaTeX extension.
*/
const latexPlugin: JupyterLabPlugin<void> = {
const latexPlugin: JupyterFrontEndPlugin<void> = {
id: latexPluginId,
requires: [
IDocumentManager,
IEditorTracker,
ILabShell,
ILayoutRestorer,
IPDFJSTracker,
ISettingRegistry,
Expand Down Expand Up @@ -199,9 +201,10 @@ function synctexViewRequest(
* Activate the file browser.
*/
function activateLatexPlugin(
app: JupyterLab,
app: JupyterFrontEnd,
manager: IDocumentManager,
editorTracker: IEditorTracker,
shell: ILabShell,
restorer: ILayoutRestorer,
pdfTracker: IPDFJSTracker,
settingRegistry: ISettingRegistry,
Expand Down Expand Up @@ -293,7 +296,7 @@ function activateLatexPlugin(
errorPanel = null;
});
// Add the error panel to the main area.
app.shell.addToMainArea(errorPanel, {
shell.add(errorPanel, 'main', {
ref: widget.id,
mode: 'split-bottom'
});
Expand Down Expand Up @@ -330,9 +333,9 @@ function activateLatexPlugin(
// Run an initial latexRequest so that the appropriate files exist,
// then open them.
onFileChanged().then(() => {
if (!errorPanel) {
findOpenOrRevealPDF();
}
if (!errorPanel) {
findOpenOrRevealPDF();
}
});

const cleanupPreviews = () => {
Expand Down Expand Up @@ -427,7 +430,7 @@ function activateLatexPlugin(
* Add commands, keyboard shortcuts, and menu items for SyncTeX-related things.
*/
function addSynctexCommands(
app: JupyterLab,
app: JupyterFrontEnd,
editorTracker: IEditorTracker,
pdfTracker: IPDFJSTracker,
serverSettings: ServerConnection.ISettings
Expand Down Expand Up @@ -578,7 +581,7 @@ const FACTORY = 'PDFJS';
/**
* The pdf file handler extension.
*/
const pdfjsPlugin: JupyterLabPlugin<IPDFJSTracker> = {
const pdfjsPlugin: JupyterFrontEndPlugin<IPDFJSTracker> = {
activate: activatePDFJS,
id: '@jupyterlab/pdfjs-extension:plugin',
requires: [ILayoutRestorer],
Expand All @@ -587,7 +590,7 @@ const pdfjsPlugin: JupyterLabPlugin<IPDFJSTracker> = {
};

function activatePDFJS(
app: JupyterLab,
app: JupyterFrontEnd,
restorer: ILayoutRestorer
): IPDFJSTracker {
const namespace = 'pdfjs-widget';
Expand Down Expand Up @@ -631,7 +634,7 @@ function activatePDFJS(
/**
* Export the plugins as default.
*/
const plugins: JupyterLabPlugin<any>[] = [latexPlugin, pdfjsPlugin];
const plugins: JupyterFrontEndPlugin<any>[] = [latexPlugin, pdfjsPlugin];
export default plugins;

/**
Expand Down
97 changes: 56 additions & 41 deletions src/pagenumber.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,15 @@
import { ReactElementWidget } from '@jupyterlab/apputils';
import { ReactWidget } from '@jupyterlab/apputils';

import * as React from 'react';

/**
* React properties for page number component.
*/
interface IProps {
/**
* The PDF viewer.
*/
viewer: any;
}

/**
* React state for page number component.
*/
interface IState {
/**
* The label of the current page.
*/
currentPageLabel?: string;

/**
* The index of the current page in the document.
*/
currentPageNumber: number;

/**
* The number of pages of the document.
*/
pagesCount: number;

/**
* The string inserted by user in the input element.
*/
userInput: string | null;
}

/**
* Page number React component.
*/
class PageNumberComponent extends React.Component<IProps, IState> {
public state: IState = {
class PageNumberComponent extends React.Component<
PageNumberComponent.IProps,
PageNumberComponent.IState
> {
public state: PageNumberComponent.IState = {
currentPageNumber: 0,
pagesCount: 0,
userInput: null
Expand Down Expand Up @@ -163,11 +131,58 @@ class PageNumberComponent extends React.Component<IProps, IState> {
}
}

/**
* A namespace for PageNumberComponent statics.
*/
export namespace PageNumberComponent {
/**
* React properties for page number component.
*/
export interface IProps {
/**
* The PDF viewer.
*/
viewer: any;
}

/**
* React state for page number component.
*/
export interface IState {
/**
* The label of the current page.
*/
currentPageLabel?: string;

/**
* The index of the current page in the document.
*/
currentPageNumber: number;

/**
* The number of pages of the document.
*/
pagesCount: number;

/**
* The string inserted by user in the input element.
*/
userInput: string | null;
}
}

/**
* Phosphor Widget version of PageNumberComponent.
*/
export class PageNumberWidget extends ReactElementWidget {
constructor(props: IProps) {
super(<PageNumberComponent {...props} />);
export class PageNumberWidget extends ReactWidget {
constructor(props: PageNumberComponent.IProps) {
super();
this._props = props;
}

render() {
return <PageNumberComponent {...this._props} />;
}

private _props: PageNumberComponent.IProps;
}
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"check-whitespace"
],
"one-variable-per-declaration": [true, "ignore-for-loop"],
"quotemark": [true, "single", "avoid-escape"],
"quotemark": [true, "single", "avoid-escape", "jsx-double"],
"radix": true,
"semicolon": [true, "always", "ignore-bound-class-methods"],
"switch-default": true,
Expand Down

0 comments on commit 3290144

Please sign in to comment.