[MM-20822] Added cut/paste/zoom events to other pages and added exceptions for dev tools and new server modal (#1133)
* [MM-20822] Added cut/paste/zoom events to other pages and added exceptions for dev tools and new server modal * Using getFocusedWebContents * Fixed an issue where the webcontents aren't found if you're on a login page * Potential fix for mojave pasting on new team modal
This commit is contained in:
@@ -76,6 +76,17 @@ export default class MainPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTabWebContents(index = this.state.key || 0, teams = this.props.teams) {
|
getTabWebContents(index = this.state.key || 0, teams = this.props.teams) {
|
||||||
|
const allWebContents = remote.webContents.getAllWebContents();
|
||||||
|
const openDevTools = allWebContents.find((webContents) => webContents.getURL().includes('chrome-devtools') && webContents.isFocused());
|
||||||
|
if (openDevTools) {
|
||||||
|
return openDevTools;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.showNewTeamModal) {
|
||||||
|
const indexURL = '/browser/index.html';
|
||||||
|
return allWebContents.find((webContents) => webContents.getURL().includes(indexURL));
|
||||||
|
}
|
||||||
|
|
||||||
if (!teams || !teams.length || index > teams.length) {
|
if (!teams || !teams.length || index > teams.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -83,7 +94,7 @@ export default class MainPage extends React.Component {
|
|||||||
if (!tabURL) {
|
if (!tabURL) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return remote.webContents.getAllWebContents().find((webContents) => webContents.getURL().includes(tabURL));
|
return allWebContents.find((webContents) => webContents.getURL().includes(tabURL) || webContents.getURL().includes(this.refs[`mattermostView${index}`].getSrc()));
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@@ -38,6 +38,10 @@ export default class SettingsPage extends React.Component {
|
|||||||
this.saveQueue = [];
|
this.saveQueue = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTabWebContents() {
|
||||||
|
return remote.webContents.getFocusedWebContents();
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
config.on('update', (configData) => {
|
config.on('update', (configData) => {
|
||||||
this.updateSaveState();
|
this.updateSaveState();
|
||||||
@@ -75,6 +79,84 @@ export default class SettingsPage extends React.Component {
|
|||||||
ipcRenderer.on('switch-tab', (event, key) => {
|
ipcRenderer.on('switch-tab', (event, key) => {
|
||||||
backToIndex(key);
|
backToIndex(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('zoom-in', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeTabWebContents.getZoomLevel() >= 9) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.setZoomLevel(activeTabWebContents.getZoomLevel() + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('zoom-out', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeTabWebContents.getZoomLevel() <= -8) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.setZoomLevel(activeTabWebContents.getZoomLevel() - 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('zoom-reset', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.setZoomLevel(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('undo', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.undo();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('redo', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.redo();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('cut', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.cut();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('copy', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.copy();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('paste', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.paste();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('paste-and-match', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.pasteAndMatchStyle();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
convertConfigDataToState = (configData, currentState = {}) => {
|
convertConfigDataToState = (configData, currentState = {}) => {
|
||||||
|
@@ -19,6 +19,10 @@ class UpdaterPageContainer extends React.Component {
|
|||||||
this.state = props.initialState;
|
this.state = props.initialState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTabWebContents() {
|
||||||
|
return remote.webContents.getFocusedWebContents();
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
ipcRenderer.on('start-download', () => {
|
ipcRenderer.on('start-download', () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -30,6 +34,83 @@ class UpdaterPageContainer extends React.Component {
|
|||||||
progress,
|
progress,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
ipcRenderer.on('zoom-in', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeTabWebContents.getZoomLevel() >= 9) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.setZoomLevel(activeTabWebContents.getZoomLevel() + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('zoom-out', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeTabWebContents.getZoomLevel() <= -8) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.setZoomLevel(activeTabWebContents.getZoomLevel() - 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('zoom-reset', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.setZoomLevel(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('undo', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.undo();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('redo', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.redo();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('cut', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.cut();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('copy', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.copy();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('paste', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.paste();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('paste-and-match', () => {
|
||||||
|
const activeTabWebContents = this.getTabWebContents();
|
||||||
|
if (!activeTabWebContents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeTabWebContents.pasteAndMatchStyle();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
Reference in New Issue
Block a user