Merge pull request #3946 from CatoTH/v2.3.x-Bugfix-Diff2
Diff-Bugfixes regarding replaced list items
This commit is contained in:
commit
1b6d8baeaf
@ -16,7 +16,7 @@ Bugfixes:
|
|||||||
- Fixed amendment csv export (added missing submitters and recommendation, removed
|
- Fixed amendment csv export (added missing submitters and recommendation, removed
|
||||||
html tags for old and new text) [#3942].
|
html tags for old and new text) [#3942].
|
||||||
- Fixed motion/amendment diff bug: does not delete a paragraph/list item
|
- Fixed motion/amendment diff bug: does not delete a paragraph/list item
|
||||||
before an new one was inserted [#3943].
|
before an new one was inserted [#3943, #3946].
|
||||||
|
|
||||||
|
|
||||||
Version 2.3 (2018-09-20)
|
Version 2.3 (2018-09-20)
|
||||||
|
@ -1257,13 +1257,14 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
|||||||
|
|
||||||
if (lineLength !== undefined) {
|
if (lineLength !== undefined) {
|
||||||
oldTextWithBreaks = lineNumberingService.insertLineNumbersNode(oldText, lineLength, null, firstLineNumber);
|
oldTextWithBreaks = lineNumberingService.insertLineNumbersNode(oldText, lineLength, null, firstLineNumber);
|
||||||
newTextWithBreaks = lineNumberingService.insertLineNumbersNode(newText, lineLength, null, firstLineNumber);
|
newText = lineNumberingService.insertLineBreaksWithoutNumbers(newText, lineLength);
|
||||||
} else {
|
} else {
|
||||||
oldTextWithBreaks = document.createElement('div');
|
oldTextWithBreaks = document.createElement('div');
|
||||||
oldTextWithBreaks.innerHTML = oldText;
|
oldTextWithBreaks.innerHTML = oldText;
|
||||||
newTextWithBreaks = document.createElement('div');
|
|
||||||
newTextWithBreaks.innerHTML = newText;
|
|
||||||
}
|
}
|
||||||
|
newText = newText.replace(/^\s+/g, '').replace(/\s+$/g, '');
|
||||||
|
newTextWithBreaks = document.createElement('div');
|
||||||
|
newTextWithBreaks.innerHTML = newText;
|
||||||
|
|
||||||
for (var i = 0; i < oldTextWithBreaks.childNodes.length; i++) {
|
for (var i = 0; i < oldTextWithBreaks.childNodes.length; i++) {
|
||||||
currChild = oldTextWithBreaks.childNodes[i];
|
currChild = oldTextWithBreaks.childNodes[i];
|
||||||
|
@ -68,6 +68,8 @@ angular.module('OpenSlidesApp.motions.lineNumbering', [])
|
|||||||
return this._ignoreInsertedText;
|
return this._ignoreInsertedText;
|
||||||
} else if (this._isOsLineNumberNode(node)) {
|
} else if (this._isOsLineNumberNode(node)) {
|
||||||
return true;
|
return true;
|
||||||
|
} else if (node.classList && node.classList.contains('insert')) {
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -448,7 +450,7 @@ angular.module('OpenSlidesApp.motions.lineNumbering', [])
|
|||||||
throw 'This method may only be called for ELEMENT-nodes: ' + node.nodeValue;
|
throw 'This method may only be called for ELEMENT-nodes: ' + node.nodeValue;
|
||||||
}
|
}
|
||||||
if (this._isIgnoredByLineNumbering(node)) {
|
if (this._isIgnoredByLineNumbering(node)) {
|
||||||
if (this._currentInlineOffset === 0 && this._currentLineNumber !== null) {
|
if (this._currentInlineOffset === 0 && this._currentLineNumber !== null && this._isInlineElement(node)) {
|
||||||
var lineNumberNode = this._createLineNumber();
|
var lineNumberNode = this._createLineNumber();
|
||||||
if (lineNumberNode) {
|
if (lineNumberNode) {
|
||||||
node.insertBefore(lineNumberNode, node.firstChild);
|
node.insertBefore(lineNumberNode, node.firstChild);
|
||||||
|
@ -717,6 +717,20 @@ describe('linenumbering', function () {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('works with a replaced list item', function () {
|
||||||
|
var before = "<ul><li>Lorem ipsum <strong>dolor sit amet</strong>, consetetur sadipscing elitr, sed diam nonumy eirmod tempor.</li></ul>",
|
||||||
|
after = "<ul>\n<li>\n<p>At vero eos et accusam et justo duo dolores et ea rebum.</p>\n</li>\n</ul>\n",
|
||||||
|
expected = '<UL class="delete"><LI>' + noMarkup(1) + 'Lorem ipsum <STRONG>dolor sit amet</STRONG>, consetetur sadipscing elitr, sed diam nonumy ' + brMarkup(2) + 'eirmod tempor.</LI></UL>' +
|
||||||
|
"<UL class=\"insert\">\n<LI>\n<P>At vero eos et accusam et justo duo dolores et ea rebum.</P>\n</LI>\n</UL>";
|
||||||
|
|
||||||
|
var diff = diffService.diff(before, after, 80);
|
||||||
|
|
||||||
|
diff = diffService._normalizeHtmlForDiff(diff);
|
||||||
|
expected = diffService._normalizeHtmlForDiff(expected);
|
||||||
|
|
||||||
|
expect(diff.toLowerCase()).toBe(expected.toLowerCase());
|
||||||
|
});
|
||||||
|
|
||||||
it('detects broken HTML and lowercases class names', function () {
|
it('detects broken HTML and lowercases class names', function () {
|
||||||
var before = "<p><span class=\"line-number-3 os-line-number\" data-line-number=\"3\" contenteditable=\"false\"> </span>holen, da rief sie alle sieben herbei und sprach:</p>\n\n<p><span class=\"line-number-4 os-line-number\" data-line-number=\"4\" contenteditable=\"false\"> </span><span style=\"color: #000000;\">\"Liebe Kinder, ich will hinaus in den Wald, seid auf der Hut vor dem Wolf! Wenn er <br class=\"os-line-break\"><span class=\"line-number-5 os-line-number\" data-line-number=\"5\" contenteditable=\"false\"> </span>hereinkommt, frisst er euch alle mit Haut und Haar. Der Bösewicht verstellt sich oft, aber <br class=\"os-line-break\"><span class=\"line-number-6 os-line-number\" data-line-number=\"6\" contenteditable=\"false\"> </span>an der rauen Stimme und an seinen schwarzen Füßen werdet ihr ihn schon erkennen.\"</span></p>\n\n<p><span class=\"line-number-7 os-line-number\" data-line-number=\"7\" contenteditable=\"false\"> </span>Die Geißlein sagten: \" Liebe Mutter, wir wollen uns schon in acht nehmen, du kannst ohne </p>",
|
var before = "<p><span class=\"line-number-3 os-line-number\" data-line-number=\"3\" contenteditable=\"false\"> </span>holen, da rief sie alle sieben herbei und sprach:</p>\n\n<p><span class=\"line-number-4 os-line-number\" data-line-number=\"4\" contenteditable=\"false\"> </span><span style=\"color: #000000;\">\"Liebe Kinder, ich will hinaus in den Wald, seid auf der Hut vor dem Wolf! Wenn er <br class=\"os-line-break\"><span class=\"line-number-5 os-line-number\" data-line-number=\"5\" contenteditable=\"false\"> </span>hereinkommt, frisst er euch alle mit Haut und Haar. Der Bösewicht verstellt sich oft, aber <br class=\"os-line-break\"><span class=\"line-number-6 os-line-number\" data-line-number=\"6\" contenteditable=\"false\"> </span>an der rauen Stimme und an seinen schwarzen Füßen werdet ihr ihn schon erkennen.\"</span></p>\n\n<p><span class=\"line-number-7 os-line-number\" data-line-number=\"7\" contenteditable=\"false\"> </span>Die Geißlein sagten: \" Liebe Mutter, wir wollen uns schon in acht nehmen, du kannst ohne </p>",
|
||||||
after = "<p>holen, da rief sie alle sieben herbei und sprach:</p>\n\n<p><span style=\"color: #000000;\">Hello</span></p>\n\n<p><span style=\"color: #000000;\">World</span></p>\n\n<p><span style=\"color: #000000;\">Ya</span></p>\n\n<p>Die Geißlein sagten: \" Liebe Mutter, wir wollen uns schon in acht nehmen, du kannst ohne</p>";
|
after = "<p>holen, da rief sie alle sieben herbei und sprach:</p>\n\n<p><span style=\"color: #000000;\">Hello</span></p>\n\n<p><span style=\"color: #000000;\">World</span></p>\n\n<p><span style=\"color: #000000;\">Ya</span></p>\n\n<p>Die Geißlein sagten: \" Liebe Mutter, wir wollen uns schon in acht nehmen, du kannst ohne</p>";
|
||||||
|
@ -328,6 +328,14 @@ describe('linenumbering', function () {
|
|||||||
expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml);
|
expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not count within .insert nodes', function () {
|
||||||
|
var inHtml = "<p>1234</p><ul class=\"insert\"><li>1234</li></ul><p>1234 1234</p>";
|
||||||
|
var outHtml = lineNumberingService.insertLineNumbers(inHtml, 10);
|
||||||
|
expect(outHtml).toBe('<p>' + noMarkup(1) + '1234</p><ul class="insert"><li>1234</li></ul><p>' + noMarkup(2) + '1234 1234</p>');
|
||||||
|
expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml);
|
||||||
|
expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml);
|
||||||
|
});
|
||||||
|
|
||||||
it('does not create a new line for a trailing INS', function () {
|
it('does not create a new line for a trailing INS', function () {
|
||||||
var inHtml = "<p>et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur<ins>dsfsdf23</ins></p>";
|
var inHtml = "<p>et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur<ins>dsfsdf23</ins></p>";
|
||||||
var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80);
|
var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80);
|
||||||
|
Loading…
Reference in New Issue
Block a user