octalmage / Marknote

Markdown Note Taking.
36 stars 13 forks source link

Extensions. #30

Open octalmage opened 10 years ago

octalmage commented 10 years ago

Allowing JavaScript in notes has opened up some amazing possibilities. For example you can now automate note creation, modify a notes content, switch notes, you can automate anything!

I want to take this a step further and have a separate editor (in the settings) where you can input JavaScript that runs in the background. This way your "extension" runs independent of your note.

One example of what could be achieved with this is encryption! You'll be able to hook the loading of a note and decrypt it, then encrypt it when the user saves.

Another possibility is extending markdown. You could again hook note loading and use regex to add syntax for YouTube embeds, for example.

This will be a great start but I'd love for the user to be able to add GitHub projects, then Marknote will download and load the JavaScript automatically.

ValerieDittmar commented 9 years ago

What I think we could do is have a directory with autoloaded JS and have Marknote dynamically import those guys into the document that way.

Currently I'm having a dedicated note for scripts that need to be global which is pretty cool but I don't like it cluttering up with a random note.

octalmage commented 9 years ago

That sounds like a pretty good idea! I also plan on adding custom events for note changes and other actions so they can be hooked easier.

octalmage commented 9 years ago

Added some documentation to the wiki:

https://github.com/octalmage/Marknote/wiki/Plugin-API

Still need to document internal functions.

I'm also going to add more complex hooks, like rendering, so plugins can modify the rendered HTML before it's displayed. I'll use async waterfall to pass the HTML from plugin to plugin.

octalmage commented 9 years ago

Implemented hooks in the hooks branch, currently works like this:

addHook("render", function (content)
{
    return content.replace("cloud", "butt");
});

It's insanely powerful.

octalmage commented 9 years ago

hooks branch was merged, I don't think this issue is completely closed though. I'll review the API this week to find any missing functionality. #38 also related.