[英]CKeditor5 caret keeps focusing left but I want it after the text
我正在尝试对其进行编码,以便在 ckeditor 之外单击以将文本插入到编辑器中。 我在下面使用。
if (editorInstance) {
editorInstance.model.change(writer => {
writer.insertText(
` ${$(this).find('td:last').text()} `,
editorInstance.model.document.selection.getLastPosition(),
'end'
);
});
}
const text = $('.ck-content').text();
$('.ck-content').val('').focus().text(text);
如果我先在编辑器中输入然后单击插入,一切都很好。 如果我只是单击,则插入符号位置不会到达文本的末尾。 是否有一种简单的解决方案可以将文本光标移动到 ckeditor5 中的文本末尾?
我自己找到了解决方案,如下所示。
editorInstance.setData('TEXT TO SET');
editorInstance.model.change( writer => {
writer.setSelection( writer.createPositionAt( editorInstance.model.document.getRoot(), 'end' ));
});
在这里首先设置文本然后移动插入符号很重要。 我希望这会帮助将来遇到同样问题的任何人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.