Ngx-quill: How to focus the editor?

Created on 4 May 2017  路  5Comments  路  Source: KillerCodeMonkey/ngx-quill

Is there any way to focus the text field with this module? I noticed that Quill has a .focus() method, but I don't know if I can use it or how to do it.

question

Most helpful comment

I am using Angular 5 with the ngx-quill library and followed the steps above to get the editor to focus, it will focus the textbox for a second and then move the focus to the bold button (first button in toolbar)

` *ngIf="dataLoaded"
[modules]="defaultModules"
[formats]="formats"
[theme]="'snow'"
[(ngModel)]="value"
[maxLength]="maxLength"
(onContentChanged)="bodyChanged($event)"
(onEditorCreated)="setFocus($event)"

`

setFocus(editor) { editor.focus(); }

Angular 5
ngx-quill 3.3.0

All 5 comments

use the onEditorCreated output. you get the editor instance as parameter on which you can call

editor.focus()

<quill-editor (onEditorCreated)="setFocus(editor)"></quill-editor>

...

setFocus(editor) {
  editor.focus()
}

TypeError: Cannot read property 'focus' of undefined
Dunno why

sorry my fault instead of editor use $event

<quill-editor (onEditorCreated)="setFocus($event)"></quill-editor>

I didn't thought about that, now I feel a bit idiot, anyway thanks 馃憤

I am using Angular 5 with the ngx-quill library and followed the steps above to get the editor to focus, it will focus the textbox for a second and then move the focus to the bold button (first button in toolbar)

` *ngIf="dataLoaded"
[modules]="defaultModules"
[formats]="formats"
[theme]="'snow'"
[(ngModel)]="value"
[maxLength]="maxLength"
(onContentChanged)="bodyChanged($event)"
(onEditorCreated)="setFocus($event)"

`

setFocus(editor) { editor.focus(); }

Angular 5
ngx-quill 3.3.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarkusLei22 picture MarkusLei22  路  5Comments

Fzwael picture Fzwael  路  3Comments

anshumandikshit picture anshumandikshit  路  3Comments

yarik-vv picture yarik-vv  路  3Comments

KeithGillette picture KeithGillette  路  4Comments