From 6ebe28f02b3628e5b50e466318b9f5652ce0c5a5 Mon Sep 17 00:00:00 2001 From: fangnx Date: Thu, 23 May 2019 11:12:45 -0400 Subject: [PATCH] Fixes #5110, fixes #5223: re-implemented "open source" to work with image/pdf files Signed-off-by: fangnx --- packages/core/src/browser/widget-open-handler.ts | 7 +++++++ packages/editor/src/browser/editor-manager.ts | 4 ++++ .../src/browser/mini-browser-open-handler.ts | 12 +++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/core/src/browser/widget-open-handler.ts b/packages/core/src/browser/widget-open-handler.ts index 02440e74ef988..e36271738c237 100644 --- a/packages/core/src/browser/widget-open-handler.ts +++ b/packages/core/src/browser/widget-open-handler.ts @@ -36,6 +36,13 @@ export interface WidgetOpenerOptions extends OpenerOptions { * By default to the main area. */ widgetOptions?: ApplicationShell.WidgetOptions; + /** + * Specify what the widget is opened for + * preview: preview of image/pdf/etc. + * edit: source file + * By default to `edit` + */ + openFor?: 'preview' | 'edit'; } @injectable() diff --git a/packages/editor/src/browser/editor-manager.ts b/packages/editor/src/browser/editor-manager.ts index 29b549d8f8dba..01dff7b63b6d1 100644 --- a/packages/editor/src/browser/editor-manager.ts +++ b/packages/editor/src/browser/editor-manager.ts @@ -98,6 +98,10 @@ export class EditorManager extends NavigatableWidgetOpenHandler { } canHandle(uri: URI, options?: WidgetOpenerOptions): number { + // Set the priority negative if an open handler is called for 'preview' (not for 'edit) + if (options && options.openFor === 'preview') { + return -100; + } return 100; } diff --git a/packages/mini-browser/src/browser/mini-browser-open-handler.ts b/packages/mini-browser/src/browser/mini-browser-open-handler.ts index 9eea089d06bc2..14acb5acef0b5 100644 --- a/packages/mini-browser/src/browser/mini-browser-open-handler.ts +++ b/packages/mini-browser/src/browser/mini-browser-open-handler.ts @@ -97,11 +97,15 @@ export class MiniBrowserOpenHandler extends NavigatableWidgetOpenHandler