feat: the getText method add list style conversion
This commit is contained in:
@@ -28,7 +28,8 @@ import {
|
|||||||
} from '../dataset/constant/Element'
|
} from '../dataset/constant/Element'
|
||||||
import {
|
import {
|
||||||
listStyleCSSMapping,
|
listStyleCSSMapping,
|
||||||
listTypeElementMapping
|
listTypeElementMapping,
|
||||||
|
ulStyleMapping
|
||||||
} from '../dataset/constant/List'
|
} from '../dataset/constant/List'
|
||||||
import { START_LINE_BREAK_REG } from '../dataset/constant/Regular'
|
import { START_LINE_BREAK_REG } from '../dataset/constant/Regular'
|
||||||
import {
|
import {
|
||||||
@@ -37,6 +38,7 @@ import {
|
|||||||
titleSizeMapping
|
titleSizeMapping
|
||||||
} from '../dataset/constant/Title'
|
} from '../dataset/constant/Title'
|
||||||
import { ControlComponent, ControlType } from '../dataset/enum/Control'
|
import { ControlComponent, ControlType } from '../dataset/enum/Control'
|
||||||
|
import { UlStyle } from '../dataset/enum/List'
|
||||||
import { DeepRequired } from '../interface/Common'
|
import { DeepRequired } from '../interface/Common'
|
||||||
import { IRowElement } from '../interface/Row'
|
import { IRowElement } from '../interface/Row'
|
||||||
import { ITd } from '../interface/table/Td'
|
import { ITd } from '../interface/table/Td'
|
||||||
@@ -1234,11 +1236,17 @@ export function getTextFromElementList(elementList: IElement[]) {
|
|||||||
// 按照换行符拆分
|
// 按照换行符拆分
|
||||||
const zipList = zipElementList(element.valueList!)
|
const zipList = zipElementList(element.valueList!)
|
||||||
const listElementListMap = splitListElement(zipList)
|
const listElementListMap = splitListElement(zipList)
|
||||||
|
// 无序列表前缀
|
||||||
|
let ulListStyleText = ''
|
||||||
|
if (element.listType === ListType.UL) {
|
||||||
|
ulListStyleText =
|
||||||
|
ulStyleMapping[<UlStyle>(<unknown>element.listStyle)]
|
||||||
|
}
|
||||||
listElementListMap.forEach((listElementList, listIndex) => {
|
listElementListMap.forEach((listElementList, listIndex) => {
|
||||||
const isLast = listElementListMap.size - 1 === listIndex
|
const isLast = listElementListMap.size - 1 === listIndex
|
||||||
text += `\n${listIndex + 1}.${buildText(listElementList)}${
|
text += `\n${ulListStyleText || `${listIndex + 1}.`}${buildText(
|
||||||
isLast ? `\n` : ``
|
listElementList
|
||||||
}`
|
)}${isLast ? `\n` : ``}`
|
||||||
})
|
})
|
||||||
} else if (element.type === ElementType.CHECKBOX) {
|
} else if (element.type === ElementType.CHECKBOX) {
|
||||||
text += element.checkbox?.value ? `☑` : `□`
|
text += element.checkbox?.value ? `☑` : `□`
|
||||||
|
|||||||
Reference in New Issue
Block a user