Strange problem with quill field

Strange problem with quill field

GargiucnGargiucn Posts: 120Questions: 33Answers: 0

Good morning,
I have a problem with quill.
It has always worked very well, but now it has a problem that I cannot solve.
I should mention that I am using the latest version of Datables and Editor.
Quill works normally with different font sizes, bold and italics, but it no longer works with colours (both font and background colours). When I use colours, it adds the <span></span> tag.

<p><strong>Bold font</strong></p>
<p><em>Italic font</em></p>
<p><u>Underlined font</u></p>
<p><span>Red font</span></p>
<p><span>Font with red background</span></p>

Can anyone help me?
Thank you,
Giuseppe

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 22,261Questions: 26Answers: 5,122
    edited September 4

    It seems that is the way Quill works. Go to the Quill format example and change the text and background colors. Use the browser's inspect tool to see the generated HTML. For example:

    Datatables doesn't control the HTML generated by Quill.

    Does this answer your questions?

    Does the span cause issues?

    Kevin

  • GargiucnGargiucn Posts: 120Questions: 33Answers: 0

    Thank you for your reply.
    The problem is that quill should not put only the <span></span> tags for colours but should generate something like this:

    <p><strong>Bold font</strong></p>
    <p><em>Italic font</em></p>
    <p><u>Underlined font</u></p>
    <p><span style="color: rgb(230, 0, 0);">Red font</span></p>
    <p><span style="background-color: rgb(230, 0, 0);">Font with red background</span></p>
    

    Instead, he writes <span></span> for colours!!!!
    Giuseppe

  • kthorngrenkthorngren Posts: 22,261Questions: 26Answers: 5,122
    edited September 4

    Instead, he writes <span></span> for colours!!!!

    Do you mean the DB is missing the styles in the span?

    I built this simple test case:
    https://live.datatables.net/guwafemu/646/edit

    Edit any of the Position fields and set the color of some or all the text. The console output shows the style remains and the field shows the updated styles.

    I would start by using the browser's network inspector tool to see the request and response data when performing an edit. What do you see? Post both the request and response data.

    Kevin

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    Is this a problem with the Editor integration with Quill, or is it a problem with the HTML that Quill generates? If you use Quill standalone, I believe it will generate the same HTML with a span, that's just how it works. You'd need to take that up with the Quill developers if you need it to work differently.

    Allan

  • GargiucnGargiucn Posts: 120Questions: 33Answers: 0

    I'm going crazy trying to figure out what the problem is.
    I have another application that uses exactly the same libraries and works perfectly.
    In this one, however, in the quill edit mask, I see all the lines with colours, but when I save to the database, all the other control characters remain, while those relating to colours are saved as <span></span>.
    Unbelievable...

  • GargiucnGargiucn Posts: 120Questions: 33Answers: 0

    Edit row

    Show row

    Alert added in edit

  • kthorngrenkthorngren Posts: 22,261Questions: 26Answers: 5,122

    Have you tried my debugging suggestion above:

    I would start by using the browser's network inspector tool to see the request and response data when performing an edit. What do you see? Post both the request and response data.

    If you see the styles in the span in the request data but not in the JSON response then something is happening in the server to remove the styles.

    Kevin

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    Are you using the PHP Editor libraries? Try adding ->xss(false) to the Field in question. Possibly the XSS protection might be stripping out the style attribute.

    Allan

  • GargiucnGargiucn Posts: 120Questions: 33Answers: 0

    Do I need to write:
    Field::inst( “help_text” ) -> xss(false)
    in the PHP file?
    I'll try that.
    In the meantime, I'm attaching images of the edit sequence.

    Thank you both,
    Giuseppe!

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin
    Answer ✓

    Yes, where you define the Field instance in the PHP, add ->xss(false) to it.

    Allan

  • GargiucnGargiucn Posts: 120Questions: 33Answers: 0

    It works!
    I know I won't understand anything, but would you mind trying to explain it to me even though I'm sure I won't understand a thing?

    Thanks again,
    Giuseppe

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    Sure thing - Editor uses the htmLawed libraries in its PHP libraries to try and help prevent XSS attacks. Unfortunately, part of the way htmLawed works is to strip parts of HTML that it doesn't know about. Normally it isn't an issue since HTML isn't submitted, but obviously in the case of a WYSIWYG editor such as Quill, that becomes important, and in this case results in the need to disable the XSS protection.

    Allan

  • GargiucnGargiucn Posts: 120Questions: 33Answers: 0

    Incredible, I UNDERSTAND!

    Thanks again,
    Giuseppe

Sign In or Register to comment.