//
// SPDX-License-Identifier: AGPL-3.0
-import * as React from 'react';
+import React from 'react';
import { WrappedFieldProps } from 'redux-form';
-import { ArvadosTheme } from '~/common/custom-theme';
+import { ArvadosTheme } from 'common/custom-theme';
import {
TextField as MaterialTextField,
StyleRulesCallback,
PropTypes
} from '@material-ui/core';
import RichTextEditor from 'react-rte';
-import Margin = PropTypes.Margin;
type CssRules = 'textField' | 'rte';
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
textField: {
- marginBottom: theme.spacing.unit * 3
+ marginBottom: theme.spacing.unit
},
rte: {
fontFamily: 'Arial',
type TextFieldProps = WrappedFieldProps & WithStyles<CssRules>;
export const TextField = withStyles(styles)((props: TextFieldProps & {
- label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, disabled?: boolean, children: React.ReactNode, margin?: Margin, placeholder?: string,
+ label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, disabled?: boolean, children: React.ReactNode, margin?: PropTypes.Margin, placeholder?: string,
helperText?: string, type?: string,
}) =>
<MaterialTextField
onChange = (value: any) => {
this.setState({ value });
- this.props.input.onChange(value.toString('html'));
+ this.props.input.onChange(
+ !!value.getEditorState().getCurrentContent().getPlainText().trim()
+ ? value.toString('html')
+ : null
+ );
}
render() {