@atlaskit/editor-plugin-show-diff 4.0.6 → 4.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 4.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 4.0.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`6911179854bdb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6911179854bdb) -
|
|
14
|
+
Remove diff highlighting if there are overlapping mark steps (ie. add and then remove)
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 4.0.6
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -5,17 +5,71 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getMarkChangeRanges = void 0;
|
|
7
7
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
9
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
8
12
|
var filterUndefined = function filterUndefined(x) {
|
|
9
13
|
return !!x;
|
|
10
14
|
};
|
|
15
|
+
var extractMarkStep = function extractMarkStep(step) {
|
|
16
|
+
if (step instanceof _transform.AddMarkStep) {
|
|
17
|
+
return {
|
|
18
|
+
type: 'add',
|
|
19
|
+
from: step.from,
|
|
20
|
+
to: step.to,
|
|
21
|
+
markName: step.mark.type.name
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (step instanceof _transform.RemoveMarkStep) {
|
|
25
|
+
return {
|
|
26
|
+
type: 'remove',
|
|
27
|
+
from: step.from,
|
|
28
|
+
to: step.to,
|
|
29
|
+
markName: step.mark.type.name
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
};
|
|
11
34
|
var getMarkChangeRanges = exports.getMarkChangeRanges = function getMarkChangeRanges(steps) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
35
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_deduplicate_mark_diff', 'isEnabled', true)) {
|
|
36
|
+
return steps.map(function (step) {
|
|
37
|
+
if (step instanceof _transform.AddMarkStep || step instanceof _transform.RemoveMarkStep) {
|
|
38
|
+
return {
|
|
39
|
+
fromB: step.from,
|
|
40
|
+
toB: step.to
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}).filter(filterUndefined);
|
|
45
|
+
}
|
|
46
|
+
var resultRanges = [];
|
|
47
|
+
var lastOp;
|
|
48
|
+
var _iterator = _createForOfIteratorHelper(steps),
|
|
49
|
+
_step;
|
|
50
|
+
try {
|
|
51
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
52
|
+
var step = _step.value;
|
|
53
|
+
var op = extractMarkStep(step);
|
|
54
|
+
if (!op) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Check if previous operation cancels this one
|
|
59
|
+
if (lastOp && lastOp.from === op.from && lastOp.to === op.to && lastOp.markName === op.markName && lastOp.type !== op.type) {
|
|
60
|
+
resultRanges.pop();
|
|
61
|
+
} else {
|
|
62
|
+
resultRanges.push({
|
|
63
|
+
fromB: op.from,
|
|
64
|
+
toB: op.to
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
lastOp = op;
|
|
18
68
|
}
|
|
19
|
-
|
|
20
|
-
|
|
69
|
+
} catch (err) {
|
|
70
|
+
_iterator.e(err);
|
|
71
|
+
} finally {
|
|
72
|
+
_iterator.f();
|
|
73
|
+
}
|
|
74
|
+
return resultRanges;
|
|
21
75
|
};
|
|
@@ -1,13 +1,55 @@
|
|
|
1
1
|
import { AddMarkStep, RemoveMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
const filterUndefined = x => !!x;
|
|
4
|
+
const extractMarkStep = step => {
|
|
5
|
+
if (step instanceof AddMarkStep) {
|
|
6
|
+
return {
|
|
7
|
+
type: 'add',
|
|
8
|
+
from: step.from,
|
|
9
|
+
to: step.to,
|
|
10
|
+
markName: step.mark.type.name
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (step instanceof RemoveMarkStep) {
|
|
14
|
+
return {
|
|
15
|
+
type: 'remove',
|
|
16
|
+
from: step.from,
|
|
17
|
+
to: step.to,
|
|
18
|
+
markName: step.mark.type.name
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
3
23
|
export const getMarkChangeRanges = steps => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
24
|
+
if (!expValEquals('platform_editor_deduplicate_mark_diff', 'isEnabled', true)) {
|
|
25
|
+
return steps.map(step => {
|
|
26
|
+
if (step instanceof AddMarkStep || step instanceof RemoveMarkStep) {
|
|
27
|
+
return {
|
|
28
|
+
fromB: step.from,
|
|
29
|
+
toB: step.to
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}).filter(filterUndefined);
|
|
34
|
+
}
|
|
35
|
+
const resultRanges = [];
|
|
36
|
+
let lastOp;
|
|
37
|
+
for (const step of steps) {
|
|
38
|
+
const op = extractMarkStep(step);
|
|
39
|
+
if (!op) {
|
|
40
|
+
continue;
|
|
10
41
|
}
|
|
11
|
-
|
|
12
|
-
|
|
42
|
+
|
|
43
|
+
// Check if previous operation cancels this one
|
|
44
|
+
if (lastOp && lastOp.from === op.from && lastOp.to === op.to && lastOp.markName === op.markName && lastOp.type !== op.type) {
|
|
45
|
+
resultRanges.pop();
|
|
46
|
+
} else {
|
|
47
|
+
resultRanges.push({
|
|
48
|
+
fromB: op.from,
|
|
49
|
+
toB: op.to
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
lastOp = op;
|
|
53
|
+
}
|
|
54
|
+
return resultRanges;
|
|
13
55
|
};
|
|
@@ -1,15 +1,69 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
1
4
|
import { AddMarkStep, RemoveMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
6
|
var filterUndefined = function filterUndefined(x) {
|
|
3
7
|
return !!x;
|
|
4
8
|
};
|
|
9
|
+
var extractMarkStep = function extractMarkStep(step) {
|
|
10
|
+
if (step instanceof AddMarkStep) {
|
|
11
|
+
return {
|
|
12
|
+
type: 'add',
|
|
13
|
+
from: step.from,
|
|
14
|
+
to: step.to,
|
|
15
|
+
markName: step.mark.type.name
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (step instanceof RemoveMarkStep) {
|
|
19
|
+
return {
|
|
20
|
+
type: 'remove',
|
|
21
|
+
from: step.from,
|
|
22
|
+
to: step.to,
|
|
23
|
+
markName: step.mark.type.name
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
};
|
|
5
28
|
export var getMarkChangeRanges = function getMarkChangeRanges(steps) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
29
|
+
if (!expValEquals('platform_editor_deduplicate_mark_diff', 'isEnabled', true)) {
|
|
30
|
+
return steps.map(function (step) {
|
|
31
|
+
if (step instanceof AddMarkStep || step instanceof RemoveMarkStep) {
|
|
32
|
+
return {
|
|
33
|
+
fromB: step.from,
|
|
34
|
+
toB: step.to
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}).filter(filterUndefined);
|
|
39
|
+
}
|
|
40
|
+
var resultRanges = [];
|
|
41
|
+
var lastOp;
|
|
42
|
+
var _iterator = _createForOfIteratorHelper(steps),
|
|
43
|
+
_step;
|
|
44
|
+
try {
|
|
45
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
46
|
+
var step = _step.value;
|
|
47
|
+
var op = extractMarkStep(step);
|
|
48
|
+
if (!op) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Check if previous operation cancels this one
|
|
53
|
+
if (lastOp && lastOp.from === op.from && lastOp.to === op.to && lastOp.markName === op.markName && lastOp.type !== op.type) {
|
|
54
|
+
resultRanges.pop();
|
|
55
|
+
} else {
|
|
56
|
+
resultRanges.push({
|
|
57
|
+
fromB: op.from,
|
|
58
|
+
toB: op.to
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
lastOp = op;
|
|
12
62
|
}
|
|
13
|
-
|
|
14
|
-
|
|
63
|
+
} catch (err) {
|
|
64
|
+
_iterator.e(err);
|
|
65
|
+
} finally {
|
|
66
|
+
_iterator.f();
|
|
67
|
+
}
|
|
68
|
+
return resultRanges;
|
|
15
69
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.8",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
33
33
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
34
34
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
35
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
35
|
+
"@atlaskit/tmp-editor-statsig": "^23.0.0",
|
|
36
36
|
"@atlaskit/tokens": "^11.0.0",
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"prosemirror-changeset": "^2.3.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@atlaskit/editor-common": "^111.
|
|
43
|
+
"@atlaskit/editor-common": "^111.12.0",
|
|
44
44
|
"react": "^18.2.0"
|
|
45
45
|
},
|
|
46
46
|
"techstack": {
|