Skip to content

Commit

Permalink
feat: optimize text selection at the beginning of a line #695
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Jul 15, 2024
1 parent 26a3468 commit 97ac2da
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/editor/core/position/Position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,17 @@ export class Position {
const headIndex = positionList.findIndex(
p => p.pageNo === positionNo && p.rowNo === rowNo
)
const headElement = elementList[headIndex]
const headPosition = positionList[headIndex]
// 是否在头部
if (x < this.options.margins[3]) {
const headStartX =
headElement.listStyle === ListStyle.CHECKBOX
? this.options.margins[3]
: headPosition.coordinate.leftTop[0]
if (x < headStartX) {
// 头部元素为空元素时无需选中
if (~headIndex) {
if (positionList[headIndex].value === ZERO) {
if (headPosition.value === ZERO) {
curPositionIndex = headIndex
} else {
curPositionIndex = headIndex - 1
Expand All @@ -526,10 +532,7 @@ export class Position {
}
} else {
// 是否是复选框列表
if (
elementList[headIndex].listStyle === ListStyle.CHECKBOX &&
x < leftTop[0]
) {
if (headElement.listStyle === ListStyle.CHECKBOX && x < leftTop[0]) {
return {
index: headIndex,
isDirectHit: true,
Expand Down

0 comments on commit 97ac2da

Please sign in to comment.