Skip to content

Commit 9662007

Browse files
juliusknorrbackportbot[bot]
authored andcommitted
Show tooltip on link hover
Signed-off-by: Julius Härtl <[email protected]>
1 parent 8a02445 commit 9662007

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/EditorFactory.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
HardBreak,
2525
Heading,
2626
Code,
27-
Link,
2827
BulletList,
2928
OrderedList,
3029
Blockquote,
@@ -34,7 +33,7 @@ import {
3433
History,
3534
Placeholder,
3635
} from 'tiptap-extensions'
37-
import { Strong, Italic, Strike } from './marks'
36+
import { Strong, Italic, Strike, Link } from './marks'
3837
import { Image, PlainTextDocument, ListItem } from './nodes'
3938
import MarkdownIt from 'markdown-it'
4039
import taskLists from 'markdown-it-task-lists'

src/marks/index.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*/
2222

23-
import { Bold, Italic as TipTapItalic, Strike as TipTapStrike } from 'tiptap-extensions'
23+
import { Bold, Italic as TipTapItalic, Strike as TipTapStrike, Link as TipTapLink } from 'tiptap-extensions'
2424

2525
/**
2626
* This file maps prosemirror mark names to tiptap classes,
@@ -74,10 +74,39 @@ class Strike extends TipTapStrike {
7474

7575
}
7676

77+
class Link extends TipTapLink {
78+
79+
get schema() {
80+
return {
81+
attrs: {
82+
href: {
83+
default: null,
84+
},
85+
},
86+
inclusive: false,
87+
parseDOM: [
88+
{
89+
tag: 'a[href]',
90+
getAttrs: dom => ({
91+
href: dom.getAttribute('href'),
92+
}),
93+
},
94+
],
95+
toDOM: node => ['a', {
96+
...node.attrs,
97+
title: node.attrs.href,
98+
rel: 'noopener noreferrer nofollow',
99+
}, 0],
100+
}
101+
}
102+
103+
}
104+
77105
/** Strike is currently unsupported by prosemirror-markdown */
78106

79107
export {
80108
Strong,
81109
Italic,
82110
Strike,
111+
Link,
83112
}

0 commit comments

Comments
 (0)