Created
May 14, 2020 06:14
-
-
Save MattyBalaam/8aa769c8f02be314f92d71a4e27ea999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.public-DraftStyleDefault-ltr { | |
.justify-left & { | |
text-align: left; | |
} | |
.justify-right & { | |
text-align: right; | |
} | |
.justify-center & { | |
text-align: center; | |
} | |
.justify-full & { | |
text-align: justify; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PureComponent } from 'react'; | |
import { createBlockStyleButton } from 'draft-js-buttons'; | |
import TextAlignmentButton from './TextAlignmentButton'; | |
import { TYPES } from 'textAlignment'; | |
export default class Alignment extends PureComponent { | |
buttons = TYPES.map((type) => { | |
const Button = createBlockStyleButton({ | |
blockType: type, | |
key: type, | |
children: <TextAlignmentButton type={ type } />, | |
}); | |
return Button; | |
}); | |
render() { | |
return this.buttons.map(Button => <Button { ...this.props } />); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './textAlignment.css'; | |
export const TYPES = ['justify-left', 'justify-right', 'justify-center', 'justify-full']; | |
export default () => ({ | |
blockStyleFn: (contentBlock) => { | |
const type = contentBlock.getType(); | |
return TYPES.includes(type) && type; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment