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

Toolbar Plugin #1332

Open
benjamin-kirkbride opened this issue Jul 4, 2023 · 8 comments
Open

Toolbar Plugin #1332

benjamin-kirkbride opened this issue Jul 4, 2023 · 8 comments

Comments

@benjamin-kirkbride
Copy link
Contributor

image

When editing a Markdown file, I want some buttons on a bar to appear above the editor window to help with common Markdown features.

I am not aware of an existing pattern for implementing such a thing. Probably need a separate issue for creating a toggleable "button bar".

Hopefully this isn't antithetical to what people are wanting for Porcupine, but this isn't any more invasive than the side-by-side thing that @rdbende is working on, I think

@benjamin-kirkbride
Copy link
Contributor Author

So I'm not sure this makes sense to implement as a plugin. The reason for that is because I would want other plugins to be able to bind "commands" to this (in the form of buttons). Similar to how menubar.add_filetab_command works now. This is also pertinent to #1319

I'm going to pursue this further and see how it goes. Input appreciated.

@Akuli
Copy link
Owner

Akuli commented Jul 4, 2023

I don't really want buttons like this. A few reasons:

  • We don't have a good way to deal with the many flavors of markdown. For example, should triple-backticks or indentation be used for code blocks? The preview plugin can just support both, but we have to pick one if we have a code snippet button. The button would be useless when writing for something that only supports the other kind of syntax.
  • The entire purpose of markdown compared to other similar languages is that the syntax is easy to write and remember. For this reason I think most people wouldn't use the buttons.
  • This would be a lot of work to implement (many buttons, each with an image) for little benefit.

I hope this makes sense. I find it's best to tell people early when I'm not interested, so that they don't work on something for a few days only to find out that I don't want to merge.

@Akuli
Copy link
Owner

Akuli commented Jul 4, 2023

Related: #159

@benjamin-kirkbride
Copy link
Contributor Author

The way I have conceived of implementing this I think actually addresses all of your concerns. Also I'm intending to implement this as a plugin, so it can be turned off without problem :)

We don't have a good way to deal with the many flavors of markdown

#1322 ;)

should triple-backticks or indentation be used for code blocks

There is a lot of prior art here.

Github:
image

Joplin:
image

StackEdit:
image

I think we would want to do what most of them do.

The button would be useless when writing for something that only supports the other kind of syntax.

I'm envisioning plugins that register buttons based on the filetype, thus this would not really be an issue. If no buttons are registered for a filetype then the buttonbar does not appear.

The entire purpose of markdown compared to other similar languages is that the syntax is easy to write and remember

Yes and no. Lists and headings sure. Tables, diagrams, and custom syntax? Not so much unfortunately. Also I can never remember how to make links, if its [url](desc) or the other way around 😅

I'd also like an emoji picker button, a button to create and insert Draw.io diagrams, a button to find and link images, etc.


I'm having fun hacking on this and think I can have a prototype pretty soon, I'm happy to continue working on it even knowing you may not ultimately green-light it unless you are saying with a very high certainty you are completely uninterested.

@benjamin-kirkbride benjamin-kirkbride changed the title Markdown Editor Controls Toolbar Plugin Jul 4, 2023
@Akuli
Copy link
Owner

Akuli commented Jul 4, 2023

Instead of "completely uninterested", a better way of looking at this could be that I want a different user interface for the same thing.

Instead of buttons, I would be more interested in typing something like <Ctrl+M> link <Enter> to insert [link text](https://example.com/), where Ctrl+M is a magic keybinding (can be something else too), and as I am typing link I see what else I can insert than a link. My use for this would be in languages with a lot of boilerplate, like latex, but markdown links would be an equally valid use case.

Ideally the things to insert would be simply listed in filetypes.toml, so that it's easy to start using this in more languages.

As for buttons, I'm still not convinced that they are a good idea. Having to include an image for every action would be a pain for configurability. Maybe buttons with text on them instead of images, and a setting to hide the entire toolbar?

@benjamin-kirkbride
Copy link
Contributor Author

I would be more interested in typing something like <Ctrl+M> link

Sounds like you are referring to #1319 ?

Ideally the things to insert would be simply listed in filetypes.toml, so that it's easy to start using this in more languages.

So I'm not just talking about snippets here, though for that use case I agree having it be part of filetypes.toml makes a lot of sense :)

Having to include an image for every action would be a pain for configurability

I'm not planning on having the buttons be configurable outside of perhaps snippets, as again I'm not envisioning this being mostly for just inserting some raw text.

As far as the images themselves, there is https://iconoir.com/:
image

Can we use SVG's as icons? How does that work?

@Akuli
Copy link
Owner

Akuli commented Jul 4, 2023

Sounds like you are referring to #1319 ?

#1319 and #159 are pretty similar. I was referring to #159 but you can view #159 as being just specific commands within #1319.

Can we use SVG's as icons? How does that work?

SVG's are a pain in tkinter. I once got them to work through two rounds of conversion, with two different libraries: SVG -> PDF -> PNG. They always ended up having white background though, so it would be easier to make a script that converts them to transparent PNGs, maybe with imagemagick.

@benjamin-kirkbride
Copy link
Contributor Author

make a script that converts them to transparent PNGs, maybe with imagemagick

Easy enough.

@benjamin-kirkbride benjamin-kirkbride mentioned this issue Jul 5, 2023
11 tasks
This was referenced Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants