Skip to main content

Module inline_edit

Module inline_edit 

Source
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 after 1.8s) or failed (the old words drop back in with a warning flash lasting 1.4s).
    • validate runs 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 standard with a 2–8px blur sharpen.

Known deviations from upstream:

  • on_save returns Result<(), SharedString> synchronously instead of a Promise: Ok shows the saved check, Err(msg) rolls back and reveals msg. There is no separate async “saving” phase.
  • The multiline variant, caret-position-at-point, and the web as element override are omitted; the width morphs only in single-line mode via a text-width estimate.

Structs§

InlineEdit
Arc InlineEdit — click-to-edit text with save/rollback phases.

Enums§

InlineEditPhase

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.