简体   繁体   English

任何人都知道我如何在 NuxtJs 中使用 CkEditor?

[英]Anyone knows how i can use CkEditor in NuxtJs?

I have been trying to implement an CkEditor, but i haven't made any success.我一直在尝试实现 CkEditor,但我没有取得任何成功。 I have created an online-builder from https://ckeditor.com/ckeditor-5/online-builder/ .我从https://ckeditor.com/ckeditor-5/online-builder/创建了一个在线构建器。

-I have instaled: "@ckeditor/ckeditor5-build-classic": "^25.0.0", "@ckeditor/ckeditor5-vue2": "^1.0.5", -我已安装:“@ckeditor/ckeditor5-build-classic”:“^25.0.0”、“@ckeditor/ckeditor5-vue2”:“^1.0.5”、

picture of files organization that i use i我使用的文件组织图片

And here is my component:这是我的组件:

***in components/ckEditor***

<template>
  <div class="editor">
  </div>
</template>
<script src="/build/ckeditor.js"></script>
<script>

  ClassicEditor.create(document.querySelector('.editor'), {

    toolbar: {
      items: [
        'heading',
        '|',
        'undo',
        'redo',
        '|',
        'bold',
        'italic',
        '|',
        'fontColor',
        'fontBackgroundColor',
        'fontFamily',
        'fontSize',
        '|',
        'link',
        '|',
        'bulletedList',
        'numberedList',
        'indent',
        'outdent',
        '|',
        'imageUpload',
        'mediaEmbed',
        '|',
        'insertTable'
      ]
    },
    language: 'pt-br',
    image: {
      toolbar: [
        'imageTextAlternative',
        'imageStyle:full',
        'imageStyle:side',
        'linkImage'
      ]
    },
    table: {
      contentToolbar: [
        'tableColumn',
        'tableRow',
        'mergeTableCells'
      ]
    },
    licenseKey: '',

  })
    .then(editor => {
      window.editor = editor;
    })
    .catch(error => {
      console.error(error);
    });
</script>

<style scoped>
</style>

and here is how use my component:以下是如何使用我的组件:

*** in pages/index.vue***
<template>
  <div class="container grid">
    <CkCadastroLoja/>
  </div>
</template>

I have read the documentation from from CkEditor for vue2, and vue3, but didnt manage to make it work.我已经阅读了来自 CkEditor 的关于 vue2 和 vue3 的文档,但没有设法让它工作。 Can anyone help me?谁能帮我?

I have solved the problem!!我已经解决了问题!!

If you are searching for an RichText editor for Nuxt version 2.14 to 2.15, use Quilljs!!如果您正在寻找 Nuxt 版本 2.14 到 2.15 的 RichText 编辑器,请使用 Quilljs!

Its awsome, and there is this tutorial for it: https://www.programmersought.com/article/4960245701/ ,它太棒了,有这个教程: https://www.programmersought.com/article/4960245701/

and its own git that is super helpful!!和它自己的 git 超级有用!! https://github.com/quilljs/quill https://github.com/quilljs/quill

you can face problems with the seting up, depending on your component, and the solution to the last part of the tutorial is an example of component.您可能会遇到设置问题,具体取决于您的组件,本教程最后一部分的解决方案是组件示例。

dont use the不要使用

  <section class="container">
    <div class="quill-editor" 
         :content="content"
         @change="onEditorChange($event)"
         @blur="onEditorBlur($event)"
         @focus="onEditorFocus($event)"
         @ready="onEditorReady($event)"
         v-quill:myQuillEditor="editorOption">
    </div>
  </section>

just use只需使用


    <div class="quill-editor container" 
         :content="content"
         @change="onEditorChange($event)"
         @blur="onEditorBlur($event)"
         @focus="onEditorFocus($event)"
         @ready="onEditorReady($event)"
         v-quill:myQuillEditor="editorOption">
    </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM