samclarke / SCEditor

A lightweight HTML and BBCode WYSIWYG editor
http://www.sceditor.com/
Other
659 stars 188 forks source link

Unexpected undo behaviour when adding BBCode tags #928

Closed Melonking906 closed 1 year ago

Melonking906 commented 1 year ago

When using CTRL+Z to undo inserting BBCode, it erases the entire text, not just the BBCode you inserted. It should probably just undo the last action.

This only happens if you use the buttons to apply a BBCode tag on a piece of selected text (e.g. selecting something, clicking the Bold button to encase it in b tags, and then pressing CTRL+Z.)

Steps to reproduce the problem

This can be observed in the example editor on the sceditor website.

  1. Switch to BBCode mode in the editor
  2. Write some text, then select it and press a BBCode button like Bold
  3. Do CTRL-Z, instead of undoing the bold BBCode wrap it will erase all your text.
samclarke commented 1 year ago

Thanks for reporting. What browser are you using and are you using the undo plugin?

I've tried to reproduce this but so far I'm not getting the behaviour. Could you see if I'm doing anything different:

Attempt to reproduce the problem

The above is with the undo plugin, without the plugin I'm getting the same behaviour as above except it doesn't undo.

Melonking906 commented 1 year ago

Well this is odd; I based this report on testing I did about a week ago and it was present in the editor on sceditor.com but now the editor there is behaving as if it does not have the undo plugin, undo is doing nothing to tags.

On my forum I can replicate this bug on all browsers I tested; Safari, Firefox, Chrome on Mac and Firefox on Linux - however my forum runs an old build (jQuery 3.6.3 and SCEditor 2.1.3; it cant be updated because 3+ appears to break other parts of my forum)- However this is such an unusual dynamic Im not sure its a valid test for you; and since its no longer present in the demo editor; we probably cant proceed with this issue.

Otherwise your test is exactly what I was doing.

samclarke commented 1 year ago

Nothing has changed recently with the editor on sceditor.com so if you were able to reproduce it there recently then it might still be an issue but one that has some extra unknown criteria which your forum is consistently triggering.

Would it be possible to share a link to your forum? If you want to keep it out of public issues you can email me at sam@samclarke.com.

it cant be updated because 3+ appears to break other parts of my forum

The main backwards incompatibility with 3+ is dropping IE WYSIWYG support so if it is breaking something that would likely be a bug. What was it breaking? Again, can use the above email if you prefer.

samclarke commented 1 year ago

Closing this as it isn't an issue with the current version.

The undo issue was a bug with the undo plugin but it has been fixed in v3.1.0.

The backwards compatibility issues were due the HTML sanitiser stripping some HTML attributes, changing them to data- attributes fixes the issue.