@atlaskit/editor-plugin-show-diff 24.0.0 → 24.0.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +1 -9
  3. package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +16 -3
  4. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +16 -4
  5. package/dist/cjs/pm-plugins/decorations/decorationKeys.js +9 -1
  6. package/dist/cjs/pm-plugins/decorations/extractContributorTags.js +41 -23
  7. package/dist/cjs/pm-plugins/decorations/utils/getWidgetElement.js +16 -0
  8. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +10 -0
  9. package/dist/cjs/pm-plugins/getDeletedWidgets.js +2 -12
  10. package/dist/cjs/pm-plugins/main.js +26 -0
  11. package/dist/cjs/pm-plugins/utils/taggableBlockNodes.js +1 -1
  12. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +1 -5
  13. package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +16 -3
  14. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +20 -10
  15. package/dist/es2019/pm-plugins/decorations/decorationKeys.js +7 -0
  16. package/dist/es2019/pm-plugins/decorations/extractContributorTags.js +22 -2
  17. package/dist/es2019/pm-plugins/decorations/utils/getWidgetElement.js +11 -0
  18. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +10 -0
  19. package/dist/es2019/pm-plugins/getDeletedWidgets.js +1 -12
  20. package/dist/es2019/pm-plugins/main.js +26 -0
  21. package/dist/es2019/pm-plugins/utils/taggableBlockNodes.js +1 -1
  22. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +1 -9
  23. package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +16 -3
  24. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +16 -4
  25. package/dist/esm/pm-plugins/decorations/decorationKeys.js +9 -1
  26. package/dist/esm/pm-plugins/decorations/extractContributorTags.js +41 -23
  27. package/dist/esm/pm-plugins/decorations/utils/getWidgetElement.js +10 -0
  28. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +10 -0
  29. package/dist/esm/pm-plugins/getDeletedWidgets.js +1 -11
  30. package/dist/esm/pm-plugins/main.js +26 -0
  31. package/dist/esm/pm-plugins/utils/taggableBlockNodes.js +1 -1
  32. package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +2 -0
  33. package/dist/types/pm-plugins/decorations/utils/getWidgetElement.d.ts +2 -0
  34. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 24.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`646c02ae8de28`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/646c02ae8de28) -
8
+ Fix contributor tag and step mismatch in show diff: the spacer widget no longer becomes an
9
+ untagged navigation stop when contributor tags are shown, and block cards inside a table now carry
10
+ attribution.
11
+ - [`7b18b1db6b6d3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7b18b1db6b6d3) -
12
+ EDITOR-9415 Allow native browser selection and copying within diff widgets behind
13
+ platform_editor_ai_show_diff_patch_2
14
+
15
+ ## 24.0.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`37fc21aa0e358`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/37fc21aa0e358) -
20
+ Show contributor tags for layout changes in version history when
21
+ `confluence_ncs_step_diffing_version_history` is enabled
22
+ - Updated dependencies
23
+
3
24
  ## 24.0.0
4
25
 
5
26
  ### Patch Changes
@@ -8,7 +8,6 @@ exports.createBlockChangedDecoration = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
11
- var _utils = require("@atlaskit/editor-prosemirror/utils");
12
11
  var _view = require("@atlaskit/editor-prosemirror/view");
13
12
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
14
13
  var _fg = require("@atlaskit/platform-feature-flags/fg");
@@ -34,13 +33,6 @@ var UNSTYLED_NODES = ['mediaSingle', 'mediaGroup', 'table',
34
33
  'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'];
35
34
  var CELL_NODES = ['tableCell', 'tableHeader'];
36
35
 
37
- /** Panels, rules and media can also sit in a table cell, which is out of scope for block tags. */
38
- var isInsideTable = function isInsideTable(doc, pos) {
39
- return (0, _utils.findParentNodeClosestToPos)(doc.resolve(pos), function (node) {
40
- return node.type.name === 'table';
41
- }) !== undefined;
42
- };
43
-
44
36
  /**
45
37
  * Whether this block can host a contributor tag of its own.
46
38
  *
@@ -56,7 +48,7 @@ var canTagBlock = function canTagBlock(_ref) {
56
48
  return false;
57
49
  }
58
50
  var nodeType = (_doc$nodeAt = doc.nodeAt(from)) === null || _doc$nodeAt === void 0 ? void 0 : _doc$nodeAt.type;
59
- return nodeType !== undefined && (0, _taggableBlockNodes.isTaggableBlockNode)(nodeType) && !isInsideTable(doc, from);
51
+ return nodeType !== undefined && (0, _taggableBlockNodes.isTaggableBlockNode)(nodeType);
60
52
  };
61
53
 
62
54
  /** Positioning context for the cell overlay widget decorations. */
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _view = require("@atlaskit/editor-prosemirror/view");
10
10
  var _fg = require("@atlaskit/platform-feature-flags/fg");
11
11
  var _contributorTagController = require("../../ui/ContributorTag/contributorTagController");
12
+ var _baseNodeName = require("../utils/baseNodeName");
12
13
  var _charsByOffset = require("../utils/charsByOffset");
13
14
  var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
14
15
  var _decorationKeys = require("./decorationKeys");
@@ -219,6 +220,16 @@ var resolveHoistedCodeBlockAnchor = exports.resolveHoistedCodeBlockAnchor = func
219
220
  };
220
221
  };
221
222
 
223
+ /** Find the position before a layout for a tag anchored to one of its columns. */
224
+ var resolveLayoutSectionStart = function resolveLayoutSectionStart(doc, pos) {
225
+ var _doc$nodeAt$type$name, _doc$nodeAt;
226
+ if ((0, _baseNodeName.resolveBaseNodeName)((_doc$nodeAt$type$name = (_doc$nodeAt = doc.nodeAt(pos)) === null || _doc$nodeAt === void 0 ? void 0 : _doc$nodeAt.type.name) !== null && _doc$nodeAt$type$name !== void 0 ? _doc$nodeAt$type$name : '') !== 'layoutColumn') {
227
+ return undefined;
228
+ }
229
+ var $pos = doc.resolve(pos);
230
+ return (0, _baseNodeName.resolveBaseNodeName)($pos.parent.type.name) === 'layoutSection' ? $pos.before($pos.depth) : undefined;
231
+ };
232
+
222
233
  /**
223
234
  * The contributor tag widget for one diff range, placed on the first visible character the range
224
235
  * highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
@@ -231,7 +242,7 @@ var resolveHoistedCodeBlockAnchor = exports.resolveHoistedCodeBlockAnchor = func
231
242
  * element ProseMirror drew it into — see `mountContributorTag`.
232
243
  */
233
244
  var createContributorTagWidget = exports.createContributorTagWidget = function createContributorTagWidget(_ref4) {
234
- var _hoisted$codeBlockSta, _ref5, _hoisted$anchorName;
245
+ var _ref5, _hoisted$anchorName, _hoisted$codeBlockSta;
235
246
  var _ref4$anchorAtRangeSt = _ref4.anchorAtRangeStart,
236
247
  anchorAtRangeStart = _ref4$anchorAtRangeSt === void 0 ? false : _ref4$anchorAtRangeSt,
237
248
  anchorName = _ref4.anchorName,
@@ -251,8 +262,6 @@ var createContributorTagWidget = exports.createContributorTagWidget = function c
251
262
  // A change inside a code block is hoisted out of it, anchored to its own marker; anything else
252
263
  // keeps its own anchor.
253
264
  var hoisted = resolveHoistedCodeBlockAnchor(doc, anchorPos, diffId);
254
- // Keep the host out of the table row's grid (EDITOR-8442).
255
- var hostPos = (0, _createAnchorDecorationWidgets.clampAnchorPosIntoCell)(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1);
256
265
 
257
266
  // Inline diffs pass no anchorName. Give them their own point anchor instead of the
258
267
  // `position: relative` fallback, which drifts left once the range wraps a line (EDITOR-9286).
@@ -262,6 +271,10 @@ var createContributorTagWidget = exports.createContributorTagWidget = function c
262
271
  });
263
272
  var effectiveAnchorName = (_ref5 = (_hoisted$anchorName = hoisted === null || hoisted === void 0 ? void 0 : hoisted.anchorName) !== null && _hoisted$anchorName !== void 0 ? _hoisted$anchorName : anchorName) !== null && _ref5 !== void 0 ? _ref5 : ownAnchorName;
264
273
  var tagAnchorName = effectiveAnchorName && supportsAnchorPositioning() ? effectiveAnchorName : undefined;
274
+ var layoutSectionStart = tagAnchorName ? resolveLayoutSectionStart(doc, anchorPos) : undefined;
275
+ // Keep the host out of the table row's grid (EDITOR-8442). Layout-column tags are hoisted before
276
+ // their layout so the advanced layout widget-flattening rule cannot put them behind nearby text.
277
+ var hostPos = layoutSectionStart !== null && layoutSectionStart !== void 0 ? layoutSectionStart : (0, _createAnchorDecorationWidgets.clampAnchorPosIntoCell)(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1);
265
278
  var decorations = [];
266
279
  if (hoisted) {
267
280
  decorations.push(hoisted.marker);
@@ -8,6 +8,7 @@ exports.createNodeChangedDecorationWidget = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _view = require("@atlaskit/editor-prosemirror/view");
10
10
  var _fg = require("@atlaskit/platform-feature-flags/fg");
11
+ var _baseNodeName = require("../utils/baseNodeName");
11
12
  var _emptyTextBlocks = require("../utils/emptyTextBlocks");
12
13
  var _isEmptyParagraphSlice = require("../utils/isEmptyParagraphSlice");
13
14
  var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
@@ -124,7 +125,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
124
125
  * that is not in the current document.
125
126
  */
126
127
  var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
127
- var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
128
+ var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _hoistedCodeBlockAnch, _slice$content$firstC2;
128
129
  var attributionKey = _ref2.attributionKey,
129
130
  change = _ref2.change,
130
131
  doc = _ref2.doc,
@@ -280,6 +281,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
280
281
  // Match the rendering predicate above: an empty paragraph has no widget to tag, while whitespace
281
282
  // text in a rendered widget remains eligible.
282
283
  var canTagWidget = showContributorTags && !shouldSkipDeletedEmptyParagraphDecoration;
284
+ var contributorTagAnchorName;
283
285
  var decorations = [];
284
286
  var replacementNode = newDoc.nodeAt(change.fromB);
285
287
  var firstReplacedNode = slice.content.firstChild;
@@ -380,6 +382,14 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
380
382
  var $sourcePos = (0, _fg.fg)('platform_editor_ai_show_diff_patch_2') ? getSourcePos(doc, $changeFromA, slice.openStart, index) : null;
381
383
  var nodeView = serializer.tryCreateNodeView(node, 0, $sourcePos !== null && $sourcePos !== void 0 ? $sourcePos : undefined, isInserted, colorScheme);
382
384
  if (nodeView) {
385
+ if (canTagWidget && contributorTagAnchorName === undefined && (0, _baseNodeName.resolveBaseNodeName)(node.type.name) === 'layoutColumn' && nodeView instanceof HTMLElement && (0, _fg.fg)('confluence_ncs_step_diffing_version_history')) {
386
+ // The deleted column is rendered inside this widget; anchor to its box.
387
+ contributorTagAnchorName = (0, _decorationKeys.buildAnchorDecorationKey)({
388
+ diffId: diffId,
389
+ anchorType: _decorationKeys.AnchorTypeKey.tag
390
+ });
391
+ nodeView.style.setProperty('anchor-name', "--".concat(contributorTagAnchorName));
392
+ }
383
393
  if (node.isInline) {
384
394
  var wrapper = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted, reveal);
385
395
  wrapper.append(nodeView);
@@ -427,7 +437,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
427
437
  if (hoistedCodeBlockAnchor) {
428
438
  decorations.push(hoistedCodeBlockAnchor.marker);
429
439
  }
430
- var contributorTagAnchorName = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName;
440
+ contributorTagAnchorName = (_hoistedCodeBlockAnch = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName) !== null && _hoistedCodeBlockAnch !== void 0 ? _hoistedCodeBlockAnch : contributorTagAnchorName;
431
441
  if (!isInserted && deletedColumns !== null && deletedColumns !== void 0 && deletedColumns.length) {
432
442
  var table = dom.querySelector('table');
433
443
  var firstRow = table === null || table === void 0 ? void 0 : table.rows[0];
@@ -647,12 +657,14 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
647
657
  if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
648
658
  defaultSpacer.style.setProperty('scroll-margin-top', _decorationKeys.scrollMarginTopValue);
649
659
  }
650
- decorations.push(_view.Decoration.widget(safeInsertPos, defaultSpacer, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
660
+ decorations.push(_view.Decoration.widget(safeInsertPos, defaultSpacer,
661
+ // Spacing only: a diff spec would make it an untagged navigation stop.
662
+ showContributorTags ? {} : (0, _decorationKeys.buildDiffDecorationSpec)({
651
663
  colorScheme: colorScheme,
652
664
  decorationType: 'widget',
653
665
  diffId: crypto.randomUUID(),
654
666
  isInserted: isInserted
655
- }))));
667
+ })));
656
668
  }
657
669
  }
658
670
  return decorations;
@@ -9,6 +9,7 @@ exports.buildAnchorDecorationSpec = buildAnchorDecorationSpec;
9
9
  exports.scrollMarginTopValue = exports.scrollMarginTopStyle = exports.isDiffDecorationSpec = exports.isDiffDecoration = exports.isAnchorDecorationSpec = exports.extractDiffDescriptors = exports.buildDiffDecorationSpec = exports.buildDiffDecorationKey = exports.buildContributorTagDecorationSpec = void 0;
10
10
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
12
13
  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; }
13
14
  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; }
14
15
  /**
@@ -81,7 +82,7 @@ var buildDiffDecorationSpec = exports.buildDiffDecorationSpec = function buildDi
81
82
  leftAnchorId = _ref3.leftAnchorId,
82
83
  nodeName = _ref3.nodeName,
83
84
  side = _ref3.side;
84
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
85
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
85
86
  decorationFamily: DecorationFamily.diff,
86
87
  decorationType: decorationType,
87
88
  diffId: diffId,
@@ -104,6 +105,13 @@ var buildDiffDecorationSpec = exports.buildDiffDecorationSpec = function buildDi
104
105
  nodeName: nodeName
105
106
  } : {}), side !== undefined ? {
106
107
  side: side
108
+ } : {}), decorationType === 'widget' && (0, _fg.fg)('platform_editor_ai_show_diff_patch_2') ? {
109
+ // Widget content is outside the document. Keep its native DOM selection
110
+ // and let the browser handle events within it.
111
+ ignoreSelection: true,
112
+ stopEvent: function stopEvent() {
113
+ return true;
114
+ }
107
115
  } : {});
108
116
  };
109
117
  function buildAnchorDecorationSpec(_ref4) {
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.extractContributorTags = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
10
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
11
  var _fg = require("@atlaskit/platform-feature-flags/fg");
12
+ var _baseNodeName = require("../utils/baseNodeName");
13
13
  var _decorationKeys = require("./decorationKeys");
14
14
  var _excluded = ["connectedToKey"];
15
15
  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; }
@@ -54,7 +54,10 @@ var leadsReplacement = function leadsReplacement(widget) {
54
54
  * inline/widget range that merely overlaps the block is a separate change (EDITOR-9473).
55
55
  */
56
56
  var isSameBlockChange = function isSameBlockChange(inner, block) {
57
- return inner.spec.attributionKey === block.spec.attributionKey && block.from <= inner.from && inner.to <= block.to;
57
+ return inner.spec.attributionKey === block.spec.attributionKey && (inner.spec.decorationType === 'widget' ?
58
+ // Deleted content is zero-width and sits at the start of what replaced it, so a widget at the
59
+ // block's edge is beside the block rather than within it and keeps its own tag.
60
+ block.from < inner.from && inner.to < block.to : block.from <= inner.from && inner.to <= block.to);
58
61
  };
59
62
 
60
63
  /**
@@ -75,12 +78,27 @@ var byLeadingPosition = function byLeadingPosition(a, b) {
75
78
  return a.decoration.from - b.decoration.from || ((_a$decoration$spec$si = a.decoration.spec.side) !== null && _a$decoration$spec$si !== void 0 ? _a$decoration$spec$si : 0) - ((_b$decoration$spec$si = b.decoration.spec.side) !== null && _b$decoration$spec$si !== void 0 ? _b$decoration$spec$si : 0) || a.decoration.to - a.decoration.from - (b.decoration.to - b.decoration.from);
76
79
  };
77
80
 
78
- /** The targets a navigation range wholly covers, leader first. */
79
- var containedBy = function containedBy(targets, _ref2) {
80
- var from = _ref2.from,
81
- to = _ref2.to;
82
- return targets.filter(function (_ref3) {
81
+ /** Select the first layout column only when the inline layout range starts immediately before it. */
82
+ var navigationLeader = function navigationLeader(members) {
83
+ var ordered = (0, _toConsumableArray2.default)(members).sort(byLeadingPosition);
84
+ var layoutColumn = (0, _fg.fg)('confluence_ncs_step_diffing_version_history') ? ordered.find(function (_ref2) {
85
+ var _decoration$spec$node;
86
+ var decoration = _ref2.decoration;
87
+ return decoration.spec.decorationType === 'block' && (0, _baseNodeName.resolveBaseNodeName)((_decoration$spec$node = decoration.spec.nodeName) !== null && _decoration$spec$node !== void 0 ? _decoration$spec$node : '') === 'layoutColumn';
88
+ }) : undefined;
89
+ var startsWholeLayout = layoutColumn !== undefined && members.some(function (_ref3) {
83
90
  var decoration = _ref3.decoration;
91
+ return decoration.spec.decorationType === 'inline' && decoration.from === layoutColumn.decoration.from - 1;
92
+ });
93
+ return startsWholeLayout ? layoutColumn : ordered[0];
94
+ };
95
+
96
+ /** The targets a navigation range wholly covers, leader first. */
97
+ var containedBy = function containedBy(targets, _ref4) {
98
+ var from = _ref4.from,
99
+ to = _ref4.to;
100
+ return targets.filter(function (_ref5) {
101
+ var decoration = _ref5.decoration;
84
102
  return from <= decoration.from && decoration.to <= to;
85
103
  }).sort(byLeadingPosition);
86
104
  };
@@ -154,16 +172,16 @@ var extractContributorTags = exports.extractContributorTags = function extractCo
154
172
  } finally {
155
173
  _iterator.f();
156
174
  }
157
- var inlineTargets = targets.filter(function (_ref4) {
158
- var decoration = _ref4.decoration;
175
+ var inlineTargets = targets.filter(function (_ref6) {
176
+ var decoration = _ref6.decoration;
159
177
  return decoration.spec.decorationType === 'inline';
160
178
  });
161
- var blockTargets = targets.filter(function (_ref5) {
162
- var decoration = _ref5.decoration;
179
+ var blockTargets = targets.filter(function (_ref7) {
180
+ var decoration = _ref7.decoration;
163
181
  return decoration.spec.decorationType === 'block';
164
182
  });
165
- var widgetTargets = targets.filter(function (_ref6) {
166
- var decoration = _ref6.decoration;
183
+ var widgetTargets = targets.filter(function (_ref8) {
184
+ var decoration = _ref8.decoration;
167
185
  return decoration.spec.decorationType === 'widget';
168
186
  });
169
187
  var linkedDiffIds = new Map();
@@ -191,8 +209,8 @@ var extractContributorTags = exports.extractContributorTags = function extractCo
191
209
  }
192
210
 
193
211
  // A block outranks both other kinds, so it is tried first.
194
- var block = blockTargets.find(function (_ref7) {
195
- var decoration = _ref7.decoration;
212
+ var block = blockTargets.find(function (_ref9) {
213
+ var decoration = _ref9.decoration;
196
214
  return isSameBlockChange(target.decoration, decoration);
197
215
  });
198
216
  if (block) {
@@ -201,8 +219,8 @@ var extractContributorTags = exports.extractContributorTags = function extractCo
201
219
  }
202
220
  if (decorationType === 'inline') {
203
221
  // The deleted half renders in front of this one, so that half captions the change.
204
- var leadingWidget = widgetTargets.find(function (_ref8) {
205
- var decoration = _ref8.decoration;
222
+ var leadingWidget = widgetTargets.find(function (_ref0) {
223
+ var decoration = _ref0.decoration;
206
224
  return leadsReplacement(decoration) && isSameChange(decoration, target.decoration);
207
225
  });
208
226
  if (leadingWidget) {
@@ -215,8 +233,8 @@ var extractContributorTags = exports.extractContributorTags = function extractCo
215
233
  if (leadsReplacement(target.decoration)) {
216
234
  return 0; // continue
217
235
  }
218
- var host = inlineTargets.find(function (_ref9) {
219
- var decoration = _ref9.decoration;
236
+ var host = inlineTargets.find(function (_ref1) {
237
+ var decoration = _ref1.decoration;
220
238
  return isSameChange(target.decoration, decoration);
221
239
  });
222
240
  if (host) {
@@ -320,10 +338,10 @@ var extractContributorTags = exports.extractContributorTags = function extractCo
320
338
  try {
321
339
  var _loop2 = function _loop2() {
322
340
  var members = _step6.value;
323
- var _sort = (0, _toConsumableArray2.default)(members).sort(byLeadingPosition),
324
- _sort2 = (0, _toArray2.default)(_sort),
325
- leader = _sort2[0],
326
- trailing = _arrayLikeToArray(_sort2).slice(1);
341
+ var leader = navigationLeader(members);
342
+ var trailing = members.filter(function (target) {
343
+ return target !== leader;
344
+ });
327
345
  trailing.forEach(function (target) {
328
346
  return fold(leader, target);
329
347
  });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getWidgetElement = void 0;
7
+ // prosemirror-view does not type `Decoration.type`; a widget's `type.toDOM` is the node passed to
8
+ // `Decoration.widget()` (an element or a factory — the `WidgetConstructor` union).
9
+
10
+ // The element a widget renders, or undefined if it renders via a factory.
11
+ var getWidgetElement = exports.getWidgetElement = function getWidgetElement(decoration) {
12
+ var _type;
13
+ var _ref = (_type = decoration.type) !== null && _type !== void 0 ? _type : {},
14
+ toDOM = _ref.toDOM;
15
+ return toDOM instanceof HTMLElement ? toDOM : undefined;
16
+ };
@@ -12,6 +12,7 @@ var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
12
12
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
13
13
  var _fg = require("@atlaskit/platform-feature-flags/fg");
14
14
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
+ var _baseNodeName = require("../../utils/baseNodeName");
15
16
  var _createInlineChangedDecoration = require("../createInlineChangedDecoration");
16
17
  var _revealStyles = require("../revealStyles");
17
18
  var _getAttrChangeRanges = require("./getAttrChangeRanges");
@@ -353,6 +354,15 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref9
353
354
  // should not also get the inline content style (borderBottom underline) on their container.
354
355
  var shouldSkipContentStyle = isInserted && nodeStyle !== undefined;
355
356
  var contentStyle = shouldSkipContentStyle ? '' : (0, _wrapBlockNodeViewStyles.getChangedContentStyle)(colorScheme, isActive, isInserted, hideAddedDiffsUnderline);
357
+ var isEmptyDeletedLayoutColumn = !isInserted && (0, _baseNodeName.resolveBaseNodeName)(targetNode.type.name) === 'layoutColumn' && targetNode.textContent.length === 0 && (0, _fg.fg)('confluence_ncs_step_diffing_version_history');
358
+ if (isEmptyDeletedLayoutColumn && nodeView instanceof HTMLElement) {
359
+ var _nodeView$querySelect;
360
+ // Give an empty deleted column height so its diff box doesn't collapse
361
+ var placeholderTarget = (_nodeView$querySelect = nodeView.querySelector('[data-layout-content]')) !== null && _nodeView$querySelect !== void 0 ? _nodeView$querySelect : nodeView;
362
+ appendStyleToElement(placeholderTarget, (0, _lazyNodeView.convertToInlineCss)({
363
+ minHeight: "var(--ds-space-300, 24px)"
364
+ }));
365
+ }
356
366
 
357
367
  // A `breakout` node renders wider than the editor column while the wrapper divs
358
368
  // stay at column width, so paint the outline on the node element that spans that width.
@@ -5,18 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getDeletedWidgets = void 0;
7
7
  var _decorationKeys = require("./decorations/decorationKeys");
8
+ var _getWidgetElement = require("./decorations/utils/getWidgetElement");
8
9
  var _main = require("./main");
9
- // prosemirror-view does not type `Decoration.type`; a widget's `type.toDOM` is the node passed to
10
- // `Decoration.widget()` (an element or a factory — the `WidgetConstructor` union).
11
-
12
- // The element a deleted-content widget renders, or undefined if it renders via a factory.
13
- var getWidgetElement = function getWidgetElement(decoration) {
14
- var _type;
15
- var _ref = (_type = decoration.type) !== null && _type !== void 0 ? _type : {},
16
- toDOM = _ref.toDOM;
17
- return toDOM instanceof HTMLElement ? toDOM : undefined;
18
- };
19
-
20
10
  /**
21
11
  * The rendered deleted-content widgets in `editorState`, optionally restricted to `[from, to]`,
22
12
  * ordered by position. Deleted content is rendered as widget decorations rather than document
@@ -34,7 +24,7 @@ var getDeletedWidgets = exports.getDeletedWidgets = function getDeletedWidgets(e
34
24
  return decorations.find(range === null || range === void 0 ? void 0 : range.from, range === null || range === void 0 ? void 0 : range.to, function (spec) {
35
25
  return (0, _decorationKeys.isDiffDecorationSpec)(spec) && spec.decorationType === 'widget';
36
26
  }).reduce(function (widgets, decoration) {
37
- var element = getWidgetElement(decoration);
27
+ var element = (0, _getWidgetElement.getWidgetElement)(decoration);
38
28
  if (element) {
39
29
  widgets.push({
40
30
  element: element,
@@ -16,6 +16,7 @@ var _fg = require("@atlaskit/platform-feature-flags/fg");
16
16
  var _announceActiveDiff = require("../ui/DiffNavigation/announceActiveDiff");
17
17
  var _calculateDiffDecorations = require("./calculateDiff/calculateDiffDecorations");
18
18
  var _decorationKeys = require("./decorations/decorationKeys");
19
+ var _getWidgetElement = require("./decorations/utils/getWidgetElement");
19
20
  var _enforceCustomStepRegisters = require("./enforceCustomStepRegisters");
20
21
  var _getDefaultDiffType = require("./getDefaultDiffType");
21
22
  var _getScrollableDecorations = require("./getScrollableDecorations");
@@ -306,6 +307,31 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
306
307
  };
307
308
  },
308
309
  props: {
310
+ handleDOMEvents: {
311
+ // Bypass ProseMirror's copy handler without preventing native browser copy
312
+ // when the selection is completely contained within an inverted diff widget
313
+ copy: function copy(view) {
314
+ if (!(0, _fg.fg)('platform_editor_ai_show_diff_patch_2')) {
315
+ return false;
316
+ }
317
+ var pluginState = showDiffPluginKey.getState(view.state);
318
+ if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDisplayingChanges) || !pluginState.isInverted) {
319
+ return false;
320
+ }
321
+ var selection = view.dom.ownerDocument.getSelection();
322
+ if (!selection || selection.isCollapsed || selection.rangeCount !== 1) {
323
+ return false;
324
+ }
325
+ var range = selection.getRangeAt(0);
326
+ return pluginState.decorations.find().filter(_decorationKeys.isDiffDecoration).some(function (decoration) {
327
+ if (decoration.spec.decorationType !== 'widget') {
328
+ return false;
329
+ }
330
+ var dom = (0, _getWidgetElement.getWidgetElement)(decoration);
331
+ return Boolean(dom && view.dom.contains(dom) && dom.contains(range.startContainer) && dom.contains(range.endContainer));
332
+ });
333
+ }
334
+ },
309
335
  decorations: function decorations(state) {
310
336
  var pluginState = showDiffPluginKey.getState(state);
311
337
  return pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations;
@@ -15,7 +15,7 @@ var _baseNodeName = require("./baseNodeName");
15
15
  *
16
16
  * Base names only — match with the predicates below, never against `type.name` directly.
17
17
  */
18
- var TAGGABLE_BLOCK_NODES = new Set(['blockCard', 'blockquote', 'bodiedExtension', 'codeBlock', 'decisionList', 'embedCard', 'expand', 'extension', 'media', 'multiBodiedExtension', 'panel', 'rule', 'taskList']);
18
+ var TAGGABLE_BLOCK_NODES = new Set(['blockCard', 'blockquote', 'bodiedExtension', 'codeBlock', 'decisionList', 'embedCard', 'expand', 'extension', 'layoutColumn', 'media', 'multiBodiedExtension', 'panel', 'rule', 'taskList']);
19
19
 
20
20
  /**
21
21
  * Whether this node hosts a contributor tag of its own. Navigation grouping does not consult this:
@@ -1,5 +1,4 @@
1
1
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
- import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
3
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
3
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
4
  import { fg } from '@atlaskit/platform-feature-flags/fg';
@@ -23,9 +22,6 @@ const UNSTYLED_NODES = ['mediaSingle', 'mediaGroup', 'table',
23
22
  'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'];
24
23
  const CELL_NODES = ['tableCell', 'tableHeader'];
25
24
 
26
- /** Panels, rules and media can also sit in a table cell, which is out of scope for block tags. */
27
- const isInsideTable = (doc, pos) => findParentNodeClosestToPos(doc.resolve(pos), node => node.type.name === 'table') !== undefined;
28
-
29
25
  /**
30
26
  * Whether this block can host a contributor tag of its own.
31
27
  *
@@ -42,7 +38,7 @@ const canTagBlock = ({
42
38
  return false;
43
39
  }
44
40
  const nodeType = (_doc$nodeAt = doc.nodeAt(from)) === null || _doc$nodeAt === void 0 ? void 0 : _doc$nodeAt.type;
45
- return nodeType !== undefined && isTaggableBlockNode(nodeType) && !isInsideTable(doc, from);
41
+ return nodeType !== undefined && isTaggableBlockNode(nodeType);
46
42
  };
47
43
 
48
44
  /** Positioning context for the cell overlay widget decorations. */
@@ -1,6 +1,7 @@
1
1
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
2
  import { fg } from '@atlaskit/platform-feature-flags/fg';
3
3
  import { ContributorTagController } from '../../ui/ContributorTag/contributorTagController';
4
+ import { resolveBaseNodeName } from '../utils/baseNodeName';
4
5
  import { buildCharsByOffset, isWhitespaceChar } from '../utils/charsByOffset';
5
6
  import { clampAnchorPosIntoCell, createAnchorNameSpan } from './createAnchorDecorationWidgets';
6
7
  import { AnchorTypeKey, buildAnchorDecorationKey, buildAnchorDecorationSpec, buildContributorTagDecorationSpec } from './decorationKeys';
@@ -207,6 +208,16 @@ export const resolveHoistedCodeBlockAnchor = (doc, pos, diffId) => {
207
208
  };
208
209
  };
209
210
 
211
+ /** Find the position before a layout for a tag anchored to one of its columns. */
212
+ const resolveLayoutSectionStart = (doc, pos) => {
213
+ var _doc$nodeAt$type$name, _doc$nodeAt;
214
+ if (resolveBaseNodeName((_doc$nodeAt$type$name = (_doc$nodeAt = doc.nodeAt(pos)) === null || _doc$nodeAt === void 0 ? void 0 : _doc$nodeAt.type.name) !== null && _doc$nodeAt$type$name !== void 0 ? _doc$nodeAt$type$name : '') !== 'layoutColumn') {
215
+ return undefined;
216
+ }
217
+ const $pos = doc.resolve(pos);
218
+ return resolveBaseNodeName($pos.parent.type.name) === 'layoutSection' ? $pos.before($pos.depth) : undefined;
219
+ };
220
+
210
221
  /**
211
222
  * The contributor tag widget for one diff range, placed on the first visible character the range
212
223
  * highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
@@ -227,7 +238,7 @@ export const createContributorTagWidget = ({
227
238
  diffId,
228
239
  mountContext
229
240
  }) => {
230
- var _hoisted$codeBlockSta, _ref2, _hoisted$anchorName;
241
+ var _ref2, _hoisted$anchorName, _hoisted$codeBlockSta;
231
242
  if (!isContributorTagWidgetEnabled()) {
232
243
  return undefined;
233
244
  }
@@ -239,8 +250,6 @@ export const createContributorTagWidget = ({
239
250
  // A change inside a code block is hoisted out of it, anchored to its own marker; anything else
240
251
  // keeps its own anchor.
241
252
  const hoisted = resolveHoistedCodeBlockAnchor(doc, anchorPos, diffId);
242
- // Keep the host out of the table row's grid (EDITOR-8442).
243
- const hostPos = clampAnchorPosIntoCell(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1);
244
253
 
245
254
  // Inline diffs pass no anchorName. Give them their own point anchor instead of the
246
255
  // `position: relative` fallback, which drifts left once the range wraps a line (EDITOR-9286).
@@ -250,6 +259,10 @@ export const createContributorTagWidget = ({
250
259
  });
251
260
  const effectiveAnchorName = (_ref2 = (_hoisted$anchorName = hoisted === null || hoisted === void 0 ? void 0 : hoisted.anchorName) !== null && _hoisted$anchorName !== void 0 ? _hoisted$anchorName : anchorName) !== null && _ref2 !== void 0 ? _ref2 : ownAnchorName;
252
261
  const tagAnchorName = effectiveAnchorName && supportsAnchorPositioning() ? effectiveAnchorName : undefined;
262
+ const layoutSectionStart = tagAnchorName ? resolveLayoutSectionStart(doc, anchorPos) : undefined;
263
+ // Keep the host out of the table row's grid (EDITOR-8442). Layout-column tags are hoisted before
264
+ // their layout so the advanced layout widget-flattening rule cannot put them behind nearby text.
265
+ const hostPos = layoutSectionStart !== null && layoutSectionStart !== void 0 ? layoutSectionStart : clampAnchorPosIntoCell(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1);
253
266
  const decorations = [];
254
267
  if (hoisted) {
255
268
  decorations.push(hoisted.marker);
@@ -1,5 +1,6 @@
1
1
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
2
  import { fg } from '@atlaskit/platform-feature-flags/fg';
3
+ import { resolveBaseNodeName } from '../utils/baseNodeName';
3
4
  import { countEmptyTextBlockOnlySlice } from '../utils/emptyTextBlocks';
4
5
  import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
5
6
  import { clampAnchorPosIntoCell, createAnchorNameSpan, createLeftAnchorWidget } from './createAnchorDecorationWidgets';
@@ -138,7 +139,7 @@ export const createNodeChangedDecorationWidget = ({
138
139
  tagMountContext,
139
140
  deletedColumns
140
141
  }) => {
141
- var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
142
+ var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _hoistedCodeBlockAnch, _slice$content$firstC2;
142
143
  const slice = doc.slice(change.fromA, change.toA);
143
144
  const shouldSkipDeletedEmptyParagraphDecoration = !isInserted && isEmptyParagraphSlice(slice);
144
145
  // How many blank lines the deletion took, when it took nothing else. Blank means an empty
@@ -272,6 +273,7 @@ export const createNodeChangedDecorationWidget = ({
272
273
  // Match the rendering predicate above: an empty paragraph has no widget to tag, while whitespace
273
274
  // text in a rendered widget remains eligible.
274
275
  const canTagWidget = showContributorTags && !shouldSkipDeletedEmptyParagraphDecoration;
276
+ let contributorTagAnchorName;
275
277
  const decorations = [];
276
278
  const replacementNode = newDoc.nodeAt(change.fromB);
277
279
  const firstReplacedNode = slice.content.firstChild;
@@ -366,6 +368,14 @@ export const createNodeChangedDecorationWidget = ({
366
368
  const $sourcePos = fg('platform_editor_ai_show_diff_patch_2') ? getSourcePos(doc, $changeFromA, slice.openStart, index) : null;
367
369
  const nodeView = serializer.tryCreateNodeView(node, 0, $sourcePos !== null && $sourcePos !== void 0 ? $sourcePos : undefined, isInserted, colorScheme);
368
370
  if (nodeView) {
371
+ if (canTagWidget && contributorTagAnchorName === undefined && resolveBaseNodeName(node.type.name) === 'layoutColumn' && nodeView instanceof HTMLElement && fg('confluence_ncs_step_diffing_version_history')) {
372
+ // The deleted column is rendered inside this widget; anchor to its box.
373
+ contributorTagAnchorName = buildAnchorDecorationKey({
374
+ diffId,
375
+ anchorType: AnchorTypeKey.tag
376
+ });
377
+ nodeView.style.setProperty('anchor-name', `--${contributorTagAnchorName}`);
378
+ }
369
379
  if (node.isInline) {
370
380
  const wrapper = createContentWrapper(colorScheme, isActive, isInserted, reveal);
371
381
  wrapper.append(nodeView);
@@ -413,7 +423,7 @@ export const createNodeChangedDecorationWidget = ({
413
423
  if (hoistedCodeBlockAnchor) {
414
424
  decorations.push(hoistedCodeBlockAnchor.marker);
415
425
  }
416
- let contributorTagAnchorName = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName;
426
+ contributorTagAnchorName = (_hoistedCodeBlockAnch = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName) !== null && _hoistedCodeBlockAnch !== void 0 ? _hoistedCodeBlockAnch : contributorTagAnchorName;
417
427
  if (!isInserted && deletedColumns !== null && deletedColumns !== void 0 && deletedColumns.length) {
418
428
  const table = dom.querySelector('table');
419
429
  const firstRow = table === null || table === void 0 ? void 0 : table.rows[0];
@@ -631,14 +641,14 @@ export const createNodeChangedDecorationWidget = ({
631
641
  if (fg('platform_editor_ai_show_diff_patch_1')) {
632
642
  defaultSpacer.style.setProperty('scroll-margin-top', scrollMarginTopValue);
633
643
  }
634
- decorations.push(Decoration.widget(safeInsertPos, defaultSpacer, {
635
- ...buildDiffDecorationSpec({
636
- colorScheme,
637
- decorationType: 'widget',
638
- diffId: crypto.randomUUID(),
639
- isInserted
640
- })
641
- }));
644
+ decorations.push(Decoration.widget(safeInsertPos, defaultSpacer,
645
+ // Spacing only: a diff spec would make it an untagged navigation stop.
646
+ showContributorTags ? {} : buildDiffDecorationSpec({
647
+ colorScheme,
648
+ decorationType: 'widget',
649
+ diffId: crypto.randomUUID(),
650
+ isInserted
651
+ })));
642
652
  }
643
653
  }
644
654
  return decorations;
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
1
2
  /**
2
3
  * Decoration families produced by the show-diff plugin.
3
4
  * Each family owns its own key space and spec shape.
@@ -98,6 +99,12 @@ export const buildDiffDecorationSpec = ({
98
99
  } : {}),
99
100
  ...(side !== undefined ? {
100
101
  side
102
+ } : {}),
103
+ ...(decorationType === 'widget' && fg('platform_editor_ai_show_diff_patch_2') ? {
104
+ // Widget content is outside the document. Keep its native DOM selection
105
+ // and let the browser handle events within it.
106
+ ignoreSelection: true,
107
+ stopEvent: () => true
101
108
  } : {})
102
109
  });
103
110
  export function buildAnchorDecorationSpec({