add basic extension classes

This commit is contained in:
Philipp Kühn
2020-10-09 22:59:25 +02:00
parent a4ccb36e10
commit 8324f57528
13 changed files with 421 additions and 266 deletions

View File

@@ -1,29 +1,49 @@
import { Command, Node } from '@tiptap/core'
// import ParagraphComponent from './paragraph.vue'
export type ParagraphCommand = () => Command
// export type ParagraphCommand = () => Command
declare module '@tiptap/core/src/Editor' {
interface Commands {
paragraph: ParagraphCommand,
// declare module '@tiptap/core/src/Editor' {
// interface Commands {
// paragraph: ParagraphCommand,
// }
// }
// export default new Node()
// .name('paragraph')
// .schema(() => ({
// content: 'inline*',
// group: 'block',
// parseDOM: [{ tag: 'p' }],
// toDOM: () => ['p', 0],
// // toVue: ParagraphComponent,
// }))
// .commands(({ name }) => ({
// [name]: () => ({ commands }) => {
// return commands.toggleBlockType(name, 'paragraph')
// },
// }))
// .keys(({ editor }) => ({
// 'Mod-Alt-0': () => editor.paragraph(),
// }))
// .create()
export default class Paragraph extends Node {
name = 'paragraph'
group = 'block'
content = 'inline*'
parseHTML() {
return [
{ tag: 'p' },
]
}
}
export default new Node()
.name('paragraph')
.schema(() => ({
content: 'inline*',
group: 'block',
parseDOM: [{ tag: 'p' }],
toDOM: () => ['p', 0],
// toVue: ParagraphComponent,
}))
.commands(({ name }) => ({
[name]: () => ({ commands }) => {
return commands.toggleBlockType(name, 'paragraph')
},
}))
.keys(({ editor }) => ({
'Mod-Alt-0': () => editor.paragraph(),
}))
.create()
renderHTML() {
return ['p', 0]
}
}