最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Unfocus quill's text editor - Stack Overflow

programmeradmin7浏览0评论

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:/

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:/

Share Improve this question edited Dec 14, 2015 at 7:17 user2975885 asked Dec 12, 2015 at 23:56 user2975885user2975885 511 silver badge4 bronze badges 5
  • Hi(: can you help me? @jhchen – user2975885 Commented Dec 13, 2015 at 9:19
  • So you want the user to highlight text and format it but not type (insert or delete text)? – jhchen Commented Dec 13, 2015 at 18:05
  • No.. I edited my question to be more clear.. I don't want to highlight text.. i want to update the format of the whole text. – user2975885 Commented Dec 14, 2015 at 7:20
  • The confusing part for me is "and then the text area on focus and the user can write". Can you rephrase? – jhchen Commented Dec 14, 2015 at 19:36
  • 1 when the text area on focus- the user can edit the text (write or delete the text).. i don't want to give him that option. i want to give him the ability to change just the format of the whole text. So, after i'm changing the format of the text using my code, i would like to unfocus the text area. there is a focus method.. is there a way to unfocus? – user2975885 Commented Dec 16, 2015 at 12:03
Add a ment  | 

2 Answers 2

Reset to default 4

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();

发布评论

评论列表(0)

  1. 暂无评论