@atlaskit/editor-plugin-show-diff 10.1.19 → 10.1.20
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 +8 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +10 -4
- package/dist/cjs/pm-plugins/decorations/createAnchorDecorationWidgets.js +218 -73
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +15 -1
- package/dist/cjs/ui/IndicatorBar/IndicatorBarContentComponent.js +18 -4
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +9 -4
- package/dist/es2019/pm-plugins/decorations/createAnchorDecorationWidgets.js +212 -67
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +12 -1
- package/dist/es2019/ui/IndicatorBar/IndicatorBarContentComponent.js +18 -4
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +10 -4
- package/dist/esm/pm-plugins/decorations/createAnchorDecorationWidgets.js +218 -72
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +14 -1
- package/dist/esm/ui/IndicatorBar/IndicatorBarContentComponent.js +18 -4
- package/dist/types/pm-plugins/decorations/createAnchorDecorationWidgets.d.ts +19 -0
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +4 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 10.1.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`afd15695098bb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/afd15695098bb) -
|
|
8
|
+
EDItOR-7711: Show block changed diff indicators.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 10.1.19
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -61,7 +61,9 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
61
61
|
isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
|
|
62
62
|
activeIndexPos = _ref2.activeIndexPos,
|
|
63
63
|
_ref2$shouldHideDelet = _ref2.shouldHideDeleted,
|
|
64
|
-
shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet
|
|
64
|
+
shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet,
|
|
65
|
+
_ref2$showIndicators = _ref2.showIndicators,
|
|
66
|
+
showIndicators = _ref2$showIndicators === void 0 ? false : _ref2$showIndicators;
|
|
65
67
|
var decorations = [];
|
|
66
68
|
// Iterate over the document nodes within the range
|
|
67
69
|
doc.nodesBetween(from, to, function (node, pos) {
|
|
@@ -77,7 +79,9 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
77
79
|
colorScheme: colorScheme,
|
|
78
80
|
isInserted: isInserted,
|
|
79
81
|
isActive: isActive,
|
|
80
|
-
shouldHideDeleted: shouldHideDeleted
|
|
82
|
+
shouldHideDeleted: shouldHideDeleted,
|
|
83
|
+
showIndicators: showIndicators,
|
|
84
|
+
doc: doc
|
|
81
85
|
})));
|
|
82
86
|
}
|
|
83
87
|
});
|
|
@@ -199,7 +203,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
199
203
|
colorScheme: colorScheme
|
|
200
204
|
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
201
205
|
isInserted: isInserted,
|
|
202
|
-
shouldHideDeleted: shouldHideDeleted
|
|
206
|
+
shouldHideDeleted: shouldHideDeleted,
|
|
207
|
+
showIndicators: showIndicators
|
|
203
208
|
}), {}, {
|
|
204
209
|
activeIndexPos: activeIndexPos,
|
|
205
210
|
intl: intl
|
|
@@ -334,7 +339,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
334
339
|
colorScheme: colorScheme,
|
|
335
340
|
isInserted: true,
|
|
336
341
|
activeIndexPos: activeIndexPos,
|
|
337
|
-
intl: intl
|
|
342
|
+
intl: intl,
|
|
343
|
+
showIndicators: showIndicators
|
|
338
344
|
})));
|
|
339
345
|
}
|
|
340
346
|
});
|
|
@@ -3,87 +3,88 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.createLeftAnchorWidget = exports.createInlineIndicatorAnchorWidgets = exports.createDocMarginAnchorWidget = void 0;
|
|
6
|
+
exports.createLeftAnchorWidget = exports.createInlineIndicatorAnchorWidgets = exports.createDocMarginAnchorWidget = exports.createBlockIndicatorAnchorWidgets = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
7
8
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
8
9
|
var _decorationKeys = require("./decorationKeys");
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the doc-level block node (table/expand/layout) for `from`, along with
|
|
12
|
+
* the position right before it (`beforePos`). Falls back to `$from.nodeAfter`
|
|
13
|
+
* when there is no depth-1 ancestor (e.g. `from` sits just before the block).
|
|
14
|
+
*/
|
|
15
|
+
var resolveDocLevelNode = function resolveDocLevelNode(doc, from) {
|
|
16
|
+
var _$from$node;
|
|
17
|
+
var $from = doc.resolve(from);
|
|
18
|
+
var node = (_$from$node = $from.node(1)) !== null && _$from$node !== void 0 ? _$from$node : $from.nodeAfter;
|
|
11
19
|
if (!node) {
|
|
12
20
|
return undefined;
|
|
13
21
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
return
|
|
22
|
+
|
|
23
|
+
// Content start of the block. For the depth-1 case this is `$from.start(1)`;
|
|
24
|
+
// for the `nodeAfter` fallback, `from` is the position just before the block
|
|
25
|
+
// node, so its content starts at `from + 1`.
|
|
26
|
+
var nodeStart = $from.node(1) ? $from.start(1) : from + 1;
|
|
27
|
+
return {
|
|
28
|
+
node: node,
|
|
29
|
+
nodeStart: nodeStart,
|
|
30
|
+
// Position of the block node itself (one before its content start).
|
|
31
|
+
beforePos: nodeStart - 1
|
|
32
|
+
};
|
|
20
33
|
};
|
|
21
34
|
|
|
22
35
|
/**
|
|
23
36
|
* Handles edge cases for block nodes whose inline content can exceed the doc
|
|
24
|
-
* margin (tables, layouts, expands). Returns
|
|
25
|
-
* the left anchor, or `undefined` when
|
|
37
|
+
* margin (tables, layouts, expands). Returns the position whose DOM should be
|
|
38
|
+
* measured to size the left anchor, or `undefined` when the diff is not inside
|
|
39
|
+
* such a node.
|
|
26
40
|
*/
|
|
27
41
|
var edgeCases = function edgeCases(doc, from) {
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
if (!docLevelNode) {
|
|
42
|
+
var resolved = resolveDocLevelNode(doc, from);
|
|
43
|
+
if (!resolved) {
|
|
31
44
|
return undefined;
|
|
32
45
|
}
|
|
33
|
-
|
|
46
|
+
var node = resolved.node,
|
|
47
|
+
nodeStart = resolved.nodeStart,
|
|
48
|
+
beforePos = resolved.beforePos;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* All resizable nodes will need dynamic calculations of the block indicator left anchor
|
|
52
|
+
*/
|
|
53
|
+
if (node.marks.some(function (mark) {
|
|
54
|
+
return mark.type.name === 'breakout';
|
|
55
|
+
})) {
|
|
56
|
+
/**
|
|
57
|
+
* Layouts and Expands have extra padding around the container
|
|
58
|
+
*/
|
|
59
|
+
return {
|
|
60
|
+
measurePos: beforePos
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
switch (node.type.name) {
|
|
34
64
|
/**
|
|
35
65
|
* For resizable blocks, inline content can exceed the doc margin.
|
|
36
|
-
* The
|
|
37
|
-
*
|
|
66
|
+
* The widget is placed before the block; the anchor is sized against the
|
|
67
|
+
* block's DOM so it doesn't get clipped when the block is resized :')
|
|
38
68
|
*/
|
|
39
69
|
case 'table':
|
|
40
70
|
{
|
|
41
|
-
|
|
42
|
-
if (!
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
var lastRowStart = $from.start(1) + docLevelNode.content.size - lastRow.nodeSize;
|
|
46
|
-
var firstCellOfLastRow = lastRow.firstChild;
|
|
47
|
-
var tableAnchorPos = findPosAfterLastChild(firstCellOfLastRow, lastRowStart + 1);
|
|
48
|
-
if (tableAnchorPos === undefined) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
/**
|
|
53
|
-
* We use the last row because the first row could be a sticky header -
|
|
54
|
-
* when it becomes sticky the anchor won't be defined since it will be rendered
|
|
55
|
-
* outside of the context
|
|
56
|
-
*/
|
|
57
|
-
pos: tableAnchorPos,
|
|
58
|
-
leftMargin: "var(--ds-space-negative-025, -2px)",
|
|
59
|
-
side: -1
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
case 'expand':
|
|
63
|
-
{
|
|
64
|
-
var expandAnchorPos = findPosAfterLastChild(docLevelNode, $from.start(1));
|
|
65
|
-
if (expandAnchorPos === undefined) {
|
|
71
|
+
// A table with no rows has nothing to measure.
|
|
72
|
+
if (!node.firstChild) {
|
|
66
73
|
return undefined;
|
|
67
74
|
}
|
|
75
|
+
|
|
76
|
+
// Measure the first row (`nodeStart` is just inside the table, i.e. the
|
|
77
|
+
// position of the first row): its width matches the table's.
|
|
68
78
|
return {
|
|
69
|
-
|
|
70
|
-
leftMargin: "var(--ds-space-0, 0px)",
|
|
71
|
-
side: -1
|
|
79
|
+
measurePos: nodeStart
|
|
72
80
|
};
|
|
73
81
|
}
|
|
74
82
|
case 'layoutSection':
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
pos: layoutAnchorPos,
|
|
83
|
-
leftMargin: "var(--ds-space-negative-025, -2px)",
|
|
84
|
-
side: 1
|
|
85
|
-
};
|
|
86
|
-
}
|
|
83
|
+
case 'expand':
|
|
84
|
+
// Measure the block itself (the widget is rendered outside the block).
|
|
85
|
+
return {
|
|
86
|
+
leftOffset: 12
|
|
87
|
+
};
|
|
87
88
|
default:
|
|
88
89
|
return undefined;
|
|
89
90
|
}
|
|
@@ -99,9 +100,11 @@ var createDocMarginAnchorWidget = exports.createDocMarginAnchorWidget = function
|
|
|
99
100
|
var span = document.createElement('span');
|
|
100
101
|
span.style.setProperty('anchor-name', "--".concat(_decorationKeys.AnchorDocMarginKey));
|
|
101
102
|
return span;
|
|
102
|
-
},
|
|
103
|
+
},
|
|
104
|
+
// set the side to -999 so that it is always rendered before any other anchors
|
|
105
|
+
(0, _decorationKeys.buildAnchorDecorationSpec)({
|
|
103
106
|
anchorType: _decorationKeys.AnchorTypeKey.docMargin,
|
|
104
|
-
side:
|
|
107
|
+
side: -999
|
|
105
108
|
}));
|
|
106
109
|
};
|
|
107
110
|
|
|
@@ -123,20 +126,54 @@ var createLeftAnchorWidget = exports.createLeftAnchorWidget = function createLef
|
|
|
123
126
|
if (edgeCase === undefined) {
|
|
124
127
|
return undefined;
|
|
125
128
|
}
|
|
129
|
+
|
|
130
|
+
// Render the widget right before the doc-level node so it lives outside the
|
|
131
|
+
// resizable block container.
|
|
132
|
+
var resolved = resolveDocLevelNode(doc, from);
|
|
133
|
+
if (!resolved) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
var beforePos = resolved.beforePos;
|
|
126
137
|
var leftAnchorKey = (0, _decorationKeys.buildAnchorDecorationKey)({
|
|
127
138
|
diffId: diffId,
|
|
128
139
|
anchorType: _decorationKeys.AnchorTypeKey.left
|
|
129
140
|
});
|
|
130
|
-
return _view.Decoration.widget(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
return _view.Decoration.widget(beforePos, function (view, getPos) {
|
|
142
|
+
// Outer span stays in the flow but takes up no space.
|
|
143
|
+
var wrapper = document.createElement('div');
|
|
144
|
+
wrapper.style.setProperty('position', 'relative');
|
|
145
|
+
wrapper.style.setProperty('width', '100%');
|
|
146
|
+
|
|
147
|
+
// Inner span is absolutely positioned in the doc margin; it carries the
|
|
148
|
+
// `anchor-name` the IndicatorBar aligns its left edge against.
|
|
149
|
+
var anchor = document.createElement('div');
|
|
150
|
+
anchor.style.setProperty('anchor-name', "--".concat(leftAnchorKey));
|
|
151
|
+
anchor.style.setProperty('position', 'absolute');
|
|
152
|
+
anchor.style.setProperty('left', "calc(50% - ".concat((edgeCase === null || edgeCase === void 0 ? void 0 : edgeCase.leftOffset) || 0, "px)"));
|
|
153
|
+
anchor.style.setProperty('transform', 'translateX(-50%)');
|
|
154
|
+
wrapper.appendChild(anchor);
|
|
155
|
+
|
|
156
|
+
// The block DOM may not be settled synchronously (e.g. after a
|
|
157
|
+
// transaction), so defer the measurement like the gap cursor does.
|
|
158
|
+
requestAnimationFrame(function () {
|
|
159
|
+
// The widget may have been unmounted; bail if its position is gone.
|
|
160
|
+
// We still measure the stable block node position, not the widget's
|
|
161
|
+
// own position.
|
|
162
|
+
if (getPos() === undefined || edgeCase.measurePos === undefined) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
var dom = view.nodeDOM(edgeCase.measurePos);
|
|
166
|
+
if (dom instanceof HTMLElement) {
|
|
167
|
+
// The left anchor only needs the container width so the
|
|
168
|
+
// IndicatorBar can align against the block's horizontal extent.
|
|
169
|
+
anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
return wrapper;
|
|
136
173
|
}, (0, _decorationKeys.buildAnchorDecorationSpec)({
|
|
137
174
|
diffId: diffId,
|
|
138
175
|
anchorType: _decorationKeys.AnchorTypeKey.left,
|
|
139
|
-
side:
|
|
176
|
+
side: -999
|
|
140
177
|
}));
|
|
141
178
|
};
|
|
142
179
|
var isFullNodeRange = function isFullNodeRange(doc, from, to) {
|
|
@@ -150,6 +187,114 @@ var isFullNodeRange = function isFullNodeRange(doc, from, to) {
|
|
|
150
187
|
});
|
|
151
188
|
return matchesFullNodeRange;
|
|
152
189
|
};
|
|
190
|
+
/**
|
|
191
|
+
* Creates invisible anchor widgets for a single block-changed diff so that the
|
|
192
|
+
* `IndicatorBar` can use CSS anchor positioning to align itself with the diff.
|
|
193
|
+
*
|
|
194
|
+
* The interface mirrors `createInlineIndicatorAnchorWidgets`:
|
|
195
|
+
* - A `from` anchor is placed at the start of the node range (top of the bar).
|
|
196
|
+
* - A `to` anchor is placed at the end of the node range (bottom of the bar).
|
|
197
|
+
* - An optional `left` anchor is placed inside a resizable container (table,
|
|
198
|
+
* layout, expand) so the bar aligns within the container boundary.
|
|
199
|
+
*
|
|
200
|
+
* Unlike the inline variant there is no `isFullNodeRange` guard — block diffs
|
|
201
|
+
* always span exactly one block node so the anchors are always needed.
|
|
202
|
+
*/
|
|
203
|
+
var createBlockIndicatorAnchorWidgets = exports.createBlockIndicatorAnchorWidgets = function createBlockIndicatorAnchorWidgets(_ref2) {
|
|
204
|
+
var doc = _ref2.doc,
|
|
205
|
+
from = _ref2.from,
|
|
206
|
+
to = _ref2.to,
|
|
207
|
+
diffId = _ref2.diffId;
|
|
208
|
+
var leftAnchor = createLeftAnchorWidget({
|
|
209
|
+
doc: doc,
|
|
210
|
+
from: from,
|
|
211
|
+
diffId: diffId
|
|
212
|
+
});
|
|
213
|
+
var maybeLeftAnchor = leftAnchor ? [leftAnchor] : [];
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* A single anchor widget spans the full height of the block node, mimicking
|
|
217
|
+
* the gap cursor placement logic (see `place-gap-cursor.ts`): an element
|
|
218
|
+
* whose height is measured from the block's DOM so its box covers the block.
|
|
219
|
+
*
|
|
220
|
+
* Because the anchor rect covers the whole block, the `IndicatorBar` can
|
|
221
|
+
* resolve `top`, `bottom` and `left` against this one anchor (keyed by
|
|
222
|
+
* `diffId` with no `anchorType`) instead of separate `from`/`to` anchors.
|
|
223
|
+
*/
|
|
224
|
+
var blockAnchorKey = (0, _decorationKeys.buildAnchorDecorationKey)({
|
|
225
|
+
diffId: diffId
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* If `from` lands inside a table cell/header or a table row, the widget must
|
|
230
|
+
* still be rendered *outside* the table (widgets placed inside a table are
|
|
231
|
+
* clipped/mis-laid-out), but we want the anchor to be sized against the
|
|
232
|
+
* actual cell/row DOM. So we split into two positions:
|
|
233
|
+
* - `widgetPos`: where the widget DOM is rendered (outside the table).
|
|
234
|
+
* - `measurePos`: the closest cell/row whose DOM we measure for the height.
|
|
235
|
+
*/
|
|
236
|
+
var $from = doc.resolve(from);
|
|
237
|
+
var parentTable = (0, _utils.findParentNodeClosestToPos)($from, function (ancestor) {
|
|
238
|
+
return ancestor.type.name === 'table';
|
|
239
|
+
});
|
|
240
|
+
var parentCellOrRow = (0, _utils.findParentNodeClosestToPos)($from, function (ancestor) {
|
|
241
|
+
return ['tableCell', 'tableHeader', 'tableRow'].includes(ancestor.type.name);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// Render outside the table when inside one; otherwise keep the original pos.
|
|
245
|
+
var widgetPos = parentTable ? parentTable.pos : from;
|
|
246
|
+
// Measure the actual cell/row DOM when inside one; otherwise measure the
|
|
247
|
+
// widget's own position.
|
|
248
|
+
var measurePos = parentCellOrRow ? parentCellOrRow.pos : from;
|
|
249
|
+
var blockWidget = _view.Decoration.widget(widgetPos, function (view, getPos) {
|
|
250
|
+
// Outer span stays in the flow but takes up no space.
|
|
251
|
+
var wrapper = document.createElement('span');
|
|
252
|
+
wrapper.style.setProperty('position', 'relative');
|
|
253
|
+
|
|
254
|
+
// Inner span is absolutely positioned and sized to the block height;
|
|
255
|
+
// it carries the `anchor-name` the IndicatorBar aligns against.
|
|
256
|
+
var anchor = document.createElement('span');
|
|
257
|
+
anchor.style.setProperty('position', 'absolute');
|
|
258
|
+
anchor.style.setProperty('anchor-name', "--".concat(blockAnchorKey));
|
|
259
|
+
wrapper.appendChild(anchor);
|
|
260
|
+
|
|
261
|
+
// The block DOM may not be settled synchronously (e.g. after a
|
|
262
|
+
// transaction), so defer the measurement like the gap cursor does.
|
|
263
|
+
requestAnimationFrame(function () {
|
|
264
|
+
// The widget may have been unmounted; bail if its position is gone.
|
|
265
|
+
// We still measure the stable cell/row node position, not the
|
|
266
|
+
// widget's own position.
|
|
267
|
+
if (getPos() === undefined) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
var dom = view.nodeDOM(measurePos);
|
|
271
|
+
if (dom instanceof HTMLElement) {
|
|
272
|
+
anchor.style.setProperty('height', "".concat(dom.offsetHeight, "px"));
|
|
273
|
+
|
|
274
|
+
// The wrapper renders outside the table, so there is a vertical
|
|
275
|
+
// gap between it and the cell/row we're anchoring to. Measure
|
|
276
|
+
// that delta and offset the (absolutely positioned) anchor by it
|
|
277
|
+
// so its box lines up with the cell/row.
|
|
278
|
+
var wrapperTop = wrapper.getBoundingClientRect().top;
|
|
279
|
+
var domTop = dom.getBoundingClientRect().top;
|
|
280
|
+
var verticalOffset = domTop - wrapperTop;
|
|
281
|
+
anchor.style.setProperty('top', "".concat(verticalOffset, "px"));
|
|
282
|
+
// The offset already accounts for the cell/row's position, so the
|
|
283
|
+
// margin-top must not be double-applied.
|
|
284
|
+
anchor.style.setProperty('margin-top', '0px');
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
return wrapper;
|
|
288
|
+
}, (0, _decorationKeys.buildAnchorDecorationSpec)({
|
|
289
|
+
diffId: diffId,
|
|
290
|
+
// Reuse the `from` anchor type slot; the generated key intentionally
|
|
291
|
+
// omits the anchor type so the single element backs top/bottom/left.
|
|
292
|
+
anchorType: _decorationKeys.AnchorTypeKey.from,
|
|
293
|
+
side: -1
|
|
294
|
+
}));
|
|
295
|
+
return [blockWidget].concat(maybeLeftAnchor);
|
|
296
|
+
};
|
|
297
|
+
|
|
153
298
|
/**
|
|
154
299
|
* Creates invisible anchor widgets for a single inline diff range so that the
|
|
155
300
|
* `IndicatorBar` can use CSS anchor positioning to align itself with the diff.
|
|
@@ -159,11 +304,11 @@ var isFullNodeRange = function isFullNodeRange(doc, from, to) {
|
|
|
159
304
|
* - An optional `left` anchor is placed before the first textblock when the
|
|
160
305
|
* diff is inside a resizable block node (table, layout, expand).
|
|
161
306
|
*/
|
|
162
|
-
var createInlineIndicatorAnchorWidgets = exports.createInlineIndicatorAnchorWidgets = function createInlineIndicatorAnchorWidgets(
|
|
163
|
-
var doc =
|
|
164
|
-
from =
|
|
165
|
-
to =
|
|
166
|
-
diffId =
|
|
307
|
+
var createInlineIndicatorAnchorWidgets = exports.createInlineIndicatorAnchorWidgets = function createInlineIndicatorAnchorWidgets(_ref3) {
|
|
308
|
+
var doc = _ref3.doc,
|
|
309
|
+
from = _ref3.from,
|
|
310
|
+
to = _ref3.to,
|
|
311
|
+
diffId = _ref3.diffId;
|
|
167
312
|
if (isFullNodeRange(doc, from, to)) {
|
|
168
313
|
return [];
|
|
169
314
|
}
|
|
@@ -176,8 +321,8 @@ var createInlineIndicatorAnchorWidgets = exports.createInlineIndicatorAnchorWidg
|
|
|
176
321
|
|
|
177
322
|
/**
|
|
178
323
|
* Two widgets mark the start and end of the inline range so the
|
|
179
|
-
* IndicatorBar can determine top/bottom even
|
|
180
|
-
*
|
|
324
|
+
* IndicatorBar can determine top/bottom even if
|
|
325
|
+
* the inline decoration is broken up by marks / between blocks.
|
|
181
326
|
*/
|
|
182
327
|
var fromAnchorKey = (0, _decorationKeys.buildAnchorDecorationKey)({
|
|
183
328
|
diffId: diffId,
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.createBlockChangedDecoration = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
9
11
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
12
|
var _standard = require("./colorSchemes/standard");
|
|
11
13
|
var _traditional = require("./colorSchemes/traditional");
|
|
14
|
+
var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
|
|
12
15
|
var _decorationKeys = require("./decorationKeys");
|
|
13
16
|
var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
14
17
|
display: 'none'
|
|
@@ -130,7 +133,10 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
130
133
|
_ref2$isActive = _ref2.isActive,
|
|
131
134
|
isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
|
|
132
135
|
_ref2$shouldHideDelet = _ref2.shouldHideDeleted,
|
|
133
|
-
shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet
|
|
136
|
+
shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet,
|
|
137
|
+
_ref2$showIndicators = _ref2.showIndicators,
|
|
138
|
+
showIndicators = _ref2$showIndicators === void 0 ? false : _ref2$showIndicators,
|
|
139
|
+
doc = _ref2.doc;
|
|
134
140
|
var decorations = [];
|
|
135
141
|
var diffId = crypto.randomUUID();
|
|
136
142
|
if (shouldHideDeleted) {
|
|
@@ -183,5 +189,13 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
183
189
|
nodeName: change.name
|
|
184
190
|
})));
|
|
185
191
|
}
|
|
192
|
+
if (decorations.length > 0 && showIndicators && doc && (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
193
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createAnchorDecorationWidgets.createBlockIndicatorAnchorWidgets)({
|
|
194
|
+
doc: doc,
|
|
195
|
+
from: change.from,
|
|
196
|
+
to: change.to,
|
|
197
|
+
diffId: diffId
|
|
198
|
+
})));
|
|
199
|
+
}
|
|
186
200
|
return decorations;
|
|
187
201
|
};
|
|
@@ -31,6 +31,24 @@ var renderIndicatorBar = function renderIndicatorBar(descriptor) {
|
|
|
31
31
|
})
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
+
case 'block':
|
|
35
|
+
{
|
|
36
|
+
// The block anchor is a single element (keyed by diffId with no
|
|
37
|
+
// anchorType) sized to the full height of the block node, so top,
|
|
38
|
+
// bottom and left all resolve against it.
|
|
39
|
+
var blockAnchor = (0, _decorationKeys.buildAnchorDecorationKey)({
|
|
40
|
+
diffId: descriptor.id
|
|
41
|
+
});
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_IndicatorBar.IndicatorBar, {
|
|
43
|
+
key: descriptor.id,
|
|
44
|
+
anchorTop: blockAnchor,
|
|
45
|
+
anchorBottom: blockAnchor,
|
|
46
|
+
anchorLeft: (0, _decorationKeys.buildAnchorDecorationKey)({
|
|
47
|
+
diffId: descriptor.id,
|
|
48
|
+
anchorType: _decorationKeys.AnchorTypeKey.left
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
34
52
|
case 'widget':
|
|
35
53
|
{
|
|
36
54
|
return /*#__PURE__*/_react.default.createElement(_IndicatorBar.IndicatorBar, {
|
|
@@ -50,10 +68,6 @@ var renderIndicatorBar = function renderIndicatorBar(descriptor) {
|
|
|
50
68
|
})
|
|
51
69
|
});
|
|
52
70
|
}
|
|
53
|
-
/**
|
|
54
|
-
* TODO EDITOR-7711:
|
|
55
|
-
* Support IndicatorBar for block-changed type diffs.
|
|
56
|
-
*/
|
|
57
71
|
default:
|
|
58
72
|
return null;
|
|
59
73
|
}
|
|
@@ -46,7 +46,8 @@ const calculateNodesForBlockDecoration = ({
|
|
|
46
46
|
colorScheme,
|
|
47
47
|
isInserted = true,
|
|
48
48
|
activeIndexPos,
|
|
49
|
-
shouldHideDeleted = false
|
|
49
|
+
shouldHideDeleted = false,
|
|
50
|
+
showIndicators = false
|
|
50
51
|
}) => {
|
|
51
52
|
const decorations = [];
|
|
52
53
|
// Iterate over the document nodes within the range
|
|
@@ -63,7 +64,9 @@ const calculateNodesForBlockDecoration = ({
|
|
|
63
64
|
colorScheme,
|
|
64
65
|
isInserted,
|
|
65
66
|
isActive,
|
|
66
|
-
shouldHideDeleted
|
|
67
|
+
shouldHideDeleted,
|
|
68
|
+
showIndicators,
|
|
69
|
+
doc
|
|
67
70
|
}));
|
|
68
71
|
}
|
|
69
72
|
});
|
|
@@ -178,7 +181,8 @@ const calculateDiffDecorationsInner = ({
|
|
|
178
181
|
colorScheme,
|
|
179
182
|
...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
180
183
|
isInserted,
|
|
181
|
-
shouldHideDeleted
|
|
184
|
+
shouldHideDeleted,
|
|
185
|
+
showIndicators
|
|
182
186
|
}),
|
|
183
187
|
activeIndexPos,
|
|
184
188
|
intl
|
|
@@ -310,7 +314,8 @@ const calculateDiffDecorationsInner = ({
|
|
|
310
314
|
colorScheme,
|
|
311
315
|
isInserted: true,
|
|
312
316
|
activeIndexPos,
|
|
313
|
-
intl
|
|
317
|
+
intl,
|
|
318
|
+
showIndicators
|
|
314
319
|
}));
|
|
315
320
|
}
|
|
316
321
|
});
|