Ionaru/easy-markdown-editor

Add dimension support for images

SchrodingersGat opened this issue · 4 comments

Is your feature request related to a problem? Please describe.

It would be useful to be able to specify the size (height / width) of images within the markdown.

Describe the solution you'd like

The ability to specify width / height within the markdown tags. wiki.js offers this feature in their markdown editor:

image

Describe alternatives you've considered

You can use <img> tags but in some systems raw html tags are stripped for security reasons and prevents this approach.

Ionaru commented

It looks like the wiki.js markdown renderer supports this from itself, it isn't standard as far as I know.

Using the previewRender option it is possible to use any custom markdown renderer that is available. Including ones that support image sizes. If wiki.js exports its markdown renderer, then you can use that.

Alternatively you can use plain HTML for images and specify a size like this:

<img src="https://placekitten.com/g/500/500" width="50px" height="50px">

I think it will be a good idea to support multiple markdown renderers out-of-the-box, but that would require significant work and I would rather include that in #447.

It looks like the wiki.js markdown renderer supports this from itself, it isn't standard as far as I know.

I'm not expecting it to be standard, but it is a nice feature :)

Alternatively you can use plain HTML for images and specify a size like this:

The system I am implementing in sanitizes HTML tags in uploaded data, which is why I'm looking for an alternative!

Would you consider adding this rendering feature, or be open to a PR?

Ionaru commented

Would you consider adding this rendering feature, or be open to a PR?

No, the editor should never change the way markdown is displayed by default. Any developer can change options for their use-case using the previewRender or renderingConfig.markedOptions options, but any specific syntax or rendering changes will vendor-lock people to easymde or a specific markdown renderer which defeats the purpose of the editor.

EasyMDE is a markdown editor with a preview function to help with editing, not a markdown renderer, markdown parser or markdown displayer.

@Ionaru understood, I'll close this out then :)