11import type { Processor } from 'unified' ;
22import type { Schema } from 'hast-util-sanitize' ;
33import type { VFile } from 'vfile' ;
4+ import type { Editor , EditorConfiguration } from 'codemirror' ;
45
56export interface EditorContext {
67 /**
78 * CodeMirror editor instance
89 */
9- editor : CodeMirror . Editor ;
10+ editor : Editor ;
1011 /**
1112 * Root element, `$('.bytemd')`
1213 */
1314 $el : HTMLElement ;
1415}
1516
17+ export interface ViewerContext {
18+ /**
19+ * Root element of the Viewer, `$('.markdown-body')`
20+ */
21+ $el : HTMLElement ;
22+ /**
23+ * Markdown process result
24+ */
25+ result : VFile ;
26+ }
27+
1628export interface BytemdToolbarItem {
1729 /**
1830 * Tooltip of toolbar item
@@ -52,16 +64,7 @@ export interface BytemdPlugin {
5264 /**
5365 * Side effect for viewer, triggers when HTML or plugin list changes
5466 */
55- viewerEffect ?( context : {
56- /**
57- * Root element of the Viewer, `$('.markdown-body')`
58- */
59- $el : HTMLElement ;
60- /**
61- * Markdown process result
62- */
63- result : VFile ;
64- } ) : void | ( ( ) => void ) ;
67+ viewerEffect ?( context : ViewerContext ) : void | ( ( ) => void ) ;
6568}
6669
6770export interface EditorProps extends ViewerProps {
@@ -84,6 +87,10 @@ export interface EditorProps extends ViewerProps {
8487 toolbar ?:
8588 | string [ ]
8689 | ( ( itemMap : Record < string , BytemdToolbarItem > ) => string [ ] ) ;
90+ /**
91+ * CodeMirror editor config
92+ */
93+ editorConfig : Omit < EditorConfiguration , 'value' | 'mode' > ;
8794}
8895
8996export interface ViewerProps {
0 commit comments