Skip to content

Commit

Permalink
#30 use loaded js notebook content for js save
Browse files Browse the repository at this point in the history
also added simple hello-world.js to notebook samples for source code view and testing (#28)
  • Loading branch information
RandomFractals committed May 18, 2020
1 parent 56ffb14 commit 6dbe7b2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
31 changes: 31 additions & 0 deletions notebooks/intro/hello-world.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// URL: https://observablehq.com/@tmcw/hello-world
// Title: Hello ${name}
// Author: Tom MacWright (@tmcw)
// Version: 7
// Runtime version: 1

const m0 = {
id: "6759b582dec65059@7",
variables: [
{
name: "hello",
inputs: ["md","name"],
value: (function(md,name){return(
md`# Hello ${name}`
)})
},
{
name: "name",
value: (function(){return(
'world'
)})
}
]
};

const notebook = {
id: "6759b582dec65059@7",
modules: [m0]
};

export default notebook;
8 changes: 1 addition & 7 deletions src/views/notebook.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,7 @@ export class NotebookView {
// save notebook file
switch (fileType) {
case '.js':
const notebookDocumentUrl: string =
`${config.observableApiUrl}/${this._notebook.authorName}/${this._notebook.fileName}.js`;
fetch(notebookDocumentUrl)
.then((response: any) => response.text())
.then((notebookJS: string) => {
this.saveFile(notebookFileUri, notebookJS);
});
this.saveFile(notebookFileUri, this._content);
break;
case '.html':
// TODO
Expand Down

0 comments on commit 6dbe7b2

Please sign in to comment.