Merge pull request #3943 from CatoTH/v2.3.x-Bugfix-Diff
Diff Bugfix: inserted/deleted list items
This commit is contained in:
commit
709182119c
@ -6,14 +6,17 @@ https://openslides.org/
|
||||
|
||||
Version 2.3.1 (unreleased)
|
||||
==========================
|
||||
`Milestone <https://github.com/OpenSlides/OpenSlides/milestones/2.3.1>`_
|
||||
|
||||
Bugfixes:
|
||||
- Fixed image browser in CKEditor plugin to show uploaded images.
|
||||
- Fixed sorting of users in dropdowns for speakers, submitters and candidates.
|
||||
- Fixed election ballot paper layout (more space required for global 'no').
|
||||
- Fixed missing output of special poll values (for motions and elections).
|
||||
- Fixed image browser in CKEditor plugin to show uploaded images [#3889].
|
||||
- Fixed sorting of users in dropdowns for speakers, submitters and candidates [#3932].
|
||||
- Fixed election ballot paper layout (more space required for global 'no') [#3932].
|
||||
- Fixed missing output of special poll values (for motions and elections) [#3932].
|
||||
- Fixed amendment csv export (added missing submitters and recommendation, removed
|
||||
html tags for old and new text).
|
||||
html tags for old and new text) [#3942].
|
||||
- Fixed motion/amendment diff bug: does not delete a paragraph/list item
|
||||
before an new one was inserted [#3943].
|
||||
|
||||
|
||||
Version 2.3 (2018-09-20)
|
||||
|
@ -1545,6 +1545,33 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
||||
}
|
||||
);
|
||||
|
||||
// <ins><li>...</li></ins> => <li class="insert">...</li>
|
||||
diffUnnormalized = diffUnnormalized.replace(
|
||||
/<(ins|del)><(p|div|blockquote|li)([^>]*)>([\s\S]*)<\/\2><\/\1>/gi,
|
||||
function(whole, insDel, block, blockArguments, content) {
|
||||
// Prevent accidental matches like <ins><p>...</p>...</ins><ins>...<p></p></ins>
|
||||
if (content.match(/<(ins|del)>/gi)) {
|
||||
return whole;
|
||||
}
|
||||
|
||||
// Add the CSS-class to the existing "class"-attribute, or add one
|
||||
var newArguments = blockArguments;
|
||||
var modificationClass = (insDel.toLowerCase() === 'ins' ? 'insert' : 'delete');
|
||||
if (newArguments.match(/class="/gi)) {
|
||||
// class="someclass" => class="someclass insert"
|
||||
newArguments = newArguments.replace(/(class\s*=\s*)(["'])([^\2]*)\2/gi,
|
||||
function(classWhole, attr, para, content) {
|
||||
return attr + para + content + ' ' + modificationClass + para;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
newArguments += ' class="' + modificationClass + '"';
|
||||
}
|
||||
|
||||
return '<' + block + newArguments + '>' + content + '</' + block + '>';
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if (diffUnnormalized.substr(0, workaroundPrepend.length) === workaroundPrepend) {
|
||||
diffUnnormalized = diffUnnormalized.substring(workaroundPrepend.length);
|
||||
@ -1554,18 +1581,6 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
||||
if (this._diffDetectBrokenDiffHtml(diffUnnormalized)) {
|
||||
diff = this._diffParagraphs(htmlOld, htmlNew, lineLength, firstLineNumber);
|
||||
} else {
|
||||
diffUnnormalized = diffUnnormalized.replace(/<ins>.*?(\n.*?)*<\/ins>/gi, function (found) {
|
||||
found = found.replace(/<(div|p|li)[^>]*>/gi, function(match) { return match + '<ins>'; });
|
||||
found = found.replace(/<\/(div|p|li)[^>]*>/gi, function(match) { return '</ins>' + match; });
|
||||
return found;
|
||||
});
|
||||
diffUnnormalized = diffUnnormalized.replace(/<del>.*?(\n.*?)*<\/del>/gi, function (found) {
|
||||
found = found.replace(/<(div|p|li)[^>]*>/gi, function(match) { return match + '<del>'; });
|
||||
found = found.replace(/<\/(div|p|li)[^>]*>/gi, function(match) { return '</del>' + match; });
|
||||
return found;
|
||||
});
|
||||
diffUnnormalized = diffUnnormalized.replace(/^<del><p>(.*)<\/p><\/del>$/gi, function(match, inner) { return "<p>" + inner + "</p>"; });
|
||||
|
||||
var node = document.createElement('div');
|
||||
node.innerHTML = diffUnnormalized;
|
||||
diff = node.innerHTML;
|
||||
|
@ -563,7 +563,7 @@ describe('linenumbering', function () {
|
||||
var before = "<P>Ihr könnt ohne Sorge fortgehen.'Da meckerte die Alte und machte sich getrost auf den Weg.</P>",
|
||||
after = "";
|
||||
var diff = diffService.diff(before, after);
|
||||
expect(diff).toBe("<P class=\"delete\">Ihr könnt ohne Sorge fortgehen.'Da meckerte die Alte und machte sich getrost auf den Weg.</P>");
|
||||
expect(diff).toBe("<p class=\"delete\">Ihr könnt ohne Sorge fortgehen.'Da meckerte die Alte und machte sich getrost auf den Weg.</p>");
|
||||
});
|
||||
|
||||
it('does not repeat the last word (1)', function () {
|
||||
@ -661,7 +661,21 @@ describe('linenumbering', function () {
|
||||
'Gegenüber</p>';
|
||||
var diff = diffService.diff(inHtml, outHtml);
|
||||
expect(diff).toBe('<p>Test 123<br>wir strikt ab. lehnen wir ' + brMarkup(1486) + 'ab.<br>' + noMarkup(1487) + 'Gegenüber</p>')
|
||||
});
|
||||
});
|
||||
|
||||
it('does not delete a paragraph before an inserted one', function () {
|
||||
var inHtml = '<ul class="os-split-before"><li>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</li>\n' +
|
||||
'</ul>',
|
||||
outHtml = '<ul class="os-split-before">\n' +
|
||||
'<li>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</li>\n' +
|
||||
'<li class="testclass">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>\n' +
|
||||
'</ul>';
|
||||
var diff = diffService.diff(inHtml, outHtml);
|
||||
expect(diff).toBe('<ul class="os-split-before">' +
|
||||
'<li>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</li>' +
|
||||
'<li class="testclass insert">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>' +
|
||||
'</ul>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ignoring line numbers', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user