JSPM

quill-hashtag

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27
  • Score
    100M100P100Q59262F
  • License MIT

#hashtags for the Quill rich text editor

Package Exports

  • quill-hashtag

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (quill-hashtag) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Quill Mention

License: MIT

Quill Mention is a module to provide @mentions functionality for the Quill rich text editor.

Getting Started

Install

Install with npm:

npm install quill-hashtag --save

Install with Yarn:

yarn add quill-hashtag

Example

const values = [
  { id: 1, value: 'Hashtag1' },
  { id: 2, value: 'Hashtag' }
];
const quill = new Quill(editor, {
  modules: {
    mention: {
      allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
      source: function (searchTerm) {
        if (searchTerm.length === 0) {
          this.renderList(values, searchTerm);
        } else {
          const matches = [];
          for (i = 0; i < values.length; i++)
            if (~values[i].value.toLowerCase().indexOf(searchTerm)) matches.push(values[i]);
          this.renderList(matches, searchTerm);
        }
      },
    },
  }
});

Settings

Property Default Description
source(searchTerm) null Required callback function to handle the search term and connect it to a data source for matches. The data source can be a local source or an AJAX request. The callback should call this.renderList(matches, searchTerm); with matches of JSON Objects in an array to show the result for the user. The JSON Objects should have id and value but can also have other values to be used in renderItem for custom display.
renderItem(item) function A function that gives you control over how matches from source are displayed.
allowedChars [a-zA-Z0-9_] Allowed characters in search term triggering a search request using regular expressions
minChars 0 Minimum number of characters after the @ symbol triggering a search request
maxChars 31 Maximum number of characters after the @ symbol triggering a search request
offsetTop 2 Additional top offset of the mention container position
offsetLeft 0 Additional left offset of the mention container position

License

This project is licensed under the MIT License - see the LICENSE file for details