1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Paste-intercept plumbing shared by the two editors (backlog
//! first-app/0273): [`PasteAction`] + the shared hook slot both
//! `TextInput` and `TextArea` consult BEFORE inserting a paste.
//!
//! WHY A HOOK AND NOT AN EVENT: `UiEvent::Paste` already routes to the
//! focused widget whole (never per-char synthesis — the injection
//! attack bracketed paste exists to prevent). What apps need is a
//! DECISION POINT between "the paste arrived" and "the editor inserted
//! it": a terminal file DROP arrives as a paste of the file's path
//! (see `input::paste` for the cross-terminal spellings), and an
//! attachment-taking composer wants to turn that paste into a chip
//! instead of text. The hook sees the RAW paste text and answers
//! [`PasteAction`]; everything else — classification, fs checks,
//! chips — is app code on top.
//!
//! ORDERING vs the disposal-safety law (backlog 0297): the law says
//! user callbacks run LAST so they may dispose the widget's scope.
//! This hook is a different kind of callback — an INTERCEPTOR whose
//! whole point is to run FIRST (it decides whether widget writes
//! happen at all). The law's guarantee is preserved from both arms:
//! on [`PasteAction::Consume`] the widget performs NO signal writes
//! after the hook; on [`PasteAction::Insert`] the widget re-checks
//! its value signal's liveness and treats a hook that disposed the
//! scope as consumed (nothing left to insert into) instead of
//! panicking on dead signals.
//!
//! OWNER: REACT.
use RefCell;
use Rc;
/// The app's decision for one intercepted paste (see
/// [`TextInput::on_paste`](super::TextInput::on_paste) /
/// [`TextArea::on_paste`](crate::widgets::TextArea::on_paste)).
///
/// `#[non_exhaustive]` per ADR-0003 §3 — an enum the engine may grow
/// (a replace-text variant is a plausible future). Constructing the
/// existing variants is stable downstream; foreign `match`es carry a
/// `_` arm (treat unknown future actions as [`PasteAction::Insert`]
/// if you must map them — never silently drop user text).
/// Boxed intercept callback (`on_paste` builder slots).
pub type PasteHookFn = ;
/// The shared slot both editors consult from their event handlers.
/// Same shape as `widgets::SharedCallback`; same held-borrow contract
/// (dispatch-only slot — see the `SharedCallback` docs).
pub type PasteHook = ;
/// Run the intercept hook against the raw paste text. `None` = no hook
/// bound (the caller proceeds with today's insertion, byte-identical);
/// `Some(action)` = the hook ran and the caller must honor the action
/// AND re-check its signals' liveness before writing (the hook may
/// have disposed the widget's scope — module docs).
pub