3

I have looked around the Quill documentation, GitHub topics, and here in Stack Overflow and I have been unable to find a simple example of using the format attribute. I would like to limit my users so that they can only bold, italicize, underline, and hyperlink text.

From what I understand, this can be achieved with a format whitelist, but I have only been able to find examples regarding custom fonts or other more complex properties.

Thank you for your time!

Nick
  • 81
  • 1
  • 6

1 Answers1

5

I did some more digging around and found the answer. The following creates a Quill editor that allows only bold, italics, underline, and links. The list of allowed formats is just an array, and all omitted formats will not be allowed in the editor, so they won't show up if a user pastes text.

var toolbarOptions = [['bold', 'italic', 'underline'],['link'],['clean']];
var formatWhitelist = ['bold','italic','link'];

var quill = new Quill('#notification-message', {
    scrollingContainer: 'true',
    theme: 'snow',
    formats: formatWhitelist,
    modules: {
        toolbar: toolbarOptions
    }
});
Nick
  • 81
  • 1
  • 6