html中引入了CKEditor5的js代码,然后通过下面代码绑定到textarea元素上面。
<textarea name="content" id="editor">
<p>Here goes the initial content of the editor.</p>
</textarea>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
console.log( editor );
} )
.catch( error => {
console.error( error );
} );
然后js的方式就不能获取到textarea的文本节点,查看CKEditor的API问题,发现可以通过editor.getData()获取;但是只能刚加载的时候获取,如何做到,点击某个按钮就能拿到文本框内容呢?