Merge pull request #4376 from tsiegleauq/pdf-list-fixes

Adds extra cases for PDF CR lists
This commit is contained in:
Emanuel Schütze 2019-02-21 09:54:29 +01:00 committed by GitHub
commit f4f8b8422f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 5 deletions

View File

@ -350,10 +350,8 @@ export class HtmlToPdfService {
margin: [0, 0, 0, 0] margin: [0, 0, 0, 0]
}; };
// This has the effect that changed complex lists will look good with line numbers, // if this is a "fake list" lower put it close to the element above
// but simple lists will be too close. The information in the HTML is highly redundant and if (this.isFakeList(element)) {
// there is currently no clear way to determine what to do with the lists.
if (classes.includes('os-split-after')) {
listCol.margin[3] = -this.LI_MARGIN_BOTTOM; listCol.margin[3] = -this.LI_MARGIN_BOTTOM;
} }
@ -546,6 +544,28 @@ export class HtmlToPdfService {
return false; 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 * Helper function to safer extract a line number from an element
* *

View File

@ -99,7 +99,7 @@ export class MotionPdfCatalogService {
* @returns The motion list title for the PDF document * @returns The motion list title for the PDF document
*/ */
private createTitle(): object { private createTitle(): object {
const titleText = this.configService.instant<string>('motions_export_title'); const titleText = this.translate.instant(this.configService.instant<string>('motions_export_title'));
return { return {
text: titleText, text: titleText,
style: 'title' style: 'title'