羽毛笔编辑器 - 焦点

jj0*_*008 7 html quill

每当我创建编辑器的另一个实例时(在我的例子中,通过 onkeypress 事件),当我创建新编辑器时,我会失去对正在输入的编辑器的关注。如何防止所有编辑对任何事件失去注意力?

Rus*_*ust 6

Quill 有一个focus()为此调用的方法。

var quill = new Quill('#editor', {
  theme: 'snow'
});

// This will focus the instance of quill editor
quill.focus()
Run Code Online (Sandbox Code Playgroud)


Kar*_*a U 6

setTimeout(() => { 
  quill.focus();
})
Run Code Online (Sandbox Code Playgroud)

会起作用的

  • 请解释为什么您的解决方案可以与支持您的主张的其他来源一起使用。 (3认同)
  • 在我们调用 focus 方法的同时,渲染视图需要一些时间。所以编辑器没有聚焦。 (2认同)