Skip to content

Commit

Permalink
Improve link matching to support URL schemes (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong authored Nov 25, 2024
1 parent 52222a3 commit 24d01e4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CoreEditor/src/styling/nodes/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isReleaseMode } from '../../common/utils';
import { isMetaKeyDown } from '../../modules/events';

// Fragile approach, but we only use it for link clicking, it should be fine
const regexp = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,16}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)|(\[.*?\]\()(.+?)[\s)]/g;
const regexp = /[a-zA-Z][a-zA-Z0-9+.-]*:\/\/\/?(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}(\.)?[a-z]{2,16}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)|(\[.*?\]\()(.+?)[\s)]/g;
const className = 'cm-md-link';

declare global {
Expand All @@ -31,9 +31,9 @@ export const linkStyle = createDecoPlugin(() => {
},
});

if (match[3]) {
if (match[4]) {
// Markdown links, only decorate the part inside parentheses
add(from + match[3].length, to - 1, deco);
add(from + match[4].length, to - 1, deco);
} else {
// Normal links, decorate the full match
add(from, to, deco);
Expand Down

0 comments on commit 24d01e4

Please sign in to comment.