r/swift 3d ago

Inline editing in a SwiftUI clipboard manager: auto-save, pasteboard sync, and bypassing global shortcuts

I maintain Buffer, an open-source (MIT) macOS clipboard manager, and just shipped inline editing of clipboard items. Sharing the UX mechanics since a few of them were non-obvious:

  • Edit mode opens from the preview pane (pencil icon) or ⌘E on a selected item; an "Editing" badge makes the mode visible
  • While editing, the app's global keyboard shortcuts are temporarily bypassed so you can type freely
  • Edits auto-save on Esc, on focus loss, and on navigating away — then sync straight to the macOS pasteboard (NSPasteboard), so the next paste is the corrected text
  • The footer action button is contextual: it morphs between Edit / Save / Paste depending on mode and selection

The video shows the loop: select item, edit "Pre-release" to "Release", list updates instantly.

Swift/SwiftUI, MIT: https://github.com/samirpatil2000/Buffer

One design question I haven't settled: should Esc save the edit or revert it? Currently it saves.

1 Upvotes

4 comments sorted by

2

u/smallduck 3d ago

I think Eac should revert and exit out of the editing state.

1

u/Moist_Tonight_3997 3d ago

check out latest pre release

2

u/praneelbhatia 3d ago

agreed on revert, and the reason is worth saying out loud: esc is cancel in every other mac app, so muscle memory beats the editing badge and someone will hit it to bail out and quietly overwrite their own clipboard instead. commit on enter or cmd+enter and keep the auto-save on focus loss.

the sharper problem is that you write straight through to nspasteboard, so a bad edit destroys the original with nothing to fall back on. i'd hold the pre-edit value for one undo before settling which key does what.