Release version 2.0.0-rc.9
This commit is contained in:
parent
9bbc87ae89
commit
0f38cdeb79
6 changed files with 414 additions and 452 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "diff2html",
|
||||
"version": "2.0.0-rc.8",
|
||||
"version": "2.0.0-rc.9",
|
||||
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
||||
"description": "Fast Diff to colorized HTML",
|
||||
"keywords": [
|
||||
|
|
|
|||
52
dist/diff2html-ui.js
vendored
52
dist/diff2html-ui.js
vendored
|
|
@ -13,11 +13,10 @@
|
|||
/*global $, hljs, Diff2Html*/
|
||||
|
||||
(function() {
|
||||
|
||||
var highlightJS = require('./highlight.js-internals.js').HighlightJS;
|
||||
|
||||
var diffJson = null;
|
||||
var defaultTarget = "body";
|
||||
var defaultTarget = 'body';
|
||||
var currentSelectionColumnId = -1;
|
||||
|
||||
function Diff2HtmlUI(config) {
|
||||
|
|
@ -42,13 +41,11 @@
|
|||
|
||||
function synchronisedScroll($target, config) {
|
||||
if (config.synchronisedScroll) {
|
||||
|
||||
$target.find(".d2h-file-side-diff").scroll(function() {
|
||||
$target.find('.d2h-file-side-diff').scroll(function() {
|
||||
var $this = $(this);
|
||||
$this.closest(".d2h-file-wrapper").find(".d2h-file-side-diff")
|
||||
$this.closest('.d2h-file-wrapper').find('.d2h-file-side-diff')
|
||||
.scrollLeft($this.scrollLeft());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +54,9 @@
|
|||
|
||||
var hashTag = this._getHashTag();
|
||||
|
||||
var $showBtn = $target.find(".d2h-show");
|
||||
var $hideBtn = $target.find(".d2h-hide");
|
||||
var $fileList = $target.find(".d2h-file-list");
|
||||
var $showBtn = $target.find('.d2h-show');
|
||||
var $hideBtn = $target.find('.d2h-hide');
|
||||
var $fileList = $target.find('.d2h-file-list');
|
||||
|
||||
if (hashTag === 'files-summary-show') show();
|
||||
else if (hashTag === 'files-summary-hide') hide();
|
||||
|
|
@ -88,22 +85,22 @@
|
|||
var $target = that._getTarget(targetId);
|
||||
|
||||
// collect all the diff files and execute the highlight on their lines
|
||||
var $files = $target.find(".d2h-file-wrapper");
|
||||
var $files = $target.find('.d2h-file-wrapper');
|
||||
$files.map(function(_i, file) {
|
||||
var oldLinesState;
|
||||
var newLinesState;
|
||||
var $file = $(file);
|
||||
var language = $file.data("lang");
|
||||
var language = $file.data('lang');
|
||||
|
||||
// collect all the code lines and execute the highlight on them
|
||||
var $codeLines = $file.find(".d2h-code-line-ctn");
|
||||
var $codeLines = $file.find('.d2h-code-line-ctn');
|
||||
$codeLines.map(function(_j, line) {
|
||||
var $line = $(line);
|
||||
var text = line.textContent;
|
||||
var lineParent = line.parentNode;
|
||||
|
||||
var lineState;
|
||||
if (lineParent.className.indexOf("d2h-del") !== -1) {
|
||||
if (lineParent.className.indexOf('d2h-del') !== -1) {
|
||||
lineState = oldLinesState;
|
||||
} else {
|
||||
lineState = newLinesState;
|
||||
|
|
@ -111,9 +108,9 @@
|
|||
|
||||
var result = hljs.getLanguage(language) ? hljs.highlight(language, text, true, lineState) : hljs.highlightAuto(text);
|
||||
|
||||
if (lineParent.className.indexOf("d2h-del") !== -1) {
|
||||
if (lineParent.className.indexOf('d2h-del') !== -1) {
|
||||
oldLinesState = result.top;
|
||||
} else if (lineParent.className.indexOf("d2h-ins") !== -1) {
|
||||
} else if (lineParent.className.indexOf('d2h-ins') !== -1) {
|
||||
newLinesState = result.top;
|
||||
} else {
|
||||
oldLinesState = result.top;
|
||||
|
|
@ -127,7 +124,7 @@
|
|||
result.value = highlightJS.mergeStreams(originalStream, highlightJS.nodeStream(resultNode), text);
|
||||
}
|
||||
|
||||
$line.addClass("hljs");
|
||||
$line.addClass('hljs');
|
||||
$line.addClass(result.language);
|
||||
$line.html(result.value);
|
||||
});
|
||||
|
|
@ -143,7 +140,7 @@
|
|||
$target = $(targetId);
|
||||
} else {
|
||||
console.error("Wrong target provided! Falling back to default value 'body'.");
|
||||
console.log("Please provide a jQuery object or a valid DOM query string.");
|
||||
console.log('Please provide a jQuery object or a valid DOM query string.');
|
||||
$target = $(defaultTarget);
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +192,6 @@
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
Diff2HtmlUI.prototype._getSelectedText = function() {
|
||||
var sel = window.getSelection();
|
||||
var range = sel.getRangeAt(0);
|
||||
|
|
@ -220,7 +216,6 @@
|
|||
|
||||
// Expose diff2html in the browser
|
||||
global.Diff2HtmlUI = Diff2HtmlUI;
|
||||
|
||||
})();
|
||||
|
||||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
|
|
@ -233,7 +228,6 @@
|
|||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
function HighlightJS() {
|
||||
}
|
||||
|
||||
|
|
@ -258,9 +252,9 @@
|
|||
var result = [];
|
||||
(function _nodeStream(node, offset) {
|
||||
for (var child = node.firstChild; child; child = child.nextSibling) {
|
||||
if (child.nodeType == 3)
|
||||
if (child.nodeType === 3) {
|
||||
offset += child.nodeValue.length;
|
||||
else if (child.nodeType == 1) {
|
||||
} else if (child.nodeType === 1) {
|
||||
result.push({
|
||||
event: 'start',
|
||||
offset: offset,
|
||||
|
|
@ -293,7 +287,7 @@
|
|||
if (!original.length || !highlighted.length) {
|
||||
return original.length ? original : highlighted;
|
||||
}
|
||||
if (original[0].offset != highlighted[0].offset) {
|
||||
if (original[0].offset !== highlighted[0].offset) {
|
||||
return (original[0].offset < highlighted[0].offset) ? original : highlighted;
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +304,7 @@
|
|||
return highlighted;
|
||||
... which is collapsed to:
|
||||
*/
|
||||
return highlighted[0].event == 'start' ? original : highlighted;
|
||||
return highlighted[0].event === 'start' ? original : highlighted;
|
||||
}
|
||||
|
||||
function open(node) {
|
||||
|
|
@ -326,15 +320,14 @@
|
|||
}
|
||||
|
||||
function render(event) {
|
||||
(event.event == 'start' ? open : close)(event.node);
|
||||
(event.event === 'start' ? open : close)(event.node);
|
||||
}
|
||||
|
||||
while (original.length || highlighted.length) {
|
||||
var stream = selectStream();
|
||||
result += escape(value.substr(processed, stream[0].offset - processed));
|
||||
processed = stream[0].offset;
|
||||
if (stream == original) {
|
||||
|
||||
if (stream === original) {
|
||||
/*
|
||||
On any opening or closing tag of the original markup we first close
|
||||
the entire highlighted node stack, then render the original tag along
|
||||
|
|
@ -345,10 +338,10 @@
|
|||
do {
|
||||
render(stream.splice(0, 1)[0]);
|
||||
stream = selectStream();
|
||||
} while (stream == original && stream.length && stream[0].offset == processed);
|
||||
} while (stream === original && stream.length && stream[0].offset === processed);
|
||||
nodeStack.reverse().forEach(open);
|
||||
} else {
|
||||
if (stream[0].event == 'start') {
|
||||
if (stream[0].event === 'start') {
|
||||
nodeStack.push(stream[0].node);
|
||||
} else {
|
||||
nodeStack.pop();
|
||||
|
|
@ -362,7 +355,6 @@
|
|||
/* **** Highlight.js Private API **** */
|
||||
|
||||
module.exports.HighlightJS = new HighlightJS();
|
||||
|
||||
})();
|
||||
|
||||
},{}]},{},[1]);
|
||||
|
|
|
|||
2
dist/diff2html-ui.min.js
vendored
2
dist/diff2html-ui.min.js
vendored
File diff suppressed because one or more lines are too long
801
dist/diff2html.js
vendored
801
dist/diff2html.js
vendored
File diff suppressed because it is too large
Load diff
7
dist/diff2html.min.js
vendored
7
dist/diff2html.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "diff2html",
|
||||
"version": "2.0.0-rc.8",
|
||||
"version": "2.0.0-rc.9",
|
||||
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
||||
"description": "Fast Diff to colorized HTML",
|
||||
"keywords": [
|
||||
|
|
|
|||
Loading…
Reference in a new issue