@atlaskit/editor-plugin-show-diff
Version:
ShowDiff plugin for @atlaskit/editor-core
57 lines (56 loc) • 2.03 kB
TypeScript
import type { StepJson } from '@atlaskit/editor-common/collab';
import type { NextEditorPlugin, EditorCommand, OptionalPlugin } from '@atlaskit/editor-common/types';
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
import type { Node } from '@atlaskit/editor-prosemirror/model';
import type { Step } from '@atlaskit/editor-prosemirror/transform';
export type ColorScheme = 'standard' | 'traditional';
export type DiffType = 'inline' | 'block';
export type DiffParams = {
/**
* Color scheme to use for displaying diffs.
* 'standard' (default) uses purple for highlighting changes
* 'traditional' uses green for additions and red for deletions
*/
colorScheme?: ColorScheme;
originalDoc: JSONDocNode;
/**
* Prosemirror steps. This is used to calculate and show the diff in the editor
*/
steps: StepJson[];
};
export type PMDiffParams = {
diffType?: DiffType;
isInverted?: boolean;
originalDoc: Node;
/**
* Prosemirror steps. This is used to calculate and show the diff in the editor
*/
steps: Step[];
};
export type ACTION = 'SHOW_DIFF' | 'HIDE_DIFF' | 'SCROLL_TO_NEXT' | 'SCROLL_TO_PREVIOUS';
export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
commands: {
hideDiff: EditorCommand;
scrollToNext: EditorCommand;
scrollToPrevious: EditorCommand;
showDiff: (config: PMDiffParams) => EditorCommand;
};
dependencies: [OptionalPlugin<AnalyticsPlugin>];
pluginConfiguration: DiffParams | undefined;
sharedState: {
/**
* The index of the current diff being viewed.
*/
activeIndex?: number;
/**
* Whether the show diff feature is currently displaying changes.
* Defaults to false.
*/
isDisplayingChanges: boolean;
/**
* The number of changes being displayed
*/
numberOfChanges?: number;
};
}>;