@atlaskit/editor-plugin-show-diff 6.0.2 → 6.1.1
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/dist/cjs/pm-plugins/calculateDiffDecorations.js +37 -16
- package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +23 -1
- package/dist/cjs/pm-plugins/decorations/colorSchemes/traditional.js +23 -1
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +60 -8
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +19 -4
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +24 -4
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +92 -21
- package/dist/cjs/pm-plugins/decorations/utils/getMarkChangeRanges.js +0 -15
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +87 -45
- package/dist/cjs/pm-plugins/main.js +17 -7
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +35 -13
- package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +22 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/traditional.js +22 -0
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +59 -8
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +20 -6
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +25 -6
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +84 -16
- package/dist/es2019/pm-plugins/decorations/utils/getMarkChangeRanges.js +0 -13
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +58 -19
- package/dist/es2019/pm-plugins/main.js +22 -4
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +37 -16
- package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +22 -0
- package/dist/esm/pm-plugins/decorations/colorSchemes/traditional.js +22 -0
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +62 -10
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +21 -6
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +26 -6
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +93 -23
- package/dist/esm/pm-plugins/decorations/utils/getMarkChangeRanges.js +0 -15
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +89 -47
- package/dist/esm/pm-plugins/main.js +17 -7
- package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +2 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/traditional.d.ts +2 -0
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +6 -1
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
- package/dist/types/pm-plugins/main.d.ts +1 -0
- package/dist/types/showDiffPluginType.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +6 -1
- package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
- package/dist/types-ts4.5/showDiffPluginType.d.ts +1 -0
- package/package.json +5 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { trackChangesMessages } from '@atlaskit/editor-common/messages';
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
|
-
import { deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedStyleQuoteNodeWithLozenge } from '../colorSchemes/standard';
|
|
5
|
-
import { deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle, deletedTraditionalStyleQuoteNode } from '../colorSchemes/traditional';
|
|
4
|
+
import { deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedStyleQuoteNodeWithLozenge, editingStyle, editingStyleActive, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
|
|
5
|
+
import { deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle, deletedTraditionalStyleQuoteNode, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
|
|
6
6
|
var lozengeStyle = convertToInlineCss({
|
|
7
7
|
display: 'inline-flex',
|
|
8
8
|
boxSizing: 'border-box',
|
|
@@ -19,8 +19,15 @@ var lozengeStyle = convertToInlineCss({
|
|
|
19
19
|
whiteSpace: 'nowrap',
|
|
20
20
|
color: "var(--ds-text-warning-inverse, #292A2E)"
|
|
21
21
|
});
|
|
22
|
-
var
|
|
22
|
+
var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
|
|
23
23
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
24
|
+
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
25
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted) {
|
|
26
|
+
if (colorScheme === 'traditional') {
|
|
27
|
+
return isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
28
|
+
}
|
|
29
|
+
return isActive ? editingStyleActive : editingStyle;
|
|
30
|
+
}
|
|
24
31
|
if (colorScheme === 'traditional') {
|
|
25
32
|
return deletedTraditionalContentStyle;
|
|
26
33
|
}
|
|
@@ -29,8 +36,18 @@ var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
|
29
36
|
}
|
|
30
37
|
return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
|
|
31
38
|
};
|
|
32
|
-
var
|
|
39
|
+
var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
|
|
40
|
+
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
33
41
|
var isTraditional = colorScheme === 'traditional';
|
|
42
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted) {
|
|
43
|
+
if (shouldApplyStylesDirectly(nodeName)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
if (isTraditional) {
|
|
47
|
+
return traditionalStyleNode;
|
|
48
|
+
}
|
|
49
|
+
return editingStyleNode;
|
|
50
|
+
}
|
|
34
51
|
switch (nodeName) {
|
|
35
52
|
case 'blockquote':
|
|
36
53
|
return isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge;
|
|
@@ -51,7 +68,6 @@ var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
|
|
|
51
68
|
case 'mediaSingle':
|
|
52
69
|
case 'panel':
|
|
53
70
|
case 'decisionList':
|
|
54
|
-
return true;
|
|
55
71
|
case 'embedCard':
|
|
56
72
|
case 'blockquote':
|
|
57
73
|
return true;
|
|
@@ -63,7 +79,6 @@ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeCla
|
|
|
63
79
|
switch (nodeName) {
|
|
64
80
|
case 'mediaSingle':
|
|
65
81
|
case 'embedCard':
|
|
66
|
-
return true;
|
|
67
82
|
case 'blockquote':
|
|
68
83
|
return true;
|
|
69
84
|
default:
|
|
@@ -78,6 +93,17 @@ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeCla
|
|
|
78
93
|
var shouldApplyStylesDirectly = function shouldApplyStylesDirectly(nodeName) {
|
|
79
94
|
return nodeName === 'heading';
|
|
80
95
|
};
|
|
96
|
+
var applyCellOverlayStyles = function applyCellOverlayStyles(_ref) {
|
|
97
|
+
var element = _ref.element,
|
|
98
|
+
colorScheme = _ref.colorScheme,
|
|
99
|
+
isInserted = _ref.isInserted;
|
|
100
|
+
element.querySelectorAll('td, th').forEach(function (cell) {
|
|
101
|
+
var overlay = document.createElement('span');
|
|
102
|
+
var overlayStyle = colorScheme === 'traditional' ? isInserted ? traditionalAddedCellOverlayStyle : deletedTraditionalCellOverlayStyle : isInserted ? addedCellOverlayStyle : deletedCellOverlayStyle;
|
|
103
|
+
overlay.setAttribute('style', overlayStyle);
|
|
104
|
+
cell.appendChild(overlay);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
81
107
|
|
|
82
108
|
/**
|
|
83
109
|
* Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
|
|
@@ -120,26 +146,28 @@ var createBlockNodeWrapper = function createBlockNodeWrapper() {
|
|
|
120
146
|
/**
|
|
121
147
|
* Applies styles directly to an HTML element by merging with existing styles
|
|
122
148
|
*/
|
|
123
|
-
var applyStylesToElement = function applyStylesToElement(
|
|
124
|
-
var element =
|
|
125
|
-
targetNode =
|
|
126
|
-
colorScheme =
|
|
149
|
+
var applyStylesToElement = function applyStylesToElement(_ref2) {
|
|
150
|
+
var element = _ref2.element,
|
|
151
|
+
targetNode = _ref2.targetNode,
|
|
152
|
+
colorScheme = _ref2.colorScheme,
|
|
153
|
+
isInserted = _ref2.isInserted;
|
|
127
154
|
var currentStyle = element.getAttribute('style') || '';
|
|
128
|
-
var
|
|
129
|
-
var nodeSpecificStyle =
|
|
130
|
-
element.setAttribute('style', "".concat(currentStyle).concat(
|
|
155
|
+
var contentStyle = getChangedContentStyle(colorScheme, false, isInserted);
|
|
156
|
+
var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted) || '';
|
|
157
|
+
element.setAttribute('style', "".concat(currentStyle).concat(contentStyle).concat(nodeSpecificStyle));
|
|
131
158
|
};
|
|
132
159
|
|
|
133
160
|
/**
|
|
134
161
|
* Creates a content wrapper with deleted styles for a block node
|
|
135
162
|
*/
|
|
136
|
-
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(
|
|
137
|
-
var nodeView =
|
|
138
|
-
targetNode =
|
|
139
|
-
colorScheme =
|
|
163
|
+
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref3) {
|
|
164
|
+
var nodeView = _ref3.nodeView,
|
|
165
|
+
targetNode = _ref3.targetNode,
|
|
166
|
+
colorScheme = _ref3.colorScheme,
|
|
167
|
+
isInserted = _ref3.isInserted;
|
|
140
168
|
var contentWrapper = document.createElement('div');
|
|
141
|
-
var nodeStyle =
|
|
142
|
-
contentWrapper.setAttribute('style', "".concat(
|
|
169
|
+
var nodeStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted);
|
|
170
|
+
contentWrapper.setAttribute('style', "".concat(getChangedContentStyle(colorScheme, false, isInserted)).concat(nodeStyle || ''));
|
|
143
171
|
contentWrapper.append(nodeView);
|
|
144
172
|
return contentWrapper;
|
|
145
173
|
};
|
|
@@ -150,12 +178,12 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref2
|
|
|
150
178
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
151
179
|
* @returns true if embedCard was handled
|
|
152
180
|
*/
|
|
153
|
-
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(
|
|
154
|
-
var dom =
|
|
155
|
-
nodeView =
|
|
156
|
-
targetNode =
|
|
157
|
-
lozenge =
|
|
158
|
-
colorScheme =
|
|
181
|
+
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref4) {
|
|
182
|
+
var dom = _ref4.dom,
|
|
183
|
+
nodeView = _ref4.nodeView,
|
|
184
|
+
targetNode = _ref4.targetNode,
|
|
185
|
+
lozenge = _ref4.lozenge,
|
|
186
|
+
colorScheme = _ref4.colorScheme;
|
|
159
187
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
160
188
|
return false;
|
|
161
189
|
}
|
|
@@ -187,12 +215,12 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref3) {
|
|
|
187
215
|
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
188
216
|
* @returns true if mediaSingle was handled, false otherwise
|
|
189
217
|
*/
|
|
190
|
-
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
|
|
191
|
-
var dom =
|
|
192
|
-
nodeView =
|
|
193
|
-
targetNode =
|
|
194
|
-
lozenge =
|
|
195
|
-
colorScheme =
|
|
218
|
+
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref5) {
|
|
219
|
+
var dom = _ref5.dom,
|
|
220
|
+
nodeView = _ref5.nodeView,
|
|
221
|
+
targetNode = _ref5.targetNode,
|
|
222
|
+
lozenge = _ref5.lozenge,
|
|
223
|
+
colorScheme = _ref5.colorScheme;
|
|
196
224
|
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
197
225
|
return false;
|
|
198
226
|
}
|
|
@@ -221,14 +249,16 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref4)
|
|
|
221
249
|
/**
|
|
222
250
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
223
251
|
*/
|
|
224
|
-
var wrapBlockNode = function wrapBlockNode(
|
|
225
|
-
var dom =
|
|
226
|
-
nodeView =
|
|
227
|
-
targetNode =
|
|
228
|
-
colorScheme =
|
|
229
|
-
intl =
|
|
252
|
+
var wrapBlockNode = function wrapBlockNode(_ref6) {
|
|
253
|
+
var dom = _ref6.dom,
|
|
254
|
+
nodeView = _ref6.nodeView,
|
|
255
|
+
targetNode = _ref6.targetNode,
|
|
256
|
+
colorScheme = _ref6.colorScheme,
|
|
257
|
+
intl = _ref6.intl,
|
|
258
|
+
_ref6$isInserted = _ref6.isInserted,
|
|
259
|
+
isInserted = _ref6$isInserted === void 0 ? false : _ref6$isInserted;
|
|
230
260
|
var blockWrapper = createBlockNodeWrapper();
|
|
231
|
-
if (shouldShowRemovedLozenge(targetNode.type.name)) {
|
|
261
|
+
if (shouldShowRemovedLozenge(targetNode.type.name) && (!expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || !isInserted)) {
|
|
232
262
|
var lozenge = createRemovedLozenge(intl);
|
|
233
263
|
if (handleEmbedCardWithLozenge({
|
|
234
264
|
dom: dom,
|
|
@@ -253,7 +283,8 @@ var wrapBlockNode = function wrapBlockNode(_ref5) {
|
|
|
253
283
|
var contentWrapper = createBlockNodeContentWrapper({
|
|
254
284
|
nodeView: nodeView,
|
|
255
285
|
targetNode: targetNode,
|
|
256
|
-
colorScheme: colorScheme
|
|
286
|
+
colorScheme: colorScheme,
|
|
287
|
+
isInserted: isInserted
|
|
257
288
|
});
|
|
258
289
|
blockWrapper.append(contentWrapper);
|
|
259
290
|
if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
@@ -268,18 +299,28 @@ var wrapBlockNode = function wrapBlockNode(_ref5) {
|
|
|
268
299
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
269
300
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
270
301
|
*/
|
|
271
|
-
export var wrapBlockNodeView = function wrapBlockNodeView(
|
|
272
|
-
var dom =
|
|
273
|
-
nodeView =
|
|
274
|
-
targetNode =
|
|
275
|
-
colorScheme =
|
|
276
|
-
intl =
|
|
302
|
+
export var wrapBlockNodeView = function wrapBlockNodeView(_ref7) {
|
|
303
|
+
var dom = _ref7.dom,
|
|
304
|
+
nodeView = _ref7.nodeView,
|
|
305
|
+
targetNode = _ref7.targetNode,
|
|
306
|
+
colorScheme = _ref7.colorScheme,
|
|
307
|
+
intl = _ref7.intl,
|
|
308
|
+
_ref7$isInserted = _ref7.isInserted,
|
|
309
|
+
isInserted = _ref7$isInserted === void 0 ? false : _ref7$isInserted;
|
|
277
310
|
if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
|
|
278
311
|
// Apply deleted styles directly to preserve natural block-level margins
|
|
279
312
|
applyStylesToElement({
|
|
280
313
|
element: nodeView,
|
|
281
314
|
targetNode: targetNode,
|
|
282
|
-
colorScheme: colorScheme
|
|
315
|
+
colorScheme: colorScheme,
|
|
316
|
+
isInserted: isInserted
|
|
317
|
+
});
|
|
318
|
+
dom.append(nodeView);
|
|
319
|
+
} else if (targetNode.type.name === 'table' && nodeView instanceof HTMLElement && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
320
|
+
applyCellOverlayStyles({
|
|
321
|
+
element: nodeView,
|
|
322
|
+
colorScheme: colorScheme,
|
|
323
|
+
isInserted: isInserted
|
|
283
324
|
});
|
|
284
325
|
dom.append(nodeView);
|
|
285
326
|
} else {
|
|
@@ -289,7 +330,8 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref6) {
|
|
|
289
330
|
nodeView: nodeView,
|
|
290
331
|
targetNode: targetNode,
|
|
291
332
|
colorScheme: colorScheme,
|
|
292
|
-
intl: intl
|
|
333
|
+
intl: intl,
|
|
334
|
+
isInserted: isInserted
|
|
293
335
|
});
|
|
294
336
|
}
|
|
295
337
|
};
|
|
@@ -7,6 +7,7 @@ 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
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
11
|
import { calculateDiffDecorations } from './calculateDiffDecorations';
|
|
11
12
|
import { NodeViewSerializer } from './NodeViewSerializer';
|
|
12
13
|
import { scrollToActiveDecoration } from './scrollToActiveDecoration';
|
|
@@ -29,25 +30,28 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
29
30
|
state: {
|
|
30
31
|
init: function init(_, _state) {
|
|
31
32
|
// We do initial setup after we setup the editor view
|
|
32
|
-
return {
|
|
33
|
+
return _objectSpread({
|
|
33
34
|
steps: [],
|
|
34
35
|
originalDoc: undefined,
|
|
35
36
|
decorations: DecorationSet.empty,
|
|
36
37
|
isDisplayingChanges: false
|
|
37
|
-
}
|
|
38
|
+
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
39
|
+
isInverted: false
|
|
40
|
+
} : {});
|
|
38
41
|
},
|
|
39
42
|
apply: function apply(tr, currentPluginState, oldState, newState) {
|
|
40
43
|
var meta = tr.getMeta(showDiffPluginKey);
|
|
41
44
|
var newPluginState = currentPluginState;
|
|
42
45
|
if (meta) {
|
|
43
46
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
|
|
47
|
+
var _newPluginState;
|
|
44
48
|
// Update the plugin state with the new metadata
|
|
45
49
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
46
50
|
isDisplayingChanges: true,
|
|
47
51
|
activeIndex: undefined
|
|
48
52
|
});
|
|
49
53
|
// Calculate and store decorations in state
|
|
50
|
-
var decorations = calculateDiffDecorations({
|
|
54
|
+
var decorations = calculateDiffDecorations(_objectSpread({
|
|
51
55
|
state: newState,
|
|
52
56
|
pluginState: newPluginState,
|
|
53
57
|
nodeViewSerializer: nodeViewSerializer,
|
|
@@ -55,7 +59,9 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
55
59
|
intl: getIntl(),
|
|
56
60
|
activeIndexPos: fg('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined,
|
|
57
61
|
api: api
|
|
58
|
-
})
|
|
62
|
+
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
63
|
+
isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted
|
|
64
|
+
} : {}));
|
|
59
65
|
// Update the decorations
|
|
60
66
|
newPluginState.decorations = decorations;
|
|
61
67
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
|
|
@@ -63,7 +69,9 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
63
69
|
decorations: DecorationSet.empty,
|
|
64
70
|
isDisplayingChanges: false,
|
|
65
71
|
activeIndex: undefined
|
|
66
|
-
})
|
|
72
|
+
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
73
|
+
isInverted: false
|
|
74
|
+
} : {});
|
|
67
75
|
} 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') && fg('platform_editor_show_diff_scroll_navigation')) {
|
|
68
76
|
// Update the active index in plugin state and recalculate decorations
|
|
69
77
|
var _decorations = getScrollableDecorations(currentPluginState.decorations);
|
|
@@ -92,7 +100,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
92
100
|
} : undefined
|
|
93
101
|
});
|
|
94
102
|
// Recalculate decorations with the new active index
|
|
95
|
-
var updatedDecorations = calculateDiffDecorations({
|
|
103
|
+
var updatedDecorations = calculateDiffDecorations(_objectSpread({
|
|
96
104
|
state: newState,
|
|
97
105
|
pluginState: newPluginState,
|
|
98
106
|
nodeViewSerializer: nodeViewSerializer,
|
|
@@ -100,7 +108,9 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
100
108
|
intl: getIntl(),
|
|
101
109
|
activeIndexPos: newPluginState.activeIndexPos,
|
|
102
110
|
api: api
|
|
103
|
-
})
|
|
111
|
+
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
112
|
+
isInverted: newPluginState.isInverted
|
|
113
|
+
} : {}));
|
|
104
114
|
newPluginState.decorations = updatedDecorations;
|
|
105
115
|
}
|
|
106
116
|
} else {
|
|
@@ -15,3 +15,5 @@ export declare const editingStyleRuleNode: string;
|
|
|
15
15
|
export declare const editingStyleNode: string;
|
|
16
16
|
export declare const editingStyleCardBlockNode: string;
|
|
17
17
|
export declare const standardDecorationMarkerVariable: string;
|
|
18
|
+
export declare const addedCellOverlayStyle: string;
|
|
19
|
+
export declare const deletedCellOverlayStyle: string;
|
|
@@ -11,3 +11,5 @@ export declare const traditionalStyleRuleNode: string;
|
|
|
11
11
|
export declare const traditionalStyleNode: string;
|
|
12
12
|
export declare const traditionalStyleCardBlockNode: string;
|
|
13
13
|
export declare const traditionalDecorationMarkerVariable: string;
|
|
14
|
+
export declare const traditionalAddedCellOverlayStyle: string;
|
|
15
|
+
export declare const deletedTraditionalCellOverlayStyle: string;
|
|
@@ -6,11 +6,12 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
6
6
|
* @param change Changeset "change" containing information about the change content + range
|
|
7
7
|
* @returns Prosemirror inline decoration
|
|
8
8
|
*/
|
|
9
|
-
export declare const createBlockChangedDecoration: ({ change, colorScheme, }: {
|
|
9
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, }: {
|
|
10
10
|
change: {
|
|
11
11
|
from: number;
|
|
12
12
|
name: string;
|
|
13
13
|
to: number;
|
|
14
14
|
};
|
|
15
15
|
colorScheme?: ColorScheme;
|
|
16
|
+
isInserted: boolean;
|
|
16
17
|
}) => Decoration | undefined;
|
|
@@ -7,9 +7,10 @@ type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
|
|
|
7
7
|
/**
|
|
8
8
|
* Main function to handle deleted rows - computes diff and creates decorations
|
|
9
9
|
*/
|
|
10
|
-
export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: {
|
|
10
|
+
export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, isInserted, }: {
|
|
11
11
|
changes: SimpleChange[];
|
|
12
12
|
colorScheme?: ColorScheme;
|
|
13
|
+
isInserted?: boolean;
|
|
13
14
|
newDoc: PMNode;
|
|
14
15
|
nodeViewSerializer: NodeViewSerializer;
|
|
15
16
|
originalDoc: PMNode;
|
|
@@ -6,11 +6,12 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
6
6
|
* @param change Changeset "change" containing information about the change content + range
|
|
7
7
|
* @returns Prosemirror inline decoration
|
|
8
8
|
*/
|
|
9
|
-
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, }: {
|
|
9
|
+
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, }: {
|
|
10
10
|
change: {
|
|
11
11
|
fromB: number;
|
|
12
12
|
toB: number;
|
|
13
13
|
};
|
|
14
14
|
colorScheme?: ColorScheme;
|
|
15
15
|
isActive?: boolean;
|
|
16
|
+
isInserted?: boolean;
|
|
16
17
|
}) => Decoration;
|
|
@@ -4,12 +4,17 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { ColorScheme } from '../../showDiffPluginType';
|
|
6
6
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* This function is used to create a decoration widget to show content
|
|
9
|
+
* that is not in the current document.
|
|
10
|
+
*/
|
|
11
|
+
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, isInserted, }: {
|
|
8
12
|
change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted">;
|
|
9
13
|
colorScheme?: ColorScheme;
|
|
10
14
|
doc: PMNode;
|
|
11
15
|
intl: IntlShape;
|
|
12
16
|
isActive?: boolean;
|
|
17
|
+
isInserted?: boolean;
|
|
13
18
|
newDoc: PMNode;
|
|
14
19
|
nodeViewSerializer: NodeViewSerializer;
|
|
15
20
|
}) => Decoration[] | undefined;
|
|
@@ -6,10 +6,11 @@ import type { ColorScheme } from '../../../showDiffPluginType';
|
|
|
6
6
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
7
7
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
8
8
|
*/
|
|
9
|
-
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, }: {
|
|
9
|
+
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isInserted, }: {
|
|
10
10
|
colorScheme?: ColorScheme;
|
|
11
11
|
dom: HTMLElement;
|
|
12
12
|
intl: IntlShape;
|
|
13
|
+
isInserted: boolean;
|
|
13
14
|
nodeView: Node;
|
|
14
15
|
targetNode: PMNode;
|
|
15
16
|
}) => void;
|
|
@@ -15,3 +15,5 @@ export declare const editingStyleRuleNode: string;
|
|
|
15
15
|
export declare const editingStyleNode: string;
|
|
16
16
|
export declare const editingStyleCardBlockNode: string;
|
|
17
17
|
export declare const standardDecorationMarkerVariable: string;
|
|
18
|
+
export declare const addedCellOverlayStyle: string;
|
|
19
|
+
export declare const deletedCellOverlayStyle: string;
|
|
@@ -11,3 +11,5 @@ export declare const traditionalStyleRuleNode: string;
|
|
|
11
11
|
export declare const traditionalStyleNode: string;
|
|
12
12
|
export declare const traditionalStyleCardBlockNode: string;
|
|
13
13
|
export declare const traditionalDecorationMarkerVariable: string;
|
|
14
|
+
export declare const traditionalAddedCellOverlayStyle: string;
|
|
15
|
+
export declare const deletedTraditionalCellOverlayStyle: string;
|
|
@@ -6,11 +6,12 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
6
6
|
* @param change Changeset "change" containing information about the change content + range
|
|
7
7
|
* @returns Prosemirror inline decoration
|
|
8
8
|
*/
|
|
9
|
-
export declare const createBlockChangedDecoration: ({ change, colorScheme, }: {
|
|
9
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, }: {
|
|
10
10
|
change: {
|
|
11
11
|
from: number;
|
|
12
12
|
name: string;
|
|
13
13
|
to: number;
|
|
14
14
|
};
|
|
15
15
|
colorScheme?: ColorScheme;
|
|
16
|
+
isInserted: boolean;
|
|
16
17
|
}) => Decoration | undefined;
|
|
@@ -7,9 +7,10 @@ type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
|
|
|
7
7
|
/**
|
|
8
8
|
* Main function to handle deleted rows - computes diff and creates decorations
|
|
9
9
|
*/
|
|
10
|
-
export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: {
|
|
10
|
+
export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, isInserted, }: {
|
|
11
11
|
changes: SimpleChange[];
|
|
12
12
|
colorScheme?: ColorScheme;
|
|
13
|
+
isInserted?: boolean;
|
|
13
14
|
newDoc: PMNode;
|
|
14
15
|
nodeViewSerializer: NodeViewSerializer;
|
|
15
16
|
originalDoc: PMNode;
|
|
@@ -6,11 +6,12 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
6
6
|
* @param change Changeset "change" containing information about the change content + range
|
|
7
7
|
* @returns Prosemirror inline decoration
|
|
8
8
|
*/
|
|
9
|
-
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, }: {
|
|
9
|
+
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, }: {
|
|
10
10
|
change: {
|
|
11
11
|
fromB: number;
|
|
12
12
|
toB: number;
|
|
13
13
|
};
|
|
14
14
|
colorScheme?: ColorScheme;
|
|
15
15
|
isActive?: boolean;
|
|
16
|
+
isInserted?: boolean;
|
|
16
17
|
}) => Decoration;
|
|
@@ -4,12 +4,17 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { ColorScheme } from '../../showDiffPluginType';
|
|
6
6
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* This function is used to create a decoration widget to show content
|
|
9
|
+
* that is not in the current document.
|
|
10
|
+
*/
|
|
11
|
+
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, isInserted, }: {
|
|
8
12
|
change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted">;
|
|
9
13
|
colorScheme?: ColorScheme;
|
|
10
14
|
doc: PMNode;
|
|
11
15
|
intl: IntlShape;
|
|
12
16
|
isActive?: boolean;
|
|
17
|
+
isInserted?: boolean;
|
|
13
18
|
newDoc: PMNode;
|
|
14
19
|
nodeViewSerializer: NodeViewSerializer;
|
|
15
20
|
}) => Decoration[] | undefined;
|
|
@@ -6,10 +6,11 @@ import type { ColorScheme } from '../../../showDiffPluginType';
|
|
|
6
6
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
7
7
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
8
8
|
*/
|
|
9
|
-
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, }: {
|
|
9
|
+
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isInserted, }: {
|
|
10
10
|
colorScheme?: ColorScheme;
|
|
11
11
|
dom: HTMLElement;
|
|
12
12
|
intl: IntlShape;
|
|
13
|
+
isInserted: boolean;
|
|
13
14
|
nodeView: Node;
|
|
14
15
|
targetNode: PMNode;
|
|
15
16
|
}) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/adf-schema": "^52.
|
|
31
|
+
"@atlaskit/adf-schema": "^52.3.0",
|
|
32
32
|
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
33
33
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
34
34
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
35
35
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
36
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
36
|
+
"@atlaskit/tmp-editor-statsig": "^39.0.0",
|
|
37
37
|
"@atlaskit/tokens": "^11.1.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
@@ -41,10 +41,11 @@
|
|
|
41
41
|
"prosemirror-changeset": "^2.3.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@atlaskit/adf-utils": "^19.27.0",
|
|
44
45
|
"@atlassian/content-reconciliation": "^0.1.3506"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@atlaskit/editor-common": "^112.
|
|
48
|
+
"@atlaskit/editor-common": "^112.3.0",
|
|
48
49
|
"react": "^18.2.0"
|
|
49
50
|
},
|
|
50
51
|
"techstack": {
|