Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 18, 2025

This PR adds a user setting to disable the automatic text selection menu that appears when users select text in the ebook reader. This resolves conflicts with browser translation extensions that also respond to text selection events.

Problem

Users who have browser translation extensions (like Google Translate, Youdao, etc.) installed experience conflicts when selecting text in the reader. Both the reader's text selection menu and the translation extension popup would appear simultaneously, creating a poor user experience.

Solution

Added a new setting "Disable automatic text selection menu" that allows users to:

  • Keep the default behavior (text selection menu appears) when the setting is disabled
  • Disable the automatic popup menu when the setting is enabled, while preserving text selection functionality

Changes Made

  • Settings Interface: Added disableTextSelectionMenu boolean property to the Settings interface in state.ts
  • UI Component: Added checkbox control in the Settings page with proper internationalization
  • Text Selection Logic: Modified TextSelectionMenu component to conditionally render based on the setting
  • Localization: Added translation strings for English, Chinese (Simplified), and Japanese

Screenshots

Settings Page with New Option:
Settings with Text Selection Menu option

Setting Enabled (Checkbox Checked):
Setting enabled state

Behavior Comparison:

Default behavior (setting disabled) - Text selection menu appears:
Text selection with menu enabled

With setting enabled - No popup menu appears:
Text selection with menu disabled

Implementation Details

  • The setting is persisted in localStorage using the existing settings system
  • Text selection functionality continues to work normally in both modes
  • The implementation follows React hooks rules and maintains proper component lifecycle
  • No breaking changes to existing functionality

Testing

  • ✅ Builds successfully in both development and production modes
  • ✅ Passes all linting checks
  • ✅ Setting persistence works correctly
  • ✅ Internationalization works for all supported languages
  • ✅ Text selection behavior verified for both enabled/disabled states
  • ✅ No conflicts with existing text selection functionality

This change provides users with the flexibility to choose their preferred text selection experience while maintaining full backward compatibility.

Fixes #142.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Aug 18, 2025

@pacexy 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copy link

vercel bot commented Aug 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
flow-reader Ready Ready Preview Comment Aug 18, 2025 2:02pm
flow-website Ready Ready Preview Comment Aug 18, 2025 2:02pm

@Copilot Copilot AI changed the title [WIP] 关于选择单词后自动弹出的菜单 Add setting to disable automatic text selection menu Aug 18, 2025
@Copilot Copilot AI requested a review from pacexy August 18, 2025 14:06
Copilot finished work on behalf of pacexy August 18, 2025 14:06
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.

关于选择单词后自动弹出的菜单
2 participants