diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/webview/contextMenuBuilder.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/webview/contextMenuBuilder.ts b/src/webview/contextMenuBuilder.ts index d18bc56f9..0d8b659f0 100644 --- a/src/webview/contextMenuBuilder.ts +++ b/src/webview/contextMenuBuilder.ts | |||
@@ -249,6 +249,10 @@ export class ContextMenuBuilder { | |||
249 | return this.buildMenuForImage(info); | 249 | return this.buildMenuForImage(info); |
250 | } | 250 | } |
251 | 251 | ||
252 | if (info.mediaType === 'video') { | ||
253 | return this.buildMenuForVideo(info); | ||
254 | } | ||
255 | |||
252 | if ( | 256 | if ( |
253 | info.isEditable || | 257 | info.isEditable || |
254 | (info.inputFieldType && info.inputFieldType !== 'none') | 258 | (info.inputFieldType && info.inputFieldType !== 'none') |
@@ -407,6 +411,40 @@ export class ContextMenuBuilder { | |||
407 | } | 411 | } |
408 | 412 | ||
409 | /** | 413 | /** |
414 | * Builds a menu applicable to a video. | ||
415 | * | ||
416 | * @return {Menu} The `Menu` | ||
417 | */ | ||
418 | buildMenuForVideo( | ||
419 | menuInfo: IContextMenuParams, | ||
420 | ): Electron.CrossProcessExports.Menu { | ||
421 | const menu = new Menu(); | ||
422 | const video = document.querySelectorAll('video')[0]; | ||
423 | |||
424 | if ( | ||
425 | document.pictureInPictureEnabled && | ||
426 | !video.disablePictureInPicture && | ||
427 | this.isSrcUrlValid(menuInfo) | ||
428 | ) { | ||
429 | menu.append( | ||
430 | new MenuItem({ | ||
431 | type: 'checkbox', | ||
432 | label: 'Picture in picture', | ||
433 | enabled: true, | ||
434 | checked: !!document.pictureInPictureElement, | ||
435 | click: async () => { | ||
436 | await (document.pictureInPictureElement | ||
437 | ? document.exitPictureInPicture() | ||
438 | : video.requestPictureInPicture()); | ||
439 | }, | ||
440 | }), | ||
441 | ); | ||
442 | } | ||
443 | |||
444 | return menu; | ||
445 | } | ||
446 | |||
447 | /** | ||
410 | * Checks if the current text selection contains a single misspelled word and | 448 | * Checks if the current text selection contains a single misspelled word and |
411 | * if so, adds suggested spellings as individual menu items. | 449 | * if so, adds suggested spellings as individual menu items. |
412 | */ | 450 | */ |