Fix sending of emptystring class for Prosemirror decoration (#1004)

Prosemirror does not handle emptystring classes well for decorations when the decoration applies to a range that has other decorations. For example, both a spellchecking plugin and the tiptap highlighting plugin.

Furthermore, there is no reason to emit empty decorations, so this change resolves that issue as well.
This commit is contained in:
Andrew Scott 2021-04-14 12:42:58 -07:00 committed by GitHub
parent d2cf88fd16
commit 2466d3398f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,6 +47,11 @@ function getDecorations({ doc, name }) {
}
})
.forEach(node => {
if (node.classes.length === 0) {
// Do not emit empty decorations.
return
}
const decoration = Decoration.inline(node.from, node.to, {
class: node.classes.join(' '),
})