feat: insert element boundary optimization #669
This commit is contained in:
@@ -2263,7 +2263,9 @@ export class CommandAdapt {
|
||||
// 格式化上下文信息
|
||||
const { startIndex } = this.range.getRange()
|
||||
const elementList = this.draw.getElementList()
|
||||
formatElementContext(elementList, cloneElementList, startIndex)
|
||||
formatElementContext(elementList, cloneElementList, startIndex, {
|
||||
isBreakWhenWrap: true
|
||||
})
|
||||
this.draw.insertElementList(cloneElementList)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ export function enter(evt: KeyboardEvent, host: CanvasEvent) {
|
||||
if (evt.shiftKey && startElement.listId) {
|
||||
enterText.listWrap = true
|
||||
}
|
||||
// 格式化上下文
|
||||
formatElementContext(elementList, [enterText], startIndex, {
|
||||
isBreakWhenWrap: true
|
||||
})
|
||||
// 标题结尾处回车无需格式化及样式复制
|
||||
if (
|
||||
!(
|
||||
@@ -45,8 +49,6 @@ export function enter(evt: KeyboardEvent, host: CanvasEvent) {
|
||||
endElement.titleId !== elementList[endIndex + 1]?.titleId
|
||||
)
|
||||
) {
|
||||
// 格式化上下文
|
||||
formatElementContext(elementList, [enterText], startIndex)
|
||||
// 复制样式属性
|
||||
const copyElement = getAnchorElement(elementList, endIndex)
|
||||
if (copyElement) {
|
||||
|
||||
@@ -826,7 +826,7 @@ export function formatElementContext(
|
||||
if (
|
||||
isBreakWhenWrap &&
|
||||
!copyElement.listId &&
|
||||
/^\n/.test(targetElement.value)
|
||||
START_LINE_BREAK_REG.test(targetElement.value)
|
||||
) {
|
||||
isBreakWarped = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user