@@ -25,7 +25,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@tiptap/extension-code-block": "^2.0.0-beta.15",
|
||||
"lowlight": "^2.0.1",
|
||||
"@types/lowlight": "^0.0.2",
|
||||
"lowlight": "^1.20.0",
|
||||
"prosemirror-model": "^1.14.1",
|
||||
"prosemirror-state": "^1.3.4",
|
||||
"prosemirror-view": "^1.18.7"
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Plugin, PluginKey } from 'prosemirror-state'
|
||||
import { Decoration, DecorationSet } from 'prosemirror-view'
|
||||
import { Node as ProsemirrorNode } from 'prosemirror-model'
|
||||
import { findChildren } from '@tiptap/core'
|
||||
import { lowlight as lowlightAll } from 'lowlight'
|
||||
|
||||
function parseNodes(nodes: any[], className: string[] = []): { text: string, classes: string[] }[] {
|
||||
return nodes
|
||||
@@ -35,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).children
|
||||
: lowlight.highlightAuto(block.node.textContent).children
|
||||
? lowlight.highlight(language, block.node.textContent).value
|
||||
: lowlight.highlightAuto(block.node.textContent).value
|
||||
|
||||
parseNodes(nodes).forEach(node => {
|
||||
const to = from + node.text.length
|
||||
|
||||
Reference in New Issue
Block a user