fix: paste and format element boundary error

This commit is contained in:
Hufe921
2023-04-24 14:23:12 +08:00
parent ef9ee07a55
commit 86569f51d3
4 changed files with 114 additions and 106 deletions
+3 -2
View File
@@ -76,8 +76,9 @@ export class CursorAgent {
const pasteElementList = getElementListByHTML(htmlText, {
innerWidth: this.draw.getOriginalInnerWidth()
})
if (~startIndex) {
// 如果是复制到虚拟元素里,则粘贴列表的虚拟元素需扁平化处理
// 全选粘贴无需格式化上下文
if (~startIndex && !rangeManager.getIsSelectAll()) {
// 如果是复制到虚拟元素里,则粘贴列表的虚拟元素需扁平化处理,避免产生新的虚拟元素
const anchorElement = elementList[startIndex]
if (anchorElement?.titleId || anchorElement?.listId) {
let start = 0
+6
View File
@@ -154,6 +154,12 @@ export class RangeManager {
return rangeElementList
}
public getIsSelectAll() {
const elementList = this.draw.getElementList()
const { startIndex, endIndex } = this.range
return startIndex === 0 && elementList.length - 1 === endIndex
}
public getIsPointInRange(x: number, y: number): boolean {
const { startIndex, endIndex } = this.range
const positionList = this.position.getPositionList()