然后我运行classiceditor.greate用ckeditor 5 Editor替换Textarea。
ClassicEditor.create($("#texto_contenido")[0], {
licenseKey: 'eyJhbGciOiJFUzI1NiJ9.eyJleHAiOjE3NDA1Mjc5OTksImp0aSI6ImNiNjk1OTZhLTM4YzUtNDc2YS1iM2UxLTFmOWU1OTNlMDQ0MCIsInVzYWdlRW5kcG9pbnQiOiJodHRwczovL3Byb3h5LWV2ZW50LmNrZWRpdG9yLmNvbSIsImRpc3RyaWJ1dGlvbkNoYW5uZWwiOlsiY2xvdWQiLCJkcnVwYWwiLCJzaCJdLCJ3aGl0ZUxhYmVsIjp0cnVlLCJsaWNlbnNlVHlwZSI6InRyaWFsIiwiZmVhdHVyZXMiOlsiKiJdLCJ2YyI6IjA4Y2QwYjJiIn0.283faOBt808tzYbU44p9td1uQgmOyNFeVsV_tYEGywdfUZqNXFgzQuKKXm12u9RJoz7WOuEKHoxi_O0zxew0hA',
toolbar: { items: ["bold", "italic", "|", "alignment", "|", "undo", "redo"] },
plugins: [Alignment, Bold, Italic, Paragraph, Undo],
language: "es"
})
.then(editor => { window.editorInstance = editor; })
.catch(error => { console.error(error); });
不可能在编辑器中编写,如果事先编辑了文本区域,则确实需要文本,但是仍然无法编辑任何内容。我显示了一个示例屏幕截图
i我能够复制该问题,这是由缺失的ckeditor插件引起的。
exterentials插件“启用剪贴板,输入,选择全部,Shiftenter,键入和撤消支持。”
demo
const KEY = "eyJhbGciOiJFUzI1NiJ9.eyJleHAiOjE3NDA1Mjc5OTksImp0aSI6ImNiNjk1OTZhLTM4YzUtNDc2YS1iM2UxLTFmOWU1OTNlMDQ0MCIsInVzYWdlRW5kcG9pbnQiOiJodHRwczovL3Byb3h5LWV2ZW50LmNrZWRpdG9yLmNvbSIsImRpc3RyaWJ1dGlvbkNoYW5uZWwiOlsiY2xvdWQiLCJkcnVwYWwiLCJzaCJdLCJ3aGl0ZUxhYmVsIjp0cnVlLCJsaWNlbnNlVHlwZSI6InRyaWFsIiwiZmVhdHVyZXMiOlsiKiJdLCJ2YyI6IjA4Y2QwYjJiIn0.283faOBt808tzYbU44p9td1uQgmOyNFeVsV_tYEGywdfUZqNXFgzQuKKXm12u9RJoz7WOuEKHoxi_O0zxew0hA"
const { Essentials, ClassicEditor, Alignment, Undo, Bold, Italic, Font, Paragraph } = CKEDITOR
ClassicEditor.create(document.getElementById("texto_contenido"), {
licenseKey: KEY,
toolbar: { items: ["bold", "italic", "|", "alignment", "|", "undo", "redo"] },
plugins: [Essentials, Alignment, Bold, Italic, Paragraph, Undo],
language: "es"
})
.then(editor => { window.editorInstance = editor; })
.catch(error => { console.error(error); });
<!-- Button trigger modal -->
<button
type="button"
class="btn btn-primary"
data-bs-toggle="modal"
data-bs-target="#staticBackdrop"
>
Open Modal
</button>
<!-- Modal -->
<div
class="modal fade"
id="staticBackdrop"
data-bs-backdrop="static"
data-bs-keyboard="false"
tabindex="-1"
aria-labelledby="staticBackdropLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="">
<h1 class="modal-title fs-5" id="staticBackdropLabel">
Editor</h1>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<!-- ckeditor -->
<div class="main-container">
<div id="texto_contenido">
<p>Hello from CKEditor 5!</p>
</div>
</div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<!-- BOOTSTRAP 5 -->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<!-- CKEDITOR -->
<link
rel="stylesheet"
href="https://cdn.ckeditor.com/ckeditor5/44.2.1/ckeditor5.css"
/>
<script src="https://cdn.ckeditor.com/ckeditor5/44.2.1/ckeditor5.umd.js"></script>