diff --git a/README.md b/README.md
index 1b40243..c95ad89 100644
--- a/README.md
+++ b/README.md
@@ -2,18 +2,20 @@
https://mergely.com
-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 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.
+Mergely has a JavaScript implementation of the Longest Common Subsequence (LCS) diff algorithm, and a customizable markup engine. It computs the diff within the browser.
## Installation
### Installation via webpack
+
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).
### Installation via .tgz
@@ -29,7 +31,7 @@ Unpack mergely.tgz into a folder, for example, `./lib`, and add the following to
```
-Create a div for the editor in `
`.
+Create a div for the editor in ``.
This example uses a style that provides 8px padding (`mergely-full-screen-8`):
@@ -71,22 +73,21 @@ $(document).ready(function () {
If the editor contents are retrieved asynchronously (recommended), then retrieve the editor contents and set them:
-```js
-$(document).ready(function () {
+```html
+
```
## Options
-
|Option|Type|Default value|Description|
|------|----|-------------|-----------|
|autoresize|boolean|`true`|Enables/disables the auto-resizing of the editor.|
@@ -135,7 +136,7 @@ Clears the editor contents for the specified `side`.
#### Example
```js
-$('#mergely').mergely('clear', 'lhs');
+doc.clear('lhs');
```
### cm
@@ -149,7 +150,7 @@ Gets the CodeMirror editor for the specified `side`.
#### Example
```js
-$('#mergely').mergely('cm', 'lhs');
+doc.cm('lhs');
```
### diff
@@ -162,7 +163,7 @@ None.
#### Example
```js
-$('#mergely').mergely('diff');
+doc.diff();
```
### get
@@ -176,7 +177,7 @@ Gets the text editor contents for the specified `side`.
#### Example
```js
-$('#mergely').mergely('get', 'lhs');
+doc.get('lhs');
```
### lhs
@@ -190,7 +191,7 @@ Sets the value of the left-hand editor.
#### Example
```js
-$('#mergely').mergely('lhs', 'This is text');
+doc.lhs('This is text');
```
### merge
@@ -204,7 +205,7 @@ Merges whole file from the specified `side` to the opposite side.
#### Example
```js
-$('#mergely').mergely('merge', 'lhs');
+doc.merge('lhs');
```
### mergeCurrentChange
@@ -218,7 +219,7 @@ Merges the current change from the specified `side` to the opposite side.
#### Example
```js
-$('#mergely').mergely('mergeCurrentChange', 'lhs');
+doc.mergeCurrentChange('lhs');
```
@@ -233,7 +234,7 @@ Sets the editor options. Will automatically update with the new settings unless
#### Example
```js
-$('#mergely').mergely('options', { line_numbers: true });
+doc.options({ line_numbers: true });
```
### options
@@ -245,7 +246,7 @@ None.
#### Example
```js
-$('#mergely').mergely('options');
+doc.options();
```
### resize
@@ -257,7 +258,7 @@ None.
#### Example
```js
-$('#mergely').mergely('resize');
+doc.resize();
```
### rhs
@@ -271,7 +272,7 @@ Sets the value of the right-hand editor.
#### Example
```js
-$('#mergely').mergely('rhs', 'This is text');
+doc.rhs('This is text');
```
### scrollTo
@@ -286,7 +287,7 @@ Scrolls the `side` to line number specified by `num`.
#### Example
```js
-$('#mergely').mergely('scrollTo', 'lhs', 100);
+doc.scrollTo('lhs', 100);
```
### scrollToDiff
@@ -300,7 +301,7 @@ Scrolls to the next change specified by `direction`.
#### Example
```js
-$('#mergely').mergely('scrollToDiff', 'next');
+doc.scrollToDiff('next');
```
### search
@@ -315,7 +316,7 @@ Search the editor for `text`, scrolling to the next available match. Repeating t
#### Example
```js
-$('#mergely').mergely('search', 'lhs', 'needle');
+doc.search('lhs', 'needle');
```
### summary
@@ -336,8 +337,8 @@ None.
#### Example
```js
-console.log($('#mergely').mergely('summary'));
-// { a: 0, c: 1, d: 0, lhsLength: 44, numChanges: 1, rhsLength: 45 }
+console.log(doc.summary());
+// { a: 0, c: 1, d: 0, lhsLength: 44, rhsLength: 45, numChanges: 1 }
```
### swap
@@ -349,7 +350,7 @@ None.
#### Example
```js
-$('#mergely').mergely('swap');
+doc.swap();
```
### unmarkup
@@ -361,19 +362,7 @@ None.
#### Example
```js
-$('#mergely').mergely('unmarkup');
-```
-
-### update
-
-Manually updates the editor by recalculating the diff and applying new settings.
-
-#### Parameters
-None.
-
-#### Example
-```js
-$('#mergely').mergely('update');
+doc.unmarkup();
```
## Events
diff --git a/examples/README.md b/examples/README.md
index adddd2c..31130b5 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,33 +1,23 @@
# Mergely examples
-To run these examples, you need to run:
+
+## Mergely development server
+
+To run the hot dev-server for development, you need to run:
```bash
-$ npm run build
$ npm start
```
-This runs Mergely in a hot dev-server for development. However, only the main example is hot-reloaded when mergely is changed. The others require a rebuild.
+After, the application can be accessed http://localhost:8080
-## Main example
-http://localhost:8080
+## Mergely examples
-Shows basic functionality.
+These examples require a build.
-## Ajax example
+```bash
+$ npm run build:dist
+$ npm run examples
+```
-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
+After, the examples can be accessed http://localhost:3000
diff --git a/examples/ajax.html b/examples/ajax.html
deleted file mode 100644
index 6c1356f..0000000
--- a/examples/ajax.html
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
-
-
- Mergely - Simple Example
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/app.html b/examples/app.html
index 9011c6b..026c790 100644
--- a/examples/app.html
+++ b/examples/app.html
@@ -4,20 +4,26 @@ This example demonstrates the minimum amount of code required to use Mergely.
- Mergely - Application example
+
+ Mergely - Application example
+
+
-
+
diff --git a/examples/app.js b/examples/app.js
index fe75b57..91be63a 100644
--- a/examples/app.js
+++ b/examples/app.js
@@ -19,24 +19,18 @@ document.onreadystatechange = function () {
return;
}
- const doc = new Mergely('#mergely', {
+ const doc = new Mergely('#compare', {
license: 'lgpl',
- ignorews: true,
- wrap_lines: false,
- change_timeout: 50,
- viewport: true,
- cmsettings: {
- readOnly: false
- },
- lhs: function(setValue) {
- setValue(macbeth.join('\n'));
- },
- rhs: function(setValue) {
- setValue(macbeth.join('\n')
- .replace(/\brain\b/g, 'sleet')
- .replace(/\bfog\b/g, 'smog'));
- //.replace(/heart/g, 'head'));
- }
+ // ignorews: true,
+ // wrap_lines: false,
+ // change_timeout: 50,
+ // viewport: true,
+ // cmsettings: {
+ // readOnly: true
+ // },
+ line_numbers: false,
+ lhs: (setValue) => setValue(lhs),
+ rhs: (setValue) => setValue(rhs)
});
// On init, scroll to first diff
diff --git a/examples/styles.html b/examples/change-styles.html
similarity index 82%
rename from examples/styles.html
rename to examples/change-styles.html
index 22d557c..59d9446 100755
--- a/examples/styles.html
+++ b/examples/change-styles.html
@@ -1,15 +1,14 @@
-
- Mergely - Simple Example
+
+ Mergely - Example change styles
+
@@ -27,12 +26,12 @@ This example demonstrates the minimum amount of code required to use Mergely.
}
.column-layout {
display: flex;
- height: 90px;
}
.column-layout > * {
flex: 1;
+ height: 90px;
}
- .full-width-layout {
+ .full-width-layout > * {
height: 90px;
}
.dark {
@@ -82,6 +81,12 @@ This example demonstrates the minimum amount of code required to use Mergely.
.dark .CodeMirror-cursor {
border-left: 2px solid #B19F73;
}
+ .dark .CodeMirror-selected {
+ background-color: #424242;
+ }
+ .dark .CodeMirror-focused .CodeMirror-selected {
+ background-color: #07468b;
+ }
@@ -95,7 +100,7 @@ This example demonstrates the minimum amount of code required to use Mergely.
-
Removed and added, not at the start or end
+
Removed and added from the middle
@@ -152,110 +157,110 @@ This example demonstrates the minimum amount of code required to use Mergely.
return;
}
-const data = [{
- lhs: `\
+ const data = [{
+ lhs: `\
the quick red fox
jumped over the hairy dog
`,
- rhs: `\
+ rhs: `\
the quick brown fox
jumped over the lazy dog
`
-}, {
- lhs: `\
+ }, {
+ lhs: `\
the quick red fox
jumped over the hairy dog
`,
- rhs: `\
+ rhs: `\
the quick brown fox
jumped over the lazy dog
`
-}, {
- lhs: `\
+ }, {
+ lhs: `\
the quick red fox
jumped over the hairy dog
`,
- rhs: `\
+ rhs: `\
the quick brown fox
jumped over the lazy dog
`
-}, {
- lhs: `\
+ }, {
+ lhs: `\
the quick brown fox
jumped over the lazy dog
`,
- rhs: `\
+ rhs: `\
the quick red fox
jumped over the hairy dog
`
-}, {
- lhs: ``,
- rhs: `\
+ }, {
+ lhs: ``,
+ rhs: `\
the quick brown fox
`
-}, {
- lhs: `\
+ }, {
+ lhs: `\
the quick red fox
`,
- rhs: ``
-}, {
- lhs: ``,
- rhs: `\
+ rhs: ``
+ }, {
+ lhs: ``,
+ rhs: `\
the quick brown fox
jumped over the lazy dog
`
-}, {
- lhs: `\
+ }, {
+ lhs: `\
the quick red fox
jumped over the hairy dog
`,
- rhs: ``
-}, {
- lhs: `\
+ rhs: ``
+ }, {
+ lhs: `\
the quick brown fox
jumped over the lazy dog`,
- rhs: `\
+ rhs: `\
the quick brown fox
jumped over the lazy dog
and the fence`
-}, {
- lhs: `\
+ }, {
+ lhs: `\
the quick brown fox
jumped over the lazy dog
and the fence`,
- rhs: `\
+ rhs: `\
the quick brown fox
jumped over the lazy dog`
-}, {
- lhs: `\
+ }, {
+ lhs: `\
the quick red fox
jumped over the hairy dog`,
- rhs: `\
+ rhs: `\
the quick brown fox
jumped over the lazy dog`
-}, {
- lhs: `\
+ }, {
+ lhs: `\
the quick red fox
jumped over the hairy dog
and the fence
`,
- rhs: `\
+ rhs: `\
the quick brown fox
jumped over the lazy dog
@@ -268,20 +273,16 @@ and the postman
const { lhs, rhs } = data[i];
const doc = new Mergely(`#mergely${i}`, {
license: 'lgpl-separate-notice',
- wrap_lines: true,
- ignorews: true,
- lhs: function(setValue) {
- setValue(lhs);
- },
- rhs: function(setValue) {
- setValue(rhs);
- }
+ lhs: (setValue) => setValue(lhs),
+ rhs: (setValue) => setValue(rhs)
});
- // On init, scroll to first diff
- doc.once('updated', () => {
- doc.scrollToDiff('next');
- });
+ if (i === 0 || i === 1) {
+ // On init, scroll to first diff
+ doc.once('updated', () => {
+ doc.scrollToDiff('next');
+ });
+ }
}
};
diff --git a/examples/editor.html b/examples/editor.html
new file mode 100644
index 0000000..9467d35
--- /dev/null
+++ b/examples/editor.html
@@ -0,0 +1,344 @@
+
+
+
+
+ Mergely - Example editor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/simple.html b/examples/fixed-height.html
similarity index 60%
rename from examples/simple.html
rename to examples/fixed-height.html
index 959cb76..cafae5d 100644
--- a/examples/simple.html
+++ b/examples/fixed-height.html
@@ -1,15 +1,14 @@
-
- Mergely - Simple Example
+
+ Mergely - Example fixed height editor
+
@@ -17,33 +16,29 @@ This example demonstrates the minimum amount of code required to use Mergely.
-
+
-
+
-
-
-
-
-
+
+
+
diff --git a/examples/fixed-size.html b/examples/fixed-size.html
new file mode 100644
index 0000000..4b0434e
--- /dev/null
+++ b/examples/fixed-size.html
@@ -0,0 +1,43 @@
+
+
+
+
+ Mergely - Example fixed size editor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/full-page.html b/examples/full-page.html
index 7f01d0e..b732e24 100644
--- a/examples/full-page.html
+++ b/examples/full-page.html
@@ -1,50 +1,47 @@
-
-
+
- Mergely - Full page example
+ Mergely - Example full page editor
+
-
-
-
+
+
+
-
-
-
-
+
-
diff --git a/examples/index.html b/examples/index.html
index cd01fc5..4624510 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -10,27 +10,37 @@ This example demonstrates the minimum amount of code required to use Mergely.
+
+
-
An editor that becomes visible once ready (less flicker).
+
diff --git a/examples/lhs.txt b/examples/lhs.txt
deleted file mode 100644
index 14b478c..0000000
--- a/examples/lhs.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-the quick red fox jumped
-over the hairy dog
diff --git a/examples/rhs.txt b/examples/rhs.txt
deleted file mode 100644
index 13fde44..0000000
--- a/examples/rhs.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-the quick brown fox jumped
-over the lazy dog
diff --git a/examples/scroll-to-first-change.html b/examples/scroll-to-first-change.html
index e891157..8694acd 100644
--- a/examples/scroll-to-first-change.html
+++ b/examples/scroll-to-first-change.html
@@ -1,15 +1,13 @@
-
- Mergely - Simple Example
+ Mergely - Example scroll to first change
+
@@ -25,25 +23,27 @@ This example demonstrates the minimum amount of code required to use Mergely.
height: 100%;
margin: 0;
}
+ #compare {
+ height: 100%;
+ }
-
+
diff --git a/examples/size.html b/examples/visible.html
old mode 100755
new mode 100644
similarity index 55%
rename from examples/size.html
rename to examples/visible.html
index d934251..3e5ce84
--- a/examples/size.html
+++ b/examples/visible.html
@@ -1,15 +1,13 @@
-
- Mergely - Simple Example
+ Mergely - Example visibility
+
@@ -17,53 +15,36 @@ This example demonstrates the minimum amount of code required to use Mergely.
-
+
-