add basic text align extension
This commit is contained in:
27
packages/extension-text-align/index.ts
Normal file
27
packages/extension-text-align/index.ts
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user