@atlaskit/editor-plugin-show-diff 10.7.0 → 10.7.2

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 10.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 10.7.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`f8eddc13a614d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f8eddc13a614d) -
14
+ Resolve inline anchor positions into inline content depending on if delete widget is rendered to
15
+ prevent indicators extending at the top
16
+ - Updated dependencies
17
+
3
18
  ## 10.7.0
4
19
 
5
20
  ### Minor Changes
@@ -255,6 +255,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
255
255
  // emit ONE inline decoration per leaf text-bearing block within the range — the text
256
256
  // gets highlighted, and structural gaps never do.
257
257
  var isSmartNodeLevel = diffType === 'smart' && (0, _platformFeatureFlags.fg)('platform_editor_ai_smart_diff') && (0, _helpers.smartChangeLevel)(change) === 'node';
258
+ // Whether the deleted-content widget will actually be rendered for this
259
+ // change. Used to decide if indicator anchor positions should be adjusted
260
+ // inward — when the widget is present the anchor must stay at the block
261
+ // boundary to keep the indicator bar continuous with the deleted content.
262
+ var willRenderDeletedWidget = change.deleted.length > 0 && !((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && !isInverted && (hideDeletedDiffs || showGranularWithBlock) && change.inserted.length > 0);
258
263
  if (isSmartNodeLevel) {
259
264
  var _iterator2 = _createForOfIteratorHelper(leafTextblockRanges(tr.doc, change.fromB, change.toB)),
260
265
  _step2;
@@ -276,7 +281,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
276
281
  isInserted: isInserted,
277
282
  shouldHideDeleted: shouldHideDeleted,
278
283
  showIndicators: showIndicators,
279
- hideAddedDiffsUnderline: hideAddedDiffsUnderline
284
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline,
285
+ hasDeletedWidget: willRenderDeletedWidget
280
286
  }))));
281
287
  }
282
288
  } catch (err) {
@@ -295,7 +301,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
295
301
  isInserted: isInserted,
296
302
  shouldHideDeleted: shouldHideDeleted,
297
303
  showIndicators: showIndicators,
298
- hideAddedDiffsUnderline: hideAddedDiffsUnderline
304
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline,
305
+ hasDeletedWidget: willRenderDeletedWidget
299
306
  }))));
300
307
  }
301
308
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
@@ -53,7 +53,9 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
53
53
  diffType = _ref.diffType,
54
54
  _ref$hideAddedDiffsUn = _ref.hideAddedDiffsUnderline,
55
55
  hideAddedDiffsUnderline = _ref$hideAddedDiffsUn === void 0 ? false : _ref$hideAddedDiffsUn,
56
- inlineNodeName = _ref.inlineNodeName;
56
+ inlineNodeName = _ref.inlineNodeName,
57
+ _ref$hasDeletedWidget = _ref.hasDeletedWidget,
58
+ hasDeletedWidget = _ref$hasDeletedWidget === void 0 ? false : _ref$hasDeletedWidget;
57
59
  var diffId = crypto.randomUUID();
58
60
  if (shouldHideDeleted) {
59
61
  return [_view.Decoration.inline(change.fromB, change.toB, {
@@ -104,10 +106,28 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
104
106
  isActive: isActive
105
107
  }))];
106
108
  if (showIndicators && doc && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
109
+ // For paragraphs, fromB/toB land on the outer block
110
+ // boundary. Adjust anchor widgets into inline content so the indicator
111
+ // bar doesn't extend into the preceding block's margin.
112
+ // Skip when the deleted-content widget is rendered — the anchor must
113
+ // stay at the boundary to keep the indicator continuous.
114
+ var anchorFrom = change.fromB;
115
+ var anchorTo = change.toB;
116
+ if (!hasDeletedWidget) {
117
+ var _$from$nodeAfter, _$to$nodeBefore;
118
+ var $from = doc.resolve(anchorFrom);
119
+ if (!$from.parent.inlineContent && (_$from$nodeAfter = $from.nodeAfter) !== null && _$from$nodeAfter !== void 0 && _$from$nodeAfter.isTextblock) {
120
+ anchorFrom = anchorFrom + 1;
121
+ }
122
+ var $to = doc.resolve(anchorTo);
123
+ if (!$to.parent.inlineContent && (_$to$nodeBefore = $to.nodeBefore) !== null && _$to$nodeBefore !== void 0 && _$to$nodeBefore.isTextblock) {
124
+ anchorTo = anchorTo - 1;
125
+ }
126
+ }
107
127
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createAnchorDecorationWidgets.createInlineIndicatorAnchorWidgets)({
108
128
  doc: doc,
109
- from: change.fromB,
110
- to: change.toB,
129
+ from: anchorFrom,
130
+ to: anchorTo,
111
131
  diffId: diffId
112
132
  })));
113
133
  }
@@ -1,4 +1,4 @@
1
- /* IndicatorBar.tsx generated by @compiled/babel-plugin v0.40.0 */
1
+ /* IndicatorBar.tsx generated by @compiled/babel-plugin v2.0.0 */
2
2
  "use strict";
3
3
 
4
4
  var _typeof = require("@babel/runtime/helpers/typeof");
@@ -1,4 +1,4 @@
1
- /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v0.40.0 */
1
+ /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v2.0.0 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -229,6 +229,11 @@ const calculateDiffDecorationsInner = ({
229
229
  // emit ONE inline decoration per leaf text-bearing block within the range — the text
230
230
  // gets highlighted, and structural gaps never do.
231
231
  const isSmartNodeLevel = diffType === 'smart' && fg('platform_editor_ai_smart_diff') && smartChangeLevel(change) === 'node';
232
+ // Whether the deleted-content widget will actually be rendered for this
233
+ // change. Used to decide if indicator anchor positions should be adjusted
234
+ // inward — when the widget is present the anchor must stay at the block
235
+ // boundary to keep the indicator bar continuous with the deleted content.
236
+ const willRenderDeletedWidget = change.deleted.length > 0 && !(isExtendedEnabled(diffType) && !isInverted && (hideDeletedDiffs || showGranularWithBlock) && change.inserted.length > 0);
232
237
  if (isSmartNodeLevel) {
233
238
  for (const [from, to] of leafTextblockRanges(tr.doc, change.fromB, change.toB)) {
234
239
  decorations.push(...createInlineChangedDecoration({
@@ -244,7 +249,8 @@ const calculateDiffDecorationsInner = ({
244
249
  isInserted,
245
250
  shouldHideDeleted,
246
251
  showIndicators,
247
- hideAddedDiffsUnderline
252
+ hideAddedDiffsUnderline,
253
+ hasDeletedWidget: willRenderDeletedWidget
248
254
  })
249
255
  }));
250
256
  }
@@ -259,7 +265,8 @@ const calculateDiffDecorationsInner = ({
259
265
  isInserted,
260
266
  shouldHideDeleted,
261
267
  showIndicators,
262
- hideAddedDiffsUnderline
268
+ hideAddedDiffsUnderline,
269
+ hasDeletedWidget: willRenderDeletedWidget
263
270
  })
264
271
  }));
265
272
  }
@@ -36,7 +36,8 @@ export const createInlineChangedDecoration = ({
36
36
  doc,
37
37
  diffType,
38
38
  hideAddedDiffsUnderline = false,
39
- inlineNodeName
39
+ inlineNodeName,
40
+ hasDeletedWidget = false
40
41
  }) => {
41
42
  const diffId = crypto.randomUUID();
42
43
  if (shouldHideDeleted) {
@@ -88,10 +89,28 @@ export const createInlineChangedDecoration = ({
88
89
  isActive
89
90
  }))];
90
91
  if (showIndicators && doc && isExtendedEnabled(diffType)) {
92
+ // For paragraphs, fromB/toB land on the outer block
93
+ // boundary. Adjust anchor widgets into inline content so the indicator
94
+ // bar doesn't extend into the preceding block's margin.
95
+ // Skip when the deleted-content widget is rendered — the anchor must
96
+ // stay at the boundary to keep the indicator continuous.
97
+ let anchorFrom = change.fromB;
98
+ let anchorTo = change.toB;
99
+ if (!hasDeletedWidget) {
100
+ var _$from$nodeAfter, _$to$nodeBefore;
101
+ const $from = doc.resolve(anchorFrom);
102
+ if (!$from.parent.inlineContent && (_$from$nodeAfter = $from.nodeAfter) !== null && _$from$nodeAfter !== void 0 && _$from$nodeAfter.isTextblock) {
103
+ anchorFrom = anchorFrom + 1;
104
+ }
105
+ const $to = doc.resolve(anchorTo);
106
+ if (!$to.parent.inlineContent && (_$to$nodeBefore = $to.nodeBefore) !== null && _$to$nodeBefore !== void 0 && _$to$nodeBefore.isTextblock) {
107
+ anchorTo = anchorTo - 1;
108
+ }
109
+ }
91
110
  decorations.push(...createInlineIndicatorAnchorWidgets({
92
111
  doc,
93
- from: change.fromB,
94
- to: change.toB,
112
+ from: anchorFrom,
113
+ to: anchorTo,
95
114
  diffId
96
115
  }));
97
116
  }
@@ -1,4 +1,4 @@
1
- /* IndicatorBar.tsx generated by @compiled/babel-plugin v0.40.0 */
1
+ /* IndicatorBar.tsx generated by @compiled/babel-plugin v2.0.0 */
2
2
  import "./IndicatorBar.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,4 @@
1
- /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v0.40.0 */
1
+ /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v2.0.0 */
2
2
  import { ax, ix } from "@compiled/react/runtime";
3
3
  import React from 'react';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
@@ -249,6 +249,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
249
249
  // emit ONE inline decoration per leaf text-bearing block within the range — the text
250
250
  // gets highlighted, and structural gaps never do.
251
251
  var isSmartNodeLevel = diffType === 'smart' && fg('platform_editor_ai_smart_diff') && smartChangeLevel(change) === 'node';
252
+ // Whether the deleted-content widget will actually be rendered for this
253
+ // change. Used to decide if indicator anchor positions should be adjusted
254
+ // inward — when the widget is present the anchor must stay at the block
255
+ // boundary to keep the indicator bar continuous with the deleted content.
256
+ var willRenderDeletedWidget = change.deleted.length > 0 && !(isExtendedEnabled(diffType) && !isInverted && (hideDeletedDiffs || showGranularWithBlock) && change.inserted.length > 0);
252
257
  if (isSmartNodeLevel) {
253
258
  var _iterator2 = _createForOfIteratorHelper(leafTextblockRanges(tr.doc, change.fromB, change.toB)),
254
259
  _step2;
@@ -270,7 +275,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
270
275
  isInserted: isInserted,
271
276
  shouldHideDeleted: shouldHideDeleted,
272
277
  showIndicators: showIndicators,
273
- hideAddedDiffsUnderline: hideAddedDiffsUnderline
278
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline,
279
+ hasDeletedWidget: willRenderDeletedWidget
274
280
  }))));
275
281
  }
276
282
  } catch (err) {
@@ -289,7 +295,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
289
295
  isInserted: isInserted,
290
296
  shouldHideDeleted: shouldHideDeleted,
291
297
  showIndicators: showIndicators,
292
- hideAddedDiffsUnderline: hideAddedDiffsUnderline
298
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline,
299
+ hasDeletedWidget: willRenderDeletedWidget
293
300
  }))));
294
301
  }
295
302
  decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
@@ -46,7 +46,9 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
46
46
  diffType = _ref.diffType,
47
47
  _ref$hideAddedDiffsUn = _ref.hideAddedDiffsUnderline,
48
48
  hideAddedDiffsUnderline = _ref$hideAddedDiffsUn === void 0 ? false : _ref$hideAddedDiffsUn,
49
- inlineNodeName = _ref.inlineNodeName;
49
+ inlineNodeName = _ref.inlineNodeName,
50
+ _ref$hasDeletedWidget = _ref.hasDeletedWidget,
51
+ hasDeletedWidget = _ref$hasDeletedWidget === void 0 ? false : _ref$hasDeletedWidget;
50
52
  var diffId = crypto.randomUUID();
51
53
  if (shouldHideDeleted) {
52
54
  return [Decoration.inline(change.fromB, change.toB, {
@@ -97,10 +99,28 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
97
99
  isActive: isActive
98
100
  }))];
99
101
  if (showIndicators && doc && isExtendedEnabled(diffType)) {
102
+ // For paragraphs, fromB/toB land on the outer block
103
+ // boundary. Adjust anchor widgets into inline content so the indicator
104
+ // bar doesn't extend into the preceding block's margin.
105
+ // Skip when the deleted-content widget is rendered — the anchor must
106
+ // stay at the boundary to keep the indicator continuous.
107
+ var anchorFrom = change.fromB;
108
+ var anchorTo = change.toB;
109
+ if (!hasDeletedWidget) {
110
+ var _$from$nodeAfter, _$to$nodeBefore;
111
+ var $from = doc.resolve(anchorFrom);
112
+ if (!$from.parent.inlineContent && (_$from$nodeAfter = $from.nodeAfter) !== null && _$from$nodeAfter !== void 0 && _$from$nodeAfter.isTextblock) {
113
+ anchorFrom = anchorFrom + 1;
114
+ }
115
+ var $to = doc.resolve(anchorTo);
116
+ if (!$to.parent.inlineContent && (_$to$nodeBefore = $to.nodeBefore) !== null && _$to$nodeBefore !== void 0 && _$to$nodeBefore.isTextblock) {
117
+ anchorTo = anchorTo - 1;
118
+ }
119
+ }
100
120
  decorations.push.apply(decorations, _toConsumableArray(createInlineIndicatorAnchorWidgets({
101
121
  doc: doc,
102
- from: change.fromB,
103
- to: change.toB,
122
+ from: anchorFrom,
123
+ to: anchorTo,
104
124
  diffId: diffId
105
125
  })));
106
126
  }
@@ -1,4 +1,4 @@
1
- /* IndicatorBar.tsx generated by @compiled/babel-plugin v0.40.0 */
1
+ /* IndicatorBar.tsx generated by @compiled/babel-plugin v2.0.0 */
2
2
  import "./IndicatorBar.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,4 @@
1
- /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v0.40.0 */
1
+ /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v2.0.0 */
2
2
  import { ax, ix } from "@compiled/react/runtime";
3
3
  import React from 'react';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
@@ -8,7 +8,7 @@ import type { InlineAttrChangeNodeName } from './utils/getAttrChangeRanges';
8
8
  * @param change Changeset "change" containing information about the change content + range
9
9
  * @returns Prosemirror inline decoration
10
10
  */
11
- export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, isAtomicInlineNode, shouldHideDeleted, showIndicators, doc, diffType, hideAddedDiffsUnderline, inlineNodeName, }: {
11
+ export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, isAtomicInlineNode, shouldHideDeleted, showIndicators, doc, diffType, hideAddedDiffsUnderline, inlineNodeName, hasDeletedWidget, }: {
12
12
  change: {
13
13
  fromB: number;
14
14
  toB: number;
@@ -16,6 +16,7 @@ export declare const createInlineChangedDecoration: ({ change, colorScheme, isAc
16
16
  colorScheme?: ColorScheme;
17
17
  diffType?: DiffType;
18
18
  doc?: PMNode;
19
+ hasDeletedWidget?: boolean;
19
20
  hideAddedDiffsUnderline?: boolean;
20
21
  inlineNodeName?: InlineAttrChangeNodeName;
21
22
  isActive?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "10.7.0",
3
+ "version": "10.7.2",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -20,7 +20,7 @@
20
20
  "sideEffects": false,
21
21
  "atlaskit:src": "src/index.ts",
22
22
  "dependencies": {
23
- "@atlaskit/adf-schema": "^56.2.0",
23
+ "@atlaskit/adf-schema": "^56.4.0",
24
24
  "@atlaskit/custom-steps": "^1.0.0",
25
25
  "@atlaskit/editor-plugin-analytics": "^12.1.0",
26
26
  "@atlaskit/editor-plugin-expand": "^13.2.0",
@@ -28,7 +28,7 @@
28
28
  "@atlaskit/editor-prosemirror": "^8.0.0",
29
29
  "@atlaskit/editor-tables": "^3.0.0",
30
30
  "@atlaskit/platform-feature-flags": "^2.1.0",
31
- "@atlaskit/tmp-editor-statsig": "^135.7.0",
31
+ "@atlaskit/tmp-editor-statsig": "^136.0.0",
32
32
  "@atlaskit/tokens": "^16.3.0",
33
33
  "@babel/runtime": "^7.0.0",
34
34
  "@compiled/react": "^1.0.0",
@@ -38,10 +38,10 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@atlaskit/adf-utils": "^20.4.0",
41
- "@atlaskit/button": "^24.3.0",
41
+ "@atlaskit/button": "^25.0.0",
42
42
  "@atlaskit/css": "^1.0.0",
43
43
  "@atlaskit/dropdown-menu": "^17.2.0",
44
- "@atlaskit/editor-core": "^221.16.0",
44
+ "@atlaskit/editor-core": "^221.17.0",
45
45
  "@atlaskit/editor-json-transformer": "^9.2.0",
46
46
  "@atlaskit/form": "^16.1.0",
47
47
  "@atlaskit/primitives": "^22.2.0",
@@ -54,7 +54,7 @@
54
54
  "react-intl": "^7.0.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "@atlaskit/editor-common": "^116.45.0",
57
+ "@atlaskit/editor-common": "^116.48.0",
58
58
  "react": "^18.2.0 || ^19.2.0"
59
59
  },
60
60
  "techstack": {