react-markdown-editor-lite
Version:
a light-weight Markdown editor based on React
70 lines (69 loc) • 2.07 kB
TypeScript
import type { FC } from 'react';
import type Editor from '../editor';
import type { PluginComponent } from '../plugins/Plugin';
export type UploadFunc = ((file: File) => Promise<string>) | ((file: File, callback: (url: string) => void) => void);
export type EditorEvent = 'change' | 'fullscreen' | 'viewchange' | 'keydown' | 'focus' | 'blur' | 'scroll' | 'editor_keydown';
export interface EditorConfig {
theme?: string;
name?: string;
view?: {
menu: boolean;
md: boolean;
html: boolean;
};
canView?: {
menu: boolean;
md: boolean;
html: boolean;
both: boolean;
fullScreen: boolean;
hideMenu: boolean;
};
htmlClass?: string;
markdownClass?: string;
imageUrl?: string;
imageAccept?: string;
linkUrl?: string;
loggerMaxSize?: number;
loggerInterval?: number;
table?: {
maxRow: number;
maxCol: number;
};
syncScrollMode?: string[];
allowPasteImage?: boolean;
onImageUpload?: UploadFunc;
onChangeTrigger?: 'both' | 'beforeRender' | 'afterRender';
onCustomImageUpload?: (event: any) => Promise<{
url: string;
text?: string;
}>;
shortcuts?: boolean;
}
export interface Selection {
start: number;
end: number;
text: string;
}
export declare const initialSelection: Selection;
export type KeyboardEventCallback = (e: React.KeyboardEvent<HTMLDivElement>) => void;
export interface KeyboardEventCondition {
key?: string;
keyCode: number;
aliasCommand?: boolean;
withKey?: ('ctrlKey' | 'shiftKey' | 'altKey' | 'metaKey')[];
}
export interface KeyboardEventListener extends KeyboardEventCondition {
callback: KeyboardEventCallback;
}
export interface PluginProps<C = any> {
editor: Editor;
editorConfig: EditorConfig;
config: C;
}
export type FunctionPlugin<C = any> = FC<PluginProps<C>> & {
pluginName?: string;
align?: string;
defaultConfig?: C;
};
export type EditorPlugin<C = any> = typeof PluginComponent<any, C> | FunctionPlugin;