forked from Tencent/cherry-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor.d.ts
63 lines (59 loc) · 2.29 KB
/
editor.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
/**
* Copyright (C) 2021 THL A29 Limited, a Tencent company.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import CodeMirror from 'codemirror';
import Cherry from '../src/Cherry.js';
interface EditorEventMap {
onBlur: FocusEvent;
onFocus: FocusEvent;
onKeydown: KeyboardEvent;
onPaste: ClipboardEvent;
}
type EditorDefaultCallback = () => void;
export type EditorEventCallback<
E = unknown,
K extends keyof EditorEventMap = keyof EditorEventMap
> = E extends EditorEventMap[K]
? (event: E, codemirror: CodeMirror.Editor) => void
: (codemirror: CodeMirror.Editor) => void;
type EditorPasteEventHandler = (
event: ClipboardEvent,
clipboardData: ClipboardEvent['clipboardData'],
codemirror: CodeMirror.Editor,
) => void;
export type EditorConfiguration = {
id?: string; // textarea 的id属性值
name?: string; // textarea 的name属性值
autoSave2Textarea?: boolean; // 是否自动将编辑区的内容回写到textarea里
editorDom: HTMLElement;
wrapperDom: HTMLElement;
toolbars: any;
value?: string;
convertWhenPaste?: boolean;
codemirror: CodeMirror.EditorConfiguration;
onKeydown: EditorEventCallback<EditorEventMap['onKeydown']>;
onFocus: EditorEventCallback<EditorEventMap['onFocus']>;
onBlur: EditorEventCallback<EditorEventMap['onBlur']>;
onPaste: EditorEventCallback<EditorEventMap['onPaste']>;
onChange: (changeList: CodeMirror.EditorChangeLinkedList, codemirror: CodeMirror.Editor) => void;
onScroll: EditorEventCallback;
handlePaste?: EditorPasteEventHandler;
/** 预览区域跟随编辑器光标自动滚动 */
autoScrollByCursor: boolean;
fileUpload?: (file: File, callback: (fileUrl: string) => void) => void;
$cherry?: Cherry;
/** 书写风格,normal 普通 | typewriter 打字机 | focus 专注,默认normal */
writingStyle?: string;
};