mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
[test-in-browser] Replace diff_match_patch with diff library
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
////
|
||||
//// Setup
|
||||
////
|
||||
import { diff_match_patch } from './diff_match_patch_uncompressed'
|
||||
import { diffChars } from 'diff'
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
|
||||
const arraysEqual = (a, b) => {
|
||||
@@ -628,10 +628,13 @@ Template.event.events({
|
||||
|
||||
// e.g. doDiff('abc', 'bcd') => [[-1, 'a'], [0, 'bc'], [1, 'd']]
|
||||
var doDiff = function (str1, str2) {
|
||||
var D = new diff_match_patch();
|
||||
var pieces = D.diff_main(str1, str2, false);
|
||||
D.diff_cleanupSemantic(pieces);
|
||||
return pieces;
|
||||
const diff = diffChars(str1, str2);
|
||||
|
||||
return diff.map(part => {
|
||||
if (part.added) return [1, part.value];
|
||||
if (part.removed) return [-1, part.value];
|
||||
return [0, part.value];
|
||||
});
|
||||
};
|
||||
|
||||
Template.event.helpers({
|
||||
|
||||
@@ -6,6 +6,7 @@ Package.describe({
|
||||
|
||||
Npm.depends({
|
||||
'bootstrap': '4.3.1',
|
||||
'diff': '8.0.2'
|
||||
});
|
||||
|
||||
Package.onUse(function (api) {
|
||||
|
||||
Reference in New Issue
Block a user