@theia/preview 1.67.0-next.56 → 1.67.0-next.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +21 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/markdown/index.d.ts +2 -0
- package/lib/browser/markdown/index.d.ts.map +1 -0
- package/lib/browser/markdown/index.js +20 -0
- package/lib/browser/markdown/index.js.map +1 -0
- package/lib/browser/markdown/markdown-preview-handler.d.ts +29 -0
- package/lib/browser/markdown/markdown-preview-handler.d.ts.map +1 -0
- package/lib/browser/markdown/markdown-preview-handler.js +294 -0
- package/lib/browser/markdown/markdown-preview-handler.js.map +1 -0
- package/lib/browser/markdown/markdown-preview-handler.spec.d.ts +2 -0
- package/lib/browser/markdown/markdown-preview-handler.spec.d.ts.map +1 -0
- package/lib/browser/markdown/markdown-preview-handler.spec.js +194 -0
- package/lib/browser/markdown/markdown-preview-handler.spec.js.map +1 -0
- package/lib/browser/preview-contribution.d.ts +51 -0
- package/lib/browser/preview-contribution.d.ts.map +1 -0
- package/lib/browser/preview-contribution.js +256 -0
- package/lib/browser/preview-contribution.js.map +1 -0
- package/lib/browser/preview-frontend-module.d.ts +6 -0
- package/lib/browser/preview-frontend-module.d.ts.map +1 -0
- package/lib/browser/preview-frontend-module.js +53 -0
- package/lib/browser/preview-frontend-module.js.map +1 -0
- package/lib/browser/preview-handler.d.ts +105 -0
- package/lib/browser/preview-handler.d.ts.map +1 -0
- package/lib/browser/preview-handler.js +66 -0
- package/lib/browser/preview-handler.js.map +1 -0
- package/lib/browser/preview-link-normalizer.d.ts +8 -0
- package/lib/browser/preview-link-normalizer.d.ts.map +1 -0
- package/lib/browser/preview-link-normalizer.js +47 -0
- package/lib/browser/preview-link-normalizer.js.map +1 -0
- package/lib/browser/preview-uri.d.ts +9 -0
- package/lib/browser/preview-uri.d.ts.map +1 -0
- package/lib/browser/preview-uri.js +48 -0
- package/lib/browser/preview-uri.js.map +1 -0
- package/lib/browser/preview-widget.d.ts +55 -0
- package/lib/browser/preview-widget.d.ts.map +1 -0
- package/lib/browser/preview-widget.js +251 -0
- package/lib/browser/preview-widget.js.map +1 -0
- package/lib/common/preview-preferences.d.ts +14 -0
- package/lib/common/preview-preferences.d.ts.map +1 -0
- package/lib/common/preview-preferences.js +48 -0
- package/lib/common/preview-preferences.js.map +1 -0
- package/lib/node/preview-backend-module.d.ts +4 -0
- package/lib/node/preview-backend-module.d.ts.map +1 -0
- package/lib/node/preview-backend-module.js +23 -0
- package/lib/node/preview-backend-module.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +26 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Widget } from '@theia/core/shared/@lumino/widgets';
|
|
2
|
+
import { FrontendApplicationContribution, WidgetOpenerOptions, NavigatableWidgetOpenHandler } from '@theia/core/lib/browser';
|
|
3
|
+
import { EditorManager, TextEditor, EditorWidget } from '@theia/editor/lib/browser';
|
|
4
|
+
import { CommandContribution, CommandRegistry, Command, MenuContribution, MenuModelRegistry, Disposable } from '@theia/core/lib/common';
|
|
5
|
+
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
6
|
+
import URI from '@theia/core/lib/common/uri';
|
|
7
|
+
import { Position } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
8
|
+
import { PreviewWidget } from './preview-widget';
|
|
9
|
+
import { PreviewHandlerProvider } from './preview-handler';
|
|
10
|
+
import { PreviewPreferences } from '../common/preview-preferences';
|
|
11
|
+
export declare namespace PreviewCommands {
|
|
12
|
+
/**
|
|
13
|
+
* No `label`. Otherwise, it would show up in the `Command Palette` and we already have the `Preview` open handler.
|
|
14
|
+
* See in (`WorkspaceCommandContribution`)[https://bit.ly/2DncrSD].
|
|
15
|
+
*/
|
|
16
|
+
const OPEN: Command;
|
|
17
|
+
const OPEN_SOURCE: Command;
|
|
18
|
+
}
|
|
19
|
+
export interface PreviewOpenerOptions extends WidgetOpenerOptions {
|
|
20
|
+
originUri?: URI;
|
|
21
|
+
}
|
|
22
|
+
export declare class PreviewContribution extends NavigatableWidgetOpenHandler<PreviewWidget> implements CommandContribution, MenuContribution, FrontendApplicationContribution, TabBarToolbarContribution {
|
|
23
|
+
readonly id = "code-editor-preview";
|
|
24
|
+
readonly label: string;
|
|
25
|
+
protected readonly editorManager: EditorManager;
|
|
26
|
+
protected readonly previewHandlerProvider: PreviewHandlerProvider;
|
|
27
|
+
protected readonly preferences: PreviewPreferences;
|
|
28
|
+
protected readonly synchronizedUris: Set<string>;
|
|
29
|
+
protected scrollSyncLockOn: 'preview' | 'editor' | undefined;
|
|
30
|
+
protected scrollSyncLockTimeout: number | undefined;
|
|
31
|
+
onStart(): void;
|
|
32
|
+
protected lockScrollSync(on: 'preview' | 'editor', delay?: number): Promise<void>;
|
|
33
|
+
protected registerEditorAndPreviewSync(source: PreviewWidget | EditorWidget): Promise<void>;
|
|
34
|
+
protected revealSourceLineInPreview(previewWidget: PreviewWidget, position: Position): void;
|
|
35
|
+
protected synchronizeScrollToEditor(previewWidget: PreviewWidget, editor: TextEditor): Disposable;
|
|
36
|
+
protected registerOpenOnDoubleClick(ref: PreviewWidget): void;
|
|
37
|
+
canHandle(uri: URI): number;
|
|
38
|
+
protected get openByDefault(): boolean;
|
|
39
|
+
open(uri: URI, options?: PreviewOpenerOptions): Promise<PreviewWidget>;
|
|
40
|
+
protected serializeUri(uri: URI): string;
|
|
41
|
+
protected resolveOpenerOptions(options?: PreviewOpenerOptions): Promise<PreviewOpenerOptions>;
|
|
42
|
+
registerCommands(registry: CommandRegistry): void;
|
|
43
|
+
registerMenus(menus: MenuModelRegistry): void;
|
|
44
|
+
registerToolbarItems(registry: TabBarToolbarRegistry): void;
|
|
45
|
+
protected canHandleEditorUri(widget?: Widget): boolean;
|
|
46
|
+
protected getCurrentEditorUri(widget?: Widget): URI | undefined;
|
|
47
|
+
protected getCurrentEditor(widget?: Widget): EditorWidget | undefined;
|
|
48
|
+
protected openForEditor(widget?: Widget): Promise<void>;
|
|
49
|
+
protected openSource(ref: PreviewWidget): Promise<EditorWidget>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=preview-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/preview-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,+BAA+B,EAAE,mBAAmB,EAAE,4BAA4B,EAAW,MAAM,yBAAyB,CAAC;AACtI,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAqB,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAwB,mBAAmB,EAAE,eAAe,EAAE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC9J,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AAEjH,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAKnE,yBAAiB,eAAe,CAAC;IAC7B;;;OAGG;IACI,MAAM,IAAI,SAIqD,CAAC;IAChE,MAAM,WAAW,EAAE,OAGzB,CAAC;CACL;AAED,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC7D,SAAS,CAAC,EAAE,GAAG,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G,MAAM;cAIjC,oBAAoB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAWnG,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAajD,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAM7C,oBAAoB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;IAa3D,SAAS,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAKtD,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAK/D,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;cAKrD,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;cAW7C,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CASxE"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PreviewContribution = exports.PreviewCommands = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
22
|
+
const browser_2 = require("@theia/editor/lib/browser");
|
|
23
|
+
const common_1 = require("@theia/core/lib/common");
|
|
24
|
+
const mini_browser_open_handler_1 = require("@theia/mini-browser/lib/browser/mini-browser-open-handler");
|
|
25
|
+
const preview_widget_1 = require("./preview-widget");
|
|
26
|
+
const preview_handler_1 = require("./preview-handler");
|
|
27
|
+
const preview_uri_1 = require("./preview-uri");
|
|
28
|
+
const preview_preferences_1 = require("../common/preview-preferences");
|
|
29
|
+
const nls_1 = require("@theia/core/lib/common/nls");
|
|
30
|
+
const debounce = require("@theia/core/shared/lodash.debounce");
|
|
31
|
+
var PreviewCommands;
|
|
32
|
+
(function (PreviewCommands) {
|
|
33
|
+
/**
|
|
34
|
+
* No `label`. Otherwise, it would show up in the `Command Palette` and we already have the `Preview` open handler.
|
|
35
|
+
* See in (`WorkspaceCommandContribution`)[https://bit.ly/2DncrSD].
|
|
36
|
+
*/
|
|
37
|
+
PreviewCommands.OPEN = common_1.Command.toLocalizedCommand({
|
|
38
|
+
id: 'preview:open',
|
|
39
|
+
label: 'Open Preview',
|
|
40
|
+
iconClass: (0, browser_1.codicon)('open-preview')
|
|
41
|
+
}, 'vscode.markdown-language-features/package/markdown.preview.title');
|
|
42
|
+
PreviewCommands.OPEN_SOURCE = {
|
|
43
|
+
id: 'preview.open.source',
|
|
44
|
+
iconClass: (0, browser_1.codicon)('go-to-file')
|
|
45
|
+
};
|
|
46
|
+
})(PreviewCommands || (exports.PreviewCommands = PreviewCommands = {}));
|
|
47
|
+
let PreviewContribution = class PreviewContribution extends browser_1.NavigatableWidgetOpenHandler {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
this.id = preview_uri_1.PreviewUri.id;
|
|
51
|
+
this.label = nls_1.nls.localize(mini_browser_open_handler_1.MiniBrowserCommands.PREVIEW_CATEGORY_KEY, mini_browser_open_handler_1.MiniBrowserCommands.PREVIEW_CATEGORY);
|
|
52
|
+
this.synchronizedUris = new Set();
|
|
53
|
+
this.scrollSyncLockOn = undefined;
|
|
54
|
+
}
|
|
55
|
+
onStart() {
|
|
56
|
+
this.onCreated(previewWidget => {
|
|
57
|
+
this.registerOpenOnDoubleClick(previewWidget);
|
|
58
|
+
this.registerEditorAndPreviewSync(previewWidget);
|
|
59
|
+
});
|
|
60
|
+
this.editorManager.onCreated(editorWidget => {
|
|
61
|
+
this.registerEditorAndPreviewSync(editorWidget);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async lockScrollSync(on, delay = 50) {
|
|
65
|
+
this.scrollSyncLockOn = on;
|
|
66
|
+
if (this.scrollSyncLockTimeout) {
|
|
67
|
+
window.clearTimeout(this.scrollSyncLockTimeout);
|
|
68
|
+
}
|
|
69
|
+
this.scrollSyncLockTimeout = window.setTimeout(() => {
|
|
70
|
+
this.scrollSyncLockOn = undefined;
|
|
71
|
+
}, delay);
|
|
72
|
+
}
|
|
73
|
+
async registerEditorAndPreviewSync(source) {
|
|
74
|
+
let uri;
|
|
75
|
+
let editorWidget;
|
|
76
|
+
let previewWidget;
|
|
77
|
+
if (source instanceof browser_2.EditorWidget) {
|
|
78
|
+
editorWidget = source;
|
|
79
|
+
uri = editorWidget.editor.uri.toString();
|
|
80
|
+
previewWidget = await this.getWidget(editorWidget.editor.uri);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
previewWidget = source;
|
|
84
|
+
uri = previewWidget.getUri().toString();
|
|
85
|
+
editorWidget = await this.editorManager.getByUri(previewWidget.getUri());
|
|
86
|
+
}
|
|
87
|
+
if (!previewWidget || !editorWidget || !uri) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (this.synchronizedUris.has(uri)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const syncDisposables = new common_1.DisposableCollection();
|
|
94
|
+
previewWidget.disposed.connect(() => syncDisposables.dispose());
|
|
95
|
+
editorWidget.disposed.connect(() => syncDisposables.dispose());
|
|
96
|
+
const editor = editorWidget.editor;
|
|
97
|
+
syncDisposables.push(editor.onScrollChanged(debounce(() => {
|
|
98
|
+
if (this.scrollSyncLockOn === 'editor') {
|
|
99
|
+
// avoid recursive scroll synchronization
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.lockScrollSync('preview');
|
|
103
|
+
const range = editor.getVisibleRanges();
|
|
104
|
+
if (range.length > 0) {
|
|
105
|
+
this.revealSourceLineInPreview(previewWidget, range[0].start);
|
|
106
|
+
}
|
|
107
|
+
}), 100));
|
|
108
|
+
syncDisposables.push(this.synchronizeScrollToEditor(previewWidget, editor));
|
|
109
|
+
this.synchronizedUris.add(uri);
|
|
110
|
+
syncDisposables.push(common_1.Disposable.create(() => this.synchronizedUris.delete(uri)));
|
|
111
|
+
}
|
|
112
|
+
revealSourceLineInPreview(previewWidget, position) {
|
|
113
|
+
previewWidget.revealForSourceLine(position.line);
|
|
114
|
+
}
|
|
115
|
+
synchronizeScrollToEditor(previewWidget, editor) {
|
|
116
|
+
return previewWidget.onDidScroll(sourceLine => {
|
|
117
|
+
if (this.scrollSyncLockOn === 'preview') {
|
|
118
|
+
// avoid recursive scroll synchronization
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const line = Math.floor(sourceLine);
|
|
122
|
+
this.lockScrollSync('editor'); // avoid recursive scroll synchronization
|
|
123
|
+
editor.revealRange({
|
|
124
|
+
start: {
|
|
125
|
+
line,
|
|
126
|
+
character: 0
|
|
127
|
+
},
|
|
128
|
+
end: {
|
|
129
|
+
line: line + 1,
|
|
130
|
+
character: 0
|
|
131
|
+
}
|
|
132
|
+
}, { at: 'top' });
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
registerOpenOnDoubleClick(ref) {
|
|
136
|
+
const disposable = ref.onDidDoubleClick(async (location) => {
|
|
137
|
+
const { editor } = await this.openSource(ref);
|
|
138
|
+
editor.revealPosition(location.range.start);
|
|
139
|
+
editor.selection = {
|
|
140
|
+
...location.range,
|
|
141
|
+
direction: 'ltr'
|
|
142
|
+
};
|
|
143
|
+
ref.revealForSourceLine(location.range.start.line);
|
|
144
|
+
});
|
|
145
|
+
ref.disposed.connect(() => disposable.dispose());
|
|
146
|
+
}
|
|
147
|
+
canHandle(uri) {
|
|
148
|
+
if (!this.previewHandlerProvider.canHandle(uri)) {
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
const editorPriority = this.editorManager.canHandle(uri);
|
|
152
|
+
if (editorPriority === 0) {
|
|
153
|
+
return 200;
|
|
154
|
+
}
|
|
155
|
+
if (preview_uri_1.PreviewUri.match(uri)) {
|
|
156
|
+
return editorPriority * 2;
|
|
157
|
+
}
|
|
158
|
+
return editorPriority * (this.openByDefault ? 2 : 0.5);
|
|
159
|
+
}
|
|
160
|
+
get openByDefault() {
|
|
161
|
+
return this.preferences['preview.openByDefault'];
|
|
162
|
+
}
|
|
163
|
+
async open(uri, options) {
|
|
164
|
+
const resolvedOptions = await this.resolveOpenerOptions(options);
|
|
165
|
+
return super.open(uri, resolvedOptions);
|
|
166
|
+
}
|
|
167
|
+
serializeUri(uri) {
|
|
168
|
+
return super.serializeUri(preview_uri_1.PreviewUri.decode(uri));
|
|
169
|
+
}
|
|
170
|
+
async resolveOpenerOptions(options) {
|
|
171
|
+
const resolved = { mode: 'activate', ...options };
|
|
172
|
+
if (resolved.originUri) {
|
|
173
|
+
const ref = await this.getWidget(resolved.originUri);
|
|
174
|
+
if (ref) {
|
|
175
|
+
resolved.widgetOptions = { ...resolved.widgetOptions, ref };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return resolved;
|
|
179
|
+
}
|
|
180
|
+
registerCommands(registry) {
|
|
181
|
+
registry.registerCommand(PreviewCommands.OPEN, {
|
|
182
|
+
execute: widget => this.openForEditor(widget),
|
|
183
|
+
isEnabled: widget => this.canHandleEditorUri(widget),
|
|
184
|
+
isVisible: widget => this.canHandleEditorUri(widget)
|
|
185
|
+
});
|
|
186
|
+
registry.registerCommand(PreviewCommands.OPEN_SOURCE, {
|
|
187
|
+
execute: widget => this.openSource(widget),
|
|
188
|
+
isEnabled: widget => widget instanceof preview_widget_1.PreviewWidget,
|
|
189
|
+
isVisible: widget => widget instanceof preview_widget_1.PreviewWidget
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
registerMenus(menus) {
|
|
193
|
+
menus.registerMenuAction(browser_2.EditorContextMenu.NAVIGATION, {
|
|
194
|
+
commandId: PreviewCommands.OPEN.id
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
registerToolbarItems(registry) {
|
|
198
|
+
registry.registerItem({
|
|
199
|
+
id: PreviewCommands.OPEN.id,
|
|
200
|
+
command: PreviewCommands.OPEN.id,
|
|
201
|
+
tooltip: nls_1.nls.localize('vscode.markdown-language-features/package/markdown.previewSide.title', 'Open Preview to the Side')
|
|
202
|
+
});
|
|
203
|
+
registry.registerItem({
|
|
204
|
+
id: PreviewCommands.OPEN_SOURCE.id,
|
|
205
|
+
command: PreviewCommands.OPEN_SOURCE.id,
|
|
206
|
+
tooltip: nls_1.nls.localize('vscode.markdown-language-features/package/markdown.showSource.title', 'Open Source')
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
canHandleEditorUri(widget) {
|
|
210
|
+
const uri = this.getCurrentEditorUri(widget);
|
|
211
|
+
return !!uri && this.previewHandlerProvider.canHandle(uri);
|
|
212
|
+
}
|
|
213
|
+
getCurrentEditorUri(widget) {
|
|
214
|
+
const current = this.getCurrentEditor(widget);
|
|
215
|
+
return current && current.editor.uri;
|
|
216
|
+
}
|
|
217
|
+
getCurrentEditor(widget) {
|
|
218
|
+
const current = widget ? widget : this.editorManager.currentEditor;
|
|
219
|
+
return current instanceof browser_2.EditorWidget && current || undefined;
|
|
220
|
+
}
|
|
221
|
+
async openForEditor(widget) {
|
|
222
|
+
const ref = this.getCurrentEditor(widget);
|
|
223
|
+
if (!ref) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
await this.open(ref.editor.uri, {
|
|
227
|
+
mode: 'reveal',
|
|
228
|
+
widgetOptions: { ref, mode: 'open-to-right' }
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
async openSource(ref) {
|
|
232
|
+
if (ref instanceof preview_widget_1.PreviewWidget) {
|
|
233
|
+
return this.editorManager.open(ref.uri, {
|
|
234
|
+
widgetOptions: { ref, mode: 'tab-after' }
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
exports.PreviewContribution = PreviewContribution;
|
|
240
|
+
tslib_1.__decorate([
|
|
241
|
+
(0, inversify_1.inject)(browser_2.EditorManager),
|
|
242
|
+
tslib_1.__metadata("design:type", browser_2.EditorManager)
|
|
243
|
+
], PreviewContribution.prototype, "editorManager", void 0);
|
|
244
|
+
tslib_1.__decorate([
|
|
245
|
+
(0, inversify_1.inject)(preview_handler_1.PreviewHandlerProvider),
|
|
246
|
+
tslib_1.__metadata("design:type", preview_handler_1.PreviewHandlerProvider)
|
|
247
|
+
], PreviewContribution.prototype, "previewHandlerProvider", void 0);
|
|
248
|
+
tslib_1.__decorate([
|
|
249
|
+
(0, inversify_1.inject)(preview_preferences_1.PreviewPreferences),
|
|
250
|
+
tslib_1.__metadata("design:type", Object)
|
|
251
|
+
], PreviewContribution.prototype, "preferences", void 0);
|
|
252
|
+
exports.PreviewContribution = PreviewContribution = tslib_1.__decorate([
|
|
253
|
+
(0, inversify_1.injectable)()
|
|
254
|
+
// eslint-disable-next-line max-len
|
|
255
|
+
], PreviewContribution);
|
|
256
|
+
//# sourceMappingURL=preview-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-contribution.js","sourceRoot":"","sources":["../../src/browser/preview-contribution.ts"],"names":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AAI,CAAC,GAAG,CAAC,GAAG,EAAE;gBACpC,aAAa,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE;aAC5C,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CAEJ,CAAA;AA/NY,kDAAmB;AAMT;IADlB,IAAA,kBAAM,EAAC,uBAAa,CAAC;sCACY,uBAAa;0DAAC;AAG7B;IADlB,IAAA,kBAAM,EAAC,wCAAsB,CAAC;sCACY,wCAAsB;mEAAC;AAG/C;IADlB,IAAA,kBAAM,EAAC,wCAAkB,CAAC;;wDACwB;8BAZ1C,mBAAmB;IAF/B,IAAA,sBAAU,GAAE;IACb,mCAAmC;GACtB,mBAAmB,CA+N/B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
2
|
+
import '../../src/browser/style/index.css';
|
|
3
|
+
import '../../src/browser/markdown/style/index.css';
|
|
4
|
+
declare const _default: ContainerModule;
|
|
5
|
+
export default _default;
|
|
6
|
+
//# sourceMappingURL=preview-frontend-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/preview-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAa/D,OAAO,mCAAmC,CAAC;AAC3C,OAAO,4CAA4C,CAAC;;AAEpD,wBAwBG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
19
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
20
|
+
const common_1 = require("@theia/core/lib/common");
|
|
21
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
22
|
+
const tab_bar_toolbar_1 = require("@theia/core/lib/browser/shell/tab-bar-toolbar");
|
|
23
|
+
const preview_contribution_1 = require("./preview-contribution");
|
|
24
|
+
const preview_widget_1 = require("./preview-widget");
|
|
25
|
+
const preview_handler_1 = require("./preview-handler");
|
|
26
|
+
const preview_uri_1 = require("./preview-uri");
|
|
27
|
+
const markdown_1 = require("./markdown");
|
|
28
|
+
const preview_preferences_1 = require("../common/preview-preferences");
|
|
29
|
+
const preview_link_normalizer_1 = require("./preview-link-normalizer");
|
|
30
|
+
require("../../src/browser/style/index.css");
|
|
31
|
+
require("../../src/browser/markdown/style/index.css");
|
|
32
|
+
exports.default = new inversify_1.ContainerModule(bind => {
|
|
33
|
+
(0, preview_preferences_1.bindPreviewPreferences)(bind);
|
|
34
|
+
bind(preview_handler_1.PreviewHandlerProvider).toSelf().inSingletonScope();
|
|
35
|
+
(0, common_1.bindContributionProvider)(bind, preview_handler_1.PreviewHandler);
|
|
36
|
+
bind(markdown_1.MarkdownPreviewHandler).toSelf().inSingletonScope();
|
|
37
|
+
bind(preview_handler_1.PreviewHandler).toService(markdown_1.MarkdownPreviewHandler);
|
|
38
|
+
bind(preview_link_normalizer_1.PreviewLinkNormalizer).toSelf().inSingletonScope();
|
|
39
|
+
bind(preview_widget_1.PreviewWidget).toSelf();
|
|
40
|
+
bind(browser_1.WidgetFactory).toDynamicValue(ctx => ({
|
|
41
|
+
id: preview_uri_1.PreviewUri.id,
|
|
42
|
+
async createWidget(options) {
|
|
43
|
+
const { container } = ctx;
|
|
44
|
+
const resource = await container.get(common_1.ResourceProvider)(new uri_1.default(options.uri));
|
|
45
|
+
const child = container.createChild();
|
|
46
|
+
child.bind(preview_widget_1.PreviewWidgetOptions).toConstantValue({ resource });
|
|
47
|
+
return child.get(preview_widget_1.PreviewWidget);
|
|
48
|
+
}
|
|
49
|
+
})).inSingletonScope();
|
|
50
|
+
bind(preview_contribution_1.PreviewContribution).toSelf().inSingletonScope();
|
|
51
|
+
[common_1.CommandContribution, common_1.MenuContribution, browser_1.OpenHandler, browser_1.FrontendApplicationContribution, tab_bar_toolbar_1.TabBarToolbarContribution].forEach(serviceIdentifier => bind(serviceIdentifier).toService(preview_contribution_1.PreviewContribution));
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=preview-frontend-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-frontend-module.js","sourceRoot":"","sources":["../../src/browser/preview-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,oDAA6C;AAC7C,mDAA2H;AAC3H,qDAAgI;AAChI,mFAA0F;AAC1F,iEAA6D;AAC7D,qDAAuE;AACvE,uDAA2E;AAC3E,+CAA2C;AAC3C,yCAAoD;AACpD,uEAAuE;AACvE,uEAAkE;AAElE,6CAA2C;AAC3C,sDAAoD;AAEpD,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IA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BAAiB,CAAC,EAAE,CACzI,IAAI,CAAC,iBAAiB,CAAC,CAAC,SAAS,CAAC,0CAAmB,CAAC,CACzD,CAAC;AACN,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import URI from '@theia/core/lib/common/uri';
|
|
2
|
+
import { ContributionProvider, MaybePromise } from '@theia/core';
|
|
3
|
+
export declare const PreviewHandler: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* The parameters given to the preview handler to render the preview content.
|
|
6
|
+
*/
|
|
7
|
+
export interface RenderContentParams {
|
|
8
|
+
/**
|
|
9
|
+
* Textual content of the resource.
|
|
10
|
+
*/
|
|
11
|
+
content: string;
|
|
12
|
+
/**
|
|
13
|
+
* URI identifying the source resource.
|
|
14
|
+
*/
|
|
15
|
+
originUri: URI;
|
|
16
|
+
}
|
|
17
|
+
export declare namespace RenderContentParams {
|
|
18
|
+
function is(params: unknown): params is RenderContentParams;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A PreviewHandler manages the integration of one or more previews.
|
|
22
|
+
*
|
|
23
|
+
* It indicates whether a preview shall be rendered for a given resource URI and, if yes, renders the content.
|
|
24
|
+
* Additionally it optionally provides methods with which the scroll state of the preview and corresponding
|
|
25
|
+
* editor can be managed.
|
|
26
|
+
*
|
|
27
|
+
* See {@link MarkdownPreviewHandler} for an example implementation.
|
|
28
|
+
*/
|
|
29
|
+
export interface PreviewHandler {
|
|
30
|
+
/**
|
|
31
|
+
* One or more classes which specify the preview widget icon.
|
|
32
|
+
*/
|
|
33
|
+
readonly iconClass?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Indicates whether and with which priority (larger is better) this preview handler is responsible for the resource identified by the given URI.
|
|
36
|
+
* If multiple handlers return the same priority it's undefined which one will be used.
|
|
37
|
+
*
|
|
38
|
+
* @param uri the URI identifying a resource.
|
|
39
|
+
*
|
|
40
|
+
* @returns a number larger than 0 if the handler is applicable, 0 or a negative number otherwise.
|
|
41
|
+
*/
|
|
42
|
+
canHandle(uri: URI): number;
|
|
43
|
+
/**
|
|
44
|
+
* Render the preview content by returning appropriate HTML.
|
|
45
|
+
*
|
|
46
|
+
* @param params information for the handler to render its content.
|
|
47
|
+
*
|
|
48
|
+
* @returns the HTMLElement which will be attached to the preview widget.
|
|
49
|
+
*/
|
|
50
|
+
renderContent(params: RenderContentParams): MaybePromise<HTMLElement | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Search and return the HTMLElement which corresponds to the given fragment.
|
|
53
|
+
* This is used to initially reveal elements identified via the URI fragment.
|
|
54
|
+
*
|
|
55
|
+
* @param content the preview widget element containing the content previously rendered by {@link PreviewHandler.renderContent}.
|
|
56
|
+
* @param fragment the URI fragment for which the corresponding element shall be returned
|
|
57
|
+
*
|
|
58
|
+
* @returns the HTMLElement which is part of content and corresponds to the given fragment, undefined otherwise.
|
|
59
|
+
*/
|
|
60
|
+
findElementForFragment?(content: HTMLElement, fragment: string): HTMLElement | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Search and return the HTMLElement which corresponds to the given line number.
|
|
63
|
+
* This is used to scroll the preview when the source editor scrolls.
|
|
64
|
+
*
|
|
65
|
+
* @param content the preview widget element containing the previously rendered by {@link PreviewHandler.renderContent}.
|
|
66
|
+
* @param sourceLine the line number for which the corresponding element shall be returned.
|
|
67
|
+
*
|
|
68
|
+
* @returns the HTMLElement which is part of content and corresponds to the given line number, undefined otherwise.
|
|
69
|
+
*/
|
|
70
|
+
findElementForSourceLine?(content: HTMLElement, sourceLine: number): HTMLElement | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the line number which corresponds to the preview element at the given offset.
|
|
73
|
+
* This is used to scroll the source editor when the preview scrolls.
|
|
74
|
+
*
|
|
75
|
+
* @param content the preview widget element containing the previously rendered by {@link PreviewHandler.renderContent}.
|
|
76
|
+
* @param offset the total amount by which the preview widget is scrolled.
|
|
77
|
+
*
|
|
78
|
+
* @returns the source line number which corresponds to the preview element at the given offset, undefined otherwise.
|
|
79
|
+
*/
|
|
80
|
+
getSourceLineForOffset?(content: HTMLElement, offset: number): number | undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Provider managing the available PreviewHandlers.
|
|
84
|
+
*/
|
|
85
|
+
export declare class PreviewHandlerProvider {
|
|
86
|
+
protected readonly previewHandlerContributions: ContributionProvider<PreviewHandler>;
|
|
87
|
+
constructor(previewHandlerContributions: ContributionProvider<PreviewHandler>);
|
|
88
|
+
/**
|
|
89
|
+
* Find PreviewHandlers for the given resource identifier.
|
|
90
|
+
*
|
|
91
|
+
* @param uri the URI identifying a resource.
|
|
92
|
+
*
|
|
93
|
+
* @returns the list of all supported `PreviewHandlers` sorted by their priority.
|
|
94
|
+
*/
|
|
95
|
+
findContribution(uri: URI): PreviewHandler[];
|
|
96
|
+
/**
|
|
97
|
+
* Indicates whether any PreviewHandler can process the resource identified by the given URI.
|
|
98
|
+
*
|
|
99
|
+
* @param uri the URI identifying a resource.
|
|
100
|
+
*
|
|
101
|
+
* @returns `true` when a PreviewHandler can process the resource, `false` otherwise.
|
|
102
|
+
*/
|
|
103
|
+
canHandle(uri: URI): boolean;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=preview-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-handler.d.ts","sourceRoot":"","sources":["../../src/browser/preview-handler.ts"],"names":[],"mappings":"AAiBA,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAY,YAAY,EAAkB,MAAM,aAAa,CAAC;AAE3F,eAAO,MAAM,cAAc,eAA2B,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,EAAE,GAAG,CAAC;CAClB;AAED,yBAAiB,mBAAmB,CAAC;IACjC,SAAgB,EAAE,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,mBAAmB,CAEjE;CACJ;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC;IAC5B;;;;;;OAMG;IACH,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,YAAY,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IAClF;;;;;;;;OAQG;IACH,sBAAsB,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IACzF;;;;;;;;OAQG;IACH,wBAAwB,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IAC7F;;;;;;;;OAQG;IACH,sBAAsB,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACrF;AAED;;GAEG;AACH,qBACa,sBAAsB;IAI3B,SAAS,CAAC,QAAQ,CAAC,2BAA2B,EAAE,oBAAoB,CAAC,cAAc,CAAC;gBAAjE,2BAA2B,EAAE,oBAAoB,CAAC,cAAc,CAAC;IAGxF;;;;;;OAMG;IACH,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc,EAAE;IAO5C;;;;;;OAMG;IACH,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;CAG/B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2017 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PreviewHandlerProvider = exports.RenderContentParams = exports.PreviewHandler = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const core_1 = require("@theia/core");
|
|
22
|
+
exports.PreviewHandler = Symbol('PreviewHandler');
|
|
23
|
+
var RenderContentParams;
|
|
24
|
+
(function (RenderContentParams) {
|
|
25
|
+
function is(params) {
|
|
26
|
+
return (0, core_1.isObject)(params) && 'content' in params && 'originUri' in params;
|
|
27
|
+
}
|
|
28
|
+
RenderContentParams.is = is;
|
|
29
|
+
})(RenderContentParams || (exports.RenderContentParams = RenderContentParams = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Provider managing the available PreviewHandlers.
|
|
32
|
+
*/
|
|
33
|
+
let PreviewHandlerProvider = class PreviewHandlerProvider {
|
|
34
|
+
constructor(previewHandlerContributions) {
|
|
35
|
+
this.previewHandlerContributions = previewHandlerContributions;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Find PreviewHandlers for the given resource identifier.
|
|
39
|
+
*
|
|
40
|
+
* @param uri the URI identifying a resource.
|
|
41
|
+
*
|
|
42
|
+
* @returns the list of all supported `PreviewHandlers` sorted by their priority.
|
|
43
|
+
*/
|
|
44
|
+
findContribution(uri) {
|
|
45
|
+
const prioritized = core_1.Prioritizeable.prioritizeAllSync(this.previewHandlerContributions.getContributions(), contrib => contrib.canHandle(uri));
|
|
46
|
+
return prioritized.map(c => c.value);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Indicates whether any PreviewHandler can process the resource identified by the given URI.
|
|
50
|
+
*
|
|
51
|
+
* @param uri the URI identifying a resource.
|
|
52
|
+
*
|
|
53
|
+
* @returns `true` when a PreviewHandler can process the resource, `false` otherwise.
|
|
54
|
+
*/
|
|
55
|
+
canHandle(uri) {
|
|
56
|
+
return this.findContribution(uri).length > 0;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.PreviewHandlerProvider = PreviewHandlerProvider;
|
|
60
|
+
exports.PreviewHandlerProvider = PreviewHandlerProvider = tslib_1.__decorate([
|
|
61
|
+
(0, inversify_1.injectable)(),
|
|
62
|
+
tslib_1.__param(0, (0, inversify_1.inject)(core_1.ContributionProvider)),
|
|
63
|
+
tslib_1.__param(0, (0, inversify_1.named)(exports.PreviewHandler)),
|
|
64
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
65
|
+
], PreviewHandlerProvider);
|
|
66
|
+
//# sourceMappingURL=preview-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-handler.js","sourceRoot":"","sources":["../../src/browser/preview-handler.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAyE;AAEzE,sCAA2F;AAE9E,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAgBvD,IAAiB,mBAAmB,CAInC;AAJD,WAAiB,mBAAmB;IAChC,SAAgB,EAAE,CAAC,MAAe;QAC9B,OAAO,IAAA,eAAQ,EAAC,MAAM,CAAC,IAAI,SAAS,IAAI,MAAM,IAAI,WAAW,IAAI,MAAM,CAAC;IAC5E,CAAC;IAFe,sBAAE,KAEjB,CAAA;AACL,CAAC,EAJgB,mBAAmB,mCAAnB,mBAAmB,QAInC;AAiED;;GAEG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAE/B,YAEuB,2BAAiE;QAAjE,gCAA2B,GAA3B,2BAA2B,CAAsC;IACpF,CAAC;IAEL;;;;;;OAMG;IACH,gBAAgB,CAAC,GAAQ;QACrB,MAAM,WAAW,GAAG,qBAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,2BAA2B,CAAC,gBAAgB,EAAE,EAAE,OAAO,CAAC,EAAE,CAChH,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CACzB,CAAC;QACF,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAQ;QACd,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACjD,CAAC;CACJ,CAAA;AA/BY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,sBAAU,GAAE;IAIJ,mBAAA,IAAA,kBAAM,EAAC,2BAAoB,CAAC,CAAA;IAAE,mBAAA,IAAA,iBAAK,EAAC,sBAAc,CAAC,CAAA;;GAH/C,sBAAsB,CA+BlC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import URI from '@theia/core/lib/common/uri';
|
|
2
|
+
import { MiniBrowserEnvironment } from '@theia/mini-browser/lib/browser/environment/mini-browser-environment';
|
|
3
|
+
export declare class PreviewLinkNormalizer {
|
|
4
|
+
protected urlScheme: RegExp;
|
|
5
|
+
protected readonly miniBrowserEnvironment: MiniBrowserEnvironment;
|
|
6
|
+
normalizeLink(documentUri: URI, link: string): string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=preview-link-normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-link-normalizer.d.ts","sourceRoot":"","sources":["../../src/browser/preview-link-normalizer.ts"],"names":[],"mappings":"AAiBA,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sEAAsE,CAAC;AAE9G,qBACa,qBAAqB;IAE9B,SAAS,CAAC,SAAS,SAAiD;IAGpE,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAElE,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;CAWxD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PreviewLinkNormalizer = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const mini_browser_environment_1 = require("@theia/mini-browser/lib/browser/environment/mini-browser-environment");
|
|
22
|
+
let PreviewLinkNormalizer = class PreviewLinkNormalizer {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.urlScheme = new RegExp('^[a-z][a-z|0-9|\+|\-|\.]*:', 'i');
|
|
25
|
+
}
|
|
26
|
+
normalizeLink(documentUri, link) {
|
|
27
|
+
try {
|
|
28
|
+
if (!this.urlScheme.test(link)) {
|
|
29
|
+
const location = documentUri.parent.resolve(link).path.toString();
|
|
30
|
+
return this.miniBrowserEnvironment.getEndpoint('normalized-link').getRestUrl().resolve(location).toString();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// ignore
|
|
35
|
+
}
|
|
36
|
+
return link;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.PreviewLinkNormalizer = PreviewLinkNormalizer;
|
|
40
|
+
tslib_1.__decorate([
|
|
41
|
+
(0, inversify_1.inject)(mini_browser_environment_1.MiniBrowserEnvironment),
|
|
42
|
+
tslib_1.__metadata("design:type", mini_browser_environment_1.MiniBrowserEnvironment)
|
|
43
|
+
], PreviewLinkNormalizer.prototype, "miniBrowserEnvironment", void 0);
|
|
44
|
+
exports.PreviewLinkNormalizer = PreviewLinkNormalizer = tslib_1.__decorate([
|
|
45
|
+
(0, inversify_1.injectable)()
|
|
46
|
+
], PreviewLinkNormalizer);
|
|
47
|
+
//# sourceMappingURL=preview-link-normalizer.js.map
|