Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
937 views
in Technique[技术] by (71.8m points)

reactjs - Quill Editor Unable to create mention blot in Vue js

I use VueJS and Quill Editor in my project. Also I want to use quill-mention. Everything is Okay but when I select any option of mention, it shows me this error:

[Parchment] Unable to create mention blot

This is my code, I have done everything fine but cant seem to find the problem, please help.

[ Snapshot of error ][1]

    import 'quill/dist/quill.snow.css';
    import 'quill-mention/dist/quill.mention.min.css';

    import {quillEditor} from 'vue-quill-editor';
    
    import mention from 'quill-mention';
    Quill.register({
        'modules/mention': mention
    });

    export default {
        components: {
            quillEditor
        },

        props: {
            toolbar: { default: false },
            name:{default: ''},
            id: { default: '' },
            value: { default: '' },
            placeholder: { default: ''}
        },

        data() {
            return {
                editorOption: {
                    modules: {
                        toolbar: [
                            [{'font': []}],
                            [{'header': [1, 2, 3, 4, 5, 6, false]}],
                            [{'align': []}, {'color': []}, {'background': []}],
                            ['blockquote', {'direction': 'rtl'}],
                            ['bold', 'italic'],
                            ['underline', 'strike'],
                            [{'indent': '-1'}, {'indent': '+1'}],
                            [{'list': 'ordered'}, {'list': 'bullet'}],
                            ['link', 'image']
                        ],
                        mention: {
                            allowedChars: /^[A-Za-zs]*$/,
                            mentionDenotationChars: ["@"],
                            offsetLeft : ($('body').hasClass('rtl') ? -250 : 0 ) ,
                            renderItem :function(item){
                                return item.display
                            },
                            source: function (searchTerm, renderList, mentionChar) {
                                var values = [
                                    { display: 'John', value: 'Fredrik Sundqvist' },
                                    { display: 'Sara', value: 'Patrik Sj?lin' }
                                ];

                                if (searchTerm.length === 0) {
                                    renderList(values, searchTerm);
                                } else {
                                    const matches = [];
                                    for (var i = 0; i < values.length; i++)
                                        if (~values[i].value.toLowerCase().indexOf(searchTerm.toLowerCase())) matches.push(values[i]);
                                    renderList(matches, searchTerm);
                                }
                            }
                        }
                    },
                    placeholder: 'aaaaaaaaaaaaaaaaa',
                    theme: 'snow'  // or 'bubble'
                },
                content: ''
            }
        },

        created() {
            .....
        },

        computed: {
           .......
        }
    };
</script>```


  [1]: https://camo.githubusercontent.com/de3fd74f305f8381d58c220d8503efc6f2ccbb2b6f0d74aab89a8e76a4771612/68747470733a2f2f692e696d6775722e636f6d2f61415162536c622e676966
question from:https://stackoverflow.com/questions/65641819/quill-editor-unable-to-create-mention-blot-in-vue-js

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...