Skip to content
Advertisement

Adding a custom drop down tool to the Quill Editor with JavaScript

Please note this is a self-answered question.

The Quill Editor’s toolbar module doesn’t appear to offer a way to add custom tools to it using the JavaScript API. You can merely choose from a list of predefined tools or you have to completely rewrite the entire HTML of the toolbar which seems very hacky and often is not an option. Because of that mechanism, tools can’t just be added or removed during runtime and are always static, meaning that (for example) you can’t have a dynamic drop down list that loads or changes it’s entries during runtime.

The Quill Editor itself only offers an API to add another module. So you could write another toolbar module that supports the above mentioned features the original one is lacking, but it would be much nicer to be able to continue using the original one because of the amount of work that would be required to effectively rewrite it.

The question is: How to add a potentially dynamic tool like a drop down menu to an existing Quill Editor instance’s toolbar.

Advertisement

Answer

I wrote a library called DynamicQuillTools which can do the job.

It can be used like this:

JavaScript

Here is a full demo adding a custom drop down tool and a custom button to a Quill Editor instance:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement