react-codemirror-merge
Version:
CodeMirror merge view for React.
36 lines (35 loc) • 1.53 kB
TypeScript
import React, { PropsWithChildren } from 'react';
import { EditorStateConfig, Extension } from '@codemirror/state';
import { ViewUpdate } from '@codemirror/view';
import { MergeView, MergeConfig } from '@codemirror/merge';
import { DefaultExtensionsOptions } from '@uiw/react-codemirror';
export interface StoreContextValue extends InitialState {
dispatch?: React.Dispatch<InitialState>;
}
export interface InitialState extends MergeConfig {
modifiedExtension?: {
option: Omit<DefaultExtensionsOptions, 'theme'>;
extension: Extension[];
/** Fired whenever a change occurs to the document. */
onChange?(value: string, viewUpdate: ViewUpdate): void;
};
modified?: EditorStateConfig;
originalExtension?: {
option: Omit<DefaultExtensionsOptions, 'theme'>;
extension: Extension[];
/** Fired whenever a change occurs to the document. */
onChange?(value: string, viewUpdate: ViewUpdate): void;
};
original?: EditorStateConfig;
view?: MergeView;
theme?: 'light' | 'dark' | 'none' | Extension;
container?: HTMLDivElement | null;
}
export declare const initialState: InitialState;
export declare const Context: React.Context<StoreContextValue>;
export declare function reducer(state: InitialState, action: InitialState): InitialState;
export declare const useStore: () => StoreContextValue;
export interface ProviderProps {
theme?: InitialState['theme'];
}
export declare const Provider: React.FC<PropsWithChildren<ProviderProps>>;