forked from wxik/react-native-rich-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
184 lines (149 loc) · 5.13 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import {WebViewProps} from 'react-native-webview';
import {ImageSourcePropType, StyleProp, ViewStyle} from 'react-native';
import * as React from 'react';
declare module 'react-native-pell-rich-editor' {
/** The RichTextEditor accepts all props from Webview */
export interface RichEditorProps extends WebViewProps {
/**
* Used for placement of editor
*/
contentInset?: {top: number; bottom: number};
/**
* Wrap the editor webview inside a container.
* Default is true
*/
useContainer?: boolean;
/**
* Wrap the editor content placeholder
* Default is empty string
*/
placeholder?: string;
/**
* Styling for container or for Webview depending on useContainer prop
*/
style?: StyleProp<ViewStyle>;
/**
* Initial content to be rendered inside WebView
*/
initialContentHTML?: string;
/**
* Boolean value to Initial content request focus. The default value is false.
*/
initialFocus?: boolean;
/**
* Boolean value to disable editor. The default value is false.
*/
disabled?: boolean;
/**
* Callback called after the editor has been initialized
*/
editorInitializedCallback?: () => void;
/**
* Callback after editor data modification
*/
onChange?: (text: string) => void;
/**
* Callback after height change
*/
onHeightChange?: (height: number) => void;
/**
* Styling for container or for Rich Editor more dark or light settings
*/
editorStyle?: {
backgroundColor?: string; // editor background color
color?: string; // editor text color
placeholderColor?: string; // editor placeholder text color
contentCSSText?: string; // editor content css text
cssText?: string; // editor global css text
};
}
export type SelectionChangeListener = (items: string[]) => void;
export type DefaultActions = ['image', 'bold', 'italic', 'unorderedList', 'orderedList', 'link'];
export class RichEditor extends React.Component<RichEditorProps> {
// Public API
/**
* @deprecated please use onChange
*/
getContentHtml: () => Promise<string>;
registerToolbar: (listener: SelectionChangeListener) => void;
/** Add a listener for the content focused event in WebView */
setContentFocusHandler: (listener: () => void) => void;
/**
* Set current HTML to be rendered
*/
setContentHTML: (html: string) => void;
blurContentEditor: () => void;
focusContentEditor: () => void;
insertImage: (attributes: any) => void;
insertVideo: (attributes: any) => void;
insertLink: (title: string, url: string) => void;
insertText: (text: string) => void;
insertHTML: (html: string) => void;
init: () => void;
}
export interface RichToolbarProps {
/**
* Function that returns a reference to the RichEditor instance
* Optional editor props
*/
getEditor?: () => RichEditor;
/**
* React.createRef reference to the RichEditor instance
* Optional getEditor props
*/
editor?: React.createRef;
unselectedButtonStyle?: StyleProp<ViewStyle>;
selectedButtonStyle?: StyleProp<ViewStyle>;
disabledButtonStyle?: StyleProp<ViewStyle>;
/**
* Color for selected button Icon
*/
selectedIconTint?: string;
/**
* Color for unselected button Icon
*/
iconTint?: string;
/**
* Color for disabled button Icon
*/
disabledIconTint?: string;
/**
* Boolean value to disable editor. The default value is false.
*/
disabled?: boolean;
/**
* Custom renderer for toolbar actions
*/
renderAction?: (action: string, selected: boolean) => React.Element;
/**
* Custom style prop for the toolbar
*/
style?: StyleProp<ViewStyle>;
/**
* Your own set if images for the toolbar
*/
iconMap?: Record<
string,
({
selected: boolean,
disabled: boolean,
tintColor: any,
iconSize: number,
}) => React.Element | ImageSourcePropType
>;
/**
* Logic for what happens when you press on the add image button
*/
onPressAddImage?: () => void;
/**
* Logic for what happens when you press on the add insert link button
*/
onInsertLink?: () => void;
/**
* Custom actions you want the toolbar to permit.
* By default the toolbar permits an Action set of type DefaultActions
*/
actions?: Partial<DefaultActions> | string[];
}
export class RichToolbar extends React.Component<RichToolbarProps> {}
}