Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
049a2719dc |
@@ -449,7 +449,6 @@ CodeMirrorDiffView.prototype.bind = function(container) {
|
|||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const ed = this.editor[side];
|
|
||||||
// See if the user clicked the line number of a difference:
|
// See if the user clicked the line number of a difference:
|
||||||
let found = false;
|
let found = false;
|
||||||
for (let i = 0; i < this.changes.length; ++i) {
|
for (let i = 0; i < this.changes.length; ++i) {
|
||||||
|
|||||||
@@ -122,13 +122,11 @@ class Mergely {
|
|||||||
const colors = dom.getColors(this.el);
|
const colors = dom.getColors(this.el);
|
||||||
this._options = {
|
this._options = {
|
||||||
...defaultOptions,//lgpl
|
...defaultOptions,//lgpl
|
||||||
...this._initOptions,
|
...(this._options || this._initOptions),
|
||||||
...options//lgpl-separate-notice
|
...options//lgpl-separate-notice
|
||||||
};
|
};
|
||||||
this._viewOptions = {
|
this._viewOptions = {
|
||||||
...defaultOptions,
|
...this._options,
|
||||||
...this._initOptions,
|
|
||||||
...options,
|
|
||||||
_colors: colors
|
_colors: colors
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,7 +340,6 @@ describe('markup', () => {
|
|||||||
name: 'Changes with non-letter chars',
|
name: 'Changes with non-letter chars',
|
||||||
lhs: '~# 00 == ! (dog) \n',
|
lhs: '~# 00 == ! (dog) \n',
|
||||||
rhs: '~? 11 ++ ] (fox) .\n',
|
rhs: '~? 11 ++ ] (fox) .\n',
|
||||||
only: true,
|
|
||||||
check: (editor) => {
|
check: (editor) => {
|
||||||
expect(editor.querySelectorAll(LHS_CHANGE_START_AND_END + '.cid-0')).to.have.length(1);
|
expect(editor.querySelectorAll(LHS_CHANGE_START_AND_END + '.cid-0')).to.have.length(1);
|
||||||
expect(editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0')).to.have.length(6);
|
expect(editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0')).to.have.length(6);
|
||||||
@@ -355,8 +354,6 @@ describe('markup', () => {
|
|||||||
for (const value of rhs_changes.values()) {
|
for (const value of rhs_changes.values()) {
|
||||||
rhs_values.push(value.innerText);
|
rhs_values.push(value.innerText);
|
||||||
}
|
}
|
||||||
console.log(lhs_values);
|
|
||||||
console.log(rhs_values);
|
|
||||||
expect(lhs_values).to.deep.equal(['#', '00', '==', '!', 'd', 'g']);
|
expect(lhs_values).to.deep.equal(['#', '00', '==', '!', 'd', 'g']);
|
||||||
expect(rhs_values).to.deep.equal(['?', '11', '++', ']', 'f', 'x', '.']);
|
expect(rhs_values).to.deep.equal(['?', '11', '++', ']', 'f', 'x', '.']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,19 +62,17 @@ describe('mergely', function () {
|
|||||||
try {
|
try {
|
||||||
const { children } = editor.el.children[0];
|
const { children } = editor.el.children[0];
|
||||||
const items = Array.from(children).map(a => a.className);
|
const items = Array.from(children).map(a => a.className);
|
||||||
|
expect(items[0] == 'mergely-margin');
|
||||||
|
expect(items[1] == 'mergely-column');
|
||||||
// NOTE: if running karma debug, these tests can fail because
|
// NOTE: if running karma debug, these tests can fail because
|
||||||
// the debugger grabs the focus and the CodeMirror instance
|
// the debugger grabs the focus and the CodeMirror instance
|
||||||
// loses `CodeMirror-focused`
|
// loses `CodeMirror-focused`
|
||||||
expect(items).to.deep.equal([
|
expect(items[2].indexOf('CodeMirror cm-s-default' == 0));
|
||||||
'mergely-margin',
|
expect(items[3] == 'mergely-margin');
|
||||||
'mergely-column',
|
expect(items[4] == 'mergely-column');
|
||||||
'CodeMirror cm-s-default CodeMirror-focused',
|
expect(items[5] == 'CodeMirror cm-s-default');
|
||||||
'mergely-canvas',
|
expect(items[6] == 'mergely-column');
|
||||||
'mergely-column',
|
expect(items[7] == 'mergely-splash');
|
||||||
'CodeMirror cm-s-default',
|
|
||||||
'mergely-margin',
|
|
||||||
'mergely-splash'
|
|
||||||
]);
|
|
||||||
expect(editor.get('lhs')).to.equal('');
|
expect(editor.get('lhs')).to.equal('');
|
||||||
expect(editor.get('rhs')).to.equal('');
|
expect(editor.get('rhs')).to.equal('');
|
||||||
done();
|
done();
|
||||||
@@ -99,15 +97,17 @@ describe('mergely', function () {
|
|||||||
// NOTE: if running karma debug, these tests can fail because
|
// NOTE: if running karma debug, these tests can fail because
|
||||||
// the debugger grabs the focus and the CodeMirror instance
|
// the debugger grabs the focus and the CodeMirror instance
|
||||||
// loses `CodeMirror-focused`
|
// loses `CodeMirror-focused`
|
||||||
expect(items).to.deep.equal([
|
expect(items[0] == 'mergely-margin');
|
||||||
'mergely-margin',
|
expect(items[1] == 'mergely-column');
|
||||||
'mergely-column',
|
// NOTE: if running karma debug, these tests can fail because
|
||||||
'CodeMirror cm-s-default CodeMirror-focused',
|
// the debugger grabs the focus and the CodeMirror instance
|
||||||
'mergely-canvas',
|
// loses `CodeMirror-focused`
|
||||||
'mergely-column',
|
expect(items[2].indexOf('CodeMirror cm-s-default' == 0));
|
||||||
'CodeMirror cm-s-default',
|
expect(items[3] == 'mergely-margin');
|
||||||
'mergely-margin'
|
expect(items[4] == 'mergely-column');
|
||||||
]);
|
expect(items[5] == 'CodeMirror cm-s-default');
|
||||||
|
expect(items[6] == 'mergely-column');
|
||||||
|
expect(items[7] == 'mergely-splash');
|
||||||
expect(editor.get('lhs')).to.equal('left-hand side text');
|
expect(editor.get('lhs')).to.equal('left-hand side text');
|
||||||
expect(editor.get('rhs')).to.equal('right-hand side text');
|
expect(editor.get('rhs')).to.equal('right-hand side text');
|
||||||
done();
|
done();
|
||||||
@@ -129,18 +129,17 @@ describe('mergely', function () {
|
|||||||
try {
|
try {
|
||||||
const { children } = editor.el.children[0];
|
const { children } = editor.el.children[0];
|
||||||
const items = Array.from(children).map(a => a.className);
|
const items = Array.from(children).map(a => a.className);
|
||||||
|
expect(items[0] == 'mergely-margin');
|
||||||
|
expect(items[1] == 'mergely-column');
|
||||||
// NOTE: if running karma debug, these tests can fail because
|
// NOTE: if running karma debug, these tests can fail because
|
||||||
// the debugger grabs the focus and the CodeMirror instance
|
// the debugger grabs the focus and the CodeMirror instance
|
||||||
// loses `CodeMirror-focused`
|
// loses `CodeMirror-focused`
|
||||||
expect(items).to.deep.equal([
|
expect(items[2].indexOf('CodeMirror cm-s-default' == 0));
|
||||||
'mergely-margin',
|
expect(items[3] == 'mergely-margin');
|
||||||
'mergely-column',
|
expect(items[4] == 'mergely-column');
|
||||||
'CodeMirror cm-s-default CodeMirror-focused',
|
expect(items[5] == 'CodeMirror cm-s-default');
|
||||||
'mergely-canvas',
|
expect(items[6] == 'mergely-column');
|
||||||
'mergely-column',
|
expect(items[7] == 'mergely-splash');
|
||||||
'CodeMirror cm-s-default',
|
|
||||||
'mergely-margin'
|
|
||||||
]);
|
|
||||||
expect(editor.get('lhs')).to.equal('left-hand side text');
|
expect(editor.get('lhs')).to.equal('left-hand side text');
|
||||||
expect(editor.get('rhs')).to.equal('right-hand side text');
|
expect(editor.get('rhs')).to.equal('right-hand side text');
|
||||||
done();
|
done();
|
||||||
@@ -161,18 +160,17 @@ describe('mergely', function () {
|
|||||||
try {
|
try {
|
||||||
const { children } = editor.el.children[0];
|
const { children } = editor.el.children[0];
|
||||||
const items = Array.from(children).map(a => a.className);
|
const items = Array.from(children).map(a => a.className);
|
||||||
|
expect(items[0] == 'mergely-margin');
|
||||||
|
expect(items[1] == 'mergely-column');
|
||||||
// NOTE: if running karma debug, these tests can fail because
|
// NOTE: if running karma debug, these tests can fail because
|
||||||
// the debugger grabs the focus and the CodeMirror instance
|
// the debugger grabs the focus and the CodeMirror instance
|
||||||
// loses `CodeMirror-focused`
|
// loses `CodeMirror-focused`
|
||||||
expect(items).to.deep.equal([
|
expect(items[2].indexOf('CodeMirror cm-s-default' == 0));
|
||||||
'mergely-margin',
|
expect(items[3] == 'mergely-margin');
|
||||||
'mergely-column',
|
expect(items[4] == 'mergely-column');
|
||||||
'CodeMirror cm-s-default CodeMirror-focused',
|
expect(items[5] == 'CodeMirror cm-s-default');
|
||||||
'mergely-canvas',
|
expect(items[6] == 'mergely-column');
|
||||||
'mergely-column',
|
expect(items[7] == 'mergely-splash');
|
||||||
'CodeMirror cm-s-default',
|
|
||||||
'mergely-margin'
|
|
||||||
]);
|
|
||||||
expect(children[0].style.visibility).to.equal('hidden');
|
expect(children[0].style.visibility).to.equal('hidden');
|
||||||
expect(children[6].style.visibility).to.equal('hidden');
|
expect(children[6].style.visibility).to.equal('hidden');
|
||||||
done();
|
done();
|
||||||
@@ -503,6 +501,24 @@ describe('mergely', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should preserve changed option', function (done) {
|
||||||
|
const editor = init({
|
||||||
|
change_timeout: 0,
|
||||||
|
license: 'lgpl-separate-notice',
|
||||||
|
lhs: 'left-hand side text',
|
||||||
|
rhs: 'right-hand side text'
|
||||||
|
});
|
||||||
|
editor.once('updated', () => {
|
||||||
|
editor.options({ sidebar: false });
|
||||||
|
expect(editor.options().wrap_lines).to.equal(false, 'wrap_lines');
|
||||||
|
expect(editor.options().sidebar).to.equal(false, 'sidebar');
|
||||||
|
editor.options({ wrap_lines: false });
|
||||||
|
expect(editor.options().wrap_lines).to.equal(false, 'wrap_lines-2');
|
||||||
|
expect(editor.options().sidebar).to.equal(false, 'sidebar-2');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should ignore white-space', function (done) {
|
it('should ignore white-space', function (done) {
|
||||||
const editor = init({
|
const editor = init({
|
||||||
height: 100,
|
height: 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user