55
66<template >
77 <div v-if =" filePath === null" class =" office-target-picker" >
8- <div ref =" picker" class =" reference-file-picker" />
8+ <FilePicker :name =" t('files', 'Select file or folder to link to')"
9+ :buttons =" filePickerButtons"
10+ :allow-pick-directory =" false"
11+ :multiselect =" false"
12+ :mimetype-filter =" validMimetypes"
13+ container =" .office-target-picker" />
914 </div >
1015 <div v-else class =" office-target-picker" >
1116 <h2 >{{ t('richdocuments', 'Link to office document section') }}</h2 >
4247</template >
4348
4449<script >
45- import { getFilePickerBuilder } from ' @nextcloud/dialogs'
50+ import { FilePickerVue as FilePicker } from ' @nextcloud/dialogs/filepicker.js'
51+ import { spawnDialog } from ' @nextcloud/dialogs'
4652import { generateUrl , generateOcsUrl } from ' @nextcloud/router'
4753import axios from ' @nextcloud/axios'
4854import NcButton from ' @nextcloud/vue/dist/Components/NcButton.js'
@@ -59,6 +65,7 @@ export default {
5965 NcEmptyContent,
6066 NcListItem,
6167 NcLoadingIcon,
68+ FilePicker,
6269 TableOfContentsIcon,
6370 },
6471 props: {
@@ -77,37 +84,45 @@ export default {
7784 filePath: null ,
7885 target: null ,
7986 sections: null ,
87+ filePickerButtons: [
88+ {
89+ label: t (' richdocuments' , ' Cancel' ),
90+ callback : () => {
91+ this .$emit (' cancel' )
92+ },
93+ type: ' secondary' ,
94+ },
95+ {
96+ label: t (' richdocuments' , ' Select file' ),
97+ callback : (files ) => {
98+ const file = files[0 ]
99+ this .fileId = file .fileid
100+ this .filePath = file .path
101+ this .fetchReferences ()
102+ },
103+ type: ' primary' ,
104+ },
105+ ],
80106 }
81107 },
108+ computed: {
109+ validMimetypes () {
110+ return getCapabilities ().mimetypes
111+ },
112+ },
82113 mounted () {
83- this .openFilePicker ()
84114 window .addEventListener (' click' , this .onWindowClick )
85115 },
86116 beforeDestroy () {
87117 window .removeEventListener (' click' , this .onWindowClick )
88118 },
89119 methods: {
120+ t,
90121 onWindowClick (e ) {
91122 if (e .target .tagName === ' A' && e .target .classList .contains (' oc-dialog-close' )) {
92123 this .$emit (' cancel' )
93124 }
94125 },
95- async openFilePicker () {
96- await getFilePickerBuilder (t (' files' , ' Select file or folder to link to' ))
97- .setMimeTypeFilter (getCapabilities ().mimetypes )
98- .addButton ({
99- label: t (' richdocuments' , ' Insert image' ),
100- callback : (files ) => {
101- const file = files[0 ]
102- this .fileId = file .fileid
103- this .filePath = file .path
104- this .fetchReferences ()
105- },
106- })
107- .setContainer (this .$refs .picker )
108- .build ()
109- .pick ()
110- },
111126 setTarget (entry ) {
112127 this .target = entry .id
113128 },
@@ -129,34 +144,6 @@ export default {
129144 </script >
130145
131146<style scoped lang="scss">
132- .reference-file-picker {
133- flex-grow : 1 ;
134-
135- & :deep (.oc-dialog ) {
136- transform : none !important ;
137- box-shadow : none !important ;
138- flex-grow : 1 !important ;
139- position : static !important ;
140- width : 100% !important ;
141- height : auto !important ;
142- padding : 0 !important ;
143- max-width : initial ;
144-
145- .oc-dialog-close {
146- display : none ;
147- }
148-
149- .oc-dialog-buttonrow.onebutton.aside {
150- position : absolute ;
151- padding : 12px 32px ;
152- }
153-
154- .oc-dialog-content {
155- max-width : 100% !important ;
156- }
157- }
158- }
159-
160147.office-target-picker {
161148 margin : calc (var (--default-grid-baseline ) * 4 );
162149 flex-grow : 1 ;
0 commit comments