在编辑器中设置文本后,我需要将焦点设置到文本末尾。怎么做?我无法理解
editor.setData('text');
editor.editing.view.focus(); // focus to set the beginning, but on the end
Run Code Online (Sandbox Code Playgroud)
示例: https: //jsfiddle.net/ogm5s6k7/1/
editor.setData('text');
editor.editing.view.focus(); // focus to set the beginning, but on the end
Run Code Online (Sandbox Code Playgroud)
// Editor configuration.
ClassicEditor
.create( document.querySelector( '#editor' ))
.then( editor => {
window.editor = editor;
})
.catch( error => {
console.error( error );
});
document.getElementById('focusSet').onclick = function(e) {
window.editor.setData('text');
window.editor.editing.view.focus();
};Run Code Online (Sandbox Code Playgroud)