mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
45 lines
1.0 KiB
React
45 lines
1.0 KiB
React
import PropTypes from 'prop-types';
|
|
|
|
export default function DataInputComponent(props) {
|
|
const {
|
|
html,
|
|
title,
|
|
value,
|
|
onChange,
|
|
className,
|
|
...rest
|
|
} = props;
|
|
return (
|
|
<div {...rest} className={className} style={{ height: '100%', width: '100%' }}>
|
|
{html ? (
|
|
<div
|
|
className="scratchpad__data-input"
|
|
style={{ overflowY: 'scroll' }}
|
|
wrap="off"
|
|
>
|
|
{/* eslint-disable-next-line react/no-danger */}
|
|
<pre dangerouslySetInnerHTML={{ __html: value }} contentEditable />
|
|
</div>
|
|
) : (
|
|
<textarea
|
|
className="scratchpad__data-input"
|
|
wrap="off"
|
|
value={value}
|
|
onChange={(ev) => {
|
|
ev.stopPropagation();
|
|
onChange(ev.target.value);
|
|
}}
|
|
placeholder={title}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
DataInputComponent.propTypes = {
|
|
title: PropTypes.node,
|
|
value: PropTypes.string,
|
|
onChange: PropTypes.func,
|
|
className: PropTypes.string,
|
|
};
|