Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78f68bf904 | ||
|
|
c7b0fd03b0 | ||
|
|
8d56792b37 | ||
|
|
8c1c95284e | ||
|
|
0bdbfe1078 | ||
|
|
c40672c458 | ||
|
|
64a20ee5b1 | ||
|
|
a469a65101 |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,3 +1,24 @@
|
||||
## [5.3.2](https://github.com/wickedest/Mergely/compare/v5.3.1...v5.3.2) (2024-07-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Removed debug code ([c7b0fd0](https://github.com/wickedest/Mergely/commit/c7b0fd03b01cb3267d292c2985ca8b62adda11e0))
|
||||
|
||||
## [5.3.1](https://github.com/wickedest/Mergely/compare/v5.3.0...v5.3.1) (2024-06-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fixed a regression rendering inline markup for numbers, punctuation, and symbols ([#199](https://github.com/wickedest/Mergely/issues/199)) ([c40672c](https://github.com/wickedest/Mergely/commit/c40672c458723bdd0d9a0062ef1457e435866765))
|
||||
|
||||
# [5.3.0](https://github.com/wickedest/Mergely/compare/v5.2.0...v5.3.0) (2024-06-16)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Supports unicode diacritical marks when rendering line diff (fixes [#169](https://github.com/wickedest/Mergely/issues/169)) ([#197](https://github.com/wickedest/Mergely/issues/197)) ([a469a65](https://github.com/wickedest/Mergely/commit/a469a6510122356a7cae3fb1259e999e6cc34c94))
|
||||
|
||||
# [5.2.0](https://github.com/wickedest/Mergely/compare/v5.1.4...v5.2.0) (2024-06-09)
|
||||
|
||||
|
||||
|
||||
63
package-lock.json
generated
63
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "mergely",
|
||||
"version": "5.2.0",
|
||||
"version": "5.3.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mergely",
|
||||
"version": "5.2.0",
|
||||
"version": "5.3.2",
|
||||
"license": "(GPL-3.0 OR LGPL-3.0 OR MPL-1.1 OR SEE LICENSE IN LICENSE)",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.1.6",
|
||||
@@ -5079,12 +5079,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/braces": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
||||
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fill-range": "^7.0.1"
|
||||
"fill-range": "^7.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -7148,9 +7148,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io": {
|
||||
"version": "6.5.4",
|
||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.4.tgz",
|
||||
"integrity": "sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg==",
|
||||
"version": "6.5.5",
|
||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.5.tgz",
|
||||
"integrity": "sha512-C5Pn8Wk+1vKBoHghJODM63yk8MvrO9EWZUfkAt5HAqIgPE4/8FF0PEGHXtEd40l223+cE5ABWuPzm38PHFXfMA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/cookie": "^0.4.1",
|
||||
@@ -7162,7 +7162,7 @@
|
||||
"cors": "~2.8.5",
|
||||
"debug": "~4.3.1",
|
||||
"engine.io-parser": "~5.2.1",
|
||||
"ws": "~8.11.0"
|
||||
"ws": "~8.17.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.2.0"
|
||||
@@ -7834,9 +7834,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
||||
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"to-regex-range": "^5.0.1"
|
||||
@@ -17184,13 +17184,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-adapter": {
|
||||
"version": "2.5.4",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.4.tgz",
|
||||
"integrity": "sha512-wDNHGXGewWAjQPt3pyeYBtpWSq9cLE5UW1ZUPL/2eGK9jtse/FpXib7epSTsz0Q0m+6sg6Y4KtcFTlah1bdOVg==",
|
||||
"version": "2.5.5",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz",
|
||||
"integrity": "sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"debug": "~4.3.4",
|
||||
"ws": "~8.11.0"
|
||||
"ws": "~8.17.1"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-parser": {
|
||||
@@ -18918,27 +18918,6 @@
|
||||
"url": "https://opencollective.com/webpack"
|
||||
}
|
||||
},
|
||||
"node_modules/webpack-dev-server/node_modules/ws": {
|
||||
"version": "8.17.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz",
|
||||
"integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/webpack-merge": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz",
|
||||
@@ -19310,16 +19289,16 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.11.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
|
||||
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
|
||||
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mergely",
|
||||
"version": "5.2.0",
|
||||
"version": "5.3.2",
|
||||
"description": "A javascript UI for diff/merge",
|
||||
"license": "(GPL-3.0 OR LGPL-3.0 OR MPL-1.1 OR SEE LICENSE IN LICENSE)",
|
||||
"author": {
|
||||
|
||||
@@ -241,10 +241,13 @@ function CodeifyText(lhs, rhs, options) {
|
||||
this.ctxs = {};
|
||||
this.options = options;
|
||||
this.options.split = this.options.split || 'lines';
|
||||
const exp = /\p{Letter}\p{Mark}*|\p{Number}\p{Mark}*|\p{Punctuation}\p{Mark}*|\p{Symbol}\p{Mark}*|\p{White_Space}/gu;
|
||||
|
||||
if (typeof lhs === 'string') {
|
||||
if (this.options.split === 'chars') {
|
||||
this.lhs = lhs.split('');
|
||||
// split characters and include their diacritical marks
|
||||
this.lhs = lhs.match(exp) || [];
|
||||
// this.lhs = [...lhs];
|
||||
} else if (this.options.split === 'words') {
|
||||
this.lhs = lhs.split(/\s/);
|
||||
} else if (this.options.split === 'lines') {
|
||||
@@ -255,7 +258,9 @@ function CodeifyText(lhs, rhs, options) {
|
||||
}
|
||||
if (typeof rhs === 'string') {
|
||||
if (this.options.split === 'chars') {
|
||||
this.rhs = rhs.split('');
|
||||
// split characters and include their diacritical marks
|
||||
this.rhs = rhs.match(exp) || [];
|
||||
// this.rhs = [...rhs];
|
||||
} else if (this.options.split === 'words') {
|
||||
this.rhs = rhs.split(/\s/);
|
||||
} else if (this.options.split === 'lines') {
|
||||
|
||||
22
src/vdoc.js
22
src/vdoc.js
@@ -2,6 +2,10 @@ const diff = require('./diff');
|
||||
|
||||
const trace = console.log;
|
||||
|
||||
const expLetters = new RegExp(
|
||||
/\p{Letter}\p{Mark}*|\p{Number}\p{Mark}*|\p{Punctuation}\p{Mark}*|\p{Symbol}\p{Mark}*|\p{White_Space}/gu
|
||||
);
|
||||
|
||||
class VDoc {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
@@ -275,15 +279,18 @@ class VLine {
|
||||
editor.setGutterMarker(this.id, name, item);
|
||||
}
|
||||
if (this.markup.length) {
|
||||
// while Mergely diffs unicode chars (letters+mark), CM is by character,
|
||||
// so diffs need to be mapped.
|
||||
const mapped = mapLettersToChars(editor.getValue());
|
||||
for (const markup of this.markup) {
|
||||
const [ charFrom, charTo, className ] = markup;
|
||||
const fromPos = { line: this.id };
|
||||
const toPos = { line: this.id };
|
||||
if (charFrom >= 0) {
|
||||
fromPos.ch = charFrom;
|
||||
fromPos.ch = mapped[charFrom];
|
||||
}
|
||||
if (charTo >= 0) {
|
||||
toPos.ch = charTo;
|
||||
toPos.ch = mapped[charTo];
|
||||
}
|
||||
this._clearMarkup.push(
|
||||
editor.markText(fromPos, toPos, { className }));
|
||||
@@ -334,4 +341,15 @@ function getExtents(side, change) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapLettersToChars(text) {
|
||||
let match;
|
||||
let mapped = {};
|
||||
let index = 0;
|
||||
expLetters.lastIndex = 0;
|
||||
while ((match = expLetters.exec(text)) !== null) {
|
||||
mapped[index++] = match.index;
|
||||
}
|
||||
return mapped;
|
||||
}
|
||||
|
||||
module.exports = VDoc;
|
||||
|
||||
@@ -42,6 +42,7 @@ describe('markup', () => {
|
||||
|
||||
const LHS_CHANGE_START = '.mergely.lhs.c.CodeMirror-linebackground.start';
|
||||
const LHS_CHANGE_END = '.mergely.lhs.c.CodeMirror-linebackground.end';
|
||||
const LHS_CHANGE_START_AND_END = '.mergely.lhs.c.CodeMirror-linebackground.start.end';
|
||||
const RHS_CHANGE_START = '.mergely.rhs.c.CodeMirror-linebackground.start';
|
||||
const RHS_CHANGE_END = '.mergely.rhs.c.CodeMirror-linebackground.end';
|
||||
|
||||
@@ -233,7 +234,133 @@ describe('markup', () => {
|
||||
expect(rhs_spans[1].innerText).to.equal('h');
|
||||
expect(rhs_spans[2].innerText).to.equal('ir');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'single word single diacritic non-spacing marks',
|
||||
lhs: 'كلمة',
|
||||
rhs: 'كَلمة',
|
||||
check: (editor) => {
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
const lhs_spans = editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0');
|
||||
expect(lhs_spans).to.have.length(1);
|
||||
expect(lhs_spans[0].innerText).to.equal('ك');
|
||||
const rhs_spans = editor.querySelectorAll(RHS_INLINE_TEXT + '.cid-0');
|
||||
expect(rhs_spans).to.have.length(1);
|
||||
expect(rhs_spans[0].innerText).to.equal('كَ');
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'single word multiple diacritic non-spacing marks',
|
||||
lhs: ['\u006E', '\u0061', '\u0314', '\u0065'].join(''), // na̔e
|
||||
rhs: ['\u006E', '\u0061', '\u0314', '\u034A', '\u0065'].join(''), // na̔͊e
|
||||
check: (editor) => {
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
const lhs_spans = editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0');
|
||||
expect(lhs_spans).to.have.length(1);
|
||||
expect(lhs_spans[0].innerText).to.equal(['\u0061', '\u0314'].join(''));
|
||||
const rhs_spans = editor.querySelectorAll(RHS_INLINE_TEXT + '.cid-0');
|
||||
expect(rhs_spans).to.have.length(1);
|
||||
expect(rhs_spans[0].innerText).to.equal('a̔͊');
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'multiple words diacritic non-spacing marks',
|
||||
lhs: 'كلمة اخرى',
|
||||
rhs: 'كْلمة اخرى',
|
||||
check: (editor) => {
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
const lhs_spans = editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0');
|
||||
expect(lhs_spans).to.have.length(1);
|
||||
expect(lhs_spans[0].innerText).to.equal('ك');
|
||||
const rhs_spans = editor.querySelectorAll(RHS_INLINE_TEXT + '.cid-0');
|
||||
expect(rhs_spans).to.have.length(1);
|
||||
expect(rhs_spans[0].innerText).to.equal('كْ');
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'nonnormalizable diacritic non-spacing marks',
|
||||
lhs: 'naeg',
|
||||
// there are 2 marks on 'e', tilde (0303) and x (0353)
|
||||
rhs: ['\u006E', '\u0061', '\u0353', '\u0065', '\u0353', '\u0303', '\u0067'].join(''),
|
||||
check: (editor) => {
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
const lhs_spans = editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0');
|
||||
expect(lhs_spans).to.have.length(1);
|
||||
expect(lhs_spans[0].innerText).to.equal('ae');
|
||||
const rhs_spans = editor.querySelectorAll(RHS_INLINE_TEXT + '.cid-0');
|
||||
expect(rhs_spans).to.have.length(1);
|
||||
expect(rhs_spans[0].innerText).to.equal(
|
||||
['\u0061', '\u0353', '\u0065', '\u0353', '\u0303'].join('')
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'nonnormalizable diacritic non-spacing marks',
|
||||
lhs: [
|
||||
'\u0065', '\u0353', '\u0303',
|
||||
'\u0065', '\u0353', '\u0303',
|
||||
'\u0065', '\u0353', '\u0303',
|
||||
'x',
|
||||
'\u0065', '\u0353', '\u0303',
|
||||
].join(''),
|
||||
// there are 2 marks on 'e', tilde (0303) and x (0353)
|
||||
rhs: [
|
||||
'\u0065', '\u0353', '\u0303',
|
||||
'\u0065', '\u0353', '\u0303',
|
||||
'\u0065', '\u0353', '\u0303',
|
||||
'y',
|
||||
'\u0065', '\u0353', '\u0303',
|
||||
].join(''),
|
||||
check: (editor) => {
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_START + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(RHS_CHANGE_END + '.cid-0')).to.have.length(1);
|
||||
const lhs_spans = editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0');
|
||||
expect(lhs_spans).to.have.length(1);
|
||||
expect(lhs_spans[0].innerText).to.equal('x');
|
||||
const rhs_spans = editor.querySelectorAll(RHS_INLINE_TEXT + '.cid-0');
|
||||
expect(rhs_spans).to.have.length(1);
|
||||
expect(rhs_spans[0].innerText).to.equal('y');
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Changes with non-letter chars',
|
||||
lhs: '~# 00 == ! (dog) \n',
|
||||
rhs: '~? 11 ++ ] (fox) .\n',
|
||||
only: true,
|
||||
check: (editor) => {
|
||||
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(RHS_INLINE_TEXT + '.cid-0')).to.have.length(7);
|
||||
const lhs_changes = editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0');
|
||||
const rhs_changes = editor.querySelectorAll(RHS_INLINE_TEXT + '.cid-0');
|
||||
const lhs_values = [];
|
||||
for (const value of lhs_changes.values()) {
|
||||
lhs_values.push(value.innerText);
|
||||
}
|
||||
const rhs_values = [];
|
||||
for (const value of rhs_changes.values()) {
|
||||
rhs_values.push(value.innerText);
|
||||
}
|
||||
console.log(lhs_values);
|
||||
console.log(rhs_values);
|
||||
expect(lhs_values).to.deep.equal(['#', '00', '==', '!', 'd', 'g']);
|
||||
expect(rhs_values).to.deep.equal(['?', '11', '++', ']', 'f', 'x', '.']);
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
// to debug, add `only: true` to the test `opts` above, and run `npm run debug`
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const path = require('path')
|
||||
const chalk = require('chalk');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
@@ -50,8 +51,8 @@ module.exports = {
|
||||
compiler.hooks.entryOption.tap('MyPlugin', (context, entry) => {
|
||||
console.log('-'.repeat(78));
|
||||
console.log('Applications:');
|
||||
console.log('http://localhost:8080/app.html');
|
||||
console.log('http://localhost:8080/app-styles.html');
|
||||
console.log(chalk.bold(chalk.underline(chalk.cyan('http://localhost:8080/app.html'))));
|
||||
console.log(chalk.bold(chalk.underline(chalk.cyan('http://localhost:8080/app-styles.html'))));
|
||||
console.log('-'.repeat(78));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user