@atlaskit/editor-plugin-show-diff 10.3.0 → 10.4.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 (27) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +14 -3
  3. package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +19 -1
  4. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +4 -2
  5. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -2
  6. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +40 -21
  7. package/dist/cjs/pm-plugins/main.js +11 -7
  8. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +13 -3
  9. package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +18 -0
  10. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +4 -3
  11. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +4 -2
  12. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +35 -25
  13. package/dist/es2019/pm-plugins/main.js +11 -7
  14. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +14 -3
  15. package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +18 -0
  16. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +5 -3
  17. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -2
  18. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +41 -22
  19. package/dist/esm/pm-plugins/main.js +11 -7
  20. package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
  21. package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +9 -0
  22. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  23. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -1
  24. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  25. package/dist/types/pm-plugins/main.d.ts +1 -0
  26. package/dist/types/showDiffPluginType.d.ts +12 -5
  27. package/package.json +5 -5
@@ -35,6 +35,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
35
35
  isInverted: false,
36
36
  diffType: 'inline',
37
37
  hideDeletedDiffs: false,
38
+ hideAddedDiffsUnderline: false,
38
39
  showIndicators: false,
39
40
  diffDescriptors: []
40
41
  } : {});
@@ -44,7 +45,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
44
45
  var newPluginState = currentPluginState;
45
46
  if (meta) {
46
47
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
47
- var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8;
48
+ var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9;
48
49
  // Update the plugin state with the new metadata
49
50
  newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
50
51
  isDisplayingChanges: true,
@@ -63,15 +64,16 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
63
64
  isInverted: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.isInverted,
64
65
  diffType: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.diffType,
65
66
  hideDeletedDiffs: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.hideDeletedDiffs,
66
- showIndicators: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.showIndicators,
67
- smartThresholds: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.smartThresholds,
68
- deletedDiffPlacement: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.deletedDiffPlacement
67
+ hideAddedDiffsUnderline: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideAddedDiffsUnderline,
68
+ showIndicators: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.showIndicators,
69
+ smartThresholds: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.smartThresholds,
70
+ deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement
69
71
  } : {})),
70
72
  decorations = _calculateDiffDecorat.decorations,
71
73
  diffDescriptors = _calculateDiffDecorat.diffDescriptors;
72
74
  // Update the decorations and their ids
73
75
  newPluginState.decorations = decorations;
74
- if (isExtendedEnabled((_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.diffType)) {
76
+ if (isExtendedEnabled((_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType)) {
75
77
  newPluginState.diffDescriptors = diffDescriptors;
76
78
  }
77
79
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
@@ -83,12 +85,13 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
83
85
  isInverted: false,
84
86
  diffType: 'inline',
85
87
  hideDeletedDiffs: false,
88
+ hideAddedDiffsUnderline: false,
86
89
  diffDescriptors: []
87
90
  } : {});
88
91
  } 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') {
89
- var _newPluginState9;
92
+ var _newPluginState0;
90
93
  // Update the active index in plugin state and recalculate decorations
91
- var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType);
94
+ var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType);
92
95
  if (_decorations.length > 0) {
93
96
  var _currentPluginState$a;
94
97
  // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
@@ -126,6 +129,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
126
129
  isInverted: newPluginState.isInverted,
127
130
  diffType: newPluginState.diffType,
128
131
  hideDeletedDiffs: newPluginState.hideDeletedDiffs,
132
+ hideAddedDiffsUnderline: newPluginState.hideAddedDiffsUnderline,
129
133
  showIndicators: newPluginState.showIndicators,
130
134
  smartThresholds: newPluginState.smartThresholds,
131
135
  deletedDiffPlacement: newPluginState.deletedDiffPlacement
@@ -10,7 +10,7 @@ type CalculatedDiffs = {
10
10
  decorations: DecorationSet;
11
11
  diffDescriptors: DiffDescriptor[];
12
12
  };
13
- export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, showIndicators, }: {
13
+ export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, hideAddedDiffsUnderline, showIndicators, }: {
14
14
  activeIndexPos?: {
15
15
  from: number;
16
16
  to: number;
@@ -18,6 +18,7 @@ export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState,
18
18
  api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
19
19
  colorScheme?: ColorScheme;
20
20
  deletedDiffPlacement?: DeletedDiffPlacement;
21
+ hideAddedDiffsUnderline?: boolean;
21
22
  hideDeletedDiffs?: boolean;
22
23
  intl: IntlShape;
23
24
  nodeViewSerializer: NodeViewSerializer;
@@ -4,6 +4,15 @@ export declare const editingStyleActive: string;
4
4
  export declare const editingStyleExtended: string;
5
5
  export declare const editingContentStyleInBlockExtended: string;
6
6
  export declare const editingStyleActiveExtended: string;
7
+ /**
8
+ * Underline-free variants of the extended inserted-content styles. Used when the `showDiff`
9
+ * command is called with `hideAddedDiffsUnderline: true` to remove ONLY the dark-purple
10
+ * `borderBottom` underline from added/updated content while keeping the purple background
11
+ * highlight and padding. See the `editing*Extended` constants above for the full versions.
12
+ */
13
+ export declare const editingStyleExtendedNoUnderline: string;
14
+ export declare const editingStyleActiveExtendedNoUnderline: string;
15
+ export declare const editingContentStyleInBlockExtendedNoUnderline: string;
7
16
  export declare const deletedContentStyle: string;
8
17
  export declare const deletedContentStyleActive: string;
9
18
  export declare const deletedContentStyleNew: string;
@@ -7,7 +7,7 @@ import type { ColorScheme, DiffType } from '../../showDiffPluginType';
7
7
  * @param change Changeset "change" containing information about the change content + range
8
8
  * @returns Prosemirror inline decoration
9
9
  */
10
- export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, showIndicators, doc, diffType, }: {
10
+ export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, showIndicators, doc, diffType, hideAddedDiffsUnderline, }: {
11
11
  change: {
12
12
  fromB: number;
13
13
  toB: number;
@@ -15,6 +15,7 @@ export declare const createInlineChangedDecoration: ({ change, colorScheme, isAc
15
15
  colorScheme?: ColorScheme;
16
16
  diffType?: DiffType;
17
17
  doc?: PMNode;
18
+ hideAddedDiffsUnderline?: boolean;
18
19
  isActive?: boolean;
19
20
  isInserted?: boolean;
20
21
  shouldHideDeleted?: boolean;
@@ -8,7 +8,7 @@ import type { NodeViewSerializer } from '../NodeViewSerializer';
8
8
  * This function is used to create a decoration widget to show content
9
9
  * that is not in the current document.
10
10
  */
11
- export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showIndicators, placeBelow, diffType, }: {
11
+ export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showIndicators, placeBelow, diffType, hideAddedDiffsUnderline, }: {
12
12
  activeIndexPos?: {
13
13
  from: number;
14
14
  to: number;
@@ -17,6 +17,7 @@ export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeView
17
17
  colorScheme?: ColorScheme;
18
18
  diffType?: DiffType;
19
19
  doc: PMNode;
20
+ hideAddedDiffsUnderline?: boolean;
20
21
  intl: IntlShape;
21
22
  isInserted?: boolean;
22
23
  newDoc: PMNode;
@@ -6,10 +6,11 @@ import type { ColorScheme, DiffType } from '../../../showDiffPluginType';
6
6
  * For heading nodes, applies styles directly to preserve natural margins.
7
7
  * For other block nodes, uses wrapper approach with optional lozenge.
8
8
  */
9
- export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isActive, isInserted, diffType, }: {
9
+ export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isActive, isInserted, diffType, hideAddedDiffsUnderline, }: {
10
10
  colorScheme?: ColorScheme;
11
11
  diffType?: DiffType;
12
12
  dom: HTMLElement;
13
+ hideAddedDiffsUnderline?: boolean;
13
14
  intl: IntlShape;
14
15
  isActive?: boolean;
15
16
  isInserted: boolean;
@@ -26,6 +26,7 @@ export type ShowDiffPluginState = {
26
26
  diffDescriptors?: DiffDescriptor[];
27
27
  diffType?: DiffType;
28
28
  hideDeletedDiffs?: boolean;
29
+ hideAddedDiffsUnderline?: boolean;
29
30
  isDisplayingChanges: boolean;
30
31
  isInverted?: boolean;
31
32
  originalDoc: PMNode | undefined;
@@ -41,14 +41,16 @@ export type PMDiffParams = {
41
41
  */
42
42
  deletedDiffPlacement?: DeletedDiffPlacement;
43
43
  diffType?: DiffType;
44
+ /**
45
+ * When true, removes only the dark-purple underline (`border-bottom`) from added/updated
46
+ * (inserted) diff content, keeping the purple background highlight and all other styling.
47
+ * Only affects the extended (`smart`) styles. Defaults to `false`, and is a no-op unless the
48
+ * relevant gate is enabled.
49
+ */
50
+ hideAddedDiffsUnderline?: boolean;
44
51
  hideDeletedDiffs?: boolean;
45
52
  isInverted?: boolean;
46
53
  originalDoc: Node;
47
- /**
48
- * Optional overrides for the `smart` diffType density thresholds. Ignored for other
49
- * diff types. Partial — omitted fields fall back to defaults.
50
- */
51
- smartThresholds?: Partial<SmartDiffThresholds>;
52
54
  /**
53
55
  * When true, the editor will scroll to bring the first diff decoration into view
54
56
  * after the diff is shown.
@@ -58,6 +60,11 @@ export type PMDiffParams = {
58
60
  * Whether to show indicators at the doc margin for the diffs.
59
61
  */
60
62
  showIndicators?: boolean;
63
+ /**
64
+ * Optional overrides for the `smart` diffType density thresholds. Ignored for other
65
+ * diff types. Partial — omitted fields fall back to defaults.
66
+ */
67
+ smartThresholds?: Partial<SmartDiffThresholds>;
61
68
  /**
62
69
  * Prosemirror steps. This is used to calculate and show the diff in the editor
63
70
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "10.3.0",
3
+ "version": "10.4.0",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  "@atlaskit/editor-tables": "^3.0.0",
30
30
  "@atlaskit/platform-feature-flags": "^2.0.0",
31
31
  "@atlaskit/tmp-editor-statsig": "^124.1.0",
32
- "@atlaskit/tokens": "^15.5.0",
32
+ "@atlaskit/tokens": "^15.6.0",
33
33
  "@babel/runtime": "^7.0.0",
34
34
  "@compiled/react": "^0.20.0",
35
35
  "lodash": "^4.17.21",
@@ -41,10 +41,10 @@
41
41
  "@atlaskit/button": "^24.3.0",
42
42
  "@atlaskit/css": "^1.0.0",
43
43
  "@atlaskit/dropdown-menu": "^17.1.0",
44
- "@atlaskit/editor-core": "^221.7.0",
44
+ "@atlaskit/editor-core": "^221.8.0",
45
45
  "@atlaskit/editor-json-transformer": "^9.0.0",
46
46
  "@atlaskit/form": "^16.1.0",
47
- "@atlaskit/primitives": "^20.5.0",
47
+ "@atlaskit/primitives": "^20.6.0",
48
48
  "@atlaskit/section-message": "^9.2.0",
49
49
  "@atlaskit/textarea": "^9.1.0",
50
50
  "@atlassian/confluence-presets": "workspace:^",
@@ -54,7 +54,7 @@
54
54
  "react-intl": "^7.0.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "@atlaskit/editor-common": "^116.24.0",
57
+ "@atlaskit/editor-common": "^116.25.0",
58
58
  "react": "^18.2.0"
59
59
  },
60
60
  "techstack": {