klieret / verzettler

Non-linear, non-hierarchical knowledge management: Helper scripts for your Zettelkasten.
MIT License
18 stars 1 forks source link

In-browser editor #4

Open Pablo2m opened 3 years ago

Pablo2m commented 3 years ago

The use of typora in windows is being a tough nut to crack (I don't know if this expression is used in your country), in short I am having a hard time getting it to work. Can I add support to another editor? , I am thinking of something that uses JS (a necessary evil), so that it is independent of the platform, what do you think?

klieret commented 3 years ago

That sounds great. Best would be that we could make it configurable.

So if you say that it should be a JS editor, do you mean one that directly runs in the browser?

Other than that, currently the button doesn't do much more than running a system command (e.g. typora for Typora). So all we would need to do there is to start creating a config file, where you set up the different system commands together with the name that appears on the button.

Pablo2m commented 3 years ago

So if you say that it should be a JS editor, do you mean one that directly runs in the browser?

Yes, , I have found two possible options:

https://github.com/Vanessa219/vditor/blob/master/README_en_US.md https://github.com/nhn/tui.editor

I have also seen another that could serve but does not seem actively maintained

https://github.com/laobubu/HyperMD

klieret commented 3 years ago

Yes, those options would of course be awesome! That would bring the project to a whole new level. As you saw, it's currently just using pandoc to go from markdown files (which I most often edit in zettlr) to html.

But using one of these projects probably requires a lot more work than just opening an editor via system command, right?

I probably won't have too much time to spend on this for now, how about you?

Pablo2m commented 3 years ago

But using one of these projects probably requires a lot more work than just opening an editor via system command, right?

I probably won't have too much time to spend on this for now, how about you?

I never did something like that, I really wouldn't know how to estimate the time that something like this could take, I'll try.

Pablo2m commented 3 years ago

have almost one half ready: read files and be able to edit them. I basically use a template in which the content of the file is completed.

I am missing how to save them, my current idea is to try to use an HTTP POST method to update it from Python, what do you think?

klieret commented 3 years ago

Oh interesting! So you're making fast progress afterall :)

Do you have some work in progress that I could take a look at to see how it looks? Very excited!

But yes, saving new markdown is very easy. This could be done with a normal HTTP Post exactly as you describe or we could use flask socketio to save without having to load any new page.

klieret commented 3 years ago

In the backend this is as easy as

@socketio.on('save_button_clicked')
def save_new_version(json, methods=('GET', 'POST')):
    path = json["path"]
    with open(Path(path), "w") as outf:
        outf.write(json["file_content"])

or similar.

And from the client:

socket.emit( 'save_button_clicked', {content: 'File contnet', path: 'path/to/file'} );

(from top of my head)

Pablo2m commented 3 years ago

I still have two problems, sending the text to the server (I'll check your idea, I don't know anything about javascript, I'm just trying to interpret the code). Second problem, [[wiki]] links are not supported by the editor https://github.com/Vanessa219/vditor/issues/789 Tomorrow I will make a commit and send you a message in this issue, so you can see it, that editor except for that (and because I have not yet scheduled the file upload) is very interesting

Pablo2m commented 3 years ago

Take a look: https://github.com/Pablo2m/verzettler/commit/39c8f2c7a4f53390a50b4940c2ca76f65c287a73

klieret commented 3 years ago

Wow, that looks amazing indeed! Let me see if I can get it to work with saving changes

klieret commented 3 years ago

Hi @Pablo2m that's marvellous! Thanks so much for starting this. I've made the save button work right now (and it redirects to the rendered page). I'll add an edit button there in a second as well.

I'm working on the vditor branch of this repository where I've pulled over your commits. I've also added you to this repository (you should have a pending invite), so you should be able to work on that branch as well (and create new branches etc.). The master branch is protected, so you still have to make PRs though.

klieret commented 3 years ago

@all-contributors please add @Pablo2m for code,bug,ideas

allcontributors[bot] commented 3 years ago

@klieret

I couldn't determine any contributions to add, did you specify any contributions? Please make sure to use valid contribution names.

klieret commented 3 years ago

@all-contributors please add @Pablo2m for code, bug, ideas

allcontributors[bot] commented 3 years ago

@klieret

I've put up a pull request to add @Pablo2m! :tada:

klieret commented 3 years ago

https://github.com/klieret/verzettler/pull/12

klieret commented 3 years ago

@Pablo2m Ah, I see you're already working on removing this edit/open duality by making the vditor preview work properly! That would really make it a much better experience!! :star_struck:

Pablo2m commented 3 years ago

Yes, I think it would be good, at least as an alternative. There is still a lot to do.

klieret commented 3 years ago

It would also be much faster, I'm sure ;)

Pablo2m commented 3 years ago

I have advanced with the prototyping, this week I will try to polish it and put it in the vditor branch. I liked the new readme