mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-03 00:07:50 +08:00
0c9ce26c02
This reverts commit 24c3a9abd3
.
# Conflicts:
# packages/core/src/Editor.ts
55 lines
892 B
TypeScript
55 lines
892 B
TypeScript
import { Command, Node } from '@tiptap/core'
|
|
|
|
export interface ParagraphOptions {
|
|
HTMLAttributes: {
|
|
[key: string]: any
|
|
},
|
|
}
|
|
|
|
const Paragraph = Node.create({
|
|
name: 'paragraph',
|
|
|
|
defaultOptions: <ParagraphOptions>{
|
|
HTMLAttributes: {},
|
|
},
|
|
|
|
group: 'block',
|
|
|
|
content: 'inline*',
|
|
|
|
parseHTML() {
|
|
return [
|
|
{ tag: 'p' },
|
|
]
|
|
},
|
|
|
|
renderHTML({ HTMLAttributes }) {
|
|
return ['p', HTMLAttributes, 0]
|
|
},
|
|
|
|
addCommands() {
|
|
return {
|
|
/**
|
|
* Toggle a paragraph
|
|
*/
|
|
paragraph: (): Command => ({ commands }) => {
|
|
return commands.toggleBlockType('paragraph', 'paragraph')
|
|
},
|
|
}
|
|
},
|
|
|
|
addKeyboardShortcuts() {
|
|
return {
|
|
'Mod-Alt-0': () => this.editor.commands.paragraph(),
|
|
}
|
|
},
|
|
})
|
|
|
|
export default Paragraph
|
|
|
|
declare module '@tiptap/core' {
|
|
interface AllExtensions {
|
|
Paragraph: typeof Paragraph,
|
|
}
|
|
}
|