diff options
Diffstat (limited to 'src/lib/Menu.js')
-rw-r--r-- | src/lib/Menu.js | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 66447d551..8844c0ae8 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -28,6 +28,8 @@ import { workspaceStore } from '../features/workspaces/index'; | |||
28 | import apiBase, { termsBase } from '../api/apiBase'; | 28 | import apiBase, { termsBase } from '../api/apiBase'; |
29 | import { openExternalUrl } from '../helpers/url-helpers'; | 29 | import { openExternalUrl } from '../helpers/url-helpers'; |
30 | 30 | ||
31 | const debug = require('debug')('Ferdi:Menu'); | ||
32 | |||
31 | const menuItems = defineMessages({ | 33 | const menuItems = defineMessages({ |
32 | edit: { | 34 | edit: { |
33 | id: 'menu.edit', | 35 | id: 'menu.edit', |
@@ -320,8 +322,8 @@ const menuItems = defineMessages({ | |||
320 | }, | 322 | }, |
321 | }); | 323 | }); |
322 | 324 | ||
323 | function getActiveWebview() { | 325 | function getActiveService() { |
324 | return window.ferdi.stores.services.active.webview; | 326 | return window.ferdi.stores.services.active; |
325 | } | 327 | } |
326 | 328 | ||
327 | const _titleBarTemplateFactory = (intl, locked) => [ | 329 | const _titleBarTemplateFactory = (intl, locked) => [ |
@@ -360,7 +362,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
360 | accelerator: `${cmdOrCtrlShortcutKey()}+${shiftKey()}+V`, // Override the accelerator since this adds new key combo in macos | 362 | accelerator: `${cmdOrCtrlShortcutKey()}+${shiftKey()}+V`, // Override the accelerator since this adds new key combo in macos |
361 | role: 'pasteAndMatchStyle', | 363 | role: 'pasteAndMatchStyle', |
362 | click() { | 364 | click() { |
363 | getActiveWebview().pasteAndMatchStyle(); | 365 | getActiveService().webview.pasteAndMatchStyle(); |
364 | }, | 366 | }, |
365 | }, | 367 | }, |
366 | { | 368 | { |
@@ -396,18 +398,20 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
396 | label: intl.formatMessage(menuItems.findInPage), | 398 | label: intl.formatMessage(menuItems.findInPage), |
397 | accelerator: `${cmdOrCtrlShortcutKey()}+F`, | 399 | accelerator: `${cmdOrCtrlShortcutKey()}+F`, |
398 | click() { | 400 | click() { |
401 | const service = getActiveService(); | ||
399 | // Check if there is a service active | 402 | // Check if there is a service active |
400 | if (!window.ferdi.stores.services.active) return; | 403 | if (service) { |
401 | 404 | // Focus webview so find in page popup gets focused | |
402 | // Focus webview so find in page popup gets focused | 405 | service.webview.focus(); |
403 | window.ferdi.stores.services.active.webview.focus(); | ||
404 | 406 | ||
405 | const currentService = window.ferdi.stores.services.active.id; | 407 | window.ferdi.actions.service.sendIPCMessage({ |
406 | window.ferdi.actions.service.sendIPCMessage({ | 408 | serviceId: service.id, |
407 | serviceId: currentService, | 409 | channel: 'find-in-page', |
408 | channel: 'find-in-page', | 410 | args: {}, |
409 | args: {}, | 411 | }); |
410 | }); | 412 | } else { |
413 | debug('No service is active'); | ||
414 | } | ||
411 | }, | 415 | }, |
412 | }, | 416 | }, |
413 | { | 417 | { |
@@ -417,14 +421,14 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
417 | label: intl.formatMessage(menuItems.back), | 421 | label: intl.formatMessage(menuItems.back), |
418 | accelerator: `${cmdOrCtrlShortcutKey()}+Left`, | 422 | accelerator: `${cmdOrCtrlShortcutKey()}+Left`, |
419 | click() { | 423 | click() { |
420 | getActiveWebview().goBack(); | 424 | getActiveService().webview.goBack(); |
421 | }, | 425 | }, |
422 | }, | 426 | }, |
423 | { | 427 | { |
424 | label: intl.formatMessage(menuItems.forward), | 428 | label: intl.formatMessage(menuItems.forward), |
425 | accelerator: `${cmdOrCtrlShortcutKey()}+Right`, | 429 | accelerator: `${cmdOrCtrlShortcutKey()}+Right`, |
426 | click() { | 430 | click() { |
427 | getActiveWebview().goForward(); | 431 | getActiveService().webview.goForward(); |
428 | }, | 432 | }, |
429 | }, | 433 | }, |
430 | { | 434 | { |
@@ -435,7 +439,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
435 | accelerator: `${cmdOrCtrlShortcutKey()}+0`, | 439 | accelerator: `${cmdOrCtrlShortcutKey()}+0`, |
436 | role: 'resetZoom', | 440 | role: 'resetZoom', |
437 | click() { | 441 | click() { |
438 | getActiveWebview().setZoomLevel(0); | 442 | this.actions.service.zoomResetForActiveService(); |
439 | }, | 443 | }, |
440 | }, | 444 | }, |
441 | { | 445 | { |
@@ -443,11 +447,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
443 | accelerator: `${cmdOrCtrlShortcutKey()}+plus`, | 447 | accelerator: `${cmdOrCtrlShortcutKey()}+plus`, |
444 | role: 'zoomIn', | 448 | role: 'zoomIn', |
445 | click() { | 449 | click() { |
446 | const activeService = getActiveWebview(); | 450 | this.actions.service.zoomInForActiveService(); |
447 | const level = activeService.getZoomLevel(); | ||
448 | |||
449 | // level 9 =~ +300% and setZoomLevel wouldnt zoom in further | ||
450 | if (level < 9) activeService.setZoomLevel(level + 1); | ||
451 | }, | 451 | }, |
452 | }, | 452 | }, |
453 | { | 453 | { |
@@ -455,11 +455,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
455 | accelerator: `${cmdOrCtrlShortcutKey()}+-`, | 455 | accelerator: `${cmdOrCtrlShortcutKey()}+-`, |
456 | role: 'zoomOut', | 456 | role: 'zoomOut', |
457 | click() { | 457 | click() { |
458 | const activeService = getActiveWebview(); | 458 | this.actions.service.zoomOutForActiveService(); |
459 | const level = activeService.getZoomLevel(); | ||
460 | |||
461 | // level -9 =~ -50% and setZoomLevel wouldnt zoom out further | ||
462 | if (level > -9) activeService.setZoomLevel(level - 1); | ||
463 | }, | 459 | }, |
464 | }, | 460 | }, |
465 | { | 461 | { |