forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClipboardCopyExpanded.tsx
More file actions
45 lines (39 loc) · 1.34 KB
/
ClipboardCopyExpanded.tsx
File metadata and controls
45 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as React from 'react';
import styles from '@patternfly/react-styles/css/components/ClipboardCopy/clipboard-copy';
import { css } from '@patternfly/react-styles';
import { ClipboardCopyProps } from './ClipboardCopy';
import { PickOptional } from '../../helpers/typeUtils';
export interface ClipboardCopyExpandedProps extends Omit<ClipboardCopyProps, 'onChange'> {
className?: string;
children: React.ReactNode;
onChange?: (e: React.FormEvent<HTMLDivElement>, text: string) => void;
isReadOnly?: boolean;
isCode?: boolean;
}
class ClipboardCopyExpanded extends React.Component<ClipboardCopyExpandedProps> {
static displayName = 'ClipboardCopyExpanded';
constructor(props: any) {
super(props);
}
static defaultProps: PickOptional<ClipboardCopyExpandedProps> = {
onChange: (): any => undefined,
className: '',
isReadOnly: false,
isCode: false
};
render() {
const { className, children, onChange, isReadOnly, isCode, ...props } = this.props;
return (
<div
// suppressContentEditableWarning
className={css(styles.clipboardCopyExpandableContent, className)}
onInput={(e: any) => onChange(e, e.target.innerText)}
contentEditable={!isReadOnly}
{...props}
>
{isCode ? <pre>{children}</pre> : children}
</div>
);
}
}
export { ClipboardCopyExpanded };