fix a big in highlighter
This commit is contained in:
@@ -23,10 +23,6 @@ const findBlockNodes = (doc: ProsemirrorNode) => {
|
||||
return nodes
|
||||
}
|
||||
|
||||
function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
|
||||
const decorations: Decoration[] = []
|
||||
const blocks = findBlockNodes(doc).filter(block => block.node.type.name === name)
|
||||
|
||||
function parseNodes(nodes: any[], className: string[] = []): any {
|
||||
return nodes.map(node => {
|
||||
|
||||
@@ -46,6 +42,10 @@ function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
|
||||
})
|
||||
}
|
||||
|
||||
function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
|
||||
const decorations: Decoration[] = []
|
||||
const blocks = findBlockNodes(doc).filter(block => block.node.type.name === name)
|
||||
|
||||
blocks.forEach(block => {
|
||||
let startPos = block.pos + 1
|
||||
const { language } = block.node.attrs
|
||||
@@ -57,7 +57,7 @@ function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
|
||||
: low.highlightAuto(block.node.textContent).value
|
||||
|
||||
parseNodes(nodes)
|
||||
.flat()
|
||||
.flat(Infinity)
|
||||
.map((node: any) => {
|
||||
const from = startPos
|
||||
const to = from + node.text.length
|
||||
|
||||
Reference in New Issue
Block a user