mirror of
https://github.com/wickedest/Mergely.git
synced 2026-02-26 11:07:56 +08:00
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
291 lines
5.3 KiB
HTML
Executable File
291 lines
5.3 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">
|
|
|
|
<!-- CodeMirror peer dependency -->
|
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.0/codemirror.min.js"></script>
|
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.0/addon/search/searchcursor.min.js"></script>
|
|
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.0/codemirror.min.css" />
|
|
|
|
<!-- 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;
|
|
}
|
|
.dark {
|
|
background-color: #0b0e10;
|
|
}
|
|
.dark .CodeMirror {
|
|
background-color: #12171b;
|
|
}
|
|
.dark .CodeMirror-code {
|
|
color: #d6d6d6;
|
|
}
|
|
.dark .mergely.a.rhs {
|
|
color: #fff;
|
|
}
|
|
.dark .mergely.current {
|
|
border-color: #616161;
|
|
}
|
|
.dark .mergely.d.lhs {
|
|
background-color: #2c1b48;
|
|
}
|
|
.dark .mergely.d {
|
|
border-color: #9f3fff;
|
|
}
|
|
/* FIXME: Do we need this `ch`? */
|
|
.dark .mergely.ch.d.lhs {
|
|
color: #d48eff;
|
|
}
|
|
.dark .mergely.a.rhs {
|
|
background-color: #253e56;
|
|
}
|
|
.dark .CodeMirror-gutters {
|
|
background-color: transparent;
|
|
border-right: 1px dotted #2E343A;
|
|
}
|
|
.dark .mergely.current .CodeMirror-linenumber {
|
|
background-color: #6a89f7;
|
|
}
|
|
.dark .CodeMirror-linenumber {
|
|
color: #999;
|
|
}
|
|
.dark .mergely-column {
|
|
border: 1px solid transparent;
|
|
}
|
|
.dark .mergely.current {
|
|
border-color: #6a89f7;
|
|
}
|
|
.dark .CodeMirror-cursor {
|
|
border-left: 2px solid #B19F73;
|
|
}
|
|
.dark .CodeMirror-selected {
|
|
background-color: #424242;
|
|
}
|
|
.dark .CodeMirror-focused .CodeMirror-selected {
|
|
background-color: #07468b;
|
|
}
|
|
</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" style="height:120px">
|
|
<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
|
|
`
|
|
}];
|
|
|
|
for (let i = 0; i < data.length; ++i) {
|
|
const { lhs, rhs } = data[i];
|
|
const mergely = new Mergely(`#mergely${i}`, {
|
|
license: 'lgpl-separate-notice',
|
|
lhs: (setValue) => setValue(lhs),
|
|
rhs: (setValue) => setValue(rhs)
|
|
});
|
|
|
|
if (i === 0 || i === 1) {
|
|
// On init, scroll to first diff
|
|
mergely.once('updated', () => {
|
|
mergely.scrollToDiff('next');
|
|
});
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|