@atlaskit/editor-plugin-show-diff 24.0.0 → 24.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +1 -9
- package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +16 -3
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +16 -4
- package/dist/cjs/pm-plugins/decorations/decorationKeys.js +9 -1
- package/dist/cjs/pm-plugins/decorations/extractContributorTags.js +41 -23
- package/dist/cjs/pm-plugins/decorations/utils/getWidgetElement.js +16 -0
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +10 -0
- package/dist/cjs/pm-plugins/getDeletedWidgets.js +2 -12
- package/dist/cjs/pm-plugins/main.js +26 -0
- package/dist/cjs/pm-plugins/utils/taggableBlockNodes.js +1 -1
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +1 -5
- package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +16 -3
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +20 -10
- package/dist/es2019/pm-plugins/decorations/decorationKeys.js +7 -0
- package/dist/es2019/pm-plugins/decorations/extractContributorTags.js +22 -2
- package/dist/es2019/pm-plugins/decorations/utils/getWidgetElement.js +11 -0
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +10 -0
- package/dist/es2019/pm-plugins/getDeletedWidgets.js +1 -12
- package/dist/es2019/pm-plugins/main.js +26 -0
- package/dist/es2019/pm-plugins/utils/taggableBlockNodes.js +1 -1
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +1 -9
- package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +16 -3
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +16 -4
- package/dist/esm/pm-plugins/decorations/decorationKeys.js +9 -1
- package/dist/esm/pm-plugins/decorations/extractContributorTags.js +41 -23
- package/dist/esm/pm-plugins/decorations/utils/getWidgetElement.js +10 -0
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +10 -0
- package/dist/esm/pm-plugins/getDeletedWidgets.js +1 -11
- package/dist/esm/pm-plugins/main.js +26 -0
- package/dist/esm/pm-plugins/utils/taggableBlockNodes.js +1 -1
- package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +2 -0
- package/dist/types/pm-plugins/decorations/utils/getWidgetElement.d.ts +2 -0
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
+
import { resolveBaseNodeName } from '../utils/baseNodeName';
|
|
2
3
|
import { isDiffDecoration, isDiffDecorationSpec } from './decorationKeys';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -32,7 +33,10 @@ const leadsReplacement = widget => fg('confluence_ncs_step_diffing_version_histo
|
|
|
32
33
|
* block keeps the tag — one tag per block. Only when the block fully covers `inner`; a wider
|
|
33
34
|
* inline/widget range that merely overlaps the block is a separate change (EDITOR-9473).
|
|
34
35
|
*/
|
|
35
|
-
const isSameBlockChange = (inner, block) => inner.spec.attributionKey === block.spec.attributionKey &&
|
|
36
|
+
const isSameBlockChange = (inner, block) => inner.spec.attributionKey === block.spec.attributionKey && (inner.spec.decorationType === 'widget' ?
|
|
37
|
+
// Deleted content is zero-width and sits at the start of what replaced it, so a widget at the
|
|
38
|
+
// block's edge is beside the block rather than within it and keeps its own tag.
|
|
39
|
+
block.from < inner.from && inner.to < block.to : block.from <= inner.from && inner.to <= block.to);
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
42
|
* Whether `outer` is the box `inner` sits in, for one contributor. Nested blocks they inserted read
|
|
@@ -50,6 +54,21 @@ const byLeadingPosition = (a, b) => {
|
|
|
50
54
|
return a.decoration.from - b.decoration.from || ((_a$decoration$spec$si = a.decoration.spec.side) !== null && _a$decoration$spec$si !== void 0 ? _a$decoration$spec$si : 0) - ((_b$decoration$spec$si = b.decoration.spec.side) !== null && _b$decoration$spec$si !== void 0 ? _b$decoration$spec$si : 0) || a.decoration.to - a.decoration.from - (b.decoration.to - b.decoration.from);
|
|
51
55
|
};
|
|
52
56
|
|
|
57
|
+
/** Select the first layout column only when the inline layout range starts immediately before it. */
|
|
58
|
+
const navigationLeader = members => {
|
|
59
|
+
const ordered = [...members].sort(byLeadingPosition);
|
|
60
|
+
const layoutColumn = fg('confluence_ncs_step_diffing_version_history') ? ordered.find(({
|
|
61
|
+
decoration
|
|
62
|
+
}) => {
|
|
63
|
+
var _decoration$spec$node;
|
|
64
|
+
return decoration.spec.decorationType === 'block' && resolveBaseNodeName((_decoration$spec$node = decoration.spec.nodeName) !== null && _decoration$spec$node !== void 0 ? _decoration$spec$node : '') === 'layoutColumn';
|
|
65
|
+
}) : undefined;
|
|
66
|
+
const startsWholeLayout = layoutColumn !== undefined && members.some(({
|
|
67
|
+
decoration
|
|
68
|
+
}) => decoration.spec.decorationType === 'inline' && decoration.from === layoutColumn.decoration.from - 1);
|
|
69
|
+
return startsWholeLayout ? layoutColumn : ordered[0];
|
|
70
|
+
};
|
|
71
|
+
|
|
53
72
|
/** The targets a navigation range wholly covers, leader first. */
|
|
54
73
|
const containedBy = (targets, {
|
|
55
74
|
from,
|
|
@@ -224,7 +243,8 @@ export const extractContributorTags = (decorations, contributors, activeIndexPos
|
|
|
224
243
|
byStopAndContributor.set(key, [...((_byStopAndContributor = byStopAndContributor.get(key)) !== null && _byStopAndContributor !== void 0 ? _byStopAndContributor : []), target]);
|
|
225
244
|
}
|
|
226
245
|
for (const members of byStopAndContributor.values()) {
|
|
227
|
-
const
|
|
246
|
+
const leader = navigationLeader(members);
|
|
247
|
+
const trailing = members.filter(target => target !== leader);
|
|
228
248
|
trailing.forEach(target => fold(leader, target));
|
|
229
249
|
}
|
|
230
250
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// prosemirror-view does not type `Decoration.type`; a widget's `type.toDOM` is the node passed to
|
|
2
|
+
// `Decoration.widget()` (an element or a factory — the `WidgetConstructor` union).
|
|
3
|
+
|
|
4
|
+
// The element a widget renders, or undefined if it renders via a factory.
|
|
5
|
+
export const getWidgetElement = decoration => {
|
|
6
|
+
var _type;
|
|
7
|
+
const {
|
|
8
|
+
toDOM
|
|
9
|
+
} = (_type = decoration.type) !== null && _type !== void 0 ? _type : {};
|
|
10
|
+
return toDOM instanceof HTMLElement ? toDOM : undefined;
|
|
11
|
+
};
|
|
@@ -4,6 +4,7 @@ import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-uti
|
|
|
4
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
+
import { resolveBaseNodeName } from '../../utils/baseNodeName';
|
|
7
8
|
import { getAtomicInlineChangedAttrs } from '../createInlineChangedDecoration';
|
|
8
9
|
import { applyRevealToElement } from '../revealStyles';
|
|
9
10
|
import { isInlineAttrChangeNodeName } from './getAttrChangeRanges';
|
|
@@ -341,6 +342,15 @@ const createBlockNodeContentWrapper = ({
|
|
|
341
342
|
// should not also get the inline content style (borderBottom underline) on their container.
|
|
342
343
|
const shouldSkipContentStyle = isInserted && nodeStyle !== undefined;
|
|
343
344
|
const contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted, hideAddedDiffsUnderline);
|
|
345
|
+
const isEmptyDeletedLayoutColumn = !isInserted && resolveBaseNodeName(targetNode.type.name) === 'layoutColumn' && targetNode.textContent.length === 0 && fg('confluence_ncs_step_diffing_version_history');
|
|
346
|
+
if (isEmptyDeletedLayoutColumn && nodeView instanceof HTMLElement) {
|
|
347
|
+
var _nodeView$querySelect;
|
|
348
|
+
// Give an empty deleted column height so its diff box doesn't collapse
|
|
349
|
+
const placeholderTarget = (_nodeView$querySelect = nodeView.querySelector('[data-layout-content]')) !== null && _nodeView$querySelect !== void 0 ? _nodeView$querySelect : nodeView;
|
|
350
|
+
appendStyleToElement(placeholderTarget, convertToInlineCss({
|
|
351
|
+
minHeight: "var(--ds-space-300, 24px)"
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
344
354
|
|
|
345
355
|
// A `breakout` node renders wider than the editor column while the wrapper divs
|
|
346
356
|
// stay at column width, so paint the outline on the node element that spans that width.
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { isDiffDecorationSpec } from './decorations/decorationKeys';
|
|
2
|
+
import { getWidgetElement } from './decorations/utils/getWidgetElement';
|
|
2
3
|
import { showDiffPluginKey } from './main';
|
|
3
4
|
|
|
4
|
-
// prosemirror-view does not type `Decoration.type`; a widget's `type.toDOM` is the node passed to
|
|
5
|
-
// `Decoration.widget()` (an element or a factory — the `WidgetConstructor` union).
|
|
6
|
-
|
|
7
|
-
// The element a deleted-content widget renders, or undefined if it renders via a factory.
|
|
8
|
-
const getWidgetElement = decoration => {
|
|
9
|
-
var _type;
|
|
10
|
-
const {
|
|
11
|
-
toDOM
|
|
12
|
-
} = (_type = decoration.type) !== null && _type !== void 0 ? _type : {};
|
|
13
|
-
return toDOM instanceof HTMLElement ? toDOM : undefined;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
5
|
/**
|
|
17
6
|
* The rendered deleted-content widgets in `editorState`, optionally restricted to `[from, to]`,
|
|
18
7
|
* ordered by position. Deleted content is rendered as widget decorations rather than document
|
|
@@ -8,6 +8,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
8
8
|
import { getActiveDiffAnnouncement } from '../ui/DiffNavigation/announceActiveDiff';
|
|
9
9
|
import { calculateDiffDecorations } from './calculateDiff/calculateDiffDecorations';
|
|
10
10
|
import { isDiffDecoration, isDiffDecorationSpec } from './decorations/decorationKeys';
|
|
11
|
+
import { getWidgetElement } from './decorations/utils/getWidgetElement';
|
|
11
12
|
import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
|
|
12
13
|
import { getDefaultDiffType } from './getDefaultDiffType';
|
|
13
14
|
import { getScrollableDecorations } from './getScrollableDecorations';
|
|
@@ -305,6 +306,31 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
|
|
|
305
306
|
};
|
|
306
307
|
},
|
|
307
308
|
props: {
|
|
309
|
+
handleDOMEvents: {
|
|
310
|
+
// Bypass ProseMirror's copy handler without preventing native browser copy
|
|
311
|
+
// when the selection is completely contained within an inverted diff widget
|
|
312
|
+
copy: view => {
|
|
313
|
+
if (!fg('platform_editor_ai_show_diff_patch_2')) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
const pluginState = showDiffPluginKey.getState(view.state);
|
|
317
|
+
if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDisplayingChanges) || !pluginState.isInverted) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
const selection = view.dom.ownerDocument.getSelection();
|
|
321
|
+
if (!selection || selection.isCollapsed || selection.rangeCount !== 1) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
const range = selection.getRangeAt(0);
|
|
325
|
+
return pluginState.decorations.find().filter(isDiffDecoration).some(decoration => {
|
|
326
|
+
if (decoration.spec.decorationType !== 'widget') {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
const dom = getWidgetElement(decoration);
|
|
330
|
+
return Boolean(dom && view.dom.contains(dom) && dom.contains(range.startContainer) && dom.contains(range.endContainer));
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
},
|
|
308
334
|
decorations: state => {
|
|
309
335
|
const pluginState = showDiffPluginKey.getState(state);
|
|
310
336
|
return pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations;
|
|
@@ -10,7 +10,7 @@ import { resolveBaseNodeName } from './baseNodeName';
|
|
|
10
10
|
*
|
|
11
11
|
* Base names only — match with the predicates below, never against `type.name` directly.
|
|
12
12
|
*/
|
|
13
|
-
const TAGGABLE_BLOCK_NODES = new Set(['blockCard', 'blockquote', 'bodiedExtension', 'codeBlock', 'decisionList', 'embedCard', 'expand', 'extension', 'media', 'multiBodiedExtension', 'panel', 'rule', 'taskList']);
|
|
13
|
+
const TAGGABLE_BLOCK_NODES = new Set(['blockCard', 'blockquote', 'bodiedExtension', 'codeBlock', 'decisionList', 'embedCard', 'expand', 'extension', 'layoutColumn', 'media', 'multiBodiedExtension', 'panel', 'rule', 'taskList']);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Whether this node hosts a contributor tag of its own. Navigation grouping does not consult this:
|
|
@@ -3,7 +3,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
6
|
-
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
8
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
8
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
@@ -27,13 +26,6 @@ var UNSTYLED_NODES = ['mediaSingle', 'mediaGroup', 'table',
|
|
|
27
26
|
'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'];
|
|
28
27
|
var CELL_NODES = ['tableCell', 'tableHeader'];
|
|
29
28
|
|
|
30
|
-
/** Panels, rules and media can also sit in a table cell, which is out of scope for block tags. */
|
|
31
|
-
var isInsideTable = function isInsideTable(doc, pos) {
|
|
32
|
-
return findParentNodeClosestToPos(doc.resolve(pos), function (node) {
|
|
33
|
-
return node.type.name === 'table';
|
|
34
|
-
}) !== undefined;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
29
|
/**
|
|
38
30
|
* Whether this block can host a contributor tag of its own.
|
|
39
31
|
*
|
|
@@ -49,7 +41,7 @@ var canTagBlock = function canTagBlock(_ref) {
|
|
|
49
41
|
return false;
|
|
50
42
|
}
|
|
51
43
|
var nodeType = (_doc$nodeAt = doc.nodeAt(from)) === null || _doc$nodeAt === void 0 ? void 0 : _doc$nodeAt.type;
|
|
52
|
-
return nodeType !== undefined && isTaggableBlockNode(nodeType)
|
|
44
|
+
return nodeType !== undefined && isTaggableBlockNode(nodeType);
|
|
53
45
|
};
|
|
54
46
|
|
|
55
47
|
/** Positioning context for the cell overlay widget decorations. */
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
6
|
import { ContributorTagController } from '../../ui/ContributorTag/contributorTagController';
|
|
7
|
+
import { resolveBaseNodeName } from '../utils/baseNodeName';
|
|
7
8
|
import { buildCharsByOffset, isWhitespaceChar } from '../utils/charsByOffset';
|
|
8
9
|
import { clampAnchorPosIntoCell, createAnchorNameSpan } from './createAnchorDecorationWidgets';
|
|
9
10
|
import { AnchorTypeKey, buildAnchorDecorationKey, buildAnchorDecorationSpec, buildContributorTagDecorationSpec } from './decorationKeys';
|
|
@@ -213,6 +214,16 @@ export var resolveHoistedCodeBlockAnchor = function resolveHoistedCodeBlockAncho
|
|
|
213
214
|
};
|
|
214
215
|
};
|
|
215
216
|
|
|
217
|
+
/** Find the position before a layout for a tag anchored to one of its columns. */
|
|
218
|
+
var resolveLayoutSectionStart = function resolveLayoutSectionStart(doc, pos) {
|
|
219
|
+
var _doc$nodeAt$type$name, _doc$nodeAt;
|
|
220
|
+
if (resolveBaseNodeName((_doc$nodeAt$type$name = (_doc$nodeAt = doc.nodeAt(pos)) === null || _doc$nodeAt === void 0 ? void 0 : _doc$nodeAt.type.name) !== null && _doc$nodeAt$type$name !== void 0 ? _doc$nodeAt$type$name : '') !== 'layoutColumn') {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
var $pos = doc.resolve(pos);
|
|
224
|
+
return resolveBaseNodeName($pos.parent.type.name) === 'layoutSection' ? $pos.before($pos.depth) : undefined;
|
|
225
|
+
};
|
|
226
|
+
|
|
216
227
|
/**
|
|
217
228
|
* The contributor tag widget for one diff range, placed on the first visible character the range
|
|
218
229
|
* highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
|
|
@@ -225,7 +236,7 @@ export var resolveHoistedCodeBlockAnchor = function resolveHoistedCodeBlockAncho
|
|
|
225
236
|
* element ProseMirror drew it into — see `mountContributorTag`.
|
|
226
237
|
*/
|
|
227
238
|
export var createContributorTagWidget = function createContributorTagWidget(_ref4) {
|
|
228
|
-
var _hoisted$
|
|
239
|
+
var _ref5, _hoisted$anchorName, _hoisted$codeBlockSta;
|
|
229
240
|
var _ref4$anchorAtRangeSt = _ref4.anchorAtRangeStart,
|
|
230
241
|
anchorAtRangeStart = _ref4$anchorAtRangeSt === void 0 ? false : _ref4$anchorAtRangeSt,
|
|
231
242
|
anchorName = _ref4.anchorName,
|
|
@@ -245,8 +256,6 @@ export var createContributorTagWidget = function createContributorTagWidget(_ref
|
|
|
245
256
|
// A change inside a code block is hoisted out of it, anchored to its own marker; anything else
|
|
246
257
|
// keeps its own anchor.
|
|
247
258
|
var hoisted = resolveHoistedCodeBlockAnchor(doc, anchorPos, diffId);
|
|
248
|
-
// Keep the host out of the table row's grid (EDITOR-8442).
|
|
249
|
-
var hostPos = clampAnchorPosIntoCell(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1);
|
|
250
259
|
|
|
251
260
|
// Inline diffs pass no anchorName. Give them their own point anchor instead of the
|
|
252
261
|
// `position: relative` fallback, which drifts left once the range wraps a line (EDITOR-9286).
|
|
@@ -256,6 +265,10 @@ export var createContributorTagWidget = function createContributorTagWidget(_ref
|
|
|
256
265
|
});
|
|
257
266
|
var effectiveAnchorName = (_ref5 = (_hoisted$anchorName = hoisted === null || hoisted === void 0 ? void 0 : hoisted.anchorName) !== null && _hoisted$anchorName !== void 0 ? _hoisted$anchorName : anchorName) !== null && _ref5 !== void 0 ? _ref5 : ownAnchorName;
|
|
258
267
|
var tagAnchorName = effectiveAnchorName && supportsAnchorPositioning() ? effectiveAnchorName : undefined;
|
|
268
|
+
var layoutSectionStart = tagAnchorName ? resolveLayoutSectionStart(doc, anchorPos) : undefined;
|
|
269
|
+
// Keep the host out of the table row's grid (EDITOR-8442). Layout-column tags are hoisted before
|
|
270
|
+
// their layout so the advanced layout widget-flattening rule cannot put them behind nearby text.
|
|
271
|
+
var hostPos = layoutSectionStart !== null && layoutSectionStart !== void 0 ? layoutSectionStart : clampAnchorPosIntoCell(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1);
|
|
259
272
|
var decorations = [];
|
|
260
273
|
if (hoisted) {
|
|
261
274
|
decorations.push(hoisted.marker);
|
|
@@ -3,6 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
|
+
import { resolveBaseNodeName } from '../utils/baseNodeName';
|
|
6
7
|
import { countEmptyTextBlockOnlySlice } from '../utils/emptyTextBlocks';
|
|
7
8
|
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
8
9
|
import { clampAnchorPosIntoCell, createAnchorNameSpan, createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
@@ -118,7 +119,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
|
|
|
118
119
|
* that is not in the current document.
|
|
119
120
|
*/
|
|
120
121
|
export var createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
|
|
121
|
-
var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
|
|
122
|
+
var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _hoistedCodeBlockAnch, _slice$content$firstC2;
|
|
122
123
|
var attributionKey = _ref2.attributionKey,
|
|
123
124
|
change = _ref2.change,
|
|
124
125
|
doc = _ref2.doc,
|
|
@@ -274,6 +275,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
274
275
|
// Match the rendering predicate above: an empty paragraph has no widget to tag, while whitespace
|
|
275
276
|
// text in a rendered widget remains eligible.
|
|
276
277
|
var canTagWidget = showContributorTags && !shouldSkipDeletedEmptyParagraphDecoration;
|
|
278
|
+
var contributorTagAnchorName;
|
|
277
279
|
var decorations = [];
|
|
278
280
|
var replacementNode = newDoc.nodeAt(change.fromB);
|
|
279
281
|
var firstReplacedNode = slice.content.firstChild;
|
|
@@ -374,6 +376,14 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
374
376
|
var $sourcePos = fg('platform_editor_ai_show_diff_patch_2') ? getSourcePos(doc, $changeFromA, slice.openStart, index) : null;
|
|
375
377
|
var nodeView = serializer.tryCreateNodeView(node, 0, $sourcePos !== null && $sourcePos !== void 0 ? $sourcePos : undefined, isInserted, colorScheme);
|
|
376
378
|
if (nodeView) {
|
|
379
|
+
if (canTagWidget && contributorTagAnchorName === undefined && resolveBaseNodeName(node.type.name) === 'layoutColumn' && nodeView instanceof HTMLElement && fg('confluence_ncs_step_diffing_version_history')) {
|
|
380
|
+
// The deleted column is rendered inside this widget; anchor to its box.
|
|
381
|
+
contributorTagAnchorName = buildAnchorDecorationKey({
|
|
382
|
+
diffId: diffId,
|
|
383
|
+
anchorType: AnchorTypeKey.tag
|
|
384
|
+
});
|
|
385
|
+
nodeView.style.setProperty('anchor-name', "--".concat(contributorTagAnchorName));
|
|
386
|
+
}
|
|
377
387
|
if (node.isInline) {
|
|
378
388
|
var wrapper = createContentWrapper(colorScheme, isActive, isInserted, reveal);
|
|
379
389
|
wrapper.append(nodeView);
|
|
@@ -421,7 +431,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
421
431
|
if (hoistedCodeBlockAnchor) {
|
|
422
432
|
decorations.push(hoistedCodeBlockAnchor.marker);
|
|
423
433
|
}
|
|
424
|
-
|
|
434
|
+
contributorTagAnchorName = (_hoistedCodeBlockAnch = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName) !== null && _hoistedCodeBlockAnch !== void 0 ? _hoistedCodeBlockAnch : contributorTagAnchorName;
|
|
425
435
|
if (!isInserted && deletedColumns !== null && deletedColumns !== void 0 && deletedColumns.length) {
|
|
426
436
|
var table = dom.querySelector('table');
|
|
427
437
|
var firstRow = table === null || table === void 0 ? void 0 : table.rows[0];
|
|
@@ -641,12 +651,14 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
641
651
|
if (fg('platform_editor_ai_show_diff_patch_1')) {
|
|
642
652
|
defaultSpacer.style.setProperty('scroll-margin-top', scrollMarginTopValue);
|
|
643
653
|
}
|
|
644
|
-
decorations.push(Decoration.widget(safeInsertPos, defaultSpacer,
|
|
654
|
+
decorations.push(Decoration.widget(safeInsertPos, defaultSpacer,
|
|
655
|
+
// Spacing only: a diff spec would make it an untagged navigation stop.
|
|
656
|
+
showContributorTags ? {} : buildDiffDecorationSpec({
|
|
645
657
|
colorScheme: colorScheme,
|
|
646
658
|
decorationType: 'widget',
|
|
647
659
|
diffId: crypto.randomUUID(),
|
|
648
660
|
isInserted: isInserted
|
|
649
|
-
})))
|
|
661
|
+
})));
|
|
650
662
|
}
|
|
651
663
|
}
|
|
652
664
|
return decorations;
|
|
@@ -2,6 +2,7 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
5
6
|
/**
|
|
6
7
|
* Decoration families produced by the show-diff plugin.
|
|
7
8
|
* Each family owns its own key space and spec shape.
|
|
@@ -72,7 +73,7 @@ export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
|
|
|
72
73
|
leftAnchorId = _ref3.leftAnchorId,
|
|
73
74
|
nodeName = _ref3.nodeName,
|
|
74
75
|
side = _ref3.side;
|
|
75
|
-
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
76
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
76
77
|
decorationFamily: DecorationFamily.diff,
|
|
77
78
|
decorationType: decorationType,
|
|
78
79
|
diffId: diffId,
|
|
@@ -95,6 +96,13 @@ export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
|
|
|
95
96
|
nodeName: nodeName
|
|
96
97
|
} : {}), side !== undefined ? {
|
|
97
98
|
side: side
|
|
99
|
+
} : {}), decorationType === 'widget' && fg('platform_editor_ai_show_diff_patch_2') ? {
|
|
100
|
+
// Widget content is outside the document. Keep its native DOM selection
|
|
101
|
+
// and let the browser handle events within it.
|
|
102
|
+
ignoreSelection: true,
|
|
103
|
+
stopEvent: function stopEvent() {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
98
106
|
} : {});
|
|
99
107
|
};
|
|
100
108
|
export function buildAnchorDecorationSpec(_ref4) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _toArray from "@babel/runtime/helpers/toArray";
|
|
3
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
4
|
var _excluded = ["connectedToKey"];
|
|
@@ -9,6 +8,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
9
8
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
9
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
10
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
11
|
+
import { resolveBaseNodeName } from '../utils/baseNodeName';
|
|
12
12
|
import { isDiffDecoration, isDiffDecorationSpec } from './decorationKeys';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -48,7 +48,10 @@ var leadsReplacement = function leadsReplacement(widget) {
|
|
|
48
48
|
* inline/widget range that merely overlaps the block is a separate change (EDITOR-9473).
|
|
49
49
|
*/
|
|
50
50
|
var isSameBlockChange = function isSameBlockChange(inner, block) {
|
|
51
|
-
return inner.spec.attributionKey === block.spec.attributionKey &&
|
|
51
|
+
return inner.spec.attributionKey === block.spec.attributionKey && (inner.spec.decorationType === 'widget' ?
|
|
52
|
+
// Deleted content is zero-width and sits at the start of what replaced it, so a widget at the
|
|
53
|
+
// block's edge is beside the block rather than within it and keeps its own tag.
|
|
54
|
+
block.from < inner.from && inner.to < block.to : block.from <= inner.from && inner.to <= block.to);
|
|
52
55
|
};
|
|
53
56
|
|
|
54
57
|
/**
|
|
@@ -69,12 +72,27 @@ var byLeadingPosition = function byLeadingPosition(a, b) {
|
|
|
69
72
|
return a.decoration.from - b.decoration.from || ((_a$decoration$spec$si = a.decoration.spec.side) !== null && _a$decoration$spec$si !== void 0 ? _a$decoration$spec$si : 0) - ((_b$decoration$spec$si = b.decoration.spec.side) !== null && _b$decoration$spec$si !== void 0 ? _b$decoration$spec$si : 0) || a.decoration.to - a.decoration.from - (b.decoration.to - b.decoration.from);
|
|
70
73
|
};
|
|
71
74
|
|
|
72
|
-
/**
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
/** Select the first layout column only when the inline layout range starts immediately before it. */
|
|
76
|
+
var navigationLeader = function navigationLeader(members) {
|
|
77
|
+
var ordered = _toConsumableArray(members).sort(byLeadingPosition);
|
|
78
|
+
var layoutColumn = fg('confluence_ncs_step_diffing_version_history') ? ordered.find(function (_ref2) {
|
|
79
|
+
var _decoration$spec$node;
|
|
80
|
+
var decoration = _ref2.decoration;
|
|
81
|
+
return decoration.spec.decorationType === 'block' && resolveBaseNodeName((_decoration$spec$node = decoration.spec.nodeName) !== null && _decoration$spec$node !== void 0 ? _decoration$spec$node : '') === 'layoutColumn';
|
|
82
|
+
}) : undefined;
|
|
83
|
+
var startsWholeLayout = layoutColumn !== undefined && members.some(function (_ref3) {
|
|
77
84
|
var decoration = _ref3.decoration;
|
|
85
|
+
return decoration.spec.decorationType === 'inline' && decoration.from === layoutColumn.decoration.from - 1;
|
|
86
|
+
});
|
|
87
|
+
return startsWholeLayout ? layoutColumn : ordered[0];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** The targets a navigation range wholly covers, leader first. */
|
|
91
|
+
var containedBy = function containedBy(targets, _ref4) {
|
|
92
|
+
var from = _ref4.from,
|
|
93
|
+
to = _ref4.to;
|
|
94
|
+
return targets.filter(function (_ref5) {
|
|
95
|
+
var decoration = _ref5.decoration;
|
|
78
96
|
return from <= decoration.from && decoration.to <= to;
|
|
79
97
|
}).sort(byLeadingPosition);
|
|
80
98
|
};
|
|
@@ -148,16 +166,16 @@ export var extractContributorTags = function extractContributorTags(decorations,
|
|
|
148
166
|
} finally {
|
|
149
167
|
_iterator.f();
|
|
150
168
|
}
|
|
151
|
-
var inlineTargets = targets.filter(function (
|
|
152
|
-
var decoration =
|
|
169
|
+
var inlineTargets = targets.filter(function (_ref6) {
|
|
170
|
+
var decoration = _ref6.decoration;
|
|
153
171
|
return decoration.spec.decorationType === 'inline';
|
|
154
172
|
});
|
|
155
|
-
var blockTargets = targets.filter(function (
|
|
156
|
-
var decoration =
|
|
173
|
+
var blockTargets = targets.filter(function (_ref7) {
|
|
174
|
+
var decoration = _ref7.decoration;
|
|
157
175
|
return decoration.spec.decorationType === 'block';
|
|
158
176
|
});
|
|
159
|
-
var widgetTargets = targets.filter(function (
|
|
160
|
-
var decoration =
|
|
177
|
+
var widgetTargets = targets.filter(function (_ref8) {
|
|
178
|
+
var decoration = _ref8.decoration;
|
|
161
179
|
return decoration.spec.decorationType === 'widget';
|
|
162
180
|
});
|
|
163
181
|
var linkedDiffIds = new Map();
|
|
@@ -185,8 +203,8 @@ export var extractContributorTags = function extractContributorTags(decorations,
|
|
|
185
203
|
}
|
|
186
204
|
|
|
187
205
|
// A block outranks both other kinds, so it is tried first.
|
|
188
|
-
var block = blockTargets.find(function (
|
|
189
|
-
var decoration =
|
|
206
|
+
var block = blockTargets.find(function (_ref9) {
|
|
207
|
+
var decoration = _ref9.decoration;
|
|
190
208
|
return isSameBlockChange(target.decoration, decoration);
|
|
191
209
|
});
|
|
192
210
|
if (block) {
|
|
@@ -195,8 +213,8 @@ export var extractContributorTags = function extractContributorTags(decorations,
|
|
|
195
213
|
}
|
|
196
214
|
if (decorationType === 'inline') {
|
|
197
215
|
// The deleted half renders in front of this one, so that half captions the change.
|
|
198
|
-
var leadingWidget = widgetTargets.find(function (
|
|
199
|
-
var decoration =
|
|
216
|
+
var leadingWidget = widgetTargets.find(function (_ref0) {
|
|
217
|
+
var decoration = _ref0.decoration;
|
|
200
218
|
return leadsReplacement(decoration) && isSameChange(decoration, target.decoration);
|
|
201
219
|
});
|
|
202
220
|
if (leadingWidget) {
|
|
@@ -209,8 +227,8 @@ export var extractContributorTags = function extractContributorTags(decorations,
|
|
|
209
227
|
if (leadsReplacement(target.decoration)) {
|
|
210
228
|
return 0; // continue
|
|
211
229
|
}
|
|
212
|
-
var host = inlineTargets.find(function (
|
|
213
|
-
var decoration =
|
|
230
|
+
var host = inlineTargets.find(function (_ref1) {
|
|
231
|
+
var decoration = _ref1.decoration;
|
|
214
232
|
return isSameChange(target.decoration, decoration);
|
|
215
233
|
});
|
|
216
234
|
if (host) {
|
|
@@ -314,10 +332,10 @@ export var extractContributorTags = function extractContributorTags(decorations,
|
|
|
314
332
|
try {
|
|
315
333
|
var _loop2 = function _loop2() {
|
|
316
334
|
var members = _step6.value;
|
|
317
|
-
var
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
335
|
+
var leader = navigationLeader(members);
|
|
336
|
+
var trailing = members.filter(function (target) {
|
|
337
|
+
return target !== leader;
|
|
338
|
+
});
|
|
321
339
|
trailing.forEach(function (target) {
|
|
322
340
|
return fold(leader, target);
|
|
323
341
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// prosemirror-view does not type `Decoration.type`; a widget's `type.toDOM` is the node passed to
|
|
2
|
+
// `Decoration.widget()` (an element or a factory — the `WidgetConstructor` union).
|
|
3
|
+
|
|
4
|
+
// The element a widget renders, or undefined if it renders via a factory.
|
|
5
|
+
export var getWidgetElement = function getWidgetElement(decoration) {
|
|
6
|
+
var _type;
|
|
7
|
+
var _ref = (_type = decoration.type) !== null && _type !== void 0 ? _type : {},
|
|
8
|
+
toDOM = _ref.toDOM;
|
|
9
|
+
return toDOM instanceof HTMLElement ? toDOM : undefined;
|
|
10
|
+
};
|
|
@@ -5,6 +5,7 @@ import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-uti
|
|
|
5
5
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
+
import { resolveBaseNodeName } from '../../utils/baseNodeName';
|
|
8
9
|
import { getAtomicInlineChangedAttrs } from '../createInlineChangedDecoration';
|
|
9
10
|
import { applyRevealToElement } from '../revealStyles';
|
|
10
11
|
import { isInlineAttrChangeNodeName } from './getAttrChangeRanges';
|
|
@@ -346,6 +347,15 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref9
|
|
|
346
347
|
// should not also get the inline content style (borderBottom underline) on their container.
|
|
347
348
|
var shouldSkipContentStyle = isInserted && nodeStyle !== undefined;
|
|
348
349
|
var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted, hideAddedDiffsUnderline);
|
|
350
|
+
var isEmptyDeletedLayoutColumn = !isInserted && resolveBaseNodeName(targetNode.type.name) === 'layoutColumn' && targetNode.textContent.length === 0 && fg('confluence_ncs_step_diffing_version_history');
|
|
351
|
+
if (isEmptyDeletedLayoutColumn && nodeView instanceof HTMLElement) {
|
|
352
|
+
var _nodeView$querySelect;
|
|
353
|
+
// Give an empty deleted column height so its diff box doesn't collapse
|
|
354
|
+
var placeholderTarget = (_nodeView$querySelect = nodeView.querySelector('[data-layout-content]')) !== null && _nodeView$querySelect !== void 0 ? _nodeView$querySelect : nodeView;
|
|
355
|
+
appendStyleToElement(placeholderTarget, convertToInlineCss({
|
|
356
|
+
minHeight: "var(--ds-space-300, 24px)"
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
349
359
|
|
|
350
360
|
// A `breakout` node renders wider than the editor column while the wrapper divs
|
|
351
361
|
// stay at column width, so paint the outline on the node element that spans that width.
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { isDiffDecorationSpec } from './decorations/decorationKeys';
|
|
2
|
+
import { getWidgetElement } from './decorations/utils/getWidgetElement';
|
|
2
3
|
import { showDiffPluginKey } from './main';
|
|
3
4
|
|
|
4
|
-
// prosemirror-view does not type `Decoration.type`; a widget's `type.toDOM` is the node passed to
|
|
5
|
-
// `Decoration.widget()` (an element or a factory — the `WidgetConstructor` union).
|
|
6
|
-
|
|
7
|
-
// The element a deleted-content widget renders, or undefined if it renders via a factory.
|
|
8
|
-
var getWidgetElement = function getWidgetElement(decoration) {
|
|
9
|
-
var _type;
|
|
10
|
-
var _ref = (_type = decoration.type) !== null && _type !== void 0 ? _type : {},
|
|
11
|
-
toDOM = _ref.toDOM;
|
|
12
|
-
return toDOM instanceof HTMLElement ? toDOM : undefined;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
5
|
/**
|
|
16
6
|
* The rendered deleted-content widgets in `editorState`, optionally restricted to `[from, to]`,
|
|
17
7
|
* ordered by position. Deleted content is rendered as widget decorations rather than document
|
|
@@ -11,6 +11,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
11
11
|
import { getActiveDiffAnnouncement } from '../ui/DiffNavigation/announceActiveDiff';
|
|
12
12
|
import { calculateDiffDecorations } from './calculateDiff/calculateDiffDecorations';
|
|
13
13
|
import { isDiffDecoration, isDiffDecorationSpec } from './decorations/decorationKeys';
|
|
14
|
+
import { getWidgetElement } from './decorations/utils/getWidgetElement';
|
|
14
15
|
import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
|
|
15
16
|
import { getDefaultDiffType } from './getDefaultDiffType';
|
|
16
17
|
import { getScrollableDecorations } from './getScrollableDecorations';
|
|
@@ -299,6 +300,31 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
299
300
|
};
|
|
300
301
|
},
|
|
301
302
|
props: {
|
|
303
|
+
handleDOMEvents: {
|
|
304
|
+
// Bypass ProseMirror's copy handler without preventing native browser copy
|
|
305
|
+
// when the selection is completely contained within an inverted diff widget
|
|
306
|
+
copy: function copy(view) {
|
|
307
|
+
if (!fg('platform_editor_ai_show_diff_patch_2')) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
var pluginState = showDiffPluginKey.getState(view.state);
|
|
311
|
+
if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDisplayingChanges) || !pluginState.isInverted) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
var selection = view.dom.ownerDocument.getSelection();
|
|
315
|
+
if (!selection || selection.isCollapsed || selection.rangeCount !== 1) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
var range = selection.getRangeAt(0);
|
|
319
|
+
return pluginState.decorations.find().filter(isDiffDecoration).some(function (decoration) {
|
|
320
|
+
if (decoration.spec.decorationType !== 'widget') {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
var dom = getWidgetElement(decoration);
|
|
324
|
+
return Boolean(dom && view.dom.contains(dom) && dom.contains(range.startContainer) && dom.contains(range.endContainer));
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
},
|
|
302
328
|
decorations: function decorations(state) {
|
|
303
329
|
var pluginState = showDiffPluginKey.getState(state);
|
|
304
330
|
return pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations;
|
|
@@ -10,7 +10,7 @@ import { resolveBaseNodeName } from './baseNodeName';
|
|
|
10
10
|
*
|
|
11
11
|
* Base names only — match with the predicates below, never against `type.name` directly.
|
|
12
12
|
*/
|
|
13
|
-
var TAGGABLE_BLOCK_NODES = new Set(['blockCard', 'blockquote', 'bodiedExtension', 'codeBlock', 'decisionList', 'embedCard', 'expand', 'extension', 'media', 'multiBodiedExtension', 'panel', 'rule', 'taskList']);
|
|
13
|
+
var TAGGABLE_BLOCK_NODES = new Set(['blockCard', 'blockquote', 'bodiedExtension', 'codeBlock', 'decisionList', 'embedCard', 'expand', 'extension', 'layoutColumn', 'media', 'multiBodiedExtension', 'panel', 'rule', 'taskList']);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Whether this node hosts a contributor tag of its own. Navigation grouping does not consult this:
|
|
@@ -30,6 +30,7 @@ export type DiffDecorationSpec = BaseDecorationSpec<typeof DecorationFamily.diff
|
|
|
30
30
|
colorScheme?: ColorScheme;
|
|
31
31
|
decorationType: DiffDescriptor['type'];
|
|
32
32
|
diffId: string;
|
|
33
|
+
ignoreSelection?: boolean;
|
|
33
34
|
/**
|
|
34
35
|
* The change currently stepped to. Needed on the spec because `activeIndex` indexes the filtered,
|
|
35
36
|
* re-sorted scrollable decorations, not `diffDescriptors`.
|
|
@@ -50,6 +51,7 @@ export type DiffDecorationSpec = BaseDecorationSpec<typeof DecorationFamily.diff
|
|
|
50
51
|
* consumed by `scrollToDiff`; never present on a decoration in the plugin's `DecorationSet`.
|
|
51
52
|
*/
|
|
52
53
|
scrollTarget?: Decoration;
|
|
54
|
+
stopEvent?: (event: Event) => boolean;
|
|
53
55
|
};
|
|
54
56
|
export declare const AnchorTypeKey: {
|
|
55
57
|
readonly from: 'from';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.0.2",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
41
41
|
"@atlaskit/primitives": "^22.5.0",
|
|
42
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
42
|
+
"@atlaskit/tmp-editor-statsig": "^228.0.0",
|
|
43
43
|
"@atlaskit/tokens": "^20.4.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@compiled/react": "^1.0.2",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"react-intl": "^7.0.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@atlaskit/editor-common": "^130.
|
|
74
|
+
"@atlaskit/editor-common": "^130.1.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"
|