Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
fix: Invalid selection should not crash editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Feb 24, 2021
1 parent 2a85d9f commit 19e5430
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/LinkToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ function isActive(props: Props) {
const { view } = props;
const { selection } = view.state;

const paragraph = view.domAtPos(selection.from);
return props.isActive && !!paragraph.node;
try {
const paragraph = view.domAtPos(selection.from);
return props.isActive && !!paragraph.node;
} catch (err) {
return false;
}
}

export default class LinkToolbar extends React.Component<Props> {
Expand Down

0 comments on commit 19e5430

Please sign in to comment.