@atlaskit/editor-plugin-show-diff 15.1.4 → 15.1.6

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/diffBySteps.js +2 -31
  3. package/dist/cjs/pm-plugins/calculateDiff/smart/classifySmartChanges.js +3 -2
  4. package/dist/cjs/pm-plugins/calculateDiff/smart/segmentText.js +3 -34
  5. package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +49 -23
  6. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +9 -2
  7. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +7 -2
  8. package/dist/cjs/pm-plugins/decorations/extractContributorTags.js +38 -10
  9. package/dist/cjs/pm-plugins/utils/charsByOffset.js +45 -0
  10. package/dist/cjs/pm-plugins/utils/hasVisibleContent.js +37 -0
  11. package/dist/cjs/ui/ContributorTag/contributorTagController.js +1 -1
  12. package/dist/cjs/ui/IndicatorBar/IndicatorBar.js +1 -1
  13. package/dist/cjs/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  14. package/dist/es2019/pm-plugins/calculateDiff/diffBySteps.js +1 -30
  15. package/dist/es2019/pm-plugins/calculateDiff/smart/classifySmartChanges.js +2 -1
  16. package/dist/es2019/pm-plugins/calculateDiff/smart/segmentText.js +2 -28
  17. package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +40 -15
  18. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +10 -3
  19. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +7 -2
  20. package/dist/es2019/pm-plugins/decorations/extractContributorTags.js +27 -3
  21. package/dist/es2019/pm-plugins/utils/charsByOffset.js +37 -0
  22. package/dist/es2019/pm-plugins/utils/hasVisibleContent.js +28 -0
  23. package/dist/es2019/ui/ContributorTag/contributorTagController.js +1 -1
  24. package/dist/es2019/ui/IndicatorBar/IndicatorBar.js +1 -1
  25. package/dist/es2019/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  26. package/dist/esm/pm-plugins/calculateDiff/diffBySteps.js +1 -30
  27. package/dist/esm/pm-plugins/calculateDiff/smart/classifySmartChanges.js +2 -1
  28. package/dist/esm/pm-plugins/calculateDiff/smart/segmentText.js +2 -32
  29. package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +48 -22
  30. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +10 -3
  31. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +7 -2
  32. package/dist/esm/pm-plugins/decorations/extractContributorTags.js +38 -10
  33. package/dist/esm/pm-plugins/utils/charsByOffset.js +39 -0
  34. package/dist/esm/pm-plugins/utils/hasVisibleContent.js +32 -0
  35. package/dist/esm/ui/ContributorTag/contributorTagController.js +1 -1
  36. package/dist/esm/ui/IndicatorBar/IndicatorBar.js +1 -1
  37. package/dist/esm/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  38. package/dist/types/pm-plugins/calculateDiff/smart/segmentText.d.ts +0 -9
  39. package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +4 -3
  40. package/dist/types/pm-plugins/decorations/extractContributorTags.d.ts +1 -1
  41. package/dist/types/pm-plugins/utils/charsByOffset.d.ts +16 -0
  42. package/dist/types/pm-plugins/utils/hasVisibleContent.d.ts +13 -0
  43. package/dist/types/ui/ContributorTag/contributorTagController.d.ts +1 -1
  44. package/package.json +4 -4
@@ -6,10 +6,11 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
6
6
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
7
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
8
  import { isExtendedEnabled } from '../isExtendedEnabled';
9
+ import { hasVisibleContent } from '../utils/hasVisibleContent';
9
10
  import { buildAtomicInlineChangedCSSVariables, buildDeletedInlineContentStyleExtended, buildDeletedInlineStyle, buildDeletedInlineStyleStandard, buildInsertStyle, buildInsertStyleActive, buildInsertStyleExtended, buildInsertStyleExtendedActive, buildInsertStyleExtendedNoUnderline, buildInsertStyleExtendedNoUnderlineActive } from './colorSchemes/factory';
10
11
  import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
11
12
  import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
12
- import { createContributorTagWidget } from './createContributorTagWidget';
13
+ import { createContributorTagWidget, isContributorTagWidgetEnabled } from './createContributorTagWidget';
13
14
  import { getAtomicInlineNodeClassNameLegacy, resolveInlineChangedStyleLegacy } from './createInlineChangedDecoration.styles.legacy';
14
15
  import { buildDiffDecorationSpec } from './decorationKeys';
15
16
  import { REVEAL_ATTR, resolveRevealStyle } from './revealStyles';
@@ -134,6 +135,12 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
134
135
  // rebuilds decorations without touching the doc, and a fresh id would change the React key and the
135
136
  // tag host's key, remounting every tag mid-step. Random ids are kept when tags are off.
136
137
  var diffId = showContributorTags ? "inline-".concat(change.fromB, "-").concat(change.toB) : crypto.randomUUID();
138
+
139
+ // Whether this highlight hosts a tag. A range of nothing but whitespace has nothing to caption,
140
+ // so it stays unattributed: the spec is the only route attribution takes to
141
+ // `extractContributorTags`, so dropping the key there is what keeps a tag from being resolved for
142
+ // a host that is never emitted (EDITOR-8855).
143
+ var canTagChange = showContributorTags && !!doc && isExtendedEnabled(diffType) && isContributorTagWidgetEnabled() && hasVisibleContent(doc.slice(change.fromB, change.toB).content);
137
144
  if (shouldHideDeleted) {
138
145
  return [Decoration.inline(change.fromB, change.toB, {
139
146
  style: displayNoneStyle
@@ -178,7 +185,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
178
185
  }, showContributorTags && {
179
186
  'data-diff-id': diffId
180
187
  }), buildDiffDecorationSpec({
181
- attributionKey: attributionKey,
188
+ attributionKey: canTagChange ? attributionKey : undefined,
182
189
  colorScheme: colorScheme,
183
190
  decorationType: 'inline',
184
191
  diffId: diffId,
@@ -223,7 +230,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
223
230
 
224
231
  // Built from the raw change range, not the anchors above: a tag lines up with the changed text,
225
232
  // while the bar's anchors are held on a block boundary when a deleted widget renders beside them.
226
- if (showContributorTags && doc && isExtendedEnabled(diffType)) {
233
+ if (canTagChange && doc) {
227
234
  var tagWidget = createContributorTagWidget({
228
235
  doc: doc,
229
236
  from: change.fromB,
@@ -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 { isExtendedEnabled } from '../isExtendedEnabled';
7
+ import { hasVisibleContent } from '../utils/hasVisibleContent';
7
8
  import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
8
9
  import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
9
10
  import { createContributorTagHost, unmountContributorTag } from './createContributorTagWidget';
@@ -213,6 +214,10 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
213
214
  // Derived from the deleted range so it survives a recalculation — see the same reasoning in
214
215
  // `createInlineChangedDecoration`.
215
216
  var diffId = showContributorTags ? "widget-".concat(change.fromA, "-").concat(change.toA) : crypto.randomUUID();
217
+ // Whether this widget hosts a tag. Removing nothing but whitespace leaves no visible deleted
218
+ // content to caption, so the change stays unattributed — matching the inline half's rule in
219
+ // `createInlineChangedDecoration` (EDITOR-8855).
220
+ var canTagWidget = showContributorTags && hasVisibleContent(slice.content);
216
221
  var decorations = [];
217
222
  var replacementNode = newDoc.nodeAt(change.fromB);
218
223
  var firstReplacedNode = slice.content.firstChild;
@@ -348,7 +353,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
348
353
  // Taken down in the widget's `destroy` below: `dom` is rebuilt on every recalculation, so the tag
349
354
  // mounted into it must not outlive the copy ProseMirror is drawing.
350
355
  var tagMount;
351
- if (showContributorTags) {
356
+ if (canTagWidget) {
352
357
  // Lets the contributor tag find the deleted content on hover.
353
358
  dom.setAttribute('data-diff-id', diffId);
354
359
 
@@ -371,7 +376,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
371
376
  }
372
377
  }
373
378
  decorations.push(Decoration.widget(safeInsertPos, dom, _objectSpread(_objectSpread(_objectSpread({}, buildDiffDecorationSpec(_objectSpread({
374
- attributionKey: attributionKey,
379
+ attributionKey: canTagWidget ? attributionKey : undefined,
375
380
  colorScheme: colorScheme,
376
381
  decorationType: 'widget',
377
382
  diffId: diffId,
@@ -7,6 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
8
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; } }
9
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; }
10
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
10
11
  import { isDiffDecoration, isDiffDecorationSpec } from './decorationKeys';
11
12
 
12
13
  /**
@@ -30,6 +31,16 @@ var isSameChange = function isSameChange(widget, inline) {
30
31
  return widget.spec.attributionKey === inline.spec.attributionKey && widget.from >= inline.from && widget.from <= inline.to;
31
32
  };
32
33
 
34
+ /**
35
+ * Whether a deleted-content widget is the left-most half of the replacement it belongs to, in which
36
+ * case it keeps the tag so the tag marks where the change begins (EDITOR-8855). `side: -1` paints
37
+ * the deleted content in front of the inserted text; `1` is `deletedDiffPlacement: 'bottom'` /
38
+ * `inlineDeletedDiffPlacement: 'after'`, where the inline half leads instead.
39
+ */
40
+ var leadsReplacement = function leadsReplacement(widget) {
41
+ return fg('confluence_ncs_step_diffing_version_history') && widget.spec.side === -1;
42
+ };
43
+
33
44
  /**
34
45
  * Whether `inner` captions the same change as the block decoration `block`, in which case only the
35
46
  * block keeps the tag — one tag per block. Containment counts in either direction: a leaf block's
@@ -42,7 +53,7 @@ var isSameBlockChange = function isSameBlockChange(inner, block) {
42
53
  /**
43
54
  * One model per diff decoration whose attribution resolves to a supplied contributor; anything
44
55
  * unattributed, untaggable or unresolved is skipped. A replacement's two decorations are collapsed
45
- * into the single inline tag — see `isSameChange`.
56
+ * into a single tag, on whichever half renders first — see `isSameChange` and `leadsReplacement`.
46
57
  */
47
58
  export var extractContributorTags = function extractContributorTags(decorations, contributors) {
48
59
  if (!contributors) {
@@ -71,7 +82,7 @@ export var extractContributorTags = function extractContributorTags(decorations,
71
82
  });
72
83
  }
73
84
 
74
- // The inline decoration keeps the tag: it captions content still in the document.
85
+ // Candidate hosts, in the order they outrank each other: block, then leading widget, then inline.
75
86
  } catch (err) {
76
87
  _iterator.e(err);
77
88
  } finally {
@@ -85,6 +96,10 @@ export var extractContributorTags = function extractContributorTags(decorations,
85
96
  var decoration = _ref3.decoration;
86
97
  return decoration.spec.decorationType === 'block';
87
98
  });
99
+ var widgetTargets = targets.filter(function (_ref4) {
100
+ var decoration = _ref4.decoration;
101
+ return decoration.spec.decorationType === 'widget';
102
+ });
88
103
  var linkedDiffIds = new Map();
89
104
  var folded = new Set();
90
105
  var fold = function fold(host, target) {
@@ -101,19 +116,32 @@ export var extractContributorTags = function extractContributorTags(decorations,
101
116
  }
102
117
 
103
118
  // A block outranks both other kinds, so it is tried first.
104
- var block = blockTargets.find(function (_ref4) {
105
- var decoration = _ref4.decoration;
119
+ var block = blockTargets.find(function (_ref5) {
120
+ var decoration = _ref5.decoration;
106
121
  return isSameBlockChange(target.decoration, decoration);
107
122
  });
108
123
  if (block) {
109
124
  fold(block, target);
110
125
  return 0; // continue
111
126
  }
112
- if (decorationType !== 'widget') {
127
+ if (decorationType === 'inline') {
128
+ // The deleted half renders in front of this one, so that half captions the change.
129
+ var leadingWidget = widgetTargets.find(function (_ref6) {
130
+ var decoration = _ref6.decoration;
131
+ return leadsReplacement(decoration) && isSameChange(decoration, target.decoration);
132
+ });
133
+ if (leadingWidget) {
134
+ fold(leadingWidget, target);
135
+ }
113
136
  return 0; // continue
114
137
  }
115
- var host = inlineTargets.find(function (_ref5) {
116
- var decoration = _ref5.decoration;
138
+
139
+ // A leading widget keeps its own tag; it was folded into above.
140
+ if (leadsReplacement(target.decoration)) {
141
+ return 0; // continue
142
+ }
143
+ var host = inlineTargets.find(function (_ref7) {
144
+ var decoration = _ref7.decoration;
117
145
  return isSameChange(target.decoration, decoration);
118
146
  });
119
147
  if (host) {
@@ -127,9 +155,9 @@ export var extractContributorTags = function extractContributorTags(decorations,
127
155
  }
128
156
  return targets.filter(function (target) {
129
157
  return !folded.has(target);
130
- }).map(function (_ref6) {
131
- var contributor = _ref6.contributor,
132
- spec = _ref6.decoration.spec;
158
+ }).map(function (_ref8) {
159
+ var contributor = _ref8.contributor,
160
+ spec = _ref8.decoration.spec;
133
161
  var connected = contributor.connectedToKey ? contributors[contributor.connectedToKey] : undefined;
134
162
  var connectedContributor = connected ? toTagContributor(connected) : undefined;
135
163
  var linked = linkedDiffIds.get(spec.diffId);
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Whitespace as the diff treats it, U+00A0 included: a non-breaking space separates words for every
3
+ * consumer here, so it is not a character a change can be said to start on.
4
+ *
5
+ * A Set rather than a regex, to avoid both the `require-unicode-regexp` lint rule and the TS1501
6
+ * error the `u` flag triggers under this package's declaration build target.
7
+ */
8
+ var WHITESPACE_CHAR_SET = new Set([' ', '\t', '\n', '\r', '\f', '\v', "\xA0"]);
9
+ export var isWhitespaceChar = function isWhitespaceChar(char) {
10
+ return WHITESPACE_CHAR_SET.has(char);
11
+ };
12
+
13
+ /**
14
+ * Build a per-content-offset view of a textblock's characters.
15
+ *
16
+ * Returns an array whose length is `parent.content.size`. For every offset that lies inside a text
17
+ * node, `chars[offset]` is the character at that offset; for every offset that lies inside (or on
18
+ * the edge of) a non-text inline node — hardBreak, mention, emoji, date, … — the entry is `null`,
19
+ * which acts as an *opaque single token*: it counts as one word and is never whitespace.
20
+ *
21
+ * Using doc positions to index `parent.textContent` is wrong because `textContent` strips non-text
22
+ * inline nodes, so every such node shifts the lookup off by its size. This per-offset view restores
23
+ * a 1:1 mapping between doc positions inside the textblock and the character (or "no character",
24
+ * i.e. a hard word boundary) at that position.
25
+ */
26
+ export var buildCharsByOffset = function buildCharsByOffset(parent) {
27
+ var chars = new Array(parent.content.size).fill(null);
28
+ parent.content.forEach(function (child, offset) {
29
+ var _child$text;
30
+ if (!child.isText) {
31
+ return;
32
+ }
33
+ var text = (_child$text = child.text) !== null && _child$text !== void 0 ? _child$text : '';
34
+ for (var i = 0; i < text.length; i++) {
35
+ chars[offset + i] = text[i];
36
+ }
37
+ });
38
+ return chars;
39
+ };
@@ -0,0 +1,32 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { isWhitespaceChar } from './charsByOffset';
3
+
4
+ /**
5
+ * Whether `fragment` holds anything a reader can see.
6
+ *
7
+ * Text counts once it carries a single non-whitespace character; a leaf node (mention, emoji, date,
8
+ * media, rule, hardBreak, …) counts in its own right, exactly as `resolveTagAnchorPos` treats one.
9
+ * Everything else is descended into, so a paragraph is visible when its content is.
10
+ *
11
+ * A change whose content is nothing but whitespace — a space typed between two words, a run of
12
+ * trailing spaces, an added blank paragraph — has no visible content for a contributor tag to
13
+ * caption, so it carries no tag (EDITOR-8855).
14
+ */
15
+ var _hasVisibleContent = function hasVisibleContent(fragment) {
16
+ var visible = false;
17
+ fragment.forEach(function (node) {
18
+ if (visible) {
19
+ return;
20
+ }
21
+ if (node.isText) {
22
+ var _node$text;
23
+ visible = _toConsumableArray((_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : '').some(function (char) {
24
+ return !isWhitespaceChar(char);
25
+ });
26
+ return;
27
+ }
28
+ visible = node.isLeaf || _hasVisibleContent(node.content);
29
+ });
30
+ return visible;
31
+ };
32
+ export { _hasVisibleContent as hasVisibleContent };
@@ -87,7 +87,7 @@ var identityOf = function identityOf(model) {
87
87
  * `toDOM` for a widget it reuses: stepping to the next change republishes the tags without redrawing
88
88
  * their hosts, so anything the tag reacts to — `isActive` above all — has to arrive through a
89
89
  * subscription of its own (EDITOR-8702). Draws nothing when this diff has no tag, which is the case
90
- * for the deleted half of a replacement: that half is folded into the inline tag.
90
+ * for the folded half of a replacement: its two decorations share the one tag.
91
91
  */
92
92
  export var ContributorTagController = /*#__PURE__*/function () {
93
93
  function ContributorTagController(options) {
@@ -1,4 +1,4 @@
1
- /* IndicatorBar.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* IndicatorBar.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./IndicatorBar.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,4 @@
1
- /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import { ax, ix } from "@compiled/react/runtime";
3
3
  import React from 'react';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
@@ -1,4 +1,3 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
1
  /**
3
2
  * A half-open offset span `[from, to)` measured in *content offsets* relative to the
4
3
  * start of a textblock (i.e. the same coordinate space as `buildCharsByOffset`).
@@ -7,14 +6,6 @@ export type OffsetSpan = {
7
6
  from: number;
8
7
  to: number;
9
8
  };
10
- /**
11
- * Build a per-content-offset view of a textblock's characters.
12
- *
13
- * `chars[i]` is the character at content offset `i`, or `null` when that offset lies
14
- * inside a non-text inline node (mention, date, emoji, hardBreak, …). A `null` acts as an
15
- * *opaque single token*: it counts as one word and never terminates a sentence.
16
- */
17
- export declare const buildCharsByOffset: (parent: PMNode) => Array<string | null>;
18
9
  /**
19
10
  * Segment a textblock char-view into sentence spans (content-offset coordinates).
20
11
  * Uses Intl.Segmenter when available, otherwise a conservative regex fallback.
@@ -5,6 +5,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { ShowDiffPlugin } from '../../showDiffPluginType';
6
6
  /** Marks the host element of one tag, so a tag can be found in the document by its own diff. */
7
7
  export declare const CONTRIBUTOR_TAG_HOST_ATTRIBUTE = "data-contributor-tag-host";
8
+ export declare const isContributorTagWidgetEnabled: () => boolean;
8
9
  /**
9
10
  * Everything a tag needs to draw itself into the document, plumbed down from the plugin. Absent in
10
11
  * unit tests that build decorations directly: the hosts are still emitted, they just stay empty.
@@ -42,9 +43,9 @@ export declare const createContributorTagHost: (diffId: string, mountContext?: C
42
43
  mount: ContributorTagMount | undefined;
43
44
  } | undefined;
44
45
  /**
45
- * A widget hosting the contributor tag of one diff range, placed on the first character the range
46
- * highlights — or, with `anchorAtRangeStart`, at `from` itself. Either way a host that would land
47
- * inside a code block is hoisted out in front of it; see `resolveCodeBlockStart`.
46
+ * A widget hosting the contributor tag of one diff range, placed on the first visible character the
47
+ * range highlights — or, with `anchorAtRangeStart`, at `from` itself. Either way a host that would
48
+ * land inside a code block is hoisted out in front of it; see `resolveCodeBlockStart`.
48
49
  *
49
50
  * The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
50
51
  * element ProseMirror drew it into — see `mountContributorTag`.
@@ -4,6 +4,6 @@ import type { ResolvedDiffContributors } from './colorSchemes/attributions';
4
4
  /**
5
5
  * One model per diff decoration whose attribution resolves to a supplied contributor; anything
6
6
  * unattributed, untaggable or unresolved is skipped. A replacement's two decorations are collapsed
7
- * into the single inline tag — see `isSameChange`.
7
+ * into a single tag, on whichever half renders first — see `isSameChange` and `leadsReplacement`.
8
8
  */
9
9
  export declare const extractContributorTags: (decorations: DecorationSet, contributors: ResolvedDiffContributors | undefined) => ContributorTagModel[];
@@ -0,0 +1,16 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ export declare const isWhitespaceChar: (char: string) => boolean;
3
+ /**
4
+ * Build a per-content-offset view of a textblock's characters.
5
+ *
6
+ * Returns an array whose length is `parent.content.size`. For every offset that lies inside a text
7
+ * node, `chars[offset]` is the character at that offset; for every offset that lies inside (or on
8
+ * the edge of) a non-text inline node — hardBreak, mention, emoji, date, … — the entry is `null`,
9
+ * which acts as an *opaque single token*: it counts as one word and is never whitespace.
10
+ *
11
+ * Using doc positions to index `parent.textContent` is wrong because `textContent` strips non-text
12
+ * inline nodes, so every such node shifts the lookup off by its size. This per-offset view restores
13
+ * a 1:1 mapping between doc positions inside the textblock and the character (or "no character",
14
+ * i.e. a hard word boundary) at that position.
15
+ */
16
+ export declare const buildCharsByOffset: (parent: PMNode) => Array<string | null>;
@@ -0,0 +1,13 @@
1
+ import type { Fragment } from '@atlaskit/editor-prosemirror/model';
2
+ /**
3
+ * Whether `fragment` holds anything a reader can see.
4
+ *
5
+ * Text counts once it carries a single non-whitespace character; a leaf node (mention, emoji, date,
6
+ * media, rule, hardBreak, …) counts in its own right, exactly as `resolveTagAnchorPos` treats one.
7
+ * Everything else is descended into, so a paragraph is visible when its content is.
8
+ *
9
+ * A change whose content is nothing but whitespace — a space typed between two words, a run of
10
+ * trailing spaces, an added blank paragraph — has no visible content for a contributor tag to
11
+ * caption, so it carries no tag (EDITOR-8855).
12
+ */
13
+ export declare const hasVisibleContent: (fragment: Fragment) => boolean;
@@ -26,7 +26,7 @@ export type ContributorTagControllerOptions = {
26
26
  * `toDOM` for a widget it reuses: stepping to the next change republishes the tags without redrawing
27
27
  * their hosts, so anything the tag reacts to — `isActive` above all — has to arrive through a
28
28
  * subscription of its own (EDITOR-8702). Draws nothing when this diff has no tag, which is the case
29
- * for the deleted half of a replacement: that half is folded into the inline tag.
29
+ * for the folded half of a replacement: its two decorations share the one tag.
30
30
  */
31
31
  export declare class ContributorTagController {
32
32
  private options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "15.1.4",
3
+ "version": "15.1.6",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/platform-feature-experiments": "^0.3.0",
32
32
  "@atlaskit/platform-feature-flags": "^2.2.0",
33
33
  "@atlaskit/primitives": "^22.5.0",
34
- "@atlaskit/tmp-editor-statsig": "^184.0.0",
34
+ "@atlaskit/tmp-editor-statsig": "^185.0.0",
35
35
  "@atlaskit/tokens": "^16.11.0",
36
36
  "@babel/runtime": "^7.0.0",
37
37
  "@compiled/react": "^1.0.2",
@@ -56,14 +56,14 @@
56
56
  "@atlassian/confluence-presets": "workspace:^",
57
57
  "@atlassian/content-reconciliation": "^0.1.3506",
58
58
  "@atlassian/editor-ai-injected-editors": "^31.0.0",
59
- "@atlassian/editor-plugin-ai": "^71.2.0",
59
+ "@atlassian/editor-plugin-ai": "^71.3.0",
60
60
  "@atlassian/structured-docs-types": "workspace:^",
61
61
  "react": "^19.2.0",
62
62
  "react-dom": "^19.2.0",
63
63
  "react-intl": "^7.0.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "@atlaskit/editor-common": "^121.2.0",
66
+ "@atlaskit/editor-common": "^121.3.0",
67
67
  "react": "^18.2.0 || ^19.2.0",
68
68
  "react-dom": "^18.2.0 || ^19.2.0",
69
69
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"