Merge pull request #3347 from FinnStutzenstein/Issue3343

Fixing paragraphs in lists when exporting PDF (fixes #3343)
This commit is contained in:
Emanuel Schütze 2017-08-16 10:11:39 +02:00 committed by GitHub
commit b01513ac60
2 changed files with 19 additions and 4 deletions

View File

@ -75,7 +75,7 @@ General:
- Switched from npm to Yarn [#3188]. - Switched from npm to Yarn [#3188].
- Improved performance for PDF generation significantly (by upgrading - Improved performance for PDF generation significantly (by upgrading
to pdfmake 0.1.30) [#3278, #3285]. 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]. - Improvements for plugin integration [#3330].

View File

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