Hello,
Does anyone know how to set focus in CKEditor 5 component's editor?
My <ckeditor> component is disabled by default, and I would like to set the focus when the user presses a button.
I tried something like this, but the elementRef is private :
addFocus(): void {
this.isEditing = true;
this.ckEditor.elementRef.nativeElement.focus();
}
Hi @M-Blobby,
the <ckeditor> component exposes the editorInstance, which is an instance of CKEditor 5 editor, on which you can use the editorInstance.editing.view.focus() method to focus the editable element.
Hello @ma2ciek ,
Thank you a lot for your help :). Just in case someone has the same problem, I followed the ma2ciek help but without 'document' (else I got the error "the function focus is not defined") so :
editorInstance.editing.view.focus();
Where does this "editorInstance" come from?
I'm trying to use the ViewChild, to a local reference on
Hi @tarcisiocipriano,
Most helpful comment
Hello @ma2ciek ,
Thank you a lot for your help :). Just in case someone has the same problem, I followed the ma2ciek help but without 'document' (else I got the error "the function focus is not defined") so :