我从经典版本构建了自定义CKEditor5。
git clone -b stable https://github.com/my/forked/repo
cd ckeditor5
npm install
npm run build
在我的VUE2项目的main.js
import 'path/to/ckeditor5/build/editor.js'
Vue.prototype.editor = window.ClassicEditor
在我的组件中
<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>
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)
我可以获取div.editor
元素,但是在创建编辑器时显示错误。
答案 0 :(得分:2)
此错误来自错误的Babel移植。它已在Babel端和CKEditor 5端进行了跟踪,希望很快会得到修复。我们在React集成中听说过类似的问题。
我建议现在更改构建过程并使用旧版本的babel。或不要翻译代码。