add horizontal rule, fix #170

This commit is contained in:
Philipp Kühn
2019-01-19 09:57:46 +01:00
parent 0cf905abb9
commit 3b87dc9e57
4 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import { Node } from 'tiptap'
export default class HorizontalRule extends Node {
get name() {
return 'horizontal_rule'
}
get schema() {
return {
group: 'block',
parseDOM: [{ tag: 'hr' }],
toDOM: () => ['hr'],
}
}
commands({ type }) {
return () => (state, dispatch) => dispatch(state.tr.replaceSelectionWith(type.create()))
}
}