mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
This commit is contained in:
7
.changes/feat-webview-auto-resize.md
Normal file
7
.changes/feat-webview-auto-resize.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"tauri": "minor:feat"
|
||||
"@tauri-apps/api": "minor:feat"
|
||||
---
|
||||
|
||||
Expose the `setAutoResize` API for webviews in `@tauri-apps/api`.
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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);
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user