qpam

brings autocomplete to Quill placeholder module

  • qpam

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
qpam
1.0.4-64 years ago4 years agoMinified + gzip package size for qpam in KB

Readme

quill-placeholder-autocomplete
brings autocomplete to quill-placeholder-module

Install

  • using NPM:
``` npm install --save quill-placeholder-autocomplete-module quill-placeholder-module ```
  • using yarn:
``` yarn add quill-placeholder-autocomplete-module quill-placeholder-module ```

Usage

import getPlaceholderModule from 'quill-placeholder-module';
import getAutocompleteModule from 'quill-placeholder-autocomplete-module';

Quill.register('modules/placeholder', getPlaceholderModule(Quill,  { 
  className: 'ql-placeholder-content',  // default 
}));
Quill.register('modules/autocomplete', getAutocompleteModule(Quill));

const placeholders = [
  {id: 'foo', label: 'Foo'},
  {id: 'required', label: 'Required', required: true}
]

var quill = new Quill('#editor', {
  modules: {
    toolbar: {container: `#toolbar`},
    placeholder: {
      delimiters: ['{', '}'],               // default
      placeholders
    },
    autocomplete: {
      getPlaceholders: () => placeholders       // factory
      container: '#completions',               // can also be return of `document.querySelector` or keeped to `undefined`
      onOpen: () => console.log('opened'),    // optional
      onClose: (placeholder) => console.log('user choosed:', placeholder),  //optional
    }
  },
  placeholder: 'Compose an epic...',
  theme: 'snow'
});