[英]How Can I add underline option & Alignment option in toolbar of CKEditor5 in reactjs
如何在 reactjs 的 reactjs 中添加选项作为文本 Alignment 和 CKEditor 中的下划线,但没有成功。 请帮我
text-editor.js
import React from 'react'
import CKEditor from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
const TextEditor = ({handleChildClick}) => {
return (
<div className="container">
<CKEditor
editor={ ClassicEditor }
onChange={ ( event, editor ) => {
const data = editor.getData();
handleChildClick(data)
} }
/>
<style>
{`
.ck-content { height: 150px; }
`}
</style>
</div>
);
};
export default TextEditor
Parent.js
<TextEditor handleChildClick={getDataFromTextEditor} />
使用 ClassicEditor 会删除一些按钮,例如“下划线、下标、上标”。 您将需要使用编辑器的自定义版本,而不是经典版本。
我已经与 CKEditor 团队取得了联系。 他们已将我发送给他们的在线构建器: https://ckeditor.com/ckeditor-5/online-builder/
我已经尝试过了,它看起来很简单好用。 有很多选项,所以你需要通过它 go 。
基本上,选择你的编辑器类型,添加插件,选择你的语言,构建和使用构建。
希望能帮助到你
我看到这个问题已经回答了,但我想我可以补充一下我是如何解决这个问题的。
在安装 ckeditor 进行反应时,我使用了
npm install --save @ckeditor/ckeditor5-react @ckeditor/ckeditor5-build-decoupled-document
代替文档中给出的示例
npm install --save @ckeditor/ckeditor5-react @ckeditor/ckeditor5-build-classic
然后我按照文档中所示的创建解耦编辑器的方法
import { CKEditor } from '@ckeditor/ckeditor5-react';
import DecoupledEditor from '@ckeditor/ckeditor5-build-decoupled-document';
class App extends Component {
editor = null;
render() {
return (
<div className="App">
<h2>CKEditor 5 using a custom build - decoupled editor</h2>
<CKEditor
onReady={ editor => {
console.log( 'Editor is ready to use!', editor );
editor.ui.getEditableElement().parentElement.insertBefore(
editor.ui.view.toolbar.element,
editor.ui.getEditableElement()
);
this.editor = editor;
} }
onError={ ( { willEditorRestart } ) => {
// This is why you need to remove the older toolbar.
if ( willEditorRestart ) {
this.editor.ui.view.toolbar.element.remove();
}
} }
onChange={ ( event, editor ) => console.log( { event, editor } ) }
editor={ DecoupledEditor }
data="<p>Hello from CKEditor 5's decoupled editor!</p>"
config={ /* the editor configuration */ }
/>
);
}
}
export default App;
这是给 Angular 的,如果有人在找这个会很有帮助。
参考: https://github.com/ckeditor/ckeditor5-angular/issues/156 1)
npm install --save ckeditor5-build-classic-plus
<ckeditor (ready)="editorsReady($event)" [editor]="Editor" data="test" [config]="optionsNews">
从'ckeditor5-build-classic-plus'导入ClassicEditor;
public editorsReady(editor) {
editor.ui.getEditableElement().parentElement.insertBefore(
editor.ui.view.toolbar.element,
editor.ui.getEditableElement() );
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.