diff --git a/client/src/app/core/ui-services/html-to-pdf.service.ts b/client/src/app/core/ui-services/html-to-pdf.service.ts index 0b29ce71b..af1a9ee7a 100644 --- a/client/src/app/core/ui-services/html-to-pdf.service.ts +++ b/client/src/app/core/ui-services/html-to-pdf.service.ts @@ -350,10 +350,8 @@ export class HtmlToPdfService { margin: [0, 0, 0, 0] }; - // This has the effect that changed complex lists will look good with line numbers, - // but simple lists will be too close. The information in the HTML is highly redundant and - // there is currently no clear way to determine what to do with the lists. - if (classes.includes('os-split-after')) { + // if this is a "fake list" lower put it close to the element above + if (this.isFakeList(element)) { listCol.margin[3] = -this.LI_MARGIN_BOTTOM; } @@ -546,6 +544,28 @@ export class HtmlToPdfService { return false; } + /** + * Checks if a given UL or LI list (as element) is a "fake list" + * Fake lists in fact lists by should appear like the parent list + * would seamlessly continue. + * This usually happens when a user makes change recommendations in + * lists + * + * @param element the list to check, can be UL or LI + * returns wether the list is fake or not + */ + private isFakeList(element: Element): boolean { + if (element.firstElementChild && element.classList.contains('os-split-after')) { + // either first child has split-before or last child has split-after + const firstChild = element.firstElementChild; + const lastChild = element.childNodes[element.childNodes.length - 1] as Element; + const splitBefore = firstChild.nodeName === 'LI' && firstChild.classList.contains('os-split-before'); + const splitAfter = lastChild.nodeName === 'LI' && lastChild.classList.contains('os-split-after'); + return splitBefore || splitAfter; + } + return false; + } + /** * Helper function to safer extract a line number from an element * diff --git a/client/src/app/site/motions/services/motion-pdf-catalog.service.ts b/client/src/app/site/motions/services/motion-pdf-catalog.service.ts index d13024763..5ccd6e7f7 100644 --- a/client/src/app/site/motions/services/motion-pdf-catalog.service.ts +++ b/client/src/app/site/motions/services/motion-pdf-catalog.service.ts @@ -99,7 +99,7 @@ export class MotionPdfCatalogService { * @returns The motion list title for the PDF document */ private createTitle(): object { - const titleText = this.configService.instant('motions_export_title'); + const titleText = this.translate.instant(this.configService.instant('motions_export_title')); return { text: titleText, style: 'title'