quilljs / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility.

Home Page:https://quilljs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add attributes from toolbar options

lughino opened this issue · comments

Starting from a simple addition of features like to add tooltips to the buttons, I looked into your file and found an example where just add your toolbar by creating an html markup.
While this is very good, it is often more useful to generate the toolbar through the options.
It would be very useful to be able to pass the attributes to the options so that these are attached to the elements.
For example like this:

const toolbarOptions = [
    [
      { 'bold': {  
          attributes: { 
            'data-toggle': 'tooltip', 
            'data-placement': 'bottom', 
            'title': 'Bold' 
          }
        } 
      }, 'italic', 'underline', 'strike'],
   // other options..
  ];

I think this adds a simple but powerful additional customization without touching the html.

Really simple feature, and enhances the UI with a standard means of helping users.

Would be a great enhancement to a great product.

I don't want Quill's toolbar to be an endlessly configurable HTML generator. You can always pass in custom HTML toolbar container for advanced use cases and Quill will attach to those inputs. For quick simple use cases Quill recognizes a simple list of formats.

Is can be debated forever where the "quick simple" line should be and how far it can be extended but the core Quill project has drawn that line where it feels is the right balance between simplicity and power.

Those that disagree please feel free to extend the Toolbar module and publish separately to npm if you would like to share with others. The naming convention is quill-yourname-module. For example quill-image-drop-module is a recent community contributed module that extends Quill for use cases the core does not cover. We are in the process of creating a curated list of high quality community contributed modules.

怎么添加控制文本行间距