我试图在ckeditor 5中创建从当前焦点到文档开始的范围,在用户单击文档中的任意位置后,我将获得选择焦点并创建到文档根的范围。
const htmlElement = writer.createElement( 'paragraph' );
//inserting the html element at the point of focus
writer.insert( htmlElement, doc.selection.focus );
const rangeStart = writer.createPositionBefore( htmlElement );
// trying to create the range from current but `createRangeIn` is selecting the whole document range
writer.createRangeIn( editor.model.document.getRoot(), rangeStart );
为此尝试了createRange
,但不确定如何创建一个范围来选择内容,直到开始。