@@ -63,11 +63,11 @@ export class FilePicker<IsMultiSelect extends boolean> {
6363 }
6464
6565 /**
66- * Pick files using the FilePicker
66+ * Pick files using the FilePicker.
6767 *
6868 * @return Promise with array of picked files or rejected promise on close without picking
6969 */
70- public async pick ( ) : Promise < IsMultiSelect extends true ? string [ ] : string > {
70+ public async pickNodes ( ) : Promise < Node [ ] > {
7171 const { FilePickerVue } = await import ( './components/FilePicker/index' )
7272
7373 return new Promise ( ( resolve , reject ) => {
@@ -86,16 +86,25 @@ export class FilePicker<IsMultiSelect extends boolean> {
8686 if ( ! Array . isArray ( nodes ) || nodes . length === 0 ) {
8787 reject ( new FilePickerClosed ( 'FilePicker: No nodes selected' ) )
8888 } else {
89- if ( this . multiSelect ) {
90- resolve ( ( nodes as Node [ ] ) . map ( ( node ) => node . path ) as ( IsMultiSelect extends true ? string [ ] : string ) )
91- } else {
92- resolve ( ( ( nodes as Node [ ] ) [ 0 ] ?. path || '/' ) as ( IsMultiSelect extends true ? string [ ] : string ) )
93- }
89+ resolve ( nodes )
9490 }
9591 } )
9692 } )
9793 }
9894
95+ /**
96+ * Pick files using the FilePicker
97+ *
98+ * @return Promise with array of paths of picked files or rejected promise on close without picking
99+ */
100+ public async pick ( ) : Promise < IsMultiSelect extends true ? string [ ] : string > {
101+ const nodes = await this . pickNodes ( )
102+ if ( this . multiSelect ) {
103+ return ( nodes [ 0 ] ?. path ?? '/' ) as ( IsMultiSelect extends true ? string [ ] : string )
104+ }
105+ return nodes . map ( ( node ) => node . path ) as ( IsMultiSelect extends true ? string [ ] : string )
106+ }
107+
99108}
100109
101110export class FilePickerBuilder < IsMultiSelect extends boolean > {
0 commit comments