add basic text align extension

This commit is contained in:
Philipp Kühn
2020-10-23 15:23:40 +02:00
parent ecadf7ea0a
commit 5976d6083c
7 changed files with 134 additions and 30 deletions

View File

@@ -0,0 +1,27 @@
import { createExtension } from '@tiptap/core'
const TextAlign = createExtension({
addGlobalAttributes() {
return [
{
types: ['paragraph'],
attributes: {
align: {
default: 'left',
renderHTML: attributes => ({
style: `text-align: ${attributes.align}`,
}),
},
},
},
]
},
})
export default TextAlign
declare module '@tiptap/core/src/Editor' {
interface AllExtensions {
TextAlign: typeof TextAlign,
}
}