@atlaskit/editor-plugin-show-diff 6.3.2 → 6.4.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 +19 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +38 -24
- package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +7 -1
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +21 -6
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +14 -1
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +7 -2
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +159 -62
- package/dist/cjs/pm-plugins/main.js +10 -5
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +37 -25
- package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +6 -0
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +20 -6
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +13 -2
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +4 -1
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +120 -21
- package/dist/es2019/pm-plugins/main.js +10 -5
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +38 -24
- package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +6 -0
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +21 -6
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +14 -2
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +7 -2
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +160 -63
- package/dist/esm/pm-plugins/main.js +10 -5
- package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +1 -0
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.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/calculateDiff/calculateDiffDecorations.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.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 +4 -4
|
@@ -4,6 +4,9 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
4
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
5
|
import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
6
6
|
import { traditionalDecorationMarkerVariable, traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariable, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNode, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNode, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNode, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNode, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
|
|
7
|
+
var displayNoneStyle = convertToInlineCss({
|
|
8
|
+
display: 'none'
|
|
9
|
+
});
|
|
7
10
|
var getNodeClass = function getNodeClass(name) {
|
|
8
11
|
switch (name) {
|
|
9
12
|
case 'extension':
|
|
@@ -102,8 +105,19 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
102
105
|
_ref2$isInserted = _ref2.isInserted,
|
|
103
106
|
isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
|
|
104
107
|
_ref2$isActive = _ref2.isActive,
|
|
105
|
-
isActive = _ref2$isActive === void 0 ? false : _ref2$isActive
|
|
108
|
+
isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
|
|
109
|
+
_ref2$shouldHideDelet = _ref2.shouldHideDeleted,
|
|
110
|
+
shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet;
|
|
106
111
|
var decorations = [];
|
|
112
|
+
if (shouldHideDeleted) {
|
|
113
|
+
return [Decoration.node(change.from, change.to, {
|
|
114
|
+
style: displayNoneStyle
|
|
115
|
+
}, {
|
|
116
|
+
key: 'diff-block',
|
|
117
|
+
nodeName: change.name
|
|
118
|
+
})];
|
|
119
|
+
}
|
|
120
|
+
var style;
|
|
107
121
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && ['tableCell', 'tableHeader'].includes(change.name)) {
|
|
108
122
|
var cellOverlay = document.createElement('div');
|
|
109
123
|
var cellOverlayStyle = isInserted ? colorScheme === 'traditional' ? traditionalAddedCellOverlayStyle : addedCellOverlayStyle : colorScheme === 'traditional' ? deletedTraditionalCellOverlayStyle : deletedCellOverlayStyle;
|
|
@@ -114,11 +128,6 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
114
128
|
key: "diff-widget-cell-overlay-".concat(change.to)
|
|
115
129
|
}));
|
|
116
130
|
}
|
|
117
|
-
var style = getBlockNodeStyle({
|
|
118
|
-
nodeName: change.name,
|
|
119
|
-
colorScheme: colorScheme,
|
|
120
|
-
isActive: isActive
|
|
121
|
-
});
|
|
122
131
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
123
132
|
style = getBlockNodeStyle({
|
|
124
133
|
nodeName: change.name,
|
|
@@ -126,6 +135,12 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
126
135
|
isInserted: isInserted,
|
|
127
136
|
isActive: isActive
|
|
128
137
|
});
|
|
138
|
+
} else {
|
|
139
|
+
style = getBlockNodeStyle({
|
|
140
|
+
nodeName: change.name,
|
|
141
|
+
colorScheme: colorScheme,
|
|
142
|
+
isActive: isActive
|
|
143
|
+
});
|
|
129
144
|
}
|
|
130
145
|
var className = getNodeClass(change.name);
|
|
131
146
|
if (fg('platform_editor_show_diff_scroll_navigation')) {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
1
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { editingStyle, editingStyleActive, deletedContentStyle, deletedContentStyleActive } from './colorSchemes/standard';
|
|
4
5
|
import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle } from './colorSchemes/traditional';
|
|
5
|
-
|
|
6
|
+
var displayNoneStyle = convertToInlineCss({
|
|
7
|
+
display: 'none'
|
|
8
|
+
});
|
|
6
9
|
/**
|
|
7
10
|
* Inline decoration used for insertions as the content already exists in the document
|
|
8
11
|
*
|
|
@@ -16,7 +19,16 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
16
19
|
_ref$isActive = _ref.isActive,
|
|
17
20
|
isActive = _ref$isActive === void 0 ? false : _ref$isActive,
|
|
18
21
|
_ref$isInserted = _ref.isInserted,
|
|
19
|
-
isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted
|
|
22
|
+
isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted,
|
|
23
|
+
_ref$shouldHideDelete = _ref.shouldHideDeleted,
|
|
24
|
+
shouldHideDeleted = _ref$shouldHideDelete === void 0 ? false : _ref$shouldHideDelete;
|
|
25
|
+
if (shouldHideDeleted) {
|
|
26
|
+
return Decoration.inline(change.fromB, change.toB, {
|
|
27
|
+
style: displayNoneStyle
|
|
28
|
+
}, {
|
|
29
|
+
key: 'diff-inline'
|
|
30
|
+
});
|
|
31
|
+
}
|
|
20
32
|
var style;
|
|
21
33
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
22
34
|
if (isInserted) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
2
5
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
3
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -255,8 +258,10 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
255
258
|
});
|
|
256
259
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
257
260
|
var decorations = [];
|
|
258
|
-
decorations.push(Decoration.widget(safeInsertPos, dom, {
|
|
261
|
+
decorations.push(Decoration.widget(safeInsertPos, dom, _objectSpread({
|
|
259
262
|
key: "diff-widget-".concat(isActive ? 'active' : 'inactive')
|
|
260
|
-
})
|
|
263
|
+
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
264
|
+
side: -1
|
|
265
|
+
})));
|
|
261
266
|
return decorations;
|
|
262
267
|
};
|
|
@@ -2,7 +2,7 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
|
2
2
|
import { trackChangesMessages } from '@atlaskit/editor-common/messages';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
-
import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingStyle, editingStyleActive, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
|
|
5
|
+
import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlock, editingStyle, editingStyleActive, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
|
|
6
6
|
import { deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRounded, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNode, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyle, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
|
|
7
7
|
var lozengeStyle = convertToInlineCss({
|
|
8
8
|
display: 'inline-flex',
|
|
@@ -74,7 +74,10 @@ var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
|
|
|
74
74
|
var isActive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
75
75
|
var isTraditional = colorScheme === 'traditional';
|
|
76
76
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted) {
|
|
77
|
-
if (
|
|
77
|
+
if (isMultiContainerBlockNode(nodeName)) {
|
|
78
|
+
return editingContentStyleInBlock;
|
|
79
|
+
}
|
|
80
|
+
if (isTextLikeBlockNode(nodeName)) {
|
|
78
81
|
return undefined;
|
|
79
82
|
}
|
|
80
83
|
if (isTraditional) {
|
|
@@ -155,6 +158,12 @@ var maybeAddDeletedOutlineNewClass = function maybeAddDeletedOutlineNewClass(_re
|
|
|
155
158
|
var shouldApplyStylesDirectly = function shouldApplyStylesDirectly(nodeName) {
|
|
156
159
|
return nodeName === 'heading';
|
|
157
160
|
};
|
|
161
|
+
var isMultiContainerBlockNode = function isMultiContainerBlockNode(nodeName) {
|
|
162
|
+
return ['decisionList', 'layoutSection'].includes(nodeName);
|
|
163
|
+
};
|
|
164
|
+
var isTextLikeBlockNode = function isTextLikeBlockNode(nodeName) {
|
|
165
|
+
return ['heading', 'bulletList', 'orderedList', 'listItem', 'taskList', 'blockquote'].includes(nodeName);
|
|
166
|
+
};
|
|
158
167
|
var applyCellOverlayStyles = function applyCellOverlayStyles(_ref2) {
|
|
159
168
|
var element = _ref2.element,
|
|
160
169
|
colorScheme = _ref2.colorScheme,
|
|
@@ -222,16 +231,66 @@ var applyStylesToElement = function applyStylesToElement(_ref3) {
|
|
|
222
231
|
var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive) || '';
|
|
223
232
|
element.setAttribute('style', "".concat(currentStyle).concat(contentStyle).concat(nodeSpecificStyle));
|
|
224
233
|
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
* Creates a content wrapper with deleted styles for a block node
|
|
228
|
-
*/
|
|
229
|
-
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref4) {
|
|
230
|
-
var nodeView = _ref4.nodeView,
|
|
234
|
+
var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref4) {
|
|
235
|
+
var element = _ref4.element,
|
|
231
236
|
targetNode = _ref4.targetNode,
|
|
232
237
|
colorScheme = _ref4.colorScheme,
|
|
233
238
|
isActive = _ref4.isActive,
|
|
234
239
|
isInserted = _ref4.isInserted;
|
|
240
|
+
var currentStyle = element.getAttribute('style') || '';
|
|
241
|
+
var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive) || '';
|
|
242
|
+
if (targetNode.type.name === 'decisionList') {
|
|
243
|
+
element.querySelectorAll('li').forEach(function (listItem) {
|
|
244
|
+
var currentListItemStyle = listItem.getAttribute('style') || '';
|
|
245
|
+
listItem.setAttribute('style', "".concat(currentListItemStyle).concat(editingStyleNode));
|
|
246
|
+
});
|
|
247
|
+
} else if (targetNode.type.name === 'layoutSection') {
|
|
248
|
+
element.querySelectorAll('[data-layout-column="true"]').forEach(function (section) {
|
|
249
|
+
var currentSectionStyle = section.getAttribute('style') || '';
|
|
250
|
+
section.setAttribute('style', "".concat(currentSectionStyle).concat(editingStyleNode));
|
|
251
|
+
});
|
|
252
|
+
} else if (targetNode.type.name === 'taskList') {
|
|
253
|
+
element.querySelectorAll('li').forEach(function (listItem) {
|
|
254
|
+
var currentListItemStyle = listItem.getAttribute('style') || '';
|
|
255
|
+
listItem.setAttribute('style', "".concat(currentListItemStyle).concat(editingStyleNode));
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
element.setAttribute('style', "".concat(currentStyle, ";").concat(nodeSpecificStyle));
|
|
259
|
+
};
|
|
260
|
+
var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref5) {
|
|
261
|
+
var element = _ref5.element,
|
|
262
|
+
targetNode = _ref5.targetNode,
|
|
263
|
+
colorScheme = _ref5.colorScheme,
|
|
264
|
+
isActive = _ref5.isActive,
|
|
265
|
+
isInserted = _ref5.isInserted;
|
|
266
|
+
getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive) || '';
|
|
267
|
+
var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted);
|
|
268
|
+
var walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
269
|
+
var textNodesToWrap = [];
|
|
270
|
+
var currentNode = walker.nextNode();
|
|
271
|
+
while (currentNode) {
|
|
272
|
+
if (currentNode instanceof Text && currentNode.textContent !== '' && currentNode.parentElement) {
|
|
273
|
+
textNodesToWrap.push(currentNode);
|
|
274
|
+
}
|
|
275
|
+
currentNode = walker.nextNode();
|
|
276
|
+
}
|
|
277
|
+
textNodesToWrap.forEach(function (textNode) {
|
|
278
|
+
var contentWrapper = document.createElement('span');
|
|
279
|
+
contentWrapper.setAttribute('style', contentStyle);
|
|
280
|
+
textNode.replaceWith(contentWrapper);
|
|
281
|
+
contentWrapper.append(textNode);
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Creates a content wrapper with deleted styles for a block node
|
|
287
|
+
*/
|
|
288
|
+
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6) {
|
|
289
|
+
var nodeView = _ref6.nodeView,
|
|
290
|
+
targetNode = _ref6.targetNode,
|
|
291
|
+
colorScheme = _ref6.colorScheme,
|
|
292
|
+
isActive = _ref6.isActive,
|
|
293
|
+
isInserted = _ref6.isInserted;
|
|
235
294
|
var contentWrapper = document.createElement('div');
|
|
236
295
|
var nodeStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive);
|
|
237
296
|
contentWrapper.setAttribute('style', "".concat(getChangedContentStyle(colorScheme, isActive, isInserted)).concat(nodeStyle || ''));
|
|
@@ -245,14 +304,14 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref4
|
|
|
245
304
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
246
305
|
* @returns true if embedCard was handled
|
|
247
306
|
*/
|
|
248
|
-
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(
|
|
249
|
-
var dom =
|
|
250
|
-
nodeView =
|
|
251
|
-
targetNode =
|
|
252
|
-
lozenge =
|
|
253
|
-
colorScheme =
|
|
254
|
-
|
|
255
|
-
isActive =
|
|
307
|
+
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref7) {
|
|
308
|
+
var dom = _ref7.dom,
|
|
309
|
+
nodeView = _ref7.nodeView,
|
|
310
|
+
targetNode = _ref7.targetNode,
|
|
311
|
+
lozenge = _ref7.lozenge,
|
|
312
|
+
colorScheme = _ref7.colorScheme,
|
|
313
|
+
_ref7$isActive = _ref7.isActive,
|
|
314
|
+
isActive = _ref7$isActive === void 0 ? false : _ref7$isActive;
|
|
256
315
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
257
316
|
return false;
|
|
258
317
|
}
|
|
@@ -293,14 +352,14 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref5) {
|
|
|
293
352
|
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
294
353
|
* @returns true if mediaSingle was handled, false otherwise
|
|
295
354
|
*/
|
|
296
|
-
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
|
|
297
|
-
var dom =
|
|
298
|
-
nodeView =
|
|
299
|
-
targetNode =
|
|
300
|
-
lozenge =
|
|
301
|
-
colorScheme =
|
|
302
|
-
|
|
303
|
-
isActive =
|
|
355
|
+
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref8) {
|
|
356
|
+
var dom = _ref8.dom,
|
|
357
|
+
nodeView = _ref8.nodeView,
|
|
358
|
+
targetNode = _ref8.targetNode,
|
|
359
|
+
lozenge = _ref8.lozenge,
|
|
360
|
+
colorScheme = _ref8.colorScheme,
|
|
361
|
+
_ref8$isActive = _ref8.isActive,
|
|
362
|
+
isActive = _ref8$isActive === void 0 ? false : _ref8$isActive;
|
|
304
363
|
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
305
364
|
return false;
|
|
306
365
|
}
|
|
@@ -338,16 +397,16 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref6)
|
|
|
338
397
|
/**
|
|
339
398
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
340
399
|
*/
|
|
341
|
-
var wrapBlockNode = function wrapBlockNode(
|
|
342
|
-
var dom =
|
|
343
|
-
nodeView =
|
|
344
|
-
targetNode =
|
|
345
|
-
colorScheme =
|
|
346
|
-
intl =
|
|
347
|
-
|
|
348
|
-
isActive =
|
|
349
|
-
|
|
350
|
-
isInserted =
|
|
400
|
+
var wrapBlockNode = function wrapBlockNode(_ref9) {
|
|
401
|
+
var dom = _ref9.dom,
|
|
402
|
+
nodeView = _ref9.nodeView,
|
|
403
|
+
targetNode = _ref9.targetNode,
|
|
404
|
+
colorScheme = _ref9.colorScheme,
|
|
405
|
+
intl = _ref9.intl,
|
|
406
|
+
_ref9$isActive = _ref9.isActive,
|
|
407
|
+
isActive = _ref9$isActive === void 0 ? false : _ref9$isActive,
|
|
408
|
+
_ref9$isInserted = _ref9.isInserted,
|
|
409
|
+
isInserted = _ref9$isInserted === void 0 ? false : _ref9$isInserted;
|
|
351
410
|
var blockWrapper = createBlockNodeWrapper();
|
|
352
411
|
if (shouldShowRemovedLozenge(targetNode.type.name) && (!expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || !isInserted)) {
|
|
353
412
|
var lozenge = createRemovedLozenge(intl, isActive, colorScheme);
|
|
@@ -402,35 +461,50 @@ var wrapBlockNode = function wrapBlockNode(_ref7) {
|
|
|
402
461
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
403
462
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
404
463
|
*/
|
|
405
|
-
export var wrapBlockNodeView = function wrapBlockNodeView(
|
|
406
|
-
var dom =
|
|
407
|
-
nodeView =
|
|
408
|
-
targetNode =
|
|
409
|
-
colorScheme =
|
|
410
|
-
intl =
|
|
411
|
-
|
|
412
|
-
isActive =
|
|
413
|
-
|
|
414
|
-
isInserted =
|
|
415
|
-
if (
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
464
|
+
export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
|
|
465
|
+
var dom = _ref0.dom,
|
|
466
|
+
nodeView = _ref0.nodeView,
|
|
467
|
+
targetNode = _ref0.targetNode,
|
|
468
|
+
colorScheme = _ref0.colorScheme,
|
|
469
|
+
intl = _ref0.intl,
|
|
470
|
+
_ref0$isActive = _ref0.isActive,
|
|
471
|
+
isActive = _ref0$isActive === void 0 ? false : _ref0$isActive,
|
|
472
|
+
_ref0$isInserted = _ref0.isInserted,
|
|
473
|
+
isInserted = _ref0$isInserted === void 0 ? false : _ref0$isInserted;
|
|
474
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
475
|
+
if (nodeView instanceof HTMLElement) {
|
|
476
|
+
if (isInserted && isMultiContainerBlockNode(targetNode.type.name)) {
|
|
477
|
+
applyMultiContainerLikeStyles({
|
|
478
|
+
element: nodeView,
|
|
479
|
+
targetNode: targetNode,
|
|
480
|
+
colorScheme: colorScheme,
|
|
481
|
+
isActive: isActive,
|
|
482
|
+
isInserted: isInserted
|
|
483
|
+
});
|
|
484
|
+
dom.append(nodeView);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (isTextLikeBlockNode(targetNode.type.name)) {
|
|
488
|
+
applyTextLikeBlockNodeStyles({
|
|
489
|
+
element: nodeView,
|
|
490
|
+
targetNode: targetNode,
|
|
491
|
+
colorScheme: colorScheme,
|
|
492
|
+
isActive: isActive,
|
|
493
|
+
isInserted: isInserted
|
|
494
|
+
});
|
|
495
|
+
dom.append(nodeView);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (targetNode.type.name === 'table') {
|
|
499
|
+
applyCellOverlayStyles({
|
|
500
|
+
element: nodeView,
|
|
501
|
+
colorScheme: colorScheme,
|
|
502
|
+
isInserted: isInserted
|
|
503
|
+
});
|
|
504
|
+
dom.append(nodeView);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
434
508
|
wrapBlockNode({
|
|
435
509
|
dom: dom,
|
|
436
510
|
nodeView: nodeView,
|
|
@@ -440,5 +514,28 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref8) {
|
|
|
440
514
|
isActive: isActive,
|
|
441
515
|
isInserted: isInserted
|
|
442
516
|
});
|
|
517
|
+
return;
|
|
518
|
+
} else {
|
|
519
|
+
if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
|
|
520
|
+
// Apply deleted styles directly to preserve natural block-level margins
|
|
521
|
+
applyStylesToElement({
|
|
522
|
+
element: nodeView,
|
|
523
|
+
targetNode: targetNode,
|
|
524
|
+
colorScheme: colorScheme,
|
|
525
|
+
isActive: isActive,
|
|
526
|
+
isInserted: isInserted
|
|
527
|
+
});
|
|
528
|
+
dom.append(nodeView);
|
|
529
|
+
} else {
|
|
530
|
+
wrapBlockNode({
|
|
531
|
+
dom: dom,
|
|
532
|
+
nodeView: nodeView,
|
|
533
|
+
targetNode: targetNode,
|
|
534
|
+
colorScheme: colorScheme,
|
|
535
|
+
intl: intl,
|
|
536
|
+
isActive: isActive,
|
|
537
|
+
isInserted: isInserted
|
|
538
|
+
});
|
|
539
|
+
}
|
|
443
540
|
}
|
|
444
541
|
};
|
|
@@ -36,7 +36,8 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
36
36
|
isDisplayingChanges: false
|
|
37
37
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
38
38
|
isInverted: false,
|
|
39
|
-
diffType: 'inline'
|
|
39
|
+
diffType: 'inline',
|
|
40
|
+
hideDeletedDiffs: false
|
|
40
41
|
} : {});
|
|
41
42
|
},
|
|
42
43
|
apply: function apply(tr, currentPluginState, oldState, newState) {
|
|
@@ -44,7 +45,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
44
45
|
var newPluginState = currentPluginState;
|
|
45
46
|
if (meta) {
|
|
46
47
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
|
|
47
|
-
var _newPluginState, _newPluginState2;
|
|
48
|
+
var _newPluginState, _newPluginState2, _newPluginState3;
|
|
48
49
|
// Update the plugin state with the new metadata
|
|
49
50
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
50
51
|
isDisplayingChanges: true,
|
|
@@ -61,7 +62,8 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
61
62
|
api: api
|
|
62
63
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
63
64
|
isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted,
|
|
64
|
-
diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType
|
|
65
|
+
diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType,
|
|
66
|
+
hideDeletedDiffs: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.hideDeletedDiffs
|
|
65
67
|
} : {}));
|
|
66
68
|
// Update the decorations
|
|
67
69
|
newPluginState.decorations = decorations;
|
|
@@ -72,7 +74,8 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
72
74
|
activeIndex: undefined
|
|
73
75
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
74
76
|
isInverted: false,
|
|
75
|
-
diffType: 'inline'
|
|
77
|
+
diffType: 'inline',
|
|
78
|
+
hideDeletedDiffs: false
|
|
76
79
|
} : {});
|
|
77
80
|
} 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')) {
|
|
78
81
|
// Update the active index in plugin state and recalculate decorations
|
|
@@ -111,7 +114,9 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
111
114
|
activeIndexPos: newPluginState.activeIndexPos,
|
|
112
115
|
api: api
|
|
113
116
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
114
|
-
isInverted: newPluginState.isInverted
|
|
117
|
+
isInverted: newPluginState.isInverted,
|
|
118
|
+
diffType: newPluginState.diffType,
|
|
119
|
+
hideDeletedDiffs: newPluginState.hideDeletedDiffs
|
|
115
120
|
} : {}));
|
|
116
121
|
newPluginState.decorations = updatedDecorations;
|
|
117
122
|
}
|
|
@@ -6,13 +6,14 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import type { ColorScheme, ShowDiffPlugin } from '../../showDiffPluginType';
|
|
7
7
|
import type { ShowDiffPluginState } from '../main';
|
|
8
8
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
9
|
-
export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, }: {
|
|
9
|
+
export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, }: {
|
|
10
10
|
activeIndexPos?: {
|
|
11
11
|
from: number;
|
|
12
12
|
to: number;
|
|
13
13
|
};
|
|
14
14
|
api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
|
|
15
15
|
colorScheme?: ColorScheme;
|
|
16
|
+
hideDeletedDiffs?: boolean;
|
|
16
17
|
intl: IntlShape;
|
|
17
18
|
nodeViewSerializer: NodeViewSerializer;
|
|
18
19
|
pluginState: Omit<ShowDiffPluginState, 'decorations'>;
|
|
@@ -8,7 +8,7 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
8
8
|
* @param isActive Whether this node is part of the currently active/focused change
|
|
9
9
|
* @returns Prosemirror node decoration or undefined
|
|
10
10
|
*/
|
|
11
|
-
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, }: {
|
|
11
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, }: {
|
|
12
12
|
change: {
|
|
13
13
|
from: number;
|
|
14
14
|
name: string;
|
|
@@ -17,4 +17,5 @@ export declare const createBlockChangedDecoration: ({ change, colorScheme, isIns
|
|
|
17
17
|
colorScheme?: ColorScheme;
|
|
18
18
|
isActive?: boolean;
|
|
19
19
|
isInserted?: boolean;
|
|
20
|
+
shouldHideDeleted?: boolean;
|
|
20
21
|
}) => Decoration[];
|
|
@@ -6,7 +6,7 @@ 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, isInserted, }: {
|
|
9
|
+
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, }: {
|
|
10
10
|
change: {
|
|
11
11
|
fromB: number;
|
|
12
12
|
toB: number;
|
|
@@ -14,4 +14,5 @@ export declare const createInlineChangedDecoration: ({ change, colorScheme, isAc
|
|
|
14
14
|
colorScheme?: ColorScheme;
|
|
15
15
|
isActive?: boolean;
|
|
16
16
|
isInserted?: boolean;
|
|
17
|
+
shouldHideDeleted?: boolean;
|
|
17
18
|
}) => Decoration;
|
|
@@ -6,13 +6,14 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import type { ColorScheme, ShowDiffPlugin } from '../../showDiffPluginType';
|
|
7
7
|
import type { ShowDiffPluginState } from '../main';
|
|
8
8
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
9
|
-
export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, }: {
|
|
9
|
+
export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, }: {
|
|
10
10
|
activeIndexPos?: {
|
|
11
11
|
from: number;
|
|
12
12
|
to: number;
|
|
13
13
|
};
|
|
14
14
|
api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
|
|
15
15
|
colorScheme?: ColorScheme;
|
|
16
|
+
hideDeletedDiffs?: boolean;
|
|
16
17
|
intl: IntlShape;
|
|
17
18
|
nodeViewSerializer: NodeViewSerializer;
|
|
18
19
|
pluginState: Omit<ShowDiffPluginState, 'decorations'>;
|
|
@@ -8,7 +8,7 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
8
8
|
* @param isActive Whether this node is part of the currently active/focused change
|
|
9
9
|
* @returns Prosemirror node decoration or undefined
|
|
10
10
|
*/
|
|
11
|
-
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, }: {
|
|
11
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, }: {
|
|
12
12
|
change: {
|
|
13
13
|
from: number;
|
|
14
14
|
name: string;
|
|
@@ -17,4 +17,5 @@ export declare const createBlockChangedDecoration: ({ change, colorScheme, isIns
|
|
|
17
17
|
colorScheme?: ColorScheme;
|
|
18
18
|
isActive?: boolean;
|
|
19
19
|
isInserted?: boolean;
|
|
20
|
+
shouldHideDeleted?: boolean;
|
|
20
21
|
}) => Decoration[];
|
|
@@ -6,7 +6,7 @@ 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, isInserted, }: {
|
|
9
|
+
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, }: {
|
|
10
10
|
change: {
|
|
11
11
|
fromB: number;
|
|
12
12
|
toB: number;
|
|
@@ -14,4 +14,5 @@ export declare const createInlineChangedDecoration: ({ change, colorScheme, isAc
|
|
|
14
14
|
colorScheme?: ColorScheme;
|
|
15
15
|
isActive?: boolean;
|
|
16
16
|
isInserted?: boolean;
|
|
17
|
+
shouldHideDeleted?: boolean;
|
|
17
18
|
}) => Decoration;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.1",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/adf-schema": "^52.
|
|
31
|
+
"@atlaskit/adf-schema": "^52.5.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.16.0",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
34
34
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
35
35
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
36
36
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
37
|
-
"@atlaskit/tmp-editor-statsig": "^62.
|
|
37
|
+
"@atlaskit/tmp-editor-statsig": "^62.4.0",
|
|
38
38
|
"@atlaskit/tokens": "^13.0.0",
|
|
39
39
|
"@babel/runtime": "^7.0.0",
|
|
40
40
|
"lodash": "^4.17.21",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^112.
|
|
59
|
+
"@atlaskit/editor-common": "^112.22.0",
|
|
60
60
|
"react": "^18.2.0"
|
|
61
61
|
},
|
|
62
62
|
"techstack": {
|