mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-21 15:28:09 +08:00
24 lines
492 B
TypeScript
24 lines
492 B
TypeScript
import { Node } from '@tiptap/core'
|
|
|
|
export default new Node()
|
|
.name('codeBlock')
|
|
.schema(() => ({
|
|
content: 'text*',
|
|
marks: '',
|
|
group: 'block',
|
|
code: true,
|
|
defining: true,
|
|
draggable: false,
|
|
parseDOM: [
|
|
{ tag: 'pre', preserveWhitespace: 'full' },
|
|
],
|
|
toDOM: () => ['pre', ['code', 0]],
|
|
}))
|
|
.commands(({ editor, name }) => ({
|
|
[name]: next => attrs => {
|
|
editor.toggleNode(name, 'paragraph', attrs)
|
|
next()
|
|
},
|
|
}))
|
|
.create()
|