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();
};
isSidenoteEntityActive = () => {
return EditorUtils.hasEntity(this.props.getEditorState(), 'SIDENOTE');
}
render() {
const { theme, onRemoveLinkAtSelection } = this.props;
const hasLinkSelected = EditorUtils.hasEntity(
this.props.store.getEditorState(),
'LINK'
);
const className = hasLinkSelected
? clsx(theme.button, theme.active)
: theme.button;
return (
<div>
<button type="button"></button></div>
render() {
const { theme } = this.props;
const hasLinkSelected = EditorUtils.hasEntity(
this.props.getEditorState(),
'LINK'
);
const className = hasLinkSelected
? unionClassNames(theme.button, theme.active)
: theme.button;
return (
<div>
</div>
const isSidenoteSelected = (editorState) => {
return EditorUtils.hasEntity(editorState, 'SIDENOTE');
}
render() {
const { theme, onRemoveLinkAtSelection } = this.props;
const hasLinkSelected = EditorUtils.hasEntity(
this.props.store.getEditorState(),
'LINK',
);
const className = hasLinkSelected
? unionClassNames(theme.button, theme.active)
: theme.button;
return (
<div role="presentation">
</div>
onRemoveLinkAtSelection = () => this.props.setEditorState(
EditorUtils.removeLinkAtSelection(this.props.getEditorState())
)