From 2466d3398f3cd1c64aa9a6211860a69bc253cb91 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 14 Apr 2021 12:42:58 -0700 Subject: [PATCH] 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. --- packages/tiptap-extensions/src/plugins/Highlight.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/tiptap-extensions/src/plugins/Highlight.js b/packages/tiptap-extensions/src/plugins/Highlight.js index f66b0d027..0f3528cc3 100644 --- a/packages/tiptap-extensions/src/plugins/Highlight.js +++ b/packages/tiptap-extensions/src/plugins/Highlight.js @@ -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(' '), })