@tauri-apps/plugin-dialog 2.4.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist-js/index.d.ts +68 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,24 @@ tauri-plugin-dialog = "2.0.0"
|
|
|
31
31
|
tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
### Linux XDG Desktop Portal Support
|
|
35
|
+
|
|
36
|
+
By default, this plugin uses gtk to show dialogs, however since `v2.5.0` you can switch to using [XDG Desktop Portal](https://flatpak.github.io/xdg-desktop-portal/) by adding the following to your `Cargo.toml` file:
|
|
37
|
+
|
|
38
|
+
```toml
|
|
39
|
+
[dependencies]
|
|
40
|
+
tauri-plugin-dialog = { version = "2.5.0", default-features = false, features = ["xdg-portal"] }
|
|
41
|
+
# alternatively with Git:
|
|
42
|
+
tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2", default-features = false, features = ["xdg-portal"] }
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Do note if you use the `xdg-portal` feature, you need to ensure that [`zenity`](https://gitlab.gnome.org/GNOME/zenity) and an [XDG Desktop Portal backend](https://flatpak.github.io/xdg-desktop-portal#using-portals) is installed with your program.
|
|
47
|
+
|
|
48
|
+
For more information, see [XDG Desktop Portal documentation](https://flatpak.github.io/xdg-desktop-portal/) and [`rfd` documentation](https://docs.rs/rfd/latest/rfd#xdg-desktop-portal-backend).
|
|
49
|
+
|
|
50
|
+
### JavaScript
|
|
51
|
+
|
|
34
52
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
|
35
53
|
|
|
36
54
|
```sh
|
package/dist-js/index.d.ts
CHANGED
|
@@ -8,6 +8,16 @@ interface DialogFilter {
|
|
|
8
8
|
name: string;
|
|
9
9
|
/**
|
|
10
10
|
* Extensions to filter, without a `.` prefix.
|
|
11
|
+
*
|
|
12
|
+
* **Note:** Mobile platforms have different APIs for filtering that may not support extensions.
|
|
13
|
+
* iOS: Extensions are supported in the document picker, but not in the media picker.
|
|
14
|
+
* Android: Extensions are not supported.
|
|
15
|
+
*
|
|
16
|
+
* For these platforms, MIME types are the primary way to filter files, as opposed to extensions.
|
|
17
|
+
* This means the string values here labeled as `extensions` may also be a MIME type.
|
|
18
|
+
* This property name of `extensions` is being kept for backwards compatibility, but this may be revisited to
|
|
19
|
+
* specify the difference between extension or MIME type filtering.
|
|
20
|
+
*
|
|
11
21
|
* @example
|
|
12
22
|
* ```typescript
|
|
13
23
|
* extensions: ['svg', 'png']
|
|
@@ -23,7 +33,14 @@ interface DialogFilter {
|
|
|
23
33
|
interface OpenDialogOptions {
|
|
24
34
|
/** The title of the dialog window (desktop only). */
|
|
25
35
|
title?: string;
|
|
26
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The filters of the dialog.
|
|
38
|
+
* On mobile platforms, if either:
|
|
39
|
+
* A) the {@linkcode pickerMode} is set to `media`, `image`, or `video`
|
|
40
|
+
* -- or --
|
|
41
|
+
* B) the filters include **only** either image or video mime types, the media picker will be displayed.
|
|
42
|
+
* Otherwise, the document picker will be displayed.
|
|
43
|
+
*/
|
|
27
44
|
filters?: DialogFilter[];
|
|
28
45
|
/**
|
|
29
46
|
* Initial directory or file path.
|
|
@@ -45,6 +62,38 @@ interface OpenDialogOptions {
|
|
|
45
62
|
recursive?: boolean;
|
|
46
63
|
/** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */
|
|
47
64
|
canCreateDirectories?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The preferred mode of the dialog.
|
|
67
|
+
* This is meant for mobile platforms (iOS and Android) which have distinct file and media pickers.
|
|
68
|
+
* If not provided, the dialog will automatically choose the best mode based on the MIME types or extensions of the {@linkcode filters}.
|
|
69
|
+
* On desktop, this option is ignored.
|
|
70
|
+
*/
|
|
71
|
+
pickerMode?: PickerMode;
|
|
72
|
+
/**
|
|
73
|
+
* The file access mode of the dialog.
|
|
74
|
+
* If not provided, `copy` is used, which matches the behavior of the {@linkcode open} method before the introduction of this option.
|
|
75
|
+
*
|
|
76
|
+
* **Usage**
|
|
77
|
+
* If a file is opened with {@linkcode fileAccessMode: 'copy'}, it will be copied to the app's sandbox.
|
|
78
|
+
* This means the file can be read, edited, deleted, copied, or any other operation without any issues, since the file
|
|
79
|
+
* now belongs to the app.
|
|
80
|
+
* This also means that the caller has responsibility of deleting the file if this file is not meant to be retained
|
|
81
|
+
* in the app sandbox.
|
|
82
|
+
*
|
|
83
|
+
* If a file is opened with {@linkcode fileAccessMode: 'scoped'}, the file will remain in its original location
|
|
84
|
+
* and security-scoped access will be automatically managed by the system.
|
|
85
|
+
*
|
|
86
|
+
* **Note**
|
|
87
|
+
* This is specifically meant for document pickers on iOS or MacOS, in conjunction with [security scoped resources](https://developer.apple.com/documentation/foundation/nsurl/startaccessingsecurityscopedresource()).
|
|
88
|
+
*
|
|
89
|
+
* Why only document pickers, and not image or video pickers?
|
|
90
|
+
* The image and video pickers on iOS behave differently from the document pickers, and return [NSItemProvider](https://developer.apple.com/documentation/foundation/nsitemprovider) objects instead of file URLs.
|
|
91
|
+
* These are meant to be ephemeral (only available within the callback of the picker), and are not accessible outside of the callback.
|
|
92
|
+
* So for image and video pickers, the only way to access the file is to copy it to the app's sandbox, and this is the URL that is returned from this API.
|
|
93
|
+
* This means there is no provision for using `scoped` mode with image or video pickers.
|
|
94
|
+
* If an image or video picker is used, `copy` is always used.
|
|
95
|
+
*/
|
|
96
|
+
fileAccessMode?: FileAccessMode;
|
|
48
97
|
}
|
|
49
98
|
/**
|
|
50
99
|
* Options for the save dialog.
|
|
@@ -68,6 +117,24 @@ interface SaveDialogOptions {
|
|
|
68
117
|
/** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */
|
|
69
118
|
canCreateDirectories?: boolean;
|
|
70
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* The preferred mode of the dialog.
|
|
122
|
+
* This is meant for mobile platforms (iOS and Android) which have distinct file and media pickers.
|
|
123
|
+
* On desktop, this option is ignored.
|
|
124
|
+
* If not provided, the dialog will automatically choose the best mode based on the MIME types or extensions of the {@linkcode filters}.
|
|
125
|
+
*
|
|
126
|
+
* **Note:** This option is only supported on iOS 14 and above. This parameter is ignored on iOS 13 and below.
|
|
127
|
+
*/
|
|
128
|
+
export type PickerMode = 'document' | 'media' | 'image' | 'video';
|
|
129
|
+
/**
|
|
130
|
+
* The file access mode of the dialog.
|
|
131
|
+
*
|
|
132
|
+
* - `copy`: copy/move the picked file to the app sandbox; no scoped access required.
|
|
133
|
+
* - `scoped`: keep file in place; security-scoped access is automatically managed.
|
|
134
|
+
*
|
|
135
|
+
* **Note:** This option is only supported on iOS 14 and above. This parameter is ignored on iOS 13 and below.
|
|
136
|
+
*/
|
|
137
|
+
export type FileAccessMode = 'copy' | 'scoped';
|
|
71
138
|
/**
|
|
72
139
|
* Default buttons for a message dialog.
|
|
73
140
|
*
|