Compare commits
15 Commits
webpack-up
...
4.0.14
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06189782de | ||
|
|
5947f1b313 | ||
|
|
64960c770a | ||
|
|
73c1604981 | ||
|
|
66c4ed650f | ||
|
|
7a123a7ed7 | ||
|
|
90ab7f3f5e | ||
|
|
788c5ad17b | ||
|
|
09cfb5328e | ||
|
|
43ae12269c | ||
|
|
79608df3fb | ||
|
|
2474005eab | ||
|
|
4498b8bbf5 | ||
|
|
a2eaef8a13 | ||
|
|
d9f2edc1ad |
25
CHANGES.md
25
CHANGES.md
@@ -1,5 +1,24 @@
|
||||
# Changes
|
||||
|
||||
## 4.0.14
|
||||
* patch: fixes issue #104 where diff text conflicted with selected text
|
||||
|
||||
## 4.0.13
|
||||
* patch: fixed issue where `lhs_cmsettings` and `lhs_cmsettings` were ignored
|
||||
* patch: updated documentation
|
||||
* patch: fixed typos
|
||||
* patch: fixes issue #115 merging deleted line(s) from lhs would munge rhs text
|
||||
* patch: fixes two typos in README.md
|
||||
|
||||
## 4.0.11
|
||||
* patch: fixes typo in example ajax.html
|
||||
|
||||
## 4.0.10
|
||||
* patch: fixes bad 4.0.9 artifacts
|
||||
|
||||
## 4.0.9
|
||||
* patch: fixes issue #106 merge edge-case with add
|
||||
|
||||
## 4.0.8
|
||||
* chore: updated webpack
|
||||
|
||||
@@ -8,15 +27,15 @@
|
||||
|
||||
## 4.0.6
|
||||
|
||||
* #89: fixes missing merge buttons
|
||||
* patch: fixes issue #89 missing merge buttons
|
||||
|
||||
## 4.0.5
|
||||
|
||||
* #85: fixes XSS vulnerability with DOM id
|
||||
* patch: fixes issue #85 XSS vulnerability with DOM id
|
||||
|
||||
## 4.0.2
|
||||
|
||||
* #83: fixes poor rendering performance
|
||||
* patch: fixes issue #83 poor rendering performance
|
||||
|
||||
## 4.0.0
|
||||
|
||||
|
||||
32
README.md
32
README.md
@@ -2,19 +2,23 @@
|
||||
|
||||
http://mergely.com
|
||||
|
||||
Mergely is a javascript component to diff/merge files interactively in a browser, providing rich API that enables you to easily integrate Mergely into your existing web application. It is suitable for comparing text files online, e.g. .txt, .html, .xml, .c, .cpp, .java, etc. Mergely has a javascript implementation of the Longest Common Subsequence diff algorithm (LCS) and a customizable markup engine.
|
||||
Mergely is a JavaScript component for differencing and merging files interactively in a browser (diff/merge), providing rich API that enables you to easily integrate Mergely into your existing web application. It is suitable for comparing text files online, for example, .txt, .html, .xml, .c, .cpp, .java, etc.
|
||||
|
||||
Mergely has a JavaScript implementation of the Longest Common Subsequence (LCS) diff algorithm, and a customizable markup engine.
|
||||
|
||||
## Installation
|
||||
|
||||
### Installation via webpack
|
||||
The recommended way to install mergely is to use npm and [webpack](https://webpack.js.org/) to install mergely and its dependencies. It is highly recommended that you start by cloning [mergely-webpack](https://github.com/wickedest/mergely-webpack). It has everything that you need to get started.
|
||||
The recommended way to install mergely and its dependencies is to use a Node package manager (`npm` or `yarn`) and [webpack](https://webpack.js.org/).
|
||||
|
||||
It is highly recommended that you start by cloning [mergely-webpack](https://github.com/wickedest/mergely-webpack). The webpack has everything that you need to get started.
|
||||
|
||||
### Angular 6.1.1
|
||||
You can also use mergely within angular. You can start by cloning [mergely-angular](https://github.com/wickedest/mergely-angular).
|
||||
You can also use mergely within angular. You can start by cloning [mergely-angular](https://github.com/wickedest/mergely-angular).
|
||||
|
||||
### Installation via .tgz
|
||||
|
||||
Unpack mergely.tgz into a folder, e.g. `./lib`, and then add the following to the `<head>` of your target html source file.
|
||||
Unpack mergely.tgz into a folder, for example, `./lib`, and add the following to the `<head>` of your target HTML source file.
|
||||
|
||||
```html
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
@@ -25,7 +29,9 @@ Unpack mergely.tgz into a folder, e.g. `./lib`, and then add the following to th
|
||||
<link rel="stylesheet" media="all" href="lib/mergely/lib/mergely.css" />
|
||||
```
|
||||
|
||||
Create a div for the editor in `<body>`. This example uses a style that provides 8px padding (`mergely-full-screen-8`):
|
||||
Create a div for the editor in `<body>`.
|
||||
|
||||
This example uses a style that provides 8px padding (`mergely-full-screen-8`):
|
||||
|
||||
```html
|
||||
<div class="mergely-full-screen-8">
|
||||
@@ -45,7 +51,7 @@ $(document).ready(function () {
|
||||
|
||||
### Synchronous content initialization
|
||||
|
||||
The following example can be used to set the `lhs` and `rhs` editors synchronously (i.e. their contents are already known):
|
||||
The following example can be used to set the `lhs` and `rhs` editors synchronously (that is, when their contents are already known):
|
||||
|
||||
```js
|
||||
$(document).ready(function () {
|
||||
@@ -61,7 +67,7 @@ $(document).ready(function () {
|
||||
});
|
||||
```
|
||||
|
||||
### Aynchronous initialization
|
||||
### Asynchronous initialization
|
||||
|
||||
If the editor contents are retrieved asynchronously (recommended), then retrieve the editor contents and set them:
|
||||
|
||||
@@ -86,7 +92,7 @@ $(document).ready(function () {
|
||||
|<a name="autoresize"></a>autoresize|boolean|`true`|Enables/disables the auto-resizing of the editor.|
|
||||
|<a name="autoupdate"></a>autoupdate|boolean|`true`|Enables/disables the auto-updating of the editor when changes are made.|
|
||||
|<a name="bgcolor"></a>bgcolor|string|`#eeeeee`|The background color that mergely fills the margin canvas with.|
|
||||
|<a name="change_timeout"></a>change_timeout|number|`500`|The timeout, after a text change, before Mergely calcualtes a diff. Only used when `readonly` enabled.|
|
||||
|<a name="change_timeout"></a>change_timeout|number|`500`|The timeout, after a text change, before Mergely calculates a diff. Only used when `readonly` is enabled.|
|
||||
|<a name="cmsettings"></a>cmsettings|object|`{mode: 'text/plain', readOnly: false}`|CodeMirror settings (see [CodeMirror](http://codemirror.net])) that are combined with `lhs_cmsettings` and `rhs_cmsettings`.|
|
||||
|<a name="editor_width"></a>editor_width|string|`400px`|Starting width.|
|
||||
|<a name="editor_height"></a>editor_height|string|`400px`|Starting height.|
|
||||
@@ -95,12 +101,12 @@ $(document).ready(function () {
|
||||
|<a name="ignorews"></a>ignorews|boolean|`false`|Ignores white-space.|
|
||||
|<a name="ignorecase"></a>ignorecase|boolean|`false`|Ignores case when differientiating.
|
||||
|<a name="lcs"></a>lcs|boolean|`true`|Enables/disables LCS computation for paragraphs (word-by-word changes). Disabling can give a performance gain for large documents.|
|
||||
|<a name="license"></a>license|string|`lgpl`|The choice of license to use with Mergely. Valid values are: `lgpl`, `gpl`, `mpl` or `lgpl-separate-notice`, `gpl-separate-notice`, `mpl-separate-notice` (the license requirements are met in a spearate notice file).|
|
||||
|<a name="license"></a>license|string|`lgpl`|The choice of license to use with Mergely. Valid values are: `lgpl`, `gpl`, `mpl` or `lgpl-separate-notice`, `gpl-separate-notice`, `mpl-separate-notice` (the license requirements are met in a separate notice file).|
|
||||
|<a name="line_numbers"></a>line_numbers|boolean|`true`|Enables/disables line numbers. Enabling line numbers will toggle the visibility of the line number margins.|
|
||||
|<a name="lhs_cmsettings"></a>lhs_cmsettings|object|`{}`|The CodeMirror settings (see [CodeMirror](http://codemirror.net])) for the left-hand side editor.|
|
||||
|<a name="resize_timeout"></a>resize_timeout|number|`500`|The timeout, after a resize, before Mergely auto-resizes. Only used when autoresize enabled.|
|
||||
|<a name="rhs_cmsettings"></a>rhs_cmsettings|object|`{}`|The CodeMirror settings (see [CodeMirror](http://codemirror.net])) for the right-hand side editor.|
|
||||
|<a name="rhs_margin"></a>rhs_margin|string|`right`|Location for the rhs markup margin is either right or left.|
|
||||
|<a name="rhs_margin"></a>rhs_margin|string|`right`|Location for the rhs markup margin. Possible values: right, left.|
|
||||
|<a name="sidebar"></a>sidebar|boolean|`true`|Enables/disables sidebar markers. Disabling can give a performance gain for large documents.|
|
||||
|<a name="vpcolor"></a>vpcolor|string|`rgba(0, 0, 200, 0.5)`|The margin/viewport indicator color.|
|
||||
|<a name="viewport"></a>viewport|boolean|`false`|Enables/disables the viewport. Enabling the viewport can give a performance gain for large documents.|
|
||||
@@ -243,7 +249,7 @@ $('#mergely').mergely('options');
|
||||
|
||||
### resize
|
||||
|
||||
Resize the editor. Must be called explicitly if `autoresize` is disabled.
|
||||
Resizes the editor. It must be called explicitly if `autoresize` is disabled.
|
||||
|
||||
#### Parameters
|
||||
None.
|
||||
@@ -313,7 +319,7 @@ $('#mergely').mergely('search', 'lhs', 'needle');
|
||||
|
||||
### swap
|
||||
|
||||
Swap the content of the left and right editors.
|
||||
Swaps the content of the left and right editors.
|
||||
|
||||
#### Parameters
|
||||
None.
|
||||
@@ -337,7 +343,7 @@ $('#mergely').mergely('unmarkup');
|
||||
|
||||
### update
|
||||
|
||||
Manual update; recalculates diff and applies new settings.
|
||||
Manually updates the editor by recalculating the diff and applying new settings.
|
||||
|
||||
#### Parameters
|
||||
None.
|
||||
|
||||
@@ -104,7 +104,7 @@ This example demonstrates how to set left and right editors using ajax.
|
||||
//a.innerHTML = "content ready.";
|
||||
}
|
||||
document.getElementById('save-lhs').addEventListener('mouseover', function() { download_content(this, "lhs"); }, false);
|
||||
document.getElementById('save-rhs').addEventListener('mouseover', function() { download_content(this, "lhs"); }, false);
|
||||
document.getElementById('save-rhs').addEventListener('mouseover', function() { download_content(this, "rhs"); }, false);
|
||||
document.getElementById('ignorews').addEventListener('change', function() {
|
||||
$('#compare').mergely('options', { ignorews: this.checked });
|
||||
}, false);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mergely",
|
||||
"version": "4.0.8",
|
||||
"version": "4.0.14",
|
||||
"description": "A javascript UI for diff/merge",
|
||||
"directories": {
|
||||
"doc": "doc",
|
||||
@@ -40,7 +40,7 @@
|
||||
"babel-loader": "^8.0.4",
|
||||
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
||||
"chai": "^4.1.2",
|
||||
"codemirror": "^5.32.0",
|
||||
"codemirror": "^5.50.2",
|
||||
"copy-webpack-plugin": "^4.6.0",
|
||||
"css-loader": "^0.28.11",
|
||||
"file-loader": "^1.1.5",
|
||||
|
||||
@@ -48,3 +48,4 @@
|
||||
.mergely.current.CodeMirror-linenumber { color: #F9F9F9; font-weight: bold; background-color: #777; }
|
||||
.CodeMirror-linenumber { cursor: pointer; }
|
||||
.CodeMirror-code { color: #717171; }
|
||||
span.CodeMirror-selectedtext { background: none !important; }
|
||||
|
||||
@@ -395,6 +395,9 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
license: '',
|
||||
width: 'auto',
|
||||
height: 'auto',
|
||||
cmsettings: {
|
||||
styleSelectedText: true
|
||||
},
|
||||
lhs: function(setValue) { },
|
||||
rhs: function(setValue) { },
|
||||
loaded: function() { },
|
||||
@@ -456,8 +459,8 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
if (this.rhs_cmsettings.lineNumbers) {
|
||||
rhs_gutters = ['merge', 'CodeMirror-linenumbers']
|
||||
}
|
||||
jQuery.extend(true, this.lhs_cmsettings, this.settings.cmsettings, { gutters: lhs_gutters }, this.settings);
|
||||
jQuery.extend(true, this.rhs_cmsettings, this.settings.cmsettings, { gutters: rhs_gutters }, this.settings);
|
||||
jQuery.extend(true, this.lhs_cmsettings, this.settings.cmsettings, { gutters: lhs_gutters }, this.settings.lhs_cmsettings);
|
||||
jQuery.extend(true, this.rhs_cmsettings, this.settings.cmsettings, { gutters: rhs_gutters }, this.settings.rhs_cmsettings);
|
||||
|
||||
// bind if the element is destroyed
|
||||
this.element.bind('destroyed', jQuery.proxy(this.teardown, this));
|
||||
@@ -671,7 +674,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
}
|
||||
else {
|
||||
// homebrew
|
||||
var style = 'opacity:0.6;height:16px;background-color:#bfbfbf;cursor:pointer;text-align:center;color:#eee;border:1px solid #848484;margin-right:5px;margin-top:-2px;';
|
||||
var style = 'opacity:0.6;height:16px;background-color:#bfbfbf;cursor:pointer;text-align:center;color:#eee;border:1px solid #848484;margin-right:-15px;margin-top:-2px;';
|
||||
merge_lhs_button = '<div style="' + style + '" title="Merge left"><</div>';
|
||||
merge_rhs_button = '<div style="' + style + '" title="Merge right">></div>';
|
||||
}
|
||||
@@ -1496,13 +1499,15 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
odoc.replaceRange(text, CodeMirror.Pos(ofrom, 0), CodeMirror.Pos(oto, otolen));
|
||||
} else if ((oside === 'lhs' && change['op'] === 'd') || (oside === 'rhs' && change['op'] === 'a')) {
|
||||
if (from > 0) {
|
||||
text = doc.getRange(CodeMirror.Pos(from - 1, fromlen), CodeMirror.Pos(to, tolen));
|
||||
text = doc.getRange(CodeMirror.Pos(from, fromlen), CodeMirror.Pos(to, tolen));
|
||||
ofrom += 1;
|
||||
} else {
|
||||
text = doc.getRange(CodeMirror.Pos(0, 0), CodeMirror.Pos(to + 1, 0));
|
||||
}
|
||||
odoc.replaceRange(text, CodeMirror.Pos(ofrom - 1, 0), CodeMirror.Pos(oto + 1, 0));
|
||||
} else if ((oside === 'rhs' && change['op'] === 'd') || (oside === 'lhs' && change['op'] === 'a')) {
|
||||
if (from > 0) {
|
||||
fromlen = doc.getLine(from - 1).length + 1;
|
||||
text = doc.getRange(CodeMirror.Pos(from - 1, fromlen), CodeMirror.Pos(to, tolen));
|
||||
} else {
|
||||
text = doc.getRange(CodeMirror.Pos(0, 0), CodeMirror.Pos(to + 1, 0));
|
||||
@@ -1761,4 +1766,10 @@ jQuery.pluginMaker = function(plugin) {
|
||||
// make the mergely widget
|
||||
jQuery.pluginMaker(Mgly.mergely);
|
||||
|
||||
})(require('jquery'), require('CodeMirror'));
|
||||
})(
|
||||
require('jquery'),
|
||||
require('CodeMirror'),
|
||||
{
|
||||
markSelection: require('../node_modules/codemirror/addon/selection/mark-selection.js')
|
||||
}
|
||||
);
|
||||
|
||||
@@ -336,6 +336,12 @@ describe('mergely', function () {
|
||||
dir: 'lhs',
|
||||
name: 'delete is lines 2-3 and insert into middle of rhs'
|
||||
},
|
||||
{
|
||||
lhs: 'a\nb\nc',
|
||||
rhs: 'a\nb\nx\nc',
|
||||
dir: 'lhs',
|
||||
name: 'delete line 3 of length 1 of rhs and will be replaced with empty line 2 of lhs'
|
||||
},
|
||||
// delete 36-43 merge rhs
|
||||
{
|
||||
lhs: '\na',
|
||||
@@ -384,6 +390,60 @@ describe('mergely', function () {
|
||||
rhs: 'a\nd',
|
||||
dir: 'rhs',
|
||||
name: 'delete is lines 2-3 and insert into middle of rhs'
|
||||
},
|
||||
{
|
||||
lhs: 'a\nb\nc',
|
||||
rhs: 'a\nb\nx\nc',
|
||||
dir: 'rhs',
|
||||
name: 'merge rhs line 3 of length 1 and insert after line 2 of lhs'
|
||||
},
|
||||
{
|
||||
lhs: '\ngood',
|
||||
rhs: 'good',
|
||||
dir: 'rhs',
|
||||
name: 'lhs has deleted line at start'
|
||||
},
|
||||
{
|
||||
lhs: '\na\nb\nc\ngood',
|
||||
rhs: 'good',
|
||||
dir: 'rhs',
|
||||
name: 'lhs has multiple deleted lines at start'
|
||||
},
|
||||
{
|
||||
lhs: 'good\n',
|
||||
rhs: 'good',
|
||||
dir: 'rhs',
|
||||
name: 'lhs has deleted line at end (issue #115)'
|
||||
},
|
||||
{
|
||||
lhs: 'good\na\nb\nc',
|
||||
rhs: 'good',
|
||||
dir: 'rhs',
|
||||
name: 'lhs has multiple deleted lines at end (issue #115)'
|
||||
},
|
||||
{
|
||||
lhs: 'good',
|
||||
rhs: '\ngood',
|
||||
dir: 'lhs',
|
||||
name: 'rhs has added line at start'
|
||||
},
|
||||
{
|
||||
lhs: 'good',
|
||||
rhs: '\na\nb\nc\ngood',
|
||||
dir: 'lhs',
|
||||
name: 'rhs has multiple added lines at start'
|
||||
},
|
||||
{
|
||||
lhs: 'good',
|
||||
rhs: 'good\n',
|
||||
dir: 'lhs',
|
||||
name: 'rhs has added line at end'
|
||||
},
|
||||
{
|
||||
lhs: 'good',
|
||||
rhs: 'good\na\nb\nc',
|
||||
dir: 'lhs',
|
||||
name: 'rhs has multiple added lines at end'
|
||||
}];
|
||||
|
||||
opts.forEach((opt, i) => {
|
||||
|
||||
Reference in New Issue
Block a user