简体   繁体   中英

Unfocus quill's text editor

Is there a way to unfocus?

I want to update the whole text format using my code and i don't want to give my user the option to write text after it. I update the format of the whole text (range: start=0, end=text length) using formatText method and then the text area on focus and the user can write:/

There is not an explicit unfocus() API since there's not much that Quill needs beyond the existing DOM blur function:

quill.root.blur()

The user can of course click back into the editor so if you want to prevent that you can disable the whole editor with:

quill.editor.disable()

You may still make API calls but the user will be unable to interact with the editor while disabled.

I had an issue with the cursor remaining on the screen after blur. I realized that quill already has a hidden focusable element that seems to fix the problem.

quill.querySelector('.ql-clipboard').focus();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM