hvlads / django-ckeditor-5

Django CKEditor 5 integration.
Other
152 stars 60 forks source link

Span surrounding saved text #185

Closed DanB-Web closed 8 months ago

DanB-Web commented 9 months ago

Hi,

When saving content, it appears that the text within p-tags is also getting a surrounding span which is applying an inline style (a fontColor of #ce9178, in my case) - is it possible to remove this?

I don't have this colour anywhere in my codebase so I'm assuming it must come from the library somewhere?

DanB-Web commented 9 months ago

As an example, this is what is saved when I dump to a fixture:

"<p><span style=\"color:#ce9178;\">Yadda yadda yadda....</span></p>"
goapunk commented 9 months ago

@DanB-Web I can't reproduce that, simply entering Yadda yadda yadda.... does not produce a span for me. Is there anything special you do to enter it?

DanWeissman commented 8 months ago

Hi, apologies for the later reply.

No, nothing special, although I am using it within the Django admin area if that helps give context. I solved the issue for my use case by running the content through Beautiful Soup in a pre-save signal.

DanB-Web commented 8 months ago

Sorry, switched from work account :-)

As an example, here is one of the fixtures from and earlier commit in my repo:

https://github.com/DanB-Web/jobs/blob/92ad1cbea70caf97d8d1d469499510bcef1fb952/jobs/fixtures/data.json

As you can see, description, requirements and role in the jobs model (the three fields using the WYSIWYG editor in the admin) all have the span around them.

The fields are on the Job model as below:

description = CKEditor5Field('Job description', config_name='extends', blank=False)
requirements = CKEditor5Field('Job requirements', config_name='extends', blank=False)
role = CKEditor5Field('Role details', config_name='extends', blank=False)
goapunk commented 8 months ago

@DanB-Web Strange, when using the example blog application from this repo and entering any text, I see the following in the sqlite database:

sqlite> SELECT * from articles_article;
1|title|<p>test</p>|

So I can't reproduce it at all. Only guess is it's maybe something in your ckeditor config? As a side-note: we use Bleach to get rid of unwanted html tags as it's a good idea to filter user input anyway :)