Merge pull request #6047 from CatoTH/bugfix-6030-amending-list-items

Fixes #6030 - amending a list item does not show the change inline in…
This commit is contained in:
Emanuel Schütze 2021-05-03 13:01:49 +02:00 committed by GitHub
commit 261c69387f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 3 deletions

View File

@ -1866,21 +1866,37 @@ export class DiffService {
// We only do this for P for now, as for more complex types like UL/LI that tend to be nestend,
// information would get lost by this that we will need to recursively merge it again later on.
let oldIsSplitAfter = false,
newIsSplitAfter = false;
newIsSplitAfter = false,
oldIsSplitBefore = false,
newIsSplitBefore = false;
htmlOld = htmlOld.replace(
/(\s*<p[^>]+class\s*=\s*["'][^"']*)os-split-after/gi,
/(\s*<(?:p|ul|ol|li|blockquote|div)[^>]+class\s*=\s*["'][^"']*)os-split-after */gi,
(match: string, beginning: string): string => {
oldIsSplitAfter = true;
return beginning;
}
);
htmlNew = htmlNew.replace(
/(\s*<p[^>]+class\s*=\s*["'][^"']*)os-split-after/gi,
/(\s*<(?:p|ul|ol|li|blockquote|div)[^>]+class\s*=\s*["'][^"']*)os-split-after */gi,
(match: string, beginning: string): string => {
newIsSplitAfter = true;
return beginning;
}
);
htmlOld = htmlOld.replace(
/(\s*<(?:p|ul|ol|li|blockquote|div)[^>]+class\s*=\s*["'][^"']*)os-split-before */gi,
(match: string, beginning: string): string => {
oldIsSplitBefore = true;
return beginning;
}
);
htmlNew = htmlNew.replace(
/(\s*<(?:p|ul|ol|li|blockquote|div)[^>]+class\s*=\s*["'][^"']*)os-split-before */gi,
(match: string, beginning: string): string => {
newIsSplitBefore = true;
return beginning;
}
);
// Performing the actual diff
const str = this.diffString(workaroundPrepend + htmlOld, workaroundPrepend + htmlNew);
@ -2150,6 +2166,9 @@ export class DiffService {
if (oldIsSplitAfter || newIsSplitAfter) {
diff = this.addClassToLastNode(diff, 'os-split-after');
}
if (oldIsSplitBefore || newIsSplitBefore) {
diff = this.addClassToLastNode(diff, 'os-split-before');
}
this.diffCache.put(cacheKey, diff);
return diff;