@kedao/editor
Version:
Rich Text Editor Based On Draft.js
36 lines • 1.83 kB
JavaScript
import React from 'react';
import { ContentUtils } from '@kedao/utils';
import ControlGroup from '..//ControlGroup';
class TextIndent extends React.Component {
constructor() {
super(...arguments);
this.state = {
currentIndent: 0
};
this.increaseIndent = () => {
this.props.editor.setValue(ContentUtils.increaseSelectionIndent(this.props.editorState));
this.props.editor.requestFocus();
};
this.decreaseIndent = () => {
this.props.editor.setValue(ContentUtils.decreaseSelectionIndent(this.props.editorState));
this.props.editor.requestFocus();
};
}
// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps) {
this.setState({
currentIndent: ContentUtils.getSelectionBlockData(nextProps.editorState, 'textIndent') || 0
});
}
render() {
const { currentIndent } = this.state;
const { language } = this.props;
return (React.createElement(ControlGroup, null,
React.createElement("button", { key: 0, type: "button", "data-title": language.controls.increaseIndent, disabled: currentIndent >= 6, className: `control-item button button-indent-increase${currentIndent > 0 && currentIndent < 6 ? ' active' : ''}`, onClick: this.increaseIndent },
React.createElement("i", { className: "bfi-indent-increase" })),
React.createElement("button", { key: 1, type: "button", "data-title": language.controls.decreaseIndent, disabled: currentIndent <= 0, className: "control-item button button-indent-decrease", onClick: this.decreaseIndent },
React.createElement("i", { className: "bfi-indent-decrease" }))));
}
}
export default TextIndent;
//# sourceMappingURL=index.js.map