File tree Expand file tree Collapse file tree 2 files changed +75
-8
lines changed
src/components/ContextChat Expand file tree Collapse file tree 2 files changed +75
-8
lines changed Original file line number Diff line number Diff line change 7
7
<label class =" cc-output__sources__label" >
8
8
{{ outputShape.sources.description }}
9
9
</label >
10
- <NcRichText v-for =" (source, i) in sources"
11
- :key =" 'source-' + i"
12
- :text =" source.url"
13
- :use-markdown =" false"
14
- :reference-limit =" 1"
15
- :autolink =" true" />
10
+ <ContextChatSource v-for =" (source, i) in sources"
11
+ :key =" 'source-' + i + '-' + source.url"
12
+ :source =" source" />
16
13
</div >
17
14
</template >
18
15
19
16
<script >
20
- import { NcRichText } from ' @nextcloud/vue/dist/Components/NcRichText.js '
17
+ import ContextChatSource from ' ./ContextChatSource.vue '
21
18
22
19
export default {
23
20
name: ' ContextChatSearchOutputForm' ,
24
21
25
22
components: {
26
- NcRichText ,
23
+ ContextChatSource ,
27
24
},
28
25
29
26
props: {
Original file line number Diff line number Diff line change
1
+ <!--
2
+ - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
3
+ - SPDX-License-Identifier: AGPL-3.0-or-later
4
+ -->
5
+ <template >
6
+ <NcRichText
7
+ :text =" text"
8
+ :use-markdown =" true"
9
+ :reference-limit =" 1"
10
+ :references =" references"
11
+ :autolink =" true" />
12
+ </template >
13
+
14
+ <script >
15
+ import { NcRichText } from ' @nextcloud/vue/dist/Components/NcRichText.js'
16
+
17
+ import { generateOcsUrl } from ' @nextcloud/router'
18
+ import axios from ' @nextcloud/axios'
19
+
20
+ export default {
21
+ name: ' ContextChatSource' ,
22
+
23
+ components: {
24
+ NcRichText,
25
+ },
26
+
27
+ props: {
28
+ source: {
29
+ type: Object ,
30
+ required: true ,
31
+ },
32
+ },
33
+
34
+ data : () => {
35
+ return {
36
+ // we could initialize this with undefined but then NcRichText will try to find links
37
+ // and resolve them before we had a chance to do so, resulting in unnecessary requests to references/resolve
38
+ // with [] we inhibit the extract+resolve mechanism on NcRichText
39
+ // TODO This can be removed (and all the custom extract+resolve logic) when fixed in NcRichText
40
+ references: [],
41
+ }
42
+ },
43
+
44
+ computed: {
45
+ text () {
46
+ return ' [' + this .source .label + ' ](' + this .source .url + ' )'
47
+ },
48
+ },
49
+
50
+ mounted () {
51
+ this .fetch ()
52
+ },
53
+
54
+ methods: {
55
+ fetch () {
56
+ axios .get (generateOcsUrl (' references/resolve' ) + ` ?reference=${ encodeURIComponent (this .source .url )} ` )
57
+ .then ((response ) => {
58
+ this .references = Object .values (response .data .ocs .data .references )
59
+ })
60
+ .catch ((error ) => {
61
+ console .error (' Failed to extract references' , error)
62
+ })
63
+ },
64
+ },
65
+ }
66
+ </script >
67
+
68
+ <style lang="scss" scoped>
69
+ // nothing yet
70
+ </style >
You can’t perform that action at this time.
0 commit comments