Skip to content

Commit a36081e

Browse files
Antreesybackportbot[bot]
authored andcommitted
fix: extract NcRichTextExternalLink component
fix: extract NcRichTextExternalLink component - add noExtDecoration prop for reusing the component Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com> [skip ci]
1 parent df74096 commit a36081e

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
- SPDX-License-Identifier: AGPL-3.0-or-later
4+
-->
5+
6+
<script setup lang="ts">
7+
const { href, decorateExternal = false } = defineProps<{
8+
/** Link attribute to render */
9+
href: string
10+
/** Whether to add the appended arrow decoration */
11+
decorateExternal?: boolean
12+
}>()
13+
</script>
14+
15+
<template>
16+
<a
17+
:href="href"
18+
rel="noopener noreferrer"
19+
target="_blank"
20+
:class="[$style.externalLink, {
21+
[$style.externalLink_decorated]: decorateExternal,
22+
}]">
23+
<slot name="default">
24+
{{ href }}
25+
</slot>
26+
</a>
27+
</template>
28+
29+
<style module lang="scss">
30+
.externalLink {
31+
text-decoration: underline;
32+
}
33+
34+
.externalLink_decorated::after {
35+
content: '';
36+
}
37+
</style>
38+
39+
<docs>
40+
An internal component
41+
</docs>

src/components/NcRichText/autolink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function parseUrl(text) {
8787
textAfter = lastChar
8888
}
8989
list.push(textBefore)
90-
list.push({ component: NcLink, props: { href } })
90+
list.push({ component: NcRichTextExternalLink, props: { href: href.trim(), decorateExternal: true } })
9191
if (textAfter) {
9292
list.push(textAfter)
9393
}

0 commit comments

Comments
 (0)