Fixing paragraphs in lists when exporting PDF (fixes #3343)

This commit is contained in:
FinnStutzenstein 2017-08-11 10:07:38 +02:00
parent f0d840148e
commit c36b756f25
2 changed files with 19 additions and 4 deletions

View File

@ -75,7 +75,7 @@ General:
- Switched from npm to Yarn [#3188].
- Improved performance for PDF generation significantly (by upgrading
to pdfmake 0.1.30) [#3278, #3285].
- Bugfixes for PDF creation [#3227, #3251, #3279, #3286, #3346].
- Bugfixes for PDF creation [#3227, #3251, #3279, #3286, #3346, #3347].
- Improvements for plugin integration [#3330].

View File

@ -590,6 +590,17 @@ angular.module('OpenSlidesApp.core.pdf', [])
return false;
}
},
// Helper function for determinating whether a parent of element is a list item.
isInsideAList = function (element) {
parent = element.parentNode;
while(parent !== null) {
if (parent.nodeName.toLowerCase() === 'li') {
return true;
}
parent = parent.parentNode;
}
return false;
},
/**
* Parses a single HTML element
* @function
@ -791,9 +802,13 @@ angular.module('OpenSlidesApp.core.pdf', [])
case "p":
var pObjectToPush; //determine what to push later
currentParagraph = create("text");
currentParagraph.margin = [20, 0, 0, 0];
if (classes.indexOf('os-split-before') === -1) {
currentParagraph.margin[1] = 8;
// If this element is inside a list (happens if copied from word), do not set spaces
// and margins. Just leave the paragraph there..
if (!isInsideAList(element)) {
currentParagraph.margin = [20, 0, 0, 0];
if (classes.indexOf('os-split-before') === -1) {
currentParagraph.margin[1] = 8;
}
}
currentParagraph.lineHeight = 1.25;
var stackP = create("stack");