2021-04-12 22:20:49 +08:00
|
|
|
import lowlight from 'lowlight/lib/core'
|
|
|
|
import CodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block'
|
2021-04-02 06:07:40 +08:00
|
|
|
import { LowlightPlugin } from './lowlight-plugin'
|
|
|
|
|
2021-04-12 22:20:49 +08:00
|
|
|
export interface CodeBlockLowlightOptions extends CodeBlockOptions {
|
|
|
|
lowlight: any,
|
|
|
|
}
|
|
|
|
|
|
|
|
export const CodeBlockLowlight = CodeBlock.extend<CodeBlockLowlightOptions>({
|
|
|
|
defaultOptions: {
|
|
|
|
...CodeBlock.config.defaultOptions,
|
|
|
|
lowlight,
|
|
|
|
},
|
|
|
|
|
2021-04-02 06:07:40 +08:00
|
|
|
addProseMirrorPlugins() {
|
|
|
|
return [
|
2021-04-12 17:11:02 +08:00
|
|
|
...this.parentConfig.addProseMirrorPlugins?.() || [],
|
2021-04-12 22:20:49 +08:00
|
|
|
LowlightPlugin({
|
|
|
|
name: 'codeBlock',
|
|
|
|
lowlight: this.options.lowlight,
|
|
|
|
}),
|
2021-04-02 06:07:40 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
})
|