X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4f5fdd49c0c9866fbb613c6c82641d686b0b8ad5..2a7fd99c212c33a1ec9911f8529fa5afc59a7bb2:/src/components/text-field/text-field.tsx diff --git a/src/components/text-field/text-field.tsx b/src/components/text-field/text-field.tsx index 13bb1e4f13..b2a8dd4848 100644 --- a/src/components/text-field/text-field.tsx +++ b/src/components/text-field/text-field.tsx @@ -2,31 +2,58 @@ // // 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 { TextField as MaterialTextField, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core'; +import { ArvadosTheme } from 'common/custom-theme'; +import { + TextField as MaterialTextField, + StyleRulesCallback, + WithStyles, + withStyles, + PropTypes +} from '@material-ui/core'; import RichTextEditor from 'react-rte'; -type CssRules = 'textField'; +type CssRules = 'textField' | 'rte'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ textField: { - marginBottom: theme.spacing.unit * 3 + marginBottom: theme.spacing.unit }, + rte: { + fontFamily: 'Arial', + '& a': { + textDecoration: 'none', + color: theme.palette.primary.main, + '&:hover': { + cursor: 'pointer', + textDecoration: 'underline' + } + } + } }); -export const TextField = withStyles(styles)((props: WrappedFieldProps & WithStyles & { label?: string, autoFocus?: boolean, required?: boolean }) => +type TextFieldProps = WrappedFieldProps & WithStyles; + +export const TextField = withStyles(styles)((props: TextFieldProps & { + label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, disabled?: boolean, children: React.ReactNode, margin?: PropTypes.Margin, placeholder?: string, + helperText?: string, type?: string, +}) => ); @@ -35,7 +62,7 @@ interface RichEditorTextFieldData { label?: string; } -type RichEditorTextFieldProps = RichEditorTextFieldData & WrappedFieldProps & WithStyles; +type RichEditorTextFieldProps = RichEditorTextFieldData & TextFieldProps; export const RichEditorTextField = withStyles(styles)( class RichEditorTextField extends React.Component { @@ -45,11 +72,16 @@ export const RichEditorTextField = withStyles(styles)( 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() { - return ; @@ -57,20 +89,19 @@ export const RichEditorTextField = withStyles(styles)( } ); -type DateTextFieldProps = WrappedFieldProps & WithStyles; - export const DateTextField = withStyles(styles) - ((props: DateTextFieldProps) => + ((props: TextFieldProps) => - ); \ No newline at end of file + /> + );