@atlaskit/editor-plugin-show-diff 9.0.17 → 9.1.1
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 +22 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +11 -3
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +7 -2
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -1
- package/dist/cjs/pm-plugins/decorations/decorationKeys.js +32 -0
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +7 -1
- package/dist/cjs/pm-plugins/getScrollableDecorations.js +7 -6
- package/dist/cjs/pm-plugins/scrollToDiff.js +3 -2
- package/dist/cjs/showDiffPlugin.js +13 -0
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +11 -3
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +7 -2
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -1
- package/dist/es2019/pm-plugins/decorations/decorationKeys.js +25 -0
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +7 -1
- package/dist/es2019/pm-plugins/getScrollableDecorations.js +11 -9
- package/dist/es2019/pm-plugins/scrollToDiff.js +5 -3
- package/dist/es2019/showDiffPlugin.js +13 -0
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +11 -3
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +7 -2
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -1
- package/dist/esm/pm-plugins/decorations/decorationKeys.js +26 -0
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +7 -1
- package/dist/esm/pm-plugins/getScrollableDecorations.js +8 -6
- package/dist/esm/pm-plugins/scrollToDiff.js +4 -2
- package/dist/esm/showDiffPlugin.js +13 -0
- package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +23 -0
- package/dist/types/showDiffPluginType.d.ts +6 -1
- package/dist/types-ts4.5/pm-plugins/decorations/decorationKeys.d.ts +23 -0
- package/dist/types-ts4.5/showDiffPluginType.d.ts +3 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 9.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3cd3edf123888`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3cd3edf123888) -
|
|
8
|
+
Remove purple underline from block widget containers when diffs are inverted with extended
|
|
9
|
+
experiment enabled
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 9.1.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [`a3a227e567efe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a3a227e567efe) -
|
|
17
|
+
[ux] [EDITOR-7662] disabled block controls when viewing diffs
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [`281cf98f35fe5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/281cf98f35fe5) -
|
|
22
|
+
Minor refactor to use a decoration key builder so that it can be extended upon in upcoming work.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 9.0.17
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -9,6 +9,7 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
9
9
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
10
|
var _standard = require("./colorSchemes/standard");
|
|
11
11
|
var _traditional = require("./colorSchemes/traditional");
|
|
12
|
+
var _decorationKeys = require("./decorationKeys");
|
|
12
13
|
var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
13
14
|
display: 'none'
|
|
14
15
|
});
|
|
@@ -118,7 +119,9 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
118
119
|
return [_view.Decoration.node(change.from, change.to, {
|
|
119
120
|
style: displayNoneStyle
|
|
120
121
|
}, {
|
|
121
|
-
key:
|
|
122
|
+
key: (0, _decorationKeys.buildDiffDecorationKey)({
|
|
123
|
+
type: _decorationKeys.DiffDecorationKey.block
|
|
124
|
+
}),
|
|
122
125
|
nodeName: change.name
|
|
123
126
|
})];
|
|
124
127
|
}
|
|
@@ -130,7 +133,10 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
130
133
|
decorations.push(
|
|
131
134
|
// change.to - 1 to position the overlay inside the end of the cell
|
|
132
135
|
_view.Decoration.widget(change.to - 1, cellOverlay, {
|
|
133
|
-
key:
|
|
136
|
+
key: (0, _decorationKeys.buildDiffDecorationKey)({
|
|
137
|
+
type: _decorationKeys.DiffDecorationKey.widget,
|
|
138
|
+
isActive: isActive
|
|
139
|
+
})
|
|
134
140
|
}));
|
|
135
141
|
}
|
|
136
142
|
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
@@ -154,7 +160,9 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
154
160
|
'data-testid': 'show-diff-changed-decoration-node',
|
|
155
161
|
class: className
|
|
156
162
|
}, {
|
|
157
|
-
key:
|
|
163
|
+
key: (0, _decorationKeys.buildDiffDecorationKey)({
|
|
164
|
+
type: _decorationKeys.DiffDecorationKey.block
|
|
165
|
+
}),
|
|
158
166
|
nodeName: change.name
|
|
159
167
|
}));
|
|
160
168
|
}
|
|
@@ -9,6 +9,7 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
9
9
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
10
|
var _standard = require("./colorSchemes/standard");
|
|
11
11
|
var _traditional = require("./colorSchemes/traditional");
|
|
12
|
+
var _decorationKeys = require("./decorationKeys");
|
|
12
13
|
var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
13
14
|
display: 'none'
|
|
14
15
|
});
|
|
@@ -32,7 +33,9 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
32
33
|
return _view.Decoration.inline(change.fromB, change.toB, {
|
|
33
34
|
style: displayNoneStyle
|
|
34
35
|
}, {
|
|
35
|
-
key:
|
|
36
|
+
key: (0, _decorationKeys.buildDiffDecorationKey)({
|
|
37
|
+
type: _decorationKeys.DiffDecorationKey.inline
|
|
38
|
+
})
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
var style;
|
|
@@ -67,6 +70,8 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
67
70
|
style: style,
|
|
68
71
|
'data-testid': 'show-diff-changed-decoration'
|
|
69
72
|
}, {
|
|
70
|
-
key:
|
|
73
|
+
key: (0, _decorationKeys.buildDiffDecorationKey)({
|
|
74
|
+
type: _decorationKeys.DiffDecorationKey.inline
|
|
75
|
+
})
|
|
71
76
|
});
|
|
72
77
|
};
|
|
@@ -13,6 +13,7 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
|
13
13
|
var _standard = require("./colorSchemes/standard");
|
|
14
14
|
var _traditional = require("./colorSchemes/traditional");
|
|
15
15
|
var _createChangedRowDecorationWidgets = require("./createChangedRowDecorationWidgets");
|
|
16
|
+
var _decorationKeys = require("./decorationKeys");
|
|
16
17
|
var _findSafeInsertPos = require("./utils/findSafeInsertPos");
|
|
17
18
|
var _wrapBlockNodeView = require("./utils/wrapBlockNodeView");
|
|
18
19
|
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; }
|
|
@@ -257,7 +258,10 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
257
258
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
258
259
|
var decorations = [];
|
|
259
260
|
decorations.push(_view.Decoration.widget(safeInsertPos, dom, _objectSpread({
|
|
260
|
-
key:
|
|
261
|
+
key: (0, _decorationKeys.buildDiffDecorationKey)({
|
|
262
|
+
type: _decorationKeys.DiffDecorationKey.widget,
|
|
263
|
+
isActive: isActive
|
|
264
|
+
})
|
|
261
265
|
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
262
266
|
side: -1
|
|
263
267
|
})));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildDiffDecorationKey = exports.DiffDecorationKey = exports.DIFF_KEY_PREFIX = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Shared prefix for every decoration key produced by the show-diff plugin.
|
|
9
|
+
* All keys derive from this, so the full set of plugin decorations can be
|
|
10
|
+
* identified by this single prefix.
|
|
11
|
+
*/
|
|
12
|
+
var DIFF_KEY_PREFIX = exports.DIFF_KEY_PREFIX = 'diff';
|
|
13
|
+
/**
|
|
14
|
+
* The kinds of decoration the show-diff plugin produces. Each value is the
|
|
15
|
+
* leading segment of the generated key, so a decoration's kind can be matched
|
|
16
|
+
* with `key?.startsWith(DiffDecorationKey.inline)` etc.
|
|
17
|
+
*/
|
|
18
|
+
var DiffDecorationKey = exports.DiffDecorationKey = {
|
|
19
|
+
inline: "".concat(DIFF_KEY_PREFIX, "-inline"),
|
|
20
|
+
block: "".concat(DIFF_KEY_PREFIX, "-block"),
|
|
21
|
+
widget: "".concat(DIFF_KEY_PREFIX, "-widget")
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Builds a decoration key in the form `{type}-{active|inactive}`
|
|
26
|
+
* (e.g. `diff-inline-active`).
|
|
27
|
+
*/
|
|
28
|
+
var buildDiffDecorationKey = exports.buildDiffDecorationKey = function buildDiffDecorationKey(_ref) {
|
|
29
|
+
var type = _ref.type,
|
|
30
|
+
isActive = _ref.isActive;
|
|
31
|
+
return isActive !== undefined ? "".concat(type, "-").concat(isActive ? 'active' : 'inactive') : type;
|
|
32
|
+
};
|
|
@@ -299,7 +299,13 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6
|
|
|
299
299
|
var contentWrapper = document.createElement('div');
|
|
300
300
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
301
301
|
var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
|
|
302
|
-
|
|
302
|
+
|
|
303
|
+
// When the extended experiment is enabled and the content is inserted,
|
|
304
|
+
// block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
|
|
305
|
+
// should not also get the inline content style (borderBottom underline) on their container.
|
|
306
|
+
var shouldSkipContentStyle = (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted && nodeStyle !== undefined;
|
|
307
|
+
var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
|
|
308
|
+
contentWrapper.setAttribute('style', "".concat(contentStyle).concat(nodeStyle || ''));
|
|
303
309
|
contentWrapper.append(nodeView);
|
|
304
310
|
return contentWrapper;
|
|
305
311
|
};
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getScrollableDecorations = void 0;
|
|
8
8
|
exports.isInlineDiffDecorationRenderableInDoc = isInlineDiffDecorationRenderableInDoc;
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _decorationKeys = require("./decorations/decorationKeys");
|
|
10
11
|
/**
|
|
11
12
|
* True if `fragment` contains at least one inline node (text, hardBreak, emoji, mention, etc.).
|
|
12
13
|
* Block-only subtrees (e.g. empty paragraphs, block cards with no inline children) return false.
|
|
@@ -69,14 +70,14 @@ var getScrollableDecorations = exports.getScrollableDecorations = function getSc
|
|
|
69
70
|
}
|
|
70
71
|
var seenBlockKeys = new Set();
|
|
71
72
|
var allDecorations = set.find(undefined, undefined, function (spec) {
|
|
72
|
-
var _spec$key;
|
|
73
|
-
return spec.key ===
|
|
73
|
+
var _spec$key, _spec$key2, _spec$key3;
|
|
74
|
+
return ((_spec$key = spec.key) === null || _spec$key === void 0 ? void 0 : _spec$key.startsWith(_decorationKeys.DiffDecorationKey.inline)) || ((_spec$key2 = spec.key) === null || _spec$key2 === void 0 ? void 0 : _spec$key2.startsWith(_decorationKeys.DiffDecorationKey.widget)) || ((_spec$key3 = spec.key) === null || _spec$key3 === void 0 ? void 0 : _spec$key3.startsWith(_decorationKeys.DiffDecorationKey.block));
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
// First pass: filter out listItem blocks and deduplicates blocks
|
|
77
78
|
var filtered = allDecorations.filter(function (dec) {
|
|
78
79
|
var _dec$spec, _dec$spec$nodeName, _dec$spec3;
|
|
79
|
-
if ((
|
|
80
|
+
if ((_dec$spec = dec.spec) !== null && _dec$spec !== void 0 && (_dec$spec = _dec$spec.key) !== null && _dec$spec !== void 0 && _dec$spec.startsWith(_decorationKeys.DiffDecorationKey.block)) {
|
|
80
81
|
var _dec$spec2;
|
|
81
82
|
// Skip listItem blocks as they are not scrollable
|
|
82
83
|
if (((_dec$spec2 = dec.spec) === null || _dec$spec2 === void 0 ? void 0 : _dec$spec2.nodeName) === 'listItem') return false;
|
|
@@ -91,18 +92,18 @@ var getScrollableDecorations = exports.getScrollableDecorations = function getSc
|
|
|
91
92
|
// Separate decorations by type for easier processing
|
|
92
93
|
var blocks = filtered.filter(function (d) {
|
|
93
94
|
var _d$spec;
|
|
94
|
-
return (
|
|
95
|
+
return (_d$spec = d.spec) === null || _d$spec === void 0 || (_d$spec = _d$spec.key) === null || _d$spec === void 0 ? void 0 : _d$spec.startsWith(_decorationKeys.DiffDecorationKey.block);
|
|
95
96
|
});
|
|
96
97
|
var rawInlines = filtered.filter(function (d) {
|
|
97
98
|
var _d$spec2;
|
|
98
|
-
return (
|
|
99
|
+
return (_d$spec2 = d.spec) === null || _d$spec2 === void 0 || (_d$spec2 = _d$spec2.key) === null || _d$spec2 === void 0 ? void 0 : _d$spec2.startsWith(_decorationKeys.DiffDecorationKey.inline);
|
|
99
100
|
});
|
|
100
101
|
var inlines = doc !== undefined ? rawInlines.filter(function (d) {
|
|
101
102
|
return isInlineDiffDecorationRenderableInDoc(doc, d.from, d.to);
|
|
102
103
|
}) : rawInlines;
|
|
103
104
|
var widgets = filtered.filter(function (d) {
|
|
104
105
|
var _d$spec3;
|
|
105
|
-
return (_d$spec3 = d.spec) === null || _d$spec3 === void 0 || (_d$spec3 = _d$spec3.key) === null || _d$spec3 === void 0 ? void 0 : _d$spec3.startsWith(
|
|
106
|
+
return (_d$spec3 = d.spec) === null || _d$spec3 === void 0 || (_d$spec3 = _d$spec3.key) === null || _d$spec3 === void 0 ? void 0 : _d$spec3.startsWith(_decorationKeys.DiffDecorationKey.widget);
|
|
106
107
|
});
|
|
107
108
|
|
|
108
109
|
// Second pass: exclude overlapping decorations
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.scrollToFirstDecoration = exports.scrollToActiveDecoration = void 0;
|
|
7
|
+
var _decorationKeys = require("./decorations/decorationKeys");
|
|
7
8
|
/**
|
|
8
9
|
* Extra space above the scrolled-to element so it does not sit flush under the
|
|
9
10
|
* viewport edge (helps with sticky table headers, toolbars, etc.).
|
|
@@ -54,7 +55,7 @@ var scrollToFirstDecoration = exports.scrollToFirstDecoration = function scrollT
|
|
|
54
55
|
var _decoration$spec, _decoration$type;
|
|
55
56
|
rafId = null;
|
|
56
57
|
// @ts-expect-error - decoration.type is not typed public API
|
|
57
|
-
if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec = _decoration$spec.key) !== null && _decoration$spec !== void 0 && _decoration$spec.startsWith(
|
|
58
|
+
if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec = _decoration$spec.key) !== null && _decoration$spec !== void 0 && _decoration$spec.startsWith(_decorationKeys.DiffDecorationKey.widget) && decoration !== null && decoration !== void 0 && (_decoration$type = decoration.type) !== null && _decoration$type !== void 0 && _decoration$type.toDOM) {
|
|
58
59
|
// @ts-expect-error - decoration.type is not typed public API
|
|
59
60
|
var widgetDom = decoration.type.toDOM;
|
|
60
61
|
// Always scroll to the top of this decoration even if it's in view already
|
|
@@ -90,7 +91,7 @@ var scrollToActiveDecoration = exports.scrollToActiveDecoration = function scrol
|
|
|
90
91
|
var rafId = requestAnimationFrame(function () {
|
|
91
92
|
var _decoration$spec2;
|
|
92
93
|
rafId = null;
|
|
93
|
-
if ((
|
|
94
|
+
if ((_decoration$spec2 = decoration.spec) !== null && _decoration$spec2 !== void 0 && (_decoration$spec2 = _decoration$spec2.key) !== null && _decoration$spec2 !== void 0 && _decoration$spec2.startsWith(_decorationKeys.DiffDecorationKey.widget)) {
|
|
94
95
|
var _decoration$type2;
|
|
95
96
|
// @ts-expect-error - decoration.type is not typed public API
|
|
96
97
|
var widgetDom = decoration === null || decoration === void 0 || (_decoration$type2 = decoration.type) === null || _decoration$type2 === void 0 ? void 0 : _decoration$type2.toDOM;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.showDiffPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
9
10
|
var _getScrollableDecorations = require("./pm-plugins/getScrollableDecorations");
|
|
10
11
|
var _main = require("./pm-plugins/main");
|
|
11
12
|
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; }
|
|
@@ -19,6 +20,12 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
19
20
|
showDiff: function showDiff(params) {
|
|
20
21
|
return function (_ref2) {
|
|
21
22
|
var tr = _ref2.tr;
|
|
23
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
24
|
+
var _api$userIntent;
|
|
25
|
+
api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('viewingDiff')({
|
|
26
|
+
tr: tr
|
|
27
|
+
});
|
|
28
|
+
}
|
|
22
29
|
return tr.setMeta(_main.showDiffPluginKey, _objectSpread(_objectSpread({}, params), {}, {
|
|
23
30
|
action: 'SHOW_DIFF'
|
|
24
31
|
}));
|
|
@@ -26,6 +33,12 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
26
33
|
},
|
|
27
34
|
hideDiff: function hideDiff(_ref3) {
|
|
28
35
|
var tr = _ref3.tr;
|
|
36
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
37
|
+
var _api$userIntent2;
|
|
38
|
+
api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent('default')({
|
|
39
|
+
tr: tr
|
|
40
|
+
});
|
|
41
|
+
}
|
|
29
42
|
return tr.setMeta(_main.showDiffPluginKey, {
|
|
30
43
|
steps: [],
|
|
31
44
|
action: 'HIDE_DIFF'
|
|
@@ -3,6 +3,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
5
5
|
import { traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
|
|
6
|
+
import { buildDiffDecorationKey, DiffDecorationKey } from './decorationKeys';
|
|
6
7
|
const displayNoneStyle = convertToInlineCss({
|
|
7
8
|
display: 'none'
|
|
8
9
|
});
|
|
@@ -109,7 +110,9 @@ export const createBlockChangedDecoration = ({
|
|
|
109
110
|
return [Decoration.node(change.from, change.to, {
|
|
110
111
|
style: displayNoneStyle
|
|
111
112
|
}, {
|
|
112
|
-
key:
|
|
113
|
+
key: buildDiffDecorationKey({
|
|
114
|
+
type: DiffDecorationKey.block
|
|
115
|
+
}),
|
|
113
116
|
nodeName: change.name
|
|
114
117
|
})];
|
|
115
118
|
}
|
|
@@ -121,7 +124,10 @@ export const createBlockChangedDecoration = ({
|
|
|
121
124
|
decorations.push(
|
|
122
125
|
// change.to - 1 to position the overlay inside the end of the cell
|
|
123
126
|
Decoration.widget(change.to - 1, cellOverlay, {
|
|
124
|
-
key:
|
|
127
|
+
key: buildDiffDecorationKey({
|
|
128
|
+
type: DiffDecorationKey.widget,
|
|
129
|
+
isActive
|
|
130
|
+
})
|
|
125
131
|
}));
|
|
126
132
|
}
|
|
127
133
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
@@ -145,7 +151,9 @@ export const createBlockChangedDecoration = ({
|
|
|
145
151
|
'data-testid': 'show-diff-changed-decoration-node',
|
|
146
152
|
class: className
|
|
147
153
|
}, {
|
|
148
|
-
key:
|
|
154
|
+
key: buildDiffDecorationKey({
|
|
155
|
+
type: DiffDecorationKey.block
|
|
156
|
+
}),
|
|
149
157
|
nodeName: change.name
|
|
150
158
|
}));
|
|
151
159
|
}
|
|
@@ -3,6 +3,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { editingStyle, editingStyleExtended, editingStyleActive, editingStyleActiveExtended, deletedContentStyle, deletedContentStyleActive, deletedInlineContentStyleExtended } from './colorSchemes/standard';
|
|
5
5
|
import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle } from './colorSchemes/traditional';
|
|
6
|
+
import { buildDiffDecorationKey, DiffDecorationKey } from './decorationKeys';
|
|
6
7
|
const displayNoneStyle = convertToInlineCss({
|
|
7
8
|
display: 'none'
|
|
8
9
|
});
|
|
@@ -24,7 +25,9 @@ export const createInlineChangedDecoration = ({
|
|
|
24
25
|
return Decoration.inline(change.fromB, change.toB, {
|
|
25
26
|
style: displayNoneStyle
|
|
26
27
|
}, {
|
|
27
|
-
key:
|
|
28
|
+
key: buildDiffDecorationKey({
|
|
29
|
+
type: DiffDecorationKey.inline
|
|
30
|
+
})
|
|
28
31
|
});
|
|
29
32
|
}
|
|
30
33
|
let style;
|
|
@@ -59,6 +62,8 @@ export const createInlineChangedDecoration = ({
|
|
|
59
62
|
style,
|
|
60
63
|
'data-testid': 'show-diff-changed-decoration'
|
|
61
64
|
}, {
|
|
62
|
-
key:
|
|
65
|
+
key: buildDiffDecorationKey({
|
|
66
|
+
type: DiffDecorationKey.inline
|
|
67
|
+
})
|
|
63
68
|
});
|
|
64
69
|
};
|
|
@@ -4,6 +4,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
4
4
|
import { editingStyle, editingStyleExtended, editingStyleActive, editingStyleActiveExtended, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleUnbounded, deletedInlineContentStyleExtended } from './colorSchemes/standard';
|
|
5
5
|
import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive } from './colorSchemes/traditional';
|
|
6
6
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
7
|
+
import { buildDiffDecorationKey, DiffDecorationKey } from './decorationKeys';
|
|
7
8
|
import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
8
9
|
import { wrapBlockNodeView } from './utils/wrapBlockNodeView';
|
|
9
10
|
const getDeletedContentStyleUnbounded = (colorScheme, isActive = false) => {
|
|
@@ -231,7 +232,10 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
231
232
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
232
233
|
const decorations = [];
|
|
233
234
|
decorations.push(Decoration.widget(safeInsertPos, dom, {
|
|
234
|
-
key:
|
|
235
|
+
key: buildDiffDecorationKey({
|
|
236
|
+
type: DiffDecorationKey.widget,
|
|
237
|
+
isActive
|
|
238
|
+
}),
|
|
235
239
|
...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
236
240
|
side: -1
|
|
237
241
|
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prefix for every decoration key produced by the show-diff plugin.
|
|
3
|
+
* All keys derive from this, so the full set of plugin decorations can be
|
|
4
|
+
* identified by this single prefix.
|
|
5
|
+
*/
|
|
6
|
+
export const DIFF_KEY_PREFIX = 'diff';
|
|
7
|
+
/**
|
|
8
|
+
* The kinds of decoration the show-diff plugin produces. Each value is the
|
|
9
|
+
* leading segment of the generated key, so a decoration's kind can be matched
|
|
10
|
+
* with `key?.startsWith(DiffDecorationKey.inline)` etc.
|
|
11
|
+
*/
|
|
12
|
+
export const DiffDecorationKey = {
|
|
13
|
+
inline: `${DIFF_KEY_PREFIX}-inline`,
|
|
14
|
+
block: `${DIFF_KEY_PREFIX}-block`,
|
|
15
|
+
widget: `${DIFF_KEY_PREFIX}-widget`
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Builds a decoration key in the form `{type}-{active|inactive}`
|
|
20
|
+
* (e.g. `diff-inline-active`).
|
|
21
|
+
*/
|
|
22
|
+
export const buildDiffDecorationKey = ({
|
|
23
|
+
type,
|
|
24
|
+
isActive
|
|
25
|
+
}) => isActive !== undefined ? `${type}-${isActive ? 'active' : 'inactive'}` : type;
|
|
@@ -292,7 +292,13 @@ const createBlockNodeContentWrapper = ({
|
|
|
292
292
|
const contentWrapper = document.createElement('div');
|
|
293
293
|
const targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
|
|
294
294
|
const nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
|
|
295
|
-
|
|
295
|
+
|
|
296
|
+
// When the extended experiment is enabled and the content is inserted,
|
|
297
|
+
// block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
|
|
298
|
+
// should not also get the inline content style (borderBottom underline) on their container.
|
|
299
|
+
const shouldSkipContentStyle = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted && nodeStyle !== undefined;
|
|
300
|
+
const contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
|
|
301
|
+
contentWrapper.setAttribute('style', `${contentStyle}${nodeStyle || ''}`);
|
|
296
302
|
contentWrapper.append(nodeView);
|
|
297
303
|
return contentWrapper;
|
|
298
304
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DiffDecorationKey } from './decorations/decorationKeys';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* True if `fragment` contains at least one inline node (text, hardBreak, emoji, mention, etc.).
|
|
3
5
|
* Block-only subtrees (e.g. empty paragraphs, block cards with no inline children) return false.
|
|
@@ -60,14 +62,14 @@ export const getScrollableDecorations = (set, doc) => {
|
|
|
60
62
|
}
|
|
61
63
|
const seenBlockKeys = new Set();
|
|
62
64
|
const allDecorations = set.find(undefined, undefined, spec => {
|
|
63
|
-
var _spec$key;
|
|
64
|
-
return spec.key ===
|
|
65
|
+
var _spec$key, _spec$key2, _spec$key3;
|
|
66
|
+
return ((_spec$key = spec.key) === null || _spec$key === void 0 ? void 0 : _spec$key.startsWith(DiffDecorationKey.inline)) || ((_spec$key2 = spec.key) === null || _spec$key2 === void 0 ? void 0 : _spec$key2.startsWith(DiffDecorationKey.widget)) || ((_spec$key3 = spec.key) === null || _spec$key3 === void 0 ? void 0 : _spec$key3.startsWith(DiffDecorationKey.block));
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
// First pass: filter out listItem blocks and deduplicates blocks
|
|
68
70
|
const filtered = allDecorations.filter(dec => {
|
|
69
|
-
var _dec$spec, _dec$spec$nodeName, _dec$spec3;
|
|
70
|
-
if ((
|
|
71
|
+
var _dec$spec, _dec$spec$key, _dec$spec$nodeName, _dec$spec3;
|
|
72
|
+
if ((_dec$spec = dec.spec) !== null && _dec$spec !== void 0 && (_dec$spec$key = _dec$spec.key) !== null && _dec$spec$key !== void 0 && _dec$spec$key.startsWith(DiffDecorationKey.block)) {
|
|
71
73
|
var _dec$spec2;
|
|
72
74
|
// Skip listItem blocks as they are not scrollable
|
|
73
75
|
if (((_dec$spec2 = dec.spec) === null || _dec$spec2 === void 0 ? void 0 : _dec$spec2.nodeName) === 'listItem') return false;
|
|
@@ -81,17 +83,17 @@ export const getScrollableDecorations = (set, doc) => {
|
|
|
81
83
|
|
|
82
84
|
// Separate decorations by type for easier processing
|
|
83
85
|
const blocks = filtered.filter(d => {
|
|
84
|
-
var _d$spec;
|
|
85
|
-
return (
|
|
86
|
+
var _d$spec, _d$spec$key;
|
|
87
|
+
return (_d$spec = d.spec) === null || _d$spec === void 0 ? void 0 : (_d$spec$key = _d$spec.key) === null || _d$spec$key === void 0 ? void 0 : _d$spec$key.startsWith(DiffDecorationKey.block);
|
|
86
88
|
});
|
|
87
89
|
const rawInlines = filtered.filter(d => {
|
|
88
|
-
var _d$spec2;
|
|
89
|
-
return (
|
|
90
|
+
var _d$spec2, _d$spec2$key;
|
|
91
|
+
return (_d$spec2 = d.spec) === null || _d$spec2 === void 0 ? void 0 : (_d$spec2$key = _d$spec2.key) === null || _d$spec2$key === void 0 ? void 0 : _d$spec2$key.startsWith(DiffDecorationKey.inline);
|
|
90
92
|
});
|
|
91
93
|
const inlines = doc !== undefined ? rawInlines.filter(d => isInlineDiffDecorationRenderableInDoc(doc, d.from, d.to)) : rawInlines;
|
|
92
94
|
const widgets = filtered.filter(d => {
|
|
93
95
|
var _d$spec3, _d$spec3$key;
|
|
94
|
-
return (_d$spec3 = d.spec) === null || _d$spec3 === void 0 ? void 0 : (_d$spec3$key = _d$spec3.key) === null || _d$spec3$key === void 0 ? void 0 : _d$spec3$key.startsWith(
|
|
96
|
+
return (_d$spec3 = d.spec) === null || _d$spec3 === void 0 ? void 0 : (_d$spec3$key = _d$spec3.key) === null || _d$spec3$key === void 0 ? void 0 : _d$spec3$key.startsWith(DiffDecorationKey.widget);
|
|
95
97
|
});
|
|
96
98
|
|
|
97
99
|
// Second pass: exclude overlapping decorations
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DiffDecorationKey } from './decorations/decorationKeys';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Extra space above the scrolled-to element so it does not sit flush under the
|
|
3
5
|
* viewport edge (helps with sticky table headers, toolbars, etc.).
|
|
@@ -48,7 +50,7 @@ export const scrollToFirstDecoration = (view, decorations) => {
|
|
|
48
50
|
var _decoration$spec, _decoration$spec$key, _decoration$type;
|
|
49
51
|
rafId = null;
|
|
50
52
|
// @ts-expect-error - decoration.type is not typed public API
|
|
51
|
-
if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec$key = _decoration$spec.key) !== null && _decoration$spec$key !== void 0 && _decoration$spec$key.startsWith(
|
|
53
|
+
if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec$key = _decoration$spec.key) !== null && _decoration$spec$key !== void 0 && _decoration$spec$key.startsWith(DiffDecorationKey.widget) && decoration !== null && decoration !== void 0 && (_decoration$type = decoration.type) !== null && _decoration$type !== void 0 && _decoration$type.toDOM) {
|
|
52
54
|
// @ts-expect-error - decoration.type is not typed public API
|
|
53
55
|
const widgetDom = decoration.type.toDOM;
|
|
54
56
|
// Always scroll to the top of this decoration even if it's in view already
|
|
@@ -82,9 +84,9 @@ export const scrollToActiveDecoration = (view, decorations, activeIndex) => {
|
|
|
82
84
|
return () => {};
|
|
83
85
|
}
|
|
84
86
|
let rafId = requestAnimationFrame(() => {
|
|
85
|
-
var _decoration$spec2;
|
|
87
|
+
var _decoration$spec2, _decoration$spec2$key;
|
|
86
88
|
rafId = null;
|
|
87
|
-
if ((
|
|
89
|
+
if ((_decoration$spec2 = decoration.spec) !== null && _decoration$spec2 !== void 0 && (_decoration$spec2$key = _decoration$spec2.key) !== null && _decoration$spec2$key !== void 0 && _decoration$spec2$key.startsWith(DiffDecorationKey.widget)) {
|
|
88
90
|
var _decoration$type2;
|
|
89
91
|
// @ts-expect-error - decoration.type is not typed public API
|
|
90
92
|
const widgetDom = decoration === null || decoration === void 0 ? void 0 : (_decoration$type2 = decoration.type) === null || _decoration$type2 === void 0 ? void 0 : _decoration$type2.toDOM;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
1
2
|
import { getScrollableDecorations } from './pm-plugins/getScrollableDecorations';
|
|
2
3
|
import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
|
|
3
4
|
export const showDiffPlugin = ({
|
|
@@ -9,6 +10,12 @@ export const showDiffPlugin = ({
|
|
|
9
10
|
showDiff: params => ({
|
|
10
11
|
tr
|
|
11
12
|
}) => {
|
|
13
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
14
|
+
var _api$userIntent;
|
|
15
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('viewingDiff')({
|
|
16
|
+
tr
|
|
17
|
+
});
|
|
18
|
+
}
|
|
12
19
|
return tr.setMeta(showDiffPluginKey, {
|
|
13
20
|
...params,
|
|
14
21
|
action: 'SHOW_DIFF'
|
|
@@ -17,6 +24,12 @@ export const showDiffPlugin = ({
|
|
|
17
24
|
hideDiff: ({
|
|
18
25
|
tr
|
|
19
26
|
}) => {
|
|
27
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
28
|
+
var _api$userIntent2;
|
|
29
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default')({
|
|
30
|
+
tr
|
|
31
|
+
});
|
|
32
|
+
}
|
|
20
33
|
return tr.setMeta(showDiffPluginKey, {
|
|
21
34
|
steps: [],
|
|
22
35
|
action: 'HIDE_DIFF'
|
|
@@ -3,6 +3,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
5
5
|
import { traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
|
|
6
|
+
import { buildDiffDecorationKey, DiffDecorationKey } from './decorationKeys';
|
|
6
7
|
var displayNoneStyle = convertToInlineCss({
|
|
7
8
|
display: 'none'
|
|
8
9
|
});
|
|
@@ -112,7 +113,9 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
112
113
|
return [Decoration.node(change.from, change.to, {
|
|
113
114
|
style: displayNoneStyle
|
|
114
115
|
}, {
|
|
115
|
-
key:
|
|
116
|
+
key: buildDiffDecorationKey({
|
|
117
|
+
type: DiffDecorationKey.block
|
|
118
|
+
}),
|
|
116
119
|
nodeName: change.name
|
|
117
120
|
})];
|
|
118
121
|
}
|
|
@@ -124,7 +127,10 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
124
127
|
decorations.push(
|
|
125
128
|
// change.to - 1 to position the overlay inside the end of the cell
|
|
126
129
|
Decoration.widget(change.to - 1, cellOverlay, {
|
|
127
|
-
key:
|
|
130
|
+
key: buildDiffDecorationKey({
|
|
131
|
+
type: DiffDecorationKey.widget,
|
|
132
|
+
isActive: isActive
|
|
133
|
+
})
|
|
128
134
|
}));
|
|
129
135
|
}
|
|
130
136
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
@@ -148,7 +154,9 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
148
154
|
'data-testid': 'show-diff-changed-decoration-node',
|
|
149
155
|
class: className
|
|
150
156
|
}, {
|
|
151
|
-
key:
|
|
157
|
+
key: buildDiffDecorationKey({
|
|
158
|
+
type: DiffDecorationKey.block
|
|
159
|
+
}),
|
|
152
160
|
nodeName: change.name
|
|
153
161
|
}));
|
|
154
162
|
}
|
|
@@ -3,6 +3,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { editingStyle, editingStyleExtended, editingStyleActive, editingStyleActiveExtended, deletedContentStyle, deletedContentStyleActive, deletedInlineContentStyleExtended } from './colorSchemes/standard';
|
|
5
5
|
import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle } from './colorSchemes/traditional';
|
|
6
|
+
import { buildDiffDecorationKey, DiffDecorationKey } from './decorationKeys';
|
|
6
7
|
var displayNoneStyle = convertToInlineCss({
|
|
7
8
|
display: 'none'
|
|
8
9
|
});
|
|
@@ -26,7 +27,9 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
26
27
|
return Decoration.inline(change.fromB, change.toB, {
|
|
27
28
|
style: displayNoneStyle
|
|
28
29
|
}, {
|
|
29
|
-
key:
|
|
30
|
+
key: buildDiffDecorationKey({
|
|
31
|
+
type: DiffDecorationKey.inline
|
|
32
|
+
})
|
|
30
33
|
});
|
|
31
34
|
}
|
|
32
35
|
var style;
|
|
@@ -61,6 +64,8 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
61
64
|
style: style,
|
|
62
65
|
'data-testid': 'show-diff-changed-decoration'
|
|
63
66
|
}, {
|
|
64
|
-
key:
|
|
67
|
+
key: buildDiffDecorationKey({
|
|
68
|
+
type: DiffDecorationKey.inline
|
|
69
|
+
})
|
|
65
70
|
});
|
|
66
71
|
};
|
|
@@ -8,6 +8,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
8
8
|
import { editingStyle, editingStyleExtended, editingStyleActive, editingStyleActiveExtended, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleUnbounded, deletedInlineContentStyleExtended } from './colorSchemes/standard';
|
|
9
9
|
import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive } from './colorSchemes/traditional';
|
|
10
10
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
11
|
+
import { buildDiffDecorationKey, DiffDecorationKey } from './decorationKeys';
|
|
11
12
|
import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
12
13
|
import { wrapBlockNodeView } from './utils/wrapBlockNodeView';
|
|
13
14
|
var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
@@ -250,7 +251,10 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
250
251
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
251
252
|
var decorations = [];
|
|
252
253
|
decorations.push(Decoration.widget(safeInsertPos, dom, _objectSpread({
|
|
253
|
-
key:
|
|
254
|
+
key: buildDiffDecorationKey({
|
|
255
|
+
type: DiffDecorationKey.widget,
|
|
256
|
+
isActive: isActive
|
|
257
|
+
})
|
|
254
258
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
255
259
|
side: -1
|
|
256
260
|
})));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prefix for every decoration key produced by the show-diff plugin.
|
|
3
|
+
* All keys derive from this, so the full set of plugin decorations can be
|
|
4
|
+
* identified by this single prefix.
|
|
5
|
+
*/
|
|
6
|
+
export var DIFF_KEY_PREFIX = 'diff';
|
|
7
|
+
/**
|
|
8
|
+
* The kinds of decoration the show-diff plugin produces. Each value is the
|
|
9
|
+
* leading segment of the generated key, so a decoration's kind can be matched
|
|
10
|
+
* with `key?.startsWith(DiffDecorationKey.inline)` etc.
|
|
11
|
+
*/
|
|
12
|
+
export var DiffDecorationKey = {
|
|
13
|
+
inline: "".concat(DIFF_KEY_PREFIX, "-inline"),
|
|
14
|
+
block: "".concat(DIFF_KEY_PREFIX, "-block"),
|
|
15
|
+
widget: "".concat(DIFF_KEY_PREFIX, "-widget")
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Builds a decoration key in the form `{type}-{active|inactive}`
|
|
20
|
+
* (e.g. `diff-inline-active`).
|
|
21
|
+
*/
|
|
22
|
+
export var buildDiffDecorationKey = function buildDiffDecorationKey(_ref) {
|
|
23
|
+
var type = _ref.type,
|
|
24
|
+
isActive = _ref.isActive;
|
|
25
|
+
return isActive !== undefined ? "".concat(type, "-").concat(isActive ? 'active' : 'inactive') : type;
|
|
26
|
+
};
|
|
@@ -293,7 +293,13 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6
|
|
|
293
293
|
var contentWrapper = document.createElement('div');
|
|
294
294
|
var targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
|
|
295
295
|
var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
|
|
296
|
-
|
|
296
|
+
|
|
297
|
+
// When the extended experiment is enabled and the content is inserted,
|
|
298
|
+
// block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
|
|
299
|
+
// should not also get the inline content style (borderBottom underline) on their container.
|
|
300
|
+
var shouldSkipContentStyle = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted && nodeStyle !== undefined;
|
|
301
|
+
var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
|
|
302
|
+
contentWrapper.setAttribute('style', "".concat(contentStyle).concat(nodeStyle || ''));
|
|
297
303
|
contentWrapper.append(nodeView);
|
|
298
304
|
return contentWrapper;
|
|
299
305
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { DiffDecorationKey } from './decorations/decorationKeys';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* True if `fragment` contains at least one inline node (text, hardBreak, emoji, mention, etc.).
|
|
4
6
|
* Block-only subtrees (e.g. empty paragraphs, block cards with no inline children) return false.
|
|
@@ -61,14 +63,14 @@ export var getScrollableDecorations = function getScrollableDecorations(set, doc
|
|
|
61
63
|
}
|
|
62
64
|
var seenBlockKeys = new Set();
|
|
63
65
|
var allDecorations = set.find(undefined, undefined, function (spec) {
|
|
64
|
-
var _spec$key;
|
|
65
|
-
return spec.key ===
|
|
66
|
+
var _spec$key, _spec$key2, _spec$key3;
|
|
67
|
+
return ((_spec$key = spec.key) === null || _spec$key === void 0 ? void 0 : _spec$key.startsWith(DiffDecorationKey.inline)) || ((_spec$key2 = spec.key) === null || _spec$key2 === void 0 ? void 0 : _spec$key2.startsWith(DiffDecorationKey.widget)) || ((_spec$key3 = spec.key) === null || _spec$key3 === void 0 ? void 0 : _spec$key3.startsWith(DiffDecorationKey.block));
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
// First pass: filter out listItem blocks and deduplicates blocks
|
|
69
71
|
var filtered = allDecorations.filter(function (dec) {
|
|
70
72
|
var _dec$spec, _dec$spec$nodeName, _dec$spec3;
|
|
71
|
-
if ((
|
|
73
|
+
if ((_dec$spec = dec.spec) !== null && _dec$spec !== void 0 && (_dec$spec = _dec$spec.key) !== null && _dec$spec !== void 0 && _dec$spec.startsWith(DiffDecorationKey.block)) {
|
|
72
74
|
var _dec$spec2;
|
|
73
75
|
// Skip listItem blocks as they are not scrollable
|
|
74
76
|
if (((_dec$spec2 = dec.spec) === null || _dec$spec2 === void 0 ? void 0 : _dec$spec2.nodeName) === 'listItem') return false;
|
|
@@ -83,18 +85,18 @@ export var getScrollableDecorations = function getScrollableDecorations(set, doc
|
|
|
83
85
|
// Separate decorations by type for easier processing
|
|
84
86
|
var blocks = filtered.filter(function (d) {
|
|
85
87
|
var _d$spec;
|
|
86
|
-
return (
|
|
88
|
+
return (_d$spec = d.spec) === null || _d$spec === void 0 || (_d$spec = _d$spec.key) === null || _d$spec === void 0 ? void 0 : _d$spec.startsWith(DiffDecorationKey.block);
|
|
87
89
|
});
|
|
88
90
|
var rawInlines = filtered.filter(function (d) {
|
|
89
91
|
var _d$spec2;
|
|
90
|
-
return (
|
|
92
|
+
return (_d$spec2 = d.spec) === null || _d$spec2 === void 0 || (_d$spec2 = _d$spec2.key) === null || _d$spec2 === void 0 ? void 0 : _d$spec2.startsWith(DiffDecorationKey.inline);
|
|
91
93
|
});
|
|
92
94
|
var inlines = doc !== undefined ? rawInlines.filter(function (d) {
|
|
93
95
|
return isInlineDiffDecorationRenderableInDoc(doc, d.from, d.to);
|
|
94
96
|
}) : rawInlines;
|
|
95
97
|
var widgets = filtered.filter(function (d) {
|
|
96
98
|
var _d$spec3;
|
|
97
|
-
return (_d$spec3 = d.spec) === null || _d$spec3 === void 0 || (_d$spec3 = _d$spec3.key) === null || _d$spec3 === void 0 ? void 0 : _d$spec3.startsWith(
|
|
99
|
+
return (_d$spec3 = d.spec) === null || _d$spec3 === void 0 || (_d$spec3 = _d$spec3.key) === null || _d$spec3 === void 0 ? void 0 : _d$spec3.startsWith(DiffDecorationKey.widget);
|
|
98
100
|
});
|
|
99
101
|
|
|
100
102
|
// Second pass: exclude overlapping decorations
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DiffDecorationKey } from './decorations/decorationKeys';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Extra space above the scrolled-to element so it does not sit flush under the
|
|
3
5
|
* viewport edge (helps with sticky table headers, toolbars, etc.).
|
|
@@ -48,7 +50,7 @@ export var scrollToFirstDecoration = function scrollToFirstDecoration(view, deco
|
|
|
48
50
|
var _decoration$spec, _decoration$type;
|
|
49
51
|
rafId = null;
|
|
50
52
|
// @ts-expect-error - decoration.type is not typed public API
|
|
51
|
-
if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec = _decoration$spec.key) !== null && _decoration$spec !== void 0 && _decoration$spec.startsWith(
|
|
53
|
+
if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec = _decoration$spec.key) !== null && _decoration$spec !== void 0 && _decoration$spec.startsWith(DiffDecorationKey.widget) && decoration !== null && decoration !== void 0 && (_decoration$type = decoration.type) !== null && _decoration$type !== void 0 && _decoration$type.toDOM) {
|
|
52
54
|
// @ts-expect-error - decoration.type is not typed public API
|
|
53
55
|
var widgetDom = decoration.type.toDOM;
|
|
54
56
|
// Always scroll to the top of this decoration even if it's in view already
|
|
@@ -84,7 +86,7 @@ export var scrollToActiveDecoration = function scrollToActiveDecoration(view, de
|
|
|
84
86
|
var rafId = requestAnimationFrame(function () {
|
|
85
87
|
var _decoration$spec2;
|
|
86
88
|
rafId = null;
|
|
87
|
-
if ((
|
|
89
|
+
if ((_decoration$spec2 = decoration.spec) !== null && _decoration$spec2 !== void 0 && (_decoration$spec2 = _decoration$spec2.key) !== null && _decoration$spec2 !== void 0 && _decoration$spec2.startsWith(DiffDecorationKey.widget)) {
|
|
88
90
|
var _decoration$type2;
|
|
89
91
|
// @ts-expect-error - decoration.type is not typed public API
|
|
90
92
|
var widgetDom = decoration === null || decoration === void 0 || (_decoration$type2 = decoration.type) === null || _decoration$type2 === void 0 ? void 0 : _decoration$type2.toDOM;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
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
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { getScrollableDecorations } from './pm-plugins/getScrollableDecorations';
|
|
5
6
|
import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
|
|
6
7
|
export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
@@ -12,6 +13,12 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
12
13
|
showDiff: function showDiff(params) {
|
|
13
14
|
return function (_ref2) {
|
|
14
15
|
var tr = _ref2.tr;
|
|
16
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
17
|
+
var _api$userIntent;
|
|
18
|
+
api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('viewingDiff')({
|
|
19
|
+
tr: tr
|
|
20
|
+
});
|
|
21
|
+
}
|
|
15
22
|
return tr.setMeta(showDiffPluginKey, _objectSpread(_objectSpread({}, params), {}, {
|
|
16
23
|
action: 'SHOW_DIFF'
|
|
17
24
|
}));
|
|
@@ -19,6 +26,12 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
19
26
|
},
|
|
20
27
|
hideDiff: function hideDiff(_ref3) {
|
|
21
28
|
var tr = _ref3.tr;
|
|
29
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
30
|
+
var _api$userIntent2;
|
|
31
|
+
api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent('default')({
|
|
32
|
+
tr: tr
|
|
33
|
+
});
|
|
34
|
+
}
|
|
22
35
|
return tr.setMeta(showDiffPluginKey, {
|
|
23
36
|
steps: [],
|
|
24
37
|
action: 'HIDE_DIFF'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prefix for every decoration key produced by the show-diff plugin.
|
|
3
|
+
* All keys derive from this, so the full set of plugin decorations can be
|
|
4
|
+
* identified by this single prefix.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DIFF_KEY_PREFIX = "diff";
|
|
7
|
+
type DiffDecorationKind = 'inline' | 'block' | 'widget';
|
|
8
|
+
type DiffDecorationKeyType = `${typeof DIFF_KEY_PREFIX}-${DiffDecorationKind}`;
|
|
9
|
+
/**
|
|
10
|
+
* The kinds of decoration the show-diff plugin produces. Each value is the
|
|
11
|
+
* leading segment of the generated key, so a decoration's kind can be matched
|
|
12
|
+
* with `key?.startsWith(DiffDecorationKey.inline)` etc.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DiffDecorationKey: Readonly<Record<DiffDecorationKind, DiffDecorationKeyType>>;
|
|
15
|
+
/**
|
|
16
|
+
* Builds a decoration key in the form `{type}-{active|inactive}`
|
|
17
|
+
* (e.g. `diff-inline-active`).
|
|
18
|
+
*/
|
|
19
|
+
export declare const buildDiffDecorationKey: ({ type, isActive, }: {
|
|
20
|
+
isActive?: boolean;
|
|
21
|
+
type: DiffDecorationKeyType;
|
|
22
|
+
}) => string;
|
|
23
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import type { NextEditorPlugin, EditorCommand, OptionalPlugin } from '@atlaskit/
|
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
5
|
import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
|
|
6
|
+
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
6
7
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
7
8
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
8
9
|
export type ColorScheme = 'standard' | 'traditional';
|
|
@@ -43,7 +44,11 @@ export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
|
|
|
43
44
|
scrollToPrevious: EditorCommand;
|
|
44
45
|
showDiff: (config: PMDiffParams) => EditorCommand;
|
|
45
46
|
};
|
|
46
|
-
dependencies: [
|
|
47
|
+
dependencies: [
|
|
48
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
49
|
+
OptionalPlugin<ExpandPlugin>,
|
|
50
|
+
OptionalPlugin<UserIntentPlugin>
|
|
51
|
+
];
|
|
47
52
|
pluginConfiguration: DiffParams | undefined;
|
|
48
53
|
sharedState: {
|
|
49
54
|
/**
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prefix for every decoration key produced by the show-diff plugin.
|
|
3
|
+
* All keys derive from this, so the full set of plugin decorations can be
|
|
4
|
+
* identified by this single prefix.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DIFF_KEY_PREFIX = "diff";
|
|
7
|
+
type DiffDecorationKind = 'inline' | 'block' | 'widget';
|
|
8
|
+
type DiffDecorationKeyType = `${typeof DIFF_KEY_PREFIX}-${DiffDecorationKind}`;
|
|
9
|
+
/**
|
|
10
|
+
* The kinds of decoration the show-diff plugin produces. Each value is the
|
|
11
|
+
* leading segment of the generated key, so a decoration's kind can be matched
|
|
12
|
+
* with `key?.startsWith(DiffDecorationKey.inline)` etc.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DiffDecorationKey: Readonly<Record<DiffDecorationKind, DiffDecorationKeyType>>;
|
|
15
|
+
/**
|
|
16
|
+
* Builds a decoration key in the form `{type}-{active|inactive}`
|
|
17
|
+
* (e.g. `diff-inline-active`).
|
|
18
|
+
*/
|
|
19
|
+
export declare const buildDiffDecorationKey: ({ type, isActive, }: {
|
|
20
|
+
isActive?: boolean;
|
|
21
|
+
type: DiffDecorationKeyType;
|
|
22
|
+
}) => string;
|
|
23
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import type { NextEditorPlugin, EditorCommand, OptionalPlugin } from '@atlaskit/
|
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
5
|
import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
|
|
6
|
+
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
6
7
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
7
8
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
8
9
|
export type ColorScheme = 'standard' | 'traditional';
|
|
@@ -45,7 +46,8 @@ export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
|
|
|
45
46
|
};
|
|
46
47
|
dependencies: [
|
|
47
48
|
OptionalPlugin<AnalyticsPlugin>,
|
|
48
|
-
OptionalPlugin<ExpandPlugin
|
|
49
|
+
OptionalPlugin<ExpandPlugin>,
|
|
50
|
+
OptionalPlugin<UserIntentPlugin>
|
|
49
51
|
];
|
|
50
52
|
pluginConfiguration: DiffParams | undefined;
|
|
51
53
|
sharedState: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,10 +32,11 @@
|
|
|
32
32
|
"@atlaskit/custom-steps": "^0.17.0",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^11.0.0",
|
|
34
34
|
"@atlaskit/editor-plugin-expand": "^12.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-user-intent": "^9.1.0",
|
|
35
36
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
36
37
|
"@atlaskit/editor-tables": "^2.10.0",
|
|
37
38
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
38
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^102.0.0",
|
|
39
40
|
"@atlaskit/tokens": "^13.4.0",
|
|
40
41
|
"@babel/runtime": "^7.0.0",
|
|
41
42
|
"lodash": "^4.17.21",
|