fix: paste list element boundary error
This commit is contained in:
@@ -3,7 +3,7 @@ import { EDITOR_ELEMENT_COPY_ATTR } from '../../../dataset/constant/Element'
|
||||
import { ElementType } from '../../../dataset/enum/Element'
|
||||
import { IElement } from '../../../interface/Element'
|
||||
import { splitText } from '../../../utils'
|
||||
import { formatElementContext } from '../../../utils/element'
|
||||
import { formatElementContext, getAnchorElement } from '../../../utils/element'
|
||||
import { CanvasEvent } from '../CanvasEvent'
|
||||
|
||||
export function input(data: string, host: CanvasEvent) {
|
||||
@@ -34,11 +34,8 @@ export function input(data: string, host: CanvasEvent) {
|
||||
const { startIndex, endIndex } = rangeManager.getRange()
|
||||
// 格式化元素
|
||||
const elementList = draw.getElementList()
|
||||
const endElement = elementList[endIndex]
|
||||
const endNextElement = elementList[endIndex + 1]
|
||||
const copyElement = endElement.value === ZERO && endNextElement
|
||||
? endNextElement
|
||||
: endElement
|
||||
const copyElement = getAnchorElement(elementList, endIndex)
|
||||
if (!copyElement) return
|
||||
const inputData: IElement[] = splitText(text).map(value => {
|
||||
const newElement: IElement = {
|
||||
value
|
||||
|
||||
@@ -77,7 +77,11 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
|
||||
const enterText: IElement = {
|
||||
value: ZERO
|
||||
}
|
||||
formatElementContext(elementList, [enterText], startIndex)
|
||||
// 标题结尾处回车无需格式化
|
||||
const endElement = elementList[endIndex]
|
||||
if (!(endElement.titleId && endElement.titleId !== elementList[endIndex + 1]?.titleId)) {
|
||||
formatElementContext(elementList, [enterText], startIndex)
|
||||
}
|
||||
let curIndex: number
|
||||
if (activeControl && !control.isRangInPostfix()) {
|
||||
curIndex = control.setValue([enterText])
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ControlComponent } from '../../dataset/enum/Control'
|
||||
import { IEditorOption } from '../../interface/Editor'
|
||||
import { IElement } from '../../interface/Element'
|
||||
import { IRange, RangeRowArray, RangeRowMap } from '../../interface/Range'
|
||||
import { getAnchorElement } from '../../utils/element'
|
||||
import { Draw } from '../draw/Draw'
|
||||
import { HistoryManager } from '../history/HistoryManager'
|
||||
import { Listener } from '../listener/Listener'
|
||||
@@ -219,7 +220,7 @@ export class RangeManager {
|
||||
if (!this.listener.rangeStyleChange) return
|
||||
// 结束光标位置
|
||||
const { endIndex, isCrossRowCol } = this.range
|
||||
let curElement: IElement
|
||||
let curElement: IElement | null
|
||||
if (isCrossRowCol) {
|
||||
// 单元格选择以当前表格定位
|
||||
const originalElementList = this.draw.getOriginalElementList()
|
||||
@@ -229,11 +230,7 @@ export class RangeManager {
|
||||
const index = ~endIndex ? endIndex : 0
|
||||
// 行首以第一个非换行符元素定位
|
||||
const elementList = this.draw.getElementList()
|
||||
const endElement = elementList[index]
|
||||
const endNextElement = elementList[index + 1]
|
||||
curElement = endElement.value === ZERO && endNextElement && endNextElement.value !== ZERO
|
||||
? endNextElement
|
||||
: endElement
|
||||
curElement = getAnchorElement(elementList, index)
|
||||
}
|
||||
if (!curElement) return
|
||||
// 选取元素列表
|
||||
|
||||
Reference in New Issue
Block a user