diff --git a/docs/src/demos/Examples/CodeBlockLanguage/index.vue b/docs/src/demos/Examples/CodeBlockLanguage/index.vue index 1646588731..11b0106568 100644 --- a/docs/src/demos/Examples/CodeBlockLanguage/index.vue +++ b/docs/src/demos/Examples/CodeBlockLanguage/index.vue @@ -17,10 +17,10 @@ import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight' import CodeBlockComponent from './CodeBlockComponent' // load all highlight.js languages -import lowlight from 'lowlight' +import { lowlight } from 'lowlight' // load specific languages only -// import lowlight from 'lowlight/lib/core' +// import { lowlight } from 'lowlight/lib/core' // import javascript from 'highlight.js/lib/languages/javascript' // lowlight.registerLanguage('javascript', javascript) diff --git a/docs/src/demos/Nodes/CodeBlockLowlight/index.vue b/docs/src/demos/Nodes/CodeBlockLowlight/index.vue index 916987effa..cea4965725 100644 --- a/docs/src/demos/Nodes/CodeBlockLowlight/index.vue +++ b/docs/src/demos/Nodes/CodeBlockLowlight/index.vue @@ -16,10 +16,10 @@ import Text from '@tiptap/extension-text' import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight' // load all highlight.js languages -import lowlight from 'lowlight' +import { lowlight } from 'lowlight' // load specific languages only -// import lowlight from 'lowlight/lib/core' +// import { lowlight } from 'lowlight/lib/core' // import javascript from 'highlight.js/lib/languages/javascript' // lowlight.registerLanguage('javascript', javascript) diff --git a/packages/extension-code-block-lowlight/package.json b/packages/extension-code-block-lowlight/package.json index f0c26af880..b45d0c5351 100644 --- a/packages/extension-code-block-lowlight/package.json +++ b/packages/extension-code-block-lowlight/package.json @@ -25,8 +25,7 @@ }, "dependencies": { "@tiptap/extension-code-block": "^2.0.0-beta.15", - "@types/lowlight": "^0.0.2", - "lowlight": "^1.20.0", + "lowlight": "^2.0.1", "prosemirror-model": "^1.14.1", "prosemirror-state": "^1.3.4", "prosemirror-view": "^1.18.7" 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 adb73639a6..b2f72c8f93 100644 --- a/packages/extension-code-block-lowlight/src/code-block-lowlight.ts +++ b/packages/extension-code-block-lowlight/src/code-block-lowlight.ts @@ -1,4 +1,4 @@ -import lowlight from 'lowlight/lib/core' +import { lowlight } from 'lowlight/lib/core' import CodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block' import { LowlightPlugin } from './lowlight-plugin' diff --git a/packages/extension-code-block-lowlight/src/lowlight-plugin.ts b/packages/extension-code-block-lowlight/src/lowlight-plugin.ts index f0aa9b26be..25e24e6dcd 100644 --- a/packages/extension-code-block-lowlight/src/lowlight-plugin.ts +++ b/packages/extension-code-block-lowlight/src/lowlight-plugin.ts @@ -34,8 +34,8 @@ function getDecorations({ doc, name, lowlight }: { doc: ProsemirrorNode, name: s const { language } = block.node.attrs const languages = lowlight.listLanguages() const nodes = language && languages.includes(language) - ? lowlight.highlight(language, block.node.textContent).value - : lowlight.highlightAuto(block.node.textContent).value + ? lowlight.highlight(language, block.node.textContent).children + : lowlight.highlightAuto(block.node.textContent).children parseNodes(nodes).forEach(node => { const to = from + node.text.length