@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,194 +1,194 @@
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
- /* eslint-disable no-unsanitized/property */
19
- const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
20
- let disableJSDOM = (0, jsdom_1.enableJSDOM)();
21
- const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
22
- frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
23
- const chai = require("chai");
24
- const chai_1 = require("chai");
25
- const uri_1 = require("@theia/core/lib/common/uri");
26
- const markdown_preview_handler_1 = require("./markdown-preview-handler");
27
- disableJSDOM();
28
- chai.use(require('chai-string'));
29
- let previewHandler;
30
- before(() => {
31
- previewHandler = new markdown_preview_handler_1.MarkdownPreviewHandler();
32
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
- previewHandler.linkNormalizer = {
34
- normalizeLink: (documentUri, link) => 'endpoint/' + documentUri.parent.resolve(link).path.toString().substring(1)
35
- };
36
- });
37
- describe('markdown-preview-handler', () => {
38
- before(() => {
39
- disableJSDOM = (0, jsdom_1.enableJSDOM)();
40
- });
41
- after(() => {
42
- disableJSDOM();
43
- });
44
- it('renders html with line information', async () => {
45
- await assertRenderedContent(exampleMarkdown1, exampleHtml1);
46
- });
47
- it('renders images', async () => {
48
- await assertRenderedContent(exampleMarkdown2, exampleHtml2);
49
- });
50
- it('renders HTML image as block', async () => {
51
- await assertRenderedContent(exampleMarkdown3, exampleHtml3);
52
- });
53
- it('renders HTML images inlined', async () => {
54
- await assertRenderedContent(exampleMarkdown4, exampleHtml4);
55
- });
56
- it('renders multiple HTML images in a html block', async () => {
57
- await assertRenderedContent(exampleMarkdown5, exampleHtml5);
58
- });
59
- it('finds element for source line', () => {
60
- document.body.innerHTML = exampleHtml1;
61
- const element = previewHandler.findElementForSourceLine(document.body, 4);
62
- (0, chai_1.expect)(element).not.to.be.equal(undefined);
63
- (0, chai_1.expect)(element.tagName).to.be.equal('H2');
64
- (0, chai_1.expect)(element.textContent).to.be.equal('License');
65
- });
66
- it('finds previous element for empty source line', () => {
67
- document.body.innerHTML = exampleHtml1;
68
- const element = previewHandler.findElementForSourceLine(document.body, 3);
69
- (0, chai_1.expect)(element).not.to.be.equal(undefined);
70
- (0, chai_1.expect)(element.tagName).to.be.equal('P');
71
- (0, chai_1.expect)(element.textContent).that.startWith('Shows a preview of supported resources.');
72
- });
73
- it('finds source line for offset in html', () => {
74
- mockOffsetProperties();
75
- document.body.innerHTML = exampleHtml1;
76
- for (const expectedLine of [0, 1, 4, 5]) {
77
- const line = previewHandler.getSourceLineForOffset(document.body, offsetForLine(expectedLine));
78
- (0, chai_1.expect)(line).to.be.equal(expectedLine);
79
- }
80
- });
81
- it('interpolates source lines for offset in html', () => {
82
- mockOffsetProperties();
83
- document.body.innerHTML = exampleHtml1;
84
- const expectedLines = [1, 2, 3, 4];
85
- const offsets = expectedLines.map(l => offsetForLine(l));
86
- for (let i = 0; i < expectedLines.length; i++) {
87
- const expectedLine = expectedLines[i];
88
- const offset = offsets[i];
89
- const line = previewHandler.getSourceLineForOffset(document.body, offset);
90
- (0, chai_1.expect)(line).to.be.equal(expectedLine);
91
- }
92
- });
93
- it('can handle \'.md\' files', () => {
94
- (0, chai_1.expect)(previewHandler.canHandle(new uri_1.default('a.md'))).greaterThan(0);
95
- });
96
- it('can handle \'.markdown\' files', () => {
97
- (0, chai_1.expect)(previewHandler.canHandle(new uri_1.default('a.markdown'))).greaterThan(0);
98
- });
99
- });
100
- async function assertRenderedContent(source, expectation) {
101
- const contentElement = previewHandler.renderContent({ content: source, originUri: new uri_1.default('file:///workspace/DEMO.md') });
102
- (0, chai_1.expect)(contentElement.innerHTML).equals(expectation);
103
- }
104
- const exampleMarkdown1 = //
105
- `# Theia - Preview Extension
106
- Shows a preview of supported resources.
107
- See [here](https://github.com/eclipse-theia/theia).
108
-
109
- ## License
110
- [Apache-2.0](https://github.com/eclipse-theia/theia/blob/master/LICENSE)
111
- `;
112
- const exampleHtml1 = //
113
- `<h1 data-line="0" class="line" id="theia---preview-extension">Theia - Preview Extension</h1>
114
- <p data-line="1" class="line">Shows a preview of supported resources.
115
- See <a href="https://github.com/eclipse-theia/theia">here</a>.</p>
116
- <h2 data-line="4" class="line" id="license">License</h2>
117
- <p data-line="5" class="line"><a href="https://github.com/eclipse-theia/theia/blob/master/LICENSE">Apache-2.0</a></p>
118
- `;
119
- const exampleMarkdown2 = //
120
- `# Heading
121
- ![alternativetext](subfolder/image.png)
122
- `;
123
- const exampleHtml2 = //
124
- `<h1 data-line="0" class="line" id="heading">Heading</h1>
125
- <p data-line="1" class="line"><img alt="alternativetext" src="endpoint/workspace/subfolder/image.png"></p>
126
- `;
127
- const exampleMarkdown3 = //
128
- `# Block HTML Image
129
- <img src="subfolder/image1.png" alt="tada"/>
130
-
131
- # Block HTML Image
132
- <img src="subfolder/image3.png" alt="tada"/>
133
- `;
134
- const exampleHtml3 = //
135
- `<h1 data-line="0" class="line" id="block-html-image">Block HTML Image</h1>
136
- <img alt="tada" src="endpoint/workspace/subfolder/image1.png">
137
- <h1 data-line="3" class="line" id="block-html-image-2">Block HTML Image</h1>
138
- <img alt="tada" src="endpoint/workspace/subfolder/image3.png">
139
- `;
140
- const exampleMarkdown4 = //
141
- `# Inlined HTML Image
142
- text in paragraph <img src="subfolder/image2.png" alt="tada"/>
143
- `;
144
- const exampleHtml4 = //
145
- `<h1 data-line="0" class="line" id="inlined-html-image">Inlined HTML Image</h1>
146
- <p data-line="1" class="line">text in paragraph <img alt="tada" src="endpoint/workspace/subfolder/image2.png"></p>
147
- `;
148
- const exampleMarkdown5 = //
149
- `# Multiple HTML Images nested in blocks
150
- word <p>
151
- <img src="subfolder/image2.png" alt="tada"/>
152
- </p>
153
-
154
- <p>
155
- <img src="subfolder/image2.png" alt="tada"/>
156
- </p>
157
- `;
158
- const exampleHtml5 = //
159
- `<h1 data-line="0" class="line" id="multiple-html-images-nested-in-blocks">Multiple HTML Images nested in blocks</h1>
160
- <p data-line="1" class="line">word </p><p>
161
- <img alt="tada" src="endpoint/workspace/subfolder/image2.png"></p>
162
- <p></p>
163
- <p>
164
- <img alt="tada" src="endpoint/workspace/subfolder/image2.png">
165
- </p>
166
- `;
167
- /**
168
- * `offsetTop` of elements to be `sourceLine` number times `20`.
169
- */
170
- function mockOffsetProperties() {
171
- Object.defineProperties(HTMLElement.prototype, {
172
- offsetLeft: {
173
- get: () => 0
174
- },
175
- offsetTop: {
176
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
177
- get: function () {
178
- const element = this;
179
- const line = Number.parseInt(element.getAttribute('data-line') || '0');
180
- return offsetForLine(line);
181
- }
182
- },
183
- offsetHeight: {
184
- get: () => 0
185
- },
186
- offsetWidth: {
187
- get: () => 0
188
- }
189
- });
190
- }
191
- function offsetForLine(line) {
192
- return line * 20;
193
- }
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
+ /* eslint-disable no-unsanitized/property */
19
+ const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
20
+ let disableJSDOM = (0, jsdom_1.enableJSDOM)();
21
+ const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
22
+ frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
23
+ const chai = require("chai");
24
+ const chai_1 = require("chai");
25
+ const uri_1 = require("@theia/core/lib/common/uri");
26
+ const markdown_preview_handler_1 = require("./markdown-preview-handler");
27
+ disableJSDOM();
28
+ chai.use(require('chai-string'));
29
+ let previewHandler;
30
+ before(() => {
31
+ previewHandler = new markdown_preview_handler_1.MarkdownPreviewHandler();
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ previewHandler.linkNormalizer = {
34
+ normalizeLink: (documentUri, link) => 'endpoint/' + documentUri.parent.resolve(link).path.toString().substring(1)
35
+ };
36
+ });
37
+ describe('markdown-preview-handler', () => {
38
+ before(() => {
39
+ disableJSDOM = (0, jsdom_1.enableJSDOM)();
40
+ });
41
+ after(() => {
42
+ disableJSDOM();
43
+ });
44
+ it('renders html with line information', async () => {
45
+ await assertRenderedContent(exampleMarkdown1, exampleHtml1);
46
+ });
47
+ it('renders images', async () => {
48
+ await assertRenderedContent(exampleMarkdown2, exampleHtml2);
49
+ });
50
+ it('renders HTML image as block', async () => {
51
+ await assertRenderedContent(exampleMarkdown3, exampleHtml3);
52
+ });
53
+ it('renders HTML images inlined', async () => {
54
+ await assertRenderedContent(exampleMarkdown4, exampleHtml4);
55
+ });
56
+ it('renders multiple HTML images in a html block', async () => {
57
+ await assertRenderedContent(exampleMarkdown5, exampleHtml5);
58
+ });
59
+ it('finds element for source line', () => {
60
+ document.body.innerHTML = exampleHtml1;
61
+ const element = previewHandler.findElementForSourceLine(document.body, 4);
62
+ (0, chai_1.expect)(element).not.to.be.equal(undefined);
63
+ (0, chai_1.expect)(element.tagName).to.be.equal('H2');
64
+ (0, chai_1.expect)(element.textContent).to.be.equal('License');
65
+ });
66
+ it('finds previous element for empty source line', () => {
67
+ document.body.innerHTML = exampleHtml1;
68
+ const element = previewHandler.findElementForSourceLine(document.body, 3);
69
+ (0, chai_1.expect)(element).not.to.be.equal(undefined);
70
+ (0, chai_1.expect)(element.tagName).to.be.equal('P');
71
+ (0, chai_1.expect)(element.textContent).that.startWith('Shows a preview of supported resources.');
72
+ });
73
+ it('finds source line for offset in html', () => {
74
+ mockOffsetProperties();
75
+ document.body.innerHTML = exampleHtml1;
76
+ for (const expectedLine of [0, 1, 4, 5]) {
77
+ const line = previewHandler.getSourceLineForOffset(document.body, offsetForLine(expectedLine));
78
+ (0, chai_1.expect)(line).to.be.equal(expectedLine);
79
+ }
80
+ });
81
+ it('interpolates source lines for offset in html', () => {
82
+ mockOffsetProperties();
83
+ document.body.innerHTML = exampleHtml1;
84
+ const expectedLines = [1, 2, 3, 4];
85
+ const offsets = expectedLines.map(l => offsetForLine(l));
86
+ for (let i = 0; i < expectedLines.length; i++) {
87
+ const expectedLine = expectedLines[i];
88
+ const offset = offsets[i];
89
+ const line = previewHandler.getSourceLineForOffset(document.body, offset);
90
+ (0, chai_1.expect)(line).to.be.equal(expectedLine);
91
+ }
92
+ });
93
+ it('can handle \'.md\' files', () => {
94
+ (0, chai_1.expect)(previewHandler.canHandle(new uri_1.default('a.md'))).greaterThan(0);
95
+ });
96
+ it('can handle \'.markdown\' files', () => {
97
+ (0, chai_1.expect)(previewHandler.canHandle(new uri_1.default('a.markdown'))).greaterThan(0);
98
+ });
99
+ });
100
+ async function assertRenderedContent(source, expectation) {
101
+ const contentElement = previewHandler.renderContent({ content: source, originUri: new uri_1.default('file:///workspace/DEMO.md') });
102
+ (0, chai_1.expect)(contentElement.innerHTML).equals(expectation);
103
+ }
104
+ const exampleMarkdown1 = //
105
+ `# Theia - Preview Extension
106
+ Shows a preview of supported resources.
107
+ See [here](https://github.com/eclipse-theia/theia).
108
+
109
+ ## License
110
+ [Apache-2.0](https://github.com/eclipse-theia/theia/blob/master/LICENSE)
111
+ `;
112
+ const exampleHtml1 = //
113
+ `<h1 data-line="0" class="line" id="theia---preview-extension">Theia - Preview Extension</h1>
114
+ <p data-line="1" class="line">Shows a preview of supported resources.
115
+ See <a href="https://github.com/eclipse-theia/theia">here</a>.</p>
116
+ <h2 data-line="4" class="line" id="license">License</h2>
117
+ <p data-line="5" class="line"><a href="https://github.com/eclipse-theia/theia/blob/master/LICENSE">Apache-2.0</a></p>
118
+ `;
119
+ const exampleMarkdown2 = //
120
+ `# Heading
121
+ ![alternativetext](subfolder/image.png)
122
+ `;
123
+ const exampleHtml2 = //
124
+ `<h1 data-line="0" class="line" id="heading">Heading</h1>
125
+ <p data-line="1" class="line"><img alt="alternativetext" src="endpoint/workspace/subfolder/image.png"></p>
126
+ `;
127
+ const exampleMarkdown3 = //
128
+ `# Block HTML Image
129
+ <img src="subfolder/image1.png" alt="tada"/>
130
+
131
+ # Block HTML Image
132
+ <img src="subfolder/image3.png" alt="tada"/>
133
+ `;
134
+ const exampleHtml3 = //
135
+ `<h1 data-line="0" class="line" id="block-html-image">Block HTML Image</h1>
136
+ <img alt="tada" src="endpoint/workspace/subfolder/image1.png">
137
+ <h1 data-line="3" class="line" id="block-html-image-2">Block HTML Image</h1>
138
+ <img alt="tada" src="endpoint/workspace/subfolder/image3.png">
139
+ `;
140
+ const exampleMarkdown4 = //
141
+ `# Inlined HTML Image
142
+ text in paragraph <img src="subfolder/image2.png" alt="tada"/>
143
+ `;
144
+ const exampleHtml4 = //
145
+ `<h1 data-line="0" class="line" id="inlined-html-image">Inlined HTML Image</h1>
146
+ <p data-line="1" class="line">text in paragraph <img alt="tada" src="endpoint/workspace/subfolder/image2.png"></p>
147
+ `;
148
+ const exampleMarkdown5 = //
149
+ `# Multiple HTML Images nested in blocks
150
+ word <p>
151
+ <img src="subfolder/image2.png" alt="tada"/>
152
+ </p>
153
+
154
+ <p>
155
+ <img src="subfolder/image2.png" alt="tada"/>
156
+ </p>
157
+ `;
158
+ const exampleHtml5 = //
159
+ `<h1 data-line="0" class="line" id="multiple-html-images-nested-in-blocks">Multiple HTML Images nested in blocks</h1>
160
+ <p data-line="1" class="line">word </p><p>
161
+ <img alt="tada" src="endpoint/workspace/subfolder/image2.png"></p>
162
+ <p></p>
163
+ <p>
164
+ <img alt="tada" src="endpoint/workspace/subfolder/image2.png">
165
+ </p>
166
+ `;
167
+ /**
168
+ * `offsetTop` of elements to be `sourceLine` number times `20`.
169
+ */
170
+ function mockOffsetProperties() {
171
+ Object.defineProperties(HTMLElement.prototype, {
172
+ offsetLeft: {
173
+ get: () => 0
174
+ },
175
+ offsetTop: {
176
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
177
+ get: function () {
178
+ const element = this;
179
+ const line = Number.parseInt(element.getAttribute('data-line') || '0');
180
+ return offsetForLine(line);
181
+ }
182
+ },
183
+ offsetHeight: {
184
+ get: () => 0
185
+ },
186
+ offsetWidth: {
187
+ get: () => 0
188
+ }
189
+ });
190
+ }
191
+ function offsetForLine(line) {
192
+ return line * 20;
193
+ }
194
194
  //# sourceMappingURL=markdown-preview-handler.spec.js.map
@@ -1,51 +1,51 @@
1
- import { Widget } from '@theia/core/shared/@phosphor/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 './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
- }
1
+ import { Widget } from '@theia/core/shared/@phosphor/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 './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
51
  //# sourceMappingURL=preview-contribution.d.ts.map