In past versions there was a feature there if you select a single word double-clicking on it, it would have highlighted the same occurrences of the word in the document.
Notepad++ has the same feature and it is very handy.
In 1.1.4 it doesn't work anymore?
Or has it been removed for some reason?
Thanks.
Nicola
=== Version in use ===
Joplin for Desktop
Copyright © 2016-2020 Laurent Cozic
Joplin 1.1.4 (prod, win32)
Client ID: 203bbe446323491f959005c1d3c857fd
Sync Version: 2
Profile Version: 34
Keychain Supported: Yes
Revision: 9610b7e6 (master)
In v1.1.4 there was a switch to a new editor, it doesn't have this feature as a default. It does support the feature, but I think on the Joplin side it will be best to implement this as a plugin once plugins are available. Stay tuned.
In the meantime
1 Like
If this new editor does support this feature, is there a way to enable it?
even In the code (not from UI) would be ok for me.
I really miss this feature.
I'm struggling to not use notepad++
Thanks
What you want is the codemirror match highlighter
You should be able to enable by importing this function from within ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx
Alternatively, the new pre-release of Joplin has preliminary support for adding custom plugins, I'm going to play around with that now and I'll let you know what I find.
edit: I couldn't get the plugin to work yet, I think it will need a hook on the Joplin side.
If editing is important to you, why not edit in an external editor?
@laurent I haven't looked into extending the plugin system yet, but would you accept a pull request that adds support for extending the codemirror editor and the markdown-it renderer?
Basically what I envision is a way to grab the current CodeMirror singleton and another for markdown-it which would allow plugins to register new plugins with those two components. I know for CodeMirror this will be easy and we can write new extensions similar to the ones in CodeMirror/utils
.
Yes sure, feel free to give it a try. Extending the markdown-it renderer will definitely be needed to allow for example the Bibtext plugin, and I assume the same logic could be used for CodeMirror plugins.
I would suggest splitting this into two pull requests, one for Markdown, one for CodeMirror. How would you plan to implement this? Keep in mind that plugins run in a separate process, so you can't send instances between the plugin and the main process (only plain JS types), but I guess there are other ways to get it working. If you need any help or info let me know.
I thought about this further and the main issue is that it's not possible to run arbitrary code within the main app process. It's mostly a good thing to keep the app stable even when a plugin has errors, freezes or memory leaks, however it's not so good when we want to do more advanced customisations.
One solution would be to add the concept of "content scripts" like in Web Extensions. The plugin would simply pass a script path to the plugin API, which will then be loaded in the main app using require()
.
I've added a spec for it there: https://github.com/laurent22/joplin/issues/3933 I'll probably have a look at it at some point but if you want to give it a try feel free to do so. If you have any question or see any issue with the spec also let me know.
If I'm understanding correctly, the plugin could then prepare a javascript module in a separate file and next to index.ts
and index.ts
would then pass /home/caleb/plugins/calebsplugin/src/plugin
to Joplin and that could would then be run in the main process?
I imagine you'll probably get to this first, I still need to figure out how the plugin system is implemented
Yes that's exactly it. There's already something in place to load additional JS files (which is used for webview support) so the same technique would probably be used.
1 Like
Thank you Guys for looking into this.
I tried downloading the "match-highlighter.js" from "https://codemirror.net/doc/manual.html#addon_match-highlighter", saved to a folder in my laptop, went to Options -> Plugins (Beta) -> Development plugins and pointed to the .js file, restarted Joplin but nothing happened.
I guess, this is not the way it is meant to be, right?
Thanks,
Nicola
@CalebJohn, just so you know the latest pre-release now supports content scripts. For now, it's only for markdown-it plugins but it should be easy to extend to add support for CodeMirror or other plugins.
This is how it's done on the plugin side: https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script/src
And on the app side, the content scripts are loaded like so for markdown-it: https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/plugins/utils/contentScriptsToRendererRules.ts
(in fact that makes me realise there's a bug there as it's loading all the content scripts, not just those with type "markdownItPlugin")
And the doc for Markdown-It is on the website as well: https://joplinapp.org/api/references/plugin_api/classes/joplinplugins.html#registercontentscript
If you have any question about it feel free to let me know!
Thanks @laurent I'll take a look at this. I might be able to add codemirror support using markdown-it as a guide.
Thank you @CalebJohn and @laurent.
I recently updated to the latest 1.3.18 but apparently this feature has not been re-introduced.
It was very very handy and useful.
Any idea if it will be and when?
Thanks,
Nicola
Hi @rugginic
The code is ready but it will need to be reviewed before merging. So hopefully next release will have support.
We don't have plans to add match highlighting to the main app, but it will be a very simple plugin.
1 Like
Hi @CalebJohn
This sounds curious because this feature was already there and it was just great!
So now with the new editor and all its nitty gritty fancy stuff, this very useful feature is not supported anymore and it wont even be re-introduces and I still can't understand why......
Can you please at least provide DETAILED instructions on how to create this "VERY SIMPLE" plugin so I can do it myself and share with other people who like me feel the lack of this?
Thanks and Regards,
Nicola
Match highlighter is one of the example plugins, you can download it and use it, no need to write code.
You probably need to build the plugin as well.
1 Like
Hi @CalebJohn
I built the plugin from the directory you indicated and installed the generated jpl "joplin-match-highlighter".
The plugin is loaded and enable but simply doesn't work....
It doesn't highlight anything. Have you tried it?
I'm using version 1.6.8 (appimage) on Fedora 32
It looks like something probably went wrong when you were building the plugin.
I just double checked it on my machine and as you can see it works fine.
This is the plugin file that was generated.
org.joplinapp.plugins.MatchHighlighter.jpl (9.5 KB)
1 Like