mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
feat: 导出 pptx 文件支持文本项目符号(#95)
This commit is contained in:
parent
7f5dee88b6
commit
bc8e5a97c9
@ -82,7 +82,7 @@ export default () => {
|
||||
const slices: pptxgen.TextProps[] = []
|
||||
const parse = (obj: AST[], baseStyleObj = {}) => {
|
||||
for (const item of obj) {
|
||||
if ('tagName' in item && ['div', 'ul', 'li', 'p'].includes(item.tagName) && slices.length) {
|
||||
if ('tagName' in item && ['div', 'li', 'p'].includes(item.tagName) && slices.length) {
|
||||
const lastSlice = slices[slices.length - 1]
|
||||
if (!lastSlice.options) lastSlice.options = {}
|
||||
lastSlice.options.breakLine = true
|
||||
@ -99,6 +99,11 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
if ('tagName' in item) {
|
||||
if (item.tagName === 'ul') styleObj['list-type'] = 'ul'
|
||||
if (item.tagName === 'ol') styleObj['list-type'] = 'ol'
|
||||
}
|
||||
|
||||
if ('tagName' in item) {
|
||||
if (item.tagName === 'em') {
|
||||
styleObj['font-style'] = 'italic'
|
||||
@ -169,6 +174,13 @@ export default () => {
|
||||
slices.push({ text, options })
|
||||
}
|
||||
else if ('children' in item) parse(item.children, styleObj)
|
||||
|
||||
if ('tagName' in item && item.tagName === 'li') {
|
||||
const slice = slices[slices.length - 1]
|
||||
if (!slice.options) slice.options = {}
|
||||
if (styleObj['list-type'] === 'ol') slice.options.bullet = { type: 'number', indent: 20 * 0.75 }
|
||||
if (styleObj['list-type'] === 'ul') slice.options.bullet = { indent: 20 * 0.75 }
|
||||
}
|
||||
}
|
||||
}
|
||||
parse(ast)
|
||||
|
Loading…
x
Reference in New Issue
Block a user