diff --git a/src/marks/Link.ts b/src/marks/Link.ts index d0d06a2dfad..f2cd2aef215 100644 --- a/src/marks/Link.ts +++ b/src/marks/Link.ts @@ -98,6 +98,7 @@ const Link = TipTapLink.extend({ return { href: { default: null, + parseHTML: (element: HTMLElement) => parseHref(element), }, title: { default: null, diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js index 91554c7239c..d06e8b3cf44 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -99,9 +99,12 @@ describe('Markdown though editor', () => { // Issue #4900 expect(markdownThroughEditor('[`code`](foo)')).toBe('[`code`](foo)') expect(markdownThroughEditor('[text with `code` inside](foo)')).toBe('[text with `code` inside](foo)') + // Purely numeric targets must stay strings (issue #9519) + expect(markdownThroughEditor('[test](12345678901234)')).toBe('[test](12345678901234)') // Wiki-style links (issue #4795) expect(markdownThroughEditor('[[WikiLink]]')).toBe('[[WikiLink]]') expect(markdownThroughEditor('text [[wikiLink]] more')).toBe('text [[wikiLink]] more') + expect(markdownThroughEditor('[[12345678901234|test]]')).toBe('[[12345678901234|test]]') // Reference-style links (issue #5820) const referenceShortcutTest = 'Test with [Case-Sensitive Reference] in it.\n\n[Case-Sensitive Reference]: https://example.org/\n' diff --git a/src/tests/plugins/linkPill.spec.ts b/src/tests/plugins/linkPill.spec.ts index fa2473d0fc0..28c675f3f6d 100644 --- a/src/tests/plugins/linkPill.spec.ts +++ b/src/tests/plugins/linkPill.spec.ts @@ -24,6 +24,14 @@ describe('linkPill plugin', () => { editor.destroy() }) + it('handles purely numeric hrefs', () => { + const editor = createCustomEditor('

Test

', [Link]) + const spans = findLinkSpans(editor.state.doc) + expect(spans).toHaveLength(1) + expect(spans[0].mark.attrs.href).toBe('12345678901234') + editor.destroy() + }) + it('skips anchor links', () => { const editor = createCustomEditor('

Test

', [Link]) expect(findLinkSpans(editor.state.doc)).toHaveLength(0)