Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/components/ContentEditable/ContentEditable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,18 @@ export class ContentEditable extends Component {
handleInput,
handleKeyPress,
innerHTML,
props: { placeholder, disabled, className },
props: { placeholder, disabled, className, plaintextOnly },
} = this,
ph = typeof placeholder === "string" ? placeholder : "";

const enabledContentEditable = plaintextOnly ? "plaintext-only" : true;
const contentEditable = disabled === false ? enabledContentEditable : false;

return (
<div
ref={msgRef}
className={className}
contentEditable={disabled === false}
contentEditable={contentEditable}
disabled={disabled}
data-placeholder={ph}
onInput={handleInput}
Expand All @@ -142,6 +145,12 @@ ContentEditable.propTypes = {
/** A input can show it is currently unable to be interacted with. */
disabled: PropTypes.bool,

/**
* plaintext-only content-editable state, instead of true (when enabled).
* prevents pasting rich text (removes formatting from pasted text).
*/
plaintextOnly: PropTypes.bool,

/**
* Sets focus element and caret at the end of input
* when value is changed programmatically (e.g) from button click and element is not active
Expand Down
1 change: 1 addition & 0 deletions src/components/MessageInput/MessageInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface MessageInputProps {
value?: string;
placeholder?: string;
disabled?: boolean;
plaintextOnly?: boolean;
sendOnReturnDisabled?: boolean;
sendDisabled?: boolean;
fancyScroll?: boolean;
Expand Down
8 changes: 8 additions & 0 deletions src/components/MessageInput/MessageInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function MessageInputInner(
className,
activateAfterChange = false,
disabled = false,
plaintextOnly = false,
sendDisabled,
sendOnReturnDisabled = false,
attachDisabled = false,
Expand Down Expand Up @@ -205,6 +206,7 @@ function MessageInputInner(
ref={msgRef}
className={`${cName}__content-editor`}
disabled={disabled}
plaintextOnly={plaintextOnly}
placeholder={ph}
onKeyPress={handleKeyPress}
onChange={handleChange}
Expand Down Expand Up @@ -238,6 +240,12 @@ MessageInput.propTypes = {
/** A input can show it is currently unable to be interacted with. */
disabled: PropTypes.bool,

/**
* plaintext-only content-editable state, instead of true (when enabled).
* prevents pasting rich text (removes formatting from pasted text).
*/
plaintextOnly: PropTypes.bool,

/** Prevent that the input message is sent on a return press */
sendOnReturnDisabled: PropTypes.bool,

Expand Down