npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

quill-mention-vue2-editor

v2.1.0

Published

@mentions for the Quill rich text editor

Downloads

393

Readme

Quill Mention

Quill Mention with vue2-editor support

npm version License: MIT

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

Demo

https://afconsult.github.io/projects/quill-mention/

Mention Demo GIF

Getting Started

Install

Install with npm:

npm install quill-mention --save

Install with Yarn:

yarn add quill-mention

Example

const atValues = [
  { id: 1, value: 'Fredrik Sundqvist' },
  { id: 2, value: 'Patrik Sjölin' }
];
const hashValues = [
  { id: 3, value: 'Fredrik Sundqvist 2' },
  { id: 4, value: 'Patrik Sjölin 2' }
]
const quill = new Quill('#editor', {
      modules: {
        mention: {
          allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
          mentionDenotationChars: ["@", "#"],
          source: function (searchTerm, renderList, mentionChar) {
            let values;

            if (mentionChar === "@") {
              values = atValues;
            } else {
              values = hashValues;
            }

            if (searchTerm.length === 0) {
              renderList(values, searchTerm);
            } else {
              const matches = [];
              for (i = 0; i < values.length; i++)
                if (~values[i].value.toLowerCase().indexOf(searchTerm.toLowerCase())) matches.push(values[i]);
              renderList(matches, searchTerm);
            }
          },
        },
      },
      getMentions: function() {
        // Dummy example to get all the mentions.
        var marvelDelta = this.$refs.editor.quill.editor.delta
        var mentionDelta = _.filter(marvelDelta.ops, 'insert.mention'); // lodash
        var mentions = _.map(mentionDelta, function(value){
            return _.toInteger(_.get(value, 'insert.mention.id'));
        });
        return mentions;
      },
    });

Settings

| Property | Default | Description | | -------------------- | -------------- | ------------ | | source(searchTerm, renderList, mentionChar) | 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 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, searchTerm) | function | A function that gives you control over how matches from source are displayed. You can use this function to highlight the search term or change the design with custom HTML. | | 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 | | mentionDenotationChars | ["@"] | Specifies which characters will cause the mention autocomplete to open | isolateCharacter | false | Whether or not the denotation character(s) should be isolated. For example, to avoid mentioning in an email. | fixMentionsToQuill | false | When set to true, the mentions menu will be rendered above or below the quill container. Otherwise, the mentions menu will track the denotation character(s); |showDenotationChar | true | Whether to show the used denotation character in the mention item or not | defaultMenuOrientation | 'bottom' | Options are 'bottom' and 'top'. Determines what the default orientation of the menu will be. Quill-mention will attempt to render the menu either above or below the editor. If 'top' is provided as a value, and there is not enough space above the editor, the menu will be rendered below. Vice versa, if there is not enough space below the editor, and 'bottom' is provided as a value (or no value is provided at all), the menu will be rendered above the editor. | dataAttributes | ['id', 'value', 'denotationChar', 'link', 'target'] | A list of data values you wish to be passed from your list data to the html node. (id, value, denotationChar, link, target are included by default). | onOpen | function | Callback when mention dropdown is open. | onClose | function | Callback when mention dropdown is closed. |onSelect(item, insertItem) | function | Callback for a selected item. When overriding this method, insertItem should be used to insert item to the editor. This makes async requests possible. | linkTarget | '_blank' | Link target for mentions with a link | listItemClass | 'ql-mention-list-item' | Style class to be used for list items (may be null) | mentionContainerClass | 'ql-mention-list-container' | Style class to be used for the mention list container (may be null) | mentionListClass | 'ql-mention-list' | Style class to be used for the mention list (may be null)

Authors

Fredrik Sundqvist (MadSpindel)

See also the list of contributors who participated in this project.

License

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