How to add a custom dropdown aka picker to the quill toolbar?
See original GitHub issueOkay so I spent quite some time researching this question and trying various solutions - without success.
How can I add my custom dropdown menu (aka “picker”) to the quill toolbar?
Here are some - all non-working - approaches I tried so far:
1. Using HTML
<div id="toolbar">
<select class="ql-myDropdown">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>
</div>
<div id="editor">
</div>
2. Using JavScript in a new Quill instance
var quill = new Quill('#editor', {
modules: {
toolbar:
[
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'size': ['small', false, 'large', 'huge'] }],
['bold', 'italic', 'underline', 'strike',],
[{ 'myDropdown': ['Option 1', 'Option 2', 'Option 3', 'Option 4', 'Option 5'] }],
['clean']
]
},
theme: 'snow'
});
3. Using a quill import
var myDropdown = quill.import('ui/picker');
myDropdown = ['Option 1', 'Option 2', 'Option 3', 'Option 4', 'Option 5'];
quill.register(myDropdown, true);
While 2. is the most promising solution - as it does add a picker at the right place and inside Quill; but the heck - it’s just an empty dropdown list?
So honestly I think it would be great, if adding custom dropdowns to Quill would also be explicitely covered in the quill docs. Same as for regular click-buttons.
Thanks for any help! Oliver
P.s. a related question has been closed without any insights #1543
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:13
Top Results From Across the Web
Cannot Get Custom Dropdown to Work in QuillJS Editor
Any help would be appreciated. Ideally, I want the dropdown to show up in the toolbar and add the select option text as...
Read more >Adding a custom drop-down toolbar to react-quill
It is surprisingly unintuitive to add a custom drop-down toolbar to `quilljs`. ... 'react-quill/dist/quill.snow.css'; import ReactQuill from 'react-quill'; ...
Read more >Toolbar Module - Quill Rich Text Editor
Quill is a free, open source WYSIWYG editor built for the modern web. Completely customize it for any need with its modular architecture...
Read more >Add Custom Button In Footer Ngx-Quill - ADocLib
How to add a custom dropdown aka picker to the quill toolbar ? hot 2. quill npm install quill emoji Configure for CSS...
Read more >A look at Quill.js
Quill provides a simple framework for adding buttons to your toolbars just add them to your toolbar configuration and style them with css,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So a good soul @quannt over here provided me a jsfiddle demonstrating, what one needs in order to add a custom dropdown picker in Quill: https://jsfiddle.net/q7jferw3/
Thanks again!!
Quill uses CSS pseudo class to specify content for each toolbar dropdown menu, so do the menu label.
For example:
then for the easy part, define the handler:
addition: maybe you need to manually specify a padding for the picker label, otherwise it will overlap the pseudo class content.
I traced through the source code to derive this solution.