简体   繁体   English

VUE中的CKEditor5自定义构建

[英]CKEditor5 custom build in VUE

I built my custom CKEditor5 from classic edition. 我从经典版本构建了自定义CKEditor5。

git clone -b stable https://github.com/my/forked/repo
cd ckeditor5
npm install
npm run build

In my VUE2 project's main.js 在我的VUE2项目的main.js

import 'path/to/ckeditor5/build/editor.js'
Vue.prototype.editor = window.ClassicEditor

In my component 在我的组件中

<template>
  <div class="root">
    <div class="editor></div>
  </div>
</template>
<script>
  export default{
    mounted(){
      var vm = this;
      var ClassicEditor = vm.ClassicEditor;
      ClassicEditor.create(vm.$el.querySelector('.editor'))
    }
  }
</script>

I got error when ClassicEditor.create(...) : ClassicEditor.create(...)时出现错误:

Uncaught (in promise) TypeError: Cannot read property '0' of undefined
    at Object.to (ckeditor.js?ccdb:44)
    at new ea (ckeditor.js?ccdb:342)
    at new Ac (ckeditor.js?ccdb:479)
    at new Bc (ckeditor.js?ccdb:504)
    at Eg.qc (ckeditor.js?ccdb:20)
    at Eg.Vl (ckeditor.js?ccdb:20)
    at new Eg (ckeditor.js?ccdb:20)
    at eval (ckeditor.js?ccdb:20)
    at new Promise (<anonymous>)
    at Function.create (ckeditor.js?ccdb:20)

I can get the div.editor element but show the error when create editor. 我可以获取div.editor元素,但在创建编辑器时显示错误。

This error comes from the incorrect Babel transpilation. 此错误来自错误的Babel转换。 It's tracked on both Babel side and CKEditor 5 side and hopefully will be fixed soon. 它已在Babel端和CKEditor 5端进行了跟踪,希望很快会得到修复。 We've heard about similar problems in our React integration. 我们在React集成中听说过类似的问题。

I'd recommend to change the build process and to use an older version of babel for now. 我建议现在更改构建过程并使用旧版本的babel。 Or to do not transpile the code. 或不要翻译代码。

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

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