diff --git a/src/editor/core/cursor/Cursor.ts b/src/editor/core/cursor/Cursor.ts index 59ed328cb..c36a8b7be 100644 --- a/src/editor/core/cursor/Cursor.ts +++ b/src/editor/core/cursor/Cursor.ts @@ -1,4 +1,4 @@ -import { CURSOR_AGENT_HEIGHT } from '../../dataset/constant/Cursor' +import { CURSOR_AGENT_OFFSET_HEIGHT } from '../../dataset/constant/Cursor' import { EDITOR_PREFIX } from '../../dataset/constant/Editor' import { MoveDirection } from '../../dataset/enum/Observer' import { DeepRequired } from '../../interface/Common' @@ -121,9 +121,11 @@ export class Cursor { ? pageNo : this.draw.getPageNo() const preY = curPageNo * (height + pageGap) - // 增加1/4字体大小 - const offsetHeight = metrics.height / 4 - const cursorHeight = metrics.height + offsetHeight * 2 + // 默认偏移高度 + const defaultOffsetHeight = CURSOR_AGENT_OFFSET_HEIGHT * scale + // 增加1/4字体大小(最小为defaultOffsetHeight即默认偏移高度) + const increaseHeight = Math.min(metrics.height / 4, defaultOffsetHeight) + const cursorHeight = metrics.height + increaseHeight * 2 const agentCursorDom = this.cursorAgent.getAgentCursorDom() if (isFocus) { setTimeout(() => { @@ -135,16 +137,16 @@ export class Cursor { const descent = metrics.boundingBoxDescent < 0 ? 0 : metrics.boundingBoxDescent const cursorTop = - leftTop[1] + ascent + descent - (cursorHeight - offsetHeight) + preY + leftTop[1] + ascent + descent - (cursorHeight - increaseHeight) + preY const cursorLeft = hitLineStartIndex ? leftTop[0] : rightTop[0] agentCursorDom.style.left = `${cursorLeft}px` agentCursorDom.style.top = `${ - cursorTop + cursorHeight - CURSOR_AGENT_HEIGHT * scale + cursorTop + cursorHeight - defaultOffsetHeight }px` // 模拟光标显示 if (!isShow) return const isReadonly = this.draw.isReadonly() - this.cursorDom.style.width = `${width}px` + this.cursorDom.style.width = `${width * scale}px` this.cursorDom.style.backgroundColor = color this.cursorDom.style.left = `${cursorLeft}px` this.cursorDom.style.top = `${cursorTop}px` diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index 3212157cd..47fe6fbc7 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -1194,7 +1194,7 @@ export class Draw { metrics.width = elementWidth metrics.height = elementHeight metrics.boundingBoxDescent = elementHeight - metrics.boundingBoxAscent = 0 + metrics.boundingBoxAscent = -rowMargin // 表格分页处理(拆分表格) const height = this.getHeight() const marginHeight = this.getMainOuterHeight() diff --git a/src/editor/dataset/constant/Cursor.ts b/src/editor/dataset/constant/Cursor.ts index 16c13d0e3..25bbbd0dd 100644 --- a/src/editor/dataset/constant/Cursor.ts +++ b/src/editor/dataset/constant/Cursor.ts @@ -1,6 +1,6 @@ import { ICursorOption } from '../../interface/Cursor' -export const CURSOR_AGENT_HEIGHT = 12 +export const CURSOR_AGENT_OFFSET_HEIGHT = 12 export const defaultCursorOption: Readonly> = { width: 1,