aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-06-05 16:28:52 +0530
committerLibravatar GitHub <noreply@github.com>2021-06-05 12:58:52 +0200
commit079765bad8a577d140166098e8dd0b7fe0660e4e (patch)
tree4a157a1e5fd0eb3b6a2ce71229a0aed7165dddb3 /src/webview
parentRemoved hardcoded strings and reused constants defined in config.js (#1499) (diff)
downloadferdium-app-079765bad8a577d140166098e8dd0b7fe0660e4e.tar.gz
ferdium-app-079765bad8a577d140166098e8dd0b7fe0660e4e.tar.zst
ferdium-app-079765bad8a577d140166098e8dd0b7fe0660e4e.zip
Added ability to turn off notifications for clipboard events generated by context menu actions (#1494)
Diffstat (limited to 'src/webview')
-rw-r--r--src/webview/contextMenu.js4
-rw-r--r--src/webview/contextMenuBuilder.js17
-rw-r--r--src/webview/recipe.js1
3 files changed, 13 insertions, 9 deletions
diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js
index f19d863ee..567a2d470 100644
--- a/src/webview/contextMenu.js
+++ b/src/webview/contextMenu.js
@@ -3,7 +3,7 @@ import ContextMenuBuilder from './contextMenuBuilder';
3 3
4const webContents = getCurrentWebContents(); 4const webContents = getCurrentWebContents();
5 5
6export default async function setupContextMenu(isSpellcheckEnabled, getDefaultSpellcheckerLanguage, getSpellcheckerLanguage, getSearchEngine) { 6export default async function setupContextMenu(isSpellcheckEnabled, getDefaultSpellcheckerLanguage, getSpellcheckerLanguage, getSearchEngine, getClipboardNotifications) {
7 const contextMenuBuilder = new ContextMenuBuilder( 7 const contextMenuBuilder = new ContextMenuBuilder(
8 webContents, 8 webContents,
9 ); 9 );
@@ -11,7 +11,7 @@ export default async function setupContextMenu(isSpellcheckEnabled, getDefaultSp
11 webContents.on('context-menu', (e, props) => { 11 webContents.on('context-menu', (e, props) => {
12 // TODO?: e.preventDefault(); 12 // TODO?: e.preventDefault();
13 contextMenuBuilder.showPopupMenu( 13 contextMenuBuilder.showPopupMenu(
14 { ...props, searchEngine: getSearchEngine() }, 14 { ...props, searchEngine: getSearchEngine(), clipboardNotifications: getClipboardNotifications() },
15 isSpellcheckEnabled(), 15 isSpellcheckEnabled(),
16 getDefaultSpellcheckerLanguage(), 16 getDefaultSpellcheckerLanguage(),
17 getSpellcheckerLanguage(), 17 getSpellcheckerLanguage(),
diff --git a/src/webview/contextMenuBuilder.js b/src/webview/contextMenuBuilder.js
index 7c178145d..c26f192fe 100644
--- a/src/webview/contextMenuBuilder.js
+++ b/src/webview/contextMenuBuilder.js
@@ -161,7 +161,7 @@ module.exports = class ContextMenuBuilder {
161 // Omit the mailto: portion of the link; we just want the address 161 // Omit the mailto: portion of the link; we just want the address
162 const url = isEmailAddress ? menuInfo.linkText : menuInfo.linkURL; 162 const url = isEmailAddress ? menuInfo.linkText : menuInfo.linkURL;
163 clipboard.writeText(url); 163 clipboard.writeText(url);
164 this.sendNotificationOnClipboardEvent(`Link URL copied: ${url}`); 164 this._sendNotificationOnClipboardEvent(menuInfo.clipboardNotifications, () => `Link URL copied: ${url}`);
165 }, 165 },
166 }); 166 });
167 167
@@ -321,7 +321,7 @@ module.exports = class ContextMenuBuilder {
321 const result = this.convertImageToBase64(menuInfo.srcURL, 321 const result = this.convertImageToBase64(menuInfo.srcURL,
322 dataURL => clipboard.writeImage(nativeImage.createFromDataURL(dataURL))); 322 dataURL => clipboard.writeImage(nativeImage.createFromDataURL(dataURL)));
323 323
324 this.sendNotificationOnClipboardEvent(`Image copied from URL: ${menuInfo.srcURL}`); 324 this._sendNotificationOnClipboardEvent(menuInfo.clipboardNotifications, () => `Image copied from URL: ${menuInfo.srcURL}`);
325 return result; 325 return result;
326 }, 326 },
327 }); 327 });
@@ -332,7 +332,7 @@ module.exports = class ContextMenuBuilder {
332 label: this.stringTable.copyImageUrl(), 332 label: this.stringTable.copyImageUrl(),
333 click: () => { 333 click: () => {
334 const result = clipboard.writeText(menuInfo.srcURL); 334 const result = clipboard.writeText(menuInfo.srcURL);
335 this.sendNotificationOnClipboardEvent(`Image URL copied: ${menuInfo.srcURL}`); 335 this._sendNotificationOnClipboardEvent(menuInfo.clipboardNotifications, () => `Image URL copied: ${menuInfo.srcURL}`);
336 return result; 336 return result;
337 }, 337 },
338 }); 338 });
@@ -357,7 +357,7 @@ module.exports = class ContextMenuBuilder {
357 }, 357 },
358 }); 358 });
359 }); 359 });
360 this.sendNotificationOnClipboardEvent(`Image downloaded: ${urlWithoutBlob}`); 360 this._sendNotificationOnClipboardEvent(menuInfo.clipboardNotifications, () => `Image downloaded: ${urlWithoutBlob}`);
361 }, 361 },
362 }); 362 });
363 363
@@ -520,7 +520,7 @@ module.exports = class ContextMenuBuilder {
520 enabled: true, 520 enabled: true,
521 click: () => { 521 click: () => {
522 clipboard.writeText(window.location.href); 522 clipboard.writeText(window.location.href);
523 this.sendNotificationOnClipboardEvent(`Page URL copied: ${window.location.href}`); 523 this._sendNotificationOnClipboardEvent(menu.clipboardNotifications, () => `Page URL copied: ${window.location.href}`);
524 }, 524 },
525 })); 525 }));
526 526
@@ -560,11 +560,14 @@ module.exports = class ContextMenuBuilder {
560 return menu; 560 return menu;
561 } 561 }
562 562
563 sendNotificationOnClipboardEvent(notificationText) { 563 _sendNotificationOnClipboardEvent(isDisabled, notificationText) {
564 if (isDisabled) {
565 return;
566 }
564 // eslint-disable-next-line no-new 567 // eslint-disable-next-line no-new
565 new window.Notification('Data copied into Clipboard', 568 new window.Notification('Data copied into Clipboard',
566 { 569 {
567 body: notificationText, 570 body: notificationText(),
568 }); 571 });
569 } 572 }
570}; 573};
diff --git a/src/webview/recipe.js b/src/webview/recipe.js
index 5a24effa2..6c382d388 100644
--- a/src/webview/recipe.js
+++ b/src/webview/recipe.js
@@ -92,6 +92,7 @@ class RecipeController {
92 () => this.settings.app.spellcheckerLanguage, 92 () => this.settings.app.spellcheckerLanguage,
93 () => this.spellcheckerLanguage, 93 () => this.spellcheckerLanguage,
94 () => this.settings.app.searchEngine, 94 () => this.settings.app.searchEngine,
95 () => this.settings.app.clipboardNotifications,
95 ); 96 );
96 97
97 autorun(() => this.update()); 98 autorun(() => this.update());