mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
feat(ui): re-enable input selection and add context menu
Re-enable user selection for input and textarea elements so users can select and copy text in form fields. Add an Electron context menu handler that shows a focused edit menu only for recognized text input types or editable fields. The menu includes Cut, Copy, Paste and Select All and respects the editFlags to enable actions. This restores native editing UX in the renderer while avoiding global context menus elsewhere in the app.
This commit is contained in:
1 parent
c2c06a99be
commit
a5685ef27d
2 files changed
+44
-1
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { BrowserWindow, screen, shell } from 'electron';
|
||||
import { BrowserWindow, Menu, screen, shell } from 'electron';
|
||||
import { join } from 'path';
|
||||
import { environment } from '../environments/environment';
|
||||
import { rendererAppName, rendererAppPort } from './constants';
|
||||
@@ -115,6 +115,43 @@ export default class App {
|
||||
store.set(WINDOW_BOUNDS, App.mainWindow.getNormalBounds());
|
||||
}
|
||||
});
|
||||
|
||||
// Enable context menu for input fields only
|
||||
App.mainWindow.webContents.on('context-menu', (event, params) => {
|
||||
const { isEditable, editFlags } = params;
|
||||
|
||||
// Check if this is an editable field (input, textarea, contenteditable)
|
||||
// editFlags.canPaste is a good indicator of an input field
|
||||
if (isEditable && editFlags.canPaste) {
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Cut',
|
||||
role: 'cut',
|
||||
enabled: editFlags.canCut,
|
||||
},
|
||||
{
|
||||
label: 'Copy',
|
||||
role: 'copy',
|
||||
enabled: editFlags.canCopy,
|
||||
},
|
||||
{
|
||||
label: 'Paste',
|
||||
role: 'paste',
|
||||
enabled: editFlags.canPaste,
|
||||
},
|
||||
{
|
||||
type: 'separator',
|
||||
},
|
||||
{
|
||||
label: 'Select All',
|
||||
role: 'selectAll',
|
||||
enabled: editFlags.canSelectAll,
|
||||
},
|
||||
]);
|
||||
|
||||
menu.popup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static loadMainWindow() {
|
||||
|
||||
@@ -23,6 +23,12 @@ html {
|
||||
font-family: Roboto, 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
// Re-enable context menu and text selection for input fields
|
||||
input,
|
||||
textarea {
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
@media (display-mode: standalone) {
|
||||
body {
|
||||
overscroll-behavior-y: contain;
|
||||
|
||||
Reference in new issue
Block a user