diff --git a/app/editor/components/LinkEditor.tsx b/app/editor/components/LinkEditor.tsx index 02e497e60321..f444f6279c62 100644 --- a/app/editor/components/LinkEditor.tsx +++ b/app/editor/components/LinkEditor.tsx @@ -44,7 +44,7 @@ type Props = { href: string, event: React.MouseEvent ) => void; - onShowToast: (message: string, options: ToastOptions) => void; + onShowToast: (message: string, options?: ToastOptions) => void; view: EditorView; }; @@ -70,7 +70,7 @@ class LinkEditor extends React.Component { }; get href(): string { - return this.props.mark ? this.props.mark.attrs.href : ""; + return sanitizeHref(this.props.mark?.attrs.href) ?? ""; } get suggestedLinkTitle(): string { @@ -229,7 +229,12 @@ class LinkEditor extends React.Component { handleOpenLink = (event: React.MouseEvent): void => { event.preventDefault(); - this.props.onClickLink(this.href, event); + + try { + this.props.onClickLink(this.href, event); + } catch (err) { + this.props.onShowToast(this.props.dictionary.openLinkError); + } }; handleCreateLink = async (value: string) => {