tiptap/examples/Components/Routes/TextAlign/Paragraph.js
2018-10-30 00:00:08 +01:00

35 lines
584 B
JavaScript

import { setBlockType } from 'tiptap-commands'
import { Node } from 'tiptap'
export default class Paragraph extends Node {
get name() {
return 'paragraph'
}
get schema() {
return {
attrs: {
textAlign: {
default: 'left',
},
},
content: 'inline*',
group: 'block',
draggable: false,
parseDOM: [{
tag: 'p',
getAttrs: node => ({
textAlign: node.style.textAlign,
}),
}],
toDOM: node => ['p', { style: `text-align: ${node.attrs.textAlign}` }, 0],
}
}
commands({ type }) {
return attrs => setBlockType(type, attrs)
}
}