Skip to content

Commit

Permalink
Add text selection check before inserting hyperlink
Browse files Browse the repository at this point in the history
  • Loading branch information
choidabom committed Sep 3, 2024
1 parent a3e2f94 commit 17ca34e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/src/utils/urlHyperlinkInserter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const urlHyperlinkInserter = (doc: CodePairDocType) => {
const url = event.clipboardData?.getData("text/plain");
if (!url || !isValidUrl(url)) return;

const { from, to } = view.state.selection.main;
if (from === to) return;

insertLinkToEditor(url, view, doc);
event.preventDefault();
},
Expand Down

0 comments on commit 17ca34e

Please sign in to comment.