Skip to content

Conversation

MarkShawn2020
Copy link

功能概述

Add Shift+Alt+C keyboard shortcut to toggle between two operation modes:

  • 📝 IDE Mode (default): Click element to open in IDE
  • 📋 Copy Mode: Click element to copy file path to clipboard

主要特性

1. Mode Switching

  • Keyboard shortcut: Shift+Alt+C
  • Toast notification displays current mode
  • Mode indicator shown in popup overlay

2. Fixed Copy Path Bug

Before: Copy function returned IDE name (e.g., "vscode") instead of file path
After: Returns actual file path in format path:line:column

Example: /Users/project/src/App.tsx:42:10

3. Cross-Platform Keyboard Support

Improved keyboard event detection using multiple methods (e.key, e.code, e.keyCode) for cross-browser/OS compatibility.

Technical Implementation

Modified files:

  • packages/core/src/client/index.ts - Core functionality (~160 lines added)
  • packages/core/types/client/index.d.ts - TypeScript type definitions

New state:

@state() actionMode: 'ide' | 'copy' = 'ide';
@state() showModeToast = false;
@state() modeToastTimer: number | null = null;

New methods:

  • toggleMode() - Switch between IDE and copy modes
  • showModeToastNotification() - Display toast notification
  • handleKeyDown(e: KeyboardEvent) - Handle Shift+Alt+C shortcut

Updated UI:

  • Mode indicator in element overlay
  • Toast notification with fade animation
  • Dynamic tooltip text based on current mode

Use Cases

  1. Code Review: Quickly copy file paths to share with team
  2. Documentation: Reference specific code locations in docs
  3. Issue Tracking: Precisely locate code in bug reports
  4. Daily Development: Flexibly switch between IDE opening and path copying

Testing

Tested on:

  • ✅ macOS 15.0 + Chrome 130
  • ✅ macOS 15.0 + Safari 18
  • ✅ Next.js 14 project
  • ✅ Vite 5 + React 18 project
  • ✅ Keyboard compatibility across platforms

Backwards Compatibility

  • Fully backwards compatible
  • ✅ Default behavior unchanged (IDE mode)
  • ✅ No breaking changes to existing API
  • ✅ No impact on users who don't use the feature

For users not using the new shortcut, experience is identical to before.

Demo

Press Shift+Alt+C while the inspector is active to see the mode toggle toast notification. The overlay will show which mode is active.

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