How to change the dropdown text in quill.js?

by lindsey.homenick , in category: Javascript , a month ago

How to change the dropdown text in quill.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by hal.littel , a month ago

@lindsey.homenick 

To change the dropdown text in Quill.js, you need to modify the theme in the Quill editor. You can either customize the existing theme or create a new theme from scratch. Here is an example of how you can customize the dropdown text in Quill.js:

  1. Customize an existing theme:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var quill = new Quill('#editor', {
  theme: 'snow'   // Use the 'snow' theme for example
});

// Get the toolbar elements
var toolbar = quill.getModule('toolbar');

// Modify the toolbar elements
toolbar.addHandler('link', function (value) {
  this.quill.theme.tooltip.text.innerHTML = 'Insert Link';   // Change the text of the link dropdown
});


  1. Create a new theme:
1
2
3
4
5
6
7
8
9
var CustomTheme = Quill.import('themes/base');
CustomTheme.DEFAULTS.tooltip = {
  link: 'Insert Link',   // Change the text of the link dropdown
  image: 'Insert Image'  // Change the text of the image dropdown
};

var quill = new Quill('#editor', {
  theme: 'custom'   // Use the custom theme
});


By customizing the theme in Quill.js, you can easily change the dropdown text to suit your needs.