Merge pull request #14 from Chrissi2812/underline_mark

UnderlineMark added
This commit is contained in:
Philipp Kühn
2018-09-13 21:31:04 +02:00
committed by GitHub
4 changed files with 47 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ 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 UnderlineMark } from './marks/Underline'
export { default as HistoryExtension } from './extensions/History'
export { default as PlaceholderExtension } from './extensions/Placeholder'

View File

@@ -0,0 +1,35 @@
import { Mark } from 'tiptap'
import { toggleMark } from 'tiptap-commands'
export default class UnderlineMark extends Mark {
get name() {
return 'underline'
}
get schema() {
return {
parseDOM: [
{
tag: 'u',
},
{
style: 'text-decoration',
getAttrs: value => value === 'underline',
},
],
toDOM: () => ['u', 0],
}
}
keys({ type }) {
return {
'Mod-u': toggleMark(type),
}
}
command({ type }) {
return toggleMark(type)
}
}