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 5, 2024
1 parent 002d5e7 commit a5a3022
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 a5a3022

Please sign in to comment.