yldm
yldm

Reputation: 164

QuillJS - remove formatting when pasting into the editor

I previously used https://github.com/quilljs/quill/issues/1184#issuecomment-403657128 to make sure that no one can paste formatted text in the QuillJS editor, because I would like people to only use the few editing buttons that I enabled from QuillJs. Since then, it stopped working for me. My question is:

Upvotes: 3

Views: 6489

Answers (1)

user14972917
user14972917

Reputation:

One thing about https://github.com/quilljs/quill/issues/1184#issuecomment-403657128 that may behave different than you may have expected could be the 'silent'.

"APIs causing text to change may also be called with a "silent" source, in which case text-change will not be emitted. This is not recommended as it will likely break the undo stack and other functions that rely on a full record of text changes." [ https://quilljs.com/docs/api/#events ]

So if you expected to get the text-change event get emitted but do not get it, then change these two lines

this.quill.updateContents(delta, 'silent')
this.quill.setSelection(index, length, 'silent')

like this:

this.quill.updateContents(delta, 'user')
this.quill.setSelection(index, length, 'user')

Then the text-change event will get fired.

Upvotes: 1

Related Questions