code refactoring
This commit is contained in:
parent
fb4c302ddd
commit
57c4369849
2
css/main.min.css
vendored
2
css/main.min.css
vendored
File diff suppressed because one or more lines are too long
24
index.html
24
index.html
@ -1669,15 +1669,21 @@
|
|||||||
clone.querySelector('.entry__author').textContent = editor
|
clone.querySelector('.entry__author').textContent = editor
|
||||||
if (oldText !== '') {
|
if (oldText !== '') {
|
||||||
const frag = document.createDocumentFragment()
|
const frag = document.createDocumentFragment()
|
||||||
Diff.diffChars(oldText, plainText).forEach((part) => {
|
Diff.diffWords(oldText, plainText).forEach((part) => {
|
||||||
const type = part.added ? 'added' :
|
if (part.hasOwnProperty('added') || part.hasOwnProperty('removed')) {
|
||||||
part.removed ? 'removed' : '';
|
const type = part.added ? 'added' :
|
||||||
frag.append(
|
part.removed ? 'removed' : '';
|
||||||
createElement('span', {
|
frag.append(
|
||||||
textContent: part.value,
|
createElement('span', {
|
||||||
className: type
|
textContent: part.value,
|
||||||
})
|
className: type
|
||||||
);
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
frag.append(
|
||||||
|
document.createTextNode(part.value)
|
||||||
|
)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
clone.querySelector('.entry__changes').append(frag)
|
clone.querySelector('.entry__changes').append(frag)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user