@atlaskit/editor-plugin-show-diff 4.1.3 → 5.0.0

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 (32) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/pm-plugins/calculateDiffDecorations.js +15 -12
  3. package/dist/cjs/pm-plugins/decorations.js +47 -26
  4. package/dist/cjs/pm-plugins/deletedBlocksHandler.js +22 -22
  5. package/dist/cjs/pm-plugins/deletedRowsHandler.js +7 -7
  6. package/dist/cjs/pm-plugins/main.js +11 -5
  7. package/dist/cjs/showDiffPlugin.js +2 -1
  8. package/dist/es2019/pm-plugins/calculateDiffDecorations.js +15 -12
  9. package/dist/es2019/pm-plugins/decorations.js +47 -24
  10. package/dist/es2019/pm-plugins/deletedBlocksHandler.js +22 -22
  11. package/dist/es2019/pm-plugins/deletedRowsHandler.js +7 -7
  12. package/dist/es2019/pm-plugins/main.js +8 -4
  13. package/dist/es2019/showDiffPlugin.js +3 -2
  14. package/dist/esm/pm-plugins/calculateDiffDecorations.js +15 -12
  15. package/dist/esm/pm-plugins/decorations.js +47 -26
  16. package/dist/esm/pm-plugins/deletedBlocksHandler.js +22 -22
  17. package/dist/esm/pm-plugins/deletedRowsHandler.js +7 -7
  18. package/dist/esm/pm-plugins/main.js +10 -4
  19. package/dist/esm/showDiffPlugin.js +3 -2
  20. package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +2 -2
  21. package/dist/types/pm-plugins/decorations.d.ts +6 -6
  22. package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +8 -8
  23. package/dist/types/pm-plugins/deletedRowsHandler.d.ts +3 -3
  24. package/dist/types/pm-plugins/main.d.ts +2 -0
  25. package/dist/types/showDiffPluginType.d.ts +2 -1
  26. package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +2 -2
  27. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +6 -6
  28. package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +8 -8
  29. package/dist/types-ts4.5/pm-plugins/deletedRowsHandler.d.ts +3 -3
  30. package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -0
  31. package/dist/types-ts4.5/showDiffPluginType.d.ts +2 -1
  32. package/package.json +3 -3
@@ -56,8 +56,8 @@ var lozengeStyle = convertToInlineCss({
56
56
  whiteSpace: 'nowrap',
57
57
  color: "var(--ds-text-warning-inverse, #292A2E)"
58
58
  });
59
- export var getDeletedStyleNode = function getDeletedStyleNode(nodeName, colourScheme) {
60
- var isTraditional = colourScheme === 'traditional';
59
+ export var getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
60
+ var isTraditional = colorScheme === 'traditional';
61
61
  switch (nodeName) {
62
62
  case 'blockquote':
63
63
  return fg('platform_editor_ai_aifc_patch_ga_blockers') ? isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge : deletedStyleQuoteNode;
@@ -156,29 +156,29 @@ export var createBlockNodeWrapper = function createBlockNodeWrapper() {
156
156
  /**
157
157
  * Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
158
158
  */
159
- export var createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colourScheme, isActive) {
159
+ export var createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colorScheme, isActive) {
160
160
  var wrapper = document.createElement('span');
161
- wrapper.setAttribute('style', getDeletedContentStyle(colourScheme, isActive));
161
+ wrapper.setAttribute('style', getDeletedContentStyle(colorScheme, isActive));
162
162
  return wrapper;
163
163
  };
164
164
 
165
165
  /**
166
166
  * Applies deleted styles directly to an HTML element by merging with existing styles
167
167
  */
168
- export var applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colourScheme) {
168
+ export var applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colorScheme) {
169
169
  var currentStyle = element.getAttribute('style') || '';
170
- var deletedContentStyle = getDeletedContentStyle(colourScheme);
171
- var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colourScheme) || '';
170
+ var deletedContentStyle = getDeletedContentStyle(colorScheme);
171
+ var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colorScheme) || '';
172
172
  element.setAttribute('style', "".concat(currentStyle).concat(deletedContentStyle).concat(nodeSpecificStyle));
173
173
  };
174
174
 
175
175
  /**
176
176
  * Creates a content wrapper with deleted styles for a block node
177
177
  */
178
- export var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeView, targetNode, colourScheme) {
178
+ export var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeView, targetNode, colorScheme) {
179
179
  var contentWrapper = document.createElement('div');
180
- var nodeStyle = getDeletedStyleNode(targetNode.type.name, colourScheme);
181
- contentWrapper.setAttribute('style', "".concat(getDeletedContentStyle(colourScheme)).concat(nodeStyle || ''));
180
+ var nodeStyle = getDeletedStyleNode(targetNode.type.name, colorScheme);
181
+ contentWrapper.setAttribute('style', "".concat(getDeletedContentStyle(colorScheme)).concat(nodeStyle || ''));
182
182
  contentWrapper.append(nodeView);
183
183
  return contentWrapper;
184
184
  };
@@ -189,7 +189,7 @@ export var createBlockNodeContentWrapper = function createBlockNodeContentWrappe
189
189
  * to wait for the rich-media-item to appear before attaching the lozenge.
190
190
  * @returns true if embedCard was handled
191
191
  */
192
- export var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colourScheme) {
192
+ export var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) {
193
193
  if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
194
194
  return false;
195
195
  }
@@ -210,7 +210,7 @@ export var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom,
210
210
  });
211
211
  }
212
212
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
213
- var showDiffDeletedNodeClass = colourScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
213
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
214
214
  nodeView.classList.add(showDiffDeletedNodeClass);
215
215
  }
216
216
  dom.append(nodeView);
@@ -221,7 +221,7 @@ export var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom,
221
221
  * Handles special mediaSingle node rendering with lozenge on child media element
222
222
  * @returns true if mediaSingle was handled, false otherwise
223
223
  */
224
- export var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colourScheme) {
224
+ export var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) {
225
225
  if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
226
226
  return false;
227
227
  }
@@ -240,7 +240,7 @@ export var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
240
240
 
241
241
  // Add deleted node class if needed
242
242
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
243
- var showDiffDeletedNodeClass = colourScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
243
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
244
244
  nodeView.classList.add(showDiffDeletedNodeClass);
245
245
  }
246
246
  dom.append(nodeView);
@@ -250,22 +250,22 @@ export var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
250
250
  /**
251
251
  * Appends a block node with wrapper, lozenge, and appropriate styling
252
252
  */
253
- export var appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl) {
253
+ export var appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl) {
254
254
  var blockWrapper = createBlockNodeWrapper();
255
255
  if (shouldShowRemovedLozenge(targetNode.type.name)) {
256
256
  var lozenge = createRemovedLozenge(intl);
257
- if (handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colourScheme) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
257
+ if (handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
258
258
  return;
259
259
  }
260
- if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colourScheme)) {
260
+ if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme)) {
261
261
  return;
262
262
  }
263
263
  blockWrapper.append(lozenge);
264
264
  }
265
- var contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode, colourScheme);
265
+ var contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode, colorScheme);
266
266
  blockWrapper.append(contentWrapper);
267
267
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
268
- var showDiffDeletedNodeClass = colourScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
268
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
269
269
  nodeView.classList.add(showDiffDeletedNodeClass);
270
270
  }
271
271
  dom.append(blockWrapper);
@@ -276,13 +276,13 @@ export var appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom,
276
276
  * For heading nodes, applies styles directly to preserve natural margins.
277
277
  * For other block nodes, uses wrapper approach with optional lozenge.
278
278
  */
279
- export var handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode, colourScheme, intl) {
279
+ export var handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode, colorScheme, intl) {
280
280
  if (shouldApplyDeletedStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
281
281
  // Apply deleted styles directly to preserve natural block-level margins
282
- applyDeletedStylesToElement(nodeView, targetNode, colourScheme);
282
+ applyDeletedStylesToElement(nodeView, targetNode, colorScheme);
283
283
  dom.append(nodeView);
284
284
  } else {
285
285
  // Use wrapper approach for other block nodes
286
- appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl);
286
+ appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl);
287
287
  }
288
288
  };
@@ -58,7 +58,7 @@ var extractDeletedRows = function extractDeletedRows(change, originalDoc, newDoc
58
58
  var changeEndInTable = change.toA - tableOld.pos - 1;
59
59
  var currentOffset = 0;
60
60
  var rowIndex = 0;
61
- tableOld.node.content.forEach(function (rowNode, index) {
61
+ tableOld.node.content.forEach(function (rowNode) {
62
62
  var rowStart = currentOffset;
63
63
  var rowEnd = currentOffset + rowNode.nodeSize;
64
64
 
@@ -119,9 +119,9 @@ var isEmptyRow = function isEmptyRow(rowNode) {
119
119
  /**
120
120
  * Creates a DOM representation of a deleted table row
121
121
  */
122
- var createDeletedRowDOM = function createDeletedRowDOM(rowNode, nodeViewSerializer, colourScheme) {
122
+ var createDeletedRowDOM = function createDeletedRowDOM(rowNode, nodeViewSerializer, colorScheme) {
123
123
  var tr = document.createElement('tr');
124
- tr.setAttribute('style', colourScheme === 'traditional' ? deletedTraditionalRowStyle : deletedRowStyle);
124
+ tr.setAttribute('style', colorScheme === 'traditional' ? deletedTraditionalRowStyle : deletedRowStyle);
125
125
  tr.setAttribute('data-testid', 'show-diff-deleted-row');
126
126
 
127
127
  // Serialize each cell in the row
@@ -174,9 +174,9 @@ export var createDeletedRowsDecorations = function createDeletedRowsDecorations(
174
174
  originalDoc = _ref.originalDoc,
175
175
  newDoc = _ref.newDoc,
176
176
  nodeViewSerializer = _ref.nodeViewSerializer,
177
- colourScheme = _ref.colourScheme;
177
+ colorScheme = _ref.colorScheme;
178
178
  return deletedRows.map(function (deletedRow) {
179
- var rowDOM = createDeletedRowDOM(deletedRow.rowNode, nodeViewSerializer, colourScheme);
179
+ var rowDOM = createDeletedRowDOM(deletedRow.rowNode, nodeViewSerializer, colorScheme);
180
180
 
181
181
  // Find safe insertion position for the deleted row
182
182
  var safeInsertPos = findSafeInsertPos(newDoc, deletedRow.fromB - 1,
@@ -189,7 +189,7 @@ export var createDeletedRowsDecorations = function createDeletedRowsDecorations(
189
189
  /**
190
190
  * Main function to handle deleted rows - computes diff and creates decorations
191
191
  */
192
- export var handleDeletedRows = function handleDeletedRows(changes, originalDoc, newDoc, nodeViewSerializer, colourScheme) {
192
+ export var handleDeletedRows = function handleDeletedRows(changes, originalDoc, newDoc, nodeViewSerializer, colorScheme) {
193
193
  // First, expand the changes to include complete deleted rows
194
194
  var deletedRows = expandDiffForDeletedRows(changes.filter(function (change) {
195
195
  return change.deleted.length > 0;
@@ -199,7 +199,7 @@ export var handleDeletedRows = function handleDeletedRows(changes, originalDoc,
199
199
  originalDoc: originalDoc,
200
200
  newDoc: newDoc,
201
201
  nodeViewSerializer: nodeViewSerializer,
202
- colourScheme: colourScheme
202
+ colorScheme: colorScheme
203
203
  });
204
204
  return {
205
205
  decorations: allDecorations
@@ -10,6 +10,12 @@ import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import { calculateDiffDecorations } from './calculateDiffDecorations';
11
11
  import { NodeViewSerializer } from './NodeViewSerializer';
12
12
  export var showDiffPluginKey = new PluginKey('showDiffPlugin');
13
+ export var getScrollableDecorations = function getScrollableDecorations(set) {
14
+ var _set$find;
15
+ return (_set$find = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, function (spec) {
16
+ return spec.key === 'diff-inline' || spec.key === 'diff-widget' || spec.key === 'diff-block';
17
+ })) !== null && _set$find !== void 0 ? _set$find : [];
18
+ };
13
19
  export var createPlugin = function createPlugin(config, getIntl) {
14
20
  var nodeViewSerializer = new NodeViewSerializer({});
15
21
  var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
@@ -36,7 +42,7 @@ export var createPlugin = function createPlugin(config, getIntl) {
36
42
  if (!pluginState || pluginState.decorations.find().length === 0) {
37
43
  return;
38
44
  }
39
- var decorations = pluginState.decorations.find();
45
+ var decorations = getScrollableDecorations(pluginState.decorations);
40
46
  var decoration = decorations[(_pluginState$activeIn = pluginState.activeIndex) !== null && _pluginState$activeIn !== void 0 ? _pluginState$activeIn : 0];
41
47
  if (!decoration) {
42
48
  return;
@@ -78,7 +84,7 @@ export var createPlugin = function createPlugin(config, getIntl) {
78
84
  state: newState,
79
85
  pluginState: newPluginState,
80
86
  nodeViewSerializer: nodeViewSerializer,
81
- colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme,
87
+ colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
82
88
  intl: getIntl(),
83
89
  activeIndexPos: fg('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined
84
90
  });
@@ -92,7 +98,7 @@ export var createPlugin = function createPlugin(config, getIntl) {
92
98
  });
93
99
  } else if (((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') && fg('platform_editor_show_diff_scroll_navigation')) {
94
100
  // Update the active index in plugin state and recalculate decorations
95
- var _decorations = currentPluginState.decorations.find();
101
+ var _decorations = getScrollableDecorations(currentPluginState.decorations);
96
102
  if (_decorations.length > 0) {
97
103
  var _currentPluginState$a;
98
104
  var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : 0;
@@ -114,7 +120,7 @@ export var createPlugin = function createPlugin(config, getIntl) {
114
120
  state: newState,
115
121
  pluginState: newPluginState,
116
122
  nodeViewSerializer: nodeViewSerializer,
117
- colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme,
123
+ colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
118
124
  intl: getIntl(),
119
125
  activeIndexPos: newPluginState.activeIndexPos
120
126
  });
@@ -1,7 +1,8 @@
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 { createPlugin, showDiffPluginKey } from './pm-plugins/main';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { createPlugin, showDiffPluginKey, getScrollableDecorations } from './pm-plugins/main';
5
6
  export var showDiffPlugin = function showDiffPlugin(_ref) {
6
7
  var _api = _ref.api,
7
8
  config = _ref.config;
@@ -54,7 +55,7 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
54
55
  };
55
56
  }
56
57
  var pluginState = showDiffPluginKey.getState(editorState);
57
- var decorationCount = (pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
58
+ var decorationCount = fg('platform_editor_show_diff_scroll_navigation') ? getScrollableDecorations(pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations) : (pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
58
59
  return {
59
60
  isDisplayingChanges: decorationCount.length > 0,
60
61
  activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
@@ -3,12 +3,12 @@ import { type EditorState } from '@atlaskit/editor-prosemirror/state';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ShowDiffPluginState } from './main';
5
5
  import type { NodeViewSerializer } from './NodeViewSerializer';
6
- export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colourScheme, intl, activeIndexPos, }: {
6
+ export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, }: {
7
7
  activeIndexPos?: {
8
8
  from: number;
9
9
  to: number;
10
10
  };
11
- colourScheme?: "standard" | "traditional";
11
+ colorScheme?: "standard" | "traditional";
12
12
  intl: IntlShape;
13
13
  nodeViewSerializer: NodeViewSerializer;
14
14
  pluginState: Omit<ShowDiffPluginState, "decorations">;
@@ -12,9 +12,9 @@ import type { NodeViewSerializer } from './NodeViewSerializer';
12
12
  export declare const createInlineChangedDecoration: (change: {
13
13
  fromB: number;
14
14
  toB: number;
15
- }, colourScheme?: "standard" | "traditional", isActive?: boolean) => Decoration;
16
- export declare const getDeletedContentStyleUnbounded: (colourScheme?: "standard" | "traditional") => string;
17
- export declare const getDeletedContentStyle: (colourScheme?: "standard" | "traditional", isActive?: boolean) => string;
15
+ }, colorScheme?: "standard" | "traditional", isActive?: boolean) => Decoration;
16
+ export declare const getDeletedContentStyleUnbounded: (colorScheme?: "standard" | "traditional") => string;
17
+ export declare const getDeletedContentStyle: (colorScheme?: "standard" | "traditional", isActive?: boolean) => string;
18
18
  /**
19
19
  * Inline decoration used for insertions as the content already exists in the document
20
20
  *
@@ -25,15 +25,15 @@ export declare const createBlockChangedDecoration: (change: {
25
25
  from: number;
26
26
  name: string;
27
27
  to: number;
28
- }, colourScheme?: "standard" | "traditional") => Decoration;
28
+ }, colorScheme?: "standard" | "traditional") => Decoration | undefined;
29
29
  interface DeletedContentDecorationProps {
30
30
  change: Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
31
- colourScheme?: 'standard' | 'traditional';
31
+ colorScheme?: 'standard' | 'traditional';
32
32
  doc: PMNode;
33
33
  intl: IntlShape;
34
34
  isActive?: boolean;
35
35
  newDoc: PMNode;
36
36
  nodeViewSerializer: NodeViewSerializer;
37
37
  }
38
- export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, colourScheme, newDoc, intl, isActive, }: DeletedContentDecorationProps) => Decoration[] | undefined;
38
+ export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, }: DeletedContentDecorationProps) => Decoration[] | undefined;
39
39
  export {};
@@ -7,7 +7,7 @@ export declare const deletedBlockOutline: string;
7
7
  export declare const deletedTraditionalBlockOutline: string;
8
8
  export declare const deletedBlockOutlineRounded: string;
9
9
  export declare const deletedTraditionalBlockOutlineRounded: string;
10
- export declare const getDeletedStyleNode: (nodeName: string, colourScheme?: "standard" | "traditional") => string | undefined;
10
+ export declare const getDeletedStyleNode: (nodeName: string, colorScheme?: "standard" | "traditional") => string | undefined;
11
11
  export declare const shouldShowRemovedLozenge: (nodeName: string) => boolean;
12
12
  export declare const shouldAddShowDiffDeletedNodeClass: (nodeName: string) => boolean;
13
13
  /**
@@ -26,34 +26,34 @@ export declare const createBlockNodeWrapper: () => HTMLDivElement;
26
26
  /**
27
27
  * Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
28
28
  */
29
- export declare const createDeletedStyleWrapperWithoutOpacity: (colourScheme?: "standard" | "traditional", isActive?: boolean) => HTMLSpanElement;
29
+ export declare const createDeletedStyleWrapperWithoutOpacity: (colorScheme?: "standard" | "traditional", isActive?: boolean) => HTMLSpanElement;
30
30
  /**
31
31
  * Applies deleted styles directly to an HTML element by merging with existing styles
32
32
  */
33
- export declare const applyDeletedStylesToElement: (element: HTMLElement, targetNode: PMNode, colourScheme: "standard" | "traditional" | undefined) => void;
33
+ export declare const applyDeletedStylesToElement: (element: HTMLElement, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined) => void;
34
34
  /**
35
35
  * Creates a content wrapper with deleted styles for a block node
36
36
  */
37
- export declare const createBlockNodeContentWrapper: (nodeView: Node, targetNode: PMNode, colourScheme: "standard" | "traditional" | undefined) => HTMLElement;
37
+ export declare const createBlockNodeContentWrapper: (nodeView: Node, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined) => HTMLElement;
38
38
  /**
39
39
  * Handles embedCard node rendering with lozenge attached to the rich-media-item container.
40
40
  * Since embedCard content loads asynchronously, we use a MutationObserver
41
41
  * to wait for the rich-media-item to appear before attaching the lozenge.
42
42
  * @returns true if embedCard was handled
43
43
  */
44
- export declare const handleEmbedCardWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colourScheme: "standard" | "traditional" | undefined) => boolean;
44
+ export declare const handleEmbedCardWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colorScheme: "standard" | "traditional" | undefined) => boolean;
45
45
  /**
46
46
  * Handles special mediaSingle node rendering with lozenge on child media element
47
47
  * @returns true if mediaSingle was handled, false otherwise
48
48
  */
49
- export declare const handleMediaSingleWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colourScheme: "standard" | "traditional" | undefined) => boolean;
49
+ export declare const handleMediaSingleWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colorScheme: "standard" | "traditional" | undefined) => boolean;
50
50
  /**
51
51
  * Appends a block node with wrapper, lozenge, and appropriate styling
52
52
  */
53
- export declare const appendBlockNodeWithWrapper: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colourScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
53
+ export declare const appendBlockNodeWithWrapper: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
54
54
  /**
55
55
  * Handles all block node rendering with appropriate deleted styling.
56
56
  * For heading nodes, applies styles directly to preserve natural margins.
57
57
  * For other block nodes, uses wrapper approach with optional lozenge.
58
58
  */
59
- export declare const handleBlockNodeView: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colourScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
59
+ export declare const handleBlockNodeView: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
@@ -11,7 +11,7 @@ interface DeletedRowInfo {
11
11
  }
12
12
  type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
13
13
  interface DeletedRowsHandlerProps {
14
- colourScheme?: 'standard' | 'traditional';
14
+ colorScheme?: 'standard' | 'traditional';
15
15
  deletedRows: DeletedRowInfo[];
16
16
  newDoc: PMNode;
17
17
  nodeViewSerializer: NodeViewSerializer;
@@ -20,11 +20,11 @@ interface DeletedRowsHandlerProps {
20
20
  /**
21
21
  * Creates decorations for deleted table rows
22
22
  */
23
- export declare const createDeletedRowsDecorations: ({ deletedRows, originalDoc, newDoc, nodeViewSerializer, colourScheme, }: DeletedRowsHandlerProps) => Decoration[];
23
+ export declare const createDeletedRowsDecorations: ({ deletedRows, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: DeletedRowsHandlerProps) => Decoration[];
24
24
  /**
25
25
  * Main function to handle deleted rows - computes diff and creates decorations
26
26
  */
27
- export declare const handleDeletedRows: (changes: SimpleChange[], originalDoc: PMNode, newDoc: PMNode, nodeViewSerializer: NodeViewSerializer, colourScheme?: "standard" | "traditional") => {
27
+ export declare const handleDeletedRows: (changes: SimpleChange[], originalDoc: PMNode, newDoc: PMNode, nodeViewSerializer: NodeViewSerializer, colorScheme?: "standard" | "traditional") => {
28
28
  decorations: Decoration[];
29
29
  };
30
30
  export {};
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
6
+ import type { Decoration } from '@atlaskit/editor-prosemirror/view';
6
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
8
  import { type DiffParams } from '../showDiffPluginType';
8
9
  export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
@@ -17,4 +18,5 @@ export type ShowDiffPluginState = {
17
18
  originalDoc: PMNode | undefined;
18
19
  steps: ProseMirrorStep[];
19
20
  };
21
+ export declare const getScrollableDecorations: (set: DecorationSet | undefined) => Decoration[];
20
22
  export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape) => SafePlugin<ShowDiffPluginState>;
@@ -3,13 +3,14 @@ import type { NextEditorPlugin, EditorCommand } from '@atlaskit/editor-common/ty
3
3
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
4
4
  import type { Node } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Step } from '@atlaskit/editor-prosemirror/transform';
6
+ export type ColorScheme = 'standard' | 'traditional';
6
7
  export type DiffParams = {
7
8
  /**
8
9
  * Color scheme to use for displaying diffs.
9
10
  * 'standard' (default) uses purple for highlighting changes
10
11
  * 'traditional' uses green for additions and red for deletions
11
12
  */
12
- colourScheme?: 'standard' | 'traditional';
13
+ colorScheme?: ColorScheme;
13
14
  originalDoc: JSONDocNode;
14
15
  /**
15
16
  * Prosemirror steps. This is used to calculate and show the diff in the editor
@@ -3,12 +3,12 @@ import { type EditorState } from '@atlaskit/editor-prosemirror/state';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ShowDiffPluginState } from './main';
5
5
  import type { NodeViewSerializer } from './NodeViewSerializer';
6
- export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colourScheme, intl, activeIndexPos, }: {
6
+ export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, }: {
7
7
  activeIndexPos?: {
8
8
  from: number;
9
9
  to: number;
10
10
  };
11
- colourScheme?: "standard" | "traditional";
11
+ colorScheme?: "standard" | "traditional";
12
12
  intl: IntlShape;
13
13
  nodeViewSerializer: NodeViewSerializer;
14
14
  pluginState: Omit<ShowDiffPluginState, "decorations">;
@@ -12,9 +12,9 @@ import type { NodeViewSerializer } from './NodeViewSerializer';
12
12
  export declare const createInlineChangedDecoration: (change: {
13
13
  fromB: number;
14
14
  toB: number;
15
- }, colourScheme?: "standard" | "traditional", isActive?: boolean) => Decoration;
16
- export declare const getDeletedContentStyleUnbounded: (colourScheme?: "standard" | "traditional") => string;
17
- export declare const getDeletedContentStyle: (colourScheme?: "standard" | "traditional", isActive?: boolean) => string;
15
+ }, colorScheme?: "standard" | "traditional", isActive?: boolean) => Decoration;
16
+ export declare const getDeletedContentStyleUnbounded: (colorScheme?: "standard" | "traditional") => string;
17
+ export declare const getDeletedContentStyle: (colorScheme?: "standard" | "traditional", isActive?: boolean) => string;
18
18
  /**
19
19
  * Inline decoration used for insertions as the content already exists in the document
20
20
  *
@@ -25,15 +25,15 @@ export declare const createBlockChangedDecoration: (change: {
25
25
  from: number;
26
26
  name: string;
27
27
  to: number;
28
- }, colourScheme?: "standard" | "traditional") => Decoration;
28
+ }, colorScheme?: "standard" | "traditional") => Decoration | undefined;
29
29
  interface DeletedContentDecorationProps {
30
30
  change: Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
31
- colourScheme?: 'standard' | 'traditional';
31
+ colorScheme?: 'standard' | 'traditional';
32
32
  doc: PMNode;
33
33
  intl: IntlShape;
34
34
  isActive?: boolean;
35
35
  newDoc: PMNode;
36
36
  nodeViewSerializer: NodeViewSerializer;
37
37
  }
38
- export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, colourScheme, newDoc, intl, isActive, }: DeletedContentDecorationProps) => Decoration[] | undefined;
38
+ export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, }: DeletedContentDecorationProps) => Decoration[] | undefined;
39
39
  export {};
@@ -7,7 +7,7 @@ export declare const deletedBlockOutline: string;
7
7
  export declare const deletedTraditionalBlockOutline: string;
8
8
  export declare const deletedBlockOutlineRounded: string;
9
9
  export declare const deletedTraditionalBlockOutlineRounded: string;
10
- export declare const getDeletedStyleNode: (nodeName: string, colourScheme?: "standard" | "traditional") => string | undefined;
10
+ export declare const getDeletedStyleNode: (nodeName: string, colorScheme?: "standard" | "traditional") => string | undefined;
11
11
  export declare const shouldShowRemovedLozenge: (nodeName: string) => boolean;
12
12
  export declare const shouldAddShowDiffDeletedNodeClass: (nodeName: string) => boolean;
13
13
  /**
@@ -26,34 +26,34 @@ export declare const createBlockNodeWrapper: () => HTMLDivElement;
26
26
  /**
27
27
  * Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
28
28
  */
29
- export declare const createDeletedStyleWrapperWithoutOpacity: (colourScheme?: "standard" | "traditional", isActive?: boolean) => HTMLSpanElement;
29
+ export declare const createDeletedStyleWrapperWithoutOpacity: (colorScheme?: "standard" | "traditional", isActive?: boolean) => HTMLSpanElement;
30
30
  /**
31
31
  * Applies deleted styles directly to an HTML element by merging with existing styles
32
32
  */
33
- export declare const applyDeletedStylesToElement: (element: HTMLElement, targetNode: PMNode, colourScheme: "standard" | "traditional" | undefined) => void;
33
+ export declare const applyDeletedStylesToElement: (element: HTMLElement, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined) => void;
34
34
  /**
35
35
  * Creates a content wrapper with deleted styles for a block node
36
36
  */
37
- export declare const createBlockNodeContentWrapper: (nodeView: Node, targetNode: PMNode, colourScheme: "standard" | "traditional" | undefined) => HTMLElement;
37
+ export declare const createBlockNodeContentWrapper: (nodeView: Node, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined) => HTMLElement;
38
38
  /**
39
39
  * Handles embedCard node rendering with lozenge attached to the rich-media-item container.
40
40
  * Since embedCard content loads asynchronously, we use a MutationObserver
41
41
  * to wait for the rich-media-item to appear before attaching the lozenge.
42
42
  * @returns true if embedCard was handled
43
43
  */
44
- export declare const handleEmbedCardWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colourScheme: "standard" | "traditional" | undefined) => boolean;
44
+ export declare const handleEmbedCardWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colorScheme: "standard" | "traditional" | undefined) => boolean;
45
45
  /**
46
46
  * Handles special mediaSingle node rendering with lozenge on child media element
47
47
  * @returns true if mediaSingle was handled, false otherwise
48
48
  */
49
- export declare const handleMediaSingleWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colourScheme: "standard" | "traditional" | undefined) => boolean;
49
+ export declare const handleMediaSingleWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colorScheme: "standard" | "traditional" | undefined) => boolean;
50
50
  /**
51
51
  * Appends a block node with wrapper, lozenge, and appropriate styling
52
52
  */
53
- export declare const appendBlockNodeWithWrapper: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colourScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
53
+ export declare const appendBlockNodeWithWrapper: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
54
54
  /**
55
55
  * Handles all block node rendering with appropriate deleted styling.
56
56
  * For heading nodes, applies styles directly to preserve natural margins.
57
57
  * For other block nodes, uses wrapper approach with optional lozenge.
58
58
  */
59
- export declare const handleBlockNodeView: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colourScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
59
+ export declare const handleBlockNodeView: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
@@ -11,7 +11,7 @@ interface DeletedRowInfo {
11
11
  }
12
12
  type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
13
13
  interface DeletedRowsHandlerProps {
14
- colourScheme?: 'standard' | 'traditional';
14
+ colorScheme?: 'standard' | 'traditional';
15
15
  deletedRows: DeletedRowInfo[];
16
16
  newDoc: PMNode;
17
17
  nodeViewSerializer: NodeViewSerializer;
@@ -20,11 +20,11 @@ interface DeletedRowsHandlerProps {
20
20
  /**
21
21
  * Creates decorations for deleted table rows
22
22
  */
23
- export declare const createDeletedRowsDecorations: ({ deletedRows, originalDoc, newDoc, nodeViewSerializer, colourScheme, }: DeletedRowsHandlerProps) => Decoration[];
23
+ export declare const createDeletedRowsDecorations: ({ deletedRows, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: DeletedRowsHandlerProps) => Decoration[];
24
24
  /**
25
25
  * Main function to handle deleted rows - computes diff and creates decorations
26
26
  */
27
- export declare const handleDeletedRows: (changes: SimpleChange[], originalDoc: PMNode, newDoc: PMNode, nodeViewSerializer: NodeViewSerializer, colourScheme?: "standard" | "traditional") => {
27
+ export declare const handleDeletedRows: (changes: SimpleChange[], originalDoc: PMNode, newDoc: PMNode, nodeViewSerializer: NodeViewSerializer, colorScheme?: "standard" | "traditional") => {
28
28
  decorations: Decoration[];
29
29
  };
30
30
  export {};
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
6
+ import type { Decoration } from '@atlaskit/editor-prosemirror/view';
6
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
8
  import { type DiffParams } from '../showDiffPluginType';
8
9
  export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
@@ -17,4 +18,5 @@ export type ShowDiffPluginState = {
17
18
  originalDoc: PMNode | undefined;
18
19
  steps: ProseMirrorStep[];
19
20
  };
21
+ export declare const getScrollableDecorations: (set: DecorationSet | undefined) => Decoration[];
20
22
  export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape) => SafePlugin<ShowDiffPluginState>;
@@ -3,13 +3,14 @@ import type { NextEditorPlugin, EditorCommand } from '@atlaskit/editor-common/ty
3
3
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
4
4
  import type { Node } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Step } from '@atlaskit/editor-prosemirror/transform';
6
+ export type ColorScheme = 'standard' | 'traditional';
6
7
  export type DiffParams = {
7
8
  /**
8
9
  * Color scheme to use for displaying diffs.
9
10
  * 'standard' (default) uses purple for highlighting changes
10
11
  * 'traditional' uses green for additions and red for deletions
11
12
  */
12
- colourScheme?: 'standard' | 'traditional';
13
+ colorScheme?: ColorScheme;
13
14
  originalDoc: JSONDocNode;
14
15
  /**
15
16
  * Prosemirror steps. This is used to calculate and show the diff in the editor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "4.1.3",
3
+ "version": "5.0.0",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  "@atlaskit/editor-prosemirror": "^7.3.0",
33
33
  "@atlaskit/editor-tables": "^2.9.0",
34
34
  "@atlaskit/platform-feature-flags": "^1.1.0",
35
- "@atlaskit/tmp-editor-statsig": "^32.10.0",
35
+ "@atlaskit/tmp-editor-statsig": "^32.12.0",
36
36
  "@atlaskit/tokens": "^11.0.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "lodash": "^4.17.21",
@@ -40,7 +40,7 @@
40
40
  "prosemirror-changeset": "^2.3.1"
41
41
  },
42
42
  "peerDependencies": {
43
- "@atlaskit/editor-common": "^111.24.0",
43
+ "@atlaskit/editor-common": "^111.25.0",
44
44
  "react": "^18.2.0"
45
45
  },
46
46
  "techstack": {