tiptap/packages/extension-text-align/index.ts

28 lines
528 B
TypeScript
Raw Normal View History

2020-10-23 21:23:40 +08:00
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,
}
}