在以下代码中,当按下按钮时,编辑器将插入一些文本,然后编辑器将光标对准焦点。但是,它将光标聚焦在文本区域的开头。我希望将重点放在放置在那里的文字之后。这怎么可能?当我查看了API并使用了writer,setSelection等后,我完全不理解它们,并且无法正确使用它们,因此我们将为您提供帮助。
<div id="editor">
<p>Editor content goes here.</p>
</div>
<br>
<button id="focusSet">Focus</button>
<script>
// 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();
};
</script>```
How would I change this code to set the cursor to the end of the text? This comes from a jsfiddle
[JsFiddle][1]
[1]: https://jsfiddle.net/30mb2ef9/2/