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

feature suggestion #4

Closed
julianmueller opened this issue Aug 6, 2022 · 3 comments
Closed

feature suggestion #4

julianmueller opened this issue Aug 6, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@julianmueller
Copy link

Hi,

ich really like your plugin! But as I used it, i came across an idea how to improve it:

  • you could make the linenums toggleable, with a button that fades (like some code websides do) next ro the copy button
  • obsidian gives the ability to collapse functions/blocks etc. but with the line nums enables, the first collapseable arrow is on the left side of the linenumbers, whilst the code is on the right
  • a global option to always show linenumbers would be great!

Thanks again for the useful plugin :)

@lijyze
Copy link
Owner

lijyze commented Aug 7, 2022

Hi~, I'm happy you like it.

In terms of design, this plugin in my imagine is like a toolkit, if you need any functionality, just pick the tool from it. Instead of make tools accessible everywhere, I think that will cause confusions.
And also, the more code blocks you attach functionality, the more time you need to render. Even if it will only be a small amount of extra time.

I know if you do need number every code block, it will be convenient if there is a button or a global option, however, for the reasons mentioned above, I'm not going to add feature 1 and feature 3.

About feature 2, I think this should be a bug, I will try to fix it.

Thanks for your advices!

@lijyze lijyze added the bug Something isn't working label Aug 7, 2022
@julianmueller
Copy link
Author

I understand your concerns regarding the rendertime, but I guess thats why it could be optional. You could attach a note saying, it will increse render time slightly. But for someone like me, who would go back to all codeblocks and add die nums toolkit there manually to have it everywhere, Id willingly take the extra ms rendertime for every page.
I get what you mean, that its a toolkit, but why not make the toolkit customizable, so everyone gets the most out of it as he/she needs it.
But it just a suggestion, and i dont know the effort behind adapting the changes as i havent created a plugin yet.

@lijyze
Copy link
Owner

lijyze commented Aug 9, 2022

v1.1.2 has been released.

I simply move collapsing button to the right of the line numbers, and fixed a bug about line number after code being collapsed.

If you do need to number every code blocks you have, you can try following method

  1. Find main.js in VaultFolder/.obsidian/plugins/obsidian-advanced-codeblock/.
  2. Find the definition of the method handleLineNumbers and remove its guardian statement. This will make all of your code blocks get line numbers in preview mode.
  3. Find buildDecorations, remove if (codeblockInfo.showLineNumbers) {...} this if condition but keep the statements inside. This will make all of your code blocks get line numbers in live-preview mode.

This plugin seems won't update frequently, so this solution would work stably. Also, you can rename folder and id field in manifest.json to a new identical name to prevent plugin update.

@lijyze lijyze closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants