Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const handlePastedText = async (text, html, newEditorState) => {
const potentialLink = text.match(/^https?:\/\//) || text.match(/^
onSubmit() {
const { getEditorState, setEditorState } = this.props;
let { value: url } = this.state;
if (!URLUtils.isMail(URLUtils.normaliseMail(url))) {
url = URLUtils.normalizeUrl(url);
if (!URLUtils.isUrl(url)) {
this.setState({ isInvalid: true });
return;
}
} else {
url = URLUtils.normaliseMail(url);
}
setEditorState(EditorUtils.createLinkAtSelection(getEditorState(), url));
this.input.blur();
this.onClose();
}
submit() {
const { getEditorState, setEditorState } = this.props;
let { value: url } = this.state;
if (!URLUtils.isMail(URLUtils.normaliseMail(url))) {
url = URLUtils.normalizeUrl(url);
if (!URLUtils.isUrl(url)) {
this.setState({ isInvalid: true });
return;
}
} else {
url = URLUtils.normaliseMail(url);
}
setEditorState(EditorUtils.createLinkAtSelection(getEditorState(), url));
this.input.blur();
this.onClose();
}
onSelectItem = (e, url) => {
e.preventDefault();
this.setState({
value: url,
isInvalid: false,
});
this.props.resetSearchContent();
this.props.setEditorState(
EditorUtils.createLinkAtSelection(this.props.getEditorState(), url),
);
this.input.blur();
this.onClose();
};