-
-
Notifications
You must be signed in to change notification settings - Fork 432
/
Copy pathconfig.ts
42 lines (38 loc) · 1.25 KB
/
config.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
import { $ctx } from '@milkdown/utils'
import type { Extension } from '@codemirror/state'
import type { LanguageDescription } from '@codemirror/language'
import { withMeta } from '../__internal__/meta'
export interface CodeBlockConfig {
extensions: Extension[]
languages: LanguageDescription[]
expandIcon: () => string
searchIcon: () => string
clearSearchIcon: () => string
searchPlaceholder: string
noResultText: string
renderLanguage: (language: string, selected: boolean) => string
renderPreview: (
language: string,
content: string
) => null | string | HTMLElement
previewToggleButton: (previewOnlyMode: boolean) => string
previewLabel: () => string
}
export const defaultConfig: CodeBlockConfig = {
extensions: [],
languages: [],
expandIcon: () => '⬇',
searchIcon: () => '🔍',
clearSearchIcon: () => '⌫',
searchPlaceholder: 'Search language',
noResultText: 'No result',
renderLanguage: (language) => language,
renderPreview: () => null,
previewToggleButton: (previewOnlyMode) => (previewOnlyMode ? 'Edit' : 'Hide'),
previewLabel: () => 'Preview',
}
export const codeBlockConfig = $ctx(defaultConfig, 'codeBlockConfigCtx')
withMeta(codeBlockConfig, {
displayName: 'Config<code-block>',
group: 'CodeBlock',
})