Files
tiptap/packages/tiptap-extensions/src/nodes/BulletList.js
2018-09-23 08:04:02 +02:00

38 lines
611 B
JavaScript

import { Node } from 'tiptap'
import { wrappingInputRule, toggleList } from 'tiptap-commands'
export default class BulletNode extends Node {
get name() {
return 'bullet_list'
}
get schema() {
return {
content: 'list_item+',
group: 'block',
parseDOM: [
{ tag: 'ul' },
],
toDOM: () => ['ul', 0],
}
}
command({ type, schema }) {
return toggleList(type, schema.nodes.list_item)
}
keys({ type, schema }) {
return {
'Shift-Ctrl-8': toggleList(type, schema.nodes.list_item),
}
}
inputRules({ type }) {
return [
wrappingInputRule(/^\s*([-+*])\s$/, type),
]
}
}