@atlaskit/editor-plugin-show-diff
Version:
ShowDiff plugin for @atlaskit/editor-core
72 lines (71 loc) • 3.65 kB
TypeScript
import type { IntlShape } from 'react-intl';
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
import type { ColorScheme, ContributorTagModel, DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffStepAttribution, DiffType, InlineDeletedDiffPlacement, RevealOptions, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
import type { ResolvedDiffContributors } from './decorations/colorSchemes/attributions';
export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
export type ShowDiffPluginState = {
activeIndex?: number;
activeIndexPos?: {
attributionKey?: string;
from: number;
to: number;
};
/**
* Per-call override, set via SHOW_DIFF meta. Falls back to the plugin's configured
* `DiffParams.colorScheme` (see `createPlugin`'s `config` argument) when unset, and persists
* across `SCROLL_TO_NEXT`/`SCROLL_TO_PREVIOUS` repaints of the same diff. Reset on HIDE_DIFF.
*/
colorScheme?: ColorScheme;
/** Set via SHOW_DIFF meta, after `normalizeShowDiffParams` has keyed the public list. */
contributors?: ResolvedDiffContributors;
/** Resolved per calculation, never set via meta. */
contributorTags?: ContributorTagModel[];
decorations: DecorationSet;
/**
* For the `smart` diffType, where node/paragraph-level deleted content is rendered relative to
* the new content. Set via SHOW_DIFF meta. Defaults to `'top'`.
*/
deletedDiffPlacement?: DeletedDiffPlacement;
/**
* The diff descriptors of the diff decorations currently being displayed.
*/
diffDescriptors?: DiffDescriptor[];
diffType?: DiffType;
hideAddedDiffsUnderline?: boolean;
hideDeletedDiffs?: boolean;
/**
* For the `smart` diffType, where inline-level (and sentence-level) deleted content is rendered
* relative to the new content. Set via SHOW_DIFF meta. Defaults to `'before'`. Independent of
* `deletedDiffPlacement`.
*/
inlineDeletedDiffPlacement?: InlineDeletedDiffPlacement;
isDisplayingChanges: boolean;
isInverted?: boolean;
originalDoc: PMNode | undefined;
/**
* Reveal choreography for the CURRENT paint only. Set from SHOW_DIFF meta and deliberately not
* inherited: a scroll-to-next or an unrelated repaint must not replay the animation.
*/
reveal?: RevealOptions;
/**
* When true, the view update handler should scroll to the first decoration
* and then reset this flag.
*/
scrollIntoView?: boolean;
showIndicators?: boolean;
/**
* Optional overrides for the `smart` diffType density thresholds. Set via SHOW_DIFF
* meta. Only relevant when `diffType === 'smart'`.
*/
smartThresholds?: Partial<SmartDiffThresholds>;
/** Internal attribution derived from the public attributed-step input. */
stepAttributions?: Array<DiffStepAttribution | undefined>;
steps: ProseMirrorStep[];
};
export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined, onEditorView?: (editorView: EditorView | undefined) => void) => SafePlugin<ShowDiffPluginState>;