@tauri-apps/plugin-dialog 2.4.2 → 2.5.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 +34 -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,13 @@ 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;
|
|
48
72
|
}
|
|
49
73
|
/**
|
|
50
74
|
* Options for the save dialog.
|
|
@@ -68,6 +92,15 @@ interface SaveDialogOptions {
|
|
|
68
92
|
/** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */
|
|
69
93
|
canCreateDirectories?: boolean;
|
|
70
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The preferred mode of the dialog.
|
|
97
|
+
* This is meant for mobile platforms (iOS and Android) which have distinct file and media pickers.
|
|
98
|
+
* On desktop, this option is ignored.
|
|
99
|
+
* If not provided, the dialog will automatically choose the best mode based on the MIME types or extensions of the {@linkcode filters}.
|
|
100
|
+
*
|
|
101
|
+
* **Note:** This option is only supported on iOS 14 and above. This parameter is ignored on iOS 13 and below.
|
|
102
|
+
*/
|
|
103
|
+
export type PickerMode = 'document' | 'media' | 'image' | 'video';
|
|
71
104
|
/**
|
|
72
105
|
* Default buttons for a message dialog.
|
|
73
106
|
*
|