Skip to content

Commit

Permalink
Make NcLink non-functional
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <[email protected]>
  • Loading branch information
raimund-schluessler committed Mar 5, 2023
1 parent d36b3f6 commit cf2f87d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/NcRichText/autolink.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@ import { URL_PATTERN_AUTOLINK } from './helpers.js'
import { visit, SKIP } from 'unist-util-visit'
import { u } from 'unist-builder'

const Link = {
name: 'Link',
functional: true,
const NcLink = {
name: 'NcLink',
props: {
href: {
type: String,
required: true,
},
},
render(h, { data, props }) {
render(h) {
return h('a', {
attrs: {
href: props.href,
href: this.href,
rel: 'noopener noreferrer',
target: '_blank',
class: 'rich-text--external-link',
},
}, [props.href.trim()])
}, [this.href.trim()])
},
}

Expand All @@ -32,7 +31,7 @@ export const remarkAutolink = function({ autolink, useMarkdown }) {
}

visit(tree, (node) => node.type === 'text', (node, index, parent) => {
let parsed = parseUrl(node.value, Link)
let parsed = parseUrl(node.value, NcLink)
parsed = parsed.map((n) => {
if (typeof n === 'string') {
return u('text', n)
Expand Down Expand Up @@ -67,7 +66,7 @@ export const parseUrl = (text, linkComponent) => {
textAfter = lastChar
}
list.push(textBefore)
list.push({ component: Link, props: { href } })
list.push({ component: NcLink, props: { href } })
if (textAfter) {
list.push(textAfter)
}
Expand Down

0 comments on commit cf2f87d

Please sign in to comment.