Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attributesWhitelist does not work since version 2.45.1 #1485

Open
abvas opened this issue Nov 25, 2024 · 4 comments
Open

attributesWhitelist does not work since version 2.45.1 #1485

abvas opened this issue Nov 25, 2024 · 4 comments

Comments

@abvas
Copy link

abvas commented Nov 25, 2024

Describe the bug
Since version 2.45.1 attributesWhitelist stopped working

I use this HTML:

<div style="text-align: center">
<p>This text is centered.</p>
<p>This text is centered.</p>
</div>
SUNEDITOR.create((document.getElementById('sample')),{
"width": "100%",
"height": "auto",
"attributesWhitelist": {all: "style"},
});

But this does not work and removes the "div" tag along with the "style" attribute, and the text is of course not centered.

Only paragraphs remain:

<p>This text is centered.</p>
<p>This text is centered.</p>

To Reproduce
Steps to reproduce the behavior:

  1. Set "attributesWhitelist": {all: "style"}
  2. Try loading HTML
<div style="text-align: center">
<p>This text is centered.</p>
<p>This text is centered.</p>
</div>

Expected behavior
The div with the "style" attribute should not be removed and the text should be centered.

Codepan example
https://codepen.io/abvas/pen/xbKKWZv?editors=1010

Desktop (please complete the following information):

  • OS: Windows
  • Browser chrome,

Additional context
In v2.44.12 this all worked correctly.
Starting with v2.45.1 it no longer works (including in version 2.47.0)

@JiHong88 JiHong88 added the bug label Nov 26, 2024
@JiHong88 JiHong88 added this to the 2.47.1 milestone Nov 26, 2024
@JiHong88 JiHong88 removed the bug label Dec 16, 2024
@JiHong88 JiHong88 removed this from the 2.47.1 milestone Dec 16, 2024
@JiHong88
Copy link
Owner

Format line cannot contain another line.
It must be contained within a range element.

<div class="__se__format__range_xxx" style="text-align: center">
<p>This text is centered.</p>
<p>This text is centered.</p>
</div>

@abvas
Copy link
Author

abvas commented Dec 16, 2024

Still, this is not quite the correct behavior.
It turns out that the user cannot insert, for example, such HTML:

<div style="text-align: center">
<p>This text is centered.</p>
<p>This text is centered.</p>
</div>

the user uses external HTML and it cannot have the class "__se__format__range_xxx"
it will lose common styles.

How to make <div style="text-align: center"> not be deleted?
Please consider this issue again. This worked correctly before version 2.45.1

Thanks.

@davidkonrad
Copy link
Contributor

davidkonrad commented Dec 27, 2024

Agree. I have (yet again) rolled back to v2.41.3. All versions after that is a mess. You end up using more time fixing errors (or mysterious deletions) in the generated HTML than you are using on actual writing.

If you get the attributesWhitelist to work then it will begin to automatically delete headers, and when you fix that you cannot add attributes, if you fix that then suddenly anything is wrapped into endless spans with __custom_tag etc, after cleaning up titles are suddenly automatically removed and so on.

The older versions had some flaws, you could live with that, but the newer versions are a mess. I have used hundreds of hours just to fix users writings / text because something odd have happen. I am a single individual who are running a free service.

Obviously the problems occur around all the attribute and tag white and black -listing. It is a great idea but we really do not need parential guiding with HTML, classes or attributes. And when it not work, or one rule somehow breaks other rules, why not leave it completely out, or have it as opt-in? It is nice to have, not need to have, and certainly not if it not works as expected. And why on earth replace <q> tags with &quot; just as another example??

Well, sorry for the harsh words 🙂 Was just frustrated, have yet again used 4-5 hours to correct a text, and then finally ended up rolling back (again). Merry Christmas and a Happy New Year!! 🌲🎁🎀

@davidkonrad
Copy link
Contributor

davidkonrad commented Dec 28, 2024

Oh, by the way, why all those <span style="color: rgb(34, 34, 34)"> and so on everywhere?? Why change perfectly good HTML to a mess? SunEditor was so good and worked perfectly until ...Something.

<span style="background-color: initial; color: rgb(34, 34, 34);"> it appears everywhere, inserted by SunEditor without any reason or cause - insane you need to remove it by hand over and over. Completely unnessecary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants