Skip to content

feat(input): browser editing + zoom shortcuts (⌘C/X/V/A/Z, ⌘+/-/0) for the OSR webview#19

Merged
wenkaifan0720 merged 1 commit into
mainfrom
feat/webview-editing-shortcuts
Jul 3, 2026
Merged

feat(input): browser editing + zoom shortcuts (⌘C/X/V/A/Z, ⌘+/-/0) for the OSR webview#19
wenkaifan0720 merged 1 commit into
mainfrom
feat/webview-editing-shortcuts

Conversation

@wenkaifan0720

Copy link
Copy Markdown
Collaborator

In OSR mode there's no AppKit responder chain, so a raw ⌘-key never becomes an editor action or zoom — a focused CefWebView couldn't copy/paste/select-all or zoom like a real browser. This wires the standard shortcuts.

Layers

  • Native (main.mm): kOpEditCommandDoEditCommand runs CefFrame::Copy/Cut/Paste/SelectAll/Undo/Redo on the focused frame (no-op when nothing's focused). Zoom reuses kOpSetZoom.
  • Plugin (Swift + Dart): editCommand op + CefWebController.copy/cut/paste/selectAll/undo/redo.
  • CefWebView._onKeyEvent: intercepts ⌘C/X/V/A/Z + ⌘⇧Z → edit commands, and ⌘=/-/0 → tracked content zoom (1.2^level, clamped ~48–207%). The ⌘/⇧ modifiers still forward to the page (browsers fire keydown for them); the shortcut letter is consumed.
  • Protocol version 1 → 2 (new inbound op) — the handshake refuses a mismatched host, so this ships with a republished host + atomic consumer pin bump.

Tests

9 new widget tests drive the real focus/key path and assert the channel calls (⌘C → editCommand(0)⌘0 → setZoomLevel(0)). Full suite 141 green, analyze clean. The native CefFrame edit commands are the canonical CEF-OSR approach (not unit-testable here) — validated live in Campus.

Follow-up (not here): ⌘F find-in-page (the find op already exists; needs a small find UI).

🤖 Generated with Claude Code

…r the OSR webview

In off-screen-rendering mode there's no AppKit responder chain, so a raw ⌘-key event never becomes
an editor action or a zoom — a focused CefWebView couldn't copy/paste/select-all or zoom like a real
browser (the #1 nit reported for webviews in Campus). Wire the standard shortcuts to explicit
commands:

- Native (main.mm): kOpEditCommand → DoEditCommand runs a focused-frame edit command via
  CefFrame::Copy/Cut/Paste/SelectAll/Undo/Redo (no-ops when nothing is focused/selected). Zoom
  reuses the existing kOpSetZoom.
- Plugin (Swift + Dart): editCommand op + CefWebController.copy/cut/paste/selectAll/undo/redo;
  setZoomLevel already existed.
- CefWebView._onKeyEvent: intercept ⌘C/X/V/A/Z + ⌘⇧Z → the edit commands, and ⌘=/-/0 → a tracked
  content-zoom level (1.2^level steps, clamped ~48%..207%). Editing on key-down; zoom repeat-friendly.
  The ⌘/⇧ modifier keydowns still forward to the page (a browser fires keydown for them); the
  shortcut letter itself is consumed.
- Protocol version bumped 1 → 2 (new inbound op); the handshake refuses a mismatched host, so this
  ships with a republished host + atomic consumer pin bump.

Tests: 9 new widget tests drive the real focus/key path and assert the channel calls
(⌘C→editCommand(0) … ⌘0→setZoomLevel(0)); full suite 141 green; analyze clean. Native CefFrame edit
commands are the canonical CEF-OSR approach (not unit-testable here) — validated live in Campus.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wenkaifan0720 wenkaifan0720 merged commit cfa05ad into main Jul 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant