StrikeMark added

This commit is contained in:
Chrissi2812
2018-09-06 12:22:33 +02:00
parent 518413e33f
commit e91c76334d
4 changed files with 59 additions and 0 deletions

View File

@@ -14,5 +14,6 @@ export { default as BoldMark } from './marks/Bold'
export { default as CodeMark } from './marks/Code'
export { default as ItalicMark } from './marks/Italic'
export { default as LinkMark } from './marks/Link'
export { default as StrikeMark } from './marks/Strike'
export { default as HistoryExtension } from './extensions/History'

View File

@@ -0,0 +1,47 @@
import { Mark } from 'tiptap'
import { toggleMark, markInputRule } from 'tiptap-commands'
export default class StrikeMark extends Mark {
get name() {
return 'strike'
}
get schema() {
return {
parseDOM: [
{
tag: 's',
},
{
tag: 'del',
},
{
tag: 'strike',
},
{
style: 'text-decoration',
getAttrs: value => value === 'line-through',
},
],
toDOM: () => ['s', 0],
}
}
keys({ type }) {
return {
'Mod-d': toggleMark(type),
}
}
command({ type }) {
return toggleMark(type)
}
inputRules({ type }) {
return [
markInputRule(/~([^~]+)~$/, type),
]
}
}