Files
tiptap/packages/extension-code-block-lowlight/src/code-block-lowlight.ts
Enrique Alcántara 54be0e570e fix: Allow extending code-block-lowlight (#1917)
Use the extension name when initializing the
LowlightPlugin. In this way, several extensions
can make use of the same plugin

Co-authored-by: Enrique Alcantara <ealcantara@gitlab.com>
2021-09-21 09:26:11 +02:00

25 lines
587 B
TypeScript

import lowlight from 'lowlight/lib/core'
import CodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block'
import { LowlightPlugin } from './lowlight-plugin'
export interface CodeBlockLowlightOptions extends CodeBlockOptions {
lowlight: any,
}
export const CodeBlockLowlight = CodeBlock.extend<CodeBlockLowlightOptions>({
defaultOptions: {
...CodeBlock.options,
lowlight,
},
addProseMirrorPlugins() {
return [
...this.parent?.() || [],
LowlightPlugin({
name: this.name,
lowlight: this.options.lowlight,
}),
]
},
})