Files
Mergely/examples/change-styles.html
Jamie Peabody 37fedd05c8 v5.0 (#174)
* feat: v5

BREAKING CHANGE: Mergely is no longer a jQuery plugin.

BREAKING CHANGE: Removed `options.autoresize`

BREAKING CHANGE: Removed `options.editor_width`

BREAKING CHANGE: Removed `options.editor_height`

BREAKING CHANGE: Removed `options.fadein`

BREAKING CHANGE: Removed `options.fgcolor`

BREAKING CHANGE: Removed `options.resize`

BREAKING CHANGE: Removed `options.width`

BREAKING CHANGE: Removed `options.height`

BREAKING CHANGE: Removed `options.loaded` callback

BREAKING CHANGE: Removed `options.resized` callback

BREAKING CHANGE: Removed styles `.mergely-resizer`, `.mergely-full-screen-0`, and `.mergely-full-screen-8`

BREAKING CHANGE: Changed default for `options.change_timeout` changed from `150` to `50`.

BREAKING CHANGE: No longer automatically scrolls to first change.

feat: CodeMirror is now an explicit dependency.

feat: No longer necessary to separately require codemirror/addon/search/searchcursor

feat: No longer necessary to separately require codemirror/addon/selection/mark-selection

feat: `mergely.js` is now unminimized, and added new minimized version `mergely.min.js`

feat: Gutter click now scrolls to any line

feat: Mergely now emits `resize` event on resize

feat: The UI is now non-blocking as diff now runs in background

feat: Added support to provide `options.lhs` and `options.rhs` as strings

feat: #16 added titles to editor.mergely.com

fix: #165 block of changes at end of file are now distinguishable

fix: #140 fixed performance issue with large files

fix: Fixed issue where canvas markup was not rendered when `viewport` enabled

fix: Fixed timing issue where swap sides may not work as expected.

fix: Fixed issue where unmarkup did not emit an updated event.

fix: Fixed documentation issue where `merge` incorrectly stated: from the specified `side` to the opposite side.

fix: Fixed performance issue scrolling

fix: Fixed issue where initial render scrolled to first change, showing it at the bottom (as opposed to middle as expected)

fix: Fixed issue where line-diffs failed to diff non-alphanumeric characters

* chore: tweaked no-start/end styles

* feat: dark mode

* chore: updated examples

* chore(ci): updated webpack

* chore(ci): alpha, beta, next branches

* chore(ci): test

* chore(ci): package-lock.json

* chore(ci): ignore alpha, beta, next on branch

* fix: fixes firefox scroll-linked effect issue

* fix: fixes firefox scroll-linked effect issue

* chore: fix css

* chore: debug
2023-04-23 16:29:59 +01:00

331 lines
6.5 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mergely - Example change styles</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1, IE=edge">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="" />
<meta name="keywords" content="mergely,diff,merge,compare" />
<meta name="author" content="Jamie Peabody" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<!-- Mergely -->
<script type="text/javascript" src="/lib/mergely.js"></script>
<link type="text/css" rel="stylesheet" href="/lib/mergely.css" />
<style type="text/css">
html, body {
height: 100%;
margin: 0;
}
.column-layout {
display: flex;
}
.column-layout > * {
flex: 1;
height: 90px;
}
.full-width-layout > * {
height: 90px;
}
#mergely11 { height: 140px; }
/* dark mode example */
.dark.mergely-editor .CodeMirror-line {
color: #bcbcbc;
}
.dark.mergely-editor .CodeMirror,
.dark.mergely-editor {
background-color: #1e1e1e;
border-color: #606060;
}
.dark.mergely-editor .CodeMirror-selected {
background-color: #434360;
}
.dark.mergely-editor .CodeMirror-linenumber {
color: #727272;
}
.dark.mergely-editor .CodeMirror-gutters {
background-color: #2D2D2D;
border-color: #606060;
}
.dark.mergely-editor .CodeMirror-code {
color: #858585;
background-color: #252526;
}
.dark.mergely-editor .mergely.CodeMirror-gutter-background.current {
background-color: #777;
}
.dark.mergely-editor .mergely.current .CodeMirror-linenumber {
color: #F9F9F9;
font-weight: bold;
}
.dark.mergely-editor .merge-button {
color: #ccc;
}
.dark.mergely-editor .merge-button:hover {
color: #666;
}
.dark.mergely-editor .current .merge-button:hover {
color: #fff;
}
/* changed styles */
.dark.mergely-editor .mergely.c.CodeMirror-linebackground {
border-color: #c9b900;
background-color: #585100;
}
/* lhs styles (deleted-from) */
.dark.mergely-editor .mergely.rhs.a.no-end.CodeMirror-linebackground,
.dark.mergely-editor .mergely.rhs.a.no-start.CodeMirror-linebackground,
.dark.mergely-editor .mergely.lhs.no-end.CodeMirror-linebackground,
.dark.mergely-editor .mergely.lhs.d.CodeMirror-linebackground {
border-color: #b30000;
}
.dark.mergely-editor .mergely.lhs.d.CodeMirror-linebackground {
background-color: #5a0000;
}
/* ind is an inline delete */
.dark.mergely-editor .mergely.ch.ind.lhs {
text-decoration: line-through;
color: #ffd126;
}
.dark.mergely-editor .mergely.ch.d.lhs {
text-decoration: line-through;
color: #ff7f7f;
}
/* rhs styles (added-to) */
.dark.mergely-editor .mergely.lhs.no-end.CodeMirror-linebackground,
.dark.mergely-editor .mergely.lhs.no-start.CodeMirror-linebackground,
.dark.mergely-editor .mergely.rhs.a.CodeMirror-linebackground {
border-color: #a3d1ff;
}
.dark.mergely-editor .mergely.rhs.a.CodeMirror-linebackground {
background-color: #24507c;
}
/* ina is an inline add */
.dark.mergely-editor .mergely.ch.ina.rhs {
color: #ffeb00;
}
.dark.mergely-editor .mergely.ch.a.rhs {
color: inherit;
}
.dark.mergely-editor .mergely.current.lhs.CodeMirror-linebackground,
.dark.mergely-editor .mergely.current.rhs.CodeMirror-linebackground {
border-color: black;
}
.dark.mergely-editor .mergely.no-start.end.CodeMirror-linebackground,
.dark.mergely-editor .mergely.no-end.start.CodeMirror-linebackground {
background: none;
}
</style>
</head>
<body>
<div>
<caption>Inserted and removed at start but not end</caption>
<div class="column-layout">
<div id="mergely0"></div>
<div id="mergely1"></div>
</div>
</div>
<br />
<div>
<caption>Removed and added from the middle</caption>
<div class="column-layout">
<div id="mergely2"></div>
<div id="mergely3"></div>
</div>
</div>
<br />
<div>
<caption>One document empty, one line</caption>
<div class="column-layout">
<div id="mergely4"></div>
<div id="mergely5"></div>
</div>
</div>
<br />
<div>
<caption>One document empty, multiple lines</caption>
<div class="column-layout">
<div id="mergely6"></div>
<div id="mergely7"></div>
</div>
</div>
<br />
<div>
<caption>Inserted and removed at the end</caption>
<div class="column-layout">
<div id="mergely8"></div>
<div id="mergely9"></div>
</div>
</div>
<br />
<div>
<caption>Changed lines</caption>
<div class="full-width-layout">
<div id="mergely10"></div>
</div>
</div>
<br />
<div>
<caption>Custom styles</caption>
<div class="full-width-layout">
<div class="dark" id="mergely11"></div>
</div>
</div>
<br />
<script type="text/javascript">
document.onreadystatechange = function () {
if (document.readyState !== 'complete') {
return;
}
const data = [{
lhs: `\
the quick red fox
jumped over the hairy dog
`,
rhs: `\
the quick brown fox
jumped over the lazy dog
`
}, {
lhs: `\
the quick red fox
jumped over the hairy dog
`,
rhs: `\
the quick brown fox
jumped over the lazy dog
`
}, {
lhs: `\
the quick red fox
jumped over the hairy dog
`,
rhs: `\
the quick brown fox
jumped over the lazy dog
`
}, {
lhs: `\
the quick brown fox
jumped over the lazy dog
`,
rhs: `\
the quick red fox
jumped over the hairy dog
`
}, {
lhs: ``,
rhs: `\
the quick brown fox
`
}, {
lhs: `\
the quick red fox
`,
rhs: ``
}, {
lhs: ``,
rhs: `\
the quick brown fox
jumped over the lazy dog
`
}, {
lhs: `\
the quick red fox
jumped over the hairy dog
`,
rhs: ``
}, {
lhs: `\
the quick brown fox
jumped over the lazy dog`,
rhs: `\
the quick brown fox
jumped over the lazy dog
and the fence`
}, {
lhs: `\
the quick brown fox
jumped over the lazy dog
and the fence`,
rhs: `\
the quick brown fox
jumped over the lazy dog`
}, {
lhs: `\
the quick red fox
jumped over the hairy dog`,
rhs: `\
the quick brown fox
jumped over the lazy dog`
}, {
lhs: `\
the quick red fox
jumped over the hairy
dog
and the fence
`,
rhs: `\
the quick brown fox
jumped over the lazy
dog
and the postman
`
}];
console.log(data.length);
for (let i = 0; i < data.length; ++i) {
const { lhs, rhs } = data[i];
const darkModeOptions = i === 11 ? {
bgcolor: '#434360'
} : {}
const mergely = new Mergely(`#mergely${i}`, {
license: 'lgpl-separate-notice',
...darkModeOptions,
lhs,
rhs
});
if (i === 0 || i === 1) {
// On init, scroll to first diff
mergely.once('updated', () => {
mergely.scrollToDiff('next');
});
}
}
};
</script>
</body>
</html>