Skip to content

Commit

Permalink
Enable deprecated paste (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Feb 26, 2025
1 parent 9245913 commit 03f1b4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
3 changes: 2 additions & 1 deletion source/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,8 @@ app.View = class {
height: size.height > 768 ? 768 : size.height,
webPreferences: {
preload: path.join(dirname, 'electron.mjs'),
nodeIntegration: true
nodeIntegration: true,
enableDeprecatedPaste: true
}
};
if (owner.application.environment.titlebar) {
Expand Down
13 changes: 9 additions & 4 deletions source/electron.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,21 @@ host.ElectronHost = class {
this._view.export(data.file);
});
electron.ipcRenderer.on('cut', () => {
this._view.cut();
this.document.execCommand('cut');
});
electron.ipcRenderer.on('copy', () => {
this._view.copy();
this.document.execCommand('copy');
});
electron.ipcRenderer.on('paste', () => {
this._view.paste();
if (this.document.queryCommandSupported('paste')) {
this.document.execCommand('paste');
} else if (this.document.queryCommandSupported('insertText')) {
const content = electron.clipboard.readText();
this.document.execCommand('insertText', false, content);
}
});
electron.ipcRenderer.on('selectall', () => {
this._view.selectAll();
this.document.execCommand('selectall');
});
electron.ipcRenderer.on('toggle', (sender, name) => {
this._view.toggle(name);
Expand Down
16 changes: 0 additions & 16 deletions source/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,6 @@ view.View = class {
}
}

cut() {
this._host.document.execCommand('cut');
}

copy() {
this._host.document.execCommand('copy');
}

paste() {
this._host.document.execCommand('paste');
}

selectAll() {
this._host.document.execCommand('selectall');
}

find() {
if (this._graph && this._sidebar.identifier !== 'find') {
this._graph.select(null);
Expand Down

0 comments on commit 03f1b4a

Please sign in to comment.