【问题标题】:How to implement Quill Emojis in vue2editor?如何在 vue2editor 中实现 Quill Emojis?
【发布时间】:2019-02-07 01:45:02
【问题描述】:

我尝试将 Quill Emojis 添加到编辑器,但出现控制台错误

Uncaught ReferenceError: Quill is not defined

我正在使用 Laravel 5.6 和 vue js,而且对 vue 及其组件肯定是新手,所以我可能听起来很傻,但在过去的 3 天里,我在 google 上搜索解决方案,甚至在 github 上联系了 vue2editor 的作者是the link

这是我迄今为止尝试过的:

vue2editor.vue

<template>
    <div id="app">
        <vue-editor v-model="content"></vue-editor>
    </div>
</template>

<script>
    import { VueEditor, Quill } from 'vue2-editor';
    import Emoji from 'quill-emoji/dist/quill-emoji';
    Quill.register('modules/quill-emoji', Emoji);


    export default {
        name: 'vue2editor',
        components: { VueEditor },
        data() {
            return {
                content: "<h1>Some initial content</h1>",
                editorSettings: {
                    modules: {
                        toolbar: {
                            container: [
                                [{'size': ['small', false, 'large']}],
                                ['bold', 'italic', 'underline', 'strike'],
                                ['blockquote', 'code-block'],
                                [{ 'header': 1 }, { 'header': 2 }],
                                [{ 'list': 'ordered' }, { 'list': 'bullet' }],
                                [{ 'script': 'sub' }, { 'script': 'super' }],
                                [{ 'indent': '-1' }, { 'indent': '+1' }],
                                [{ 'direction': 'rtl' }],
                                [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
                                [{ 'color': [] }, { 'background': [] }],
                                [{ 'font': [] }],
                                [{ 'align': [] }],
                                ['clean'],
                                ['link', 'image', 'video'],
                                ['emoji'],
                            ],
                            handlers: {
                                'emoji': function () {}
                            },
                        },
                        toolbar_emoji: true,
                        short_name_emoji: true,
                        textarea_emoji:true,
                    },
                },
                text: null,
            };
        },
    };
</script>

我什至尝试了 github 上一位用户提到的 Quill-Emoji 方法,这里是 link

我满怀希望来到这里;如果这里有人要帮助我,至少告诉我我缺少什么对我来说不仅仅是帮助。

【问题讨论】:

标签: laravel vue.js vuejs2 vue-component laravel-5.6


【解决方案1】:
Quill.register({
'formats/emoji': Emoji.EmojiBlot,
'modules/short_name_emoji': Emoji.ShortNameEmoji,
'modules/toolbar_emoji': Emoji.ToolbarEmoji,
'modules/textarea_emoji': Emoji.TextAreaEmoji}, true); 

您需要注册模型,将up代码添加到您的代码中。

【讨论】:

    【解决方案2】:

    编辑:

    //1) Add plugin to laravel mix
    
        const mix = require('laravel-mix')
        mix.webpackConfig(webpack => {
            return {
                plugins: [
                    new webpack.ProvidePlugin({
                        "window.Quill": "quill/dist/quill.js",
                        Quill: "quill/dist/quill.js"
                    })
                ]
            };
        });
    
    
    //2 example vue file
    
    
     
    
    <template>
          <div class="mt-1">
            <vue-editor
              ref="editor"
              v-model="content"
              :editor-toolbar="customToolbar"
              :editorOptions="editorSettings"
            />
        
    
          </div>
        </template>
        <script>
        import { VueEditor, Quill } from "vue2-editor";
        
        import Emoji from "quill-emoji/dist/quill-emoji";
        Quill.register("modules/emoji", Emoji);
        
        export default {
          components: {
            VueEditor,
          },
          props: {
            bubble: Object,
            contentCol: {
              type: String,
            },
          },
          data() {
            return {
              edit: false,
              content: "<b>Content is here</b>",
              customToolbar: [["bold", "italic", "underline"], ["link"], ["emoji"]],
              editorSettings: {
                modules: {
                  "emoji-toolbar": true,
                  "emoji-textarea": true,
                  "emoji-shortname": true,
                },
              },
            };
          },
          beforeDestroy() {},
        
         
        };
        </script>
        
        <style  src="quill-emoji/dist/quill-emoji.css"/>
    

    【讨论】:

      猜你喜欢
      • 2022-11-10
      • 2020-03-03
      • 2020-05-19
      • 2018-03-15
      • 2019-02-08
      • 1970-01-01
      • 2021-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多