我有一个CKEditor5插件的想法,但配置一切似乎是压倒性的和复杂的。所以几乎不知道如何开始。有什么方法可以测试我对插件的想法是否值得深入了解这个项目?一些分步指南将有所帮助。
我发现至少有两种方法。您可以在CKEditor5的手动测试中编写一些简单的概念验证插件,或者扩展CKEditor5的一个版本。
CKEditor5代码由预先配置的webpack编译和提供,因此您只需担心编写正确的插件代码。您还可以使用手表模式实时反映简单插件的变化。 Webpack还使用包含简单插件的test重建页面。
npm install -g yarn mgit2
git clone https://github.com/ckeditor/ckeditor5.git
cd ckeditor5
mgit sync
yarn install
ckeditor5/packages/ckeditor5-core/tests/manual/article.js
。您可以在此文件中编写插件yarn run manual -sw --files=core/manual/article.js
http://localhost:8125
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
class SimplePlugin extends Plugin {
init() {
console.log( 'Hello world' );
}
}
并修改配置中包含的插件列表:plugins: [ ArticlePluginSet ],
,:plugins: [ ArticlePluginSet, SimplePlugin ],
Hello world
。现在,您可以对Simple Plugin
实施新的更改,并在页面上查看结果。替代解决方案是使用CKEditor5构建之一并使用您自己的简单插件扩展它。
git clone https://github.com/ckeditor/ckeditor5-build-classic.git
npm install
src/ckeditor.js
中添加插件。
在编辑器创建之前添加此部件。
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
class SimplePlugin extends Plugin {
init() {
console.log( 'Hello world' );
}
}
并修改配置中包含的插件列表。要插件数组添加SimplePlugin
,npm run build
构建你的新包samples/index.html
。你应该在浏览器的控制台中看到Hello world
。