easy-markdown-editor icon indicating copy to clipboard operation
easy-markdown-editor copied to clipboard

Copying text with bullets and headings is removed in editor making it plain text.

Open shivakaranj opened this issue 6 years ago • 3 comments

I'm submitting a...

  • [ ] Bug report
  • [x] Feature request
  1. Copy any text with headers, lists and other markdown applied.
  2. Pasting it in editor is transforming it into plain text.

Be able to paste text in preview mode to not lose text transformation. Is there a plan or chance to support this feature?

Actual: image

Expected: image

shivakaranj avatar Jan 29 '19 20:01 shivakaranj

This will be really useful when want to copy and paste huge texts from other places.

CarolsmDoza avatar Jan 30 '19 15:01 CarolsmDoza

CodeMirror provides the paste event, triggered when the user paste something in the text area.

The clipboard API standards describes several datatypes (which is now well supported by recent browsers), including plain text and html.

Here is good start to understand this:

<!DOCTYPE html>
<html><body>
<p contenteditable="true" id="paragraph">Paste something here, please.</p>
<script>
  document.getElementById('paragraph').addEventListener('paste', function(e) {
    console.log('text/plain clipboard: ' + e.clipboardData.getData('text/plain'));
    console.log('text/html clipboard: ' + e.clipboardData.getData('text/html'));
  });
</script>
</body></html>

So basically we need to retrieve e.clipboardData.getData('text/html') then convert it to markdown using the reverse parser and injecting in the text area.

lypwig avatar Feb 28 '19 23:02 lypwig

This is a great feature, has it been worked on or implemented yet?

userofit123 avatar May 30 '22 14:05 userofit123