Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
decorateNode: (text, node) => {
if (!this.props.diffBase) {
return;
}
const baseDocument = Slate.Value.fromJSON(
JSON.parse(this.props.diffBase.rawData),
).document;
const currentDocument = this.state.state.document;
const diffs = diffWordsWithSpace(
baseDocument.text,
currentDocument.text,
);
let characters = text.characters.asMutable();
let index = 0;
const document = this.state.state.document;
for (let diff of diffs) {
if (diff.removed) {
continue;
}
if (diff.added) {
for (
let characterIndex = index;
characterIndex < index + diff.value.length;
first: {
prefix: linePrefix1,
line: utils.escape(unprefixedLine1)
},
second: {
prefix: linePrefix2,
line: utils.escape(unprefixedLine2)
}
};
}
let diff;
if (config.diffStyle === "char") {
diff = jsDiff.diffChars(unprefixedLine1, unprefixedLine2);
} else {
diff = jsDiff.diffWordsWithSpace(unprefixedLine1, unprefixedLine2);
}
let highlightedLine = "";
const changedWords = [];
if (config.diffStyle === "word" && config.matching === "words") {
let treshold = 0.25;
if (typeof config.matchWordsThreshold !== "undefined") {
treshold = config.matchWordsThreshold;
}
const matcher = Rematch.rematch(function(a, b) {
const amod = a.value;
const bmod = b.value;
function errorDiff(actual, expected) {
return diff
.diffWordsWithSpace(actual, expected)
.map(function(str) {
if (str.added) {
return colorLines('diff added', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
}
return str.value;
})
.join('');
}
function errorDiff(actual, expected) {
return diff
.diffWordsWithSpace(actual, expected)
.map(function(str) {
if (str.added) {
return colorLines('diff added', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
}
return str.value;
})
.join('');
}
function errorDiff(actual, expected) {
return diff
.diffWordsWithSpace(actual, expected)
.map(function(str) {
if (str.added) {
return colorLines('diff added', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
}
return str.value;
})
.join('');
}
function errorDiff(actual, expected) {
return diff
.diffWordsWithSpace(actual, expected)
.map(function(str) {
if (str.added) {
return colorLines('diff added', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
}
return str.value;
})
.join('');
}
function errorDiff(actual, expected) {
return diff
.diffWordsWithSpace(actual, expected)
.map(function(str) {
if (str.added) {
return colorLines('diff added', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
}
return str.value;
})
.join('');
}
function buildMarkup(oldText, newText) {
const diffElement = document.createDocumentFragment();
diff.diffWordsWithSpace(oldText, newText).forEach((part) => {
let className = '';
if (part.added) className = 'diff-added';
else if (part.removed) className = 'diff-removed';
const span = document.createElement('span');
$(span).addClass(className);
span.appendChild(document.createTextNode(part.value));
diffElement.appendChild(span);
});
return diffElement;
}
var prefixSize = 1;
if (config.isCombined) {
prefixSize = 2;
}
linePrefix1 = diffLine1.substr(0, prefixSize);
linePrefix2 = diffLine2.substr(0, prefixSize);
unprefixedLine1 = diffLine1.substr(prefixSize);
unprefixedLine2 = diffLine2.substr(prefixSize);
var diff;
if (config.charByChar) {
diff = jsDiff.diffChars(unprefixedLine1, unprefixedLine2);
} else {
diff = jsDiff.diffWordsWithSpace(unprefixedLine1, unprefixedLine2);
}
var highlightedLine = '';
var changedWords = [];
if (!config.charByChar && config.matching === 'words') {
var treshold = 0.25;
if (typeof (config.matchWordsThreshold) !== 'undefined') {
treshold = config.matchWordsThreshold;
}
var matcher = Rematch.rematch(function(a, b) {
var amod = a.value;
var bmod = b.value;