clarified read option docs for use_clipboard.

Closes #119
This commit is contained in:
Maccesch 2024-07-26 10:56:39 +01:00
parent ffd4f0a6fe
commit 17cfb8a23b
3 changed files with 7 additions and 2 deletions

1
.idea/leptos-use.iml generated
View file

@ -77,6 +77,7 @@
<sourceFolder url="file://$MODULE_DIR$/examples/use_or/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/examples/use_event_source/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/examples/sync_signal/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/examples/use_user_media/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/examples/use_event_listener/target" />
<excludeFolder url="file://$MODULE_DIR$/target" />
<excludeFolder url="file://$MODULE_DIR$/docs/book/book" />

View file

@ -1,6 +1,8 @@
use leptos::*;
use leptos_use::docs::{demo_or_body, Note};
use leptos_use::{use_clipboard, use_permission, UseClipboardReturn};
use leptos_use::{
use_clipboard_with_options, use_permission, UseClipboardOptions, UseClipboardReturn,
};
#[component]
fn Demo() -> impl IntoView {
@ -11,7 +13,7 @@ fn Demo() -> impl IntoView {
text,
copied,
copy,
} = use_clipboard();
} = use_clipboard_with_options(UseClipboardOptions::default().read(true));
let permission_read = use_permission("clipboard-read");
let permission_write = use_permission("clipboard-write");

View file

@ -127,6 +127,8 @@ pub fn use_clipboard_with_options(
pub struct UseClipboardOptions {
/// When `true` event handlers are added so that the returned signal `text` is updated whenever the clipboard changes.
/// Defaults to `false`.
///
/// > Please note that clipboard changes are only detected when copying or cutting text inside the same document.
read: bool,
/// After how many milliseconds after copying should the returned signal `copied` be set to `false`?