From 59d37f569726d9af450b315e8011bb8f1022c57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Wed, 6 Feb 2019 12:05:12 +0100 Subject: [PATCH] fix code decorations again --- packages/tiptap-extensions/src/nodes/CodeBlockHighlight.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/tiptap-extensions/src/nodes/CodeBlockHighlight.js b/packages/tiptap-extensions/src/nodes/CodeBlockHighlight.js index 20b3eeca1..85ab608cc 100644 --- a/packages/tiptap-extensions/src/nodes/CodeBlockHighlight.js +++ b/packages/tiptap-extensions/src/nodes/CodeBlockHighlight.js @@ -122,12 +122,14 @@ export default class CodeBlockHighlight extends Node { init(_, { doc }) { return getDecorations(doc) }, - apply(transaction, decorationSet, oldState) { + apply(transaction, decorationSet, oldState, state) { // TODO: find way to cache decorations // see: https://discuss.prosemirror.net/t/how-to-update-multiple-inline-decorations-on-node-change/1493 + const nodeName = state.selection.$head.parent.type.name const previousNodeName = oldState.selection.$head.parent.type.name - if (transaction.docChanged && previousNodeName === 'code_block') { + + if (transaction.docChanged && [nodeName, previousNodeName].includes('code_block')) { return getDecorations(transaction.doc) }