Expand description
Ported from Arc (MIT) © 2026 Elia Kuratli
Reference: Arc源码/arc-library/registry/components/inline-edit/inline-edit.tsx & .module.css
P4 Component #20: inline-edit
- Click-to-edit text for fields read far more often than they change:
- The text turns into a field in place with the same metrics; Enter saves, Escape rolls back, and a failed save restores the last saved value and says why.
- Phases:
idle→saving→saved(a drawn check pops, then fades after1.8s) orfailed(the old words drop back in with a warning flash lasting1.4s). validateruns before saving and an error message reveals under the field.- Keyboard: Enter saves, Escape cancels; the text rolls in the direction the value moved
(later = up, rollback = down) on
standardwith a2–8pxblur sharpen.
Known deviations from upstream:
on_savereturnsResult<(), SharedString>synchronously instead of a Promise:Okshows the saved check,Err(msg)rolls back and revealsmsg. There is no separate async “saving” phase.- The multiline variant, caret-position-at-point, and the web
aselement override are omitted; the width morphs only in single-line mode via a text-width estimate.
Structs§
- Inline
Edit - Arc
InlineEdit— click-to-edit text with save/rollback phases.
Enums§
Constants§
- INLINE_
EDIT_ FAIL_ FLASH_ SECS - How long (
1.4s) the failure flash stays on. - INLINE_
EDIT_ SAVED_ HOLD_ SECS - How long (
1.8s) the saved check stays visible before fading.
Functions§
- inline_
edit_ clean - Cleans whitespace the way upstream does: single-line collapses runs to one space.