Merge pull request #3438 from FinnStutzenstein/PDF
Fixing multiline headers in PDF
This commit is contained in:
commit
9b64bd5646
@ -661,30 +661,38 @@ angular.module('OpenSlidesApp.core.pdf', [])
|
|||||||
case "h4":
|
case "h4":
|
||||||
case "h5":
|
case "h5":
|
||||||
case "h6":
|
case "h6":
|
||||||
// Special case quick fix to handle the dirty HTML format*/
|
|
||||||
// see following issue: https://github.com/OpenSlides/OpenSlides/issues/3025
|
|
||||||
if (lineNumberMode === "outside" &&
|
if (lineNumberMode === "outside" &&
|
||||||
element.childNodes.length > 0 &&
|
element.childNodes.length > 0 &&
|
||||||
element.childNodes[0].getAttribute) {
|
element.childNodes[0].getAttribute) {
|
||||||
var HeaderOutsideLineNumber = {
|
// A heading may have multiple lines, so handle line by line separated by line number elements
|
||||||
width: 20,
|
var outerStack = create("stack");
|
||||||
text: element.childNodes[0].getAttribute("data-line-number"),
|
var currentCol;
|
||||||
color: "gray",
|
_.forEach(element.childNodes, function (node) {
|
||||||
fontSize: 8,
|
if (node.getAttribute && node.getAttribute('data-line-number')) {
|
||||||
margin: [0, 2, 0, 0]
|
if (currentCol) {
|
||||||
};
|
ComputeStyle(currentCol, elementStyles[nodeName]);
|
||||||
var HeaderOutsideLineNumberText = {
|
outerStack.stack.push(currentCol);
|
||||||
text: element.childNodes[1].textContent,
|
}
|
||||||
};
|
currentCol = {
|
||||||
ComputeStyle(HeaderOutsideLineNumberText, elementStyles[nodeName]);
|
|
||||||
var HeaderOutsideLineNumberColumns = {
|
|
||||||
columns: [
|
columns: [
|
||||||
HeaderOutsideLineNumber,
|
getLineNumberObject(node.getAttribute('data-line-number')),
|
||||||
HeaderOutsideLineNumberText
|
|
||||||
],
|
],
|
||||||
margin: [0, 11, 0, 0]
|
margin: [0, 2, 0, 0],
|
||||||
};
|
};
|
||||||
alreadyConverted.push(HeaderOutsideLineNumberColumns);
|
} else if (node.textContent) {
|
||||||
|
var HeaderText = {
|
||||||
|
text: node.textContent,
|
||||||
|
};
|
||||||
|
currentCol.columns.push(HeaderText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ComputeStyle(currentCol, elementStyles[nodeName]);
|
||||||
|
outerStack.stack.push(currentCol);
|
||||||
|
outerStack.margin = [0, 0, 0, 0];
|
||||||
|
if (!/h[1-6]/.test(element.previousSibling.nodeName.toLowerCase())) {
|
||||||
|
outerStack.margin[1] = 10;
|
||||||
|
}
|
||||||
|
alreadyConverted.push(outerStack);
|
||||||
} else {
|
} else {
|
||||||
currentParagraph = create("text");
|
currentParagraph = create("text");
|
||||||
currentParagraph.marginBottom = 4;
|
currentParagraph.marginBottom = 4;
|
||||||
@ -861,7 +869,7 @@ angular.module('OpenSlidesApp.core.pdf', [])
|
|||||||
break;
|
break;
|
||||||
case "img":
|
case "img":
|
||||||
var regex = /([\w-]*)\s*:\s*([^;]*)/g;
|
var regex = /([\w-]*)\s*:\s*([^;]*)/g;
|
||||||
var match; //helper variable for the refegex
|
var match; //helper variable for the regex
|
||||||
var imageSize={};
|
var imageSize={};
|
||||||
var maxResolution = {
|
var maxResolution = {
|
||||||
width: 435,
|
width: 435,
|
||||||
|
@ -300,7 +300,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
style: 'heading3',
|
style: 'heading3',
|
||||||
marginTop: 25,
|
marginTop: 25,
|
||||||
});
|
});
|
||||||
reason.push(converter.convertHTML(motion.getReason(motionVersion), lineNumberMode));
|
reason.push(converter.convertHTML(motion.getReason(motionVersion), 'none'));
|
||||||
}
|
}
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user