How to remove or change the default font in quill.js?

by ryan.murray , in category: Javascript , 2 months ago

How to remove or change the default font in quill.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , 2 months ago

@ryan.murray 

To remove or change the default font in Quill.js, you can use the following steps:

  1. Change the default font:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
var quill = new Quill('#editor', {
  theme: 'snow',
  formats: ['bold', 'italic', 'underline', 'strike'],
  toolbar: {
    container: '#toolbar'
  }
});

quill.getModule('toolbar').addHandler('font', function(value) {
  this.quill.format('font', value);
});

quill.on('text-change', function(delta, oldDelta, source) {
  if (source == 'user') {
    // Save your changes here
  }
});


  1. Remove the default font:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
var quill = new Quill('#editor', {
  theme: 'snow',
  formats: ['bold', 'italic', 'underline', 'strike'],
  toolbar: {
    container: '#toolbar'
  }
});

quill.getModule('toolbar').addHandler('font', function() {
  this.quill.format('font', false);
});

quill.on('text-change', function(delta, oldDelta, source) {
  if (source == 'user') {
    // Save your changes here
  }
});


By following these steps, you can change or remove the default font in Quill.js.