更新时间:2022-02-22 09:27:11
The editor comes with a FocusTracker
(and the observable #isFocused
property) for that purpose:
editor.ui.focusTracker.on( 'change:isFocused', ( evt, name, value ) => {
console.log( 'isFocused = ', value );
} );
请注意,只要任何用户界面具有焦点, editor.ui.focusTracker.isFocused
就是 true
,其中包括可编辑的内容以及工具栏,浮动面板等
Note that editor.ui.focusTracker.isFocused
is true
as long as any UI has focus, which includes the editable but also the toolbar, floating panels, etc.
确定焦点可编辑的a>,即,当插入符号闪烁并可以键入时,请改用以下监听器:
To determine the focus of the editable, i.e. when the caret is blinking and typing is possible, use this listener instead:
editor.editing.view.document.on( 'change:isFocused', ( evt, name, value ) => {
console.log( 'editable isFocused =', value );
} );
将一个侦听器放置在另一个侦听器旁边,并使用编辑器和UI来查看区别.
Place one listener next to the other and play with the editor and the UI to see the difference.