I’d like to use the Quill editor with some custom toolbar buttons. I can customize the toolbar itself by rearranging the built-in toolbar buttons using code like this:
self.quill_1.toolbar = [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
['clean']
]
And I can create a handler in Python for any of those built-in buttons:
toolbar = self.quill_1.get_module('toolbar')
toolbar.addHandler('bold', self.bold)
def bold(self, args):
print("called")
print(args)
Where I’m having issues is twofold.
Problem #1
I haven’t been able to work out how to get a new toolbar image into the app. The suggestions I’m finding online involved code like this:
icons = self.quill_1.import('ui/icons');
But import isn’t a legal Python method name, so I can’t use that part of Quill’s API, if it’s even exposed.
I also tried just filling the button with a red square with this CSS, but it did not work:
.ql-toolbar .ql-foo {
fill: red;
}
Problem #2
I haven’t been able to hook up a handler for the custom button. Doing the same thing from above for a custom button tag:
self.quill_1.toolbar = [
['bold', 'italic', 'underline', 'strike', 'foo'],
['blockquote', 'code-block'],
['clean']
]
toolbar = self.quill_1.get_module('toolbar')
toolbar.addHandler('foo', self.foo)
def foo(self, args):
print("called")
The space for the toolbar button is reserved in the toolbar with a div, the same as all the others, but clicking it does not trigger the handler function.
I don’t know if this has to do with the lack of an image or something else.
Here’s a clone link. The QuillTesting form has the code I have so far.