Ngx-quill: insertText doesn't trigger form valueChanges

Created on 1 Apr 2019  ·  3Comments  ·  Source: KillerCodeMonkey/ngx-quill

I have a custom handler in my quill module that inserts variables from a dropdown into the quill editor.

handlers: { variable(value) { if (value) { const cursorPosition = this.quill.getSelection().index; this.quill.insertText(cursorPosition, value); this.quill.setSelection(cursorPosition + value.length); } }, },

The problem is, after this happens valueChanges is not fired which runs my validators. So the user has to type into quill to get valueChanges to trigger which then runs the validation. Is there an efficient way to trigger valueChanges from the handler?

Most helpful comment

Yep thats because Form controls and Models should only Update only on User
changes.

The quill API provides a "Source" Parameter for some Methods Like
setContents or the Insert ones.

So Just pass "user" AS Source of the Change :).

bricksimpleseanmccaffery notifications@github.com schrieb am Mo., 1. Apr.
2019, 20:56:

I have a custom handler in my quill module that inserts variables from a
dropdown into the quill editor.

handlers: { variable(value) { if (value) { const cursorPosition =
this.quill.getSelection().index; this.quill.insertText(cursorPosition,
value); this.quill.setSelection(cursorPosition + value.length); } }, },

The problem is, after this happens valueChanges is not fired which runs my
validators. So the user has to type into quill to get valueChanges to
trigger when then runs the validation. Is there an efficient way to trigger
valueChanges from the handler?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/KillerCodeMonkey/ngx-quill/issues/364, or mute the
thread
https://github.com/notifications/unsubscribe-auth/ACKOYNQ4ywQBOxQiFCBmvPtepeARPvy2ks5vclZGgaJpZM4cWaMH
.

All 3 comments

Yep thats because Form controls and Models should only Update only on User
changes.

The quill API provides a "Source" Parameter for some Methods Like
setContents or the Insert ones.

So Just pass "user" AS Source of the Change :).

bricksimpleseanmccaffery notifications@github.com schrieb am Mo., 1. Apr.
2019, 20:56:

I have a custom handler in my quill module that inserts variables from a
dropdown into the quill editor.

handlers: { variable(value) { if (value) { const cursorPosition =
this.quill.getSelection().index; this.quill.insertText(cursorPosition,
value); this.quill.setSelection(cursorPosition + value.length); } }, },

The problem is, after this happens valueChanges is not fired which runs my
validators. So the user has to type into quill to get valueChanges to
trigger when then runs the validation. Is there an efficient way to trigger
valueChanges from the handler?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/KillerCodeMonkey/ngx-quill/issues/364, or mute the
thread
https://github.com/notifications/unsubscribe-auth/ACKOYNQ4ywQBOxQiFCBmvPtepeARPvy2ks5vclZGgaJpZM4cWaMH
.

Ah perfect! Thanks for the super fast response. Really appreciated.

No probs . Please Close the issue If the Problem is solved :)

bricksimpleseanmccaffery notifications@github.com schrieb am Mo., 1. Apr.
2019, 21:05:

Ah perfect! Thanks for the super fast response. Really appreciated.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/KillerCodeMonkey/ngx-quill/issues/364#issuecomment-478705259,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACKOYB7vRG86LWQNJSdrdedmHvgf1Jnfks5vclhqgaJpZM4cWaMH
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chuJianNi picture chuJianNi  ·  3Comments

swymmwys picture swymmwys  ·  5Comments

anthonyinspace picture anthonyinspace  ·  3Comments

vaags picture vaags  ·  6Comments

qikong333 picture qikong333  ·  5Comments