diff --git a/docs/src/demos/Examples/CodeBlockLanguage/index.vue b/docs/src/demos/Examples/CodeBlockLanguage/index.vue index a1e8fbfe..2179ef41 100644 --- a/docs/src/demos/Examples/CodeBlockLanguage/index.vue +++ b/docs/src/demos/Examples/CodeBlockLanguage/index.vue @@ -16,10 +16,10 @@ import Text from '@tiptap/extension-text' import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight' import CodeBlockComponent from './CodeBlockComponent' -// install all highlight.js languages -import 'lowlight' +// load all highlight.js languages +import lowlight from 'lowlight' -// or install specific languages only +// load specific languages only // import lowlight from 'lowlight/lib/core' // import javascript from 'highlight.js/lib/languages/javascript' // lowlight.registerLanguage('javascript', javascript) @@ -41,11 +41,13 @@ export default { Document, Paragraph, Text, - CodeBlockLowlight.extend({ - addNodeView() { - return VueNodeViewRenderer(CodeBlockComponent) - }, - }), + CodeBlockLowlight + .extend({ + addNodeView() { + return VueNodeViewRenderer(CodeBlockComponent) + }, + }) + .configure({ lowlight }), ], content: `
diff --git a/docs/src/demos/Nodes/CodeBlockLowlight/index.vue b/docs/src/demos/Nodes/CodeBlockLowlight/index.vue index 69976deb..603082d9 100644 --- a/docs/src/demos/Nodes/CodeBlockLowlight/index.vue +++ b/docs/src/demos/Nodes/CodeBlockLowlight/index.vue @@ -15,10 +15,10 @@ import Paragraph from '@tiptap/extension-paragraph' import Text from '@tiptap/extension-text' import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight' -// install all highlight.js languages -import 'lowlight' +// load all highlight.js languages +import lowlight from 'lowlight' -// or install specific languages only +// load specific languages only // import lowlight from 'lowlight/lib/core' // import javascript from 'highlight.js/lib/languages/javascript' // lowlight.registerLanguage('javascript', javascript) @@ -40,7 +40,9 @@ export default { Document, Paragraph, Text, - CodeBlockLowlight, + CodeBlockLowlight.configure({ + lowlight, + }), ], content: `
diff --git a/packages/extension-code-block-lowlight/src/code-block-lowlight.ts b/packages/extension-code-block-lowlight/src/code-block-lowlight.ts
index 2deb1d70..115be13c 100644
--- a/packages/extension-code-block-lowlight/src/code-block-lowlight.ts
+++ b/packages/extension-code-block-lowlight/src/code-block-lowlight.ts
@@ -1,11 +1,24 @@
-import CodeBlock from '@tiptap/extension-code-block'
+import lowlight from 'lowlight/lib/core'
+import CodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block'
import { LowlightPlugin } from './lowlight-plugin'
-export const CodeBlockLowlight = CodeBlock.extend({
+export interface CodeBlockLowlightOptions extends CodeBlockOptions {
+ lowlight: any,
+}
+
+export const CodeBlockLowlight = CodeBlock.extend