-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathContext.tsx
53 lines (49 loc) · 1.22 KB
/
Context.tsx
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
import React, { Context } from 'react';
import { WebViewMessageEvent } from 'react-native-webview';
import { EditorState } from './types';
export interface ContextValue {
state: EditorState;
getContent: () => Promise<string>;
setWebViewRef: ( ref: any ) => void;
onCommand: ( commandId: string, showUI?: boolean, value?: string ) => void;
onDismissToolbar: () => void;
onFormat: ( format: string ) => void;
onMessage: ( event: WebViewMessageEvent ) => void;
onShowFormat: () => void;
onShowLink: () => void;
onUpdateContent: ( content: string ) => void;
}
export const defaultValue: ContextValue = {
state: {
// showingFormat: false,
showingFormat: false,
showingLink: false,
// showingLink: true,
textStatus: {
bold: false,
italic: false,
underline: false,
strikethrough: false,
paraType: 'p',
undo: {
hasUndo: false,
hasRedo: false,
},
link: {
href: null,
target: null,
},
},
},
getContent: null,
setWebViewRef: null,
onCommand: null,
onDismissToolbar: null,
onFormat: null,
onMessage: null,
onShowFormat: null,
onShowLink: null,
onUpdateContent: null,
};
const EditorContext: Context<ContextValue> = React.createContext( defaultValue );
export default EditorContext;