fix: paste list element boundary error #487
This commit is contained in:
@@ -581,6 +581,18 @@ export class Draw {
|
||||
}
|
||||
this.spliceElementList(elementList, start, 0, ...payload)
|
||||
curIndex = startIndex + payload.length
|
||||
// 列表前如有换行符则删除-因为列表内已存在
|
||||
const preElement = elementList[start - 1]
|
||||
if (
|
||||
payload[0].listId &&
|
||||
preElement &&
|
||||
!preElement.listId &&
|
||||
preElement?.value === ZERO &&
|
||||
(!preElement.type || preElement.type === ElementType.TEXT)
|
||||
) {
|
||||
elementList.splice(startIndex, 1)
|
||||
curIndex -= 1
|
||||
}
|
||||
}
|
||||
if (~curIndex) {
|
||||
this.range.setRange(curIndex, curIndex)
|
||||
|
||||
@@ -33,9 +33,16 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
|
||||
curIndex = control.keydown(evt)
|
||||
} else {
|
||||
// 判断是否允许删除
|
||||
if (isCollapsed && elementList[index].value === ZERO && index === 0) {
|
||||
evt.preventDefault()
|
||||
return
|
||||
if (isCollapsed && index === 0) {
|
||||
const firstElement = elementList[index]
|
||||
if (firstElement.value === ZERO) {
|
||||
// 取消首字符列表设置
|
||||
if (firstElement.listId) {
|
||||
draw.getListParticle().unsetList()
|
||||
}
|
||||
evt.preventDefault()
|
||||
return
|
||||
}
|
||||
}
|
||||
// 清空当前行对齐方式
|
||||
const startElement = elementList[startIndex]
|
||||
|
||||
Reference in New Issue
Block a user