patleeman / quill-markdown-shortcuts

Quill.js module that converts markdown to rich text formatting while typing.
https://patleeman.github.io/quill-markdown-shortcuts/
140 stars 49 forks source link

Issue with quill mentions #22

Closed satyapendem closed 5 years ago

satyapendem commented 5 years ago

Hi I'm using Quill-Mentions with MarkdownShortCuts(https://github.com/patleeman/quill-markdown-shortcuts).


    <div class="container">
        <div id="editor"></div>
        <script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.6/quill.js'></script>
        <script src="https://cdn.jsdelivr.net/npm/quill-markdown-shortcuts@latest/dist/markdownShortcuts.js"></script>
        <script src="quillMention.js"></script> <!-- quill mention dist file-->

        <script>
            Quill.register('modules/markdownShortcuts', MarkdownShortcuts);
            const atValues = [
                { id: 1, value: 'satya' },
                { id: 2, value: 'sandy' }
            ];
            const hashValues = [
                { id: 3, value: 'Fredrik Sundqvist 2' },
                { id: 4, value: 'Patrik Sjölin 2' }
            ]
            var quill = new Quill('#editor', {
                theme: 'snow',
                modules: {
                    markdownShortcuts: {},
                    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);
                            }
                        },
                    }

                }
            });
        </script>
    </div>
</body>```

here is my code. https://cl.ly/ad07c5ee8c53 . I'm facing problem first if do mention
kaatt commented 5 years ago

@satyapendem Did you figure this out? I'm facing the same issue.