VUE 中的 CKEditor5 自定义构建
CKEditor5 custom build in VUE
我从经典版构建了我的自定义 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
元素,但在创建编辑器时显示错误。
这个错误来自不正确的 Babel 转译。它在 Babel 端和 CKEditor 5 端都被跟踪,希望能尽快修复。我们在 React 集成中听说过类似的问题。
- https://github.com/babel/babel/issues/8913
- https://github.com/facebook/create-react-app/issues/5387
- https://github.com/ckeditor/ckeditor5-react/issues/41#issuecomment-428716100
我建议更改构建过程并暂时使用旧版本的 babel。或者不转译代码。
我从经典版构建了我的自定义 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
元素,但在创建编辑器时显示错误。
这个错误来自不正确的 Babel 转译。它在 Babel 端和 CKEditor 5 端都被跟踪,希望能尽快修复。我们在 React 集成中听说过类似的问题。
- https://github.com/babel/babel/issues/8913
- https://github.com/facebook/create-react-app/issues/5387
- https://github.com/ckeditor/ckeditor5-react/issues/41#issuecomment-428716100
我建议更改构建过程并暂时使用旧版本的 babel。或者不转译代码。