File tree Expand file tree Collapse file tree
src/components/NcRichText Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -532,11 +532,9 @@ export default {
532532 return entry
533533 }
534534 const { component , props } = entry
535- // do not override class of NcLink
536- const componentClass = component .name === ' NcLink' ? undefined : ' rich-text--component'
537535 return h (component, {
538536 ... props,
539- class: componentClass ,
537+ class: ' rich-text--component ' ,
540538 })
541539 })
542540 }
@@ -684,13 +682,6 @@ export default {
684682 .rich - text-- fallback, .rich - text- component {
685683 display: inline;
686684 }
687-
688- .rich - text-- external- link {
689- text- decoration: underline;
690- & : after {
691- content: ' ↗' ;
692- }
693- }
694685}
695686
696687/* Markdown styles */
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change @@ -9,28 +9,10 @@ import type { Router } from 'vue-router'
99import { getBaseUrl , getRootUrl } from '@nextcloud/router'
1010import { u } from 'unist-builder'
1111import { SKIP , visitParents } from 'unist-util-visit-parents'
12- import { defineComponent , h } from 'vue'
12+ import NcRichTextExternalLink from './NcRichTextExternalLink. vue'
1313import { logger } from '../../utils/logger.ts'
1414import { URL_PATTERN_AUTOLINK } from './helpers.js'
1515
16- const NcLink = defineComponent ( {
17- name : 'NcLink' ,
18- props : {
19- href : {
20- type : String ,
21- required : true ,
22- } ,
23- } ,
24- render ( ) {
25- return h ( 'a' , {
26- href : this . href ,
27- rel : 'noopener noreferrer' ,
28- target : '_blank' ,
29- class : 'rich-text--external-link' ,
30- } , [ this . href . trim ( ) ] )
31- } ,
32- } )
33-
3416/**
3517 *
3618 * @param root0
@@ -99,7 +81,7 @@ export function parseUrl(text: string) {
9981 textAfter = lastChar
10082 }
10183 list . push ( textBefore )
102- list . push ( { component : NcLink , props : { href } } )
84+ list . push ( { component : NcRichTextExternalLink , props : { href : href . trim ( ) , decorateExternal : true } } )
10385 if ( textAfter ) {
10486 list . push ( textAfter )
10587 }
You can’t perform that action at this time.
0 commit comments