MSK
MSK

Reputation: 401

Quill remove colour from pasted text

I am using React Quill and want to remove colour from pasted text, so that quill should show text in black colour only. I have tried Clipboard module but not able to understand how to remove colour. Has anyone achieved this?

Thanks, MSK

Upvotes: 2

Views: 3016

Answers (2)

user3266237
user3266237

Reputation: 51

Yes, you can register the color module and whitelist:

const ColorAttributor = Quill.import("attributors/style/color");
ColorAttributor.whitelist = [];
Quill.register(ColorAttributor);

Upvotes: 0

Ben Browitt
Ben Browitt

Reputation: 1872

Quill has config option with a list of allowed formats.

Demo that whitelist only link and size: https://codepen.io/anon/pen/xBWved

var quill = new Quill('#editor-container', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      ['image', 'code-block']
    ]
  },
  formats: ['link', 'size'],
  placeholder: 'Compose an epic...',
  theme: 'snow'  // or 'bubble'
});

List of all supported formats: https://quilljs.com/docs/formats/

Upvotes: 2

Related Questions