@atlaskit/editor-plugin-show-diff 6.2.4 → 6.2.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 (43) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -2
  3. package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +19 -1
  4. package/dist/cjs/pm-plugins/decorations/colorSchemes/traditional.js +18 -2
  5. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -10
  6. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +83 -14
  7. package/dist/cjs/pm-plugins/getScrollableDecorations.js +132 -0
  8. package/dist/cjs/pm-plugins/main.js +12 -25
  9. package/dist/cjs/pm-plugins/scrollToActiveDecoration.js +50 -9
  10. package/dist/cjs/showDiffPlugin.js +2 -1
  11. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -2
  12. package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +18 -0
  13. package/dist/es2019/pm-plugins/decorations/colorSchemes/traditional.js +17 -1
  14. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -9
  15. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +80 -18
  16. package/dist/es2019/pm-plugins/getScrollableDecorations.js +117 -0
  17. package/dist/es2019/pm-plugins/main.js +11 -22
  18. package/dist/es2019/pm-plugins/scrollToActiveDecoration.js +50 -10
  19. package/dist/es2019/showDiffPlugin.js +3 -2
  20. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -2
  21. package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +18 -0
  22. package/dist/esm/pm-plugins/decorations/colorSchemes/traditional.js +17 -1
  23. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -10
  24. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +85 -16
  25. package/dist/esm/pm-plugins/getScrollableDecorations.js +124 -0
  26. package/dist/esm/pm-plugins/main.js +11 -24
  27. package/dist/esm/pm-plugins/scrollToActiveDecoration.js +50 -9
  28. package/dist/esm/showDiffPlugin.js +3 -2
  29. package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +4 -0
  30. package/dist/types/pm-plugins/decorations/colorSchemes/traditional.d.ts +3 -0
  31. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +5 -2
  32. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  33. package/dist/types/pm-plugins/getScrollableDecorations.d.ts +27 -0
  34. package/dist/types/pm-plugins/main.d.ts +0 -2
  35. package/dist/types/pm-plugins/scrollToActiveDecoration.d.ts +4 -2
  36. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +4 -0
  37. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +3 -0
  38. package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +5 -2
  39. package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  40. package/dist/types-ts4.5/pm-plugins/getScrollableDecorations.d.ts +27 -0
  41. package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -2
  42. package/dist/types-ts4.5/pm-plugins/scrollToActiveDecoration.d.ts +4 -2
  43. package/package.json +4 -4
@@ -7,8 +7,12 @@ export declare const deletedContentStyleNewActive: string;
7
7
  export declare const deletedContentStyleUnbounded: string;
8
8
  export declare const deletedStyleQuoteNode: string;
9
9
  export declare const deletedStyleQuoteNodeWithLozenge: string;
10
+ /** Stronger outline when this deleted block decoration is the active scroll target */
11
+ export declare const deletedStyleQuoteNodeWithLozengeActive: string;
10
12
  export declare const deletedBlockOutline: string;
13
+ export declare const deletedBlockOutlineActive: string;
11
14
  export declare const deletedBlockOutlineRounded: string;
15
+ export declare const deletedBlockOutlineRoundedActive: string;
12
16
  export declare const deletedRowStyle: string;
13
17
  export declare const editingStyleQuoteNode: string;
14
18
  export declare const editingStyleRuleNode: string;
@@ -7,8 +7,11 @@ export declare const deletedTraditionalContentStyleUnbounded: string;
7
7
  /** Emphasised (pressed) strikethrough line for traditional when active */
8
8
  export declare const deletedTraditionalContentStyleUnboundedActive: string;
9
9
  export declare const deletedTraditionalStyleQuoteNode: string;
10
+ export declare const deletedTraditionalStyleQuoteNodeActive: string;
10
11
  export declare const deletedTraditionalBlockOutline: string;
12
+ export declare const deletedTraditionalBlockOutlineActive: string;
11
13
  export declare const deletedTraditionalBlockOutlineRounded: string;
14
+ export declare const deletedTraditionalBlockOutlineRoundedActive: string;
12
15
  export declare const deletedTraditionalRowStyle: string;
13
16
  export declare const traditionalStyleQuoteNode: string;
14
17
  export declare const traditionalStyleQuoteNodeActive: string;
@@ -8,12 +8,15 @@ 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, isActive, isInserted, }: {
11
+ export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, }: {
12
+ activeIndexPos?: {
13
+ from: number;
14
+ to: number;
15
+ };
12
16
  change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted" | "toB">;
13
17
  colorScheme?: ColorScheme;
14
18
  doc: PMNode;
15
19
  intl: IntlShape;
16
- isActive?: boolean;
17
20
  isInserted?: boolean;
18
21
  newDoc: PMNode;
19
22
  nodeViewSerializer: NodeViewSerializer;
@@ -6,10 +6,11 @@ import type { ColorScheme } 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, isInserted, }: {
9
+ export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isActive, isInserted, }: {
10
10
  colorScheme?: ColorScheme;
11
11
  dom: HTMLElement;
12
12
  intl: IntlShape;
13
+ isActive?: boolean;
13
14
  isInserted: boolean;
14
15
  nodeView: Node;
15
16
  targetNode: PMNode;
@@ -0,0 +1,27 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ /**
4
+ * Returns true when an inline decoration's [from, to) range can actually show in the document:
5
+ * positions are valid, and the slice contains at least one inline node ProseMirror would paint
6
+ * (not only empty block wrappers or block-only structure).
7
+ */
8
+ export declare function isInlineDiffDecorationRenderableInDoc(doc: PMNode, from: number, to: number): boolean;
9
+ /**
10
+ * Gets scrollable decorations from a DecorationSet, filtering out overlapping decorations
11
+ * and applying various rules for diff visualization.
12
+ *
13
+ * Rules:
14
+ * 1. Only includes diff-inline, diff-widget-* and diff-block decorations
15
+ * 2. Excludes listItem diff-block decorations (never scrollable)
16
+ * 3. Deduplicates diff-block decorations with same from, to and nodeName
17
+ * 4. When `doc` is passed: excludes diff-inline decorations whose range has no inline content
18
+ * (invalid positions, or block-only slices with no text/atoms — e.g. empty blocks)
19
+ * 5. Excludes diff-inline decorations that are fully contained within a diff-block
20
+ * 6. Excludes diff-block decorations that are fully contained within a diff-inline
21
+ * 7. Results are sorted by from position, then by to position
22
+ *
23
+ * @param set - The DecorationSet to extract scrollable decorations from
24
+ * @param doc - Current document; when set, diff-inline ranges are validated against this doc
25
+ * @returns Array of scrollable decorations, sorted and deduplicated
26
+ */
27
+ export declare const getScrollableDecorations: (set: DecorationSet | undefined, doc?: PMNode) => Decoration[];
@@ -4,7 +4,6 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
7
- import type { Decoration } from '@atlaskit/editor-prosemirror/view';
8
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
8
  import { type DiffParams, type DiffType, type ShowDiffPlugin } from '../showDiffPluginType';
10
9
  export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
@@ -21,5 +20,4 @@ export type ShowDiffPluginState = {
21
20
  originalDoc: PMNode | undefined;
22
21
  steps: ProseMirrorStep[];
23
22
  };
24
- export declare const getScrollableDecorations: (set: DecorationSet | undefined) => Decoration[];
25
23
  export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined) => SafePlugin<ShowDiffPluginState>;
@@ -1,5 +1,7 @@
1
1
  import type { EditorView, Decoration } from '@atlaskit/editor-prosemirror/view';
2
2
  /**
3
- * Scrolls the editor view to the decoration at the given index.
3
+ * Schedules scrolling to the decoration at the given index after the next frame.
4
+ *
5
+ * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
4
6
  */
5
- export declare const scrollToActiveDecoration: (view: EditorView, decorations: Decoration[], activeIndex: number) => void;
7
+ export declare const scrollToActiveDecoration: (view: EditorView, decorations: Decoration[], activeIndex: number) => (() => void);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "6.2.4",
3
+ "version": "6.2.6",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,8 +34,8 @@
34
34
  "@atlaskit/editor-prosemirror": "^7.3.0",
35
35
  "@atlaskit/editor-tables": "^2.9.0",
36
36
  "@atlaskit/platform-feature-flags": "^1.1.0",
37
- "@atlaskit/tmp-editor-statsig": "^48.0.0",
38
- "@atlaskit/tokens": "^11.3.0",
37
+ "@atlaskit/tmp-editor-statsig": "^50.0.0",
38
+ "@atlaskit/tokens": "^11.4.0",
39
39
  "@babel/runtime": "^7.0.0",
40
40
  "lodash": "^4.17.21",
41
41
  "memoize-one": "^6.0.0",
@@ -46,7 +46,7 @@
46
46
  "@atlassian/content-reconciliation": "^0.1.3506"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^112.11.0",
49
+ "@atlaskit/editor-common": "^112.13.0",
50
50
  "react": "^18.2.0"
51
51
  },
52
52
  "techstack": {