@atlaskit/editor-plugin-show-diff 9.1.0 → 9.1.2

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 (34) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +7 -1
  3. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +7 -1
  4. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +7 -1
  5. package/package.json +2 -2
  6. package/show-diff-plugin/package.json +1 -8
  7. package/show-diff-plugin-type/package.json +1 -8
  8. package/dist/types-ts4.5/entry-points/show-diff-plugin-type.d.ts +0 -1
  9. package/dist/types-ts4.5/entry-points/show-diff-plugin.d.ts +0 -1
  10. package/dist/types-ts4.5/index.d.ts +0 -2
  11. package/dist/types-ts4.5/pm-plugins/NodeViewSerializer.d.ts +0 -80
  12. package/dist/types-ts4.5/pm-plugins/areDocsEqualByBlockStructureAndText.d.ts +0 -12
  13. package/dist/types-ts4.5/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +0 -21
  14. package/dist/types-ts4.5/pm-plugins/calculateDiff/diffBySteps.d.ts +0 -4
  15. package/dist/types-ts4.5/pm-plugins/calculateDiff/groupChangesByBlock.d.ts +0 -7
  16. package/dist/types-ts4.5/pm-plugins/calculateDiff/optimizeChanges.d.ts +0 -6
  17. package/dist/types-ts4.5/pm-plugins/calculateDiff/simplifySteps.d.ts +0 -3
  18. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +0 -30
  19. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +0 -39
  20. package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +0 -21
  21. package/dist/types-ts4.5/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +0 -18
  22. package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +0 -18
  23. package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +0 -23
  24. package/dist/types-ts4.5/pm-plugins/decorations/decorationKeys.d.ts +0 -23
  25. package/dist/types-ts4.5/pm-plugins/decorations/utils/findSafeInsertPos.d.ts +0 -9
  26. package/dist/types-ts4.5/pm-plugins/decorations/utils/getAttrChangeRanges.d.ts +0 -19
  27. package/dist/types-ts4.5/pm-plugins/decorations/utils/getMarkChangeRanges.d.ts +0 -7
  28. package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +0 -17
  29. package/dist/types-ts4.5/pm-plugins/enforceCustomStepRegisters.d.ts +0 -1
  30. package/dist/types-ts4.5/pm-plugins/getScrollableDecorations.d.ts +0 -27
  31. package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -29
  32. package/dist/types-ts4.5/pm-plugins/scrollToDiff.d.ts +0 -15
  33. package/dist/types-ts4.5/showDiffPlugin.d.ts +0 -2
  34. package/dist/types-ts4.5/showDiffPluginType.d.ts +0 -68
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 9.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 9.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`3cd3edf123888`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3cd3edf123888) -
14
+ Remove purple underline from block widget containers when diffs are inverted with extended
15
+ experiment enabled
16
+ - Updated dependencies
17
+
3
18
  ## 9.1.0
4
19
 
5
20
  ### Minor Changes
@@ -299,7 +299,13 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6
299
299
  var contentWrapper = document.createElement('div');
300
300
  var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
301
301
  var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
302
- contentWrapper.setAttribute('style', "".concat(getChangedContentStyle(colorScheme, isActive, isInserted)).concat(nodeStyle || ''));
302
+
303
+ // When the extended experiment is enabled and the content is inserted,
304
+ // block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
305
+ // should not also get the inline content style (borderBottom underline) on their container.
306
+ var shouldSkipContentStyle = (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted && nodeStyle !== undefined;
307
+ var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
308
+ contentWrapper.setAttribute('style', "".concat(contentStyle).concat(nodeStyle || ''));
303
309
  contentWrapper.append(nodeView);
304
310
  return contentWrapper;
305
311
  };
@@ -292,7 +292,13 @@ const createBlockNodeContentWrapper = ({
292
292
  const contentWrapper = document.createElement('div');
293
293
  const targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
294
294
  const nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
295
- contentWrapper.setAttribute('style', `${getChangedContentStyle(colorScheme, isActive, isInserted)}${nodeStyle || ''}`);
295
+
296
+ // When the extended experiment is enabled and the content is inserted,
297
+ // block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
298
+ // should not also get the inline content style (borderBottom underline) on their container.
299
+ const shouldSkipContentStyle = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted && nodeStyle !== undefined;
300
+ const contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
301
+ contentWrapper.setAttribute('style', `${contentStyle}${nodeStyle || ''}`);
296
302
  contentWrapper.append(nodeView);
297
303
  return contentWrapper;
298
304
  };
@@ -293,7 +293,13 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6
293
293
  var contentWrapper = document.createElement('div');
294
294
  var targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
295
295
  var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
296
- contentWrapper.setAttribute('style', "".concat(getChangedContentStyle(colorScheme, isActive, isInserted)).concat(nodeStyle || ''));
296
+
297
+ // When the extended experiment is enabled and the content is inserted,
298
+ // block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
299
+ // should not also get the inline content style (borderBottom underline) on their container.
300
+ var shouldSkipContentStyle = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted && nodeStyle !== undefined;
301
+ var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
302
+ contentWrapper.setAttribute('style', "".concat(contentStyle).concat(nodeStyle || ''));
297
303
  contentWrapper.append(nodeView);
298
304
  return contentWrapper;
299
305
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "9.1.0",
3
+ "version": "9.1.2",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,7 +36,7 @@
36
36
  "@atlaskit/editor-prosemirror": "^7.3.0",
37
37
  "@atlaskit/editor-tables": "^2.10.0",
38
38
  "@atlaskit/platform-feature-flags": "^1.1.0",
39
- "@atlaskit/tmp-editor-statsig": "^101.0.0",
39
+ "@atlaskit/tmp-editor-statsig": "^103.0.0",
40
40
  "@atlaskit/tokens": "^13.4.0",
41
41
  "@babel/runtime": "^7.0.0",
42
42
  "lodash": "^4.17.21",
@@ -4,12 +4,5 @@
4
4
  "module": "../dist/esm/entry-points/show-diff-plugin.js",
5
5
  "module:es2019": "../dist/es2019/entry-points/show-diff-plugin.js",
6
6
  "sideEffects": false,
7
- "types": "../dist/types/entry-points/show-diff-plugin.d.ts",
8
- "typesVersions": {
9
- ">=4.5 <5.9": {
10
- "*": [
11
- "../dist/types-ts4.5/entry-points/show-diff-plugin.d.ts"
12
- ]
13
- }
14
- }
7
+ "types": "../dist/types/entry-points/show-diff-plugin.d.ts"
15
8
  }
@@ -4,12 +4,5 @@
4
4
  "module": "../dist/esm/entry-points/show-diff-plugin-type.js",
5
5
  "module:es2019": "../dist/es2019/entry-points/show-diff-plugin-type.js",
6
6
  "sideEffects": false,
7
- "types": "../dist/types/entry-points/show-diff-plugin-type.d.ts",
8
- "typesVersions": {
9
- ">=4.5 <5.9": {
10
- "*": [
11
- "../dist/types-ts4.5/entry-points/show-diff-plugin-type.d.ts"
12
- ]
13
- }
14
- }
7
+ "types": "../dist/types/entry-points/show-diff-plugin-type.d.ts"
15
8
  }
@@ -1 +0,0 @@
1
- export type { DiffParams, PMDiffParams, ShowDiffPlugin } from '../showDiffPluginType';
@@ -1 +0,0 @@
1
- export { showDiffPlugin } from '../showDiffPlugin';
@@ -1,2 +0,0 @@
1
- export { showDiffPlugin } from './showDiffPlugin';
2
- export type { DiffParams, PMDiffParams, ShowDiffPlugin } from './showDiffPluginType';
@@ -1,80 +0,0 @@
1
- import type { NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
2
- import type { Node as PMNode, Fragment } from '@atlaskit/editor-prosemirror/model';
3
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- /**
5
- * Utilities for working with ProseMirror node views and DOM serialization within the
6
- * Show Diff editor plugin.
7
- *
8
- * This module centralizes:
9
- * - Access to the editor's `nodeViews` registry (when available on `EditorView`)
10
- * - Safe attempts to instantiate a node view for a given node, with a blocklist to
11
- * avoid node types that are known to be problematic in this context (e.g. tables)
12
- * - Schema-driven serialization of nodes and fragments to DOM via `DOMSerializer`
13
- *
14
- * The Show Diff decorations leverage this to either render nodes using their
15
- * corresponding node view implementation, or fall back to DOM serialization.
16
- */
17
- /**
18
- * Narrowed `EditorView` that exposes the internal `nodeViews` registry.
19
- * Many editor instances provide this, but it's not part of the base type.
20
- */
21
- export interface EditorViewWithNodeViews extends EditorView {
22
- nodeViews: Record<string, NodeViewConstructor>;
23
- }
24
- /**
25
- * Type guard to detect whether an `EditorView` exposes a `nodeViews` map.
26
- */
27
- export declare function isEditorViewWithNodeViews(view: EditorView): view is EditorViewWithNodeViews;
28
- /**
29
- * Encapsulates DOM serialization and node view access/creation.
30
- *
31
- * Responsible for:
32
- * - Creating a `DOMSerializer` from the provided schema
33
- * - Reading `nodeViews` from an `EditorView` (if present) or using an explicit mapping
34
- * - Preventing node view creation for blocklisted node types
35
- */
36
- export declare class NodeViewSerializer {
37
- private editorView?;
38
- private serializer?;
39
- private nodeViews?;
40
- private nodeViewBlocklist;
41
- constructor(params: {
42
- blocklist?: string[];
43
- editorView?: EditorView;
44
- });
45
- /**
46
- * Initializes or reinitializes the NodeViewSerializer with a new EditorView.
47
- * This allows the same serializer instance to be reused across different editor states.
48
- */
49
- init(params: {
50
- editorView: EditorView;
51
- }): void;
52
- /**
53
- * Appends serialized child nodes to the given contentDOM element.
54
- */
55
- private appendChildNodes;
56
- /**
57
- * Attempts to create a node view for the given node.
58
- *
59
- * Returns `null` when there is no `EditorView`, no constructor for the node type,
60
- * or the node type is blocklisted. Otherwise returns the constructed node view instance.
61
- */
62
- tryCreateNodeView(targetNode: PMNode): Node | null;
63
- /**
64
- * Serializes a node to a DOM `Node` using the schema's `DOMSerializer`.
65
- */
66
- serializeNode(node: PMNode): Node | null;
67
- /**
68
- * Serializes a fragment to a `DocumentFragment` using the schema's `DOMSerializer`.
69
- */
70
- serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement | null;
71
- /**
72
- * Returns a copy of the current node view blocklist.
73
- */
74
- getNodeViewBlocklist(): Set<string>;
75
- /**
76
- * Returns a filtered copy of the node view blocklist, excluding specified node types.
77
- * @param excludeTypes - Array of node type names to exclude from the blocklist
78
- */
79
- getFilteredNodeViewBlocklist(excludeTypes: string[]): Set<string>;
80
- }
@@ -1,12 +0,0 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- /**
3
- * Looser equality for "safe diff" cases: same full text content and same block structure
4
- * (e.g. text moved across text-node boundaries). Used when strict areNodesEqualIgnoreAttrs fails.
5
- * This is safe because we ensure decorations get applied to valid positions.
6
- *
7
- * Marks are intentionally ignored — two documents that differ only in mark application
8
- * (e.g. bold/italic boundaries or annotation mark ordering) are considered equal here.
9
- * Both documents are mark-stripped before comparison so that mark-driven text fragmentation
10
- * does not produce false inequalities.
11
- */
12
- export declare function areDocsEqualByBlockStructureAndText(doc1: PMNode, doc2: PMNode): boolean;
@@ -1,21 +0,0 @@
1
- import { type MemoizedFn } from 'memoize-one';
2
- import type { IntlShape } from 'react-intl';
3
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
- import type { ColorScheme, ShowDiffPlugin } from '../../showDiffPluginType';
7
- import type { ShowDiffPluginState } from '../main';
8
- import type { NodeViewSerializer } from '../NodeViewSerializer';
9
- export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, }: {
10
- activeIndexPos?: {
11
- from: number;
12
- to: number;
13
- };
14
- api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
15
- colorScheme?: ColorScheme;
16
- hideDeletedDiffs?: boolean;
17
- intl: IntlShape;
18
- nodeViewSerializer: NodeViewSerializer;
19
- pluginState: Omit<ShowDiffPluginState, 'decorations'>;
20
- state: EditorState;
21
- }) => DecorationSet>;
@@ -1,4 +0,0 @@
1
- import { type Change } from 'prosemirror-changeset';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { Step } from '@atlaskit/editor-prosemirror/transform';
4
- export declare const diffBySteps: (originalDoc: PMNode, steps: Step[]) => Change[];
@@ -1,7 +0,0 @@
1
- import type { Change } from 'prosemirror-changeset';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- /**
4
- * Groups all changes that fall within the same top-level block (direct child of doc)
5
- * and merges them into a single change spanning the full block in both old and new doc.
6
- */
7
- export declare function groupChangesByBlock(changes: readonly Change[], docA: PMNode, docB: PMNode): Change[];
@@ -1,6 +0,0 @@
1
- import type { Change } from 'prosemirror-changeset';
2
- /**
3
- * Groups adjacent changes to reduce visual fragmentation in diffs.
4
- * Merges consecutive insertions and deletions that are close together.
5
- */
6
- export declare function optimizeChanges(changes: Change[]): Change[];
@@ -1,3 +0,0 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
3
- export declare function simplifySteps(steps: ProseMirrorStep[], originalDoc: PMNode): ProseMirrorStep[];
@@ -1,30 +0,0 @@
1
- export declare const editingStyle: string;
2
- export declare const editingContentStyleInBlock: string;
3
- export declare const editingStyleActive: string;
4
- export declare const editingStyleExtended: string;
5
- export declare const editingContentStyleInBlockExtended: string;
6
- export declare const editingStyleActiveExtended: string;
7
- export declare const deletedContentStyle: string;
8
- export declare const deletedContentStyleActive: string;
9
- export declare const deletedContentStyleNew: string;
10
- /**
11
- * Merge into existing styles when cleaning up
12
- */
13
- export declare const deletedInlineContentStyleExtended: string;
14
- export declare const deletedContentStyleUnbounded: string;
15
- export declare const deletedStyleQuoteNode: string;
16
- export declare const deletedStyleQuoteNodeWithLozenge: string;
17
- /** Stronger outline when this deleted block decoration is the active scroll target */
18
- export declare const deletedStyleQuoteNodeWithLozengeActive: string;
19
- export declare const deletedBlockOutline: string;
20
- export declare const deletedBlockOutlineActive: string;
21
- export declare const deletedBlockOutlineRounded: string;
22
- export declare const deletedBlockOutlineRoundedActive: string;
23
- export declare const deletedRowStyle: string;
24
- export declare const editingStyleQuoteNode: string;
25
- export declare const editingStyleRuleNode: string;
26
- export declare const editingStyleNode: string;
27
- export declare const editingStyleCardBlockNode: string;
28
- export declare const standardDecorationMarkerVariable: string;
29
- export declare const addedCellOverlayStyle: string;
30
- export declare const deletedCellOverlayStyle: string;
@@ -1,39 +0,0 @@
1
- export declare const traditionalInsertStyle: string;
2
- export declare const traditionalInsertStyleActive: string;
3
- /** Strikethrough for traditional removed inline / widget content (non-marker decorations). */
4
- export declare function getDeletedTraditionalInlineStyle(isActive: boolean): string;
5
- export declare const deletedTraditionalContentStyleUnbounded: string;
6
- /** Strikethrough line for traditional when active (background highlight on text wrapper) */
7
- export declare const deletedTraditionalContentStyleUnboundedActive: string;
8
- export declare const deletedTraditionalStyleQuoteNode: string;
9
- export declare const deletedTraditionalStyleQuoteNodeActive: string;
10
- export declare const deletedTraditionalBlockOutline: string;
11
- export declare const deletedTraditionalBlockOutlineActive: string;
12
- export declare const deletedTraditionalBlockOutlineRounded: string;
13
- export declare const deletedTraditionalBlockOutlineRoundedActive: string;
14
- /** Scroll-navigation “new” emphasis: 4px ring (see {@link traditionalStyleNodeNew}). */
15
- export declare const deletedTraditionalBlockOutlineNew: string;
16
- export declare const deletedTraditionalBlockOutlineRoundedNew: string;
17
- export declare const deletedTraditionalRowStyle: string;
18
- export declare const traditionalStyleQuoteNode: string;
19
- export declare const traditionalStyleQuoteNodeNew: string;
20
- export declare const traditionalStyleQuoteNodeActive: string;
21
- export declare const traditionalStyleRuleNode: string;
22
- export declare const traditionalStyleRuleNodeNew: string;
23
- export declare const traditionalStyleRuleNodeActive: string;
24
- export declare const traditionalStyleNode: string;
25
- export declare const traditionalStyleNodeNew: string;
26
- export declare const traditionalStyleNodeActive: string;
27
- export declare const traditionalStyleCardBlockNode: string;
28
- export declare const traditionalStyleCardBlockNodeNew: string;
29
- export declare const traditionalStyleCardBlockNodeActive: string;
30
- export declare const traditionalDecorationMarkerVariable: string;
31
- export declare const traditionalDecorationMarkerVariableNew: string;
32
- export declare const traditionalDecorationMarkerVariableActive: string;
33
- /** Inline deleted traditional styling plus diff marker CSS variables (extension / embedCard / listItem). */
34
- export declare const traditionalDeletedDecorationMarkerVariable: string;
35
- export declare const traditionalDeletedDecorationMarkerVariableNew: string;
36
- export declare const traditionalDeletedDecorationMarkerVariableActive: string;
37
- export declare const traditionalAddedCellOverlayStyle: string;
38
- export declare const traditionalAddedCellOverlayStyleNew: string;
39
- export declare const deletedTraditionalCellOverlayStyle: string;
@@ -1,21 +0,0 @@
1
- import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
- import type { ColorScheme } from '../../showDiffPluginType';
3
- /**
4
- * Node decoration used for block-level insertions. When isActive, uses emphasised (pressed) styling.
5
- *
6
- * @param change Node range and name
7
- * @param colorScheme Optional color scheme
8
- * @param isActive Whether this node is part of the currently active/focused change
9
- * @returns Prosemirror node decoration or undefined
10
- */
11
- export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, }: {
12
- change: {
13
- from: number;
14
- name: string;
15
- to: number;
16
- };
17
- colorScheme?: ColorScheme;
18
- isActive?: boolean;
19
- isInserted?: boolean;
20
- shouldHideDeleted?: boolean;
21
- }) => Decoration[];
@@ -1,18 +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 { 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, isInserted, }: {
11
- changes: SimpleChange[];
12
- colorScheme?: ColorScheme;
13
- isInserted?: boolean;
14
- newDoc: PMNode;
15
- nodeViewSerializer: NodeViewSerializer;
16
- originalDoc: PMNode;
17
- }) => Decoration[];
18
- export {};
@@ -1,18 +0,0 @@
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, isInserted, shouldHideDeleted, }: {
10
- change: {
11
- fromB: number;
12
- toB: number;
13
- };
14
- colorScheme?: ColorScheme;
15
- isActive?: boolean;
16
- isInserted?: boolean;
17
- shouldHideDeleted?: boolean;
18
- }) => Decoration;
@@ -1,23 +0,0 @@
1
- import type { Change } from 'prosemirror-changeset';
2
- import type { IntlShape } from 'react-intl';
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
- /**
8
- * This function is used to create a decoration widget to show content
9
- * that is not in the current document.
10
- */
11
- export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, }: {
12
- activeIndexPos?: {
13
- from: number;
14
- to: number;
15
- };
16
- change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted" | "toB">;
17
- colorScheme?: ColorScheme;
18
- doc: PMNode;
19
- intl: IntlShape;
20
- isInserted?: boolean;
21
- newDoc: PMNode;
22
- nodeViewSerializer: NodeViewSerializer;
23
- }) => Decoration[] | undefined;
@@ -1,23 +0,0 @@
1
- /**
2
- * Shared prefix for every decoration key produced by the show-diff plugin.
3
- * All keys derive from this, so the full set of plugin decorations can be
4
- * identified by this single prefix.
5
- */
6
- export declare const DIFF_KEY_PREFIX = "diff";
7
- type DiffDecorationKind = 'inline' | 'block' | 'widget';
8
- type DiffDecorationKeyType = `${typeof DIFF_KEY_PREFIX}-${DiffDecorationKind}`;
9
- /**
10
- * The kinds of decoration the show-diff plugin produces. Each value is the
11
- * leading segment of the generated key, so a decoration's kind can be matched
12
- * with `key?.startsWith(DiffDecorationKey.inline)` etc.
13
- */
14
- export declare const DiffDecorationKey: Readonly<Record<DiffDecorationKind, DiffDecorationKeyType>>;
15
- /**
16
- * Builds a decoration key in the form `{type}-{active|inactive}`
17
- * (e.g. `diff-inline-active`).
18
- */
19
- export declare const buildDiffDecorationKey: ({ type, isActive, }: {
20
- isActive?: boolean;
21
- type: DiffDecorationKeyType;
22
- }) => string;
23
- export {};
@@ -1,9 +0,0 @@
1
- import type { Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
2
- /**
3
- * Find a safe position to insert a deletion slice at the given position.
4
- * @param doc
5
- * @param pos
6
- * @param slice
7
- * @returns
8
- */
9
- export declare function findSafeInsertPos(doc: PMNode, pos: number, slice: Slice): number;
@@ -1,19 +0,0 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import { type Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
3
- type StepRange = {
4
- fromB: number;
5
- /** Whether the changed node is inline (true) or block (false/undefined) */
6
- isInline?: boolean;
7
- toB: number;
8
- };
9
- export declare const getAttrChangeRanges: (doc: PMNode, steps: ProseMirrorStep[]) => StepRange[];
10
- /**
11
- * Check if the step was a valid attr change and affected the doc
12
- *
13
- * @param step Attr step to test
14
- * @param beforeDoc Doc before the step
15
- * @param afterDoc Doc after the step
16
- * @returns Boolean if the change should show a decoration
17
- */
18
- export declare const stepIsValidAttrChange: (step: ProseMirrorStep, beforeDoc: PMNode, afterDoc: PMNode) => boolean;
19
- export {};
@@ -1,7 +0,0 @@
1
- import { type Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
2
- type StepRange = {
3
- fromB: number;
4
- toB: number;
5
- };
6
- export declare const getMarkChangeRanges: (steps: ProseMirrorStep[]) => StepRange[];
7
- export {};
@@ -1,17 +0,0 @@
1
- import type { IntlShape } from 'react-intl';
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, isActive, isInserted, }: {
10
- colorScheme?: ColorScheme;
11
- dom: HTMLElement;
12
- intl: IntlShape;
13
- isActive?: boolean;
14
- isInserted: boolean;
15
- nodeView: Node;
16
- targetNode: PMNode;
17
- }) => void;
@@ -1 +0,0 @@
1
- export declare const enforceCustomStepRegisters: () => void;
@@ -1,27 +0,0 @@
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[];
@@ -1,29 +0,0 @@
1
- import type { IntlShape } from 'react-intl';
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
- import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
7
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
- import type { DiffParams, DiffType, ShowDiffPlugin } from '../showDiffPluginType';
9
- export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
10
- export type ShowDiffPluginState = {
11
- activeIndex?: number;
12
- activeIndexPos?: {
13
- from: number;
14
- to: number;
15
- };
16
- decorations: DecorationSet;
17
- diffType?: DiffType;
18
- hideDeletedDiffs?: boolean;
19
- isDisplayingChanges: boolean;
20
- isInverted?: boolean;
21
- originalDoc: PMNode | undefined;
22
- /**
23
- * When true, the view update handler should scroll to the first decoration
24
- * and then reset this flag.
25
- */
26
- scrollIntoView?: boolean;
27
- steps: ProseMirrorStep[];
28
- };
29
- export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined) => SafePlugin<ShowDiffPluginState>;
@@ -1,15 +0,0 @@
1
- import type { EditorView, Decoration } from '@atlaskit/editor-prosemirror/view';
2
- /**
3
- * Schedules scrolling to the first diff decoration after the next frame.
4
- * Unlike `scrollToActiveDecoration`, this does not require an active index —
5
- * it simply scrolls to bring the first decoration into view.
6
- *
7
- * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
8
- */
9
- export declare const scrollToFirstDecoration: (view: EditorView, decorations: Decoration[]) => (() => void);
10
- /**
11
- * Schedules scrolling to the decoration at the given index after the next frame.
12
- *
13
- * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
14
- */
15
- export declare const scrollToActiveDecoration: (view: EditorView, decorations: Decoration[], activeIndex: number) => (() => void);
@@ -1,2 +0,0 @@
1
- import type { ShowDiffPlugin } from './showDiffPluginType';
2
- export declare const showDiffPlugin: ShowDiffPlugin;
@@ -1,68 +0,0 @@
1
- import type { StepJson } from '@atlaskit/editor-common/collab';
2
- import type { NextEditorPlugin, EditorCommand, OptionalPlugin } from '@atlaskit/editor-common/types';
3
- import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
4
- import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
- import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
6
- import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
7
- import type { Node } from '@atlaskit/editor-prosemirror/model';
8
- import type { Step } from '@atlaskit/editor-prosemirror/transform';
9
- export type ColorScheme = 'standard' | 'traditional';
10
- export type DiffType = 'inline' | 'block' | 'step';
11
- export type DiffParams = {
12
- /**
13
- * Color scheme to use for displaying diffs.
14
- * 'standard' (default) uses purple for highlighting changes
15
- * 'traditional' uses green for additions and red for deletions
16
- */
17
- colorScheme?: ColorScheme;
18
- originalDoc: JSONDocNode;
19
- /**
20
- * Prosemirror steps. This is used to calculate and show the diff in the editor
21
- */
22
- steps: StepJson[];
23
- };
24
- export type PMDiffParams = {
25
- diffType?: DiffType;
26
- hideDeletedDiffs?: boolean;
27
- isInverted?: boolean;
28
- originalDoc: Node;
29
- /**
30
- * When true, the editor will scroll to bring the first diff decoration into view
31
- * after the diff is shown.
32
- */
33
- scrollIntoView?: boolean;
34
- /**
35
- * Prosemirror steps. This is used to calculate and show the diff in the editor
36
- */
37
- steps: Step[];
38
- };
39
- export type ACTION = 'SHOW_DIFF' | 'HIDE_DIFF' | 'SCROLL_TO_NEXT' | 'SCROLL_TO_PREVIOUS';
40
- export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
41
- commands: {
42
- hideDiff: EditorCommand;
43
- scrollToNext: EditorCommand;
44
- scrollToPrevious: EditorCommand;
45
- showDiff: (config: PMDiffParams) => EditorCommand;
46
- };
47
- dependencies: [
48
- OptionalPlugin<AnalyticsPlugin>,
49
- OptionalPlugin<ExpandPlugin>,
50
- OptionalPlugin<UserIntentPlugin>
51
- ];
52
- pluginConfiguration: DiffParams | undefined;
53
- sharedState: {
54
- /**
55
- * The index of the current diff being viewed.
56
- */
57
- activeIndex?: number;
58
- /**
59
- * Whether the show diff feature is currently displaying changes.
60
- * Defaults to false.
61
- */
62
- isDisplayingChanges: boolean;
63
- /**
64
- * The number of changes being displayed
65
- */
66
- numberOfChanges?: number;
67
- };
68
- }>;