10000 WIP An initial implementation of cells by jasongrout · Pull Request #3 · jupyter/jupyter-js-cells · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

WIP An initial implementation of cells #3

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Initial implementation of cell models and phosphor widgets.
  • Loading branch information
jasongrout committed Dec 11, 2015
commit eac66ee81aae59267066278dd483c35bc1d99d88
2,500 changes: 2,500 additions & 0 deletions example/data/data.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions example/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.jp-Cell {
border: 1px solid gray;
}
13 changes: 13 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="index.css">
<script src="../node_modules/steal/steal.js" data-main="example/index"></script>
</head>
<body>
<div>
<button id="editMarkdown">Edit Markdown</button>
<button id="renderMarkdown">Render Markdown</button>
</div>
</body>
</html>
72 changes: 72 additions & 0 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use-strict';

import {
Widget
} from 'phosphor-widget';

import {InputAreaViewModel} from 'jupyter-js-input-area';
import {OutputAreaViewModel, consumeMessage} from 'jupyter-js-output-area';
import {TextEditorViewModel} from 'jupyter-js-input-area';


import {
CodeCellWidget, CodeCellViewModel,
MarkdownCellViewModel, MarkdownCellWidget
} from '../lib/index';

let initialCode = `def f(n):
for mdInputArea in range(n):
print(mdInputArea)
`;

let initialMD = `
# Heading 1
This is some text
## Heading 2
* some
* list
* of
* **bold**, *emphasized* items
`;

function main(): void {
let mdText = new TextEditorViewModel();
mdText.text = initialMD;
let mdInputArea = new InputAreaViewModel();
mdInputArea.textEditor = mdText;
let mdCell = new MarkdownCellViewModel();
mdCell.input = mdInputArea;
let mdWidget = new MarkdownCellWidget(mdCell);
Widget.attach(mdWidget, document.body);

// Hook up markdown cell control buttons
let mdedit = document.getElementById('editMarkdown');
let mdrender = document.getElementById('renderMarkdown');
mdedit.onclick = () => {
mdWidget.editInput()
};
mdrender.onclick = () => {
mdWidget.renderInput()
};

let codeText = new TextEditorViewModel();
codeText.text = initialCode;
codeText.mimetype = 'text/x-python';
let codeInput = new InputAreaViewModel();
codeInput.textEditor = codeText;
let codeOutput = new OutputAreaViewModel();
let codeCell = new CodeCellViewModel();
codeCell.input = codeInput;
codeCell.output = codeOutput;
let codeWidget = new CodeCellWidget(codeCell);
Widget.attach(codeWidget, document.body);

// Populate the output of the code cell
System.import('example/data/data.json').then((data: any[]) => {
data.forEach((msg) => {
consumeMessage(msg, codeOutput);
})
})
}

main();
16 changes: 16 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noEmitOnError": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "ES5",
"sourceMap": false
},

"files": [
"../typings/es6/es6-promise.d.ts",
"../typings/es6/systemjs.d.ts",
"index.ts"
]
}
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"typings": "lib/index.d.ts",
"dependencies": {
"jupyter-js-input-area": "0.0.2",
"jupyter-js-output-area": "file:../jupyter-js-output-area",
"marked": "^0.3.5",
"phosphor-observablelist": "^1.0.0-beta",
"phosphor-signaling": "^1.2.0",
"phosphor-widget": "^1.0.0-beta.1"
Expand All @@ -23,14 +25,19 @@
"karma-mocha-reporter": "^1.1.1",
"mocha": "^2.2.5",
"rimraf": "^2.4.2",
"steal": "^0.12.7",
"typedoc": "^0.3.12",
"typescript": "^1.7.3"
"typescript": "^1.6.2"
},
"scripts": {
"clean": "rimraf docs && rimraf lib && rimraf test/build",
"clean:lib": "rimraf lib",
"clean:example": "rimraf example/*.js example/*.map",
"clean:test": "rimraf test/build && rimraf test/coverage",
"clean": "npm run clean:lib && npm run clean:example && npm run clean:test",
"build:src": "tsc --project src && node scripts/copycss.js",
"build:test": "tsc --project test",
"build": "npm run build:src && npm run build:test",
"build:example": "tsc --project example",
"build": "npm run build:src && npm run build:example && npm run build:test",
"docs": "typedoc --options scripts/tdoptions.json",
"postinstall": "npm dedupe",
"prepublish": "npm run build",
Expand Down
1 change: 1 addition & 0 deletions scripts/tdoptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"out": "docs/api",
"src": [
"src/index.ts",
"typings/es6/es6-promise.d.ts"
]
}
Loading
0