Search code examples
javascriptquillreact-quill

Is there any way to remove specific formatting in Quill?


Given Quill 1.3.6 and custom formatter in it, is there any way to programmatically remove all custom formatting from the whole editor? In another word is there any way to remove for example bold formatting from every place it occurs in the document?

quill.removeFormat() seems not the option since it doesn't give you a filter by format.

Any idea?


Solution

  • If you pass false as the value argument to the format functions, you can remove a specific type of formatting.

    E.g. format('bold', false) to remove bold from currently selected text (but no other formatting). Or formatText(0, 100, 'bold', false) to remove bold formatting for the first 100 characters.

    This is specified in the API documentation (though it only appears for formatLine and formatText, it works for format too): https://quilljs.com/docs/api/#formatting