Dale K
Dale K

Reputation: 27225

TinyMCE 3.9.3 adds an un-necessary SPAN when deleting a P

When the following sequence is carried out I end up with spans being automatically added, which change the font size. This is all carried out in normal text mode, not HTML mode.

1/ Editor contains <p>Test</p>

2/ Hit return twice and enter some text, editor now contains <p>Test</p><p>&nbsp;</p><p>Now</p>.

3/ Move the cursor up so that its on the empty paragraph and hit delete once. Now the editor contains <p>Test</p><p><span style="font-size: 0.75em; line-height: 1.7em;">Now</span></p>.

TinyMCE v 3.9.3

I know its an old version of the editor, so if I have to I will upgrade, but wondering if anyone has any idea why this is happening, and ideally has a solution for this.

Upvotes: 1

Views: 131

Answers (1)

macem
macem

Reputation: 91

I have the same problem only on Chrome. Simple solution below but only remove styles not spans

editor.on('keyup', function(e) {
  var node = editor.selection.getNode();
  // workaround for chrome to generate style attr when press del
  if (node && e.keyCode === 46) {
    node.removeAttribute('style');
  }
});

Upvotes: 1

Related Questions