quill icon indicating copy to clipboard operation
quill copied to clipboard

Make the tooltip save method extendable

Open ghost opened this issue 9 years ago • 1 comments

It's not a bug, it's a feature request

I would like to add a tooltip to handle image-links

I am opening the image-links tooltip with

this.quill.tooltip.edit('image-link') but it's not possible to handle the save of it because the implementation is hardcoded as a switch, and cant be extended without replacing the whole save method.

https://github.com/quilljs/quill/blob/189563a27fe18ef97688d948d458eabe316db1d3/themes/base.js#L203

I think it would be better to move the save methods to a map, and call them from the save method directly instead of the switch statement.

saveMethods = {
  image(value) {  },
  video(value) { }
}
save() {
    let value = this.textbox.value;
    const mode = this.root.getAttribute('data-mode');
    if (typeof this.saveMethods[mode] === "function") {
       this.saveMethods[mode](value)
    }    

    this.textbox.value = '';
    this.hide();
}

I am not sure how to add saveMethods, but if you like it, you can ping me, and I'll create a PR

What do you think guys?

ghost avatar Oct 25 '16 11:10 ghost

Any updates here? I would like to use this.

baturian avatar Aug 10 '22 17:08 baturian