UNPKG

@atlaskit/editor-plugin-show-diff

Version:

ShowDiff plugin for @atlaskit/editor-core

54 lines (53 loc) 2.58 kB
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 { DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffType, InlineDeletedDiffPlacement, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType'; export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>; export type ShowDiffPluginState = { activeIndex?: number; activeIndexPos?: { from: number; to: number; }; 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. * Only set when `platform_editor_diff_plugin_extended` is on. */ 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; /** * 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>; steps: ProseMirrorStep[]; }; export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined, onEditorView?: (editorView: EditorView | undefined) => void) => SafePlugin<ShowDiffPluginState>;