2020-10-23 04:40:40 +08:00
|
|
|
import { Command, createNode } from '@tiptap/core'
|
2020-04-27 15:06:42 +08:00
|
|
|
// import ParagraphComponent from './paragraph.vue'
|
2020-03-06 03:30:58 +08:00
|
|
|
|
2020-10-23 04:40:40 +08:00
|
|
|
const Paragraph = createNode({
|
2020-10-21 21:17:05 +08:00
|
|
|
name: 'paragraph',
|
|
|
|
|
|
|
|
group: 'block',
|
|
|
|
|
|
|
|
content: 'inline*',
|
2020-10-12 16:32:54 +08:00
|
|
|
|
2020-10-22 18:34:49 +08:00
|
|
|
// addGlobalAttributes() {
|
|
|
|
// return [
|
|
|
|
// {
|
|
|
|
// types: ['paragraph'],
|
|
|
|
// attributes: {
|
|
|
|
// align: {
|
|
|
|
// default: 'right',
|
|
|
|
// renderHTML: attributes => ({
|
|
|
|
// class: 'global',
|
|
|
|
// style: `text-align: ${attributes.align}`,
|
|
|
|
// }),
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// ]
|
|
|
|
// },
|
2020-10-22 05:55:14 +08:00
|
|
|
|
2020-10-22 18:34:49 +08:00
|
|
|
// addAttributes() {
|
|
|
|
// return {
|
|
|
|
// id: {
|
|
|
|
// default: '123',
|
|
|
|
// rendered: true,
|
|
|
|
// renderHTML: attributes => ({
|
|
|
|
// class: `foo-${attributes.id}`,
|
|
|
|
// id: 'foo',
|
|
|
|
// }),
|
|
|
|
// },
|
|
|
|
// }
|
|
|
|
// },
|
2020-10-22 05:32:28 +08:00
|
|
|
|
2020-10-10 04:59:25 +08:00
|
|
|
parseHTML() {
|
|
|
|
return [
|
|
|
|
{ tag: 'p' },
|
|
|
|
]
|
2020-10-21 21:17:05 +08:00
|
|
|
},
|
2020-10-10 04:59:25 +08:00
|
|
|
|
2020-10-21 21:17:05 +08:00
|
|
|
renderHTML({ attributes }) {
|
|
|
|
return ['p', attributes, 0]
|
|
|
|
},
|
2020-10-22 15:42:28 +08:00
|
|
|
|
2020-10-22 17:14:44 +08:00
|
|
|
addCommands() {
|
2020-10-22 15:42:28 +08:00
|
|
|
return {
|
2020-10-23 04:40:40 +08:00
|
|
|
paragraph: (): Command => ({ commands }) => {
|
2020-10-22 15:42:28 +08:00
|
|
|
return commands.toggleBlockType('paragraph', 'paragraph')
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-22 17:14:44 +08:00
|
|
|
addKeyboardShortcuts() {
|
2020-10-22 15:42:28 +08:00
|
|
|
return {
|
|
|
|
'Mod-Alt-0': () => this.editor.paragraph(),
|
|
|
|
}
|
|
|
|
},
|
2020-10-21 21:17:05 +08:00
|
|
|
})
|
2020-10-23 04:40:40 +08:00
|
|
|
|
|
|
|
export default Paragraph
|
|
|
|
|
|
|
|
declare module '@tiptap/core/src/Editor' {
|
|
|
|
interface AllExtensions {
|
|
|
|
Paragraph: typeof Paragraph,
|
|
|
|
}
|
|
|
|
}
|