Skip to content

Commit 5edce3d

Browse files
committed
chore(links): use upstream markdownLinks option, drop our implementation
Signed-off-by: Jonas <jonas@freesources.org>
1 parent 6b37a09 commit 5edce3d

1 file changed

Lines changed: 1 addition & 35 deletions

File tree

src/marks/Link.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,6 @@ import { linkClicking } from '../plugins/links.ts'
1717

1818
export const PROTOCOLS_TO_LINK_TO = ['http:', 'https:', 'mailto:', 'tel:']
1919

20-
/**
21-
*
22-
* @param match to extract href from
23-
*/
24-
function extractHrefFromMatch(match: ExtendedRegExpMatchArray) {
25-
return { href: match.groups?.href }
26-
}
27-
28-
/**
29-
*
30-
* @param match with multiple capture groups
31-
*/
32-
function extractHrefFromMarkdownLink(match: ExtendedRegExpMatchArray) {
33-
/**
34-
* Removes the last capture group from the match to satisfy
35-
* Tiptap markInputRule expectation of having the content as
36-
* the last capture group in the match.
37-
*
38-
* https://github.com/ueberdosis/tiptap/blob/%40tiptap/core%402.0.0-beta.75/packages/core/src/inputRules/markInputRule.ts#L11
39-
*/
40-
match.pop()
41-
return extractHrefFromMatch(match)
42-
}
43-
4420
export interface RelativePathLinkOptions extends LinkOptions {
4521
relativePath?: string
4622
openLink?: (href: string) => void
@@ -114,6 +90,7 @@ const Link = TipTapLink.extend<RelativePathLinkOptions>({
11490
relativePath: undefined,
11591
openLink: undefined,
11692
...parentDefaults,
93+
markdownLinks: true,
11794
}
11895
},
11996

@@ -185,17 +162,6 @@ const Link = TipTapLink.extend<RelativePathLinkOptions>({
185162
]
186163
},
187164

188-
addInputRules() {
189-
const linkInputRegex = /(?:^|\s)\[([^[\]]+)\]\((?<href>.+?)\)$/gm
190-
return [
191-
markInputRule({
192-
find: linkInputRegex,
193-
type: this.type,
194-
getAttributes: extractHrefFromMarkdownLink,
195-
}),
196-
]
197-
},
198-
199165
addCommands() {
200166
return {
201167
...this.parent?.(),

0 commit comments

Comments
 (0)