@atlaskit/editor-plugin-show-diff 10.1.19 → 10.1.21
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 +14 -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 +8 -8
|
@@ -1,83 +1,85 @@
|
|
|
1
|
+
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
1
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import { buildAnchorDecorationKey, buildAnchorDecorationSpec, AnchorDocMarginKey, AnchorTypeKey } from './decorationKeys';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the doc-level block node (table/expand/layout) for `from`, along with
|
|
7
|
+
* the position right before it (`beforePos`). Falls back to `$from.nodeAfter`
|
|
8
|
+
* when there is no depth-1 ancestor (e.g. `from` sits just before the block).
|
|
9
|
+
*/
|
|
10
|
+
var resolveDocLevelNode = function resolveDocLevelNode(doc, from) {
|
|
11
|
+
var _$from$node;
|
|
12
|
+
var $from = doc.resolve(from);
|
|
13
|
+
var node = (_$from$node = $from.node(1)) !== null && _$from$node !== void 0 ? _$from$node : $from.nodeAfter;
|
|
5
14
|
if (!node) {
|
|
6
15
|
return undefined;
|
|
7
16
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
return
|
|
17
|
+
|
|
18
|
+
// Content start of the block. For the depth-1 case this is `$from.start(1)`;
|
|
19
|
+
// for the `nodeAfter` fallback, `from` is the position just before the block
|
|
20
|
+
// node, so its content starts at `from + 1`.
|
|
21
|
+
var nodeStart = $from.node(1) ? $from.start(1) : from + 1;
|
|
22
|
+
return {
|
|
23
|
+
node: node,
|
|
24
|
+
nodeStart: nodeStart,
|
|
25
|
+
// Position of the block node itself (one before its content start).
|
|
26
|
+
beforePos: nodeStart - 1
|
|
27
|
+
};
|
|
14
28
|
};
|
|
15
29
|
|
|
16
30
|
/**
|
|
17
31
|
* Handles edge cases for block nodes whose inline content can exceed the doc
|
|
18
|
-
* margin (tables, layouts, expands). Returns
|
|
19
|
-
* the left anchor, or `undefined` when
|
|
32
|
+
* margin (tables, layouts, expands). Returns the position whose DOM should be
|
|
33
|
+
* measured to size the left anchor, or `undefined` when the diff is not inside
|
|
34
|
+
* such a node.
|
|
20
35
|
*/
|
|
21
36
|
var edgeCases = function edgeCases(doc, from) {
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
if (!docLevelNode) {
|
|
37
|
+
var resolved = resolveDocLevelNode(doc, from);
|
|
38
|
+
if (!resolved) {
|
|
25
39
|
return undefined;
|
|
26
40
|
}
|
|
27
|
-
|
|
41
|
+
var node = resolved.node,
|
|
42
|
+
nodeStart = resolved.nodeStart,
|
|
43
|
+
beforePos = resolved.beforePos;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* All resizable nodes will need dynamic calculations of the block indicator left anchor
|
|
47
|
+
*/
|
|
48
|
+
if (node.marks.some(function (mark) {
|
|
49
|
+
return mark.type.name === 'breakout';
|
|
50
|
+
})) {
|
|
51
|
+
/**
|
|
52
|
+
* Layouts and Expands have extra padding around the container
|
|
53
|
+
*/
|
|
54
|
+
return {
|
|
55
|
+
measurePos: beforePos
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
switch (node.type.name) {
|
|
28
59
|
/**
|
|
29
60
|
* For resizable blocks, inline content can exceed the doc margin.
|
|
30
|
-
* The
|
|
31
|
-
*
|
|
61
|
+
* The widget is placed before the block; the anchor is sized against the
|
|
62
|
+
* block's DOM so it doesn't get clipped when the block is resized :')
|
|
32
63
|
*/
|
|
33
64
|
case 'table':
|
|
34
65
|
{
|
|
35
|
-
|
|
36
|
-
if (!
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
var lastRowStart = $from.start(1) + docLevelNode.content.size - lastRow.nodeSize;
|
|
40
|
-
var firstCellOfLastRow = lastRow.firstChild;
|
|
41
|
-
var tableAnchorPos = findPosAfterLastChild(firstCellOfLastRow, lastRowStart + 1);
|
|
42
|
-
if (tableAnchorPos === undefined) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
/**
|
|
47
|
-
* We use the last row because the first row could be a sticky header -
|
|
48
|
-
* when it becomes sticky the anchor won't be defined since it will be rendered
|
|
49
|
-
* outside of the context
|
|
50
|
-
*/
|
|
51
|
-
pos: tableAnchorPos,
|
|
52
|
-
leftMargin: "var(--ds-space-negative-025, -2px)",
|
|
53
|
-
side: -1
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
case 'expand':
|
|
57
|
-
{
|
|
58
|
-
var expandAnchorPos = findPosAfterLastChild(docLevelNode, $from.start(1));
|
|
59
|
-
if (expandAnchorPos === undefined) {
|
|
66
|
+
// A table with no rows has nothing to measure.
|
|
67
|
+
if (!node.firstChild) {
|
|
60
68
|
return undefined;
|
|
61
69
|
}
|
|
70
|
+
|
|
71
|
+
// Measure the first row (`nodeStart` is just inside the table, i.e. the
|
|
72
|
+
// position of the first row): its width matches the table's.
|
|
62
73
|
return {
|
|
63
|
-
|
|
64
|
-
leftMargin: "var(--ds-space-0, 0px)",
|
|
65
|
-
side: -1
|
|
74
|
+
measurePos: nodeStart
|
|
66
75
|
};
|
|
67
76
|
}
|
|
68
77
|
case 'layoutSection':
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
pos: layoutAnchorPos,
|
|
77
|
-
leftMargin: "var(--ds-space-negative-025, -2px)",
|
|
78
|
-
side: 1
|
|
79
|
-
};
|
|
80
|
-
}
|
|
78
|
+
case 'expand':
|
|
79
|
+
// Measure the block itself (the widget is rendered outside the block).
|
|
80
|
+
return {
|
|
81
|
+
leftOffset: 12
|
|
82
|
+
};
|
|
81
83
|
default:
|
|
82
84
|
return undefined;
|
|
83
85
|
}
|
|
@@ -93,9 +95,11 @@ export var createDocMarginAnchorWidget = function createDocMarginAnchorWidget()
|
|
|
93
95
|
var span = document.createElement('span');
|
|
94
96
|
span.style.setProperty('anchor-name', "--".concat(AnchorDocMarginKey));
|
|
95
97
|
return span;
|
|
96
|
-
},
|
|
98
|
+
},
|
|
99
|
+
// set the side to -999 so that it is always rendered before any other anchors
|
|
100
|
+
buildAnchorDecorationSpec({
|
|
97
101
|
anchorType: AnchorTypeKey.docMargin,
|
|
98
|
-
side:
|
|
102
|
+
side: -999
|
|
99
103
|
}));
|
|
100
104
|
};
|
|
101
105
|
|
|
@@ -117,20 +121,54 @@ export var createLeftAnchorWidget = function createLeftAnchorWidget(_ref) {
|
|
|
117
121
|
if (edgeCase === undefined) {
|
|
118
122
|
return undefined;
|
|
119
123
|
}
|
|
124
|
+
|
|
125
|
+
// Render the widget right before the doc-level node so it lives outside the
|
|
126
|
+
// resizable block container.
|
|
127
|
+
var resolved = resolveDocLevelNode(doc, from);
|
|
128
|
+
if (!resolved) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
var beforePos = resolved.beforePos;
|
|
120
132
|
var leftAnchorKey = buildAnchorDecorationKey({
|
|
121
133
|
diffId: diffId,
|
|
122
134
|
anchorType: AnchorTypeKey.left
|
|
123
135
|
});
|
|
124
|
-
return Decoration.widget(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
return Decoration.widget(beforePos, function (view, getPos) {
|
|
137
|
+
// Outer span stays in the flow but takes up no space.
|
|
138
|
+
var wrapper = document.createElement('div');
|
|
139
|
+
wrapper.style.setProperty('position', 'relative');
|
|
140
|
+
wrapper.style.setProperty('width', '100%');
|
|
141
|
+
|
|
142
|
+
// Inner span is absolutely positioned in the doc margin; it carries the
|
|
143
|
+
// `anchor-name` the IndicatorBar aligns its left edge against.
|
|
144
|
+
var anchor = document.createElement('div');
|
|
145
|
+
anchor.style.setProperty('anchor-name', "--".concat(leftAnchorKey));
|
|
146
|
+
anchor.style.setProperty('position', 'absolute');
|
|
147
|
+
anchor.style.setProperty('left', "calc(50% - ".concat((edgeCase === null || edgeCase === void 0 ? void 0 : edgeCase.leftOffset) || 0, "px)"));
|
|
148
|
+
anchor.style.setProperty('transform', 'translateX(-50%)');
|
|
149
|
+
wrapper.appendChild(anchor);
|
|
150
|
+
|
|
151
|
+
// The block DOM may not be settled synchronously (e.g. after a
|
|
152
|
+
// transaction), so defer the measurement like the gap cursor does.
|
|
153
|
+
requestAnimationFrame(function () {
|
|
154
|
+
// The widget may have been unmounted; bail if its position is gone.
|
|
155
|
+
// We still measure the stable block node position, not the widget's
|
|
156
|
+
// own position.
|
|
157
|
+
if (getPos() === undefined || edgeCase.measurePos === undefined) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
var dom = view.nodeDOM(edgeCase.measurePos);
|
|
161
|
+
if (dom instanceof HTMLElement) {
|
|
162
|
+
// The left anchor only needs the container width so the
|
|
163
|
+
// IndicatorBar can align against the block's horizontal extent.
|
|
164
|
+
anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return wrapper;
|
|
130
168
|
}, buildAnchorDecorationSpec({
|
|
131
169
|
diffId: diffId,
|
|
132
170
|
anchorType: AnchorTypeKey.left,
|
|
133
|
-
side:
|
|
171
|
+
side: -999
|
|
134
172
|
}));
|
|
135
173
|
};
|
|
136
174
|
var isFullNodeRange = function isFullNodeRange(doc, from, to) {
|
|
@@ -144,6 +182,114 @@ var isFullNodeRange = function isFullNodeRange(doc, from, to) {
|
|
|
144
182
|
});
|
|
145
183
|
return matchesFullNodeRange;
|
|
146
184
|
};
|
|
185
|
+
/**
|
|
186
|
+
* Creates invisible anchor widgets for a single block-changed diff so that the
|
|
187
|
+
* `IndicatorBar` can use CSS anchor positioning to align itself with the diff.
|
|
188
|
+
*
|
|
189
|
+
* The interface mirrors `createInlineIndicatorAnchorWidgets`:
|
|
190
|
+
* - A `from` anchor is placed at the start of the node range (top of the bar).
|
|
191
|
+
* - A `to` anchor is placed at the end of the node range (bottom of the bar).
|
|
192
|
+
* - An optional `left` anchor is placed inside a resizable container (table,
|
|
193
|
+
* layout, expand) so the bar aligns within the container boundary.
|
|
194
|
+
*
|
|
195
|
+
* Unlike the inline variant there is no `isFullNodeRange` guard — block diffs
|
|
196
|
+
* always span exactly one block node so the anchors are always needed.
|
|
197
|
+
*/
|
|
198
|
+
export var createBlockIndicatorAnchorWidgets = function createBlockIndicatorAnchorWidgets(_ref2) {
|
|
199
|
+
var doc = _ref2.doc,
|
|
200
|
+
from = _ref2.from,
|
|
201
|
+
to = _ref2.to,
|
|
202
|
+
diffId = _ref2.diffId;
|
|
203
|
+
var leftAnchor = createLeftAnchorWidget({
|
|
204
|
+
doc: doc,
|
|
205
|
+
from: from,
|
|
206
|
+
diffId: diffId
|
|
207
|
+
});
|
|
208
|
+
var maybeLeftAnchor = leftAnchor ? [leftAnchor] : [];
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A single anchor widget spans the full height of the block node, mimicking
|
|
212
|
+
* the gap cursor placement logic (see `place-gap-cursor.ts`): an element
|
|
213
|
+
* whose height is measured from the block's DOM so its box covers the block.
|
|
214
|
+
*
|
|
215
|
+
* Because the anchor rect covers the whole block, the `IndicatorBar` can
|
|
216
|
+
* resolve `top`, `bottom` and `left` against this one anchor (keyed by
|
|
217
|
+
* `diffId` with no `anchorType`) instead of separate `from`/`to` anchors.
|
|
218
|
+
*/
|
|
219
|
+
var blockAnchorKey = buildAnchorDecorationKey({
|
|
220
|
+
diffId: diffId
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* If `from` lands inside a table cell/header or a table row, the widget must
|
|
225
|
+
* still be rendered *outside* the table (widgets placed inside a table are
|
|
226
|
+
* clipped/mis-laid-out), but we want the anchor to be sized against the
|
|
227
|
+
* actual cell/row DOM. So we split into two positions:
|
|
228
|
+
* - `widgetPos`: where the widget DOM is rendered (outside the table).
|
|
229
|
+
* - `measurePos`: the closest cell/row whose DOM we measure for the height.
|
|
230
|
+
*/
|
|
231
|
+
var $from = doc.resolve(from);
|
|
232
|
+
var parentTable = findParentNodeClosestToPos($from, function (ancestor) {
|
|
233
|
+
return ancestor.type.name === 'table';
|
|
234
|
+
});
|
|
235
|
+
var parentCellOrRow = findParentNodeClosestToPos($from, function (ancestor) {
|
|
236
|
+
return ['tableCell', 'tableHeader', 'tableRow'].includes(ancestor.type.name);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Render outside the table when inside one; otherwise keep the original pos.
|
|
240
|
+
var widgetPos = parentTable ? parentTable.pos : from;
|
|
241
|
+
// Measure the actual cell/row DOM when inside one; otherwise measure the
|
|
242
|
+
// widget's own position.
|
|
243
|
+
var measurePos = parentCellOrRow ? parentCellOrRow.pos : from;
|
|
244
|
+
var blockWidget = Decoration.widget(widgetPos, function (view, getPos) {
|
|
245
|
+
// Outer span stays in the flow but takes up no space.
|
|
246
|
+
var wrapper = document.createElement('span');
|
|
247
|
+
wrapper.style.setProperty('position', 'relative');
|
|
248
|
+
|
|
249
|
+
// Inner span is absolutely positioned and sized to the block height;
|
|
250
|
+
// it carries the `anchor-name` the IndicatorBar aligns against.
|
|
251
|
+
var anchor = document.createElement('span');
|
|
252
|
+
anchor.style.setProperty('position', 'absolute');
|
|
253
|
+
anchor.style.setProperty('anchor-name', "--".concat(blockAnchorKey));
|
|
254
|
+
wrapper.appendChild(anchor);
|
|
255
|
+
|
|
256
|
+
// The block DOM may not be settled synchronously (e.g. after a
|
|
257
|
+
// transaction), so defer the measurement like the gap cursor does.
|
|
258
|
+
requestAnimationFrame(function () {
|
|
259
|
+
// The widget may have been unmounted; bail if its position is gone.
|
|
260
|
+
// We still measure the stable cell/row node position, not the
|
|
261
|
+
// widget's own position.
|
|
262
|
+
if (getPos() === undefined) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
var dom = view.nodeDOM(measurePos);
|
|
266
|
+
if (dom instanceof HTMLElement) {
|
|
267
|
+
anchor.style.setProperty('height', "".concat(dom.offsetHeight, "px"));
|
|
268
|
+
|
|
269
|
+
// The wrapper renders outside the table, so there is a vertical
|
|
270
|
+
// gap between it and the cell/row we're anchoring to. Measure
|
|
271
|
+
// that delta and offset the (absolutely positioned) anchor by it
|
|
272
|
+
// so its box lines up with the cell/row.
|
|
273
|
+
var wrapperTop = wrapper.getBoundingClientRect().top;
|
|
274
|
+
var domTop = dom.getBoundingClientRect().top;
|
|
275
|
+
var verticalOffset = domTop - wrapperTop;
|
|
276
|
+
anchor.style.setProperty('top', "".concat(verticalOffset, "px"));
|
|
277
|
+
// The offset already accounts for the cell/row's position, so the
|
|
278
|
+
// margin-top must not be double-applied.
|
|
279
|
+
anchor.style.setProperty('margin-top', '0px');
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
return wrapper;
|
|
283
|
+
}, buildAnchorDecorationSpec({
|
|
284
|
+
diffId: diffId,
|
|
285
|
+
// Reuse the `from` anchor type slot; the generated key intentionally
|
|
286
|
+
// omits the anchor type so the single element backs top/bottom/left.
|
|
287
|
+
anchorType: AnchorTypeKey.from,
|
|
288
|
+
side: -1
|
|
289
|
+
}));
|
|
290
|
+
return [blockWidget].concat(maybeLeftAnchor);
|
|
291
|
+
};
|
|
292
|
+
|
|
147
293
|
/**
|
|
148
294
|
* Creates invisible anchor widgets for a single inline diff range so that the
|
|
149
295
|
* `IndicatorBar` can use CSS anchor positioning to align itself with the diff.
|
|
@@ -153,11 +299,11 @@ var isFullNodeRange = function isFullNodeRange(doc, from, to) {
|
|
|
153
299
|
* - An optional `left` anchor is placed before the first textblock when the
|
|
154
300
|
* diff is inside a resizable block node (table, layout, expand).
|
|
155
301
|
*/
|
|
156
|
-
export var createInlineIndicatorAnchorWidgets = function createInlineIndicatorAnchorWidgets(
|
|
157
|
-
var doc =
|
|
158
|
-
from =
|
|
159
|
-
to =
|
|
160
|
-
diffId =
|
|
302
|
+
export var createInlineIndicatorAnchorWidgets = function createInlineIndicatorAnchorWidgets(_ref3) {
|
|
303
|
+
var doc = _ref3.doc,
|
|
304
|
+
from = _ref3.from,
|
|
305
|
+
to = _ref3.to,
|
|
306
|
+
diffId = _ref3.diffId;
|
|
161
307
|
if (isFullNodeRange(doc, from, to)) {
|
|
162
308
|
return [];
|
|
163
309
|
}
|
|
@@ -170,8 +316,8 @@ export var createInlineIndicatorAnchorWidgets = function createInlineIndicatorAn
|
|
|
170
316
|
|
|
171
317
|
/**
|
|
172
318
|
* Two widgets mark the start and end of the inline range so the
|
|
173
|
-
* IndicatorBar can determine top/bottom even
|
|
174
|
-
*
|
|
319
|
+
* IndicatorBar can determine top/bottom even if
|
|
320
|
+
* the inline decoration is broken up by marks / between blocks.
|
|
175
321
|
*/
|
|
176
322
|
var fromAnchorKey = buildAnchorDecorationKey({
|
|
177
323
|
diffId: diffId,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { standardDecorationMarkerVariable, deletedDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
5
6
|
import { traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
|
|
7
|
+
import { createBlockIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
|
|
6
8
|
import { buildDiffDecorationSpec } from './decorationKeys';
|
|
7
9
|
var displayNoneStyle = convertToInlineCss({
|
|
8
10
|
display: 'none'
|
|
@@ -124,7 +126,10 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
124
126
|
_ref2$isActive = _ref2.isActive,
|
|
125
127
|
isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
|
|
126
128
|
_ref2$shouldHideDelet = _ref2.shouldHideDeleted,
|
|
127
|
-
shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet
|
|
129
|
+
shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet,
|
|
130
|
+
_ref2$showIndicators = _ref2.showIndicators,
|
|
131
|
+
showIndicators = _ref2$showIndicators === void 0 ? false : _ref2$showIndicators,
|
|
132
|
+
doc = _ref2.doc;
|
|
128
133
|
var decorations = [];
|
|
129
134
|
var diffId = crypto.randomUUID();
|
|
130
135
|
if (shouldHideDeleted) {
|
|
@@ -177,5 +182,13 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
177
182
|
nodeName: change.name
|
|
178
183
|
})));
|
|
179
184
|
}
|
|
185
|
+
if (decorations.length > 0 && showIndicators && doc && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
186
|
+
decorations.push.apply(decorations, _toConsumableArray(createBlockIndicatorAnchorWidgets({
|
|
187
|
+
doc: doc,
|
|
188
|
+
from: change.from,
|
|
189
|
+
to: change.to,
|
|
190
|
+
diffId: diffId
|
|
191
|
+
})));
|
|
192
|
+
}
|
|
180
193
|
return decorations;
|
|
181
194
|
};
|
|
@@ -24,6 +24,24 @@ var renderIndicatorBar = function renderIndicatorBar(descriptor) {
|
|
|
24
24
|
})
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
case 'block':
|
|
28
|
+
{
|
|
29
|
+
// The block anchor is a single element (keyed by diffId with no
|
|
30
|
+
// anchorType) sized to the full height of the block node, so top,
|
|
31
|
+
// bottom and left all resolve against it.
|
|
32
|
+
var blockAnchor = buildAnchorDecorationKey({
|
|
33
|
+
diffId: descriptor.id
|
|
34
|
+
});
|
|
35
|
+
return /*#__PURE__*/React.createElement(IndicatorBar, {
|
|
36
|
+
key: descriptor.id,
|
|
37
|
+
anchorTop: blockAnchor,
|
|
38
|
+
anchorBottom: blockAnchor,
|
|
39
|
+
anchorLeft: buildAnchorDecorationKey({
|
|
40
|
+
diffId: descriptor.id,
|
|
41
|
+
anchorType: AnchorTypeKey.left
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
27
45
|
case 'widget':
|
|
28
46
|
{
|
|
29
47
|
return /*#__PURE__*/React.createElement(IndicatorBar, {
|
|
@@ -43,10 +61,6 @@ var renderIndicatorBar = function renderIndicatorBar(descriptor) {
|
|
|
43
61
|
})
|
|
44
62
|
});
|
|
45
63
|
}
|
|
46
|
-
/**
|
|
47
|
-
* TODO EDITOR-7711:
|
|
48
|
-
* Support IndicatorBar for block-changed type diffs.
|
|
49
|
-
*/
|
|
50
64
|
default:
|
|
51
65
|
return null;
|
|
52
66
|
}
|
|
@@ -21,6 +21,25 @@ export declare const createLeftAnchorWidget: ({ doc, from, diffId, }: {
|
|
|
21
21
|
doc: PMNode;
|
|
22
22
|
from: number;
|
|
23
23
|
}) => Decoration | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Creates invisible anchor widgets for a single block-changed diff so that the
|
|
26
|
+
* `IndicatorBar` can use CSS anchor positioning to align itself with the diff.
|
|
27
|
+
*
|
|
28
|
+
* The interface mirrors `createInlineIndicatorAnchorWidgets`:
|
|
29
|
+
* - A `from` anchor is placed at the start of the node range (top of the bar).
|
|
30
|
+
* - A `to` anchor is placed at the end of the node range (bottom of the bar).
|
|
31
|
+
* - An optional `left` anchor is placed inside a resizable container (table,
|
|
32
|
+
* layout, expand) so the bar aligns within the container boundary.
|
|
33
|
+
*
|
|
34
|
+
* Unlike the inline variant there is no `isFullNodeRange` guard — block diffs
|
|
35
|
+
* always span exactly one block node so the anchors are always needed.
|
|
36
|
+
*/
|
|
37
|
+
export declare const createBlockIndicatorAnchorWidgets: ({ doc, from, to, diffId, }: {
|
|
38
|
+
diffId: string;
|
|
39
|
+
doc: PMNode;
|
|
40
|
+
from: number;
|
|
41
|
+
to: number;
|
|
42
|
+
}) => Decoration[];
|
|
24
43
|
/**
|
|
25
44
|
* Creates invisible anchor widgets for a single inline diff range so that the
|
|
26
45
|
* `IndicatorBar` can use CSS anchor positioning to align itself with the diff.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
1
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
4
|
/**
|
|
@@ -8,14 +9,16 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
8
9
|
* @param isActive Whether this node is part of the currently active/focused change
|
|
9
10
|
* @returns Prosemirror node decoration or undefined
|
|
10
11
|
*/
|
|
11
|
-
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, }: {
|
|
12
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, showIndicators, doc, }: {
|
|
12
13
|
change: {
|
|
13
14
|
from: number;
|
|
14
15
|
name: string;
|
|
15
16
|
to: number;
|
|
16
17
|
};
|
|
17
18
|
colorScheme?: ColorScheme;
|
|
19
|
+
doc?: PMNode;
|
|
18
20
|
isActive?: boolean;
|
|
19
21
|
isInserted?: boolean;
|
|
20
22
|
shouldHideDeleted?: boolean;
|
|
23
|
+
showIndicators?: boolean;
|
|
21
24
|
}) => Decoration[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.21",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"atlaskit:src": "src/index.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaskit/adf-schema": "^56.
|
|
23
|
+
"@atlaskit/adf-schema": "^56.1.0",
|
|
24
24
|
"@atlaskit/custom-steps": "^1.0.0",
|
|
25
25
|
"@atlaskit/editor-plugin-analytics": "^12.0.0",
|
|
26
26
|
"@atlaskit/editor-plugin-expand": "^13.1.0",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
29
29
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
30
30
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
31
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
32
|
-
"@atlaskit/tokens": "^15.
|
|
31
|
+
"@atlaskit/tmp-editor-statsig": "^122.0.0",
|
|
32
|
+
"@atlaskit/tokens": "^15.5.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
34
|
"@compiled/react": "^0.20.0",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"prosemirror-changeset": "^2.3.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@atlaskit/adf-utils": "^20.
|
|
40
|
+
"@atlaskit/adf-utils": "^20.3.0",
|
|
41
41
|
"@atlaskit/button": "^24.3.0",
|
|
42
42
|
"@atlaskit/css": "^1.0.0",
|
|
43
|
-
"@atlaskit/editor-core": "^221.
|
|
43
|
+
"@atlaskit/editor-core": "^221.7.0",
|
|
44
44
|
"@atlaskit/editor-json-transformer": "^9.0.0",
|
|
45
45
|
"@atlaskit/form": "^16.1.0",
|
|
46
|
-
"@atlaskit/primitives": "^20.
|
|
46
|
+
"@atlaskit/primitives": "^20.5.0",
|
|
47
47
|
"@atlaskit/section-message": "^9.2.0",
|
|
48
48
|
"@atlaskit/textarea": "^9.1.0",
|
|
49
49
|
"@atlassian/confluence-presets": "workspace:^",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"react-intl": "^7.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^116.
|
|
56
|
+
"@atlaskit/editor-common": "^116.24.0",
|
|
57
57
|
"react": "^18.2.0"
|
|
58
58
|
},
|
|
59
59
|
"techstack": {
|