@atlaskit/editor-plugin-show-diff 17.1.6 → 17.1.7
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 +15 -0
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -1
- package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +54 -15
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +1 -1
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +50 -12
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +8 -3
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -1
- package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +54 -15
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +1 -1
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +52 -15
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +8 -3
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -1
- package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +54 -15
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +1 -1
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +53 -15
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +8 -3
- package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +24 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 17.1.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`597f7ce38c071`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/597f7ce38c071) -
|
|
8
|
+
Fix contributor tags rendering clipped inside code blocks, and off-position for other
|
|
9
|
+
deleted-content widgets, in version history diffs.
|
|
10
|
+
|
|
11
|
+
Anchor the contributor tag to the code block's own box when an edit inside the block hoists the
|
|
12
|
+
tag out of it, instead of an approximate host-relative offset, so the tag no longer renders
|
|
13
|
+
clipped by the code content wrapper.
|
|
14
|
+
|
|
15
|
+
Fix deleted headings, lists, and blockquotes missing their background highlight and underline on
|
|
16
|
+
the active change, behind `confluence_ncs_step_diffing_version_history`.
|
|
17
|
+
|
|
3
18
|
## 17.1.6
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -308,7 +308,7 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
308
308
|
mountContext: tagMountContext
|
|
309
309
|
});
|
|
310
310
|
if (tagWidget) {
|
|
311
|
-
decorations.push(tagWidget);
|
|
311
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(tagWidget));
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
return decorations;
|
|
@@ -426,7 +426,7 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
|
|
|
426
426
|
}));
|
|
427
427
|
}
|
|
428
428
|
if (tagWidget) {
|
|
429
|
-
decorations.push(tagWidget);
|
|
429
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(tagWidget));
|
|
430
430
|
}
|
|
431
431
|
return decorations;
|
|
432
432
|
});
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.unmountContributorTag = exports.mountContributorTag = exports.isContributorTagWidgetEnabled = exports.createContributorTagWidget = exports.createContributorTagHost = exports.CONTRIBUTOR_TAG_HOST_ATTRIBUTE = void 0;
|
|
7
|
+
exports.unmountContributorTag = exports.resolveHoistedCodeBlockAnchor = exports.resolveCodeBlockStart = exports.mountContributorTag = exports.isContributorTagWidgetEnabled = exports.createContributorTagWidget = exports.createContributorTagHost = exports.CONTRIBUTOR_TAG_HOST_ATTRIBUTE = 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");
|
|
@@ -174,13 +174,12 @@ var resolveTagAnchorPos = function resolveTagAnchorPos(doc, from, to) {
|
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
177
|
+
* Position just before the code block enclosing `pos`, or `undefined` if there is none.
|
|
178
178
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* where a whole-code-block change is tagged too (EDITOR-8766).
|
|
179
|
+
* Code blocks clip/scroll their own content, so a tag hosted inside one gets clipped away. Hoisting
|
|
180
|
+
* it before the block avoids that (EDITOR-9045, EDITOR-8766).
|
|
182
181
|
*/
|
|
183
|
-
var resolveCodeBlockStart = function resolveCodeBlockStart(doc, pos) {
|
|
182
|
+
var resolveCodeBlockStart = exports.resolveCodeBlockStart = function resolveCodeBlockStart(doc, pos) {
|
|
184
183
|
var $pos = doc.resolve(pos);
|
|
185
184
|
for (var depth = $pos.depth; depth > 0; depth--) {
|
|
186
185
|
if ($pos.node(depth).type.name === 'codeBlock') {
|
|
@@ -191,14 +190,47 @@ var resolveCodeBlockStart = function resolveCodeBlockStart(doc, pos) {
|
|
|
191
190
|
};
|
|
192
191
|
|
|
193
192
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
|
|
193
|
+
* If `pos` is inside a code block: a marker decoration to anchor the hoisted tag against, plus the
|
|
194
|
+
* position just before the block to host that tag at (EDITOR-9045).
|
|
195
|
+
*/
|
|
196
|
+
var resolveHoistedCodeBlockAnchor = exports.resolveHoistedCodeBlockAnchor = function resolveHoistedCodeBlockAnchor(doc, pos, diffId) {
|
|
197
|
+
var codeBlockStart = resolveCodeBlockStart(doc, pos);
|
|
198
|
+
if (codeBlockStart === undefined) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
var anchorName = (0, _decorationKeys.buildAnchorDecorationKey)({
|
|
202
|
+
diffId: diffId,
|
|
203
|
+
anchorType: _decorationKeys.AnchorTypeKey.tag
|
|
204
|
+
});
|
|
205
|
+
var marker = _view.Decoration.widget(pos, function () {
|
|
206
|
+
var el = document.createElement('span');
|
|
207
|
+
el.style.setProperty('anchor-name', "--".concat(anchorName));
|
|
208
|
+
return el;
|
|
209
|
+
}, {
|
|
210
|
+
key: "contributor-tag-anchor-".concat(diffId),
|
|
211
|
+
side: -1,
|
|
212
|
+
marks: [],
|
|
213
|
+
ignoreSelection: true
|
|
214
|
+
});
|
|
215
|
+
return {
|
|
216
|
+
anchorName: anchorName,
|
|
217
|
+
codeBlockStart: codeBlockStart,
|
|
218
|
+
marker: marker
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The contributor tag widget for one diff range, placed on the first visible character the range
|
|
224
|
+
* highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
|
|
225
|
+
* hoisted in front of it instead, anchored via `resolveHoistedCodeBlockAnchor` (EDITOR-9045).
|
|
226
|
+
*
|
|
227
|
+
* Returns one decoration normally, two (marker + tag) when hoisted out of a code block.
|
|
197
228
|
*
|
|
198
229
|
* The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
|
|
199
230
|
* element ProseMirror drew it into — see `mountContributorTag`.
|
|
200
231
|
*/
|
|
201
232
|
var createContributorTagWidget = exports.createContributorTagWidget = function createContributorTagWidget(_ref4) {
|
|
233
|
+
var _hoisted$anchorName, _hoisted$codeBlockSta;
|
|
202
234
|
var _ref4$anchorAtRangeSt = _ref4.anchorAtRangeStart,
|
|
203
235
|
anchorAtRangeStart = _ref4$anchorAtRangeSt === void 0 ? false : _ref4$anchorAtRangeSt,
|
|
204
236
|
anchorName = _ref4.anchorName,
|
|
@@ -210,17 +242,23 @@ var createContributorTagWidget = exports.createContributorTagWidget = function c
|
|
|
210
242
|
if (!isContributorTagWidgetEnabled()) {
|
|
211
243
|
return undefined;
|
|
212
244
|
}
|
|
213
|
-
var tagAnchorName = anchorName && supportsAnchorPositioning() ? anchorName : undefined;
|
|
214
245
|
|
|
215
246
|
// Reassigned when ProseMirror redraws this decoration, which it may do more than once for the
|
|
216
247
|
// same `Decoration` instance.
|
|
217
248
|
var mount;
|
|
218
249
|
var anchorPos = anchorAtRangeStart ? from : resolveTagAnchorPos(doc, from, to);
|
|
219
|
-
// A change inside a code block is hoisted out of it
|
|
220
|
-
|
|
221
|
-
|
|
250
|
+
// A change inside a code block is hoisted out of it, anchored to its own marker; anything else
|
|
251
|
+
// keeps its own anchor.
|
|
252
|
+
var hoisted = resolveHoistedCodeBlockAnchor(doc, anchorPos, diffId);
|
|
253
|
+
var effectiveAnchorName = (_hoisted$anchorName = hoisted === null || hoisted === void 0 ? void 0 : hoisted.anchorName) !== null && _hoisted$anchorName !== void 0 ? _hoisted$anchorName : anchorName;
|
|
254
|
+
var tagAnchorName = effectiveAnchorName && supportsAnchorPositioning() ? effectiveAnchorName : undefined;
|
|
255
|
+
var decorations = [];
|
|
256
|
+
if (hoisted) {
|
|
257
|
+
decorations.push(hoisted.marker);
|
|
258
|
+
}
|
|
259
|
+
decorations.push(_view.Decoration.widget(
|
|
222
260
|
// Keep the host out of the table row's grid (EDITOR-8442).
|
|
223
|
-
(0, _createAnchorDecorationWidgets.clampAnchorPosIntoCell)(doc,
|
|
261
|
+
(0, _createAnchorDecorationWidgets.clampAnchorPosIntoCell)(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1), function () {
|
|
224
262
|
var host = buildContributorTagHost(diffId, tagAnchorName);
|
|
225
263
|
mount = mountContributorTag({
|
|
226
264
|
anchorName: tagAnchorName,
|
|
@@ -242,5 +280,6 @@ var createContributorTagWidget = exports.createContributorTagWidget = function c
|
|
|
242
280
|
unmountContributorTag(mount);
|
|
243
281
|
mount = undefined;
|
|
244
282
|
}
|
|
245
|
-
}));
|
|
283
|
+
})));
|
|
284
|
+
return decorations;
|
|
246
285
|
};
|
|
@@ -291,7 +291,7 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
291
291
|
// Pushed after the indicator anchors so the decoration order is unchanged — see `tagWidget` above
|
|
292
292
|
// for why it is built before them.
|
|
293
293
|
if (tagWidget) {
|
|
294
|
-
decorations.push(tagWidget);
|
|
294
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(tagWidget));
|
|
295
295
|
}
|
|
296
296
|
return decorations;
|
|
297
297
|
};
|
|
@@ -419,7 +419,13 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
});
|
|
422
|
-
|
|
422
|
+
|
|
423
|
+
// A change inside a code block hoists its tag out of the block (EDITOR-9045).
|
|
424
|
+
var hoistedCodeBlockAnchor = canTagWidget ? (0, _createContributorTagWidget.resolveHoistedCodeBlockAnchor)(newDoc, safeInsertPos, diffId) : undefined;
|
|
425
|
+
if (hoistedCodeBlockAnchor) {
|
|
426
|
+
decorations.push(hoistedCodeBlockAnchor.marker);
|
|
427
|
+
}
|
|
428
|
+
var contributorTagAnchorName = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName;
|
|
423
429
|
if (!isInserted && deletedColumns !== null && deletedColumns !== void 0 && deletedColumns.length) {
|
|
424
430
|
var table = dom.querySelector('table');
|
|
425
431
|
var firstRow = table === null || table === void 0 ? void 0 : table.rows[0];
|
|
@@ -479,6 +485,13 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
479
485
|
dom.style.setProperty('anchor-name', "--".concat((0, _decorationKeys.buildAnchorDecorationKey)({
|
|
480
486
|
diffId: diffId
|
|
481
487
|
})));
|
|
488
|
+
// The tag built below only anchors via `anchor()` if `contributorTagAnchorName` is set; without
|
|
489
|
+
// it the tag falls back to a non-anchored position (EDITOR-9045).
|
|
490
|
+
if ((0, _fg.fg)('confluence_ncs_step_diffing_version_history')) {
|
|
491
|
+
contributorTagAnchorName !== null && contributorTagAnchorName !== void 0 ? contributorTagAnchorName : contributorTagAnchorName = (0, _decorationKeys.buildAnchorDecorationKey)({
|
|
492
|
+
diffId: diffId
|
|
493
|
+
});
|
|
494
|
+
}
|
|
482
495
|
}
|
|
483
496
|
|
|
484
497
|
// Taken down in the widget's `destroy` below: `dom` is rebuilt on every recalculation, so the tag
|
|
@@ -487,17 +500,42 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
487
500
|
if (canTagWidget) {
|
|
488
501
|
// Lets the contributor tag find the deleted content on hover.
|
|
489
502
|
dom.setAttribute('data-diff-id', diffId);
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
503
|
+
if (hoistedCodeBlockAnchor) {
|
|
504
|
+
// Own widget just before the code block, anchored to the marker above, not `dom` (EDITOR-9045).
|
|
505
|
+
var hoistedTagMount;
|
|
506
|
+
decorations.push(_view.Decoration.widget((0, _createAnchorDecorationWidgets.clampAnchorPosIntoCell)(newDoc, hoistedCodeBlockAnchor.codeBlockStart, 1), function () {
|
|
507
|
+
var _tagHost$host;
|
|
508
|
+
var tagHost = (0, _createContributorTagWidget.createContributorTagHost)({
|
|
509
|
+
anchorName: contributorTagAnchorName,
|
|
510
|
+
diffId: diffId,
|
|
511
|
+
mountContext: tagMountContext
|
|
512
|
+
});
|
|
513
|
+
hoistedTagMount = tagHost === null || tagHost === void 0 ? void 0 : tagHost.mount;
|
|
514
|
+
return (_tagHost$host = tagHost === null || tagHost === void 0 ? void 0 : tagHost.host) !== null && _tagHost$host !== void 0 ? _tagHost$host : document.createElement('span');
|
|
515
|
+
}, _objectSpread(_objectSpread({}, (0, _decorationKeys.buildContributorTagDecorationSpec)(diffId)), {}, {
|
|
516
|
+
side: 1,
|
|
517
|
+
marks: [],
|
|
518
|
+
ignoreSelection: true,
|
|
519
|
+
stopEvent: function stopEvent() {
|
|
520
|
+
return true;
|
|
521
|
+
},
|
|
522
|
+
destroy: function destroy() {
|
|
523
|
+
(0, _createContributorTagWidget.unmountContributorTag)(hoistedTagMount);
|
|
524
|
+
hoistedTagMount = undefined;
|
|
525
|
+
}
|
|
526
|
+
})));
|
|
527
|
+
} else {
|
|
528
|
+
// Hosted at the start of the deleted run rather than on `dom` itself: `dom` is inline, so once
|
|
529
|
+
// the deleted content wraps its box is the union of its line fragments.
|
|
530
|
+
var tagHost = (0, _createContributorTagWidget.createContributorTagHost)({
|
|
531
|
+
anchorName: contributorTagAnchorName,
|
|
532
|
+
diffId: diffId,
|
|
533
|
+
mountContext: tagMountContext
|
|
534
|
+
});
|
|
535
|
+
if (tagHost) {
|
|
536
|
+
dom.prepend(tagHost.host);
|
|
537
|
+
tagMount = tagHost.mount;
|
|
538
|
+
}
|
|
501
539
|
}
|
|
502
540
|
}
|
|
503
541
|
if (showIndicators && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
@@ -54,10 +54,15 @@ var getChangedContentStyleNext = function getChangedContentStyleNext(colorScheme
|
|
|
54
54
|
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isInserted) {
|
|
55
55
|
return (0, _factory.buildInsertedInlineStyle)(colors, isActive, hideAddedDiffsUnderline);
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
var base = (0, _factory.buildDeletedInlineContentStyle)(colors, isActive ? 'active' : (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'new' : 'default');
|
|
58
|
+
|
|
59
|
+
// Text-like blocks (heading, lists, blockquote) render their deleted content through this
|
|
60
|
+
// getter rather than `getDeletedContentStyle`, so without this they never receive the
|
|
61
|
+
// glyphTint background + underline that plain deleted text already gets.
|
|
62
|
+
if ((0, _fg.fg)('confluence_ncs_step_diffing_version_history') && colors.deletedInlineTreatment === 'glyphTint' && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
63
|
+
return base + (0, _factory.buildDeletedInlineContentStyleExtended)(colors, isActive);
|
|
59
64
|
}
|
|
60
|
-
return
|
|
65
|
+
return base;
|
|
61
66
|
};
|
|
62
67
|
var getChangedNodeStyleNext = function getChangedNodeStyleNext(nodeName, colorScheme) {
|
|
63
68
|
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -3,7 +3,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
3
3
|
import { ContributorTagController } from '../../ui/ContributorTag/contributorTagController';
|
|
4
4
|
import { buildCharsByOffset, isWhitespaceChar } from '../utils/charsByOffset';
|
|
5
5
|
import { clampAnchorPosIntoCell } from './createAnchorDecorationWidgets';
|
|
6
|
-
import { buildContributorTagDecorationSpec } from './decorationKeys';
|
|
6
|
+
import { AnchorTypeKey, buildAnchorDecorationKey, buildContributorTagDecorationSpec } from './decorationKeys';
|
|
7
7
|
|
|
8
8
|
/** Marks the host element of one tag, so a tag can be found in the document by its own diff. */
|
|
9
9
|
export const CONTRIBUTOR_TAG_HOST_ATTRIBUTE = 'data-contributor-tag-host';
|
|
@@ -162,13 +162,12 @@ const resolveTagAnchorPos = (doc, from, to) => {
|
|
|
162
162
|
};
|
|
163
163
|
|
|
164
164
|
/**
|
|
165
|
-
*
|
|
165
|
+
* Position just before the code block enclosing `pos`, or `undefined` if there is none.
|
|
166
166
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* where a whole-code-block change is tagged too (EDITOR-8766).
|
|
167
|
+
* Code blocks clip/scroll their own content, so a tag hosted inside one gets clipped away. Hoisting
|
|
168
|
+
* it before the block avoids that (EDITOR-9045, EDITOR-8766).
|
|
170
169
|
*/
|
|
171
|
-
const resolveCodeBlockStart = (doc, pos) => {
|
|
170
|
+
export const resolveCodeBlockStart = (doc, pos) => {
|
|
172
171
|
const $pos = doc.resolve(pos);
|
|
173
172
|
for (let depth = $pos.depth; depth > 0; depth--) {
|
|
174
173
|
if ($pos.node(depth).type.name === 'codeBlock') {
|
|
@@ -179,9 +178,41 @@ const resolveCodeBlockStart = (doc, pos) => {
|
|
|
179
178
|
};
|
|
180
179
|
|
|
181
180
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
|
|
181
|
+
* If `pos` is inside a code block: a marker decoration to anchor the hoisted tag against, plus the
|
|
182
|
+
* position just before the block to host that tag at (EDITOR-9045).
|
|
183
|
+
*/
|
|
184
|
+
export const resolveHoistedCodeBlockAnchor = (doc, pos, diffId) => {
|
|
185
|
+
const codeBlockStart = resolveCodeBlockStart(doc, pos);
|
|
186
|
+
if (codeBlockStart === undefined) {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
const anchorName = buildAnchorDecorationKey({
|
|
190
|
+
diffId,
|
|
191
|
+
anchorType: AnchorTypeKey.tag
|
|
192
|
+
});
|
|
193
|
+
const marker = Decoration.widget(pos, () => {
|
|
194
|
+
const el = document.createElement('span');
|
|
195
|
+
el.style.setProperty('anchor-name', `--${anchorName}`);
|
|
196
|
+
return el;
|
|
197
|
+
}, {
|
|
198
|
+
key: `contributor-tag-anchor-${diffId}`,
|
|
199
|
+
side: -1,
|
|
200
|
+
marks: [],
|
|
201
|
+
ignoreSelection: true
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
anchorName,
|
|
205
|
+
codeBlockStart,
|
|
206
|
+
marker
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The contributor tag widget for one diff range, placed on the first visible character the range
|
|
212
|
+
* highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
|
|
213
|
+
* hoisted in front of it instead, anchored via `resolveHoistedCodeBlockAnchor` (EDITOR-9045).
|
|
214
|
+
*
|
|
215
|
+
* Returns one decoration normally, two (marker + tag) when hoisted out of a code block.
|
|
185
216
|
*
|
|
186
217
|
* The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
|
|
187
218
|
* element ProseMirror drew it into — see `mountContributorTag`.
|
|
@@ -195,20 +226,27 @@ export const createContributorTagWidget = ({
|
|
|
195
226
|
diffId,
|
|
196
227
|
mountContext
|
|
197
228
|
}) => {
|
|
229
|
+
var _hoisted$anchorName, _hoisted$codeBlockSta;
|
|
198
230
|
if (!isContributorTagWidgetEnabled()) {
|
|
199
231
|
return undefined;
|
|
200
232
|
}
|
|
201
|
-
const tagAnchorName = anchorName && supportsAnchorPositioning() ? anchorName : undefined;
|
|
202
233
|
|
|
203
234
|
// Reassigned when ProseMirror redraws this decoration, which it may do more than once for the
|
|
204
235
|
// same `Decoration` instance.
|
|
205
236
|
let mount;
|
|
206
237
|
const anchorPos = anchorAtRangeStart ? from : resolveTagAnchorPos(doc, from, to);
|
|
207
|
-
// A change inside a code block is hoisted out of it
|
|
208
|
-
|
|
209
|
-
|
|
238
|
+
// A change inside a code block is hoisted out of it, anchored to its own marker; anything else
|
|
239
|
+
// keeps its own anchor.
|
|
240
|
+
const hoisted = resolveHoistedCodeBlockAnchor(doc, anchorPos, diffId);
|
|
241
|
+
const effectiveAnchorName = (_hoisted$anchorName = hoisted === null || hoisted === void 0 ? void 0 : hoisted.anchorName) !== null && _hoisted$anchorName !== void 0 ? _hoisted$anchorName : anchorName;
|
|
242
|
+
const tagAnchorName = effectiveAnchorName && supportsAnchorPositioning() ? effectiveAnchorName : undefined;
|
|
243
|
+
const decorations = [];
|
|
244
|
+
if (hoisted) {
|
|
245
|
+
decorations.push(hoisted.marker);
|
|
246
|
+
}
|
|
247
|
+
decorations.push(Decoration.widget(
|
|
210
248
|
// Keep the host out of the table row's grid (EDITOR-8442).
|
|
211
|
-
clampAnchorPosIntoCell(doc,
|
|
249
|
+
clampAnchorPosIntoCell(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1), () => {
|
|
212
250
|
const host = buildContributorTagHost(diffId, tagAnchorName);
|
|
213
251
|
mount = mountContributorTag({
|
|
214
252
|
anchorName: tagAnchorName,
|
|
@@ -229,5 +267,6 @@ export const createContributorTagWidget = ({
|
|
|
229
267
|
unmountContributorTag(mount);
|
|
230
268
|
mount = undefined;
|
|
231
269
|
}
|
|
232
|
-
});
|
|
270
|
+
}));
|
|
271
|
+
return decorations;
|
|
233
272
|
};
|
|
@@ -273,7 +273,7 @@ export const createInlineChangedDecoration = ({
|
|
|
273
273
|
// Pushed after the indicator anchors so the decoration order is unchanged — see `tagWidget` above
|
|
274
274
|
// for why it is built before them.
|
|
275
275
|
if (tagWidget) {
|
|
276
|
-
decorations.push(tagWidget);
|
|
276
|
+
decorations.push(...tagWidget);
|
|
277
277
|
}
|
|
278
278
|
return decorations;
|
|
279
279
|
};
|
|
@@ -3,10 +3,10 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
3
3
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
4
4
|
import { countEmptyTextBlockOnlySlice } from '../utils/emptyTextBlocks';
|
|
5
5
|
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
6
|
-
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
6
|
+
import { clampAnchorPosIntoCell, createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
7
7
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
8
|
-
import { createContributorTagHost, unmountContributorTag } from './createContributorTagWidget';
|
|
9
|
-
import { AnchorTypeKey, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
|
|
8
|
+
import { createContributorTagHost, resolveHoistedCodeBlockAnchor, unmountContributorTag } from './createContributorTagWidget';
|
|
9
|
+
import { AnchorTypeKey, buildContributorTagDecorationSpec, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
|
|
10
10
|
import { absorbFirstChildMarginReset } from './utils/absorbFirstChildMarginReset';
|
|
11
11
|
import { createDeletedLineBreakDecoration } from './utils/createDeletedLineBreakWidget';
|
|
12
12
|
import { createMarginAbsorber } from './utils/createMarginAbsorber';
|
|
@@ -405,7 +405,13 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
});
|
|
408
|
-
|
|
408
|
+
|
|
409
|
+
// A change inside a code block hoists its tag out of the block (EDITOR-9045).
|
|
410
|
+
const hoistedCodeBlockAnchor = canTagWidget ? resolveHoistedCodeBlockAnchor(newDoc, safeInsertPos, diffId) : undefined;
|
|
411
|
+
if (hoistedCodeBlockAnchor) {
|
|
412
|
+
decorations.push(hoistedCodeBlockAnchor.marker);
|
|
413
|
+
}
|
|
414
|
+
let contributorTagAnchorName = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName;
|
|
409
415
|
if (!isInserted && deletedColumns !== null && deletedColumns !== void 0 && deletedColumns.length) {
|
|
410
416
|
const table = dom.querySelector('table');
|
|
411
417
|
const firstRow = table === null || table === void 0 ? void 0 : table.rows[0];
|
|
@@ -465,6 +471,13 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
465
471
|
dom.style.setProperty('anchor-name', `--${buildAnchorDecorationKey({
|
|
466
472
|
diffId
|
|
467
473
|
})}`);
|
|
474
|
+
// The tag built below only anchors via `anchor()` if `contributorTagAnchorName` is set; without
|
|
475
|
+
// it the tag falls back to a non-anchored position (EDITOR-9045).
|
|
476
|
+
if (fg('confluence_ncs_step_diffing_version_history')) {
|
|
477
|
+
contributorTagAnchorName ??= buildAnchorDecorationKey({
|
|
478
|
+
diffId
|
|
479
|
+
});
|
|
480
|
+
}
|
|
468
481
|
}
|
|
469
482
|
|
|
470
483
|
// Taken down in the widget's `destroy` below: `dom` is rebuilt on every recalculation, so the tag
|
|
@@ -473,17 +486,41 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
473
486
|
if (canTagWidget) {
|
|
474
487
|
// Lets the contributor tag find the deleted content on hover.
|
|
475
488
|
dom.setAttribute('data-diff-id', diffId);
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
489
|
+
if (hoistedCodeBlockAnchor) {
|
|
490
|
+
// Own widget just before the code block, anchored to the marker above, not `dom` (EDITOR-9045).
|
|
491
|
+
let hoistedTagMount;
|
|
492
|
+
decorations.push(Decoration.widget(clampAnchorPosIntoCell(newDoc, hoistedCodeBlockAnchor.codeBlockStart, 1), () => {
|
|
493
|
+
var _tagHost$host;
|
|
494
|
+
const tagHost = createContributorTagHost({
|
|
495
|
+
anchorName: contributorTagAnchorName,
|
|
496
|
+
diffId,
|
|
497
|
+
mountContext: tagMountContext
|
|
498
|
+
});
|
|
499
|
+
hoistedTagMount = tagHost === null || tagHost === void 0 ? void 0 : tagHost.mount;
|
|
500
|
+
return (_tagHost$host = tagHost === null || tagHost === void 0 ? void 0 : tagHost.host) !== null && _tagHost$host !== void 0 ? _tagHost$host : document.createElement('span');
|
|
501
|
+
}, {
|
|
502
|
+
...buildContributorTagDecorationSpec(diffId),
|
|
503
|
+
side: 1,
|
|
504
|
+
marks: [],
|
|
505
|
+
ignoreSelection: true,
|
|
506
|
+
stopEvent: () => true,
|
|
507
|
+
destroy: () => {
|
|
508
|
+
unmountContributorTag(hoistedTagMount);
|
|
509
|
+
hoistedTagMount = undefined;
|
|
510
|
+
}
|
|
511
|
+
}));
|
|
512
|
+
} else {
|
|
513
|
+
// Hosted at the start of the deleted run rather than on `dom` itself: `dom` is inline, so once
|
|
514
|
+
// the deleted content wraps its box is the union of its line fragments.
|
|
515
|
+
const tagHost = createContributorTagHost({
|
|
516
|
+
anchorName: contributorTagAnchorName,
|
|
517
|
+
diffId,
|
|
518
|
+
mountContext: tagMountContext
|
|
519
|
+
});
|
|
520
|
+
if (tagHost) {
|
|
521
|
+
dom.prepend(tagHost.host);
|
|
522
|
+
tagMount = tagHost.mount;
|
|
523
|
+
}
|
|
487
524
|
}
|
|
488
525
|
}
|
|
489
526
|
if (showIndicators && isExtendedEnabled(diffType)) {
|
|
@@ -39,10 +39,15 @@ const getChangedContentStyleNext = (colorScheme, isActive = false, isInserted =
|
|
|
39
39
|
if (isExtendedEnabled(diffType) && isInserted) {
|
|
40
40
|
return buildInsertedInlineStyle(colors, isActive, hideAddedDiffsUnderline);
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const base = buildDeletedInlineContentStyle(colors, isActive ? 'active' : expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'new' : 'default');
|
|
43
|
+
|
|
44
|
+
// Text-like blocks (heading, lists, blockquote) render their deleted content through this
|
|
45
|
+
// getter rather than `getDeletedContentStyle`, so without this they never receive the
|
|
46
|
+
// glyphTint background + underline that plain deleted text already gets.
|
|
47
|
+
if (fg('confluence_ncs_step_diffing_version_history') && colors.deletedInlineTreatment === 'glyphTint' && isExtendedEnabled(diffType)) {
|
|
48
|
+
return base + buildDeletedInlineContentStyleExtended(colors, isActive);
|
|
44
49
|
}
|
|
45
|
-
return
|
|
50
|
+
return base;
|
|
46
51
|
};
|
|
47
52
|
const getChangedNodeStyleNext = (nodeName, colorScheme, isInserted = false, isActive = false, diffType, hideAddedDiffsUnderline = false) => {
|
|
48
53
|
const colors = getColorScheme(colorScheme);
|
|
@@ -301,7 +301,7 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
301
301
|
mountContext: tagMountContext
|
|
302
302
|
});
|
|
303
303
|
if (tagWidget) {
|
|
304
|
-
decorations.push(tagWidget);
|
|
304
|
+
decorations.push.apply(decorations, _toConsumableArray(tagWidget));
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
return decorations;
|
|
@@ -419,7 +419,7 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
|
|
|
419
419
|
}));
|
|
420
420
|
}
|
|
421
421
|
if (tagWidget) {
|
|
422
|
-
decorations.push(tagWidget);
|
|
422
|
+
decorations.push.apply(decorations, _toConsumableArray(tagWidget));
|
|
423
423
|
}
|
|
424
424
|
return decorations;
|
|
425
425
|
});
|
|
@@ -6,7 +6,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
6
6
|
import { ContributorTagController } from '../../ui/ContributorTag/contributorTagController';
|
|
7
7
|
import { buildCharsByOffset, isWhitespaceChar } from '../utils/charsByOffset';
|
|
8
8
|
import { clampAnchorPosIntoCell } from './createAnchorDecorationWidgets';
|
|
9
|
-
import { buildContributorTagDecorationSpec } from './decorationKeys';
|
|
9
|
+
import { AnchorTypeKey, buildAnchorDecorationKey, buildContributorTagDecorationSpec } from './decorationKeys';
|
|
10
10
|
|
|
11
11
|
/** Marks the host element of one tag, so a tag can be found in the document by its own diff. */
|
|
12
12
|
export var CONTRIBUTOR_TAG_HOST_ATTRIBUTE = 'data-contributor-tag-host';
|
|
@@ -168,13 +168,12 @@ var resolveTagAnchorPos = function resolveTagAnchorPos(doc, from, to) {
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
171
|
+
* Position just before the code block enclosing `pos`, or `undefined` if there is none.
|
|
172
172
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* where a whole-code-block change is tagged too (EDITOR-8766).
|
|
173
|
+
* Code blocks clip/scroll their own content, so a tag hosted inside one gets clipped away. Hoisting
|
|
174
|
+
* it before the block avoids that (EDITOR-9045, EDITOR-8766).
|
|
176
175
|
*/
|
|
177
|
-
var resolveCodeBlockStart = function resolveCodeBlockStart(doc, pos) {
|
|
176
|
+
export var resolveCodeBlockStart = function resolveCodeBlockStart(doc, pos) {
|
|
178
177
|
var $pos = doc.resolve(pos);
|
|
179
178
|
for (var depth = $pos.depth; depth > 0; depth--) {
|
|
180
179
|
if ($pos.node(depth).type.name === 'codeBlock') {
|
|
@@ -185,14 +184,47 @@ var resolveCodeBlockStart = function resolveCodeBlockStart(doc, pos) {
|
|
|
185
184
|
};
|
|
186
185
|
|
|
187
186
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
|
|
187
|
+
* If `pos` is inside a code block: a marker decoration to anchor the hoisted tag against, plus the
|
|
188
|
+
* position just before the block to host that tag at (EDITOR-9045).
|
|
189
|
+
*/
|
|
190
|
+
export var resolveHoistedCodeBlockAnchor = function resolveHoistedCodeBlockAnchor(doc, pos, diffId) {
|
|
191
|
+
var codeBlockStart = resolveCodeBlockStart(doc, pos);
|
|
192
|
+
if (codeBlockStart === undefined) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
var anchorName = buildAnchorDecorationKey({
|
|
196
|
+
diffId: diffId,
|
|
197
|
+
anchorType: AnchorTypeKey.tag
|
|
198
|
+
});
|
|
199
|
+
var marker = Decoration.widget(pos, function () {
|
|
200
|
+
var el = document.createElement('span');
|
|
201
|
+
el.style.setProperty('anchor-name', "--".concat(anchorName));
|
|
202
|
+
return el;
|
|
203
|
+
}, {
|
|
204
|
+
key: "contributor-tag-anchor-".concat(diffId),
|
|
205
|
+
side: -1,
|
|
206
|
+
marks: [],
|
|
207
|
+
ignoreSelection: true
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
anchorName: anchorName,
|
|
211
|
+
codeBlockStart: codeBlockStart,
|
|
212
|
+
marker: marker
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The contributor tag widget for one diff range, placed on the first visible character the range
|
|
218
|
+
* highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
|
|
219
|
+
* hoisted in front of it instead, anchored via `resolveHoistedCodeBlockAnchor` (EDITOR-9045).
|
|
220
|
+
*
|
|
221
|
+
* Returns one decoration normally, two (marker + tag) when hoisted out of a code block.
|
|
191
222
|
*
|
|
192
223
|
* The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
|
|
193
224
|
* element ProseMirror drew it into — see `mountContributorTag`.
|
|
194
225
|
*/
|
|
195
226
|
export var createContributorTagWidget = function createContributorTagWidget(_ref4) {
|
|
227
|
+
var _hoisted$anchorName, _hoisted$codeBlockSta;
|
|
196
228
|
var _ref4$anchorAtRangeSt = _ref4.anchorAtRangeStart,
|
|
197
229
|
anchorAtRangeStart = _ref4$anchorAtRangeSt === void 0 ? false : _ref4$anchorAtRangeSt,
|
|
198
230
|
anchorName = _ref4.anchorName,
|
|
@@ -204,17 +236,23 @@ export var createContributorTagWidget = function createContributorTagWidget(_ref
|
|
|
204
236
|
if (!isContributorTagWidgetEnabled()) {
|
|
205
237
|
return undefined;
|
|
206
238
|
}
|
|
207
|
-
var tagAnchorName = anchorName && supportsAnchorPositioning() ? anchorName : undefined;
|
|
208
239
|
|
|
209
240
|
// Reassigned when ProseMirror redraws this decoration, which it may do more than once for the
|
|
210
241
|
// same `Decoration` instance.
|
|
211
242
|
var mount;
|
|
212
243
|
var anchorPos = anchorAtRangeStart ? from : resolveTagAnchorPos(doc, from, to);
|
|
213
|
-
// A change inside a code block is hoisted out of it
|
|
214
|
-
|
|
215
|
-
|
|
244
|
+
// A change inside a code block is hoisted out of it, anchored to its own marker; anything else
|
|
245
|
+
// keeps its own anchor.
|
|
246
|
+
var hoisted = resolveHoistedCodeBlockAnchor(doc, anchorPos, diffId);
|
|
247
|
+
var effectiveAnchorName = (_hoisted$anchorName = hoisted === null || hoisted === void 0 ? void 0 : hoisted.anchorName) !== null && _hoisted$anchorName !== void 0 ? _hoisted$anchorName : anchorName;
|
|
248
|
+
var tagAnchorName = effectiveAnchorName && supportsAnchorPositioning() ? effectiveAnchorName : undefined;
|
|
249
|
+
var decorations = [];
|
|
250
|
+
if (hoisted) {
|
|
251
|
+
decorations.push(hoisted.marker);
|
|
252
|
+
}
|
|
253
|
+
decorations.push(Decoration.widget(
|
|
216
254
|
// Keep the host out of the table row's grid (EDITOR-8442).
|
|
217
|
-
clampAnchorPosIntoCell(doc,
|
|
255
|
+
clampAnchorPosIntoCell(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1), function () {
|
|
218
256
|
var host = buildContributorTagHost(diffId, tagAnchorName);
|
|
219
257
|
mount = mountContributorTag({
|
|
220
258
|
anchorName: tagAnchorName,
|
|
@@ -236,5 +274,6 @@ export var createContributorTagWidget = function createContributorTagWidget(_ref
|
|
|
236
274
|
unmountContributorTag(mount);
|
|
237
275
|
mount = undefined;
|
|
238
276
|
}
|
|
239
|
-
}));
|
|
277
|
+
})));
|
|
278
|
+
return decorations;
|
|
240
279
|
};
|
|
@@ -284,7 +284,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
284
284
|
// Pushed after the indicator anchors so the decoration order is unchanged — see `tagWidget` above
|
|
285
285
|
// for why it is built before them.
|
|
286
286
|
if (tagWidget) {
|
|
287
|
-
decorations.push(tagWidget);
|
|
287
|
+
decorations.push.apply(decorations, _toConsumableArray(tagWidget));
|
|
288
288
|
}
|
|
289
289
|
return decorations;
|
|
290
290
|
};
|
|
@@ -6,10 +6,10 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
6
6
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
7
7
|
import { countEmptyTextBlockOnlySlice } from '../utils/emptyTextBlocks';
|
|
8
8
|
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
9
|
-
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
9
|
+
import { clampAnchorPosIntoCell, createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
10
10
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
11
|
-
import { createContributorTagHost, unmountContributorTag } from './createContributorTagWidget';
|
|
12
|
-
import { AnchorTypeKey, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
|
|
11
|
+
import { createContributorTagHost, resolveHoistedCodeBlockAnchor, unmountContributorTag } from './createContributorTagWidget';
|
|
12
|
+
import { AnchorTypeKey, buildContributorTagDecorationSpec, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
|
|
13
13
|
import { absorbFirstChildMarginReset } from './utils/absorbFirstChildMarginReset';
|
|
14
14
|
import { createDeletedLineBreakDecoration } from './utils/createDeletedLineBreakWidget';
|
|
15
15
|
import { createMarginAbsorber } from './utils/createMarginAbsorber';
|
|
@@ -412,7 +412,13 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
});
|
|
415
|
-
|
|
415
|
+
|
|
416
|
+
// A change inside a code block hoists its tag out of the block (EDITOR-9045).
|
|
417
|
+
var hoistedCodeBlockAnchor = canTagWidget ? resolveHoistedCodeBlockAnchor(newDoc, safeInsertPos, diffId) : undefined;
|
|
418
|
+
if (hoistedCodeBlockAnchor) {
|
|
419
|
+
decorations.push(hoistedCodeBlockAnchor.marker);
|
|
420
|
+
}
|
|
421
|
+
var contributorTagAnchorName = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName;
|
|
416
422
|
if (!isInserted && deletedColumns !== null && deletedColumns !== void 0 && deletedColumns.length) {
|
|
417
423
|
var table = dom.querySelector('table');
|
|
418
424
|
var firstRow = table === null || table === void 0 ? void 0 : table.rows[0];
|
|
@@ -472,6 +478,13 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
472
478
|
dom.style.setProperty('anchor-name', "--".concat(buildAnchorDecorationKey({
|
|
473
479
|
diffId: diffId
|
|
474
480
|
})));
|
|
481
|
+
// The tag built below only anchors via `anchor()` if `contributorTagAnchorName` is set; without
|
|
482
|
+
// it the tag falls back to a non-anchored position (EDITOR-9045).
|
|
483
|
+
if (fg('confluence_ncs_step_diffing_version_history')) {
|
|
484
|
+
contributorTagAnchorName !== null && contributorTagAnchorName !== void 0 ? contributorTagAnchorName : contributorTagAnchorName = buildAnchorDecorationKey({
|
|
485
|
+
diffId: diffId
|
|
486
|
+
});
|
|
487
|
+
}
|
|
475
488
|
}
|
|
476
489
|
|
|
477
490
|
// Taken down in the widget's `destroy` below: `dom` is rebuilt on every recalculation, so the tag
|
|
@@ -480,17 +493,42 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
480
493
|
if (canTagWidget) {
|
|
481
494
|
// Lets the contributor tag find the deleted content on hover.
|
|
482
495
|
dom.setAttribute('data-diff-id', diffId);
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
496
|
+
if (hoistedCodeBlockAnchor) {
|
|
497
|
+
// Own widget just before the code block, anchored to the marker above, not `dom` (EDITOR-9045).
|
|
498
|
+
var hoistedTagMount;
|
|
499
|
+
decorations.push(Decoration.widget(clampAnchorPosIntoCell(newDoc, hoistedCodeBlockAnchor.codeBlockStart, 1), function () {
|
|
500
|
+
var _tagHost$host;
|
|
501
|
+
var tagHost = createContributorTagHost({
|
|
502
|
+
anchorName: contributorTagAnchorName,
|
|
503
|
+
diffId: diffId,
|
|
504
|
+
mountContext: tagMountContext
|
|
505
|
+
});
|
|
506
|
+
hoistedTagMount = tagHost === null || tagHost === void 0 ? void 0 : tagHost.mount;
|
|
507
|
+
return (_tagHost$host = tagHost === null || tagHost === void 0 ? void 0 : tagHost.host) !== null && _tagHost$host !== void 0 ? _tagHost$host : document.createElement('span');
|
|
508
|
+
}, _objectSpread(_objectSpread({}, buildContributorTagDecorationSpec(diffId)), {}, {
|
|
509
|
+
side: 1,
|
|
510
|
+
marks: [],
|
|
511
|
+
ignoreSelection: true,
|
|
512
|
+
stopEvent: function stopEvent() {
|
|
513
|
+
return true;
|
|
514
|
+
},
|
|
515
|
+
destroy: function destroy() {
|
|
516
|
+
unmountContributorTag(hoistedTagMount);
|
|
517
|
+
hoistedTagMount = undefined;
|
|
518
|
+
}
|
|
519
|
+
})));
|
|
520
|
+
} else {
|
|
521
|
+
// Hosted at the start of the deleted run rather than on `dom` itself: `dom` is inline, so once
|
|
522
|
+
// the deleted content wraps its box is the union of its line fragments.
|
|
523
|
+
var tagHost = createContributorTagHost({
|
|
524
|
+
anchorName: contributorTagAnchorName,
|
|
525
|
+
diffId: diffId,
|
|
526
|
+
mountContext: tagMountContext
|
|
527
|
+
});
|
|
528
|
+
if (tagHost) {
|
|
529
|
+
dom.prepend(tagHost.host);
|
|
530
|
+
tagMount = tagHost.mount;
|
|
531
|
+
}
|
|
494
532
|
}
|
|
495
533
|
}
|
|
496
534
|
if (showIndicators && isExtendedEnabled(diffType)) {
|
|
@@ -48,10 +48,15 @@ var getChangedContentStyleNext = function getChangedContentStyleNext(colorScheme
|
|
|
48
48
|
if (isExtendedEnabled(diffType) && isInserted) {
|
|
49
49
|
return buildInsertedInlineStyle(colors, isActive, hideAddedDiffsUnderline);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
var base = buildDeletedInlineContentStyle(colors, isActive ? 'active' : expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'new' : 'default');
|
|
52
|
+
|
|
53
|
+
// Text-like blocks (heading, lists, blockquote) render their deleted content through this
|
|
54
|
+
// getter rather than `getDeletedContentStyle`, so without this they never receive the
|
|
55
|
+
// glyphTint background + underline that plain deleted text already gets.
|
|
56
|
+
if (fg('confluence_ncs_step_diffing_version_history') && colors.deletedInlineTreatment === 'glyphTint' && isExtendedEnabled(diffType)) {
|
|
57
|
+
return base + buildDeletedInlineContentStyleExtended(colors, isActive);
|
|
53
58
|
}
|
|
54
|
-
return
|
|
59
|
+
return base;
|
|
55
60
|
};
|
|
56
61
|
var getChangedNodeStyleNext = function getChangedNodeStyleNext(nodeName, colorScheme) {
|
|
57
62
|
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -48,9 +48,27 @@ export declare const createContributorTagHost: ({ anchorName, diffId, mountConte
|
|
|
48
48
|
mount: ContributorTagMount | undefined;
|
|
49
49
|
} | undefined;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* Position just before the code block enclosing `pos`, or `undefined` if there is none.
|
|
52
|
+
*
|
|
53
|
+
* Code blocks clip/scroll their own content, so a tag hosted inside one gets clipped away. Hoisting
|
|
54
|
+
* it before the block avoids that (EDITOR-9045, EDITOR-8766).
|
|
55
|
+
*/
|
|
56
|
+
export declare const resolveCodeBlockStart: (doc: PMNode, pos: number) => number | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* If `pos` is inside a code block: a marker decoration to anchor the hoisted tag against, plus the
|
|
59
|
+
* position just before the block to host that tag at (EDITOR-9045).
|
|
60
|
+
*/
|
|
61
|
+
export declare const resolveHoistedCodeBlockAnchor: (doc: PMNode, pos: number, diffId: string) => {
|
|
62
|
+
anchorName: string;
|
|
63
|
+
codeBlockStart: number;
|
|
64
|
+
marker: Decoration;
|
|
65
|
+
} | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* The contributor tag widget for one diff range, placed on the first visible character the range
|
|
68
|
+
* highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
|
|
69
|
+
* hoisted in front of it instead, anchored via `resolveHoistedCodeBlockAnchor` (EDITOR-9045).
|
|
70
|
+
*
|
|
71
|
+
* Returns one decoration normally, two (marker + tag) when hoisted out of a code block.
|
|
54
72
|
*
|
|
55
73
|
* The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
|
|
56
74
|
* element ProseMirror drew it into — see `mountContributorTag`.
|
|
@@ -63,8 +81,8 @@ export declare const createContributorTagWidget: ({ anchorAtRangeStart, anchorNa
|
|
|
63
81
|
anchorAtRangeStart?: boolean;
|
|
64
82
|
/**
|
|
65
83
|
* The `anchor-name` the block's own decoration carries, so the tag positions against that box
|
|
66
|
-
* rather than against its host
|
|
67
|
-
*
|
|
84
|
+
* rather than against its host (EDITOR-8933). Ignored inside a code block, which anchors to its
|
|
85
|
+
* own marker instead.
|
|
68
86
|
*/
|
|
69
87
|
anchorName?: string;
|
|
70
88
|
diffId: string;
|
|
@@ -72,4 +90,4 @@ export declare const createContributorTagWidget: ({ anchorAtRangeStart, anchorNa
|
|
|
72
90
|
from: number;
|
|
73
91
|
mountContext?: ContributorTagMountContext;
|
|
74
92
|
to: number;
|
|
75
|
-
}) => Decoration | undefined;
|
|
93
|
+
}) => Decoration[] | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "17.1.
|
|
3
|
+
"version": "17.1.7",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"react-intl": "^7.0.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@atlaskit/editor-common": "^123.
|
|
74
|
+
"@atlaskit/editor-common": "^123.7.0",
|
|
75
75
|
"react": "^18.2.0 || ^19.2.0",
|
|
76
76
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
77
77
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|