JiHong88 / suneditor

Pure javascript based WYSIWYG html editor, with no dependencies.
http://suneditor.com
MIT License
1.67k stars 308 forks source link

"Font color" always wraps text in an additional "span" tag. #1323

Open abvas opened 8 months ago

abvas commented 8 months ago

Describe the bug "Font color" always adds a "span" tag even if the text is already wrapped in a "span" tag by previous operators. And it contains the style for "Font size". Because of this, other operators (for example strike or underline) do not behave correctly (have the wrong color)

To Reproduce Steps to reproduce the behavior:

  1. Type any word (for example "HELLO") - <p>HELLO</p>
  2. Apply, for example, “bold” and set Font size = 36 - <p><span style="font-size: 36px"><strong>HELLO</strong></span></p>
  3. Change Font color (for example #ff0000) - <p><span style="font-size: 36px"><span style="color: rgb(255, 0, 0);"><strong>HELLO</ strong></span></span></p> As you can see, an additional tag "span" has appeared
  4. Due to the additional "span" tag, we get incorrect behavior from other tags. For example, if you now try on strike (or underline), the line will be black and will not match the color selected as “Font color” <p><span style="font-size: 36px"><del><span style="color: rgb(255, 0, 0);"><strong>HELLO</strong></span></ del></span></p>

But if you apply "Font color" first, and then "bold" and "Font size", then everything will be fine ("bold" and "Font size" do not add the tag) <p><span style="color: rgb(255, 0, 0); font-size: 36px;"><del><strong>HELLO</strong></del></span></p>

Expected behavior "Font size" should not wrap the text in an additional "span" tag, but should use existing ones.

Screenshots problem Image 43

correctly Image 44

Desktop (please complete the following information):

Additional context A demonstration can be done and seen directly in your example: http://suneditor.com/sample/index.html

Thank you.