33 - SPDX-License-Identifier: AGPL-3.0-or-later
44-->
55<template >
6- <div contenteditable =" false" class =" preview-options-container" >
7- <NcActions
8- data-text-preview-options="select"
9- class="preview-options"
10- :open .sync =" open "
11- @open =" onOpen " >
6+ <NcActions
7+ data-text-link-options="select"
8+ class="link-options"
9+ :open .sync =" open "
10+ @open =" onOpen " >
11+ <template #icon >
12+ <DotsVerticalIcon :size =" 20 " />
13+ </template >
14+ <NcActionCaption :name =" t (' text' , ' Preview options' )" />
15+ <NcActionRadio
16+ data-text-preview-option="text-only"
17+ name="preview-option"
18+ value="text-only"
19+ :model-value =" type "
20+ @change =" (e ) => toggle (e .currentTarget .value ) " >
21+ {{ t('text', 'Text only') }}
22+ </NcActionRadio >
23+ <NcActionRadio
24+ data-text-preview-option="link-preview"
25+ name="preview-option"
26+ value="link-preview"
27+ :model-value =" type "
28+ @change =" (e ) => toggle (e .currentTarget .value ) " >
29+ {{ t('text', 'Show link preview') }}
30+ </NcActionRadio >
31+
32+ <NcActionSeparator />
33+
34+ <!-- Open link -->
35+ <NcActionButton v-if =" href " close-after-click @click =" openLink " >
36+ <template #icon >
37+ <OpenIcon :size =" 20 " />
38+ </template >
39+ {{ t('text', 'Open in new tab') }}
40+ </NcActionButton >
41+
42+ <!-- Copy link -->
43+ <NcActionButton v-if =" href " close-after-click @click =" copyLink " >
44+ <template #icon >
45+ <CheckIcon v-if =" copySuccess " :size =" 20 " />
46+ <NcLoadingIcon v-else-if =" copyLoading " :size =" 20 " />
47+ <ContentCopyIcon v-else :size =" 20 " />
48+ </template >
49+ {{ t('text', 'Copy link') }}
50+ </NcActionButton >
51+
52+ <!-- Remove link -->
53+ <NcActionButton close-after-click @click =" deleteNode " >
1254 <template #icon >
13- <DotsVerticalIcon :size =" 20 " />
55+ <DeleteOutlineIcon :size =" 20 " />
1456 </template >
15- <NcActionCaption :name =" t (' text' , ' Preview options' )" />
16- <NcActionRadio
17- data-text-preview-option="text-only"
18- name="preview-option"
19- value="text-only"
20- :model-value =" type "
21- @change =" (e ) => toggle (e .currentTarget .value ) " >
22- {{ t('text', 'Text only') }}
23- </NcActionRadio >
24- <NcActionRadio
25- data-text-preview-option="link-preview"
26- name="preview-option"
27- value="link-preview"
28- :model-value =" type "
29- @change =" (e ) => toggle (e .currentTarget .value ) " >
30- {{ t('text', 'Show link preview') }}
31- </NcActionRadio >
32- <NcActionSeparator />
33- <NcActionButton v-if =" href " close-after-click @click =" openLink " >
34- <template #icon >
35- <OpenIcon :size =" 20 " />
36- </template >
37- {{ t('text', 'Open in new tab') }}
38- </NcActionButton >
39- <NcActionButton close-after-click @click =" deleteNode " >
40- <template #icon >
41- <DeleteOutlineIcon :size =" 20 " />
42- </template >
43- {{ t('text', 'Remove link') }}
44- </NcActionButton >
45- </NcActions >
46- </div >
57+ {{ t('text', 'Remove link') }}
58+ </NcActionButton >
59+ </NcActions >
4760</template >
4861
4962<script >
@@ -53,24 +66,33 @@ import NcActionCaption from '@nextcloud/vue/components/NcActionCaption'
5366import NcActionRadio from ' @nextcloud/vue/components/NcActionRadio'
5467import NcActions from ' @nextcloud/vue/components/NcActions'
5568import NcActionSeparator from ' @nextcloud/vue/components/NcActionSeparator'
69+ import NcLoadingIcon from ' @nextcloud/vue/components/NcLoadingIcon'
70+ import CheckIcon from ' vue-material-design-icons/Check.vue'
71+ import ContentCopyIcon from ' vue-material-design-icons/ContentCopy.vue'
5672import DotsVerticalIcon from ' vue-material-design-icons/DotsVertical.vue'
5773import OpenIcon from ' vue-material-design-icons/OpenInNew.vue'
5874import DeleteOutlineIcon from ' vue-material-design-icons/TrashCanOutline.vue'
75+ import CopyToClipboardMixin from ' ../../mixins/CopyToClipboardMixin.js'
5976
6077export default {
6178 name: ' PreviewOptions' ,
6279
6380 components: {
81+ CheckIcon,
82+ ContentCopyIcon,
6483 DotsVerticalIcon,
6584 NcActions,
6685 NcActionButton,
6786 NcActionCaption,
6887 NcActionRadio,
6988 NcActionSeparator,
89+ NcLoadingIcon,
7090 DeleteOutlineIcon,
7191 OpenIcon,
7292 },
7393
94+ mixins: [CopyToClipboardMixin],
95+
7496 props: {
7597 type: {
7698 type: String ,
@@ -88,6 +110,12 @@ export default {
88110 }
89111 },
90112
113+ computed: {
114+ isPreview () {
115+ return this .type === ' link-preview'
116+ },
117+ },
118+
91119 methods: {
92120 onOpen () {
93121 this .$emit (' open' )
@@ -96,13 +124,16 @@ export default {
96124 this .open = false
97125 this .$emit (' toggle' , type)
98126 },
99- deleteNode () {
100- this .$emit (' delete' )
101- },
102127 openLink () {
103128 if (! this .href ) return
104129 window .open (this .href , ' _blank' ).focus ()
105130 },
131+ async copyLink () {
132+ await this .copyToClipboard (this .href )
133+ },
134+ deleteNode () {
135+ this .$emit (' delete' )
136+ },
106137 t,
107138 },
108139}
@@ -113,19 +144,4 @@ div[contenteditable='false'] {
113144 padding : 0 ;
114145 margin : 0 ;
115146}
116-
117- .preview-options-container {
118- position : absolute ;
119- width : 0 !important ;
120- left : -44px ;
121- top : 50% ;
122- transform : translate (0 , -50% );
123- // Required to overlay the drag handler padding
124- z-index : 10000 ;
125- }
126-
127- // Inside details, button needs to be shifted further
128- .details-content .preview-options-container {
129- left : calc (-44px - 24px );
130- }
131147 </style >
0 commit comments