Quill - saving the formatted text

Quill - saving the formatted text

mccloudmccloud Posts: 35Questions: 15Answers: 2
edited February 2017 in Editor

I have created a datatable using the online generator, and added Quill to the .js file.

"label": "Comment:",
    "name": "comment", 
        "type": "quill" 

How do I get it to keep the formatted text upon submit.? At the moment it just saves everything without spaces etc.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    I'm seeing the same. For example the bullet list or bold text i create is not sent to the server. Just the plain text. I'm more interested in the bullet list then text formatting.

    Any ideas?

    Kevin

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    I've slightly misunderstood how the new Quill API works which is what is causing this error I'm afraid. They focus on using delta objects to describe the content rather than using HTML. Great as an abstraction, but it isn't as useful for working with HTML as I think the majority of cases will be for this.

    What to do is update the set and get functions in the Editor / Quill plug-in to be:

        get: function ( conf ) {
            return conf._quill.root.innerHTML;
        },
     
        set: function ( conf, val ) {
            conf._quill.root.innerHTML = val !== null ? val : '';
        },
    

    This thread is fairly enlightening on the topic.

    Allan

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Interesting read.

    The change is not working for me. When I exit the field the plugin doesn't complete processing. I console.log statements in the get and set functions. Before making the change I would see this pattern when exiting the updated field:

    (2)get
    (2)set
    (2)get

    After the change I don't see the set function running. All I see is this:
    (2)get

    Don't know if that helps. Let me know if I can provide more info.

    Kevin

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Weird! does the console show anything else? Or is it cooking your processor?

    Allan

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    edited March 2017

    Guess I worked on it too early this morning - on my first coffee :smile:

    Short story: It does work!

    Long story: The page I'm working on has two quill fields. One field I want to have the formatting. The other I want to be a plain text file for YAML data. The YAML was working as desired as plain text. When I applied the change it appeared as though the script was stopping and not updating using inline editing.

    The problem I found is that the YAML field was also updated behind the scenes and both fields were sent to the server for updating. My validation verifies the YMAL syntax and was failing due to the HTML formatting being added. My server script returned a field error for the YAML field but since I was editing the other field the error never showed. Which on the surface looked like the script failed.

    Maybe there is an issue with either two fields being sent during inline editing or that the non-edited field needs to display the field error.

    For this particular page I'm using two versions of the plugin. The original for the plain text field and the updated for the other field.

    EDIT: thats why there is the 2 in parenthesis because both fields are being accessed even though I'm only editing one during inline edit.

    Kevin

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Another aspect of my tables is to edit and save some of the HTML used by my web pages, such as sidebars, etc using Quill. The root.innerHTML changes caused problems with the HTML fields being saved. For example it saves   instead of white space. So, for this I went back to the original using getText and setText.

    Although for other fields I want the formatting so still using the root.innerHTML version for those.

    Sometimes you need to be careful of what you ask for :smile:

    Kevin

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Hmmm. I can't help but wonder if something like this might make a better candidate as the "recommended" approach for wysiwyg in Editor. Or if anyone has any other suggestions...

    Allan

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    And two more:

This discussion has been closed.