@jupyterlab/git
Version:
A JupyterLab extension for version control using git
101 lines (100 loc) • 3.02 kB
TypeScript
import { CodeEditor } from '@jupyterlab/codeeditor';
import { IEditorLanguageRegistry } from '@jupyterlab/codemirror';
import { Contents } from '@jupyterlab/services';
import { TranslationBundle } from '@jupyterlab/translation';
import { Panel } from '@lumino/widgets';
import { MergeView } from 'nbdime/lib/common/mergeview';
import { Git } from '../../tokens';
/**
* Diff callback to be registered for plain-text files.
*
* @param model Diff model
* @param toolbar MainAreaWidget toolbar
* @returns PlainText diff widget
*/
export declare const createPlainTextDiff: ({ editorFactory, languageRegistry, model, toolbar, translator }: Git.Diff.IFactoryOptions & {
languageRegistry: IEditorLanguageRegistry;
editorFactory?: CodeEditor.Factory | undefined;
}) => Promise<PlainTextDiff>;
/**
* Plain Text Diff widget
*/
export declare class PlainTextDiff extends Panel implements Git.Diff.IDiffWidget {
constructor({ model, languageRegistry, trans, editorFactory }: {
model: Git.Diff.IModel;
languageRegistry?: IEditorLanguageRegistry;
editorFactory?: CodeEditor.Factory;
trans?: TranslationBundle;
});
/**
* Helper to determine if three-way diff should be shown.
*/
private get _hasConflict();
/**
* Checks if the conflicted file has been resolved.
*/
get isFileResolved(): boolean;
/**
* Diff model
*/
get model(): Git.Diff.IModel;
/**
* Promise which fulfills when the widget is ready.
*/
get ready(): Promise<void>;
/**
* Gets the file model of a resolved merge conflict,
* and rejects if unable to retrieve.
*/
getResolvedFile(): Promise<Partial<Contents.IModel>>;
/**
* Callback to create the diff widget once the widget
* is attached so CodeMirror get proper size.
*/
onAfterAttach(): void;
/**
* Refresh diff
*
* Note: Update the content and recompute the diff
*/
refresh(): Promise<void>;
/**
* Create wrapper node
*/
protected static createHeader(...labels: (string | undefined)[]): HTMLElement;
/**
* Create the Plain Text Diff view
*
* Note: baseContent will only be passed when displaying
* a three-way merge conflict.
*/
protected createDiffView(challengerContent: string, referenceContent: string, baseContent?: string | null): Promise<void>;
/**
* Display an error instead of the file diff
*
* @param error Error object
*/
protected showError(error: Error): void;
protected _editorFactory: CodeEditor.Factory;
protected _isReady: Promise<void>;
protected _mergeView: MergeView;
protected _model: Git.Diff.IModel;
protected _trans: TranslationBundle;
private _reference;
private _challenger;
private _languageRegistry;
private _base;
}
/**
* Diff status
*/
declare enum DiffStatus {
Equal,
Delete,
Insert
}
/**
* Diff type
*/
type Diff = [DiffStatus, string];
export {};