fix a big in highlighter
This commit is contained in:
@@ -23,11 +23,7 @@ const findBlockNodes = (doc: ProsemirrorNode) => {
|
|||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
|
function parseNodes(nodes: any[], className: string[] = []): any {
|
||||||
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 => {
|
return nodes.map(node => {
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
@@ -44,7 +40,11 @@ function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
|
|||||||
classes,
|
classes,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 => {
|
blocks.forEach(block => {
|
||||||
let startPos = block.pos + 1
|
let startPos = block.pos + 1
|
||||||
@@ -57,7 +57,7 @@ function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
|
|||||||
: low.highlightAuto(block.node.textContent).value
|
: low.highlightAuto(block.node.textContent).value
|
||||||
|
|
||||||
parseNodes(nodes)
|
parseNodes(nodes)
|
||||||
.flat()
|
.flat(Infinity)
|
||||||
.map((node: any) => {
|
.map((node: any) => {
|
||||||
const from = startPos
|
const from = startPos
|
||||||
const to = from + node.text.length
|
const to = from + node.text.length
|
||||||
|
|||||||
Reference in New Issue
Block a user