JoelOtter / kajero

Interactive JavaScript notebooks with clever graphing
Other
1.87k stars 110 forks source link

[request] More saving functionality #61

Open kishkash555 opened 6 years ago

kishkash555 commented 6 years ago

Kajero is really nice. Data source integration is an awesome feature. The thing I'm struggling with is how to methodically create Kajero documents (notebooks with data sources, code blocks and text blocks along with the specific running options of each block) and save them so I can access them later. Currently creating a new Gist each save is the only option. Since Kajero is essentially a (client-side) editor, saving the file locally would be the best and most straightforward solution but that's not an option from code running in the browser.

I'd like to suggest two alternatives that would be of great help:

  1. download the file - it's possible, from client code, to create a text file that will be saved in the browser's default download directory

  2. create a small file server that accepts POST requests and saves the incoming data file on the server side. This would have the (undesirable?) side effect of making Kajero a client-server app.

What I'd like to ask, as a first step for implementing either alternative, is to expose a function that returns all the editable parts of the document, maybe as a json which can later be parsed in server-side code.

Can you provide/expose such a function?

As a sidenote, it would be nice to just get a warning before leaving the page. The way it is, any random page refresh (F5) erases all edits.

JoelOtter commented 6 years ago

Hey @kishkash555, thanks for the feedback, that's super helpful. :)

I may be misunderstanding your request - can't you use the Markdown/HTML export to do what you describe? ATM there's only a 'copy to clipboard' button but it shouldn't be too hard to add a button for creating a file, as I believe most browser APIs offer this feature now.

As for the warning - definitely, 100% agree. Thanks!

kishkash555 commented 6 years ago

Thanks for the quick reply, @JoelOtter.

Ok, I was able to achieve what I wanted. I made changes to components/SaveDialog.js, which is what I believe your reply pointed to. I changed the functionality of the "markdown" button (it would be better to create a new button, but since I'm not a React programmer, I'm trying to minimize my client-side code changes). The "markdown" button now doesn't copy to the clipboard - instead it downloads a text file with the contents of the notebook (in markdown format). My next step (which I've started working on) is to run a node.js process in the background, that detects the new downloaded file in my download folder, then replaces the markdown in the markdown section of the original file (e.g. blank.html) with the new text. This way I'll have a "file save" functionality - making Kajero more wiki-like, while still running 100% client-side. I'll try to complete this work in the next few days, if I do I will post this work as a gist.

over9001 commented 6 years ago

I came here to find out about getting a nice click-to-save button. Glad to see I'm not the only one!