fix: format initial data boundary error #771 #784

main
Hufe921 2 years ago
parent 5285170943
commit f62a315a7b

@ -810,7 +810,7 @@ export class CommandAdapt {
tdList.push({
colspan: 1,
rowspan: 1,
value: [{ value: ZERO, size: 16 }]
value: []
})
}
trList.push(tr)

@ -1080,7 +1080,8 @@ export class Draw {
pageComponentData.forEach(data => {
if (!data) return
formatElementList(data, {
editorOptions: this.options
editorOptions: this.options,
isForceCompensation: true
})
})
this.setEditorData({

@ -892,7 +892,8 @@ export class Control {
const elementList = zipElementList(pageComponentData[pageComponentKey]!)
pageComponentData[pageComponentKey] = elementList
formatElementList(elementList, {
editorOptions: this.options
editorOptions: this.options,
isForceCompensation: true
})
}
this.draw.setEditorData(pageComponentData)

@ -84,7 +84,8 @@ export class Placeholder {
}
]
formatElementList(this.elementList, {
editorOptions: this.options
editorOptions: this.options,
isForceCompensation: true
})
// 计算
this._compute()

@ -89,7 +89,8 @@ export default class Editor {
]
pageComponentData.forEach(elementList => {
formatElementList(elementList, {
editorOptions
editorOptions,
isForceCompensation: true
})
})
// 监听

@ -65,7 +65,8 @@ export function unzipElementList(elementList: IElement[]): IElement[] {
}
interface IFormatElementListOption {
isHandleFirstElement?: boolean
isHandleFirstElement?: boolean // 根据上下文确定首字符处理逻辑(处理首字符补偿)
isForceCompensation?: boolean // 强制补偿字符
editorOptions: DeepRequired<IEditorOption>
}
@ -73,17 +74,19 @@ export function formatElementList(
elementList: IElement[],
options: IFormatElementListOption
) {
const { isHandleFirstElement, editorOptions } = <IFormatElementListOption>{
isHandleFirstElement: true,
...options
}
const {
isHandleFirstElement = true,
isForceCompensation = false,
editorOptions
} = options
const startElement = elementList[0]
// 非首字符零宽节点文本元素则补偿-列表元素内部会补偿此处忽略
if (
isHandleFirstElement &&
startElement?.type !== ElementType.LIST &&
((startElement?.type && startElement.type !== ElementType.TEXT) ||
!START_LINE_BREAK_REG.test(startElement?.value))
isForceCompensation ||
(isHandleFirstElement &&
startElement?.type !== ElementType.LIST &&
((startElement?.type && startElement.type !== ElementType.TEXT) ||
!START_LINE_BREAK_REG.test(startElement?.value)))
) {
elementList.unshift({
value: ZERO
@ -100,7 +103,8 @@ export function formatElementList(
const valueList = el.valueList || []
formatElementList(valueList, {
...options,
isHandleFirstElement: false
isHandleFirstElement: false,
isForceCompensation: false
})
// 追加节点
if (valueList.length) {
@ -134,7 +138,8 @@ export function formatElementList(
const valueList = el.valueList || []
formatElementList(valueList, {
...options,
isHandleFirstElement: true
isHandleFirstElement: true,
isForceCompensation: false
})
// 追加节点
if (valueList.length) {
@ -170,7 +175,8 @@ export function formatElementList(
td.id = tdId
formatElementList(td.value, {
...options,
isHandleFirstElement: true
isHandleFirstElement: true,
isForceCompensation: true
})
for (let v = 0; v < td.value.length; v++) {
const value = td.value[v]
@ -385,7 +391,8 @@ export function formatElementList(
}
formatElementList(valueList, {
...options,
isHandleFirstElement: false
isHandleFirstElement: false,
isForceCompensation: false
})
for (let v = 0; v < valueList.length; v++) {
const element = valueList[v]

Loading…
Cancel
Save