medium-editor icon indicating copy to clipboard operation
medium-editor copied to clipboard

Pasting text with a newline into a heading adds unwanted style

Open dcsaszar opened this issue 6 years ago • 2 comments

Description

When pasting multi-line content into a headline, the pasted content contains unwanted style attributes, even with the default plain-text paste setting.

Steps to reproduce

  1. Open http://yabwe.github.io/medium-editor/
  2. Make "The dead simple inline editor toolbar." an H2
  3. Copy these 2 lines: line 1 line 2
  4. Paste them into the H2, e.g., after "dead simple"
  5. Inspect the element with the pasted "line 2"

Expected behavior: [What you expected to happen]

Clean HTML, no style

Actual behavior: [What actually happened]

<span style="font-size: 1.5rem; font-weight: 500;">line 2</span>

image

Versions

  • medium-editor: 5.23.0
  • browser: Chrome 68
  • OS: MacOS High Sierra 10.13.6

dcsaszar avatar Sep 19 '18 15:09 dcsaszar

This worked for me.

document.execCommand('styleWithCSS', false, null);

kritollm avatar Oct 30 '19 09:10 kritollm

I tried my original reproduction steps with document.execCommand('styleWithCSS', false, null); before the paste step (4). Does not work for me.

@kritollm Can you give a more precise description how to make the above "steps to reproduce" work without getting style attributes in the resulting HTML/DOM?

dcsaszar avatar Oct 30 '19 11:10 dcsaszar