@atlaskit/editor-plugin-show-diff 29.0.0 → 29.0.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 29.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`90093ce337081`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/90093ce337081) -
8
+ Version history diff: treat documents that differ only in how adjacent same-mark text nodes are
9
+ split as equal, so changes to migrated legacy-editor content are highlighted (behind
10
+ platform_editor_show_diff_normalise_text_nodes)
11
+
3
12
  ## 29.0.0
4
13
 
5
14
  ### Major Changes
@@ -17,6 +17,7 @@ var _document = require("@atlaskit/editor-common/utils/document");
17
17
  var _transform = require("@atlaskit/editor-prosemirror/transform");
18
18
  var _view = require("@atlaskit/editor-prosemirror/view");
19
19
  var _tableMap = require("@atlaskit/editor-tables/table-map");
20
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
20
21
  var _unsafeExpValNoExposure = require("@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure");
21
22
  var _fg = require("@atlaskit/platform-feature-flags/fg");
22
23
  var _attributions = require("../decorations/colorSchemes/attributions");
@@ -39,6 +40,7 @@ var _groupChangesByBlock = require("./groupChangesByBlock");
39
40
  var _groupDeletedColumnChanges = require("./groupDeletedColumnChanges");
40
41
  var _isMarkOnlyChange = require("./isMarkOnlyChange");
41
42
  var _isOpenTokenOnlyChange = require("./isOpenTokenOnlyChange");
43
+ var _normalizeTextNodes = require("./normalizeTextNodes");
42
44
  var _optimizeChanges = require("./optimizeChanges");
43
45
  var _selectTokenEncoder2 = require("./selectTokenEncoder");
44
46
  var _simplifyChangesWithAttribution = require("./simplifyChangesWithAttribution");
@@ -482,6 +484,10 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref8
482
484
  // changes and ignores differences in attributes which don't affect decoration positions
483
485
  if (!(0, _document.areNodesEqualIgnoreAttrs)(steppedDoc, tr.doc)) {
484
486
  var _api$analytics;
487
+ // A document parsed from ADF can hold adjacent text nodes with identical marks, while the
488
+ // editor joins them whenever it rebuilds a node (for example when local ids are assigned on
489
+ // load). Positions are identical either way, so the decorations still apply.
490
+ var recoveredViaTextNodeNormalisation = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_normalise_text_nodes') && (0, _document.areNodesEqualIgnoreAttrs)((0, _normalizeTextNodes.normalizeTextNodes)(steppedDoc), (0, _normalizeTextNodes.normalizeTextNodes)(tr.doc));
485
491
  var recoveredViaContentEquality = (0, _areDocsEqualByBlockStructureAndText.areDocsEqualByBlockStructureAndText)(steppedDoc, tr.doc);
486
492
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
487
493
  eventType: 'track',
@@ -490,10 +496,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref8
490
496
  attributes: {
491
497
  docSizeEqual: steppedDoc.nodeSize === tr.doc.nodeSize,
492
498
  colorScheme: colorScheme,
493
- recoveredViaContentEquality: recoveredViaContentEquality
499
+ recoveredViaContentEquality: recoveredViaContentEquality,
500
+ recoveredViaTextNodeNormalisation: recoveredViaTextNodeNormalisation
494
501
  }
495
502
  });
496
- if (!recoveredViaContentEquality) {
503
+ if (!recoveredViaTextNodeNormalisation && !recoveredViaContentEquality) {
497
504
  return {
498
505
  contributorTags: [],
499
506
  decorations: _view.DecorationSet.empty,
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeTextNodes = void 0;
7
+ var _model = require("@atlaskit/editor-prosemirror/model");
8
+ /**
9
+ * Returns a copy of `node` in which adjacent text nodes with identical marks are joined, the same
10
+ * normalisation ProseMirror applies whenever it rebuilds a node's content. A document parsed straight
11
+ * from ADF keeps such split runs, so two documents with identical content and positions can still
12
+ * differ in child count.
13
+ */
14
+ var _normalizeTextNodes = exports.normalizeTextNodes = function normalizeTextNodes(node) {
15
+ if (node.isText || node.childCount === 0) {
16
+ return node;
17
+ }
18
+ var children = [];
19
+ node.content.forEach(function (child) {
20
+ return children.push(_normalizeTextNodes(child));
21
+ });
22
+ return node.copy(_model.Fragment.fromArray(children));
23
+ };
@@ -7,6 +7,7 @@ import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document
7
7
  import { Mapping } from '@atlaskit/editor-prosemirror/transform';
8
8
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
9
  import { TableMap } from '@atlaskit/editor-tables/table-map';
10
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
10
11
  import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
11
12
  import { fg } from '@atlaskit/platform-feature-flags/fg';
12
13
  import { createAttributionColorMap, getAttributionKey, getAttributionKeyForChange, getColorSchemeForChange, isAttributionColoringEnabled, isContributorTagsEnabled } from '../decorations/colorSchemes/attributions';
@@ -29,6 +30,7 @@ import { groupChangesByBlock } from './groupChangesByBlock';
29
30
  import { CELL_CONTENT_OFFSET, groupDeletedColumnChanges } from './groupDeletedColumnChanges';
30
31
  import { isMarkOnlyChange } from './isMarkOnlyChange';
31
32
  import { isOpenTokenOnlyChange } from './isOpenTokenOnlyChange';
33
+ import { normalizeTextNodes } from './normalizeTextNodes';
32
34
  import { optimizeChanges } from './optimizeChanges';
33
35
  import { selectTokenEncoder } from './selectTokenEncoder';
34
36
  import { collapseOverlappingChanges, simplifyChangesWithAttribution } from './simplifyChangesWithAttribution';
@@ -435,6 +437,10 @@ const calculateDiffDecorationsInner = ({
435
437
  // changes and ignores differences in attributes which don't affect decoration positions
436
438
  if (!areNodesEqualIgnoreAttrs(steppedDoc, tr.doc)) {
437
439
  var _api$analytics;
440
+ // A document parsed from ADF can hold adjacent text nodes with identical marks, while the
441
+ // editor joins them whenever it rebuilds a node (for example when local ids are assigned on
442
+ // load). Positions are identical either way, so the decorations still apply.
443
+ const recoveredViaTextNodeNormalisation = isExperimentEnabled('platform_editor_show_diff_normalise_text_nodes') && areNodesEqualIgnoreAttrs(normalizeTextNodes(steppedDoc), normalizeTextNodes(tr.doc));
438
444
  const recoveredViaContentEquality = areDocsEqualByBlockStructureAndText(steppedDoc, tr.doc);
439
445
  api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
440
446
  eventType: 'track',
@@ -443,10 +449,11 @@ const calculateDiffDecorationsInner = ({
443
449
  attributes: {
444
450
  docSizeEqual: steppedDoc.nodeSize === tr.doc.nodeSize,
445
451
  colorScheme,
446
- recoveredViaContentEquality
452
+ recoveredViaContentEquality,
453
+ recoveredViaTextNodeNormalisation
447
454
  }
448
455
  });
449
- if (!recoveredViaContentEquality) {
456
+ if (!recoveredViaTextNodeNormalisation && !recoveredViaContentEquality) {
450
457
  return {
451
458
  contributorTags: [],
452
459
  decorations: DecorationSet.empty,
@@ -0,0 +1,16 @@
1
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
+
3
+ /**
4
+ * Returns a copy of `node` in which adjacent text nodes with identical marks are joined, the same
5
+ * normalisation ProseMirror applies whenever it rebuilds a node's content. A document parsed straight
6
+ * from ADF keeps such split runs, so two documents with identical content and positions can still
7
+ * differ in child count.
8
+ */
9
+ export const normalizeTextNodes = node => {
10
+ if (node.isText || node.childCount === 0) {
11
+ return node;
12
+ }
13
+ const children = [];
14
+ node.content.forEach(child => children.push(normalizeTextNodes(child)));
15
+ return node.copy(Fragment.fromArray(children));
16
+ };
@@ -15,6 +15,7 @@ import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document
15
15
  import { Mapping } from '@atlaskit/editor-prosemirror/transform';
16
16
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
17
17
  import { TableMap } from '@atlaskit/editor-tables/table-map';
18
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
18
19
  import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
19
20
  import { fg } from '@atlaskit/platform-feature-flags/fg';
20
21
  import { createAttributionColorMap, getAttributionKey, getAttributionKeyForChange, getColorSchemeForChange, isAttributionColoringEnabled, isContributorTagsEnabled } from '../decorations/colorSchemes/attributions';
@@ -37,6 +38,7 @@ import { groupChangesByBlock } from './groupChangesByBlock';
37
38
  import { CELL_CONTENT_OFFSET, groupDeletedColumnChanges } from './groupDeletedColumnChanges';
38
39
  import { isMarkOnlyChange } from './isMarkOnlyChange';
39
40
  import { isOpenTokenOnlyChange } from './isOpenTokenOnlyChange';
41
+ import { normalizeTextNodes } from './normalizeTextNodes';
40
42
  import { optimizeChanges } from './optimizeChanges';
41
43
  import { selectTokenEncoder } from './selectTokenEncoder';
42
44
  import { collapseOverlappingChanges, simplifyChangesWithAttribution } from './simplifyChangesWithAttribution';
@@ -475,6 +477,10 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref8
475
477
  // changes and ignores differences in attributes which don't affect decoration positions
476
478
  if (!areNodesEqualIgnoreAttrs(steppedDoc, tr.doc)) {
477
479
  var _api$analytics;
480
+ // A document parsed from ADF can hold adjacent text nodes with identical marks, while the
481
+ // editor joins them whenever it rebuilds a node (for example when local ids are assigned on
482
+ // load). Positions are identical either way, so the decorations still apply.
483
+ var recoveredViaTextNodeNormalisation = isExperimentEnabled('platform_editor_show_diff_normalise_text_nodes') && areNodesEqualIgnoreAttrs(normalizeTextNodes(steppedDoc), normalizeTextNodes(tr.doc));
478
484
  var recoveredViaContentEquality = areDocsEqualByBlockStructureAndText(steppedDoc, tr.doc);
479
485
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
480
486
  eventType: 'track',
@@ -483,10 +489,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref8
483
489
  attributes: {
484
490
  docSizeEqual: steppedDoc.nodeSize === tr.doc.nodeSize,
485
491
  colorScheme: colorScheme,
486
- recoveredViaContentEquality: recoveredViaContentEquality
492
+ recoveredViaContentEquality: recoveredViaContentEquality,
493
+ recoveredViaTextNodeNormalisation: recoveredViaTextNodeNormalisation
487
494
  }
488
495
  });
489
- if (!recoveredViaContentEquality) {
496
+ if (!recoveredViaTextNodeNormalisation && !recoveredViaContentEquality) {
490
497
  return {
491
498
  contributorTags: [],
492
499
  decorations: DecorationSet.empty,
@@ -0,0 +1,19 @@
1
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
+
3
+ /**
4
+ * Returns a copy of `node` in which adjacent text nodes with identical marks are joined, the same
5
+ * normalisation ProseMirror applies whenever it rebuilds a node's content. A document parsed straight
6
+ * from ADF keeps such split runs, so two documents with identical content and positions can still
7
+ * differ in child count.
8
+ */
9
+ var _normalizeTextNodes = function normalizeTextNodes(node) {
10
+ if (node.isText || node.childCount === 0) {
11
+ return node;
12
+ }
13
+ var children = [];
14
+ node.content.forEach(function (child) {
15
+ return children.push(_normalizeTextNodes(child));
16
+ });
17
+ return node.copy(Fragment.fromArray(children));
18
+ };
19
+ export { _normalizeTextNodes as normalizeTextNodes };
@@ -0,0 +1,8 @@
1
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ /**
3
+ * Returns a copy of `node` in which adjacent text nodes with identical marks are joined, the same
4
+ * normalisation ProseMirror applies whenever it rebuilds a node's content. A document parsed straight
5
+ * from ADF keeps such split runs, so two documents with identical content and positions can still
6
+ * differ in child count.
7
+ */
8
+ export declare const normalizeTextNodes: (node: PMNode) => PMNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "29.0.0",
3
+ "version": "29.0.1",
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.6.0",
42
- "@atlaskit/tmp-editor-statsig": "^248.0.0",
42
+ "@atlaskit/tmp-editor-statsig": "^248.1.0",
43
43
  "@atlaskit/tokens": "^20.8.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@compiled/react": "^1.0.2",
@@ -53,17 +53,17 @@
53
53
  "@atlaskit/button": "^25.6.0",
54
54
  "@atlaskit/css": "^1.1.0",
55
55
  "@atlaskit/dropdown-menu": "^21.0.0",
56
- "@atlaskit/editor-core": "^241.1.0",
56
+ "@atlaskit/editor-core": "^242.0.0",
57
57
  "@atlaskit/editor-json-transformer": "^10.0.0",
58
58
  "@atlaskit/editor-plugins": "^16.2.0",
59
59
  "@atlaskit/form": "^18.3.0",
60
60
  "@atlaskit/section-message": "^10.2.0",
61
- "@atlaskit/textarea": "^10.2.0",
61
+ "@atlaskit/textarea": "^10.3.0",
62
62
  "@atlaskit/textfield": "^10.3.0",
63
63
  "@atlaskit/util-data-test": "^19.1.0",
64
64
  "@atlassian/confluence-presets": "workspace:^",
65
65
  "@atlassian/content-reconciliation": "^0.1.3506",
66
- "@atlassian/editor-ai-injected-editors": "^45.0.0",
66
+ "@atlassian/editor-ai-injected-editors": "^46.0.0",
67
67
  "@atlassian/editor-plugin-ai": "^84.0.0",
68
68
  "@atlassian/structured-docs-types": "workspace:^",
69
69
  "react": "^19.2.0",