@atlaskit/editor-plugin-show-diff 3.1.4 → 3.2.0

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-jira/tsconfig.json +3 -0
  4. package/afm-post-office/tsconfig.json +3 -0
  5. package/afm-products/tsconfig.json +3 -0
  6. package/dist/cjs/pm-plugins/attributeDecorations.js +33 -0
  7. package/dist/cjs/pm-plugins/calculateDiffDecorations.js +13 -5
  8. package/dist/cjs/pm-plugins/decorations.js +225 -7
  9. package/dist/cjs/pm-plugins/main.js +6 -5
  10. package/dist/cjs/showDiffPlugin.js +4 -3
  11. package/dist/es2019/pm-plugins/attributeDecorations.js +21 -0
  12. package/dist/es2019/pm-plugins/calculateDiffDecorations.js +13 -5
  13. package/dist/es2019/pm-plugins/decorations.js +225 -7
  14. package/dist/es2019/pm-plugins/main.js +4 -3
  15. package/dist/es2019/showDiffPlugin.js +4 -2
  16. package/dist/esm/pm-plugins/attributeDecorations.js +26 -0
  17. package/dist/esm/pm-plugins/calculateDiffDecorations.js +13 -5
  18. package/dist/esm/pm-plugins/decorations.js +225 -7
  19. package/dist/esm/pm-plugins/main.js +4 -3
  20. package/dist/esm/showDiffPlugin.js +4 -3
  21. package/dist/types/pm-plugins/attributeDecorations.d.ts +8 -0
  22. package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +3 -1
  23. package/dist/types/pm-plugins/decorations.d.ts +3 -1
  24. package/dist/types/pm-plugins/main.d.ts +2 -1
  25. package/dist/types-ts4.5/pm-plugins/attributeDecorations.d.ts +8 -0
  26. package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +3 -1
  27. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +3 -1
  28. package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
  29. package/package.json +8 -2
  30. package/afm-dev-agents/tsconfig.json +0 -27
  31. package/afm-passionfruit/tsconfig.json +0 -27
  32. package/afm-rovo-extension/tsconfig.json +0 -27
  33. package/afm-townsquare/tsconfig.json +0 -27
  34. package/afm-volt/tsconfig.json +0 -27
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 3.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`68caaf98e8f89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/68caaf98e8f89) -
8
+ [ux] [EDITOR-1628] Added "Removed" Lozenge and gray border decorations to deleted block nodes in
9
+ show diff view
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 3.1.5
16
+
17
+ ### Patch Changes
18
+
19
+ - [`7c8492867be97`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7c8492867be97) -
20
+ [ux] Add support for media attribute changes in the diff
21
+
3
22
  ## 3.1.4
4
23
 
5
24
  ### Patch Changes
@@ -17,6 +17,9 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../../platform/feature-flags/afm-cc/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../../design-system/tokens/afm-cc/tsconfig.json"
22
25
  },
@@ -17,6 +17,9 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../../platform/feature-flags/afm-jira/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../../design-system/tokens/afm-jira/tsconfig.json"
22
25
  },
@@ -17,6 +17,9 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../../platform/feature-flags/afm-post-office/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../../design-system/tokens/afm-post-office/tsconfig.json"
22
25
  },
@@ -17,6 +17,9 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../../platform/feature-flags/afm-products/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../../design-system/tokens/afm-products/tsconfig.json"
22
25
  },
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getAttrChangeRanges = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _steps = require("@atlaskit/adf-schema/steps");
10
+ var _transform = require("@atlaskit/editor-prosemirror/transform");
11
+ var filterUndefined = function filterUndefined(x) {
12
+ return !!x;
13
+ };
14
+
15
+ // Currently allow attributes that indicats a change in media image
16
+ var allowedAttrs = ['id', 'collection', 'url'];
17
+ var getAttrChangeRanges = exports.getAttrChangeRanges = function getAttrChangeRanges(doc, steps) {
18
+ return steps.map(function (step) {
19
+ if (step instanceof _transform.AttrStep && allowedAttrs.includes(step.attr) || step instanceof _steps.SetAttrsStep && (0, _toConsumableArray2.default)(Object.keys(step.attrs)).some(function (v) {
20
+ return allowedAttrs.includes(v);
21
+ })) {
22
+ var $pos = doc.resolve(step.pos);
23
+ if ($pos.parent.type === doc.type.schema.nodes.mediaSingle) {
24
+ var startPos = $pos.pos + $pos.parentOffset;
25
+ return {
26
+ fromB: startPos,
27
+ toB: startPos + $pos.parent.nodeSize - 1
28
+ };
29
+ }
30
+ }
31
+ return undefined;
32
+ }).filter(filterUndefined);
33
+ };
@@ -15,6 +15,7 @@ var _steps = require("@atlaskit/adf-schema/steps");
15
15
  var _document = require("@atlaskit/editor-common/utils/document");
16
16
  var _transform = require("@atlaskit/editor-prosemirror/transform");
17
17
  var _view = require("@atlaskit/editor-prosemirror/view");
18
+ var _attributeDecorations = require("./attributeDecorations");
18
19
  var _decorations = require("./decorations");
19
20
  var _markDecorations = require("./markDecorations");
20
21
  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; } } }; }
@@ -94,7 +95,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
94
95
  var state = _ref.state,
95
96
  pluginState = _ref.pluginState,
96
97
  nodeViewSerializer = _ref.nodeViewSerializer,
97
- colourScheme = _ref.colourScheme;
98
+ colourScheme = _ref.colourScheme,
99
+ intl = _ref.intl;
98
100
  var originalDoc = pluginState.originalDoc,
99
101
  rawSteps = pluginState.steps;
100
102
  var steps = simplifySteps(rawSteps);
@@ -141,7 +143,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
141
143
  doc: originalDoc,
142
144
  nodeViewSerializer: nodeViewSerializer,
143
145
  colourScheme: colourScheme,
144
- newDoc: tr.doc
146
+ newDoc: tr.doc,
147
+ intl: intl
145
148
  });
146
149
  if (decoration) {
147
150
  decorations.push(decoration);
@@ -151,6 +154,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
151
154
  (0, _markDecorations.getMarkChangeRanges)(steps).forEach(function (change) {
152
155
  decorations.push((0, _decorations.createInlineChangedDecoration)(change, colourScheme));
153
156
  });
157
+ (0, _attributeDecorations.getAttrChangeRanges)(tr.doc, rawSteps).forEach(function (change) {
158
+ decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme)));
159
+ });
154
160
  return _view.DecorationSet.empty.add(tr.doc, decorations);
155
161
  };
156
162
  var calculateDiffDecorations = exports.calculateDiffDecorations = (0, _memoizeOne.default)(calculateDiffDecorationsInner,
@@ -161,12 +167,14 @@ function (_ref2, _ref3) {
161
167
  _ref4$ = _ref4[0],
162
168
  pluginState = _ref4$.pluginState,
163
169
  state = _ref4$.state,
164
- colourScheme = _ref4$.colourScheme;
170
+ colourScheme = _ref4$.colourScheme,
171
+ intl = _ref4$.intl;
165
172
  var _ref5 = (0, _slicedToArray2.default)(_ref3, 1),
166
173
  _ref5$ = _ref5[0],
167
174
  lastPluginState = _ref5$.pluginState,
168
175
  lastState = _ref5$.state,
169
- lastColourScheme = _ref5$.colourScheme;
176
+ lastColourScheme = _ref5$.colourScheme,
177
+ lastIntl = _ref5$.intl;
170
178
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
171
- return (_ref6 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colourScheme === lastColourScheme) !== null && _ref6 !== void 0 ? _ref6 : false;
179
+ return (_ref6 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colourScheme === lastColourScheme && intl.locale === lastIntl.locale) !== null && _ref6 !== void 0 ? _ref6 : false;
172
180
  });
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createInlineChangedDecoration = exports.createDeletedContentDecoration = exports.createBlockChangedDecoration = void 0;
7
7
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
8
+ var _messages = require("@atlaskit/editor-common/messages");
8
9
  var _view = require("@atlaskit/editor-prosemirror/view");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
11
  var _findSafeInsertPos = require("./findSafeInsertPos");
10
12
  var editingStyle = (0, _lazyNodeView.convertToInlineCss)({
11
13
  background: "var(--ds-background-accent-purple-subtlest, #F3F0FF)",
@@ -76,6 +78,59 @@ var getEditorStyleNode = function getEditorStyleNode(nodeName, colourScheme) {
76
78
  return colourScheme === 'traditional' ? traditionalStyleNode : editingStyleNode;
77
79
  }
78
80
  };
81
+ var getDeletedStyleNode = function getDeletedStyleNode(nodeName) {
82
+ switch (nodeName) {
83
+ case 'blockquote':
84
+ return deletedStyleQuoteNode;
85
+ case 'expand':
86
+ case 'decisionList':
87
+ return deletedBlockOutline;
88
+ case 'panel':
89
+ case 'codeBlock':
90
+ return deletedBlockOutlineRounded;
91
+ default:
92
+ return undefined;
93
+ }
94
+ };
95
+ var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
96
+ switch (nodeName) {
97
+ case 'expand':
98
+ case 'codeBlock':
99
+ case 'mediaSingle':
100
+ case 'panel':
101
+ case 'decisionList':
102
+ return true;
103
+ default:
104
+ return false;
105
+ }
106
+ };
107
+ var shouldFitContentWidth = function shouldFitContentWidth(nodeName) {
108
+ switch (nodeName) {
109
+ case 'mediaSingle':
110
+ case 'embedCard':
111
+ case 'blockCard':
112
+ return true;
113
+ default:
114
+ return false;
115
+ }
116
+ };
117
+ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeClass(nodeName) {
118
+ switch (nodeName) {
119
+ case 'mediaSingle':
120
+ case 'embedCard':
121
+ return true;
122
+ default:
123
+ return false;
124
+ }
125
+ };
126
+
127
+ /**
128
+ * Checks if a node should apply deleted styles directly without wrapper
129
+ * to preserve natural block-level margins
130
+ */
131
+ var shouldApplyDeletedStylesDirectly = function shouldApplyDeletedStylesDirectly(nodeName) {
132
+ return nodeName === 'blockquote' || nodeName === 'heading';
133
+ };
79
134
  var editingStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
80
135
  borderLeft: "2px solid ".concat("var(--ds-border-accent-purple, #8270DB)")
81
136
  });
@@ -104,6 +159,18 @@ var traditionalStyleCardBlockNode = (0, _lazyNodeView.convertToInlineCss)({
104
159
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
105
160
  borderRadius: "var(--ds-radius-medium, 6px)"
106
161
  });
162
+ var deletedStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
163
+ borderLeft: "2px solid ".concat("var(--ds-border-accent-gray, #758195)")
164
+ });
165
+ var deletedBlockOutline = (0, _lazyNodeView.convertToInlineCss)({
166
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #758195)"),
167
+ borderRadius: "var(--ds-radius-small, 4px)"
168
+ });
169
+ var deletedBlockOutlineRounded = (0, _lazyNodeView.convertToInlineCss)({
170
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #758195)"),
171
+ borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
172
+ });
173
+
107
174
  /**
108
175
  * Inline decoration used for insertions as the content already exists in the document
109
176
  *
@@ -146,18 +213,149 @@ var deletedTraditionalContentStyleUnbounded = (0, _lazyNodeView.convertToInlineC
146
213
  pointerEvents: 'none',
147
214
  zIndex: 1
148
215
  });
216
+ var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
217
+ display: 'inline-flex',
218
+ boxSizing: 'border-box',
219
+ position: 'static',
220
+ blockSize: 'min-content',
221
+ borderRadius: "var(--ds-radius-small, 4px)",
222
+ overflow: 'hidden',
223
+ paddingInlineStart: "var(--ds-space-050, 4px)",
224
+ paddingInlineEnd: "var(--ds-space-050, 4px)",
225
+ backgroundColor: "var(--ds-background-accent-gray-subtler, #DCDFE4)",
226
+ font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
227
+ fontWeight: "var(--ds-font-weight-bold, 700)",
228
+ textOverflow: 'ellipsis',
229
+ whiteSpace: 'nowrap',
230
+ color: "var(--ds-text-warning-inverse, #172B4D)"
231
+ });
149
232
  var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
150
233
  return colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
151
234
  };
152
235
  var getDeletedContentStyle = function getDeletedContentStyle(colourScheme) {
153
236
  return colourScheme === 'traditional' ? deletedTraditionalContentStyle : deletedContentStyle;
154
237
  };
238
+
239
+ /**
240
+ * Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
241
+ */
242
+ var createRemovedLozenge = function createRemovedLozenge(intl, nodeName) {
243
+ var container = document.createElement('span');
244
+ var borderTopRightRadius;
245
+ var borderTopLeftRadius;
246
+ if (['expand', 'decisionList'].includes(nodeName || '')) {
247
+ borderTopRightRadius = "var(--ds-radius-small, 4px)";
248
+ } else if (['panel', 'codeBlock'].includes(nodeName || '')) {
249
+ borderTopRightRadius = "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)");
250
+ } else if (nodeName === 'mediaSingle') {
251
+ borderTopLeftRadius = "var(--ds-radius-small, 4px)";
252
+ }
253
+ var containerStyle = (0, _lazyNodeView.convertToInlineCss)({
254
+ position: 'absolute',
255
+ top: nodeName === 'mediaSingle' ? "var(--ds-space-300, 24px)" : "var(--ds-space-0, 0px)",
256
+ right: nodeName === 'mediaSingle' ? undefined : "var(--ds-space-0, 0px)",
257
+ left: nodeName === 'mediaSingle' ? "var(--ds-space-0, 0px)" : undefined,
258
+ zIndex: 2,
259
+ pointerEvents: 'none',
260
+ display: 'flex',
261
+ overflow: 'hidden',
262
+ borderTopRightRadius: borderTopRightRadius,
263
+ borderTopLeftRadius: borderTopLeftRadius
264
+ });
265
+ container.setAttribute('style', containerStyle);
266
+ container.setAttribute('data-testid', 'show-diff-removed-lozenge');
267
+
268
+ // Create vanilla HTML lozenge element with Atlaskit Lozenge styling (visual refresh)
269
+ var lozengeElement = document.createElement('span');
270
+ lozengeElement.setAttribute('style', lozengeStyle);
271
+ lozengeElement.textContent = intl.formatMessage(_messages.trackChangesMessages.removed).toUpperCase();
272
+ container.appendChild(lozengeElement);
273
+ return container;
274
+ };
275
+
276
+ /**
277
+ * Wraps a block node in a container with relative positioning to support absolute positioned lozenge
278
+ */
279
+ var createBlockNodeWrapper = function createBlockNodeWrapper(nodeName) {
280
+ var wrapper = document.createElement('div');
281
+ var fitContent = shouldFitContentWidth(nodeName);
282
+ var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
283
+ position: 'relative',
284
+ display: fitContent ? 'inline-block' : 'block',
285
+ width: fitContent ? 'fit-content' : undefined,
286
+ height: fitContent ? 'fit-content' : undefined,
287
+ opacity: 1
288
+ });
289
+ wrapper.setAttribute('style', baseStyle);
290
+ return wrapper;
291
+ };
292
+
293
+ /**
294
+ * Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
295
+ */
296
+ var createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colourScheme) {
297
+ var wrapper = document.createElement('span');
298
+ wrapper.setAttribute('style', getDeletedContentStyle(colourScheme));
299
+ return wrapper;
300
+ };
301
+
302
+ /**
303
+ * Applies deleted styles directly to an HTML element by merging with existing styles
304
+ */
305
+ var applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colourScheme) {
306
+ var currentStyle = element.getAttribute('style') || '';
307
+ var deletedContentStyle = getDeletedContentStyle(colourScheme);
308
+ var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name) || '';
309
+ element.setAttribute('style', "".concat(currentStyle).concat(deletedContentStyle).concat(nodeSpecificStyle));
310
+ };
311
+
312
+ /**
313
+ * Appends a block node with wrapper, lozenge, and appropriate styling
314
+ */
315
+ var appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl) {
316
+ var blockWrapper = createBlockNodeWrapper(targetNode.type.name);
317
+ if (shouldShowRemovedLozenge(targetNode.type.name)) {
318
+ var lozenge = createRemovedLozenge(intl, targetNode.type.name);
319
+ blockWrapper.append(lozenge);
320
+ }
321
+
322
+ // Wrap the nodeView in a content wrapper that has the opacity style AND the box-shadow
323
+ // This keeps the lozenge at full opacity while the content AND border are faded
324
+ var contentWrapper = document.createElement('div');
325
+ var nodeStyle = getDeletedStyleNode(targetNode.type.name);
326
+ contentWrapper.setAttribute('style', "".concat(getDeletedContentStyle(colourScheme)).concat(nodeStyle || ''));
327
+ contentWrapper.append(nodeView);
328
+ blockWrapper.append(contentWrapper);
329
+ if (nodeView instanceof HTMLElement) {
330
+ if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
331
+ nodeView.classList.add('show-diff-deleted-node');
332
+ }
333
+ }
334
+ dom.append(blockWrapper);
335
+ };
336
+
337
+ /**
338
+ * Handles all block node rendering with appropriate deleted styling.
339
+ * For blockquote and heading nodes, applies styles directly to preserve natural margins.
340
+ * For other block nodes, uses wrapper approach with optional lozenge.
341
+ */
342
+ var handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode, colourScheme, intl) {
343
+ if (shouldApplyDeletedStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
344
+ // Apply deleted styles directly to preserve natural block-level margins
345
+ applyDeletedStylesToElement(nodeView, targetNode, colourScheme);
346
+ dom.append(nodeView);
347
+ } else {
348
+ // Use wrapper approach for other block nodes
349
+ appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl);
350
+ }
351
+ };
155
352
  var createDeletedContentDecoration = exports.createDeletedContentDecoration = function createDeletedContentDecoration(_ref) {
156
353
  var change = _ref.change,
157
354
  doc = _ref.doc,
158
355
  nodeViewSerializer = _ref.nodeViewSerializer,
159
356
  colourScheme = _ref.colourScheme,
160
- newDoc = _ref.newDoc;
357
+ newDoc = _ref.newDoc,
358
+ intl = _ref.intl;
161
359
  var slice = doc.slice(change.fromA, change.toA);
162
360
  if (slice.content.content.length === 0) {
163
361
  return;
@@ -174,7 +372,9 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
174
372
 
175
373
  // For non-table content, use the existing span wrapper approach
176
374
  var dom = document.createElement('span');
177
- dom.setAttribute('style', getDeletedContentStyle(colourScheme));
375
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2')) {
376
+ dom.setAttribute('style', getDeletedContentStyle(colourScheme));
377
+ }
178
378
 
179
379
  /*
180
380
  * The thinking is we separate out the fragment we got from doc.slice
@@ -186,8 +386,11 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
186
386
  // Create a wrapper for each node with strikethrough
187
387
  var createWrapperWithStrikethrough = function createWrapperWithStrikethrough() {
188
388
  var wrapper = document.createElement('span');
189
- wrapper.style.position = 'relative';
190
- wrapper.style.width = 'fit-content';
389
+ var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
390
+ position: 'relative',
391
+ width: 'fit-content'
392
+ });
393
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colourScheme)));
191
394
  var strikethrough = document.createElement('span');
192
395
  strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
193
396
  wrapper.append(strikethrough);
@@ -210,7 +413,13 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
210
413
  // Fallback to serializing the individual child node
211
414
  var serializedChild = serializer.serializeNode(childNode);
212
415
  if (serializedChild) {
213
- dom.append(serializedChild);
416
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2')) {
417
+ var _wrapper = createWrapperWithStrikethrough();
418
+ _wrapper.append(serializedChild);
419
+ dom.append(_wrapper);
420
+ } else {
421
+ dom.append(serializedChild);
422
+ }
214
423
  }
215
424
  }
216
425
  });
@@ -266,6 +475,9 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
266
475
  var wrapper = createWrapperWithStrikethrough();
267
476
  wrapper.append(nodeView);
268
477
  dom.append(wrapper);
478
+ } else if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2')) {
479
+ // Handle all block nodes with unified function
480
+ handleBlockNodeView(dom, nodeView, targetNode, colourScheme, intl);
269
481
  } else {
270
482
  dom.append(nodeView);
271
483
  }
@@ -275,7 +487,13 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
275
487
  } else {
276
488
  var fallbackNode = fallbackSerialization();
277
489
  if (fallbackNode) {
278
- dom.append(fallbackNode);
490
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2')) {
491
+ var _wrapper2 = createDeletedStyleWrapperWithoutOpacity(colourScheme);
492
+ _wrapper2.append(fallbackNode);
493
+ dom.append(_wrapper2);
494
+ } else {
495
+ dom.append(fallbackNode);
496
+ }
279
497
  }
280
498
  }
281
499
  });
@@ -284,5 +502,5 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
284
502
  // Widget decoration used for deletions as the content is not in the document
285
503
  // and we want to display the deleted content with a style.
286
504
  var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, change.fromB, slice);
287
- return _view.Decoration.widget(safeInsertPos, dom, {});
505
+ return _view.Decoration.widget(safeInsertPos, dom);
288
506
  };
@@ -8,15 +8,15 @@ exports.showDiffPluginKey = exports.createPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _processRawValue = require("@atlaskit/editor-common/process-raw-value");
10
10
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
- var _state = require("@atlaskit/editor-prosemirror/state");
11
+ var _state2 = require("@atlaskit/editor-prosemirror/state");
12
12
  var _transform = require("@atlaskit/editor-prosemirror/transform");
13
13
  var _view = require("@atlaskit/editor-prosemirror/view");
14
14
  var _calculateDiffDecorations = require("./calculateDiffDecorations");
15
15
  var _NodeViewSerializer = require("./NodeViewSerializer");
16
16
  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; }
17
17
  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; }
18
- var showDiffPluginKey = exports.showDiffPluginKey = new _state.PluginKey('showDiffPlugin');
19
- var createPlugin = exports.createPlugin = function createPlugin(config) {
18
+ var showDiffPluginKey = exports.showDiffPluginKey = new _state2.PluginKey('showDiffPlugin');
19
+ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl) {
20
20
  var nodeViewSerializer = new _NodeViewSerializer.NodeViewSerializer({});
21
21
  var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
22
22
  nodeViewSerializer.init({
@@ -26,7 +26,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config) {
26
26
  return new _safePlugin.SafePlugin({
27
27
  key: showDiffPluginKey,
28
28
  state: {
29
- init: function init(_, state) {
29
+ init: function init(_, _state) {
30
30
  // We do initial setup after we setup the editor view
31
31
  return {
32
32
  steps: [],
@@ -49,7 +49,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config) {
49
49
  state: newState,
50
50
  pluginState: newPluginState,
51
51
  nodeViewSerializer: nodeViewSerializer,
52
- colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme
52
+ colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme,
53
+ intl: getIntl()
53
54
  });
54
55
  // Update the decorations
55
56
  newPluginState.decorations = decorations;
@@ -10,7 +10,7 @@ var _main = require("./pm-plugins/main");
10
10
  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; }
11
11
  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; }
12
12
  var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
13
- var api = _ref.api,
13
+ var _api = _ref.api,
14
14
  config = _ref.config;
15
15
  return {
16
16
  name: 'showDiff',
@@ -34,8 +34,9 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
34
34
  pmPlugins: function pmPlugins() {
35
35
  return [{
36
36
  name: 'showDiffPlugin',
37
- plugin: function plugin() {
38
- return (0, _main.createPlugin)(config);
37
+ plugin: function plugin(_ref4) {
38
+ var getIntl = _ref4.getIntl;
39
+ return (0, _main.createPlugin)(config, getIntl);
39
40
  }
40
41
  }];
41
42
  },
@@ -0,0 +1,21 @@
1
+ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
2
+ import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
3
+ const filterUndefined = x => !!x;
4
+
5
+ // Currently allow attributes that indicats a change in media image
6
+ const allowedAttrs = ['id', 'collection', 'url'];
7
+ export const getAttrChangeRanges = (doc, steps) => {
8
+ return steps.map(step => {
9
+ if (step instanceof AttrStep && allowedAttrs.includes(step.attr) || step instanceof SetAttrsStep && [...Object.keys(step.attrs)].some(v => allowedAttrs.includes(v))) {
10
+ const $pos = doc.resolve(step.pos);
11
+ if ($pos.parent.type === doc.type.schema.nodes.mediaSingle) {
12
+ const startPos = $pos.pos + $pos.parentOffset;
13
+ return {
14
+ fromB: startPos,
15
+ toB: startPos + $pos.parent.nodeSize - 1
16
+ };
17
+ }
18
+ }
19
+ return undefined;
20
+ }).filter(filterUndefined);
21
+ };
@@ -6,6 +6,7 @@ import { AnalyticsStep, SetAttrsStep } from '@atlaskit/adf-schema/steps';
6
6
  import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
7
7
  import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
8
8
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
+ import { getAttrChangeRanges } from './attributeDecorations';
9
10
  import { createInlineChangedDecoration, createDeletedContentDecoration, createBlockChangedDecoration } from './decorations';
10
11
  import { getMarkChangeRanges } from './markDecorations';
11
12
  const calculateNodesForBlockDecoration = (doc, from, to, colourScheme) => {
@@ -82,7 +83,8 @@ const calculateDiffDecorationsInner = ({
82
83
  state,
83
84
  pluginState,
84
85
  nodeViewSerializer,
85
- colourScheme
86
+ colourScheme,
87
+ intl
86
88
  }) => {
87
89
  const {
88
90
  originalDoc,
@@ -125,7 +127,8 @@ const calculateDiffDecorationsInner = ({
125
127
  doc: originalDoc,
126
128
  nodeViewSerializer,
127
129
  colourScheme,
128
- newDoc: tr.doc
130
+ newDoc: tr.doc,
131
+ intl
129
132
  });
130
133
  if (decoration) {
131
134
  decorations.push(decoration);
@@ -135,6 +138,9 @@ const calculateDiffDecorationsInner = ({
135
138
  getMarkChangeRanges(steps).forEach(change => {
136
139
  decorations.push(createInlineChangedDecoration(change, colourScheme));
137
140
  });
141
+ getAttrChangeRanges(tr.doc, rawSteps).forEach(change => {
142
+ decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme));
143
+ });
138
144
  return DecorationSet.empty.add(tr.doc, decorations);
139
145
  };
140
146
  export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner,
@@ -142,13 +148,15 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
142
148
  ([{
143
149
  pluginState,
144
150
  state,
145
- colourScheme
151
+ colourScheme,
152
+ intl
146
153
  }], [{
147
154
  pluginState: lastPluginState,
148
155
  state: lastState,
149
- colourScheme: lastColourScheme
156
+ colourScheme: lastColourScheme,
157
+ intl: lastIntl
150
158
  }]) => {
151
159
  var _ref;
152
160
  const originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
153
- return (_ref = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colourScheme === lastColourScheme) !== null && _ref !== void 0 ? _ref : false;
161
+ return (_ref = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colourScheme === lastColourScheme && intl.locale === lastIntl.locale) !== null && _ref !== void 0 ? _ref : false;
154
162
  });