|
@@ -735,7 +735,7 @@ export class TextEditor {
|
|
|
this.selectedCharRange = { start, end }
|
|
|
|
|
|
this.cursor.style.display = 'none'
|
|
|
- this.updateSelectedRect()
|
|
|
+ this.updateSelectedRect(true)
|
|
|
}
|
|
|
|
|
|
this.mouseMoved = true
|
|
@@ -1187,18 +1187,17 @@ export class TextEditor {
|
|
|
}
|
|
|
|
|
|
// 更新选中文本的矩形框信息
|
|
|
- async updateSelectedRect () {
|
|
|
+ async updateSelectedRect (isMoving) {
|
|
|
if (!this.selectedCharRange) return
|
|
|
const { start, end } = this.selectedCharRange
|
|
|
const selectedRectList = await this.getCharsRect(start, end)
|
|
|
if (!selectedRectList?.length) return
|
|
|
|
|
|
- const { left: rectLeft, top: rectTop } = this.rect
|
|
|
-
|
|
|
const lastSelectedRect = this.selectedRects?.[this.selectedRects.length - 1]
|
|
|
|
|
|
// check if the last selected rectangle is the same as the new one
|
|
|
if (
|
|
|
+ isMoving &&
|
|
|
lastSelectedRect?.left === selectedRectList[0].left &&
|
|
|
lastSelectedRect?.top === selectedRectList[0].top &&
|
|
|
lastSelectedRect?.width === selectedRectList[0].width &&
|
|
@@ -1341,7 +1340,6 @@ export class TextEditor {
|
|
|
await this.setCharsFontStyle('SetCharsFontBold')
|
|
|
} else if (fontStyle === 2) {
|
|
|
await this.setCharsFontStyle('SetCharsFontItalic')
|
|
|
- action = 'SetCharsFontItalic'
|
|
|
} else if (fontStyle === 3) {
|
|
|
await this.setCharsFontStyle('SetCharsFontBold')
|
|
|
await this.setCharsFontStyle('SetCharsFontItalic')
|
|
@@ -1363,6 +1361,13 @@ export class TextEditor {
|
|
|
end: this.selectedCharRange.end,
|
|
|
})
|
|
|
this.selectedCharRange = { start, end }
|
|
|
+
|
|
|
+ if (this.activeCharPlace.CharIndex === start.CharIndex) {
|
|
|
+ this.activeCharPlace = start
|
|
|
+ } else {
|
|
|
+ this.activeCharPlace = end
|
|
|
+ }
|
|
|
+
|
|
|
this.updateSelectedRect()
|
|
|
}
|
|
|
|
|
@@ -1456,19 +1461,8 @@ export class TextEditor {
|
|
|
)
|
|
|
this.cursor = cursor
|
|
|
this.textContainer.append(this.cursor)
|
|
|
-
|
|
|
- const cursorLine = createSvg(
|
|
|
- 'line',
|
|
|
- {
|
|
|
- x1: 0,
|
|
|
- x2: 0,
|
|
|
- y1: 0,
|
|
|
- y2: 20,
|
|
|
- stroke: 'currentcolor'
|
|
|
- },
|
|
|
- )
|
|
|
- this.cursorLine = cursorLine
|
|
|
- this.cursor.append(cursorLine)
|
|
|
+
|
|
|
+ this.updateCursorLine()
|
|
|
|
|
|
this.textarea.focus()
|
|
|
this.textarea.addEventListener('blur', this.onBlur)
|