feat: wrap within list item

This commit is contained in:
Hufe921
2023-04-28 21:30:50 +08:00
parent c5699bcb4c
commit 69750a115a
6 changed files with 32 additions and 14 deletions
+21 -10
View File
@@ -110,18 +110,24 @@ export function writeElementList(elementList: IElement[], options: DeepRequired<
const zipList = zipElementList(element.valueList!)
for (let z = 0; z < zipList.length; z++) {
const zipElement = zipList[z]
const zipValueList = zipElement.value.split('\n')
for (let c = 0; c < zipValueList.length; c++) {
if (c > 0) {
curListIndex += 1
}
const value = zipValueList[c]
if (zipElement.listWrap) {
const listElementList = listElementListMap.get(curListIndex) || []
listElementList.push({
...zipElement,
value,
})
listElementList.push(zipElement)
listElementListMap.set(curListIndex, listElementList)
} else {
const zipValueList = zipElement.value.split('\n')
for (let c = 0; c < zipValueList.length; c++) {
if (c > 0) {
curListIndex += 1
}
const value = zipValueList[c]
const listElementList = listElementListMap.get(curListIndex) || []
listElementList.push({
...zipElement,
value,
})
listElementListMap.set(curListIndex, listElementList)
}
}
}
listElementListMap.forEach(listElementList => {
@@ -264,6 +270,11 @@ export function getElementListByHTML(htmlText: string, options: IGetElementListB
}
listNode.querySelectorAll('li').forEach(li => {
const liValueList = getElementListByHTML(li.innerHTML, options)
liValueList.forEach(list => {
if (list.value === '\n') {
list.listWrap = true
}
})
liValueList.unshift({
value: '\n'
})