Ckeditor Chrome中的三重选择导致多行选择

Ckeditor Chrome中的三重选择导致多行选择,ckeditor,range,selection,Ckeditor,Range,Selection,我在CKEditor4之上实现了一个所见即所得(基本上我只是重写了工具栏)。 问题是,拖动鼠标进行选择,然后三次单击一条线进行选择,会产生不同的范围 使用此html: <h2>^Leo ac scegliere e iniziare^</h2> <<< Line I want to select <p>nunc ultrices eros, sed gravida</p> 三重选择 startContainer和endConta

我在CKEditor4之上实现了一个所见即所得(基本上我只是重写了工具栏)。 问题是,拖动鼠标进行选择,然后三次单击一条线进行选择,会产生不同的范围

使用此html:

<h2>^Leo ac scegliere e iniziare^</h2> <<< Line I want to select
<p>nunc ultrices eros, sed gravida</p>
三重选择

startContainer
endContainer
不一样,它不能从用户的角度反映实际情况

collapsed: false
document:CKEDITOR.dom.document {$: document}
endContainer: CKEDITOR.dom.element {$: p, getName: ƒ}
endOffset: 0 
startContainer: CKEDITOR.dom.element {$: h2, getName: ƒ}
startOffset: 0
这种差异导致了我在风格应用上的问题。 这在Chrome中发生,但在Firefox中却没有


你知道为什么会这样吗?有解决办法吗?我一直在考虑一种检查
endContainer
endOffset
的解决方案,但我担心这种解决方案会打破范围和选择,因为
mouseup
事件
我想出了以下方法:

fuction handleMouseup(event) {
  if (event.detail === 3) {
    const selection = this.editor.getSelection()
    let range = selection.getRanges()[0]
    let actualStartContainer = range.startContainer

    // Finds the highest parent untill the startContainer
    while (!actualStartContainer.getParent().equals(this.editor.element))
        actualStartContainer = actualStartContainer.getParent()

    // Select the ranges and update the selection with just the startContainer
    range.selectNodeContents(actualStartContainer)
    selection.selectRanges([range])
  }
}
fuction handleMouseup(event) {
  if (event.detail === 3) {
    const selection = this.editor.getSelection()
    let range = selection.getRanges()[0]
    let actualStartContainer = range.startContainer

    // Finds the highest parent untill the startContainer
    while (!actualStartContainer.getParent().equals(this.editor.element))
        actualStartContainer = actualStartContainer.getParent()

    // Select the ranges and update the selection with just the startContainer
    range.selectNodeContents(actualStartContainer)
    selection.selectRanges([range])
  }
}