I'm using CKeditor5 document editor in reactjs. And i want to make it disabled or readonly. I'm sending parameter in config but not working.
<CKEditor2
editor={DecoupledEditor}
data="<p>Hello from CKEditor 5!</p>"
onInit={editor => {
editor.ui.view.editable.element.parentElement.insertBefore(
editor.ui.view.toolbar.element,
editor.ui.view.editable.element
);
}}
config={
{
toolbar: ['bold', 'italic', 'bulletedList', '|', 'numberedList', 'alignment'],
removePlugins: ['Heading', 'Link'],
isReadOnly: true,
}
}
/>
Ok I think I found out what you're looking for:
Here you have a description of the component properties. On the last one you can see "disabled"
So you're code would look something like this:
<CKEditor2
editor={DecoupledEditor}
data="<p>Hello from CKEditor 5!</p>"
disabled=true
onInit={editor => {
editor.ui.view.editable.element.parentElement.insertBefore(
editor.ui.view.toolbar.element,
editor.ui.view.editable.element
);
}}
config={
{
toolbar: ['bold', 'italic', 'bulletedList', '|', 'numberedList', 'alignment'],
removePlugins: ['Heading', 'Link'],
isReadOnly: true,
}
}
/>
Also, I think you probably meant <CKEditor
instead of <CKEditor2
.
Use editor.enableReadOnlyMode("editor"); Docs
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.ckeditor.com/ckeditor5/35.0.1/classic/ckeditor.js"></script>
</head>
<body>
<div id="editor">Test</div>
<script>
ClassicEditor.create(document.querySelector("#editor"), {
toolbar: [],
}).then(editor => {
editor.enableReadOnlyMode("editor");
console.log(editor);
}).catch(error => {
console.error(error);
});
</script>
</body>
</html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.