Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/feat-webview-auto-resize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri": "minor:feat"
"@tauri-apps/api": "minor:feat"
---

Expose the `setAutoResize` API for webviews in `@tauri-apps/api`.

1 change: 1 addition & 0 deletions crates/tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const PLUGINS: &[(&str, &[(&str, bool)])] = &[
("set_webview_size", false),
("set_webview_position", false),
("set_webview_focus", false),
("set_webview_auto_resize", false),
("set_webview_zoom", false),
("webview_hide", false),
("webview_show", false),
Expand Down
26 changes: 26 additions & 0 deletions crates/tauri/permissions/webview/autogenerated/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,32 @@ Denies the reparent command without any pre-configured scope.
<tr>
<td>

`core:webview:allow-set-webview-auto-resize`

</td>
<td>

Enables the set_webview_auto_resize command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`core:webview:deny-set-webview-auto-resize`

</td>
<td>

Denies the set_webview_auto_resize command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`core:webview:allow-set-webview-background-color`

</td>
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri/scripts/bundle.global.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions crates/tauri/src/webview/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ mod desktop_commands {
setter!(set_webview_size, set_size, Size);
setter!(set_webview_position, set_position, Position);
setter!(set_webview_focus, set_focus);
setter!(set_webview_auto_resize, set_auto_resize, bool);
setter!(webview_hide, hide);
setter!(webview_show, show);
setter!(set_webview_zoom, set_zoom, f64);
Expand Down Expand Up @@ -310,6 +311,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
desktop_commands::set_webview_size,
desktop_commands::set_webview_position,
desktop_commands::set_webview_focus,
desktop_commands::set_webview_auto_resize,
desktop_commands::set_webview_background_color,
desktop_commands::set_webview_zoom,
desktop_commands::webview_hide,
Expand Down
17 changes: 17 additions & 0 deletions packages/api/src/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,23 @@ class Webview {
})
}

/**
* Sets whether the webview should automatically grow and shrink its size and position when the parent window resizes.
* @example
* ```typescript
* import { getCurrentWebview } from '@tauri-apps/api/webview';
* await getCurrentWebview().setAutoReisze(true);
* ```
*
* @returns A promise indicating the success or failure of the operation.
*/
async setAutoResize(autoResize: boolean): Promise<void> {
return invoke('plugin:webview|set_webview_auto_resize', {
label: this.label,
value: autoResize
})
}

/**
* Hide the webview.
* @example
Expand Down