close
The Wayback Machine - https://web.archive.org/web/20241121010123/https://github.com/laurent22/joplin/issues/3933
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for plugin content scripts #3933

Closed
laurent22 opened this issue Oct 16, 2020 · 8 comments
Closed

Add support for plugin content scripts #3933

laurent22 opened this issue Oct 16, 2020 · 8 comments
Labels
desktop All desktop platforms enhancement Feature requests and code enhancements plugins Anything related to Joplin's plugin system spec Fully developed spec that can serve as a starting point for a project

Comments

@laurent22
Copy link
Owner

laurent22 commented Oct 16, 2020

Plugins run in a different process and thus do not have direct access to the application content. IPC calls between the plugin process and the app process also doesn't allow transferring any complex data such as functions or entire modules.

For that reason it would be useful to introduce the concept of "content scripts" like in Web Extensions. A plugin would provide a script path to the plugin API, and this will then be loaded (using require()) inside the main app.

This will allow for example adding support for markdown-it or CodeMirror plugins.

The advantage of this approach is that most plugin operations are still done in their own process (with the associated benefits), but for specific cases we can get more customisations and performances using content scripts.

Specification

  • Add support for joplin.registerContentScript(type:string, path:string)
  • When called, it stores in the plugin Redux state (perhaps under a new "contentScripts" key) the script type and path
  • The script type is an arbitrary string which will indicate how the script should be used. It could be for example "MarkdownItPlugin" or "CodeMirrorPlugin".
  • Once a script is registered, hooks need to be added in the relevant places to load them. For example, in MdToHtml, there should be some place that check the list of content scripts with type "MarkdownItPlugin" and load them using require(). The same with CodeMirror, in the place where CodeMirror plugins are normally loaded.
@laurent22 laurent22 added enhancement Feature requests and code enhancements desktop All desktop platforms spec Fully developed spec that can serve as a starting point for a project plugins Anything related to Joplin's plugin system labels Oct 16, 2020
@nishantwrp
Copy link
Contributor

I'd like on this issue.

@roman-r-m
Copy link
Collaborator

Umm, I think this has been implemented already

@nishantwrp
Copy link
Contributor

Oh, ok. Is there any issue involving plugins that I can work on. I'm asking so that I could also get to know better how plugins work in Joplin for Google Summer of Code.

@roman-r-m
Copy link
Collaborator

That's not necessary at this point, what's more important is to demonstrate your skills.

@roman-r-m
Copy link
Collaborator

But to answer your question - the best way to learn how plugins work is to build one.

@nishantwrp
Copy link
Contributor

That's not necessary at this point, what's more important is to demonstrate your skills.

Oh, ok. Got it. What would be the best way to do that? Solving issues labeled "high"? Mostly all the issues labelled high or medium are claimed.

@roman-r-m
Copy link
Collaborator

Mostly all the issues labelled high or medium are claimed.

Apologies for the delay, I've just tagged a bunch of issues with medium, feel free to take one.

@laurent22
Copy link
Owner Author

Has been implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop All desktop platforms enhancement Feature requests and code enhancements plugins Anything related to Joplin's plugin system spec Fully developed spec that can serve as a starting point for a project
Projects
None yet
Development

No branches or pull requests

3 participants