@atlaskit/editor-plugin-show-diff 5.0.5 → 5.0.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 (65) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/pm-plugins/calculateDiffDecorations.js +12 -10
  3. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +75 -0
  4. package/dist/cjs/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +31 -52
  5. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +33 -0
  6. package/dist/cjs/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +29 -114
  7. package/dist/cjs/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
  8. package/dist/cjs/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +83 -21
  9. package/dist/es2019/pm-plugins/calculateDiffDecorations.js +6 -4
  10. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +70 -0
  11. package/dist/es2019/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +28 -50
  12. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +28 -0
  13. package/dist/es2019/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +16 -103
  14. package/dist/es2019/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
  15. package/dist/es2019/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +85 -18
  16. package/dist/esm/pm-plugins/calculateDiffDecorations.js +6 -4
  17. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +69 -0
  18. package/dist/esm/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +30 -51
  19. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +28 -0
  20. package/dist/esm/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +30 -115
  21. package/dist/esm/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
  22. package/dist/esm/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +80 -18
  23. package/dist/types/pm-plugins/NodeViewSerializer.d.ts +1 -1
  24. package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +2 -1
  25. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +16 -0
  26. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +17 -0
  27. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +16 -0
  28. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +15 -0
  29. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +15 -0
  30. package/dist/types-ts4.5/pm-plugins/NodeViewSerializer.d.ts +1 -1
  31. package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +2 -1
  32. package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +16 -0
  33. package/dist/types-ts4.5/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +17 -0
  34. package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +16 -0
  35. package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +15 -0
  36. package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +15 -0
  37. package/package.json +3 -3
  38. package/dist/types/pm-plugins/decorations.d.ts +0 -46
  39. package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +0 -14
  40. package/dist/types/pm-plugins/deletedRowsHandler.d.ts +0 -36
  41. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +0 -46
  42. package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +0 -14
  43. package/dist/types-ts4.5/pm-plugins/deletedRowsHandler.d.ts +0 -36
  44. /package/dist/cjs/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +0 -0
  45. /package/dist/cjs/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +0 -0
  46. /package/dist/cjs/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
  47. /package/dist/cjs/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
  48. /package/dist/es2019/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +0 -0
  49. /package/dist/es2019/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +0 -0
  50. /package/dist/es2019/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
  51. /package/dist/es2019/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
  52. /package/dist/esm/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +0 -0
  53. /package/dist/esm/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +0 -0
  54. /package/dist/esm/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
  55. /package/dist/esm/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
  56. /package/dist/types/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.d.ts +0 -0
  57. /package/dist/types/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.d.ts +0 -0
  58. /package/dist/types/pm-plugins/{findSafeInsertPos.d.ts → decorations/utils/findSafeInsertPos.d.ts} +0 -0
  59. /package/dist/types/pm-plugins/{attributeDecorations.d.ts → decorations/utils/getAttrChangeRanges.d.ts} +0 -0
  60. /package/dist/types/pm-plugins/{markDecorations.d.ts → decorations/utils/getMarkChangeRanges.d.ts} +0 -0
  61. /package/dist/types-ts4.5/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.d.ts +0 -0
  62. /package/dist/types-ts4.5/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.d.ts +0 -0
  63. /package/dist/types-ts4.5/pm-plugins/{findSafeInsertPos.d.ts → decorations/utils/findSafeInsertPos.d.ts} +0 -0
  64. /package/dist/types-ts4.5/pm-plugins/{attributeDecorations.d.ts → decorations/utils/getAttrChangeRanges.d.ts} +0 -0
  65. /package/dist/types-ts4.5/pm-plugins/{markDecorations.d.ts → decorations/utils/getMarkChangeRanges.d.ts} +0 -0
@@ -4,9 +4,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
5
5
  import { trackChangesMessages } from '@atlaskit/editor-common/messages';
6
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
- import { deletedStyleQuoteNode, deletedStyleQuoteNodeWithLozenge, deletedBlockOutline, deletedBlockOutlineRounded } from './colorSchemes/standard';
8
- import { deletedTraditionalStyleQuoteNode, deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded } from './colorSchemes/traditional';
9
- import { getDeletedContentStyle } from './decorations';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
+ import { deletedStyleQuoteNode, deletedStyleQuoteNodeWithLozenge, deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive } from '../colorSchemes/standard';
9
+ import { deletedTraditionalStyleQuoteNode, deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle } from '../colorSchemes/traditional';
10
10
  var lozengeStyle = convertToInlineCss({
11
11
  display: 'inline-flex',
12
12
  boxSizing: 'border-box',
@@ -23,7 +23,17 @@ var lozengeStyle = convertToInlineCss({
23
23
  whiteSpace: 'nowrap',
24
24
  color: "var(--ds-text-warning-inverse, #292A2E)"
25
25
  });
26
- export var getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
26
+ var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
27
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
28
+ if (colorScheme === 'traditional') {
29
+ return deletedTraditionalContentStyle;
30
+ }
31
+ if (isActive) {
32
+ return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNewActive : deletedContentStyleActive;
33
+ }
34
+ return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
35
+ };
36
+ var getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
27
37
  var isTraditional = colorScheme === 'traditional';
28
38
  switch (nodeName) {
29
39
  case 'blockquote':
@@ -69,7 +79,7 @@ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeCla
69
79
  * Checks if a node should apply deleted styles directly without wrapper
70
80
  * to preserve natural block-level margins
71
81
  */
72
- var shouldApplyDeletedStylesDirectly = function shouldApplyDeletedStylesDirectly(nodeName) {
82
+ var shouldApplyStylesDirectly = function shouldApplyStylesDirectly(nodeName) {
73
83
  return nodeName === 'heading' || nodeName === 'blockquote' && !fg('platform_editor_ai_aifc_patch_ga_blockers');
74
84
  };
75
85
 
@@ -121,9 +131,12 @@ var createBlockNodeWrapper = function createBlockNodeWrapper() {
121
131
  };
122
132
 
123
133
  /**
124
- * Applies deleted styles directly to an HTML element by merging with existing styles
134
+ * Applies styles directly to an HTML element by merging with existing styles
125
135
  */
126
- var applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colorScheme) {
136
+ var applyStylesToElement = function applyStylesToElement(_ref) {
137
+ var element = _ref.element,
138
+ targetNode = _ref.targetNode,
139
+ colorScheme = _ref.colorScheme;
127
140
  var currentStyle = element.getAttribute('style') || '';
128
141
  var deletedContentStyle = getDeletedContentStyle(colorScheme);
129
142
  var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colorScheme) || '';
@@ -133,7 +146,10 @@ var applyDeletedStylesToElement = function applyDeletedStylesToElement(element,
133
146
  /**
134
147
  * Creates a content wrapper with deleted styles for a block node
135
148
  */
136
- var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeView, targetNode, colorScheme) {
149
+ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref2) {
150
+ var nodeView = _ref2.nodeView,
151
+ targetNode = _ref2.targetNode,
152
+ colorScheme = _ref2.colorScheme;
137
153
  var contentWrapper = document.createElement('div');
138
154
  var nodeStyle = getDeletedStyleNode(targetNode.type.name, colorScheme);
139
155
  contentWrapper.setAttribute('style', "".concat(getDeletedContentStyle(colorScheme)).concat(nodeStyle || ''));
@@ -147,7 +163,12 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeV
147
163
  * to wait for the rich-media-item to appear before attaching the lozenge.
148
164
  * @returns true if embedCard was handled
149
165
  */
150
- var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) {
166
+ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref3) {
167
+ var dom = _ref3.dom,
168
+ nodeView = _ref3.nodeView,
169
+ targetNode = _ref3.targetNode,
170
+ lozenge = _ref3.lozenge,
171
+ colorScheme = _ref3.colorScheme;
151
172
  if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
152
173
  return false;
153
174
  }
@@ -179,7 +200,12 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeVi
179
200
  * Handles special mediaSingle node rendering with lozenge on child media element
180
201
  * @returns true if mediaSingle was handled, false otherwise
181
202
  */
182
- export var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) {
203
+ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref4) {
204
+ var dom = _ref4.dom,
205
+ nodeView = _ref4.nodeView,
206
+ targetNode = _ref4.targetNode,
207
+ lozenge = _ref4.lozenge,
208
+ colorScheme = _ref4.colorScheme;
183
209
  if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
184
210
  return false;
185
211
  }
@@ -208,19 +234,40 @@ export var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
208
234
  /**
209
235
  * Appends a block node with wrapper, lozenge, and appropriate styling
210
236
  */
211
- var appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl) {
237
+ var wrapBlockNode = function wrapBlockNode(_ref5) {
238
+ var dom = _ref5.dom,
239
+ nodeView = _ref5.nodeView,
240
+ targetNode = _ref5.targetNode,
241
+ colorScheme = _ref5.colorScheme,
242
+ intl = _ref5.intl;
212
243
  var blockWrapper = createBlockNodeWrapper();
213
244
  if (shouldShowRemovedLozenge(targetNode.type.name)) {
214
245
  var lozenge = createRemovedLozenge(intl);
215
- if (handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
246
+ if (handleEmbedCardWithLozenge({
247
+ dom: dom,
248
+ nodeView: nodeView,
249
+ targetNode: targetNode,
250
+ lozenge: lozenge,
251
+ colorScheme: colorScheme
252
+ }) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
216
253
  return;
217
254
  }
218
- if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme)) {
255
+ if (handleMediaSingleWithLozenge({
256
+ dom: dom,
257
+ nodeView: nodeView,
258
+ targetNode: targetNode,
259
+ lozenge: lozenge,
260
+ colorScheme: colorScheme
261
+ })) {
219
262
  return;
220
263
  }
221
264
  blockWrapper.append(lozenge);
222
265
  }
223
- var contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode, colorScheme);
266
+ var contentWrapper = createBlockNodeContentWrapper({
267
+ nodeView: nodeView,
268
+ targetNode: targetNode,
269
+ colorScheme: colorScheme
270
+ });
224
271
  blockWrapper.append(contentWrapper);
225
272
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
226
273
  var showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
@@ -234,13 +281,28 @@ var appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeVi
234
281
  * For heading nodes, applies styles directly to preserve natural margins.
235
282
  * For other block nodes, uses wrapper approach with optional lozenge.
236
283
  */
237
- export var handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode, colorScheme, intl) {
238
- if (shouldApplyDeletedStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
284
+ export var wrapBlockNodeView = function wrapBlockNodeView(_ref6) {
285
+ var dom = _ref6.dom,
286
+ nodeView = _ref6.nodeView,
287
+ targetNode = _ref6.targetNode,
288
+ colorScheme = _ref6.colorScheme,
289
+ intl = _ref6.intl;
290
+ if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
239
291
  // Apply deleted styles directly to preserve natural block-level margins
240
- applyDeletedStylesToElement(nodeView, targetNode, colorScheme);
292
+ applyStylesToElement({
293
+ element: nodeView,
294
+ targetNode: targetNode,
295
+ colorScheme: colorScheme
296
+ });
241
297
  dom.append(nodeView);
242
298
  } else {
243
299
  // Use wrapper approach for other block nodes
244
- appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl);
300
+ wrapBlockNode({
301
+ dom: dom,
302
+ nodeView: nodeView,
303
+ targetNode: targetNode,
304
+ colorScheme: colorScheme,
305
+ intl: intl
306
+ });
245
307
  }
246
308
  };
@@ -67,7 +67,7 @@ export declare class NodeViewSerializer {
67
67
  /**
68
68
  * Serializes a fragment to a `DocumentFragment` using the schema's `DOMSerializer`.
69
69
  */
70
- serializeFragment(fragment: Fragment): HTMLElement | DocumentFragment | null;
70
+ serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement | null;
71
71
  /**
72
72
  * Returns a copy of the current node view blocklist.
73
73
  */
@@ -1,6 +1,7 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import { type EditorState } from '@atlaskit/editor-prosemirror/state';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ import type { ColorScheme } from '../showDiffPluginType';
4
5
  import type { ShowDiffPluginState } from './main';
5
6
  import type { NodeViewSerializer } from './NodeViewSerializer';
6
7
  export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, }: {
@@ -8,7 +9,7 @@ export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<
8
9
  from: number;
9
10
  to: number;
10
11
  };
11
- colorScheme?: "standard" | "traditional";
12
+ colorScheme?: ColorScheme;
12
13
  intl: IntlShape;
13
14
  nodeViewSerializer: NodeViewSerializer;
14
15
  pluginState: Omit<ShowDiffPluginState, "decorations">;
@@ -0,0 +1,16 @@
1
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
+ import type { ColorScheme } from '../../showDiffPluginType';
3
+ /**
4
+ * Inline decoration used for insertions as the content already exists in the document
5
+ *
6
+ * @param change Changeset "change" containing information about the change content + range
7
+ * @returns Prosemirror inline decoration
8
+ */
9
+ export declare const createBlockChangedDecoration: ({ change, colorScheme, }: {
10
+ change: {
11
+ from: number;
12
+ name: string;
13
+ to: number;
14
+ };
15
+ colorScheme?: ColorScheme;
16
+ }) => Decoration | undefined;
@@ -0,0 +1,17 @@
1
+ import type { Change } from 'prosemirror-changeset';
2
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
+ import type { ColorScheme } from '../../showDiffPluginType';
5
+ import type { NodeViewSerializer } from '../NodeViewSerializer';
6
+ type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
7
+ /**
8
+ * Main function to handle deleted rows - computes diff and creates decorations
9
+ */
10
+ export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: {
11
+ changes: SimpleChange[];
12
+ colorScheme?: ColorScheme;
13
+ newDoc: PMNode;
14
+ nodeViewSerializer: NodeViewSerializer;
15
+ originalDoc: PMNode;
16
+ }) => Decoration[];
17
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
+ import type { ColorScheme } from '../../showDiffPluginType';
3
+ /**
4
+ * Inline decoration used for insertions as the content already exists in the document
5
+ *
6
+ * @param change Changeset "change" containing information about the change content + range
7
+ * @returns Prosemirror inline decoration
8
+ */
9
+ export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, }: {
10
+ change: {
11
+ fromB: number;
12
+ toB: number;
13
+ };
14
+ colorScheme?: ColorScheme;
15
+ isActive?: boolean;
16
+ }) => Decoration;
@@ -0,0 +1,15 @@
1
+ import type { Change } from 'prosemirror-changeset';
2
+ import type { IntlShape } from 'react-intl-next';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
+ import type { ColorScheme } from '../../showDiffPluginType';
6
+ import type { NodeViewSerializer } from '../NodeViewSerializer';
7
+ export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, }: {
8
+ change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted">;
9
+ colorScheme?: ColorScheme;
10
+ doc: PMNode;
11
+ intl: IntlShape;
12
+ isActive?: boolean;
13
+ newDoc: PMNode;
14
+ nodeViewSerializer: NodeViewSerializer;
15
+ }) => Decoration[] | undefined;
@@ -0,0 +1,15 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { ColorScheme } from '../../../showDiffPluginType';
4
+ /**
5
+ * Handles all block node rendering with appropriate deleted styling.
6
+ * For heading nodes, applies styles directly to preserve natural margins.
7
+ * For other block nodes, uses wrapper approach with optional lozenge.
8
+ */
9
+ export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, }: {
10
+ colorScheme?: ColorScheme;
11
+ dom: HTMLElement;
12
+ intl: IntlShape;
13
+ nodeView: Node;
14
+ targetNode: PMNode;
15
+ }) => void;
@@ -67,7 +67,7 @@ export declare class NodeViewSerializer {
67
67
  /**
68
68
  * Serializes a fragment to a `DocumentFragment` using the schema's `DOMSerializer`.
69
69
  */
70
- serializeFragment(fragment: Fragment): HTMLElement | DocumentFragment | null;
70
+ serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement | null;
71
71
  /**
72
72
  * Returns a copy of the current node view blocklist.
73
73
  */
@@ -1,6 +1,7 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import { type EditorState } from '@atlaskit/editor-prosemirror/state';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ import type { ColorScheme } from '../showDiffPluginType';
4
5
  import type { ShowDiffPluginState } from './main';
5
6
  import type { NodeViewSerializer } from './NodeViewSerializer';
6
7
  export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, }: {
@@ -8,7 +9,7 @@ export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<
8
9
  from: number;
9
10
  to: number;
10
11
  };
11
- colorScheme?: "standard" | "traditional";
12
+ colorScheme?: ColorScheme;
12
13
  intl: IntlShape;
13
14
  nodeViewSerializer: NodeViewSerializer;
14
15
  pluginState: Omit<ShowDiffPluginState, "decorations">;
@@ -0,0 +1,16 @@
1
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
+ import type { ColorScheme } from '../../showDiffPluginType';
3
+ /**
4
+ * Inline decoration used for insertions as the content already exists in the document
5
+ *
6
+ * @param change Changeset "change" containing information about the change content + range
7
+ * @returns Prosemirror inline decoration
8
+ */
9
+ export declare const createBlockChangedDecoration: ({ change, colorScheme, }: {
10
+ change: {
11
+ from: number;
12
+ name: string;
13
+ to: number;
14
+ };
15
+ colorScheme?: ColorScheme;
16
+ }) => Decoration | undefined;
@@ -0,0 +1,17 @@
1
+ import type { Change } from 'prosemirror-changeset';
2
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
+ import type { ColorScheme } from '../../showDiffPluginType';
5
+ import type { NodeViewSerializer } from '../NodeViewSerializer';
6
+ type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
7
+ /**
8
+ * Main function to handle deleted rows - computes diff and creates decorations
9
+ */
10
+ export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: {
11
+ changes: SimpleChange[];
12
+ colorScheme?: ColorScheme;
13
+ newDoc: PMNode;
14
+ nodeViewSerializer: NodeViewSerializer;
15
+ originalDoc: PMNode;
16
+ }) => Decoration[];
17
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
+ import type { ColorScheme } from '../../showDiffPluginType';
3
+ /**
4
+ * Inline decoration used for insertions as the content already exists in the document
5
+ *
6
+ * @param change Changeset "change" containing information about the change content + range
7
+ * @returns Prosemirror inline decoration
8
+ */
9
+ export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, }: {
10
+ change: {
11
+ fromB: number;
12
+ toB: number;
13
+ };
14
+ colorScheme?: ColorScheme;
15
+ isActive?: boolean;
16
+ }) => Decoration;
@@ -0,0 +1,15 @@
1
+ import type { Change } from 'prosemirror-changeset';
2
+ import type { IntlShape } from 'react-intl-next';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
+ import type { ColorScheme } from '../../showDiffPluginType';
6
+ import type { NodeViewSerializer } from '../NodeViewSerializer';
7
+ export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, }: {
8
+ change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted">;
9
+ colorScheme?: ColorScheme;
10
+ doc: PMNode;
11
+ intl: IntlShape;
12
+ isActive?: boolean;
13
+ newDoc: PMNode;
14
+ nodeViewSerializer: NodeViewSerializer;
15
+ }) => Decoration[] | undefined;
@@ -0,0 +1,15 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { ColorScheme } from '../../../showDiffPluginType';
4
+ /**
5
+ * Handles all block node rendering with appropriate deleted styling.
6
+ * For heading nodes, applies styles directly to preserve natural margins.
7
+ * For other block nodes, uses wrapper approach with optional lozenge.
8
+ */
9
+ export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, }: {
10
+ colorScheme?: ColorScheme;
11
+ dom: HTMLElement;
12
+ intl: IntlShape;
13
+ nodeView: Node;
14
+ targetNode: PMNode;
15
+ }) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
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": "^35.1.0",
35
+ "@atlaskit/tmp-editor-statsig": "^35.4.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.30.0",
43
+ "@atlaskit/editor-common": "^111.31.0",
44
44
  "react": "^18.2.0"
45
45
  },
46
46
  "techstack": {
@@ -1,46 +0,0 @@
1
- import type { Change } from 'prosemirror-changeset';
2
- import type { IntlShape } from 'react-intl-next';
3
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
- import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
- import type { NodeViewSerializer } from './NodeViewSerializer';
6
- /**
7
- * Inline decoration used for insertions as the content already exists in the document
8
- *
9
- * @param change Changeset "change" containing information about the change content + range
10
- * @returns Prosemirror inline decoration
11
- */
12
- export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, }: {
13
- change: {
14
- fromB: number;
15
- toB: number;
16
- };
17
- colorScheme?: "standard" | "traditional";
18
- isActive?: boolean;
19
- }) => Decoration;
20
- export declare const getDeletedContentStyleUnbounded: (colorScheme?: "standard" | "traditional") => string;
21
- export declare const getDeletedContentStyle: (colorScheme?: "standard" | "traditional", isActive?: boolean) => string;
22
- /**
23
- * Inline decoration used for insertions as the content already exists in the document
24
- *
25
- * @param change Changeset "change" containing information about the change content + range
26
- * @returns Prosemirror inline decoration
27
- */
28
- export declare const createBlockChangedDecoration: ({ change, colorScheme, }: {
29
- change: {
30
- from: number;
31
- name: string;
32
- to: number;
33
- };
34
- colorScheme?: "standard" | "traditional";
35
- }) => Decoration | undefined;
36
- interface DeletedContentDecorationProps {
37
- change: Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
38
- colorScheme?: 'standard' | 'traditional';
39
- doc: PMNode;
40
- intl: IntlShape;
41
- isActive?: boolean;
42
- newDoc: PMNode;
43
- nodeViewSerializer: NodeViewSerializer;
44
- }
45
- export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, }: DeletedContentDecorationProps) => Decoration[] | undefined;
46
- export {};
@@ -1,14 +0,0 @@
1
- import type { IntlShape } from 'react-intl-next';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- export declare const getDeletedStyleNode: (nodeName: string, colorScheme?: "standard" | "traditional") => string | undefined;
4
- /**
5
- * Handles special mediaSingle node rendering with lozenge on child media element
6
- * @returns true if mediaSingle was handled, false otherwise
7
- */
8
- export declare const handleMediaSingleWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colorScheme: "standard" | "traditional" | undefined) => boolean;
9
- /**
10
- * Handles all block node rendering with appropriate deleted styling.
11
- * For heading nodes, applies styles directly to preserve natural margins.
12
- * For other block nodes, uses wrapper approach with optional lozenge.
13
- */
14
- export declare const handleBlockNodeView: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
@@ -1,36 +0,0 @@
1
- import type { Change } from 'prosemirror-changeset';
2
- import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
- import type { NodeViewSerializer } from './NodeViewSerializer';
5
- interface DeletedRowInfo {
6
- fromA: number;
7
- fromB: number;
8
- rowIndex: number;
9
- rowNode: PMNode;
10
- toA: number;
11
- }
12
- type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
13
- interface DeletedRowsHandlerProps {
14
- colorScheme?: 'standard' | 'traditional';
15
- deletedRows: DeletedRowInfo[];
16
- newDoc: PMNode;
17
- nodeViewSerializer: NodeViewSerializer;
18
- originalDoc: PMNode;
19
- }
20
- /**
21
- * Creates decorations for deleted table rows
22
- */
23
- export declare const createDeletedRowsDecorations: ({ deletedRows, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: DeletedRowsHandlerProps) => Decoration[];
24
- /**
25
- * Main function to handle deleted rows - computes diff and creates decorations
26
- */
27
- export declare const handleDeletedRows: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: {
28
- changes: SimpleChange[];
29
- colorScheme?: "standard" | "traditional";
30
- newDoc: PMNode;
31
- nodeViewSerializer: NodeViewSerializer;
32
- originalDoc: PMNode;
33
- }) => {
34
- decorations: Decoration[];
35
- };
36
- export {};
@@ -1,46 +0,0 @@
1
- import type { Change } from 'prosemirror-changeset';
2
- import type { IntlShape } from 'react-intl-next';
3
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
- import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
- import type { NodeViewSerializer } from './NodeViewSerializer';
6
- /**
7
- * Inline decoration used for insertions as the content already exists in the document
8
- *
9
- * @param change Changeset "change" containing information about the change content + range
10
- * @returns Prosemirror inline decoration
11
- */
12
- export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, }: {
13
- change: {
14
- fromB: number;
15
- toB: number;
16
- };
17
- colorScheme?: "standard" | "traditional";
18
- isActive?: boolean;
19
- }) => Decoration;
20
- export declare const getDeletedContentStyleUnbounded: (colorScheme?: "standard" | "traditional") => string;
21
- export declare const getDeletedContentStyle: (colorScheme?: "standard" | "traditional", isActive?: boolean) => string;
22
- /**
23
- * Inline decoration used for insertions as the content already exists in the document
24
- *
25
- * @param change Changeset "change" containing information about the change content + range
26
- * @returns Prosemirror inline decoration
27
- */
28
- export declare const createBlockChangedDecoration: ({ change, colorScheme, }: {
29
- change: {
30
- from: number;
31
- name: string;
32
- to: number;
33
- };
34
- colorScheme?: "standard" | "traditional";
35
- }) => Decoration | undefined;
36
- interface DeletedContentDecorationProps {
37
- change: Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
38
- colorScheme?: 'standard' | 'traditional';
39
- doc: PMNode;
40
- intl: IntlShape;
41
- isActive?: boolean;
42
- newDoc: PMNode;
43
- nodeViewSerializer: NodeViewSerializer;
44
- }
45
- export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, }: DeletedContentDecorationProps) => Decoration[] | undefined;
46
- export {};
@@ -1,14 +0,0 @@
1
- import type { IntlShape } from 'react-intl-next';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- export declare const getDeletedStyleNode: (nodeName: string, colorScheme?: "standard" | "traditional") => string | undefined;
4
- /**
5
- * Handles special mediaSingle node rendering with lozenge on child media element
6
- * @returns true if mediaSingle was handled, false otherwise
7
- */
8
- export declare const handleMediaSingleWithLozenge: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, lozenge: HTMLElement, colorScheme: "standard" | "traditional" | undefined) => boolean;
9
- /**
10
- * Handles all block node rendering with appropriate deleted styling.
11
- * For heading nodes, applies styles directly to preserve natural margins.
12
- * For other block nodes, uses wrapper approach with optional lozenge.
13
- */
14
- export declare const handleBlockNodeView: (dom: HTMLElement, nodeView: Node, targetNode: PMNode, colorScheme: "standard" | "traditional" | undefined, intl: IntlShape) => void;
@@ -1,36 +0,0 @@
1
- import type { Change } from 'prosemirror-changeset';
2
- import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
- import type { NodeViewSerializer } from './NodeViewSerializer';
5
- interface DeletedRowInfo {
6
- fromA: number;
7
- fromB: number;
8
- rowIndex: number;
9
- rowNode: PMNode;
10
- toA: number;
11
- }
12
- type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
13
- interface DeletedRowsHandlerProps {
14
- colorScheme?: 'standard' | 'traditional';
15
- deletedRows: DeletedRowInfo[];
16
- newDoc: PMNode;
17
- nodeViewSerializer: NodeViewSerializer;
18
- originalDoc: PMNode;
19
- }
20
- /**
21
- * Creates decorations for deleted table rows
22
- */
23
- export declare const createDeletedRowsDecorations: ({ deletedRows, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: DeletedRowsHandlerProps) => Decoration[];
24
- /**
25
- * Main function to handle deleted rows - computes diff and creates decorations
26
- */
27
- export declare const handleDeletedRows: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: {
28
- changes: SimpleChange[];
29
- colorScheme?: "standard" | "traditional";
30
- newDoc: PMNode;
31
- nodeViewSerializer: NodeViewSerializer;
32
- originalDoc: PMNode;
33
- }) => {
34
- decorations: Decoration[];
35
- };
36
- export {};