Skip to content

Commit

Permalink
fix: error when selecting table cells #174
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Apr 13, 2023
1 parent 8a56a49 commit f0b6014
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/editor/core/range/RangeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,23 @@ export class RangeManager {
public setRangeStyle() {
if (!this.listener.rangeStyleChange) return
// 结束光标位置
const { endIndex } = this.range
const index = ~endIndex ? endIndex : 0
// 行首以第一个非换行符元素定位
const elementList = this.draw.getElementList()
const endElement = elementList[index]
const endNextElement = elementList[index + 1]
const curElement = endElement.value === ZERO && endNextElement
? endNextElement
: endElement
const { endIndex, isCrossRowCol } = this.range
let curElement: IElement
if (isCrossRowCol) {
// 单元格选择以当前表格定位
const originalElementList = this.draw.getOriginalElementList()
const positionContext = this.position.getPositionContext()
curElement = originalElementList[positionContext.index!]
} else {
const index = ~endIndex ? endIndex : 0
// 行首以第一个非换行符元素定位
const elementList = this.draw.getElementList()
const endElement = elementList[index]
const endNextElement = elementList[index + 1]
curElement = endElement.value === ZERO && endNextElement
? endNextElement
: endElement
}
if (!curElement) return
// 选取元素列表
const curElementList = this.getSelection() || [curElement]
Expand Down

0 comments on commit f0b6014

Please sign in to comment.