-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
index.d.ts
121 lines (113 loc) · 3.88 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import {
ContentBlock,
DraftDecorator,
DraftDragType,
DraftEditorCommand,
DraftHandleValue,
DraftInlineStyle,
DraftStyleMap,
Editor,
EditorProps,
EditorState,
SelectionState
} from "draft-js";
import { Component, Ref, SyntheticEvent, KeyboardEvent } from "react";
export interface PluginFunctions {
getPlugins(): EditorPlugin[]; // a function returning a list of all the plugins
getProps(): any; // a function returning a list of all the props pass into the Editor
setEditorState(editorState: EditorState): void; // a function to update the EditorState
getEditorState(): EditorState; // a function to get the current EditorState
getReadOnly(): boolean; // a function returning of the Editor is set to readOnly
setReadOnly(readOnly: boolean): void; // a function which allows to set the Editor to readOnly
getEditorRef(): Ref<any>; // a function to get the editor reference
}
export interface EditorPlugin {
decorators?: DraftDecorator[];
getAccessibilityProps?: () => {
ariaHasPopup: string;
ariaExpanded: string;
};
initialize?: (pluginFunctions: PluginFunctions) => void;
onChange?: (
editorState: EditorState,
pluginFunctions: PluginFunctions
) => EditorState;
willUnmount?: (pluginFunctions: PluginFunctions) => void;
// Events passed from the draft-js editor back to all plugins
blockRendererFn?(block: ContentBlock, pluginFunctions: PluginFunctions): any;
blockStyleFn?(block: ContentBlock, pluginFunctions: PluginFunctions): string;
customStyleFn?: (
style: DraftInlineStyle,
block: ContentBlock,
pluginFunctions: PluginFunctions
) => DraftStyleMap;
keyBindingFn?(
e: KeyboardEvent,
pluginFunctions: PluginFunctions
): DraftEditorCommand | null;
handleReturn?(
e: KeyboardEvent,
editorState: EditorState,
pluginFunctions: PluginFunctions
): DraftHandleValue;
handleKeyCommand?(
command: DraftEditorCommand,
editorState: EditorState,
eventTimeStamp: number,
pluginFunctions: PluginFunctions
): DraftHandleValue;
handleBeforeInput?(
chars: string,
editorState: EditorState,
eventTimeStamp: number,
pluginFunctions: PluginFunctions
): DraftHandleValue;
handlePastedText?(
text: string,
html: string | undefined,
editorState: EditorState,
pluginFunctions: PluginFunctions
): DraftHandleValue;
handlePastedFiles?(
files: Array<Blob>,
pluginFunctions: PluginFunctions
): DraftHandleValue;
handleDroppedFiles?(
selection: SelectionState,
files: Array<Blob>,
pluginFunctions: PluginFunctions
): DraftHandleValue;
handleDrop?(
selection: SelectionState,
dataTransfer: Object,
isInternal: DraftDragType,
pluginFunctions: PluginFunctions
): DraftHandleValue;
onEscape?(e: KeyboardEvent, pluginFunctions: PluginFunctions): void;
onTab?(e: KeyboardEvent, pluginFunctions: PluginFunctions): void;
onUpArrow?(e: KeyboardEvent, pluginFunctions: PluginFunctions): void;
onDownArrow?(e: KeyboardEvent, pluginFunctions: PluginFunctions): void;
onRightArrow?(e: KeyboardEvent, pluginFunctions: PluginFunctions): void;
onLeftArrow?(e: KeyboardEvent, pluginFunctions: PluginFunctions): void;
onBlur?(e: SyntheticEvent, pluginFunctions: PluginFunctions): void;
onFocus?(e: SyntheticEvent, pluginFunctions: PluginFunctions): void;
}
export const composeDecorators: (
...decorators: DraftDecorator[]
) => DraftDecorator;
export interface PluginEditorProps extends EditorProps {
plugins?: EditorPlugin[];
defaultKeyBindings?: boolean;
defaultKeyCommands?: boolean;
defaultBlockRenderMap?: boolean;
// eslint-disable-next-line react/no-unused-prop-types
decorators?: DraftDecorator[];
}
declare class PluginEditor extends Component<PluginEditorProps> {
focus(): void;
blur(): void;
getPlugins(): EditorPlugin[];
getPluginMethods(): PluginFunctions;
getEditorRef(): Editor | undefined;
}
export default PluginEditor;