@pierre/diffs
Version:
88 lines (87 loc) • 4.53 kB
TypeScript
import { DiffLineAnnotation, FileContents, FileDiffMetadata, LineAnnotation, SelectedLineRange, VirtualFileMetrics } from "../types.js";
import { GetHoveredLineResult } from "../managers/InteractionManager.js";
import { FileEditChangeHandler, FileEditCompleteHandler, FileOptions as FileOptions$1 } from "../components/File.js";
import { FileDiffEditChangeHandler, FileDiffEditCompleteHandler, FileDiffOptions as FileDiffOptions$1 } from "../components/FileDiff.js";
import { EditorOptions } from "../editor/editor.js";
import { CSSProperties, ReactNode } from "react";
//#region src/react/types.d.ts
type ReactOwnedEditCallbacks = 'onEditChange' | 'onEditComplete';
type FileDiffOptions<LAnnotation, Caret> = Omit<FileDiffOptions$1<LAnnotation, Caret>, ReactOwnedEditCallbacks>;
type FileOptions<LAnnotation, Caret> = Omit<FileOptions$1<LAnnotation, Caret>, ReactOwnedEditCallbacks>;
interface DiffBasePropsReact<LAnnotation, Caret> {
options?: FileDiffOptions<LAnnotation, Caret>;
/** Whether this surface has an active edit session. */
edit?: boolean;
/** Creation-time options passed to the nearest EditProvider factory. */
editorOptions?: EditorOptions<'file-diff', LAnnotation, Caret>;
/** Retain this editable draft and its undo/redo history in memory. */
editStateKey?: string;
/**
* Fired for every document change of an active edit session, with the same
* `EditorChangeEvent` the editor reports through its own `onChange`. Don't
* feed this data back into the component.
*
* When editing a diff, you are editing the contents of the new file. You
* cannot edit the contents of the old file. You are not getting back an
* update `fileDiff` during this edit session.
*/
onEditChange?: FileDiffEditChangeHandler<LAnnotation, Caret>;
/**
* Fired when `edit` toggles false or the component unmounts. Return `'accept'`
* to install the completed diff and annotations or `'reject'` to restore the
* external values. The event contains the detached editor with its final
* state.
*/
onEditComplete?: FileDiffEditCompleteHandler<LAnnotation, Caret>;
metrics?: VirtualFileMetrics;
lineAnnotations?: DiffLineAnnotation<LAnnotation>[];
selectedLines?: SelectedLineRange | null;
renderAnnotation?(annotations: DiffLineAnnotation<LAnnotation>): ReactNode;
renderCustomHeader?(fileDiff: FileDiffMetadata): ReactNode;
renderHeaderPrefix?(fileDiff: FileDiffMetadata): ReactNode;
renderHeaderFilenameSuffix?(fileDiff: FileDiffMetadata): ReactNode;
renderHeaderMetadata?(fileDiff: FileDiffMetadata): ReactNode;
renderGutterUtility?(getHoveredLine: () => GetHoveredLineResult<'diff'> | undefined): ReactNode;
className?: string;
style?: CSSProperties;
prerenderedHTML?: string;
}
interface FileProps<LAnnotation, Caret> {
file: FileContents;
options?: FileOptions<LAnnotation, Caret>;
/** Whether this surface has an active edit session. */
edit?: boolean;
/** Creation-time options passed to the nearest EditProvider factory. */
editorOptions?: EditorOptions<'file', LAnnotation, Caret>;
/** Retain this editable draft and its undo/redo history in memory. */
editStateKey?: string;
/**
* Fired for every document change of an active edit session, with the same
* `EditorChangeEvent` the editor reports through its own `onChange`. Don't
* feed this data back into the component.
*/
onEditChange?: FileEditChangeHandler<LAnnotation, Caret>;
/**
* Fired when `edit` toggles false or the component unmounts. Return `'accept'`
* to install the completed file and annotations or `'reject'` to restore the
* external values. The event contains the detached editor with its final
* state.
*/
onEditComplete?: FileEditCompleteHandler<LAnnotation, Caret>;
metrics?: VirtualFileMetrics;
lineAnnotations?: LineAnnotation<LAnnotation>[];
selectedLines?: SelectedLineRange | null;
renderAnnotation?(annotations: LineAnnotation<LAnnotation>): ReactNode;
renderCustomHeader?(file: FileContents): ReactNode;
renderHeaderPrefix?(file: FileContents): ReactNode;
renderHeaderFilenameSuffix?(file: FileContents): ReactNode;
renderHeaderMetadata?(file: FileContents): ReactNode;
renderGutterUtility?(getHoveredLine: () => GetHoveredLineResult<'file'> | undefined): ReactNode;
className?: string;
style?: CSSProperties;
prerenderedHTML?: string;
disableWorkerPool?: boolean;
}
//#endregion
export { DiffBasePropsReact, FileDiffOptions, FileOptions, FileProps };
//# sourceMappingURL=types.d.ts.map