I'm trying to capture the input inside a CKEditor5 in an Angular app using typescript. I am able to get the CKEditor to show and am able to log the editor's presence. However, I can't seem to be able to capture the input. This seemed to be pretty straightforward in CKEditor4 where a simple code such as the one below worked:
editor.on('key', function (event) {
//some work goes here
}
However, trying this with my current ClassicEditor doesn't seem to be the case. I am using Angular and have initialized the CKEditor5 in the index.html and call it from within the code in the following format
declare var ClassicEditor: any;
export class AlterInput implements OnInit {
ngOnInit() {
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then(editor => {
console.log("THIS GETS PRINTED", editor)
editor.on('key', (event) => {
console.log('THIS DOES NOT GET PRINTED', event);
})
.catch( error => {
console.error( error );
} );
}
}
I've originally created a plugin with CKEditor4 - which was done by calling CKEDITOR.plugins.add('pluginName', {\**some work in the init function**\})
However, I can't seem to find a decent example of how to do so using CKEditor5. My ultimate goal is to get the key code of the character entered, add one, and paste it.