remove languages option from codeblocklowlight

This commit is contained in:
Philipp Kühn
2021-04-08 22:13:50 +02:00
parent 95f31f48fd
commit bd392ee8c2
4 changed files with 35 additions and 64 deletions

View File

@@ -1,27 +1,7 @@
import CodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block'
import lowlight from 'lowlight/lib/core'
import CodeBlock from '@tiptap/extension-code-block'
import { LowlightPlugin } from './lowlight-plugin'
export interface CodeBlockLowlightOptions extends CodeBlockOptions {
languages: {
[key: string]: Function,
},
}
export const CodeBlockLowlight = CodeBlock.extend<CodeBlockLowlightOptions>({
defaultOptions: {
...CodeBlock.config.defaultOptions,
languages: {},
},
onBeforeCreate() {
Object
.entries(this.options.languages)
.forEach(([name, mapping]) => {
lowlight.registerLanguage(name, mapping)
})
},
export const CodeBlockLowlight = CodeBlock.extend({
addProseMirrorPlugins() {
return [
LowlightPlugin({ name: 'codeBlock' }),