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