Merge pull request #3342 from FinnStutzenstein/Umlaute

Fixing strange umlauts when copy text from word
This commit is contained in:
Emanuel Schütze 2017-08-16 14:11:28 +02:00 committed by GitHub
commit 14e38861c7
2 changed files with 12 additions and 1 deletions

View File

@ -78,7 +78,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, #3347].
- Bugfixes for PDF creation [#3227, #3251, #3279, #3286, #3346, #3347, #3342].
- Improvements for plugin integration [#3330].

View File

@ -119,10 +119,21 @@ angular.module('OpenSlidesApp.core.pdf', [])
.factory('HTMLValidizer', function() {
var HTMLValidizer = {};
// In some cases copying from word to OpenSlides results in umlauts
// that are the base letter and then the entity #776; to make the dots
// above the base letter. This breaks the PDF.
HTMLValidizer.replaceMalformedUmlauts = function (text) {
return text.replace(/([aeiouAEIOUy])[\u0308]/g, function (match, baseChar) {
return '&' + baseChar + 'uml;';
});
};
//checks if str is valid HTML. Returns valid HTML if not,
//return emptystring if empty
HTMLValidizer.validize = function(str) {
if (str) {
str = HTMLValidizer.replaceMalformedUmlauts(str);
var a = document.createElement('div');
a.innerHTML = str;
angular.forEach(a.childNodes, function (child) {