Paste to Markdown Support

Author: burlesonaCreated Jul 25, 2016Updated Aug 28, 2024
Labelsidea

I discovered simple MDE and absolutely love it so far.

I've been hearing a use case from my users that are not used to Markdown, they want to be able to paste with formatting and have it converted to MD automatically.

I've made this work on my site by creating a paste with formatting button, this opens up a modal where they can paste into a contenteditable and then click save. If they click save, I use https://github.com/netgusto/upndown to convert the resultant HTML to Markdown, and then I set the result to be the editor instance content.

This works OK, but I think it would be even better if people could just paste normally. I got that to work by intercepting the paste event on the code mirror instance under the hood, but the only problem was it ends up replacing the entire content of the editor, not just the user's current selection.

I stopped going any further down that route because I had a working solution (paste into the modal), but I wanted to bring it up here to ask two questions:

  1. Would you guys be interested in adding "paste with formatting", aka convert to markdown, as a built-in part of SimpleMDE?
  2. If so, do you prefer the "paste into a modal" approach, or a "paste into the editor and it just works approach?"

If that's something you'd be interested in incorporating into the project I was thinking I might try a PR to include the work I've already done. I might need some pointers on how to integrate a toolbar option, etc. but I'm sure I could figure it out.

I saw this was previously mentioned here (https://github.com/NextStepWebs/simplemde-markdown-editor/issues/257) but the use case I think was quite different, in my case the issue is people who are less technical having already formatted something in Word or whatever and then being upset that they have to redo the formatting in markdown.

Thanks!

Source: sparksuite/simplemde-markdown-editor