How to Update Textarea with CKEditor Changes
To update the textarea with id 'pdescription' every time the CKEditor changes, you can use the following code:
var pdescription;
ClassicEditor
.create( document.querySelector( '#pdescription' ) )
.then( editor => {
pdescription = editor;
pdescription.model.document.on('change:data', () => {
document.querySelector('#pdescription').value = pdescription.getData();
});
} )
.catch( err => {
console.error( err.stack );
} );
This code listens for the 'change:data' event on the CKEditor instance's model.document object. Whenever this event is triggered (i.e., the CKEditor content changes), it updates the value of the textarea with id 'pdescription' with the new content using the getData() method of the CKEditor instance.
原文地址: https://www.cveoy.top/t/topic/qnl5 著作权归作者所有。请勿转载和采集!