@atlaskit/editor-plugin-show-diff 12.1.0 → 12.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 +19 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +7 -2
- package/dist/cjs/pm-plugins/decorations/utils/getAttrChangeRanges.js +10 -3
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +3 -2
- package/dist/es2019/pm-plugins/decorations/utils/getAttrChangeRanges.js +4 -3
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +7 -2
- package/dist/esm/pm-plugins/decorations/utils/getAttrChangeRanges.js +10 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 12.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3a38a59a355f5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3a38a59a355f5) -
|
|
8
|
+
Add a feature-gated platform experiments strangler entry point and migrate the inline-diffs
|
|
9
|
+
experiment as its first consumer.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { isExperimentEnabled } from '@atlaskit/editor-common/deprecated-platform-feature-experiments';
|
|
13
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
|
+
|
|
15
|
+
const isEnabled = isExperimentEnabled('platform_editor_example', () =>
|
|
16
|
+
expValEquals('platform_editor_example', 'isEnabled', true),
|
|
17
|
+
);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 12.1.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -11,6 +11,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
11
11
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
12
12
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
13
13
|
var _prosemirrorChangeset = require("prosemirror-changeset");
|
|
14
|
+
var _deprecatedPlatformFeatureExperiments = require("@atlaskit/editor-common/deprecated-platform-feature-experiments");
|
|
14
15
|
var _document = require("@atlaskit/editor-common/utils/document");
|
|
15
16
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
16
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -471,7 +472,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
471
472
|
if (change.isInline) {
|
|
472
473
|
// Inline nodes (e.g. date, emoji, mention, status) need an inline decoration rather than a block decoration
|
|
473
474
|
var isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
|
|
474
|
-
var isAtomicInlineNodeFlag = (0,
|
|
475
|
+
var isAtomicInlineNodeFlag = (0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
|
|
476
|
+
return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
477
|
+
});
|
|
475
478
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createInlineChangedDecoration.createInlineChangedDecoration)({
|
|
476
479
|
change: change,
|
|
477
480
|
colorScheme: colorScheme,
|
|
@@ -486,7 +489,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
486
489
|
})));
|
|
487
490
|
// If we have the original node position, also render the old node as a "deleted" widget
|
|
488
491
|
// so the user can see what it looked like before the change.
|
|
489
|
-
if (change.fromA !== undefined && change.toA !== undefined && (0,
|
|
492
|
+
if (change.fromA !== undefined && change.toA !== undefined && (0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
|
|
493
|
+
return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
494
|
+
})) {
|
|
490
495
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)({
|
|
491
496
|
change: {
|
|
492
497
|
fromA: change.fromA,
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.stepIsValidAttrChange = exports.getAttrChangeRanges = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
10
|
+
var _deprecatedPlatformFeatureExperiments = require("@atlaskit/editor-common/deprecated-platform-feature-experiments");
|
|
10
11
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
11
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
13
|
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; }
|
|
@@ -70,7 +71,9 @@ var getAttrChangeRanges = exports.getAttrChangeRanges = function getAttrChangeRa
|
|
|
70
71
|
// date node: timestamp attribute change — highlight the date node itself (inline)
|
|
71
72
|
if (stepAttrs.some(function (v) {
|
|
72
73
|
return dateAttrs.includes(v);
|
|
73
|
-
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date' && !(0,
|
|
74
|
+
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date' && !(0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
|
|
75
|
+
return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
76
|
+
})) {
|
|
74
77
|
return {
|
|
75
78
|
fromB: step.pos,
|
|
76
79
|
toB: step.pos + nodeAtPos.nodeSize,
|
|
@@ -82,7 +85,9 @@ var getAttrChangeRanges = exports.getAttrChangeRanges = function getAttrChangeRa
|
|
|
82
85
|
// The following inline node attr changes are gated behind platform_editor_improve_inline_diffs.
|
|
83
86
|
// The changeset path (createDecorationsForChange) handles the deletion widget via
|
|
84
87
|
// prosemirror-changeset; we only need to add the inline insertion highlight here.
|
|
85
|
-
if ((0,
|
|
88
|
+
if ((0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
|
|
89
|
+
return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
90
|
+
}) && nodeAtPos) {
|
|
86
91
|
var nodeName = nodeAtPos.type.name;
|
|
87
92
|
if (isInlineAttrChangeNodeName(nodeName)) {
|
|
88
93
|
var watchedAttrs = inlineNodeAttrMap[nodeName];
|
|
@@ -143,7 +148,9 @@ var getAttrChangeRanges = exports.getAttrChangeRanges = function getAttrChangeRa
|
|
|
143
148
|
// Gated behind the same experiment as the inline node attr changes that introduced
|
|
144
149
|
// the possibility of multiple ranges for the same node position.
|
|
145
150
|
.filter(function (range, i, arr) {
|
|
146
|
-
return !(0,
|
|
151
|
+
return !(0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
|
|
152
|
+
return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
153
|
+
}) || arr.findIndex(function (r) {
|
|
147
154
|
return r.fromB === range.fromB;
|
|
148
155
|
}) === i;
|
|
149
156
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
3
|
import memoizeOne from 'memoize-one';
|
|
4
4
|
import { ChangeSet, simplifyChanges } from 'prosemirror-changeset';
|
|
5
|
+
import { isExperimentEnabled } from '@atlaskit/editor-common/deprecated-platform-feature-experiments';
|
|
5
6
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
6
7
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -434,7 +435,7 @@ const calculateDiffDecorationsInner = ({
|
|
|
434
435
|
if (change.isInline) {
|
|
435
436
|
// Inline nodes (e.g. date, emoji, mention, status) need an inline decoration rather than a block decoration
|
|
436
437
|
const isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
|
|
437
|
-
const isAtomicInlineNodeFlag = expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
438
|
+
const isAtomicInlineNodeFlag = isExperimentEnabled('platform_editor_improve_inline_diffs', () => expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true));
|
|
438
439
|
decorations.push(...createInlineChangedDecoration({
|
|
439
440
|
change,
|
|
440
441
|
colorScheme,
|
|
@@ -449,7 +450,7 @@ const calculateDiffDecorationsInner = ({
|
|
|
449
450
|
}));
|
|
450
451
|
// If we have the original node position, also render the old node as a "deleted" widget
|
|
451
452
|
// so the user can see what it looked like before the change.
|
|
452
|
-
if (change.fromA !== undefined && change.toA !== undefined && expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true)) {
|
|
453
|
+
if (change.fromA !== undefined && change.toA !== undefined && isExperimentEnabled('platform_editor_improve_inline_diffs', () => expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true))) {
|
|
453
454
|
decorations.push(...createNodeChangedDecorationWidget({
|
|
454
455
|
change: {
|
|
455
456
|
fromA: change.fromA,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
2
|
+
import { isExperimentEnabled } from '@atlaskit/editor-common/deprecated-platform-feature-experiments';
|
|
2
3
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
const filterUndefined = x => !!x;
|
|
@@ -54,7 +55,7 @@ export const getAttrChangeRanges = (doc, steps, originalDoc) => {
|
|
|
54
55
|
const nodeAtPos = doc.nodeAt(step.pos);
|
|
55
56
|
|
|
56
57
|
// date node: timestamp attribute change — highlight the date node itself (inline)
|
|
57
|
-
if (stepAttrs.some(v => dateAttrs.includes(v)) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date' && !expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true)) {
|
|
58
|
+
if (stepAttrs.some(v => dateAttrs.includes(v)) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date' && !isExperimentEnabled('platform_editor_improve_inline_diffs', () => expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true))) {
|
|
58
59
|
return {
|
|
59
60
|
fromB: step.pos,
|
|
60
61
|
toB: step.pos + nodeAtPos.nodeSize,
|
|
@@ -66,7 +67,7 @@ export const getAttrChangeRanges = (doc, steps, originalDoc) => {
|
|
|
66
67
|
// The following inline node attr changes are gated behind platform_editor_improve_inline_diffs.
|
|
67
68
|
// The changeset path (createDecorationsForChange) handles the deletion widget via
|
|
68
69
|
// prosemirror-changeset; we only need to add the inline insertion highlight here.
|
|
69
|
-
if (expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true) && nodeAtPos) {
|
|
70
|
+
if (isExperimentEnabled('platform_editor_improve_inline_diffs', () => expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true)) && nodeAtPos) {
|
|
70
71
|
const nodeName = nodeAtPos.type.name;
|
|
71
72
|
if (isInlineAttrChangeNodeName(nodeName)) {
|
|
72
73
|
const watchedAttrs = inlineNodeAttrMap[nodeName];
|
|
@@ -119,7 +120,7 @@ export const getAttrChangeRanges = (doc, steps, originalDoc) => {
|
|
|
119
120
|
// should produce only one decoration, not one per step.
|
|
120
121
|
// Gated behind the same experiment as the inline node attr changes that introduced
|
|
121
122
|
// the possibility of multiple ranges for the same node position.
|
|
122
|
-
.filter((range, i, arr) => !expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true) || arr.findIndex(r => r.fromB === range.fromB) === i);
|
|
123
|
+
.filter((range, i, arr) => !isExperimentEnabled('platform_editor_improve_inline_diffs', () => expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true)) || arr.findIndex(r => r.fromB === range.fromB) === i);
|
|
123
124
|
};
|
|
124
125
|
|
|
125
126
|
/**
|
|
@@ -10,6 +10,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
10
10
|
import isEqual from 'lodash/isEqual';
|
|
11
11
|
import memoizeOne from 'memoize-one';
|
|
12
12
|
import { ChangeSet, simplifyChanges } from 'prosemirror-changeset';
|
|
13
|
+
import { isExperimentEnabled } from '@atlaskit/editor-common/deprecated-platform-feature-experiments';
|
|
13
14
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
14
15
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
15
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -465,7 +466,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
465
466
|
if (change.isInline) {
|
|
466
467
|
// Inline nodes (e.g. date, emoji, mention, status) need an inline decoration rather than a block decoration
|
|
467
468
|
var isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
|
|
468
|
-
var isAtomicInlineNodeFlag =
|
|
469
|
+
var isAtomicInlineNodeFlag = isExperimentEnabled('platform_editor_improve_inline_diffs', function () {
|
|
470
|
+
return expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
471
|
+
});
|
|
469
472
|
decorations.push.apply(decorations, _toConsumableArray(createInlineChangedDecoration({
|
|
470
473
|
change: change,
|
|
471
474
|
colorScheme: colorScheme,
|
|
@@ -480,7 +483,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
480
483
|
})));
|
|
481
484
|
// If we have the original node position, also render the old node as a "deleted" widget
|
|
482
485
|
// so the user can see what it looked like before the change.
|
|
483
|
-
if (change.fromA !== undefined && change.toA !== undefined &&
|
|
486
|
+
if (change.fromA !== undefined && change.toA !== undefined && isExperimentEnabled('platform_editor_improve_inline_diffs', function () {
|
|
487
|
+
return expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
488
|
+
})) {
|
|
484
489
|
decorations.push.apply(decorations, _toConsumableArray(createNodeChangedDecorationWidget({
|
|
485
490
|
change: {
|
|
486
491
|
fromA: change.fromA,
|
|
@@ -2,6 +2,7 @@ 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
4
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
5
|
+
import { isExperimentEnabled } from '@atlaskit/editor-common/deprecated-platform-feature-experiments';
|
|
5
6
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
var filterUndefined = function filterUndefined(x) {
|
|
@@ -63,7 +64,9 @@ export var getAttrChangeRanges = function getAttrChangeRanges(doc, steps, origin
|
|
|
63
64
|
// date node: timestamp attribute change — highlight the date node itself (inline)
|
|
64
65
|
if (stepAttrs.some(function (v) {
|
|
65
66
|
return dateAttrs.includes(v);
|
|
66
|
-
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date' && !
|
|
67
|
+
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date' && !isExperimentEnabled('platform_editor_improve_inline_diffs', function () {
|
|
68
|
+
return expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
69
|
+
})) {
|
|
67
70
|
return {
|
|
68
71
|
fromB: step.pos,
|
|
69
72
|
toB: step.pos + nodeAtPos.nodeSize,
|
|
@@ -75,7 +78,9 @@ export var getAttrChangeRanges = function getAttrChangeRanges(doc, steps, origin
|
|
|
75
78
|
// The following inline node attr changes are gated behind platform_editor_improve_inline_diffs.
|
|
76
79
|
// The changeset path (createDecorationsForChange) handles the deletion widget via
|
|
77
80
|
// prosemirror-changeset; we only need to add the inline insertion highlight here.
|
|
78
|
-
if (
|
|
81
|
+
if (isExperimentEnabled('platform_editor_improve_inline_diffs', function () {
|
|
82
|
+
return expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
83
|
+
}) && nodeAtPos) {
|
|
79
84
|
var nodeName = nodeAtPos.type.name;
|
|
80
85
|
if (isInlineAttrChangeNodeName(nodeName)) {
|
|
81
86
|
var watchedAttrs = inlineNodeAttrMap[nodeName];
|
|
@@ -136,7 +141,9 @@ export var getAttrChangeRanges = function getAttrChangeRanges(doc, steps, origin
|
|
|
136
141
|
// Gated behind the same experiment as the inline node attr changes that introduced
|
|
137
142
|
// the possibility of multiple ranges for the same node position.
|
|
138
143
|
.filter(function (range, i, arr) {
|
|
139
|
-
return !
|
|
144
|
+
return !isExperimentEnabled('platform_editor_improve_inline_diffs', function () {
|
|
145
|
+
return expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
146
|
+
}) || arr.findIndex(function (r) {
|
|
140
147
|
return r.fromB === range.fromB;
|
|
141
148
|
}) === i;
|
|
142
149
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.1",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"react-intl": "^7.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^118.
|
|
56
|
+
"@atlaskit/editor-common": "^118.5.0",
|
|
57
57
|
"react": "^18.2.0 || ^19.2.0"
|
|
58
58
|
},
|
|
59
59
|
"techstack": {
|