fix a bug for removing code blocks

This commit is contained in:
Philipp Kühn
2019-02-01 17:54:35 +01:00
parent fce6d9dac9
commit 996b3c4dde

View File

@@ -122,12 +122,12 @@ export default class CodeBlockHighlight extends Node {
init(_, { doc }) {
return getDecorations(doc)
},
apply(transaction, decorationSet) {
apply(transaction, decorationSet, oldState) {
// TODO: find way to cache decorations
// see: https://discuss.prosemirror.net/t/how-to-update-multiple-inline-decorations-on-node-change/1493
const currentNodeName = transaction.curSelection.$head.parent.type.name
if (transaction.docChanged && currentNodeName === 'code_block') {
const previousNodeName = oldState.selection.$head.parent.type.name
if (transaction.docChanged && previousNodeName === 'code_block') {
return getDecorations(transaction.doc)
}