gitbrent / PptxGenJS

Create PowerPoint presentations with a powerful, concise JavaScript API.
https://gitbrent.github.io/PptxGenJS/
MIT License
2.62k stars 611 forks source link

[BUG] When encountering a text with the 'align' attribute added, the subsequent default attribute text content incorrectly uses the previous 'align' attribute #1322

Open terry2010 opened 4 months ago

terry2010 commented 4 months ago

Issue Category

Product Versions

[ pptxgenjs 3.12.0 ] [ PowerPoint 2013 /wps latest version] [ chrome /firefox ]

Desired Behavior

图片

Observed Behavior

图片

Steps to Reproduce

demo code

 var tmpSlide = pptx.addSlide()
            const tmpStr  = [
                {
                    text: "H2 with underline",
                    options: {
                        fontSize: 28,
                        bold: true,
                        underline: {
                            style: "sng"
                        }
                    }
                },
                {
                    text: "\n",
                    options: {}
                },
                {
                    text: "H3 Italic right aligned",
                    options: {
                        align: "right",
                        fontSize: 24,
                        bold: true,
                        italic: true
                    }
                },
                {
                    text: "\n",
                    options: {}
                },
                {
                    text: "H4 Center aligned",
                    options: {
                        align: "center",
                        fontSize: 20,
                        bold: true
                    }
                },
                {
                    text: "\n",
                    options: {}
                },
                {
                    text:  "err:H5 shouldRestore default alignment",
                    options: {
                        fontSize: 16,
                        bold: true
                    }
                },
                {
                    text: "\n",
                    options: {}
                },
                {
                    text: "auto text",
                    options: {}
                },
                {
                    text: "\n",
                    options: {}
                }
            ];
            tmpSlide.addText(tmpStr, {x: 0.5, y: 1.0, w: 5.75, h: 6.0, margin: 5, fill: {color: "#FFFFFF"}})