@atlaskit/editor-plugin-show-diff 5.0.6 → 5.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 +17 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/pm-plugins/calculateDiffDecorations.js +15 -1
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +0 -4
- package/dist/cjs/pm-plugins/main.js +5 -3
- package/dist/cjs/pm-plugins/simplifyChanges.js +3 -4
- package/dist/cjs/showDiffPlugin.js +2 -2
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +15 -1
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +0 -4
- package/dist/es2019/pm-plugins/main.js +5 -3
- package/dist/es2019/pm-plugins/simplifyChanges.js +3 -4
- package/dist/es2019/showDiffPlugin.js +2 -2
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +15 -1
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +0 -4
- package/dist/esm/pm-plugins/main.js +5 -3
- package/dist/esm/pm-plugins/simplifyChanges.js +3 -4
- package/dist/esm/showDiffPlugin.js +2 -2
- package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +4 -2
- package/dist/types/pm-plugins/main.d.ts +3 -2
- package/dist/types/showDiffPluginType.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +4 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -2
- package/dist/types-ts4.5/showDiffPluginType.d.ts +5 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 5.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e7825d1698274`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e7825d1698274) -
|
|
8
|
+
Improve areNodesEqualIgnoreAttrs by adding option ignoreMarkOrder which ensures the order of the
|
|
9
|
+
marks does not result in a "false" which can break some cases of diffs.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 5.0.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`1fd2b267eb592`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1fd2b267eb592) -
|
|
17
|
+
Cleanup `platform_editor_ai_aifc_patch_ga` flag
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 5.0.6
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -13,6 +13,7 @@ var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
|
13
13
|
var _prosemirrorChangeset = require("prosemirror-changeset");
|
|
14
14
|
var _document = require("@atlaskit/editor-common/utils/document");
|
|
15
15
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
16
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
17
|
var _createBlockChangedDecoration = require("./decorations/createBlockChangedDecoration");
|
|
17
18
|
var _createInlineChangedDecoration = require("./decorations/createInlineChangedDecoration");
|
|
18
19
|
var _createNodeChangedDecorationWidget = require("./decorations/createNodeChangedDecorationWidget");
|
|
@@ -87,7 +88,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
|
|
|
87
88
|
nodeViewSerializer = _ref2.nodeViewSerializer,
|
|
88
89
|
colorScheme = _ref2.colorScheme,
|
|
89
90
|
intl = _ref2.intl,
|
|
90
|
-
activeIndexPos = _ref2.activeIndexPos
|
|
91
|
+
activeIndexPos = _ref2.activeIndexPos,
|
|
92
|
+
api = _ref2.api;
|
|
91
93
|
var originalDoc = pluginState.originalDoc,
|
|
92
94
|
steps = pluginState.steps;
|
|
93
95
|
if (!originalDoc || !pluginState.isDisplayingChanges) {
|
|
@@ -121,6 +123,18 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
|
|
|
121
123
|
_iterator.f();
|
|
122
124
|
}
|
|
123
125
|
if (!(0, _document.areNodesEqualIgnoreAttrs)(steppedDoc, tr.doc)) {
|
|
126
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
127
|
+
var _api$analytics;
|
|
128
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
129
|
+
eventType: 'track',
|
|
130
|
+
action: 'nodesNotEqual',
|
|
131
|
+
actionSubject: 'showDiff',
|
|
132
|
+
attributes: {
|
|
133
|
+
docSizeEqual: steppedDoc.nodeSize === tr.doc.nodeSize,
|
|
134
|
+
colorScheme: colorScheme
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
124
138
|
return _view.DecorationSet.empty;
|
|
125
139
|
}
|
|
126
140
|
var changeset = _prosemirrorChangeset.ChangeSet.create(originalDoc).addSteps(steppedDoc, stepMaps, tr.doc);
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createNodeChangedDecorationWidget = void 0;
|
|
7
7
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
8
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
9
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
9
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
10
|
var _standard = require("./colorSchemes/standard");
|
|
12
11
|
var _traditional = require("./colorSchemes/traditional");
|
|
@@ -75,9 +74,6 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
77
76
|
if (isTableRowContent) {
|
|
78
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga')) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
77
|
return (0, _createChangedRowDecorationWidgets.createChangedRowDecorationWidgets)({
|
|
82
78
|
changes: [change],
|
|
83
79
|
originalDoc: doc,
|
|
@@ -24,7 +24,7 @@ var getScrollableDecorations = exports.getScrollableDecorations = function getSc
|
|
|
24
24
|
return spec.key === 'diff-inline' || spec.key === 'diff-widget' || spec.key === 'diff-block';
|
|
25
25
|
})) !== null && _set$find !== void 0 ? _set$find : [];
|
|
26
26
|
};
|
|
27
|
-
var createPlugin = exports.createPlugin = function createPlugin(config, getIntl) {
|
|
27
|
+
var createPlugin = exports.createPlugin = function createPlugin(config, getIntl, api) {
|
|
28
28
|
var nodeViewSerializer = new _NodeViewSerializer.NodeViewSerializer({});
|
|
29
29
|
var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
|
|
30
30
|
nodeViewSerializer.init({
|
|
@@ -60,7 +60,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
|
|
|
60
60
|
nodeViewSerializer: nodeViewSerializer,
|
|
61
61
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
62
62
|
intl: getIntl(),
|
|
63
|
-
activeIndexPos: (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined
|
|
63
|
+
activeIndexPos: (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined,
|
|
64
|
+
api: api
|
|
64
65
|
});
|
|
65
66
|
// Update the decorations
|
|
66
67
|
newPluginState.decorations = decorations;
|
|
@@ -96,7 +97,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
|
|
|
96
97
|
nodeViewSerializer: nodeViewSerializer,
|
|
97
98
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
98
99
|
intl: getIntl(),
|
|
99
|
-
activeIndexPos: newPluginState.activeIndexPos
|
|
100
|
+
activeIndexPos: newPluginState.activeIndexPos,
|
|
101
|
+
api: api
|
|
100
102
|
});
|
|
101
103
|
newPluginState.decorations = updatedDecorations;
|
|
102
104
|
}
|
|
@@ -7,7 +7,6 @@ exports.simplifySteps = simplifySteps;
|
|
|
7
7
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
8
8
|
var _document = require("@atlaskit/editor-common/utils/document");
|
|
9
9
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
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; } } }; }
|
|
12
11
|
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; } }
|
|
13
12
|
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; }
|
|
@@ -33,7 +32,7 @@ function mergeReplaceSteps(step1, step2) {
|
|
|
33
32
|
|
|
34
33
|
// Simplifies the steps to improve performance and reduce fragmentation in diffs
|
|
35
34
|
function simplifySteps(steps, originalDoc) {
|
|
36
|
-
var stepsToFilter =
|
|
35
|
+
var stepsToFilter = removeUnusedSteps(steps, originalDoc);
|
|
37
36
|
return stepsToFilter
|
|
38
37
|
// Remove steps that don't affect document structure or content
|
|
39
38
|
.filter(function (step) {
|
|
@@ -41,9 +40,9 @@ function simplifySteps(steps, originalDoc) {
|
|
|
41
40
|
})
|
|
42
41
|
// Merge consecutive steps where possible
|
|
43
42
|
.reduce(function (acc, step) {
|
|
44
|
-
var _lastStep$merge, _lastStep$merge2
|
|
43
|
+
var _lastStep$merge, _lastStep$merge2;
|
|
45
44
|
var lastStep = acc[acc.length - 1];
|
|
46
|
-
var merged = (
|
|
45
|
+
var merged = (_lastStep$merge = lastStep === null || lastStep === void 0 || (_lastStep$merge2 = lastStep.merge) === null || _lastStep$merge2 === void 0 ? void 0 : _lastStep$merge2.call(lastStep, step)) !== null && _lastStep$merge !== void 0 ? _lastStep$merge : mergeReplaceSteps(lastStep, step);
|
|
47
46
|
if (merged) {
|
|
48
47
|
acc[acc.length - 1] = merged;
|
|
49
48
|
} else {
|
|
@@ -11,7 +11,7 @@ var _main = require("./pm-plugins/main");
|
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
13
|
var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
14
|
-
var
|
|
14
|
+
var api = _ref.api,
|
|
15
15
|
config = _ref.config;
|
|
16
16
|
return {
|
|
17
17
|
name: 'showDiff',
|
|
@@ -49,7 +49,7 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
49
49
|
name: 'showDiffPlugin',
|
|
50
50
|
plugin: function plugin(_ref6) {
|
|
51
51
|
var getIntl = _ref6.getIntl;
|
|
52
|
-
return (0, _main.createPlugin)(config, getIntl);
|
|
52
|
+
return (0, _main.createPlugin)(config, getIntl, api);
|
|
53
53
|
}
|
|
54
54
|
}];
|
|
55
55
|
},
|
|
@@ -4,6 +4,7 @@ import memoizeOne from 'memoize-one';
|
|
|
4
4
|
import { ChangeSet, simplifyChanges } from 'prosemirror-changeset';
|
|
5
5
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { createBlockChangedDecoration } from './decorations/createBlockChangedDecoration';
|
|
8
9
|
import { createInlineChangedDecoration } from './decorations/createInlineChangedDecoration';
|
|
9
10
|
import { createNodeChangedDecorationWidget } from './decorations/createNodeChangedDecorationWidget';
|
|
@@ -78,7 +79,8 @@ const calculateDiffDecorationsInner = ({
|
|
|
78
79
|
nodeViewSerializer,
|
|
79
80
|
colorScheme,
|
|
80
81
|
intl,
|
|
81
|
-
activeIndexPos
|
|
82
|
+
activeIndexPos,
|
|
83
|
+
api
|
|
82
84
|
}) => {
|
|
83
85
|
const {
|
|
84
86
|
originalDoc,
|
|
@@ -108,6 +110,18 @@ const calculateDiffDecorationsInner = ({
|
|
|
108
110
|
// Rather than using .eq() we use a custom function that only checks for structural
|
|
109
111
|
// changes and ignores differences in attributes which don't affect decoration positions
|
|
110
112
|
if (!areNodesEqualIgnoreAttrs(steppedDoc, tr.doc)) {
|
|
113
|
+
if (expValEquals('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
114
|
+
var _api$analytics;
|
|
115
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
|
|
116
|
+
eventType: 'track',
|
|
117
|
+
action: 'nodesNotEqual',
|
|
118
|
+
actionSubject: 'showDiff',
|
|
119
|
+
attributes: {
|
|
120
|
+
docSizeEqual: steppedDoc.nodeSize === tr.doc.nodeSize,
|
|
121
|
+
colorScheme
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
111
125
|
return DecorationSet.empty;
|
|
112
126
|
}
|
|
113
127
|
const changeset = ChangeSet.create(originalDoc).addSteps(steppedDoc, stepMaps, tr.doc);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedContentStyleUnbounded } from './colorSchemes/standard';
|
|
6
5
|
import { deletedTraditionalContentStyle, deletedTraditionalContentStyleUnbounded } from './colorSchemes/traditional';
|
|
@@ -57,9 +56,6 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
59
58
|
if (isTableRowContent) {
|
|
60
|
-
if (!fg('platform_editor_ai_aifc_patch_ga')) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
59
|
return createChangedRowDecorationWidgets({
|
|
64
60
|
changes: [change],
|
|
65
61
|
originalDoc: doc,
|
|
@@ -12,7 +12,7 @@ export const getScrollableDecorations = set => {
|
|
|
12
12
|
var _set$find;
|
|
13
13
|
return (_set$find = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, spec => spec.key === 'diff-inline' || spec.key === 'diff-widget' || spec.key === 'diff-block')) !== null && _set$find !== void 0 ? _set$find : [];
|
|
14
14
|
};
|
|
15
|
-
export const createPlugin = (config, getIntl) => {
|
|
15
|
+
export const createPlugin = (config, getIntl, api) => {
|
|
16
16
|
const nodeViewSerializer = new NodeViewSerializer({});
|
|
17
17
|
const setNodeViewSerializer = editorView => {
|
|
18
18
|
nodeViewSerializer.init({
|
|
@@ -50,7 +50,8 @@ export const createPlugin = (config, getIntl) => {
|
|
|
50
50
|
nodeViewSerializer,
|
|
51
51
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
52
52
|
intl: getIntl(),
|
|
53
|
-
activeIndexPos: fg('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined
|
|
53
|
+
activeIndexPos: fg('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined,
|
|
54
|
+
api
|
|
54
55
|
});
|
|
55
56
|
// Update the decorations
|
|
56
57
|
newPluginState.decorations = decorations;
|
|
@@ -89,7 +90,8 @@ export const createPlugin = (config, getIntl) => {
|
|
|
89
90
|
nodeViewSerializer,
|
|
90
91
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
91
92
|
intl: getIntl(),
|
|
92
|
-
activeIndexPos: newPluginState.activeIndexPos
|
|
93
|
+
activeIndexPos: newPluginState.activeIndexPos,
|
|
94
|
+
api
|
|
93
95
|
});
|
|
94
96
|
newPluginState.decorations = updatedDecorations;
|
|
95
97
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
2
2
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
3
3
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Attempts to merge two consecutive ReplaceStep operations.
|
|
@@ -25,15 +24,15 @@ function mergeReplaceSteps(step1, step2) {
|
|
|
25
24
|
|
|
26
25
|
// Simplifies the steps to improve performance and reduce fragmentation in diffs
|
|
27
26
|
export function simplifySteps(steps, originalDoc) {
|
|
28
|
-
const stepsToFilter =
|
|
27
|
+
const stepsToFilter = removeUnusedSteps(steps, originalDoc);
|
|
29
28
|
return stepsToFilter
|
|
30
29
|
// Remove steps that don't affect document structure or content
|
|
31
30
|
.filter(step => !(step instanceof AnalyticsStep))
|
|
32
31
|
// Merge consecutive steps where possible
|
|
33
32
|
.reduce((acc, step) => {
|
|
34
|
-
var _lastStep$merge, _lastStep$merge2
|
|
33
|
+
var _lastStep$merge, _lastStep$merge2;
|
|
35
34
|
const lastStep = acc[acc.length - 1];
|
|
36
|
-
const merged =
|
|
35
|
+
const merged = (_lastStep$merge = lastStep === null || lastStep === void 0 ? void 0 : (_lastStep$merge2 = lastStep.merge) === null || _lastStep$merge2 === void 0 ? void 0 : _lastStep$merge2.call(lastStep, step)) !== null && _lastStep$merge !== void 0 ? _lastStep$merge : mergeReplaceSteps(lastStep, step);
|
|
37
36
|
if (merged) {
|
|
38
37
|
acc[acc.length - 1] = merged;
|
|
39
38
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { createPlugin, showDiffPluginKey, getScrollableDecorations } from './pm-plugins/main';
|
|
3
3
|
export const showDiffPlugin = ({
|
|
4
|
-
api
|
|
4
|
+
api,
|
|
5
5
|
config
|
|
6
6
|
}) => ({
|
|
7
7
|
name: 'showDiff',
|
|
@@ -42,7 +42,7 @@ export const showDiffPlugin = ({
|
|
|
42
42
|
name: 'showDiffPlugin',
|
|
43
43
|
plugin: ({
|
|
44
44
|
getIntl
|
|
45
|
-
}) => createPlugin(config, getIntl)
|
|
45
|
+
}) => createPlugin(config, getIntl, api)
|
|
46
46
|
}];
|
|
47
47
|
},
|
|
48
48
|
getSharedState: editorState => {
|
|
@@ -12,6 +12,7 @@ import memoizeOne from 'memoize-one';
|
|
|
12
12
|
import { ChangeSet, simplifyChanges } from 'prosemirror-changeset';
|
|
13
13
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
14
14
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
15
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
16
|
import { createBlockChangedDecoration } from './decorations/createBlockChangedDecoration';
|
|
16
17
|
import { createInlineChangedDecoration } from './decorations/createInlineChangedDecoration';
|
|
17
18
|
import { createNodeChangedDecorationWidget } from './decorations/createNodeChangedDecorationWidget';
|
|
@@ -81,7 +82,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
|
|
|
81
82
|
nodeViewSerializer = _ref2.nodeViewSerializer,
|
|
82
83
|
colorScheme = _ref2.colorScheme,
|
|
83
84
|
intl = _ref2.intl,
|
|
84
|
-
activeIndexPos = _ref2.activeIndexPos
|
|
85
|
+
activeIndexPos = _ref2.activeIndexPos,
|
|
86
|
+
api = _ref2.api;
|
|
85
87
|
var originalDoc = pluginState.originalDoc,
|
|
86
88
|
steps = pluginState.steps;
|
|
87
89
|
if (!originalDoc || !pluginState.isDisplayingChanges) {
|
|
@@ -115,6 +117,18 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
|
|
|
115
117
|
_iterator.f();
|
|
116
118
|
}
|
|
117
119
|
if (!areNodesEqualIgnoreAttrs(steppedDoc, tr.doc)) {
|
|
120
|
+
if (expValEquals('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
121
|
+
var _api$analytics;
|
|
122
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
123
|
+
eventType: 'track',
|
|
124
|
+
action: 'nodesNotEqual',
|
|
125
|
+
actionSubject: 'showDiff',
|
|
126
|
+
attributes: {
|
|
127
|
+
docSizeEqual: steppedDoc.nodeSize === tr.doc.nodeSize,
|
|
128
|
+
colorScheme: colorScheme
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
118
132
|
return DecorationSet.empty;
|
|
119
133
|
}
|
|
120
134
|
var changeset = ChangeSet.create(originalDoc).addSteps(steppedDoc, stepMaps, tr.doc);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedContentStyleUnbounded } from './colorSchemes/standard';
|
|
6
5
|
import { deletedTraditionalContentStyle, deletedTraditionalContentStyleUnbounded } from './colorSchemes/traditional';
|
|
@@ -69,9 +68,6 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
69
68
|
return;
|
|
70
69
|
}
|
|
71
70
|
if (isTableRowContent) {
|
|
72
|
-
if (!fg('platform_editor_ai_aifc_patch_ga')) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
71
|
return createChangedRowDecorationWidgets({
|
|
76
72
|
changes: [change],
|
|
77
73
|
originalDoc: doc,
|
|
@@ -17,7 +17,7 @@ export var getScrollableDecorations = function getScrollableDecorations(set) {
|
|
|
17
17
|
return spec.key === 'diff-inline' || spec.key === 'diff-widget' || spec.key === 'diff-block';
|
|
18
18
|
})) !== null && _set$find !== void 0 ? _set$find : [];
|
|
19
19
|
};
|
|
20
|
-
export var createPlugin = function createPlugin(config, getIntl) {
|
|
20
|
+
export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
21
21
|
var nodeViewSerializer = new NodeViewSerializer({});
|
|
22
22
|
var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
|
|
23
23
|
nodeViewSerializer.init({
|
|
@@ -53,7 +53,8 @@ export var createPlugin = function createPlugin(config, getIntl) {
|
|
|
53
53
|
nodeViewSerializer: nodeViewSerializer,
|
|
54
54
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
55
55
|
intl: getIntl(),
|
|
56
|
-
activeIndexPos: fg('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined
|
|
56
|
+
activeIndexPos: fg('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined,
|
|
57
|
+
api: api
|
|
57
58
|
});
|
|
58
59
|
// Update the decorations
|
|
59
60
|
newPluginState.decorations = decorations;
|
|
@@ -89,7 +90,8 @@ export var createPlugin = function createPlugin(config, getIntl) {
|
|
|
89
90
|
nodeViewSerializer: nodeViewSerializer,
|
|
90
91
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
91
92
|
intl: getIntl(),
|
|
92
|
-
activeIndexPos: newPluginState.activeIndexPos
|
|
93
|
+
activeIndexPos: newPluginState.activeIndexPos,
|
|
94
|
+
api: api
|
|
93
95
|
});
|
|
94
96
|
newPluginState.decorations = updatedDecorations;
|
|
95
97
|
}
|
|
@@ -4,7 +4,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
4
4
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
5
5
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
6
6
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Attempts to merge two consecutive ReplaceStep operations.
|
|
@@ -28,7 +27,7 @@ function mergeReplaceSteps(step1, step2) {
|
|
|
28
27
|
|
|
29
28
|
// Simplifies the steps to improve performance and reduce fragmentation in diffs
|
|
30
29
|
export function simplifySteps(steps, originalDoc) {
|
|
31
|
-
var stepsToFilter =
|
|
30
|
+
var stepsToFilter = removeUnusedSteps(steps, originalDoc);
|
|
32
31
|
return stepsToFilter
|
|
33
32
|
// Remove steps that don't affect document structure or content
|
|
34
33
|
.filter(function (step) {
|
|
@@ -36,9 +35,9 @@ export function simplifySteps(steps, originalDoc) {
|
|
|
36
35
|
})
|
|
37
36
|
// Merge consecutive steps where possible
|
|
38
37
|
.reduce(function (acc, step) {
|
|
39
|
-
var _lastStep$merge, _lastStep$merge2
|
|
38
|
+
var _lastStep$merge, _lastStep$merge2;
|
|
40
39
|
var lastStep = acc[acc.length - 1];
|
|
41
|
-
var merged =
|
|
40
|
+
var merged = (_lastStep$merge = lastStep === null || lastStep === void 0 || (_lastStep$merge2 = lastStep.merge) === null || _lastStep$merge2 === void 0 ? void 0 : _lastStep$merge2.call(lastStep, step)) !== null && _lastStep$merge !== void 0 ? _lastStep$merge : mergeReplaceSteps(lastStep, step);
|
|
42
41
|
if (merged) {
|
|
43
42
|
acc[acc.length - 1] = merged;
|
|
44
43
|
} else {
|
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { createPlugin, showDiffPluginKey, getScrollableDecorations } from './pm-plugins/main';
|
|
6
6
|
export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
7
|
-
var
|
|
7
|
+
var api = _ref.api,
|
|
8
8
|
config = _ref.config;
|
|
9
9
|
return {
|
|
10
10
|
name: 'showDiff',
|
|
@@ -42,7 +42,7 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
42
42
|
name: 'showDiffPlugin',
|
|
43
43
|
plugin: function plugin(_ref6) {
|
|
44
44
|
var getIntl = _ref6.getIntl;
|
|
45
|
-
return createPlugin(config, getIntl);
|
|
45
|
+
return createPlugin(config, getIntl, api);
|
|
46
46
|
}
|
|
47
47
|
}];
|
|
48
48
|
},
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import type { ColorScheme } from '../showDiffPluginType';
|
|
5
|
+
import type { ColorScheme, ShowDiffPlugin } from '../showDiffPluginType';
|
|
5
6
|
import type { ShowDiffPluginState } from './main';
|
|
6
7
|
import type { NodeViewSerializer } from './NodeViewSerializer';
|
|
7
|
-
export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, }: {
|
|
8
|
+
export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, }: {
|
|
8
9
|
activeIndexPos?: {
|
|
9
10
|
from: number;
|
|
10
11
|
to: number;
|
|
11
12
|
};
|
|
13
|
+
api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
|
|
12
14
|
colorScheme?: ColorScheme;
|
|
13
15
|
intl: IntlShape;
|
|
14
16
|
nodeViewSerializer: NodeViewSerializer;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
7
|
import type { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
7
8
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import { type DiffParams } from '../showDiffPluginType';
|
|
9
|
+
import { type DiffParams, type ShowDiffPlugin } from '../showDiffPluginType';
|
|
9
10
|
export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
|
|
10
11
|
export type ShowDiffPluginState = {
|
|
11
12
|
activeIndex?: number;
|
|
@@ -19,4 +20,4 @@ export type ShowDiffPluginState = {
|
|
|
19
20
|
steps: ProseMirrorStep[];
|
|
20
21
|
};
|
|
21
22
|
export declare const getScrollableDecorations: (set: DecorationSet | undefined) => Decoration[];
|
|
22
|
-
export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape) => SafePlugin<ShowDiffPluginState>;
|
|
23
|
+
export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined) => SafePlugin<ShowDiffPluginState>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StepJson } from '@atlaskit/editor-common/collab';
|
|
2
|
-
import type { NextEditorPlugin, EditorCommand } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { NextEditorPlugin, EditorCommand, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
5
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
6
7
|
export type ColorScheme = 'standard' | 'traditional';
|
|
@@ -32,6 +33,7 @@ export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
|
|
|
32
33
|
scrollToPrevious: EditorCommand;
|
|
33
34
|
showDiff: (config: PMDiffParams) => EditorCommand;
|
|
34
35
|
};
|
|
36
|
+
dependencies: [OptionalPlugin<AnalyticsPlugin>];
|
|
35
37
|
pluginConfiguration: DiffParams | undefined;
|
|
36
38
|
sharedState: {
|
|
37
39
|
/**
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import type { ColorScheme } from '../showDiffPluginType';
|
|
5
|
+
import type { ColorScheme, ShowDiffPlugin } from '../showDiffPluginType';
|
|
5
6
|
import type { ShowDiffPluginState } from './main';
|
|
6
7
|
import type { NodeViewSerializer } from './NodeViewSerializer';
|
|
7
|
-
export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, }: {
|
|
8
|
+
export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, }: {
|
|
8
9
|
activeIndexPos?: {
|
|
9
10
|
from: number;
|
|
10
11
|
to: number;
|
|
11
12
|
};
|
|
13
|
+
api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
|
|
12
14
|
colorScheme?: ColorScheme;
|
|
13
15
|
intl: IntlShape;
|
|
14
16
|
nodeViewSerializer: NodeViewSerializer;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
7
|
import type { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
7
8
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import { type DiffParams } from '../showDiffPluginType';
|
|
9
|
+
import { type DiffParams, type ShowDiffPlugin } from '../showDiffPluginType';
|
|
9
10
|
export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
|
|
10
11
|
export type ShowDiffPluginState = {
|
|
11
12
|
activeIndex?: number;
|
|
@@ -19,4 +20,4 @@ export type ShowDiffPluginState = {
|
|
|
19
20
|
steps: ProseMirrorStep[];
|
|
20
21
|
};
|
|
21
22
|
export declare const getScrollableDecorations: (set: DecorationSet | undefined) => Decoration[];
|
|
22
|
-
export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape) => SafePlugin<ShowDiffPluginState>;
|
|
23
|
+
export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined) => SafePlugin<ShowDiffPluginState>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StepJson } from '@atlaskit/editor-common/collab';
|
|
2
|
-
import type { NextEditorPlugin, EditorCommand } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { NextEditorPlugin, EditorCommand, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
5
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
6
7
|
export type ColorScheme = 'standard' | 'traditional';
|
|
@@ -32,6 +33,9 @@ export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
|
|
|
32
33
|
scrollToPrevious: EditorCommand;
|
|
33
34
|
showDiff: (config: PMDiffParams) => EditorCommand;
|
|
34
35
|
};
|
|
36
|
+
dependencies: [
|
|
37
|
+
OptionalPlugin<AnalyticsPlugin>
|
|
38
|
+
];
|
|
35
39
|
pluginConfiguration: DiffParams | undefined;
|
|
36
40
|
sharedState: {
|
|
37
41
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.8",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,18 +29,22 @@
|
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^52.2.0",
|
|
32
|
+
"@atlaskit/editor-plugin-analytics": "^7.0.0",
|
|
32
33
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
33
34
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
34
35
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
35
|
-
"@atlaskit/tmp-editor-statsig": "^35.
|
|
36
|
-
"@atlaskit/tokens": "^11.
|
|
36
|
+
"@atlaskit/tmp-editor-statsig": "^35.6.0",
|
|
37
|
+
"@atlaskit/tokens": "^11.1.0",
|
|
37
38
|
"@babel/runtime": "^7.0.0",
|
|
38
39
|
"lodash": "^4.17.21",
|
|
39
40
|
"memoize-one": "^6.0.0",
|
|
40
41
|
"prosemirror-changeset": "^2.3.1"
|
|
41
42
|
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@atlassian/content-reconciliation": "^0.1.3506"
|
|
45
|
+
},
|
|
42
46
|
"peerDependencies": {
|
|
43
|
-
"@atlaskit/editor-common": "^111.
|
|
47
|
+
"@atlaskit/editor-common": "^111.33.0",
|
|
44
48
|
"react": "^18.2.0"
|
|
45
49
|
},
|
|
46
50
|
"techstack": {
|
|
@@ -80,9 +84,6 @@
|
|
|
80
84
|
}
|
|
81
85
|
},
|
|
82
86
|
"platform-feature-flags": {
|
|
83
|
-
"platform_editor_ai_aifc_patch_ga": {
|
|
84
|
-
"type": "boolean"
|
|
85
|
-
},
|
|
86
87
|
"platform_editor_show_diff_scroll_navigation": {
|
|
87
88
|
"type": "boolean"
|
|
88
89
|
},
|