-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Toggle plugins #1347
Toggle plugins #1347
Conversation
This looks great. However, should @laurent22 agree to adding this, maybe we should create a separate screen and menu item for |
a few ideas for additional plugins: https://discourse.joplin.cozic.net/t/hiding-passwords-with-markdown/1588/7 |
- Also adds some new plugins
Okay this is ready to ship! @tessus I left it on the config screen for now because that was easiest and it integrates nicely with settings. I also looked into adding spoiler and summary and surprisingly it was a bit more involved than these other plugins so I thought it best to leave for another time. What this pull adds is a bunch of extra markdown features available for markdown-it and the ability to toggle them all (I also made katex toggle-able because there were some complaints about it). |
Nice job. 1 question and 1 comment though: Question: Comment: In that case I really love this change and I hope @laurent22 merges this soon. |
@@ -106,15 +106,13 @@ | |||
|
|||
let previousContentHeight = contentElement.scrollHeight; | |||
let startTime = Date.now(); | |||
ignoreNextScrollEvent = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some testing and didn't find a use for them, it seems like the subsequent restorePercentScroll();
even wasn't triggering a scroll event anyways, so by ignoring this event it introduced a subtle bug.
- webview was moving itself when scrolling to bottom anchors
To answer your question: |
The footnote plugin looks really nice, thanks for adding this! I agree enabling/disabling plugins like this is the right approach since that way we don't need to think too much about what's the right plugins to add or not. I need to review the PR a bit more but I just see few issues at the moment:
|
|
// position, the scroll positions stays correct though | ||
// Additionally an anchor could not be clicked twice because the location | ||
// would not change, this fixes that also | ||
setTimeout(function() { location.hash = old_hash; }, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read the comment but I don't quite understand the change. Based on the code it means, first we jump to the requested anchor (location.hash = href
) but then we moved back to the previous anchor (location.hash = old_hash
)? I'm sure I'm missing something but could you clarify the logic here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what's happening, this fixes 2 bugs present in the way webview handles anchors, the first is that when you click on an anchor, the url for the webview changes to reflect that movement, which has the unintended side effect of making the webview un-reactive to subsequent presses of the same anchor link. This fixes that issue by resetting the url after some tiny delay, so the webview will correctly scroll into place then reset to a standard url thus allowing the same link to be pressed again (and get the correct scrolling behavior).
The other bug this fixes is a bit weirder and is why I labelled this "hack". The webview tries to place anchors at the top of the page, which means if you have an anchor near the bottom of your page without much text below it, the webview scrolls to the bottom and would shrink to until it was able to fit the anchor at the top of the page. I suggest you remove the line I've added and give it test for yourself, its very strange. What I found was that by resetting the url the webview would correctly scroll to the bottom but wouldn't shrink to display the anchor.
I don't believe this is absolutely the best fix (hence the hack warning) but I was pretty stuck on how else it could be fixed.
Ok if it's to support these 2 plugins, please leave the changes in then.
I misread the setting page (was looking at the "public" property instead of "enabled" so I thought they were all enabled). I think it's good as it is then.
From /CliClient, you would run |
I've run the tests now and nothing related to the rendering is failing, I did get one failure though related to folder sorting? I suspect it's unrelated. |
That's maybe because the default sorting changed from ascending to descending at one point (when the change was implemented to sort by last updated). |
Thanks for the fixes @CalebJohn, it's nearly all good. For the tests, it was indeed unrelated and I've now fixed it. There's one last issue and that's regarding the setting names. I've recently added an internal plugin system, which I intend to use to add new features without touching the core files, to make the code more modular basically. So far it's just an internal feature but later it could be used to support actual plugins with possibility to enable/disable some of them. Because of this, I think we should use a more specific namespace for the new setting properties. Since they are all viewer plugins, I'm thinking they could go under |
That's awesome.
There should definitely be a new namespace, I like |
Right, it's true that viewer is a bit vague so let's go for |
All done! Thanks @laurent22 . In light of your recent change should this be changed to integrate better with the new plugin system? Or does it make sense to leave it as is for now? |
Thanks for the update!
Let's leave as it is as they are not really Joplin plugins but markdown-it plugins, so it's good if they remains separated. So I think it's all good now and ready to merge. Many thanks for your efforts @CalebJohn! |
Good point. Thanks @laurent22 ! |
With the new change to the renderer (making it much easier to use plugins) I thought it would be a good idea to allow enabling/disabling plugins through the general options. To that end I have created a test branch which adds a couple of plugins and makes one of them able to be enabled/disabled through the interface.
Here is a note with mark syntax and footnotes added.
Here is the plugin screen (I only added mark for now)
And after we hit the toggle and return to the note it looks like this.
With a system like this in place it will allow us to add a lot of plugins without worrying about users will use/like because everything can be turned off if it's annoying. This would solve some of the complaints there have been about katex hijacking the $ symbols.
With that in mind I think there still needs to be some thoughts about which plugins to enable by default, and which should be turned on by users. This would be a good place to discuss that.
For reference, here is a list of markdown-it plugins on npm