mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-23 00:27:49 +08:00
38 lines
832 B
TypeScript
38 lines
832 B
TypeScript
import { Command, Node } from '@tiptap/core'
|
|
import { wrappingInputRule } from 'prosemirror-inputrules'
|
|
|
|
export type BlockquoteCommand = () => Command
|
|
|
|
declare module '@tiptap/core/src/Editor' {
|
|
interface Commands {
|
|
blockquote: BlockquoteCommand,
|
|
}
|
|
}
|
|
|
|
export const inputRegex = /^\s*>\s$/gm
|
|
|
|
export default new Node()
|
|
.name('blockquote')
|
|
.schema(() => ({
|
|
content: 'block*',
|
|
group: 'block',
|
|
defining: true,
|
|
draggable: false,
|
|
parseDOM: [
|
|
{ tag: 'blockquote' },
|
|
],
|
|
toDOM: () => ['blockquote', 0],
|
|
}))
|
|
.commands(({ name }) => ({
|
|
[name]: () => ({ commands }) => {
|
|
return commands.toggleWrap(name)
|
|
},
|
|
}))
|
|
.keys(({ editor }) => ({
|
|
'Shift-Mod-9': () => editor.blockquote(),
|
|
}))
|
|
.inputRules(({ type }) => [
|
|
wrappingInputRule(inputRegex, type),
|
|
])
|
|
.create()
|