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 { ...@@ -7,15 +7,12 @@ import {
} from '@jupyterlab/notebook'; } from '@jupyterlab/notebook';
import { import {
CodeCell Cell, CodeCell
} from '@jupyterlab/cells'; } from '@jupyterlab/cells';
import './codemirror-finesse'; import './codemirror-finesse';
/**
* The plugin registration information.
*/
const plugin: JupyterFrontEndPlugin<void> = { const plugin: JupyterFrontEndPlugin<void> = {
activate, activate,
id: 'finesse-syntax-jupyter', id: 'finesse-syntax-jupyter',
...@@ -27,8 +24,7 @@ function activate(app: JupyterFrontEnd, tracker: INotebookTracker) { ...@@ -27,8 +24,7 @@ function activate(app: JupyterFrontEnd, tracker: INotebookTracker) {
tracker.widgetAdded.connect(activate_finesse) tracker.widgetAdded.connect(activate_finesse)
}; };
function check_all(sender: Notebook): void {
function check_syntax(sender: Notebook): void {
sender.widgets.forEach(cell => { sender.widgets.forEach(cell => {
if (cell instanceof CodeCell && cell.model.mimeType != "text/x-finesse-python") { if (cell instanceof CodeCell && cell.model.mimeType != "text/x-finesse-python") {
cell.model.mimeType = "text/x-finesse-python"; cell.model.mimeType = "text/x-finesse-python";
...@@ -36,11 +32,19 @@ function check_syntax(sender: Notebook): void { ...@@ -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 { 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; 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