KillerCodeMonkey / stencil-quill

Native web components for the Quill Rich Text Editor built with stencil
MIT License
38 stars 7 forks source link
component editor quill quill-editor quilljs renderer rendering rich-text-editor stencil stencil-quill viewer webcomponent webcomponents wysiwyg

stencil-quill Build Status

Native web components for the Quill Rich Text Editor

Built With Stencil

Donate/Support

If you like my work, feel free to support it. Donations to the project are always welcomed :)

PayPal: PayPal.Me/bengtler

Buy Me A Coffee

Examples

Installation

QuillEditor component

HTML-Tag

<quill-editor content="" format="html" theme="snow"></quill-editor>

Config

{
  toolbar: [
    ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
    ['blockquote', 'code-block'],

    [{ 'header': 1 }, { 'header': 2 }],               // custom button values
    [{ 'list': 'ordered'}, { 'list': 'bullet' }],
    [{ 'script': 'sub'}, { 'script': 'super' }],      // superscript/subscript
    [{ 'indent': '-1'}, { 'indent': '+1' }],          // outdent/indent
    [{ 'direction': 'rtl' }],                         // text direction

    [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
    [{ 'header': [1, 2, 3, 4, 5, 6, false] }],

    [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
    [{ 'font': [] }],
    [{ 'align': [] }],

    ['clean'],                                         // remove formatting button

    ['link', 'image', 'video']                         // link and image, video
  ]
};
<quill-component content="test">
  <div slot="quill-toolbar">
    <span class="ql-formats">
      <select class="ql-font">
        <option value="aref">Aref Ruqaa</option>
        <option value="mirza">Mirza</option>
        <option selected>Roboto</option>
      </select>
      <select class="ql-align" title="Aligment">
        <option selected></option>
        <option value="center"></option>
        <option value="right"></option>
        <option value="justify"></option>
      </select>
      <select class="ql-align" title="Aligment2">
        <option selected></option>
        <option value="center"></option>
        <option value="right"></option>
        <option value="justify"></option>
      </select>
    </span>
    <span class="ql-formats">
      <div id="counter"></div>
    </span>
  </div>
</quill-component>

Full Quill Toolbar HTML

Events

editor
{
  editor: editorInstance,
  html: html,
  text: text,
  content: content,
  delta: delta,
  oldDelta: oldDelta,
  source: source
}
{
  editor: editorInstance,
  range: range,
  oldRange: oldRange,
  source: source
}
{
  editor: editorInstance, // Quill
  event: 'text-change' // event type
  html: html, // html string
  text: text, // plain text string
  content: content, // Content - operatins representation
  delta: delta, // Delta
  oldDelta: oldDelta, // Delta
  source: source // ('user', 'api', 'silent' , undefined)
}

or

{
  editor: editorInstance, // Quill
  event: 'selection-change' // event type
  range: range, // Range
  oldRange: oldRange, // Range
  source: source // ('user', 'api', 'silent' , undefined)
}
{
  editor: editorInstance, // Quill
  source: source // ('user', 'api', 'silent' , undefined)
}
{
  editor: editorInstance, // Quill
  source: source // ('user', 'api', 'silent' , undefined)
}

QuillView component

It renders a readOnly quilljs editor without a border and toolbar. Does not provide any Events, but has similar properties.

HTML-Tag

<quill-view content="" format="html" theme="snow"></quill-view>

Config

QuillViewHTML component

It renders an quilljs html string as you would expect it without createing a quilljs instance.

HTML-Tag

<quill-view-html content="" theme="snow"></quill-view-html>

Config

Using the components

Script tag

Node Modules

In a stencil-starter app