X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c324b64f3b26e79b4640b6f0cf55671f1a261bca..a54420c0b7b6566ecf9d0f04835e6d8a3ef165d9:/src/components/text-field/text-field.tsx?ds=sidebyside diff --git a/src/components/text-field/text-field.tsx b/src/components/text-field/text-field.tsx index b5671dbb..b2a8dd48 100644 --- a/src/components/text-field/text-field.tsx +++ b/src/components/text-field/text-field.tsx @@ -2,28 +2,106 @@ // // 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 }) => +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, +}) => ); + + +interface RichEditorTextFieldData { + label?: string; +} + +type RichEditorTextFieldProps = RichEditorTextFieldData & TextFieldProps; + +export const RichEditorTextField = withStyles(styles)( + class RichEditorTextField extends React.Component { + state = { + value: RichTextEditor.createValueFromString(this.props.input.value, 'html') + }; + + onChange = (value: any) => { + this.setState({ value }); + this.props.input.onChange( + !!value.getEditorState().getCurrentContent().getPlainText().trim() + ? value.toString('html') + : null + ); + } + + render() { + return ; + } + } +); + +export const DateTextField = withStyles(styles) + ((props: TextFieldProps) => + + );