Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2c41d1ee1 | ||
|
|
747bcacf2c | ||
|
|
3830cff687 | ||
|
|
e38cd50037 | ||
|
|
85b02add89 |
12
CHANGES.md
12
CHANGES.md
@@ -1,5 +1,17 @@
|
||||
# Changes
|
||||
|
||||
## 4.2.4
|
||||
* patch: fixes [#142](https://github.com/wickedest/Mergely/issues/142). Added README.md to examples.
|
||||
|
||||
## 4.2.3
|
||||
* patch: fixes [#147](https://github.com/wickedest/Mergely/issues/147). Fixes the css style for the currently selected change.
|
||||
|
||||
## 4.2.2:
|
||||
* patch: fixes issue where initial change was not being set causing next/prev and merge actions to not work as expected.
|
||||
|
||||
## 4.2.1:
|
||||
* chore: updated dependencies, cleared security issues
|
||||
|
||||
## 4.2.0:
|
||||
* minor: added new option `ignoreaccents` to ignore accented characters.
|
||||
|
||||
|
||||
32
examples/README.md
Normal file
32
examples/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Mergely examples
|
||||
|
||||
To run these examples, you need to run:
|
||||
|
||||
```bash
|
||||
$ npm start
|
||||
```
|
||||
|
||||
This runs Mergely in a hot dev-server for development.
|
||||
|
||||
## Main example
|
||||
http://localhost:8080
|
||||
|
||||
Shows basic functionality.
|
||||
|
||||
## Ajax example
|
||||
|
||||
http://localhost:8080/examples/ajax.html
|
||||
|
||||
Who still says "ajax" these days? Anyway, this example demonstrates how to load your left-hand and right-hand sources from external URL, and also how to skin your own editor, and provide drop-file functionality.
|
||||
|
||||
## Simple example
|
||||
|
||||
This example demonstrates how to load your left-hand and right-hand sources from static text.
|
||||
|
||||
http://localhost:8080/examples/simple.html
|
||||
|
||||
## Size example
|
||||
|
||||
This example demonstrates how to size your editors, and also how to have multiple editors on the same page.
|
||||
|
||||
http://localhost:8080/examples/size.html
|
||||
@@ -53,11 +53,13 @@ module.exports = function(config) {
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin([{
|
||||
from: 'src/mergely.css',
|
||||
to: 'mergely.css',
|
||||
toType: 'file'
|
||||
}])
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [{
|
||||
from: 'src/mergely.css',
|
||||
to: 'mergely.css',
|
||||
toType: 'file'
|
||||
}]
|
||||
})
|
||||
]
|
||||
},
|
||||
webpackServer: {
|
||||
|
||||
37
package.json
37
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mergely",
|
||||
"version": "4.2.0",
|
||||
"version": "4.2.4",
|
||||
"description": "A javascript UI for diff/merge",
|
||||
"directories": {
|
||||
"doc": "doc",
|
||||
@@ -36,34 +36,33 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.1.6",
|
||||
"@babel/preset-env": "^7.1.6",
|
||||
"@webpack-cli/init": "^0.1.2",
|
||||
"@webpack-cli/init": "^1.0.1",
|
||||
"babel-loader": "^8.0.4",
|
||||
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
||||
"chai": "^4.1.2",
|
||||
"codemirror": "^5.50.2",
|
||||
"copy-webpack-plugin": "^4.6.0",
|
||||
"css-loader": "^0.28.11",
|
||||
"file-loader": "^1.1.5",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"image-webpack-loader": "^3.4.2",
|
||||
"jquery": "^3.2.1",
|
||||
"karma": "^3.1.1",
|
||||
"copy-webpack-plugin": "^6.2.1",
|
||||
"css-loader": "^5.0.0",
|
||||
"file-loader": "^6.1.1",
|
||||
"html-webpack-plugin": "^4.5.0",
|
||||
"image-webpack-loader": "^7.0.1",
|
||||
"jquery": "^3.5.1",
|
||||
"karma": "^5.2.3",
|
||||
"karma-chai": "^0.1.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-coverage-istanbul-reporter": "^1.3.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-mocha-reporter": "^2.2.5",
|
||||
"karma-webpack": "^2.0.9",
|
||||
"mocha": "^4.0.1",
|
||||
"style-loader": "^0.23.0",
|
||||
"uglifyjs-webpack-plugin": "^2.0.1",
|
||||
"webpack": "^4.20.2",
|
||||
"webpack-cli": "^3.1.2",
|
||||
"webpack-dev-server": "^3.1.9"
|
||||
"karma-webpack": "^4.0.2",
|
||||
"mocha": "^8.1.3",
|
||||
"style-loader": "^2.0.0",
|
||||
"webpack": "^4.44.2",
|
||||
"webpack-cli": "^4.0.0",
|
||||
"webpack-dev-server": "^3.11.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -rf lib && webpack --config ./webpack.prod.js",
|
||||
"start": "webpack-dev-server -w --debug --progress --colors --config ./webpack.dev.js --content-base ./dist --inline --hot --host 0.0.0.0",
|
||||
"start": "webpack serve --config webpack.dev.js",
|
||||
"test": "karma start",
|
||||
"test:chrome": "karma start --browsers Chrome --singleRun=false"
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
scrollToDiff: function(direction) {
|
||||
if (!this.changes.length) return;
|
||||
if (direction == 'next') {
|
||||
if (this._current_diff == this.changes.length -1) {
|
||||
if (this._current_diff == this.changes.length - 1) {
|
||||
this._current_diff = 0;
|
||||
} else {
|
||||
this._current_diff = Math.min(++this._current_diff, this.changes.length - 1);
|
||||
@@ -893,6 +893,11 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
this._skipscroll[editor_name] = false;
|
||||
return;
|
||||
}
|
||||
if (!this.changes) {
|
||||
// pasting a wide line can trigger scroll before changes
|
||||
// are calculated
|
||||
return;
|
||||
}
|
||||
var scroller = jQuery(this.editor[editor_name].getScrollerElement());
|
||||
if (this.midway == undefined) {
|
||||
this.midway = (scroller.height() / 2.0 + scroller.offset().top).toFixed(2);
|
||||
@@ -1045,11 +1050,13 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
this.trace('change', 'diff time', Timer.stop());
|
||||
this.changes = Mgly.DiffParser(d.normal_form());
|
||||
this.trace('change', 'parse time', Timer.stop());
|
||||
if (this._current_diff === undefined && this.changes.length && this._initializing) {
|
||||
if (this._current_diff === undefined && this.changes.length) {
|
||||
// go to first difference on start-up where values are provided in
|
||||
// settings.
|
||||
this._current_diff = 0;
|
||||
this._scroll_to_change(this.changes[0]);
|
||||
if (this._initializing) {
|
||||
this._scroll_to_change(this.changes[0]);
|
||||
}
|
||||
}
|
||||
this.trace('change', 'scroll_to_change time', Timer.stop());
|
||||
this._calculate_offsets(editor_name1, editor_name2, this.changes);
|
||||
@@ -1466,8 +1473,8 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
|
||||
// gutter markup that highlights all gutter line numbers for the current change.
|
||||
// cm doesn't give us the ability to style the line numbers directly.
|
||||
var lhsLineNumbers = jQuery('#mergely-lhs ~ .CodeMirror .CodeMirror-code .CodeMirror-linenumber.CodeMirror-gutter-elt');
|
||||
var rhsLineNumbers = jQuery('#mergely-rhs ~ .CodeMirror .CodeMirror-code .CodeMirror-linenumber.CodeMirror-gutter-elt');
|
||||
var lhsLineNumbers = jQuery('#' + this.id + '-lhs ~ .CodeMirror .CodeMirror-code .CodeMirror-linenumber.CodeMirror-gutter-elt');
|
||||
var rhsLineNumbers = jQuery('#' + this.id + '-rhs ~ .CodeMirror .CodeMirror-code .CodeMirror-linenumber.CodeMirror-gutter-elt');
|
||||
var jf, jt, i, j;
|
||||
rhsLineNumbers.removeClass('mergely current');
|
||||
lhsLineNumbers.removeClass('mergely current');
|
||||
|
||||
@@ -586,28 +586,48 @@ describe('mergely', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not be vulnerable to XSS', function (done) {
|
||||
function initXSS(options) {
|
||||
$('body').get(0).innerHTML = "<!DOCTYPE html><html lang=\"en\"><body><div id='mergely<script id=\"injected\">alert(123)</script>'></div></body></html>";
|
||||
const divs = document.getElementsByTagName('div');
|
||||
editor = $(divs[0]);
|
||||
editor.mergely(options);
|
||||
return editor;
|
||||
};
|
||||
it('should not be vulnerable to XSS', function (done) {
|
||||
function initXSS(options) {
|
||||
$('body').get(0).innerHTML = "<!DOCTYPE html><html lang=\"en\"><body><div id='mergely<script id=\"injected\">alert(123)</script>'></div></body></html>";
|
||||
const divs = document.getElementsByTagName('div');
|
||||
editor = $(divs[0]);
|
||||
editor.mergely(options);
|
||||
return editor;
|
||||
};
|
||||
|
||||
$(document).ready(() => {
|
||||
const editor = initXSS({
|
||||
height: 100,
|
||||
viewport: true,
|
||||
license: 'lgpl-separate-notice',
|
||||
lhs: (setValue) => setValue(macbeth),
|
||||
rhs: (setValue) => setValue(macbeth)
|
||||
});
|
||||
expect($('body').find('#injected')).to.have.length(0, 'expected no div with id injected');
|
||||
const divs = document.getElementsByTagName('div');
|
||||
expect(divs).to.have.length(1);
|
||||
expect(divs[0].id).to.equal('mergely<script id="injected">alert(123)</script>');
|
||||
$(document).ready(() => {
|
||||
const editor = initXSS({
|
||||
height: 100,
|
||||
viewport: true,
|
||||
license: 'lgpl-separate-notice',
|
||||
lhs: (setValue) => setValue(macbeth),
|
||||
rhs: (setValue) => setValue(macbeth)
|
||||
});
|
||||
expect($('body').find('#injected')).to.have.length(0, 'expected no div with id injected');
|
||||
const divs = document.getElementsByTagName('div');
|
||||
expect(divs).to.have.length(1);
|
||||
expect(divs[0].id).to.equal('mergely<script id="injected">alert(123)</script>');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should ignore accented characters', function (done) {
|
||||
$(document).ready(() => {
|
||||
const editor = init({
|
||||
height: 100,
|
||||
license: 'lgpl-separate-notice',
|
||||
ignoreaccents: true,
|
||||
lhs: (setValue) => setValue('comunicação'),
|
||||
rhs: (setValue) => setValue('comunicacao')
|
||||
});
|
||||
const { mergely } = $('#mergely');
|
||||
|
||||
$('#mergely').on('updated', () => {
|
||||
console.log('updated');
|
||||
const diff = $('#mergely').mergely('diff');;
|
||||
expect(diff).to.equal('');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,10 +19,7 @@ module.exports = {
|
||||
}, {
|
||||
test: /\.css$/,
|
||||
use: [{
|
||||
loader: 'style-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
loader: 'style-loader'
|
||||
}, {
|
||||
loader: 'css-loader'
|
||||
}]
|
||||
@@ -69,11 +66,9 @@ module.exports = {
|
||||
test: /[\\/]node_modules[\\/]/
|
||||
}
|
||||
},
|
||||
|
||||
chunks: 'async',
|
||||
minChunks: 1,
|
||||
minSize: 30000,
|
||||
name: true
|
||||
minSize: 30000
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,12 @@ module.exports = {
|
||||
CodeMirror: 'CodeMirror'
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin([{
|
||||
from: 'src/mergely.css',
|
||||
to: 'mergely.css',
|
||||
toType: 'file'
|
||||
}])
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [{
|
||||
from: 'src/mergely.css',
|
||||
to: 'mergely.css',
|
||||
toType: 'file'
|
||||
}]
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user