Added a copy and paste context menu to all input fields
parent
99a8ab9017
commit
9da9a2eae5
|
@ -1,4 +1,7 @@
|
|||
# Changelog:
|
||||
* **12.06.20**
|
||||
- Added a copy/paste menu for all HTML input elements
|
||||
|
||||
* **11.06.20**
|
||||
- Fixed channel tree deletions
|
||||
- Removed layout recalculate bottleneck on connection handler switching
|
||||
|
|
|
@ -2,19 +2,19 @@ import * as moment from "moment";
|
|||
import * as loader from "tc-loader";
|
||||
import {settings, Settings} from "tc-shared/settings";
|
||||
import * as profiles from "tc-shared/profiles/ConnectionProfile";
|
||||
import {LogCategory} from "tc-shared/log";
|
||||
import * as log from "tc-shared/log";
|
||||
import {LogCategory} from "tc-shared/log";
|
||||
import * as bipc from "./BrowserIPC";
|
||||
import * as sound from "./sound/Sounds";
|
||||
import * as i18n from "./i18n/localize";
|
||||
import {tra} from "./i18n/localize";
|
||||
import {ConnectionHandler} from "tc-shared/ConnectionHandler";
|
||||
import {createInfoModal} from "tc-shared/ui/elements/Modal";
|
||||
import {tra} from "./i18n/localize";
|
||||
import * as stats from "./stats";
|
||||
import * as fidentity from "./profiles/identities/TeaForumIdentity";
|
||||
import {default_recorder, RecorderProfile, set_default_recorder} from "tc-shared/voice/RecorderProfile";
|
||||
import * as cmanager from "tc-shared/ui/frames/connection_handlers";
|
||||
import {server_connections, ConnectionManager} from "tc-shared/ui/frames/connection_handlers";
|
||||
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
|
||||
import {spawnConnectModal} from "tc-shared/ui/modal/ModalConnect";
|
||||
import * as top_menu from "./ui/frames/MenuBar";
|
||||
import {spawnYesNo} from "tc-shared/ui/modal/ModalYesNo";
|
||||
|
@ -29,11 +29,11 @@ import * as ReactDOM from "react-dom";
|
|||
import * as cbar from "./ui/frames/control-bar";
|
||||
import * as global_ev_handler from "./events/ClientGlobalControlHandler";
|
||||
import {global_client_actions} from "tc-shared/events/GlobalEvents";
|
||||
import {
|
||||
FileTransferState,
|
||||
TransferProvider,
|
||||
} from "tc-shared/file/Transfer";
|
||||
import {FileTransferState, TransferProvider,} from "tc-shared/file/Transfer";
|
||||
import {spawnFileTransferModal} from "tc-shared/ui/modal/transfer/ModalFileTransfer";
|
||||
import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMenu";
|
||||
import {copy_to_clipboard} from "tc-shared/utils/helpers";
|
||||
import ContextMenuEvent = JQuery.ContextMenuEvent;
|
||||
|
||||
/* required import for init */
|
||||
require("./proto").initialize();
|
||||
|
@ -67,7 +67,7 @@ function setup_close() {
|
|||
if(e.serverConnection.connected())
|
||||
return e.serverConnection.disconnect(tr("client closed"));
|
||||
return Promise.resolve();
|
||||
}).map(e => e.catch(error => {
|
||||
}).map(e => e.catch(() => {
|
||||
console.warn(tr("Failed to disconnect from server on client close: %o"), e);
|
||||
}));
|
||||
|
||||
|
@ -309,10 +309,35 @@ function main() {
|
|||
}
|
||||
|
||||
/* context menu prevent */
|
||||
$(document).on('contextmenu', event => {
|
||||
$(document).on('contextmenu', (event: ContextMenuEvent) => {
|
||||
if(event.isDefaultPrevented())
|
||||
return;
|
||||
|
||||
if(event.target instanceof HTMLInputElement) {
|
||||
if((!!event.target.value || __build.target === "client") && !event.target.disabled && !event.target.readOnly) {
|
||||
spawn_context_menu(event.pageX, event.pageY, {
|
||||
type: MenuEntryType.ENTRY,
|
||||
name: tr("Copy"),
|
||||
callback: () => {
|
||||
copy_to_clipboard(event.target.value);
|
||||
},
|
||||
icon_class: "client-copy",
|
||||
visible: !!event.target.value
|
||||
}, {
|
||||
type: MenuEntryType.ENTRY,
|
||||
name: tr("Paste"),
|
||||
callback: () => {
|
||||
const { clipboard } = __non_webpack_require__('electron');
|
||||
event.target.value = clipboard.readText();
|
||||
},
|
||||
icon_class: "client-copy",
|
||||
visible: __build.target === "client",
|
||||
});
|
||||
}
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!settings.static_global(Settings.KEY_DISABLE_GLOBAL_CONTEXT_MENU))
|
||||
event.preventDefault();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue