Merge branch 'master' into markdown-paste

This commit is contained in:
Philipp Kühn
2019-02-01 17:56:22 +01:00
committed by GitHub
5 changed files with 35 additions and 5 deletions

View File

@@ -122,13 +122,16 @@ export default class CodeBlockHighlight extends Node {
init(_, { doc }) {
return getDecorations(doc)
},
apply(tr, set) {
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
if (tr.docChanged) {
return getDecorations(tr.doc)
const previousNodeName = oldState.selection.$head.parent.type.name
if (transaction.docChanged && previousNodeName === 'code_block') {
return getDecorations(transaction.doc)
}
return set.map(tr.mapping, tr.doc)
return decorationSet.map(transaction.mapping, transaction.doc)
},
},
props: {

View File

@@ -1,4 +1,5 @@
import { Node } from 'tiptap'
import { nodeInputRule } from 'tiptap-commands'
export default class HorizontalRule extends Node {
get name() {
@@ -16,4 +17,10 @@ export default class HorizontalRule extends Node {
commands({ type }) {
return () => (state, dispatch) => dispatch(state.tr.replaceSelectionWith(type.create()))
}
inputRules({ type }) {
return [
nodeInputRule(/^(?:---|___\s|\*\*\*\s)$/, type),
]
}
}