Commit 29634d18 authored by Phil Jones's avatar Phil Jones

First properly working state.

Now some finesse syntax for codemirror just needs to be written.
parent fb7e3107
......@@ -7,15 +7,12 @@ import {
} from '@jupyterlab/notebook';
import {
CodeCell
Cell, CodeCell
} from '@jupyterlab/cells';
import './codemirror-finesse';
/**
* The plugin registration information.
*/
const plugin: JupyterFrontEndPlugin<void> = {
activate,
id: 'finesse-syntax-jupyter',
......@@ -27,8 +24,7 @@ function activate(app: JupyterFrontEnd, tracker: INotebookTracker) {
tracker.widgetAdded.connect(activate_finesse)
};
function check_syntax(sender: Notebook): void {
function check_all(sender: Notebook): void {
sender.widgets.forEach(cell => {
if (cell instanceof CodeCell && cell.model.mimeType != "text/x-finesse-python") {
cell.model.mimeType = "text/x-finesse-python";
......@@ -36,11 +32,19 @@ function check_syntax(sender: Notebook): void {
});
};
function check_cell(sender: Notebook, cell: Cell): void {
if (cell instanceof CodeCell) {
cell.model.mimeType = "text/x-finesse-python";
}
}
function activate_finesse(sender: INotebookTracker, panel: NotebookPanel): void {
panel.content.modelContentChanged.connect(check_syntax);
panel.content.activeCellChanged.connect(check_cell);
// I ain't proud of this, but it's the sanest way I could find to get
// the syntax highlighting to change on startup without selecting a
// different cell
setTimeout(() => {check_all(panel.content)}, 1000);
};
/**
* Export the plugin as default.
*/
export default plugin;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment