forked from Vanessa219/vditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
995 lines (861 loc) · 27.7 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
declare module "*.svg";
declare module "*.png";
interface Window {
VditorI18n: ITips;
}
interface IObject {
[key: string]: string;
}
interface ILuteNode {
TokensStr: () => string;
__internal_object__: {
Parent: {
Type: number,
},
HeadingLevel: string,
};
}
type ILuteRenderCallback = (node: ILuteNode, entering: boolean) => [string, number];
/** @link https://ld246.com/article/1588412297062 */
interface ILuteRender {
renderDocument?: ILuteRenderCallback;
renderParagraph?: ILuteRenderCallback;
renderText?: ILuteRenderCallback;
renderCodeBlock?: ILuteRenderCallback;
renderCodeBlockOpenMarker?: ILuteRenderCallback;
renderCodeBlockInfoMarker?: ILuteRenderCallback;
renderCodeBlockCode?: ILuteRenderCallback;
renderCodeBlockCloseMarker?: ILuteRenderCallback;
renderMathBlock?: ILuteRenderCallback;
renderMathBlockOpenMarker?: ILuteRenderCallback;
renderMathBlockContent?: ILuteRenderCallback;
renderMathBlockCloseMarker?: ILuteRenderCallback;
renderBlockquote?: ILuteRenderCallback;
renderBlockquoteMarker?: ILuteRenderCallback;
renderHeading?: ILuteRenderCallback;
renderHeadingC8hMarker?: ILuteRenderCallback;
renderList?: ILuteRenderCallback;
renderListItem?: ILuteRenderCallback;
renderTaskListItemMarker?: ILuteRenderCallback;
renderThematicBreak?: ILuteRenderCallback;
renderHTML?: ILuteRenderCallback;
renderTable?: ILuteRenderCallback;
renderTableHead?: ILuteRenderCallback;
renderTableRow?: ILuteRenderCallback;
renderTableCell?: ILuteRenderCallback;
renderFootnotesDef?: ILuteRenderCallback;
renderCodeSpan?: ILuteRenderCallback;
renderCodeSpanOpenMarker?: ILuteRenderCallback;
renderCodeSpanContent?: ILuteRenderCallback;
renderCodeSpanCloseMarker?: ILuteRenderCallback;
renderInlineMath?: ILuteRenderCallback;
renderInlineMathOpenMarker?: ILuteRenderCallback;
renderInlineMathContent?: ILuteRenderCallback;
renderInlineMathCloseMarker?: ILuteRenderCallback;
renderEmphasis?: ILuteRenderCallback;
renderEmAsteriskOpenMarker?: ILuteRenderCallback;
renderEmAsteriskCloseMarker?: ILuteRenderCallback;
renderEmUnderscoreOpenMarker?: ILuteRenderCallback;
renderEmUnderscoreCloseMarker?: ILuteRenderCallback;
renderStrong?: ILuteRenderCallback;
renderStrongA6kOpenMarker?: ILuteRenderCallback;
renderStrongA6kCloseMarker?: ILuteRenderCallback;
renderStrongU8eOpenMarker?: ILuteRenderCallback;
renderStrongU8eCloseMarker?: ILuteRenderCallback;
renderStrikethrough?: ILuteRenderCallback;
renderStrikethrough1OpenMarker?: ILuteRenderCallback;
renderStrikethrough1CloseMarker?: ILuteRenderCallback;
renderStrikethrough2OpenMarker?: ILuteRenderCallback;
renderStrikethrough2CloseMarker?: ILuteRenderCallback;
renderHardBreak?: ILuteRenderCallback;
renderSoftBreak?: ILuteRenderCallback;
renderInlineHTML?: ILuteRenderCallback;
renderLink?: ILuteRenderCallback;
renderOpenBracket?: ILuteRenderCallback;
renderCloseBracket?: ILuteRenderCallback;
renderOpenParen?: ILuteRenderCallback;
renderCloseParen?: ILuteRenderCallback;
renderLinkText?: ILuteRenderCallback;
renderLinkSpace?: ILuteRenderCallback;
renderLinkDest?: ILuteRenderCallback;
renderLinkTitle?: ILuteRenderCallback;
renderImage?: ILuteRenderCallback;
renderBang?: ILuteRenderCallback;
renderEmoji?: ILuteRenderCallback;
renderEmojiUnicode?: ILuteRenderCallback;
renderEmojiImg?: ILuteRenderCallback;
renderEmojiAlias?: ILuteRenderCallback;
renderToC?: ILuteRenderCallback;
renderFootnotesRef?: ILuteRenderCallback;
renderBackslash?: ILuteRenderCallback;
renderBackslashContent?: ILuteRenderCallback;
}
interface ILuteOptions extends IMarkdownConfig {
emojis: IObject;
emojiSite: string;
headingAnchor: boolean;
inlineMathDigit: boolean;
lazyLoadImage?: string;
}
declare class Lute {
public static WalkStop: number;
public static WalkSkipChildren: number;
public static WalkContinue: number;
public static Version: string;
public static Caret: string;
public static New(): Lute;
public static EscapeHTMLStr(html: string): string;
public static GetHeadingID(node: ILuteNode): string;
public static NewNodeID(): string;
public static Sanitize(html: string): string;
private constructor();
public SetJSRenderers(options?: {
renderers: {
HTML2VditorDOM?: ILuteRender,
HTML2VditorIRDOM?: ILuteRender,
HTML2Md?: ILuteRender,
Md2HTML?: ILuteRender,
Md2VditorDOM?: ILuteRender,
Md2VditorIRDOM?: ILuteRender,
Md2VditorSVDOM?: ILuteRender,
},
}): void;
public SetChineseParagraphBeginningSpace(enable: boolean): void;
public SetHeadingID(enable: boolean): void;
public SetRenderListStyle(enable: boolean): void;
public SetLinkBase(url: string): void;
public SetVditorIR(enable: boolean): void;
public SetVditorSV(enable: boolean): void;
public SetVditorWYSIWYG(enable: boolean): void;
public SetLinkPrefix(url: string): void;
public SetMark(enable: boolean): void;
public SetGFMAutoLink(enable: boolean): void;
public SetSanitize(enable: boolean): void;
public SetHeadingAnchor(enable: boolean): void;
public SetImageLazyLoading(imagePath: string): void;
public SetInlineMathAllowDigitAfterOpenMarker(enable: boolean): void;
public SetToC(enable: boolean): void;
public SetFootnotes(enable: boolean): void;
public SetAutoSpace(enable: boolean): void;
public SetFixTermTypo(enable: boolean): void;
public SetEmojiSite(emojiSite: string): void;
public SetVditorCodeBlockPreview(enable: boolean): void;
public SetVditorMathBlockPreview(enable: boolean): void;
public PutEmojis(emojis: IObject): void;
public GetEmojis(): IObject;
public IsValidLinkDest(link: string): boolean;
// debugger md
public RenderEChartsJSON(text: string): string;
// md 转换为 html
public Md2HTML(markdown: string): string;
// 粘贴时将 html 转换为 md
public HTML2Md(html: string): string;
// wysiwyg 转换为 html
public VditorDOM2HTML(vhtml: string): string;
// wysiwyg 输入渲染
public SpinVditorDOM(html: string): string;
// 粘贴时将 html 转换为 wysiwyg
public HTML2VditorDOM(html: string): string;
// 将 wysiwyg 转换为 md
public VditorDOM2Md(html: string): string;
// 将 md 转换为 wysiwyg
public Md2VditorDOM(markdown: string): string;
// ir 输入渲染
public SpinVditorIRDOM(markdown: string): string;
// ir 获取 md
public VditorIRDOM2Md(html: string): string;
// md 转换为 ir
public Md2VditorIRDOM(text: string): string;
// 获取 HTML
public VditorIRDOM2HTML(html: string): string;
// 粘贴时将 html 转换为 sv
public HTML2VditorIRDOM(html: string): string;
// sv 输入渲染
public SpinVditorSVDOM(text: string): string;
// 粘贴是 md 转换为 sv
public Md2VditorSVDOM(text: string): string;
// 将markdown转化为JSON结构输出 https://github.com/88250/lute/issues/120
public RenderJSON(markdown: string): string;
}
declare const webkitAudioContext: {
prototype: AudioContext
new(contextOptions?: AudioContextOptions): AudioContext,
};
interface ITips {
[index: string]: string;
alignCenter: string;
alignLeft: string;
alignRight: string;
alternateText: string;
bold: string;
both: string;
check: string;
close: string;
code: string;
"code-theme": string;
column: string;
comment: string;
confirm: string;
"content-theme": string;
copied: string;
copy: string;
"delete-column": string;
"delete-row": string;
devtools: string;
down: string;
downloadTip: string;
edit: string;
"edit-mode": string;
emoji: string;
export: string;
fileTypeError: string;
footnoteRef: string;
fullscreen: string;
generate: string;
headings: string;
help: string;
imageURL: string;
indent: string;
info: string;
"inline-code": string;
"insert-after": string;
"insert-before": string;
insertColumnLeft: string;
insertColumnRight: string;
insertRowAbove: string;
insertRowBelow: string;
instantRendering: string;
italic: string;
language: string;
line: string;
link: string;
linkRef: string;
list: string;
more: string;
nameEmpty: string;
"ordered-list": string;
outdent: string;
outline: string;
over: string;
performanceTip: string;
preview: string;
quote: string;
record: string;
"record-tip": string;
recording: string;
redo: string;
remove: string;
row: string;
spin: string;
splitView: string;
strike: string;
table: string;
textIsNotEmpty: string;
title: string;
tooltipText: string;
undo: string;
up: string;
update: string;
upload: string;
uploadError: string;
uploading: string;
wysiwyg: string;
}
interface II18n {
en_US: ITips;
fr_FR: ITips;
ja_JP: ITips;
ko_KR: ITips;
ru_RU: ITips;
sv_SE: ITips;
zh_CN: ITips;
zh_TW: ITips;
pt_BR: ITips;
}
interface IClasses {
preview?: string;
}
interface IPreviewTheme {
current: string;
list?: IObject;
path?: string;
}
/** @link https://ld246.com/article/1549638745630#options-upload */
interface IUpload {
/** 上传 url */
url?: string;
/** 上传文件最大 Byte */
max?: number;
/** 剪切板中包含图片地址时,使用此 url 重新上传 */
linkToImgUrl?: string;
/** CORS 上传验证,头为 X-Upload-Token */
token?: string;
/** 文件上传类型,同 [input accept](https://www.w3schools.com/tags/att_input_accept.asp) */
accept?: string;
/** 跨站点访问控制。默认值: false */
withCredentials?: boolean;
/** 请求头设置 */
headers?: IObject;
/** 额外请求参数 */
extraData?: { [key: string]: string | Blob };
/** 是否允许多文件上传。默认值:true */
multiple?: boolean;
/** 上传字段名。默认值:file[] */
fieldName?: string;
/** 每次上传前都会重新设置请求头 */
setHeaders?(): IObject;
/** 上传成功回调 */
success?(editor: HTMLPreElement, msg: string): void;
/** 上传失败回调 */
error?(msg: string): void;
/** 文件名安全处理。 默认值: name => name.replace(/\W/g, '') */
filename?(name: string): string;
/** 校验,成功时返回 true 否则返回错误信息 */
validate?(files: File[]): string | boolean;
/** 自定义上传,当发生错误时返回错误信息 */
handler?(files: File[]): string | null | Promise<string> | Promise<null>;
/** 对服务端返回的数据进行转换,以满足内置的数据结构 */
format?(files: File[], responseText: string): string;
/** 对服务端返回的数据进行转换(对应linkToImgUrl),以满足内置的数据结构 */
linkToImgFormat?(responseText: string): string;
/** 将上传的文件处理后再返回 */
file?(files: File[]): File[] | Promise<File[]>;
/** 图片地址上传后的回调 */
linkToImgCallback?(responseText: string): void;
}
/** @link https://ld246.com/article/1549638745630#options-toolbar */
interface IMenuItem {
/** 唯一标示 */
name: string;
/** svg 图标 HTML */
icon?: string;
/** 元素的样式名称 */
className?: string;
/** 提示 */
tip?: string;
/** 快捷键,支持⌘/ctrl-key 或 ⌘/ctrl-⇧/shift-key 格式的配置,不支持 wysiwyg 模式 */
hotkey?: string;
/** 插入编辑器中的后缀 */
suffix?: string;
/** 插入编辑器中的前缀 */
prefix?: string;
/** 提示位置:ne, nw */
tipPosition?: string;
/** 子菜单 */
toolbar?: Array<string | IMenuItem>;
/** 菜单层级,最大为 3,内部使用 */
level?: number;
/** 自定义按钮点击时触发的事件 */
click?(event: Event, vditor: IVditor): void;
}
/** @link https://ld246.com/article/1549638745630#options-preview-hljs */
interface IHljs {
/** 代码块没有指定语言时,使用此值。默认值: "" */
defaultLang?: string;
/** 是否启用行号。默认值: false */
lineNumber?: boolean;
/** 代码风格,可选值参见 [Chroma](https://xyproto.github.io/splash/docs/longer/all.html)。 默认值: 'github' */
style?: string;
/** 是否启用代码高亮。默认值: true */
enable?: boolean;
/** 自定义指定语言: CODE_LANGUAGES */
langs?: string[];
}
/** @link https://ld246.com/article/1549638745630#options-preview-math */
interface IMath {
/** 内联数学公式起始 $ 后是否允许数字。默认值: false */
inlineDigit?: boolean;
/** 使用 MathJax 渲染时传入的宏定义。默认值: {} */
macros?: object;
/** 数学公式渲染引擎。默认值: 'KaTeX' */
engine?: "KaTeX" | "MathJax";
/** 数学公式渲染引擎为 MathJax 时传入的参数 */
mathJaxOptions?: any;
}
/** @link https://ld246.com/article/1549638745630#options-preview-markdown */
interface IMarkdownConfig {
/** 自动空格。默认值: false */
autoSpace?: boolean;
/** 段落开头是否空两格。默认值: false */
paragraphBeginningSpace?: boolean;
/** 自动矫正术语。默认值: false */
fixTermTypo?: boolean;
/** 插入目录。默认值: false */
toc?: boolean;
/** 脚注。默认值: true */
footnotes?: boolean;
/** wysiwyg & ir 模式代码块是否渲染。默认值: true */
codeBlockPreview?: boolean;
/** wysiwyg & ir 模式数学公式块是否渲染。默认值: true */
mathBlockPreview?: boolean;
/** 是否启用过滤 XSS。默认值: true */
sanitize?: boolean;
/** 链接相对路径前缀。默认值:'' */
linkBase?: string;
/** 链接强制前缀。默认值:'' */
linkPrefix?: string;
/** 为列表添加标记,以便[自定义列表样式](https://github.com/Vanessa219/vditor/issues/390) 默认值:false */
listStyle?: boolean;
/** 支持 mark 标记 */
mark?: boolean;
/** 支持自动链接 */
gfmAutoLink?: boolean;
}
/** @link https://ld246.com/article/1549638745630#options-preview */
interface IPreview {
/**
* 预览 debounce 毫秒间隔
* @default 1000
*/
delay?: number;
/**
* 预览区域最大宽度
* @default 800
*/
maxWidth?: number;
/**
* 显示模式
* @default "both"
*/
mode?: "both" | "editor";
/** md 解析请求 */
url?: string;
/** @link https://ld246.com/article/1549638745630#options-preview-hljs */
hljs?: IHljs;
/** @link https://ld246.com/article/1549638745630#options-preview-math */
math?: IMath;
/** @link https://ld246.com/article/1549638745630#options-preview-markdown */
markdown?: IMarkdownConfig;
/** @link https://ld246.com/article/1549638745630#options-preview-theme */
theme?: IPreviewTheme;
/**
* @link https://ld246.com/article/1549638745630#options-preview-actions
* @default ["desktop", "tablet", "mobile", "mp-wechat", "zhihu"]
*/
actions?: Array<IPreviewAction | IPreviewActionCustom>;
/** 预览回调 */
parse?(element: HTMLElement): void;
/** 渲染之前回调 */
transform?(html: string): string;
}
type IPreviewAction = "desktop" | "tablet" | "mobile" | "mp-wechat" | "zhihu";
interface IPreviewActionCustom {
/** 键名 */
key: string;
/** 按钮文本 */
text: string;
/** 按钮 className 值 */
className?: string;
/** 按钮提示信息 */
tooltip?: string;
/** 点击回调 */
click: (key: string) => void;
}
interface IPreviewOptions {
mode: "dark" | "light";
customEmoji?: IObject;
lang?: (keyof II18n);
i18n?: ITips;
lazyLoadImage?: string;
emojiPath?: string;
hljs?: IHljs;
speech?: {
enable?: boolean,
};
anchor?: number; // 0: no render, 1: render left, 2: render right
math?: IMath;
cdn?: string;
dist?: string;
staticPath?: IStaticPath;
markdown?: IMarkdownConfig;
renderers?: ILuteRender;
theme?: IPreviewTheme;
icon?: "ant" | "material" | undefined;
transform?(html: string): string;
after?(): void;
}
interface IHintData {
html: string;
value: string;
}
interface IHintExtend {
key: string;
hint?(value: string): IHintData[] | Promise<IHintData[]>;
}
/** @link https://ld246.com/article/1549638745630#options-hint */
interface IHint {
/** 提示内容是否进行 md 解析 */
parse?: boolean;
/** 常用表情提示 HTML */
emojiTail?: string;
/** 提示 debounce 毫秒间隔。默认值: 200 */
delay?: number;
/** 默认表情,可从 [lute/emoji_map](https://github.com/88250/lute/blob/master/parse/emoji_map.go#L32) 中选取,也可自定义 */
emoji?: IObject;
/** 表情图片地址。默认值: 'https://unpkg.com/vditor@${VDITOR_VERSION}/dist/images/emoji' */
emojiPath?: string;
extend?: IHintExtend[];
}
/** @link https://ld246.com/article/1549638745630#options-toolbarConfig */
interface IToolbarConfig {
/** 是否隐藏工具栏。默认值: false */
hide?: boolean;
/** 是否固定工具栏。默认值: false */
pin?: boolean;
}
/** @link https://ld246.com/article/1549638745630#options-comment */
interface IComment {
/** 是否启用评论模式。默认值: false */
enable: boolean;
/** 添加评论回调 */
add?(id: string, text: string, commentsData: ICommentsData[]): void;
/** 删除评论回调 */
remove?(ids: string[]): void;
/** 滚动回调 */
scroll?(top: number): void;
/** 文档修改时,适配评论高度 */
adjustTop?(commentsData: ICommentsData[]): void;
}
/** @link https://ld246.com/article/1549638745630#options-outline */
interface IOutline {
/** 初始化是否展现大纲。默认值: false */
enable: boolean;
/** 大纲位置:'left', 'right'。默认值: 'left' */
position: "left" | "right";
}
interface IResize {
position?: string;
enable?: boolean;
after?(height: number): void;
}
interface IStaticPath {
/**
* 文件
* @default `${baseURL}/images/logo.png`
*/
logo?: string;
/**
* 文件
* @default `${baseURL}/method.min.js`
*/
method?: string;
/**
* 文件
* @default `${baseURL}/index.css`
*/
style?: string;
/**
* 目录
* @default `${baseURL}/images/emoji`
*/
emoji?: string;
/**
* 目录
* @default `${baseURL}/js/i18n`
*/
i18n?: string;
/**
* 目录
* @default `${baseURL}/js/icons`
*/
icons?: string;
/**
* 目录
* @default `${baseURL}/css/content-theme`
*/
theme?: string;
/** 文件
* @default `${baseURL}/js/abcjs/abcjs_basic.js/abcjs/abcjs_basic.min.js`
*/
abc?: string;
/** 文件
* @default `${baseURL}/js/echarts/echarts.min.js`
*/
echarts?: string;
/** 文件
* @default `${baseURL}/js/js/flowchart.js/flowchart.min.js`
*/
flowchart?: string;
/** 文件
* @default `${baseURL}/js/graphviz/viz.js`
*/
graphviz?: string;
/** 文件
* @default `${baseURL}/js/lute/lute.min.js`
*/
lute?: string;
/** 文件
* @default `${baseURL}/js/markmap/markmap.min.js`
*/
markmap?: string;
/** 文件
* @default `${baseURL}/js/mermaid/mermaid.min.js`
*/
mermaid?: string;
/** 文件
* @default `${baseURL}/js/plantuml/plantuml-encoder.min.js`
*/
plantuml?: string;
/**
* 目录
* @default `${baseURL}/js/highlight.js`
*/
highlight?: string;
/**
* 目录
* @default `${baseURL}/js/katex`
*/
katex?: string;
/**
* 目录
* @default `${baseURL}/js/mathjax`
*/
mathjax?: string;
}
/** @link https://ld246.com/article/1549638745630#options */
interface IOptions {
/** RTL */
rtl?: boolean;
/** 历史记录间隔 */
undoDelay?: number;
/** 内部调试时使用 */
_lutePath?: string;
/**
* 自定义静态资源基础路径
* @default
* `${cdn}/${dist}`
* `${cdn}/dist`
* `https://unpkg.com/vditor@${VDITOR_VERSION}/dist`
*/
_baseURL?: string,
/**
* 自定义静态资源路径
*/
_staticPath?: IStaticPath,
/** 编辑器初始化值。默认值: '' */
value?: string;
/** 是否显示日志。默认值: false */
debugger?: boolean;
/** 是否启用打字机模式。默认值: false */
typewriterMode?: boolean;
/** 编辑器总高度。默认值: 'auto' */
height?: number | string;
/** 编辑器最小高度 */
minHeight?: number;
/** 编辑器总宽度,支持 %。默认值: 'auto' */
width?: number | string;
/** 输入区域为空时的提示。默认值: '' */
placeholder?: string;
/** 多语言。默认值: 'zh_CN' */
lang?: (keyof II18n);
/** 国际化, 自定义语言。优先级低于lang */
i18n?: ITips;
/** @link https://ld246.com/article/1549638745630#options-fullscreen */
fullscreen?: {
/** 全屏层级。默认值: 90 */
index: number;
};
/** @link https://ld246.com/article/1549638745630#options-toolbar */
toolbar?: Array<string | IMenuItem>;
/** @link https://ld246.com/article/1549638745630#options-resize */
resize?: IResize;
/** @link https://ld246.com/article/1549638745630#options-counter */
counter?: {
/** 是否启用计数器。默认值: false */
enable: boolean;
/** 允许输入的最大值 */
max?: number;
/** 统计类型。默认值: 'markdown' */
type?: "markdown" | "text";
/** 字数统计回调。 */
after?(length: number, counter: {
/** 是否启用计数器。默认值: false */
enable: boolean;
/** 允许输入的最大值 */
max?: number;
/** 统计类型。默认值: 'markdown' */
type?: "markdown" | "text"
}): void
};
/** @link https://ld246.com/article/1549638745630#options-cache */
cache?: {
/** 缓存 key,第一个参数为元素且启用缓存时必填 */
id?: string;
/** 是否使用 localStorage 进行缓存。默认值: true */
enable?: boolean;
/** 缓存后的回调 */
after?(markdown: string): void;
};
/** 编辑模式。默认值: 'wysiwyg'
*
* wysiwyg: 所见即所得
*
* ir: 即时渲染
*
* sv: 分屏预览
*/
mode?: "wysiwyg" | "sv" | "ir";
/** @link https://ld246.com/article/1549638745630#options-preview */
preview?: IPreview;
/** @link https://ld246.com/article/1549638745630#options-link */
link?: {
/** 是否打开链接地址。默认值: true */
isOpen?: boolean;
/** 点击链接事件 */
click?: (bom: Element) => void;
},
/** @link https://ld246.com/article/1549638745630#options-image */
image?: {
/** 是否预览图片。默认值: true */
isPreview?: boolean;
/** 图片预览处理 */
preview?: (bom: Element) => void;
},
/** @link https://ld246.com/article/1549638745630#options-hint */
hint?: IHint;
/** @link https://ld246.com/article/1549638745630#options-toolbarConfig */
toolbarConfig?: IToolbarConfig;
/** 评论
* @link https://ld246.com/article/1549638745630#options-comment
*/
comment?: IComment;
/** 主题。默认值: 'classic' */
theme?: "classic" | "dark";
/** 图标。默认值: 'ant' */
icon?: "ant" | "material";
/** @link https://ld246.com/article/1549638745630#options-upload */
upload?: IUpload;
/** @link https://ld246.com/article/1549638745630#options-classes */
classes?: IClasses;
/** 配置自建 CDN 地址。默认值: 'https://unpkg.com/vditor@${VDITOR_VERSION}' */
cdn?: string;
/**
* 自定义 dist 目录路径
* @default "dist"
*/
dist?: string,
/** tab 键操作字符串,支持 \t 及任意字符串 */
tab?: string;
/** @link https://ld246.com/article/1549638745630#options-outline */
outline?: IOutline;
/** 编辑器异步渲染完成后的回调方法 */
after?(): void;
/** 输入后触发 */
input?(value: string): void;
/** 聚焦后触发 */
focus?(value: string): void;
/** 失焦后触发 */
blur?(value: string): void;
/** 按下键盘触发 */
keydown?(event: KeyboardEvent): void;
/** `esc` 按下后触发 */
esc?(value: string): void;
/** `⌘/ctrl+enter` 按下后触发 */
ctrlEnter?(value: string): void;
/** 编辑器中选中文字后触发 */
select?(value: string): void;
}
interface IMergedOptions extends IOptions {
baseURL: string;
staticPath: Required<IStaticPath>;
}
interface IEChart {
setOption(option: any): void;
resize(): void;
}
interface IVditor {
element: HTMLElement;
options: IMergedOptions;
originalInnerHTML: string;
lute: Lute;
currentMode: "sv" | "wysiwyg" | "ir";
devtools?: {
element: HTMLDivElement,
renderEchart(vditor: IVditor): void,
};
outline: {
element: HTMLElement,
render(vditor: IVditor): string,
toggle(vditor: IVditor, show?: boolean, focus?: boolean): void,
};
toolbar?: {
elements?: { [key: string]: HTMLElement },
element?: HTMLElement,
};
preview?: {
element: HTMLElement
actionElement?: HTMLElement
previewElement: HTMLElement
render(vditor: IVditor, value?: string): void,
};
counter?: {
element: HTMLElement
render(vditor: IVditor, mdText?: string): void,
};
resize?: {
element: HTMLElement,
};
hint: {
timeId: number
element: HTMLDivElement
recentLanguage: string
fillEmoji(element: HTMLElement, vditor: IVditor): void
render(vditor: IVditor): void,
genHTML(data: IHintData[], key: string, vditor: IVditor): void
select(event: KeyboardEvent, vditor: IVditor): boolean,
};
tip: {
element: HTMLElement
show(text: string, time?: number): void
hide(): void,
};
upload?: {
element: HTMLElement
isUploading: boolean
range: Range,
};
undo?: {
clearStack(vditor: IVditor): void,
redo(vditor: IVditor): void
undo(vditor: IVditor): void
addToUndoStack(vditor: IVditor): void
recordFirstPosition(vditor: IVditor, event: KeyboardEvent): void,
resetIcon(vditor: IVditor): void,
};
wysiwyg?: {
range: Range,
element: HTMLPreElement,
selectPopover: HTMLDivElement,
popover: HTMLDivElement,
afterRenderTimeoutId: number,
hlToolbarTimeoutId: number,
preventInput: boolean,
composingLock: boolean,
commentIds: string[]
getComments(vditor: IVditor, getData?: boolean): ICommentsData[],
triggerRemoveComment(vditor: IVditor): void,
showComment(): void,
hideComment(): void,
unbindListener(): void,
};
ir?: {
range: Range,
element: HTMLPreElement,
composingLock: boolean,
preventInput: boolean,
processTimeoutId: number,
hlToolbarTimeoutId: number,
};
sv?: {
range: Range,
element: HTMLPreElement,
processTimeoutId: number,
hlToolbarTimeoutId: number,
composingLock: boolean,
preventInput: boolean,
};
}
interface ICommentsData {
id: string;
top: number;
}