prevent empty decorations

This commit is contained in:
Philipp Kühn 2021-04-08 22:44:40 +02:00
parent 08bc5c3d81
commit b48da13665

View File

@ -42,11 +42,14 @@ function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) {
parseNodes(nodes).forEach(node => {
const to = from + node.text.length
const decoration = Decoration.inline(from, to, {
class: node.classes.join(' '),
})
decorations.push(decoration)
if (node.classes.length) {
const decoration = Decoration.inline(from, to, {
class: node.classes.join(' '),
})
decorations.push(decoration)
}
from = to
})