roschaefer 2f90a45da7 Follow @Tirokk's review and fix a bug
The bug happened because the hashtag link won't get parsed by the
extension. This is desired for mentions because you don't want to
re-notify a user if you haven't updated the text in which you notify
somebody. For hashtags this is undesired and would lead to transforming
the hashtag link into a normal link on the next edit of a post.
2019-09-17 11:09:45 +02:00

36 lines
694 B
JavaScript

import { Link as TipTapLink } from 'tiptap-extensions'
export default class Link extends TipTapLink {
pasteRules({ type }) {
return []
}
get schema() {
return {
attrs: {
href: {
default: null,
},
},
inclusive: false,
parseDOM: [
{
// if this is an embed link or a hashtag, ignore
tag: 'a[href]:not(.embed):not([data-hashtag-id])',
getAttrs: dom => ({
href: dom.getAttribute('href'),
}),
},
],
toDOM: node => [
'a',
{
...node.attrs,
rel: 'noopener noreferrer nofollow',
},
0,
],
}
}
}