@atlaskit/editor-plugin-show-diff 8.4.5 → 8.4.7
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 +16 -0
- package/dist/cjs/pm-plugins/areDocsEqualByBlockStructureAndText.js +6 -10
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +13 -20
- package/dist/cjs/pm-plugins/calculateDiff/diffBySteps.js +141 -4
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +13 -27
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +12 -34
- package/dist/cjs/pm-plugins/decorations/utils/getAttrChangeRanges.js +30 -32
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +5 -9
- package/dist/cjs/pm-plugins/main.js +13 -18
- package/dist/cjs/showDiffPlugin.js +1 -3
- package/dist/es2019/pm-plugins/areDocsEqualByBlockStructureAndText.js +6 -10
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +13 -20
- package/dist/es2019/pm-plugins/calculateDiff/diffBySteps.js +137 -4
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +15 -27
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +10 -32
- package/dist/es2019/pm-plugins/decorations/utils/getAttrChangeRanges.js +24 -26
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +6 -10
- package/dist/es2019/pm-plugins/main.js +13 -18
- package/dist/es2019/showDiffPlugin.js +1 -3
- package/dist/esm/pm-plugins/areDocsEqualByBlockStructureAndText.js +6 -10
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +13 -20
- package/dist/esm/pm-plugins/calculateDiff/diffBySteps.js +141 -4
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +14 -27
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +12 -34
- package/dist/esm/pm-plugins/decorations/utils/getAttrChangeRanges.js +30 -32
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +6 -10
- package/dist/esm/pm-plugins/main.js +13 -18
- package/dist/esm/showDiffPlugin.js +1 -3
- package/package.json +7 -14
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
2
2
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
3
|
var filterUndefined = function filterUndefined(x) {
|
|
5
4
|
return !!x;
|
|
6
5
|
};
|
|
@@ -36,39 +35,38 @@ export var getAttrChangeRanges = function getAttrChangeRanges(doc, steps) {
|
|
|
36
35
|
var stepAttrs = getStepAttrs(step);
|
|
37
36
|
var $pos = doc.resolve(step.pos);
|
|
38
37
|
var nodeAtPos = doc.nodeAt(step.pos);
|
|
39
|
-
if (expValEquals('platform_editor_show_diff_improvements', 'isEnabled', true)) {
|
|
40
|
-
// date node: timestamp attribute change — highlight the date node itself (inline)
|
|
41
|
-
if (stepAttrs.some(function (v) {
|
|
42
|
-
return dateAttrs.includes(v);
|
|
43
|
-
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date') {
|
|
44
|
-
return {
|
|
45
|
-
fromB: step.pos,
|
|
46
|
-
toB: step.pos + nodeAtPos.nodeSize,
|
|
47
|
-
isInline: true
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
38
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
39
|
+
// date node: timestamp attribute change — highlight the date node itself (inline)
|
|
40
|
+
if (stepAttrs.some(function (v) {
|
|
41
|
+
return dateAttrs.includes(v);
|
|
42
|
+
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date') {
|
|
43
|
+
return {
|
|
44
|
+
fromB: step.pos,
|
|
45
|
+
toB: step.pos + nodeAtPos.nodeSize,
|
|
46
|
+
isInline: true
|
|
47
|
+
};
|
|
48
|
+
}
|
|
60
49
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
50
|
+
// taskItem node: state attribute change — highlight the taskItem node
|
|
51
|
+
if (stepAttrs.some(function (v) {
|
|
52
|
+
return taskItemAttrs.includes(v);
|
|
53
|
+
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'taskItem') {
|
|
54
|
+
return {
|
|
55
|
+
fromB: step.pos,
|
|
56
|
+
toB: step.pos + nodeAtPos.nodeSize
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// extension nodes: any attribute change except localId — highlight the node
|
|
61
|
+
if (nodeAtPos && extensionNodeNames.includes(nodeAtPos.type.name) && stepAttrs.some(function (v) {
|
|
62
|
+
return !extensionExcludedAttrs.includes(v);
|
|
63
|
+
})) {
|
|
64
|
+
var isInline = nodeAtPos.type.name === 'inlineExtension';
|
|
65
|
+
return {
|
|
66
|
+
fromB: step.pos,
|
|
67
|
+
toB: step.pos + nodeAtPos.nodeSize,
|
|
68
|
+
isInline: isInline
|
|
69
|
+
};
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
// media node: id/collection/url attribute change — highlight the mediaSingle parent
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { trackChangesMessages } from '@atlaskit/editor-common/messages';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlock, editingStyle, editingStyleActive, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
|
|
6
|
-
import {
|
|
5
|
+
import { deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
|
|
7
6
|
var lozengeStyle = convertToInlineCss({
|
|
8
7
|
display: 'inline-flex',
|
|
9
8
|
boxSizing: 'border-box',
|
|
@@ -81,10 +80,7 @@ var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
|
|
|
81
80
|
return undefined;
|
|
82
81
|
}
|
|
83
82
|
if (isTraditional) {
|
|
84
|
-
|
|
85
|
-
return isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew;
|
|
86
|
-
}
|
|
87
|
-
return isActive ? traditionalStyleNodeActive : traditionalStyleNode;
|
|
83
|
+
return isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew;
|
|
88
84
|
}
|
|
89
85
|
return editingStyleNode;
|
|
90
86
|
}
|
|
@@ -97,13 +93,13 @@ var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
|
|
|
97
93
|
case 'expand':
|
|
98
94
|
case 'decisionList':
|
|
99
95
|
if (isTraditional) {
|
|
100
|
-
return isActive ? deletedTraditionalBlockOutlineActive :
|
|
96
|
+
return isActive ? deletedTraditionalBlockOutlineActive : deletedTraditionalBlockOutlineNew;
|
|
101
97
|
}
|
|
102
98
|
return isActive ? deletedBlockOutlineActive : deletedBlockOutline;
|
|
103
99
|
case 'panel':
|
|
104
100
|
case 'codeBlock':
|
|
105
101
|
if (isTraditional) {
|
|
106
|
-
return isActive ? deletedTraditionalBlockOutlineRoundedActive :
|
|
102
|
+
return isActive ? deletedTraditionalBlockOutlineRoundedActive : deletedTraditionalBlockOutlineRoundedNew;
|
|
107
103
|
}
|
|
108
104
|
return isActive ? deletedBlockOutlineRoundedActive : deletedBlockOutlineRounded;
|
|
109
105
|
default:
|
|
@@ -146,7 +142,7 @@ var maybeAddDeletedOutlineNewClass = function maybeAddDeletedOutlineNewClass(_re
|
|
|
146
142
|
if (name !== 'mediaSingle' && name !== 'embedCard') {
|
|
147
143
|
return;
|
|
148
144
|
}
|
|
149
|
-
if (colorScheme === 'traditional' && !isActive
|
|
145
|
+
if (colorScheme === 'traditional' && !isActive) {
|
|
150
146
|
nodeView.classList.add('show-diff-deleted-outline-new');
|
|
151
147
|
}
|
|
152
148
|
};
|
|
@@ -170,7 +166,7 @@ var applyCellOverlayStyles = function applyCellOverlayStyles(_ref2) {
|
|
|
170
166
|
isInserted = _ref2.isInserted;
|
|
171
167
|
element.querySelectorAll('td, th').forEach(function (cell) {
|
|
172
168
|
var overlay = document.createElement('span');
|
|
173
|
-
var overlayStyle = colorScheme === 'traditional' ? isInserted ?
|
|
169
|
+
var overlayStyle = colorScheme === 'traditional' ? isInserted ? traditionalAddedCellOverlayStyleNew : deletedTraditionalCellOverlayStyle : isInserted ? addedCellOverlayStyle : deletedCellOverlayStyle;
|
|
174
170
|
overlay.setAttribute('style', overlayStyle);
|
|
175
171
|
cell.appendChild(overlay);
|
|
176
172
|
});
|
|
@@ -6,7 +6,6 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
6
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
8
8
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
10
|
import { calculateDiffDecorations } from './calculateDiff/calculateDiffDecorations';
|
|
12
11
|
import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
|
|
@@ -15,9 +14,7 @@ import { NodeViewSerializer } from './NodeViewSerializer';
|
|
|
15
14
|
import { scrollToActiveDecoration, scrollToFirstDecoration } from './scrollToDiff';
|
|
16
15
|
export var showDiffPluginKey = new PluginKey('showDiffPlugin');
|
|
17
16
|
export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
18
|
-
|
|
19
|
-
enforceCustomStepRegisters();
|
|
20
|
-
}
|
|
17
|
+
enforceCustomStepRegisters();
|
|
21
18
|
var nodeViewSerializer = new NodeViewSerializer({});
|
|
22
19
|
var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
|
|
23
20
|
nodeViewSerializer.init({
|
|
@@ -58,7 +55,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
58
55
|
nodeViewSerializer: nodeViewSerializer,
|
|
59
56
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
60
57
|
intl: getIntl(),
|
|
61
|
-
activeIndexPos:
|
|
58
|
+
activeIndexPos: newPluginState.activeIndexPos,
|
|
62
59
|
api: api
|
|
63
60
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
64
61
|
isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted,
|
|
@@ -77,7 +74,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
77
74
|
diffType: 'inline',
|
|
78
75
|
hideDeletedDiffs: false
|
|
79
76
|
} : {});
|
|
80
|
-
} else if ((
|
|
77
|
+
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') {
|
|
81
78
|
// Update the active index in plugin state and recalculate decorations
|
|
82
79
|
var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc);
|
|
83
80
|
if (_decorations.length > 0) {
|
|
@@ -163,19 +160,17 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
163
160
|
}
|
|
164
161
|
|
|
165
162
|
// Check for any potential scroll side-effects
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
api === null || api === void 0 || api.core.actions.execute(api.expand.commands.toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
|
|
176
|
-
}
|
|
177
|
-
cancelPendingScrollToDecoration = scrollToActiveDecoration(view, scrollableDecorations, pluginState.activeIndex);
|
|
163
|
+
var activeIndexChanged = (pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && pluginState.activeIndex !== previousActiveIndex;
|
|
164
|
+
previousActiveIndex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex;
|
|
165
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
|
|
166
|
+
var _cancelPendingScrollT2, _api$expand;
|
|
167
|
+
(_cancelPendingScrollT2 = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT2 === void 0 || _cancelPendingScrollT2();
|
|
168
|
+
var scrollableDecorations = getScrollableDecorations(pluginState.decorations, view.state.doc);
|
|
169
|
+
var activeDecoration = scrollableDecorations[pluginState.activeIndex];
|
|
170
|
+
if (activeDecoration && api !== null && api !== void 0 && (_api$expand = api.expand) !== null && _api$expand !== void 0 && (_api$expand = _api$expand.commands) !== null && _api$expand !== void 0 && _api$expand.toggleExpandRange) {
|
|
171
|
+
api === null || api === void 0 || api.core.actions.execute(api.expand.commands.toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
|
|
178
172
|
}
|
|
173
|
+
cancelPendingScrollToDecoration = scrollToActiveDecoration(view, scrollableDecorations, pluginState.activeIndex);
|
|
179
174
|
}
|
|
180
175
|
},
|
|
181
176
|
destroy: function destroy() {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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) { _defineProperty(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; }
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { getScrollableDecorations } from './pm-plugins/getScrollableDecorations';
|
|
6
5
|
import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
|
|
7
6
|
export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
@@ -48,7 +47,6 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
48
47
|
}];
|
|
49
48
|
},
|
|
50
49
|
getSharedState: function getSharedState(editorState) {
|
|
51
|
-
var _pluginState$decorati;
|
|
52
50
|
if (!editorState) {
|
|
53
51
|
return {
|
|
54
52
|
isDisplayingChanges: false,
|
|
@@ -56,7 +54,7 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
56
54
|
};
|
|
57
55
|
}
|
|
58
56
|
var pluginState = showDiffPluginKey.getState(editorState);
|
|
59
|
-
var decorationCount =
|
|
57
|
+
var decorationCount = getScrollableDecorations(pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations, editorState.doc);
|
|
60
58
|
return {
|
|
61
59
|
isDisplayingChanges: decorationCount.length > 0,
|
|
62
60
|
activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.7",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/adf-schema": "^52.
|
|
31
|
+
"@atlaskit/adf-schema": "^52.15.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.17.0",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^10.1.0",
|
|
34
34
|
"@atlaskit/editor-plugin-expand": "^11.2.0",
|
|
35
35
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
36
36
|
"@atlaskit/editor-tables": "^2.10.0",
|
|
37
37
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
38
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
38
|
+
"@atlaskit/tmp-editor-statsig": "^84.3.0",
|
|
39
39
|
"@atlaskit/tokens": "^13.0.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"prosemirror-changeset": "^2.3.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@atlaskit/adf-utils": "^19.
|
|
46
|
+
"@atlaskit/adf-utils": "^19.32.0",
|
|
47
47
|
"@atlaskit/button": "^23.11.0",
|
|
48
48
|
"@atlaskit/css": "^0.19.0",
|
|
49
49
|
"@atlaskit/editor-core": "^219.9.0",
|
|
50
|
-
"@atlaskit/editor-json-transformer": "^8.
|
|
50
|
+
"@atlaskit/editor-json-transformer": "^8.33.0",
|
|
51
51
|
"@atlaskit/form": "^15.5.0",
|
|
52
52
|
"@atlaskit/primitives": "^19.0.0",
|
|
53
53
|
"@atlaskit/section-message": "^8.13.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react-intl": "^6.6.2"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@atlaskit/editor-common": "^114.
|
|
62
|
+
"@atlaskit/editor-common": "^114.49.0",
|
|
63
63
|
"react": "^18.2.0"
|
|
64
64
|
},
|
|
65
65
|
"techstack": {
|
|
@@ -98,12 +98,5 @@
|
|
|
98
98
|
]
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
|
-
"platform-feature-flags": {
|
|
102
|
-
"platform_editor_show_diff_equality_fallback": {
|
|
103
|
-
"type": "boolean"
|
|
104
|
-
},
|
|
105
|
-
"platform_editor_show_diff_scroll_navigation": {
|
|
106
|
-
"type": "boolean"
|
|
107
|
-
}
|
|
108
|
-
}
|
|
101
|
+
"platform-feature-flags": {}
|
|
109
102
|
}
|