Note: Plugin support has been merged. It should be available in the Android Joplin pre-release.
See this GitHub issue for more information about plans for plugin support on iOS.
Over the past few weeks, I've been working on adding plugin support to mobile (see the relevant pull request on GitHub).
This post summarizes the status of the pull request.
To-do
- Better development experience
- Currently, it's possible to inspect plugin
WebView
s in Google Chrome, but only in a development build of Joplin. Assuming most plugin authors won't be running a development build of Joplin, a way to enable plugin WebView debugging should be added.
- Currently, it's possible to inspect plugin
- Refactoring & automated tests (where possible)
- Performance improvements
- Fix: Large renderer content scripts (like that included in ABC Sheet Music) significantly slow down the renderer.
- Fix: Plugin background WebView is created even if there are no plugins to load.
- Support more of the plugin API (see below).
- Add a way to start the mobile app in safe mode (i.e. without running plugins).
Plugins known to work
ABC sheet music
The ABC sheet music plugin mostly works.
Known issues:
- In dark mode, the music is difficult to read.
An error message is briefly shown before music renders.
ABC sheet music registers a renderer content script. This content script tries to access the plugin's settings.
With the plugin API pull request, the renderer is run inside the note viewer WebView
for security and to provide renderer plugins access to DOM APIs. This does mean, however, that communication with renderer scripts is asynchronous.
The settings API is synchronous, however (and so is markdown-it
rendering). Thus, attempting to access a setting returns undefined
, loads the setting, then triggers a re-render (with the setting loaded).
After the first render, an error message is shown by the ABC Sheet Music plugin because it doesn't expect the setting to be undefined
. The error message disappears because the setting is not undefined
in the second render.
The example CodeMirror 6 plugin
The mobile editor is based on CodeMirror 6. As such, the demo CodeMirror 6 plugin for desktop works.
Because the existing CodeMirror 6 plugin API includes a compatibility layer, plugins that target CodeMirror 5 may work, depending on the features they use.
Note: For testing purposes, this plugin is included with the demo Android APK and enabled by default.
Function plot
Math mode
Known issue: Clicking on the same line as a math expression does not move the cursor to that line.
Spoilers
Known issue: Some content is missing a show/hide arrow (renders a box instead).
Plugins known not to work
- Plugins that require file system access (e.g. Simple Backup, Outline)
Plugin API
Supported
- Markdown-it and CodeMirror 6 content scripts
joplin.data
joplin.views.toolbarButtons.create
- Currently only works for
ToolbarButtonLocation.EditorToolbar
- Currently only works for
joplin.clipboard.readText
,joplin.clipboard.writeText
- Missing support for
readHtml
,writeHtml
- Missing support for
- Most of
joplin.views.dialogs
- Missing support for
showOpenDialog
- Missing support for
joplin.commands
joplin.settings
joplin.views.panels
Unsupported
API Notes
- There are almost certainly bugs in the APIs listed as "supported" above.
joplin.versionInfo()
has been extended to include aplatform
key, which is set tomobile
when running on mobile. This API is not finalized — it might be replaced with something similar tojoplin.isMobile()
orjoplin.platform.isMobile()
. (Example usage).
Development notes
Plugins can be loaded from .jpl
files by clicking the "Install from file" button in plugin settings.
If a plugin has uncaught errors/promise rejections, an "Error" button should be visible on that plugin's card in settings. It may be necessary to close and re-open settings for the button to be visible just after installing a plugin:
Clicking that button should show entries in the application log that include the plugin's ID.
Android APK
This APK is built from the plugin support pull request and published under the "releases" page of my fork of Joplin on GitHub.
Before building, I first changed the application ID from net.cozic.joplin
to net.personalizedrefrigerator.joplin
(and renamed the app to Joplin (Beta)
). Thus, the application can be installed alongside an existing version of Joplin without overwriting it.
Feedback
Suggestions and feedback are welcome and can be posted in the comments below.