question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Formatting lost on backspace bug.

See original GitHub issue

I’ve noticed some odd behaviour with TinyMCE editors (4.2.5) that seems to be present in the most recent versions and was wondering if this is a bug and/or changeable behaviour.

Basically what I’m seeing is that if I have a line of formatted text and press return (more than once) midway through that sentence and then hit backspace the formatting for that text is lost.

The HTML at each stage looks like thus:

Formatted line:

<p><span style="font-family: 'arial black', sans-serif; font-size: 14pt;" data-mce-style="font-family: 'arial black', sans-serif; font-size: 14pt;" id="ext4-ext-gen4618">I am a line of text</span><br data-mce-bogus="1"></p>

After 2 carriage returns (as expected):

<p><span style="font-family: 'arial black', sans-serif; font-size: 14pt;" data-mce-style="font-family: 'arial black', sans-serif; font-size: 14pt;" id="ext4-ext-gen4618">I am a line </span></p> <p><span style="font-family: 'arial black', sans-serif; font-size: 14pt;" data-mce-style="font-family: 'arial black', sans-serif; font-size: 14pt;"><br data-mce-bogus="1"></span></p> <p><span style="font-family: 'arial black', sans-serif; font-size: 14pt;" data-mce-style="font-family: 'arial black', sans-serif; font-size: 14pt;" id="ext4-ext-gen4618">of text.</span><br data-mce-bogus="1"></p>

Once backspace is hit (with caret at front of last line) it becomes:

<p><span style="font-family: 'arial black', sans-serif; font-size: 14pt;" data-mce-style="font-family: 'arial black', sans-serif; font-size: 14pt;">I am a line </span></p> <p>of text.<br></p>

As you can hopefully see all of the formatting was stripped from the “of text.” line and this is not what I’d want to see, what I’d like is for it to look as it would after a single carriage return keeping its formatting ie:

<p><span style="font-family: 'arial black', sans-serif; font-size: 14pt;" data-mce-style="font-family: 'arial black', sans-serif; font-size: 14pt;">I am a line </span></p> <p><span style="font-family: 'arial black', sans-serif; font-size: 14pt;" data-mce-style="font-family: 'arial black', sans-serif; font-size: 14pt;">of text.</span></p>

Any insight you have would be appreciated.

Video of the problem: https://www.youtube.com/watch?v=-9AHNo-E4NY

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Danni-Phantomcommented, Oct 24, 2017

I am working to try and fix #3817 at the moment. I think these issues might be related

0reactions
Curi0sitycommented, Jan 30, 2020

As a workaround, I had solved it using the keydown event: ed.on("keydown",function(evt) { if (evt.keyCode == 8 || evt.keyCode == 46) //backspace or delete { var elem = tinyMCE.activeEditor.selection.getNode(); if (elem.textContent.length <= 1) { evt.preventDefault(); evt.stopPropagation(); jQuery(elem).html('&#65279'); // inserting Zero Width No-Break Space return false; } } });

Hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Backspace to get rid of formatting
The backspace feature is not removed from Word 2013; it works the same way as Word 2010 and previous versions of Office. To...
Read more >
156722 - Backspace deletes text formatting
Backspace so no text is remaining or 2b. Use mouse cursor to select point to begin typing Actual Results: In 2a, all the...
Read more >
In Redactor backspace button erase the formatting
Hi I am working on the Redactor editor in the jquery, I make the formatting for the text It shows properly but problem...
Read more >
Thread: Backspace event text box string formatting not able ...
I'm trying to make a user form for data entry and I have a textbox with tariff codes. the layout is ####.##.##.## which...
Read more >
Style Changes When "Backspace" Joins Two Separate ...
formatting.) Click to expand... Thank you for the response, Mr. Blom. The problem is that your explanation would ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found