diff --git a/client/src/app/gateways/export/html-to-pdf.service/html-to-pdf.service.spec.ts b/client/src/app/gateways/export/html-to-pdf.service/html-to-pdf.service.spec.ts index c01d88115c..ebe032116a 100644 --- a/client/src/app/gateways/export/html-to-pdf.service/html-to-pdf.service.spec.ts +++ b/client/src/app/gateways/export/html-to-pdf.service/html-to-pdf.service.spec.ts @@ -81,6 +81,49 @@ describe(`HtmlToPdfService`, () => { { text: [{ text: `Underlined`, decoration: `underline` }], decoration: `underline` } ]); }); + + it(`struck span`, () => { + const result = service.convertHtml({ + htmlText: `Struck` + }); + expect(result).toEqual([ + { text: [{ text: `Struck`, decoration: `lineThrough` }], decoration: `lineThrough` } + ]); + }); + + it(`nested underlined and struck spans`, () => { + const result = service.convertHtml({ + htmlText: `Both` + }); + expect(result).toEqual(([ + { + text: [ + { + text: [{ text: `Both`, decoration: [`underline`, `lineThrough`] }], + decoration: [`underline`, `lineThrough`] + } + ], + decoration: `lineThrough` + } + ])); + }); + + it(`nested underlined and struck spans 2`, () => { + const result = service.convertHtml({ + htmlText: `Both` + }); + expect(result).toEqual(([ + { + text: [ + { + text: [{ text: `Both`, decoration: [`lineThrough`, `underline`] }], + decoration: [`lineThrough`, `underline`] + } + ], + decoration: `underline` + } + ])); + }); }); describe(`convert format tags`, () => { diff --git a/client/src/app/gateways/export/html-to-pdf.service/html-to-pdf.service.ts b/client/src/app/gateways/export/html-to-pdf.service/html-to-pdf.service.ts index 1740625c9d..aee8866e39 100644 --- a/client/src/app/gateways/export/html-to-pdf.service/html-to-pdf.service.ts +++ b/client/src/app/gateways/export/html-to-pdf.service/html-to-pdf.service.ts @@ -482,11 +482,11 @@ export class HtmlToPdfService { case `text-decoration`: { switch (value) { case `underline`: { - styleObject.decoration = value; + styleObject.decoration = (styleObject.decoration ?? []).concat(value); break; } case `line-through`: { - styleObject.decoration = `lineThrough`; + styleObject.decoration = (styleObject.decoration ?? []).concat(`lineThrough`); break; } } @@ -513,6 +513,9 @@ export class HtmlToPdfService { } } } + if (Array.isArray(styleObject.decoration) && styleObject.decoration.length === 1) { + styleObject.decoration = styleObject.decoration[0]; + } return styleObject; }