@theia/preview 1.45.0 → 1.46.0-next.72

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.
Files changed (42) hide show
  1. package/README.md +45 -45
  2. package/lib/browser/index.d.ts +3 -3
  3. package/lib/browser/index.js +29 -29
  4. package/lib/browser/markdown/index.d.ts +1 -1
  5. package/lib/browser/markdown/index.js +28 -28
  6. package/lib/browser/markdown/markdown-preview-handler.d.ts +28 -28
  7. package/lib/browser/markdown/markdown-preview-handler.js +301 -301
  8. package/lib/browser/markdown/markdown-preview-handler.spec.d.ts +1 -1
  9. package/lib/browser/markdown/markdown-preview-handler.spec.js +193 -193
  10. package/lib/browser/preview-contribution.d.ts +50 -50
  11. package/lib/browser/preview-contribution.js +262 -262
  12. package/lib/browser/preview-frontend-module.d.ts +5 -5
  13. package/lib/browser/preview-frontend-module.js +52 -52
  14. package/lib/browser/preview-handler.d.ts +104 -104
  15. package/lib/browser/preview-handler.js +76 -76
  16. package/lib/browser/preview-link-normalizer.d.ts +7 -7
  17. package/lib/browser/preview-link-normalizer.js +54 -54
  18. package/lib/browser/preview-preferences.d.ts +11 -11
  19. package/lib/browser/preview-preferences.js +46 -46
  20. package/lib/browser/preview-uri.d.ts +8 -8
  21. package/lib/browser/preview-uri.js +47 -47
  22. package/lib/browser/preview-widget.d.ts +54 -54
  23. package/lib/browser/preview-widget.js +261 -261
  24. package/lib/package.spec.js +25 -25
  25. package/package.json +7 -7
  26. package/src/browser/index.ts +19 -19
  27. package/src/browser/markdown/index.ts +17 -17
  28. package/src/browser/markdown/markdown-preview-handler.spec.ts +228 -228
  29. package/src/browser/markdown/markdown-preview-handler.ts +309 -309
  30. package/src/browser/markdown/style/index.css +18 -18
  31. package/src/browser/markdown/style/markdown.css +203 -203
  32. package/src/browser/markdown/style/tomorrow.css +105 -105
  33. package/src/browser/preview-contribution.ts +276 -276
  34. package/src/browser/preview-frontend-module.ts +57 -57
  35. package/src/browser/preview-handler.ts +141 -141
  36. package/src/browser/preview-link-normalizer.ts +40 -40
  37. package/src/browser/preview-preferences.ts +58 -58
  38. package/src/browser/preview-uri.ts +43 -43
  39. package/src/browser/preview-widget.ts +277 -277
  40. package/src/browser/style/index.css +17 -17
  41. package/src/browser/style/preview-widget.css +29 -29
  42. package/src/package.spec.ts +29 -29
@@ -1,262 +1,262 @@
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
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- var __param = (this && this.__param) || function (paramIndex, decorator) {
27
- return function (target, key) { decorator(target, key, paramIndex); }
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.PreviewWidget = exports.PreviewWidgetOptions = exports.PREVIEW_WIDGET_CLASS = void 0;
31
- const throttle = require("@theia/core/shared/lodash.throttle");
32
- const inversify_1 = require("@theia/core/shared/inversify");
33
- const browser_1 = require("@theia/core/lib/browser");
34
- const common_1 = require("@theia/core/lib/common");
35
- const preview_handler_1 = require("./preview-handler");
36
- const theming_1 = require("@theia/core/lib/browser/theming");
37
- const browser_2 = require("@theia/editor/lib/browser");
38
- const monaco_workspace_1 = require("@theia/monaco/lib/browser/monaco-workspace");
39
- const vscode_languageserver_protocol_1 = require("@theia/core/shared/vscode-languageserver-protocol");
40
- exports.PREVIEW_WIDGET_CLASS = 'theia-preview-widget';
41
- const DEFAULT_ICON = (0, browser_1.codicon)('eye');
42
- let widgetCounter = 0;
43
- exports.PreviewWidgetOptions = Symbol('PreviewWidgetOptions');
44
- let PreviewWidget = class PreviewWidget extends browser_1.BaseWidget {
45
- constructor(options, previewHandlerProvider, themeService, workspace, editorPreferences) {
46
- super();
47
- this.options = options;
48
- this.previewHandlerProvider = previewHandlerProvider;
49
- this.themeService = themeService;
50
- this.workspace = workspace;
51
- this.editorPreferences = editorPreferences;
52
- this.firstUpdate = undefined;
53
- this.onDidScrollEmitter = new common_1.Emitter();
54
- this.onDidDoubleClickEmitter = new common_1.Emitter();
55
- this.preventScrollNotification = false;
56
- this.previousContent = undefined;
57
- this.internalRevealForSourceLine = throttle((sourceLine) => {
58
- if (!this.previewHandler || !this.previewHandler.findElementForSourceLine) {
59
- return;
60
- }
61
- const elementToReveal = this.previewHandler.findElementForSourceLine(this.node, sourceLine);
62
- if (elementToReveal) {
63
- this.preventScrollNotification = true;
64
- elementToReveal.scrollIntoView();
65
- window.setTimeout(() => {
66
- this.preventScrollNotification = false;
67
- }, 50);
68
- }
69
- }, 50);
70
- this.resource = this.options.resource;
71
- this.uri = this.resource.uri;
72
- this.id = 'preview-widget-' + widgetCounter++;
73
- this.title.closable = true;
74
- this.title.label = `Preview ${this.uri.path.base}`;
75
- this.title.caption = this.title.label;
76
- this.title.closable = true;
77
- this.toDispose.push(this.onDidScrollEmitter);
78
- this.toDispose.push(this.onDidDoubleClickEmitter);
79
- this.addClass(exports.PREVIEW_WIDGET_CLASS);
80
- this.node.tabIndex = 0;
81
- const previewHandler = this.previewHandler = this.previewHandlerProvider.findContribution(this.uri)[0];
82
- if (!previewHandler) {
83
- return;
84
- }
85
- this.title.iconClass = previewHandler.iconClass || DEFAULT_ICON;
86
- this.initialize();
87
- }
88
- async initialize() {
89
- this.scrollBeyondLastLine = !!this.editorPreferences['editor.scrollBeyondLastLine'];
90
- this.toDispose.push(this.editorPreferences.onPreferenceChanged(e => {
91
- if (e.preferenceName === 'editor.scrollBeyondLastLine') {
92
- this.scrollBeyondLastLine = Boolean(e.newValue);
93
- this.forceUpdate();
94
- }
95
- }));
96
- this.toDispose.push(this.resource);
97
- if (this.resource.onDidChangeContents) {
98
- this.toDispose.push(this.resource.onDidChangeContents(() => this.update()));
99
- }
100
- const updateIfAffected = (affectedUri) => {
101
- if (!affectedUri || affectedUri === this.uri.toString()) {
102
- this.update();
103
- }
104
- };
105
- this.toDispose.push(this.workspace.onDidOpenTextDocument(document => updateIfAffected(document.uri)));
106
- this.toDispose.push(this.workspace.onDidChangeTextDocument(params => updateIfAffected(params.model.uri)));
107
- this.toDispose.push(this.workspace.onDidCloseTextDocument(document => updateIfAffected(document.uri)));
108
- this.toDispose.push(this.themeService.onDidColorThemeChange(() => this.update()));
109
- this.firstUpdate = () => {
110
- this.revealFragment(this.uri);
111
- };
112
- this.update();
113
- }
114
- onBeforeAttach(msg) {
115
- super.onBeforeAttach(msg);
116
- this.toDispose.push(this.startScrollSync());
117
- this.toDispose.push(this.startDoubleClickListener());
118
- }
119
- startScrollSync() {
120
- return (0, browser_1.addEventListener)(this.node, 'scroll', throttle((event) => {
121
- if (this.preventScrollNotification) {
122
- return;
123
- }
124
- const scrollTop = this.node.scrollTop;
125
- this.didScroll(scrollTop);
126
- }, 50));
127
- }
128
- startDoubleClickListener() {
129
- return (0, browser_1.addEventListener)(this.node, 'dblclick', (event) => {
130
- if (!(event.target instanceof HTMLElement)) {
131
- return;
132
- }
133
- const target = event.target;
134
- let node = target;
135
- while (node && node instanceof HTMLElement) {
136
- if (node.tagName === 'A') {
137
- return;
138
- }
139
- node = node.parentElement;
140
- }
141
- const offsetParent = target.offsetParent;
142
- const offset = offsetParent.classList.contains(exports.PREVIEW_WIDGET_CLASS) ? target.offsetTop : offsetParent.offsetTop;
143
- this.didDoubleClick(offset);
144
- });
145
- }
146
- getUri() {
147
- return this.uri;
148
- }
149
- getResourceUri() {
150
- return this.uri;
151
- }
152
- createMoveToUri(resourceUri) {
153
- return this.uri.withPath(resourceUri.path);
154
- }
155
- onActivateRequest(msg) {
156
- super.onActivateRequest(msg);
157
- this.node.focus();
158
- this.update();
159
- }
160
- onUpdateRequest(msg) {
161
- super.onUpdateRequest(msg);
162
- this.performUpdate();
163
- }
164
- forceUpdate() {
165
- this.previousContent = undefined;
166
- this.update();
167
- }
168
- async performUpdate() {
169
- if (!this.resource) {
170
- return;
171
- }
172
- const uri = this.resource.uri;
173
- const document = this.workspace.textDocuments.find(d => d.uri === uri.toString());
174
- const content = document ? document.getText() : await this.resource.readContents();
175
- if (content === this.previousContent) {
176
- return;
177
- }
178
- this.previousContent = content;
179
- const contentElement = await this.render(content, uri);
180
- this.node.innerHTML = '';
181
- if (contentElement) {
182
- if (this.scrollBeyondLastLine) {
183
- contentElement.classList.add('scrollBeyondLastLine');
184
- }
185
- this.node.appendChild(contentElement);
186
- if (this.firstUpdate) {
187
- this.firstUpdate();
188
- this.firstUpdate = undefined;
189
- }
190
- }
191
- }
192
- async render(content, originUri) {
193
- if (!this.previewHandler || !this.resource) {
194
- return undefined;
195
- }
196
- return this.previewHandler.renderContent({ content, originUri });
197
- }
198
- revealFragment(uri) {
199
- if (uri.fragment === '' || !this.previewHandler || !this.previewHandler.findElementForFragment) {
200
- return;
201
- }
202
- const elementToReveal = this.previewHandler.findElementForFragment(this.node, uri.fragment);
203
- if (elementToReveal) {
204
- this.preventScrollNotification = true;
205
- elementToReveal.scrollIntoView();
206
- window.setTimeout(() => {
207
- this.preventScrollNotification = false;
208
- }, 50);
209
- }
210
- }
211
- revealForSourceLine(sourceLine) {
212
- this.internalRevealForSourceLine(sourceLine);
213
- }
214
- get onDidScroll() {
215
- return this.onDidScrollEmitter.event;
216
- }
217
- fireDidScrollToSourceLine(line) {
218
- this.onDidScrollEmitter.fire(line);
219
- }
220
- didScroll(scrollTop) {
221
- if (!this.previewHandler || !this.previewHandler.getSourceLineForOffset) {
222
- return;
223
- }
224
- const offset = scrollTop;
225
- const line = this.previewHandler.getSourceLineForOffset(this.node, offset);
226
- if (line) {
227
- this.fireDidScrollToSourceLine(line);
228
- }
229
- }
230
- get onDidDoubleClick() {
231
- return this.onDidDoubleClickEmitter.event;
232
- }
233
- fireDidDoubleClickToSourceLine(line) {
234
- if (!this.resource) {
235
- return;
236
- }
237
- this.onDidDoubleClickEmitter.fire({
238
- uri: this.resource.uri.toString(),
239
- range: vscode_languageserver_protocol_1.Range.create({ line, character: 0 }, { line, character: 0 })
240
- });
241
- }
242
- didDoubleClick(offsetTop) {
243
- if (!this.previewHandler || !this.previewHandler.getSourceLineForOffset) {
244
- return;
245
- }
246
- const line = this.previewHandler.getSourceLineForOffset(this.node, offsetTop) || 0;
247
- this.fireDidDoubleClickToSourceLine(line);
248
- }
249
- };
250
- PreviewWidget = __decorate([
251
- (0, inversify_1.injectable)(),
252
- __param(0, (0, inversify_1.inject)(exports.PreviewWidgetOptions)),
253
- __param(1, (0, inversify_1.inject)(preview_handler_1.PreviewHandlerProvider)),
254
- __param(2, (0, inversify_1.inject)(theming_1.ThemeService)),
255
- __param(3, (0, inversify_1.inject)(monaco_workspace_1.MonacoWorkspace)),
256
- __param(4, (0, inversify_1.inject)(browser_2.EditorPreferences)),
257
- __metadata("design:paramtypes", [Object, preview_handler_1.PreviewHandlerProvider,
258
- theming_1.ThemeService,
259
- monaco_workspace_1.MonacoWorkspace, Object])
260
- ], PreviewWidget);
261
- exports.PreviewWidget = PreviewWidget;
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
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
27
+ return function (target, key) { decorator(target, key, paramIndex); }
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.PreviewWidget = exports.PreviewWidgetOptions = exports.PREVIEW_WIDGET_CLASS = void 0;
31
+ const throttle = require("@theia/core/shared/lodash.throttle");
32
+ const inversify_1 = require("@theia/core/shared/inversify");
33
+ const browser_1 = require("@theia/core/lib/browser");
34
+ const common_1 = require("@theia/core/lib/common");
35
+ const preview_handler_1 = require("./preview-handler");
36
+ const theming_1 = require("@theia/core/lib/browser/theming");
37
+ const browser_2 = require("@theia/editor/lib/browser");
38
+ const monaco_workspace_1 = require("@theia/monaco/lib/browser/monaco-workspace");
39
+ const vscode_languageserver_protocol_1 = require("@theia/core/shared/vscode-languageserver-protocol");
40
+ exports.PREVIEW_WIDGET_CLASS = 'theia-preview-widget';
41
+ const DEFAULT_ICON = (0, browser_1.codicon)('eye');
42
+ let widgetCounter = 0;
43
+ exports.PreviewWidgetOptions = Symbol('PreviewWidgetOptions');
44
+ let PreviewWidget = class PreviewWidget extends browser_1.BaseWidget {
45
+ constructor(options, previewHandlerProvider, themeService, workspace, editorPreferences) {
46
+ super();
47
+ this.options = options;
48
+ this.previewHandlerProvider = previewHandlerProvider;
49
+ this.themeService = themeService;
50
+ this.workspace = workspace;
51
+ this.editorPreferences = editorPreferences;
52
+ this.firstUpdate = undefined;
53
+ this.onDidScrollEmitter = new common_1.Emitter();
54
+ this.onDidDoubleClickEmitter = new common_1.Emitter();
55
+ this.preventScrollNotification = false;
56
+ this.previousContent = undefined;
57
+ this.internalRevealForSourceLine = throttle((sourceLine) => {
58
+ if (!this.previewHandler || !this.previewHandler.findElementForSourceLine) {
59
+ return;
60
+ }
61
+ const elementToReveal = this.previewHandler.findElementForSourceLine(this.node, sourceLine);
62
+ if (elementToReveal) {
63
+ this.preventScrollNotification = true;
64
+ elementToReveal.scrollIntoView();
65
+ window.setTimeout(() => {
66
+ this.preventScrollNotification = false;
67
+ }, 50);
68
+ }
69
+ }, 50);
70
+ this.resource = this.options.resource;
71
+ this.uri = this.resource.uri;
72
+ this.id = 'preview-widget-' + widgetCounter++;
73
+ this.title.closable = true;
74
+ this.title.label = `Preview ${this.uri.path.base}`;
75
+ this.title.caption = this.title.label;
76
+ this.title.closable = true;
77
+ this.toDispose.push(this.onDidScrollEmitter);
78
+ this.toDispose.push(this.onDidDoubleClickEmitter);
79
+ this.addClass(exports.PREVIEW_WIDGET_CLASS);
80
+ this.node.tabIndex = 0;
81
+ const previewHandler = this.previewHandler = this.previewHandlerProvider.findContribution(this.uri)[0];
82
+ if (!previewHandler) {
83
+ return;
84
+ }
85
+ this.title.iconClass = previewHandler.iconClass || DEFAULT_ICON;
86
+ this.initialize();
87
+ }
88
+ async initialize() {
89
+ this.scrollBeyondLastLine = !!this.editorPreferences['editor.scrollBeyondLastLine'];
90
+ this.toDispose.push(this.editorPreferences.onPreferenceChanged(e => {
91
+ if (e.preferenceName === 'editor.scrollBeyondLastLine') {
92
+ this.scrollBeyondLastLine = Boolean(e.newValue);
93
+ this.forceUpdate();
94
+ }
95
+ }));
96
+ this.toDispose.push(this.resource);
97
+ if (this.resource.onDidChangeContents) {
98
+ this.toDispose.push(this.resource.onDidChangeContents(() => this.update()));
99
+ }
100
+ const updateIfAffected = (affectedUri) => {
101
+ if (!affectedUri || affectedUri === this.uri.toString()) {
102
+ this.update();
103
+ }
104
+ };
105
+ this.toDispose.push(this.workspace.onDidOpenTextDocument(document => updateIfAffected(document.uri)));
106
+ this.toDispose.push(this.workspace.onDidChangeTextDocument(params => updateIfAffected(params.model.uri)));
107
+ this.toDispose.push(this.workspace.onDidCloseTextDocument(document => updateIfAffected(document.uri)));
108
+ this.toDispose.push(this.themeService.onDidColorThemeChange(() => this.update()));
109
+ this.firstUpdate = () => {
110
+ this.revealFragment(this.uri);
111
+ };
112
+ this.update();
113
+ }
114
+ onBeforeAttach(msg) {
115
+ super.onBeforeAttach(msg);
116
+ this.toDispose.push(this.startScrollSync());
117
+ this.toDispose.push(this.startDoubleClickListener());
118
+ }
119
+ startScrollSync() {
120
+ return (0, browser_1.addEventListener)(this.node, 'scroll', throttle((event) => {
121
+ if (this.preventScrollNotification) {
122
+ return;
123
+ }
124
+ const scrollTop = this.node.scrollTop;
125
+ this.didScroll(scrollTop);
126
+ }, 50));
127
+ }
128
+ startDoubleClickListener() {
129
+ return (0, browser_1.addEventListener)(this.node, 'dblclick', (event) => {
130
+ if (!(event.target instanceof HTMLElement)) {
131
+ return;
132
+ }
133
+ const target = event.target;
134
+ let node = target;
135
+ while (node && node instanceof HTMLElement) {
136
+ if (node.tagName === 'A') {
137
+ return;
138
+ }
139
+ node = node.parentElement;
140
+ }
141
+ const offsetParent = target.offsetParent;
142
+ const offset = offsetParent.classList.contains(exports.PREVIEW_WIDGET_CLASS) ? target.offsetTop : offsetParent.offsetTop;
143
+ this.didDoubleClick(offset);
144
+ });
145
+ }
146
+ getUri() {
147
+ return this.uri;
148
+ }
149
+ getResourceUri() {
150
+ return this.uri;
151
+ }
152
+ createMoveToUri(resourceUri) {
153
+ return this.uri.withPath(resourceUri.path);
154
+ }
155
+ onActivateRequest(msg) {
156
+ super.onActivateRequest(msg);
157
+ this.node.focus();
158
+ this.update();
159
+ }
160
+ onUpdateRequest(msg) {
161
+ super.onUpdateRequest(msg);
162
+ this.performUpdate();
163
+ }
164
+ forceUpdate() {
165
+ this.previousContent = undefined;
166
+ this.update();
167
+ }
168
+ async performUpdate() {
169
+ if (!this.resource) {
170
+ return;
171
+ }
172
+ const uri = this.resource.uri;
173
+ const document = this.workspace.textDocuments.find(d => d.uri === uri.toString());
174
+ const content = document ? document.getText() : await this.resource.readContents();
175
+ if (content === this.previousContent) {
176
+ return;
177
+ }
178
+ this.previousContent = content;
179
+ const contentElement = await this.render(content, uri);
180
+ this.node.innerHTML = '';
181
+ if (contentElement) {
182
+ if (this.scrollBeyondLastLine) {
183
+ contentElement.classList.add('scrollBeyondLastLine');
184
+ }
185
+ this.node.appendChild(contentElement);
186
+ if (this.firstUpdate) {
187
+ this.firstUpdate();
188
+ this.firstUpdate = undefined;
189
+ }
190
+ }
191
+ }
192
+ async render(content, originUri) {
193
+ if (!this.previewHandler || !this.resource) {
194
+ return undefined;
195
+ }
196
+ return this.previewHandler.renderContent({ content, originUri });
197
+ }
198
+ revealFragment(uri) {
199
+ if (uri.fragment === '' || !this.previewHandler || !this.previewHandler.findElementForFragment) {
200
+ return;
201
+ }
202
+ const elementToReveal = this.previewHandler.findElementForFragment(this.node, uri.fragment);
203
+ if (elementToReveal) {
204
+ this.preventScrollNotification = true;
205
+ elementToReveal.scrollIntoView();
206
+ window.setTimeout(() => {
207
+ this.preventScrollNotification = false;
208
+ }, 50);
209
+ }
210
+ }
211
+ revealForSourceLine(sourceLine) {
212
+ this.internalRevealForSourceLine(sourceLine);
213
+ }
214
+ get onDidScroll() {
215
+ return this.onDidScrollEmitter.event;
216
+ }
217
+ fireDidScrollToSourceLine(line) {
218
+ this.onDidScrollEmitter.fire(line);
219
+ }
220
+ didScroll(scrollTop) {
221
+ if (!this.previewHandler || !this.previewHandler.getSourceLineForOffset) {
222
+ return;
223
+ }
224
+ const offset = scrollTop;
225
+ const line = this.previewHandler.getSourceLineForOffset(this.node, offset);
226
+ if (line) {
227
+ this.fireDidScrollToSourceLine(line);
228
+ }
229
+ }
230
+ get onDidDoubleClick() {
231
+ return this.onDidDoubleClickEmitter.event;
232
+ }
233
+ fireDidDoubleClickToSourceLine(line) {
234
+ if (!this.resource) {
235
+ return;
236
+ }
237
+ this.onDidDoubleClickEmitter.fire({
238
+ uri: this.resource.uri.toString(),
239
+ range: vscode_languageserver_protocol_1.Range.create({ line, character: 0 }, { line, character: 0 })
240
+ });
241
+ }
242
+ didDoubleClick(offsetTop) {
243
+ if (!this.previewHandler || !this.previewHandler.getSourceLineForOffset) {
244
+ return;
245
+ }
246
+ const line = this.previewHandler.getSourceLineForOffset(this.node, offsetTop) || 0;
247
+ this.fireDidDoubleClickToSourceLine(line);
248
+ }
249
+ };
250
+ PreviewWidget = __decorate([
251
+ (0, inversify_1.injectable)(),
252
+ __param(0, (0, inversify_1.inject)(exports.PreviewWidgetOptions)),
253
+ __param(1, (0, inversify_1.inject)(preview_handler_1.PreviewHandlerProvider)),
254
+ __param(2, (0, inversify_1.inject)(theming_1.ThemeService)),
255
+ __param(3, (0, inversify_1.inject)(monaco_workspace_1.MonacoWorkspace)),
256
+ __param(4, (0, inversify_1.inject)(browser_2.EditorPreferences)),
257
+ __metadata("design:paramtypes", [Object, preview_handler_1.PreviewHandlerProvider,
258
+ theming_1.ThemeService,
259
+ monaco_workspace_1.MonacoWorkspace, Object])
260
+ ], PreviewWidget);
261
+ exports.PreviewWidget = PreviewWidget;
262
262
  //# sourceMappingURL=preview-widget.js.map
@@ -1,26 +1,26 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
- /* note: this bogus test file is required so that
17
- we are able to run mocha unit tests on this
18
- package, without having any actual unit tests in it.
19
- This way a coverage report will be generated,
20
- showing 0% coverage, instead of no report.
21
- This file can be removed once we have real unit
22
- tests in place. */
23
- describe('preview package', () => {
24
- it('support code coverage statistics', () => true);
25
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ /* note: this bogus test file is required so that
17
+ we are able to run mocha unit tests on this
18
+ package, without having any actual unit tests in it.
19
+ This way a coverage report will be generated,
20
+ showing 0% coverage, instead of no report.
21
+ This file can be removed once we have real unit
22
+ tests in place. */
23
+ describe('preview package', () => {
24
+ it('support code coverage statistics', () => true);
25
+ });
26
26
  //# sourceMappingURL=package.spec.js.map
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@theia/preview",
3
- "version": "1.45.0",
3
+ "version": "1.46.0-next.72+4a275b29d",
4
4
  "description": "Theia - Preview Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.45.0",
7
- "@theia/editor": "1.45.0",
8
- "@theia/mini-browser": "1.45.0",
9
- "@theia/monaco": "1.45.0",
6
+ "@theia/core": "1.46.0-next.72+4a275b29d",
7
+ "@theia/editor": "1.46.0-next.72+4a275b29d",
8
+ "@theia/mini-browser": "1.46.0-next.72+4a275b29d",
9
+ "@theia/monaco": "1.46.0-next.72+4a275b29d",
10
10
  "@types/highlight.js": "^10.1.0",
11
11
  "@types/markdown-it-anchor": "^4.0.1",
12
12
  "highlight.js": "10.4.1",
@@ -45,10 +45,10 @@
45
45
  "watch": "theiaext watch"
46
46
  },
47
47
  "devDependencies": {
48
- "@theia/ext-scripts": "1.45.0"
48
+ "@theia/ext-scripts": "1.46.0"
49
49
  },
50
50
  "nyc": {
51
51
  "extends": "../../configs/nyc.json"
52
52
  },
53
- "gitHead": "2b20a60a0f9b54b19838a0f71760989a19622495"
53
+ "gitHead": "4a275b29d0db6c81190488c7f76cb667da05ef19"
54
54
  }
@@ -1,19 +1,19 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- export * from './preview-uri';
18
- export * from './preview-handler';
19
- export { PreviewOpenerOptions } from './preview-contribution';
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ export * from './preview-uri';
18
+ export * from './preview-handler';
19
+ export { PreviewOpenerOptions } from './preview-contribution';