@theia/editor-preview 1.34.2 → 1.34.3

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 (28) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +52 -52
  3. package/lib/browser/editor-preview-contribution.d.ts +12 -12
  4. package/lib/browser/editor-preview-contribution.js +79 -79
  5. package/lib/browser/editor-preview-frontend-module.d.ts +4 -4
  6. package/lib/browser/editor-preview-frontend-module.js +42 -42
  7. package/lib/browser/editor-preview-manager.d.ts +24 -24
  8. package/lib/browser/editor-preview-manager.js +142 -142
  9. package/lib/browser/editor-preview-preferences.d.ts +11 -11
  10. package/lib/browser/editor-preview-preferences.js +47 -47
  11. package/lib/browser/editor-preview-tree-decorator.d.ts +23 -23
  12. package/lib/browser/editor-preview-tree-decorator.js +110 -110
  13. package/lib/browser/editor-preview-widget-factory.d.ts +13 -13
  14. package/lib/browser/editor-preview-widget-factory.js +52 -52
  15. package/lib/browser/editor-preview-widget.d.ts +25 -25
  16. package/lib/browser/editor-preview-widget.js +102 -102
  17. package/lib/package.spec.js +25 -25
  18. package/package.json +6 -6
  19. package/src/browser/editor-preview-contribution.ts +67 -67
  20. package/src/browser/editor-preview-frontend-module.ts +46 -46
  21. package/src/browser/editor-preview-manager.ts +125 -125
  22. package/src/browser/editor-preview-preferences.ts +53 -53
  23. package/src/browser/editor-preview-tree-decorator.ts +107 -107
  24. package/src/browser/editor-preview-widget-factory.ts +45 -45
  25. package/src/browser/editor-preview-widget.ts +113 -113
  26. package/src/browser/style/editor-preview-widget.css +23 -23
  27. package/src/browser/style/index.css +17 -17
  28. package/src/package.spec.ts +28 -28
@@ -1,111 +1,111 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2021 Ericsson 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 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
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.EditorPreviewTreeDecorator = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const event_1 = require("@theia/core/lib/common/event");
30
- const browser_1 = require("@theia/core/lib/browser");
31
- const navigator_open_editors_tree_model_1 = require("@theia/navigator/lib/browser/open-editors-widget/navigator-open-editors-tree-model");
32
- const editor_preview_widget_1 = require("./editor-preview-widget");
33
- const editor_preview_manager_1 = require("./editor-preview-manager");
34
- let EditorPreviewTreeDecorator = class EditorPreviewTreeDecorator {
35
- constructor() {
36
- this.id = 'theia-open-editors-file-decorator';
37
- this.decorationsMap = new Map();
38
- this.decorationsChangedEmitter = new event_1.Emitter();
39
- this.onDidChangeDecorations = this.decorationsChangedEmitter.event;
40
- this.toDisposeOnDirtyChanged = new Map();
41
- this.toDisposeOnPreviewPinned = new Map();
42
- }
43
- onDidInitializeLayout(app) {
44
- this.shell.onDidAddWidget(widget => this.registerEditorListeners(widget));
45
- this.shell.onDidRemoveWidget(widget => this.unregisterEditorListeners(widget));
46
- this.editorWidgets.forEach(widget => this.registerEditorListeners(widget));
47
- }
48
- registerEditorListeners(widget) {
49
- const saveable = browser_1.Saveable.get(widget);
50
- if (saveable) {
51
- this.toDisposeOnDirtyChanged.set(widget.id, saveable.onDirtyChanged(() => {
52
- this.fireDidChangeDecorations((tree) => this.collectDecorators(tree));
53
- }));
54
- }
55
- if (widget instanceof editor_preview_widget_1.EditorPreviewWidget) {
56
- this.toDisposeOnPreviewPinned.set(widget.id, widget.onDidChangePreviewState(() => {
57
- var _a;
58
- this.fireDidChangeDecorations((tree) => this.collectDecorators(tree));
59
- (_a = this.toDisposeOnPreviewPinned.get(widget.id)) === null || _a === void 0 ? void 0 : _a.dispose();
60
- this.toDisposeOnDirtyChanged.delete(widget.id);
61
- }));
62
- }
63
- }
64
- unregisterEditorListeners(widget) {
65
- var _a, _b;
66
- (_a = this.toDisposeOnDirtyChanged.get(widget.id)) === null || _a === void 0 ? void 0 : _a.dispose();
67
- this.toDisposeOnDirtyChanged.delete(widget.id);
68
- (_b = this.toDisposeOnPreviewPinned.get(widget.id)) === null || _b === void 0 ? void 0 : _b.dispose();
69
- this.toDisposeOnPreviewPinned.delete(widget.id);
70
- }
71
- get editorWidgets() {
72
- return this.shell.widgets.filter((widget) => browser_1.NavigatableWidget.is(widget));
73
- }
74
- fireDidChangeDecorations(event) {
75
- this.decorationsChangedEmitter.fire(event);
76
- }
77
- decorations(tree) {
78
- return this.collectDecorators(tree);
79
- }
80
- // Add workspace root as caption suffix and italicize if PreviewWidget
81
- collectDecorators(tree) {
82
- const result = new Map();
83
- if (tree.root === undefined) {
84
- return result;
85
- }
86
- for (const node of new browser_1.DepthFirstTreeIterator(tree.root)) {
87
- if (navigator_open_editors_tree_model_1.OpenEditorNode.is(node)) {
88
- const { widget } = node;
89
- const isPreviewWidget = widget instanceof editor_preview_widget_1.EditorPreviewWidget && widget.isPreview;
90
- const decorations = {
91
- fontData: { style: isPreviewWidget ? 'italic' : undefined }
92
- };
93
- result.set(node.id, decorations);
94
- }
95
- }
96
- return result;
97
- }
98
- };
99
- __decorate([
100
- (0, inversify_1.inject)(editor_preview_manager_1.EditorPreviewManager),
101
- __metadata("design:type", editor_preview_manager_1.EditorPreviewManager)
102
- ], EditorPreviewTreeDecorator.prototype, "editorPreviewManager", void 0);
103
- __decorate([
104
- (0, inversify_1.inject)(browser_1.ApplicationShell),
105
- __metadata("design:type", browser_1.ApplicationShell)
106
- ], EditorPreviewTreeDecorator.prototype, "shell", void 0);
107
- EditorPreviewTreeDecorator = __decorate([
108
- (0, inversify_1.injectable)()
109
- ], EditorPreviewTreeDecorator);
110
- exports.EditorPreviewTreeDecorator = EditorPreviewTreeDecorator;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2021 Ericsson 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 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
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.EditorPreviewTreeDecorator = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const event_1 = require("@theia/core/lib/common/event");
30
+ const browser_1 = require("@theia/core/lib/browser");
31
+ const navigator_open_editors_tree_model_1 = require("@theia/navigator/lib/browser/open-editors-widget/navigator-open-editors-tree-model");
32
+ const editor_preview_widget_1 = require("./editor-preview-widget");
33
+ const editor_preview_manager_1 = require("./editor-preview-manager");
34
+ let EditorPreviewTreeDecorator = class EditorPreviewTreeDecorator {
35
+ constructor() {
36
+ this.id = 'theia-open-editors-file-decorator';
37
+ this.decorationsMap = new Map();
38
+ this.decorationsChangedEmitter = new event_1.Emitter();
39
+ this.onDidChangeDecorations = this.decorationsChangedEmitter.event;
40
+ this.toDisposeOnDirtyChanged = new Map();
41
+ this.toDisposeOnPreviewPinned = new Map();
42
+ }
43
+ onDidInitializeLayout(app) {
44
+ this.shell.onDidAddWidget(widget => this.registerEditorListeners(widget));
45
+ this.shell.onDidRemoveWidget(widget => this.unregisterEditorListeners(widget));
46
+ this.editorWidgets.forEach(widget => this.registerEditorListeners(widget));
47
+ }
48
+ registerEditorListeners(widget) {
49
+ const saveable = browser_1.Saveable.get(widget);
50
+ if (saveable) {
51
+ this.toDisposeOnDirtyChanged.set(widget.id, saveable.onDirtyChanged(() => {
52
+ this.fireDidChangeDecorations((tree) => this.collectDecorators(tree));
53
+ }));
54
+ }
55
+ if (widget instanceof editor_preview_widget_1.EditorPreviewWidget) {
56
+ this.toDisposeOnPreviewPinned.set(widget.id, widget.onDidChangePreviewState(() => {
57
+ var _a;
58
+ this.fireDidChangeDecorations((tree) => this.collectDecorators(tree));
59
+ (_a = this.toDisposeOnPreviewPinned.get(widget.id)) === null || _a === void 0 ? void 0 : _a.dispose();
60
+ this.toDisposeOnDirtyChanged.delete(widget.id);
61
+ }));
62
+ }
63
+ }
64
+ unregisterEditorListeners(widget) {
65
+ var _a, _b;
66
+ (_a = this.toDisposeOnDirtyChanged.get(widget.id)) === null || _a === void 0 ? void 0 : _a.dispose();
67
+ this.toDisposeOnDirtyChanged.delete(widget.id);
68
+ (_b = this.toDisposeOnPreviewPinned.get(widget.id)) === null || _b === void 0 ? void 0 : _b.dispose();
69
+ this.toDisposeOnPreviewPinned.delete(widget.id);
70
+ }
71
+ get editorWidgets() {
72
+ return this.shell.widgets.filter((widget) => browser_1.NavigatableWidget.is(widget));
73
+ }
74
+ fireDidChangeDecorations(event) {
75
+ this.decorationsChangedEmitter.fire(event);
76
+ }
77
+ decorations(tree) {
78
+ return this.collectDecorators(tree);
79
+ }
80
+ // Add workspace root as caption suffix and italicize if PreviewWidget
81
+ collectDecorators(tree) {
82
+ const result = new Map();
83
+ if (tree.root === undefined) {
84
+ return result;
85
+ }
86
+ for (const node of new browser_1.DepthFirstTreeIterator(tree.root)) {
87
+ if (navigator_open_editors_tree_model_1.OpenEditorNode.is(node)) {
88
+ const { widget } = node;
89
+ const isPreviewWidget = widget instanceof editor_preview_widget_1.EditorPreviewWidget && widget.isPreview;
90
+ const decorations = {
91
+ fontData: { style: isPreviewWidget ? 'italic' : undefined }
92
+ };
93
+ result.set(node.id, decorations);
94
+ }
95
+ }
96
+ return result;
97
+ }
98
+ };
99
+ __decorate([
100
+ (0, inversify_1.inject)(editor_preview_manager_1.EditorPreviewManager),
101
+ __metadata("design:type", editor_preview_manager_1.EditorPreviewManager)
102
+ ], EditorPreviewTreeDecorator.prototype, "editorPreviewManager", void 0);
103
+ __decorate([
104
+ (0, inversify_1.inject)(browser_1.ApplicationShell),
105
+ __metadata("design:type", browser_1.ApplicationShell)
106
+ ], EditorPreviewTreeDecorator.prototype, "shell", void 0);
107
+ EditorPreviewTreeDecorator = __decorate([
108
+ (0, inversify_1.injectable)()
109
+ ], EditorPreviewTreeDecorator);
110
+ exports.EditorPreviewTreeDecorator = EditorPreviewTreeDecorator;
111
111
  //# sourceMappingURL=editor-preview-tree-decorator.js.map
@@ -1,14 +1,14 @@
1
- import URI from '@theia/core/lib/common/uri';
2
- import { EditorWidgetFactory } from '@theia/editor/lib/browser/editor-widget-factory';
3
- import { EditorPreviewWidget } from './editor-preview-widget';
4
- import { NavigatableWidgetOptions } from '@theia/core/lib/browser';
5
- export interface EditorPreviewOptions extends NavigatableWidgetOptions {
6
- preview?: boolean;
7
- }
8
- export declare class EditorPreviewWidgetFactory extends EditorWidgetFactory {
9
- static ID: string;
10
- readonly id: string;
11
- createWidget(options: EditorPreviewOptions): Promise<EditorPreviewWidget>;
12
- protected constructEditor(uri: URI): Promise<EditorPreviewWidget>;
13
- }
1
+ import URI from '@theia/core/lib/common/uri';
2
+ import { EditorWidgetFactory } from '@theia/editor/lib/browser/editor-widget-factory';
3
+ import { EditorPreviewWidget } from './editor-preview-widget';
4
+ import { NavigatableWidgetOptions } from '@theia/core/lib/browser';
5
+ export interface EditorPreviewOptions extends NavigatableWidgetOptions {
6
+ preview?: boolean;
7
+ }
8
+ export declare class EditorPreviewWidgetFactory extends EditorWidgetFactory {
9
+ static ID: string;
10
+ readonly id: string;
11
+ createWidget(options: EditorPreviewOptions): Promise<EditorPreviewWidget>;
12
+ protected constructEditor(uri: URI): Promise<EditorPreviewWidget>;
13
+ }
14
14
  //# sourceMappingURL=editor-preview-widget-factory.d.ts.map
@@ -1,53 +1,53 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2018-2021 Google 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 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 EditorPreviewWidgetFactory_1;
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.EditorPreviewWidgetFactory = void 0;
26
- const uri_1 = require("@theia/core/lib/common/uri");
27
- const editor_widget_factory_1 = require("@theia/editor/lib/browser/editor-widget-factory");
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const editor_preview_widget_1 = require("./editor-preview-widget");
30
- let EditorPreviewWidgetFactory = EditorPreviewWidgetFactory_1 = class EditorPreviewWidgetFactory extends editor_widget_factory_1.EditorWidgetFactory {
31
- constructor() {
32
- super(...arguments);
33
- this.id = EditorPreviewWidgetFactory_1.ID;
34
- }
35
- async createWidget(options) {
36
- const uri = new uri_1.default(options.uri);
37
- const editor = await this.createEditor(uri, options);
38
- if (options.preview) {
39
- editor.initializePreview();
40
- }
41
- return editor;
42
- }
43
- async constructEditor(uri) {
44
- const textEditor = await this.editorProvider(uri);
45
- return new editor_preview_widget_1.EditorPreviewWidget(textEditor, this.selectionService);
46
- }
47
- };
48
- EditorPreviewWidgetFactory.ID = 'editor-preview-widget';
49
- EditorPreviewWidgetFactory = EditorPreviewWidgetFactory_1 = __decorate([
50
- (0, inversify_1.injectable)()
51
- ], EditorPreviewWidgetFactory);
52
- exports.EditorPreviewWidgetFactory = EditorPreviewWidgetFactory;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2018-2021 Google 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 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 EditorPreviewWidgetFactory_1;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.EditorPreviewWidgetFactory = void 0;
26
+ const uri_1 = require("@theia/core/lib/common/uri");
27
+ const editor_widget_factory_1 = require("@theia/editor/lib/browser/editor-widget-factory");
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const editor_preview_widget_1 = require("./editor-preview-widget");
30
+ let EditorPreviewWidgetFactory = EditorPreviewWidgetFactory_1 = class EditorPreviewWidgetFactory extends editor_widget_factory_1.EditorWidgetFactory {
31
+ constructor() {
32
+ super(...arguments);
33
+ this.id = EditorPreviewWidgetFactory_1.ID;
34
+ }
35
+ async createWidget(options) {
36
+ const uri = new uri_1.default(options.uri);
37
+ const editor = await this.createEditor(uri, options);
38
+ if (options.preview) {
39
+ editor.initializePreview();
40
+ }
41
+ return editor;
42
+ }
43
+ async constructEditor(uri) {
44
+ const textEditor = await this.editorProvider(uri);
45
+ return new editor_preview_widget_1.EditorPreviewWidget(textEditor, this.selectionService);
46
+ }
47
+ };
48
+ EditorPreviewWidgetFactory.ID = 'editor-preview-widget';
49
+ EditorPreviewWidgetFactory = EditorPreviewWidgetFactory_1 = __decorate([
50
+ (0, inversify_1.injectable)()
51
+ ], EditorPreviewWidgetFactory);
52
+ exports.EditorPreviewWidgetFactory = EditorPreviewWidgetFactory;
53
53
  //# sourceMappingURL=editor-preview-widget-factory.js.map
@@ -1,26 +1,26 @@
1
- import { Message } from '@theia/core/shared/@phosphor/messaging';
2
- import { TabBar, Widget } from '@theia/core/lib/browser';
3
- import { EditorWidget, TextEditor } from '@theia/editor/lib/browser';
4
- import { DisposableCollection, Emitter, SelectionService } from '@theia/core/lib/common';
5
- export declare class EditorPreviewWidget extends EditorWidget {
6
- protected _isPreview: boolean;
7
- protected lastTabbar: TabBar<Widget> | undefined;
8
- protected readonly onDidChangePreviewStateEmitter: Emitter<void>;
9
- readonly onDidChangePreviewState: import("@theia/core/lib/common").Event<void>;
10
- protected readonly toDisposeOnLocationChange: DisposableCollection;
11
- get isPreview(): boolean;
12
- constructor(editor: TextEditor, selectionService: SelectionService);
13
- initializePreview(): void;
14
- convertToNonPreview(): void;
15
- protected onAfterAttach(msg: Message): void;
16
- protected checkForTabbarChange(): void;
17
- storeState(): {
18
- isPreview: boolean;
19
- editorState: object;
20
- } | undefined;
21
- restoreState(oldState: {
22
- isPreview: boolean;
23
- editorState: object;
24
- }): void;
25
- }
1
+ import { Message } from '@theia/core/shared/@phosphor/messaging';
2
+ import { TabBar, Widget } from '@theia/core/lib/browser';
3
+ import { EditorWidget, TextEditor } from '@theia/editor/lib/browser';
4
+ import { DisposableCollection, Emitter, SelectionService } from '@theia/core/lib/common';
5
+ export declare class EditorPreviewWidget extends EditorWidget {
6
+ protected _isPreview: boolean;
7
+ protected lastTabbar: TabBar<Widget> | undefined;
8
+ protected readonly onDidChangePreviewStateEmitter: Emitter<void>;
9
+ readonly onDidChangePreviewState: import("@theia/core/lib/common").Event<void>;
10
+ protected readonly toDisposeOnLocationChange: DisposableCollection;
11
+ get isPreview(): boolean;
12
+ constructor(editor: TextEditor, selectionService: SelectionService);
13
+ initializePreview(): void;
14
+ convertToNonPreview(): void;
15
+ protected onAfterAttach(msg: Message): void;
16
+ protected checkForTabbarChange(): void;
17
+ storeState(): {
18
+ isPreview: boolean;
19
+ editorState: object;
20
+ } | undefined;
21
+ restoreState(oldState: {
22
+ isPreview: boolean;
23
+ editorState: object;
24
+ }): void;
25
+ }
26
26
  //# sourceMappingURL=editor-preview-widget.d.ts.map
@@ -1,103 +1,103 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2021 Ericsson 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 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.EditorPreviewWidget = void 0;
19
- const browser_1 = require("@theia/core/lib/browser");
20
- const browser_2 = require("@theia/editor/lib/browser");
21
- const common_1 = require("@theia/core/lib/common");
22
- const algorithm_1 = require("@theia/core/shared/@phosphor/algorithm");
23
- const PREVIEW_TITLE_CLASS = 'theia-editor-preview-title-unpinned';
24
- class EditorPreviewWidget extends browser_2.EditorWidget {
25
- constructor(editor, selectionService) {
26
- super(editor, selectionService);
27
- this._isPreview = false;
28
- this.onDidChangePreviewStateEmitter = new common_1.Emitter();
29
- this.onDidChangePreviewState = this.onDidChangePreviewStateEmitter.event;
30
- this.toDisposeOnLocationChange = new common_1.DisposableCollection();
31
- this.toDispose.push(this.onDidChangePreviewStateEmitter);
32
- this.toDispose.push(this.toDisposeOnLocationChange);
33
- }
34
- get isPreview() {
35
- return this._isPreview;
36
- }
37
- initializePreview() {
38
- const oneTimeListeners = new common_1.DisposableCollection();
39
- this._isPreview = true;
40
- this.title.className += ` ${PREVIEW_TITLE_CLASS}`;
41
- const oneTimeDirtyChangeListener = this.saveable.onDirtyChanged(() => {
42
- this.convertToNonPreview();
43
- oneTimeListeners.dispose();
44
- });
45
- oneTimeListeners.push(oneTimeDirtyChangeListener);
46
- const oneTimeTitleChangeHandler = () => {
47
- if (this.title.className.includes(browser_1.PINNED_CLASS)) {
48
- this.convertToNonPreview();
49
- oneTimeListeners.dispose();
50
- }
51
- };
52
- this.title.changed.connect(oneTimeTitleChangeHandler);
53
- oneTimeListeners.push(common_1.Disposable.create(() => this.title.changed.disconnect(oneTimeTitleChangeHandler)));
54
- this.toDispose.push(oneTimeListeners);
55
- }
56
- convertToNonPreview() {
57
- if (this._isPreview) {
58
- this._isPreview = false;
59
- this.toDisposeOnLocationChange.dispose();
60
- this.lastTabbar = undefined;
61
- this.title.className = this.title.className.replace(PREVIEW_TITLE_CLASS, '');
62
- this.onDidChangePreviewStateEmitter.fire();
63
- this.onDidChangePreviewStateEmitter.dispose();
64
- }
65
- }
66
- onAfterAttach(msg) {
67
- super.onAfterAttach(msg);
68
- if (this._isPreview) {
69
- this.checkForTabbarChange();
70
- }
71
- }
72
- checkForTabbarChange() {
73
- const { parent } = this;
74
- if (parent instanceof browser_1.DockPanel) {
75
- this.toDisposeOnLocationChange.dispose();
76
- const newTabbar = (0, algorithm_1.find)(parent.tabBars(), tabbar => !!tabbar.titles.find(title => title === this.title));
77
- if (this.lastTabbar && this.lastTabbar !== newTabbar) {
78
- this.convertToNonPreview();
79
- }
80
- else {
81
- this.lastTabbar = newTabbar;
82
- const listener = () => this.checkForTabbarChange();
83
- parent.layoutModified.connect(listener);
84
- this.toDisposeOnLocationChange.push(common_1.Disposable.create(() => parent.layoutModified.disconnect(listener)));
85
- }
86
- }
87
- }
88
- storeState() {
89
- var _a;
90
- if (((_a = this.getResourceUri()) === null || _a === void 0 ? void 0 : _a.scheme) !== common_1.UNTITLED_SCHEME) {
91
- const { _isPreview: isPreview } = this;
92
- return { isPreview, editorState: this.editor.storeViewState() };
93
- }
94
- }
95
- restoreState(oldState) {
96
- if (!oldState.isPreview) {
97
- this.convertToNonPreview();
98
- }
99
- this.editor.restoreViewState(oldState.editorState);
100
- }
101
- }
102
- exports.EditorPreviewWidget = EditorPreviewWidget;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2021 Ericsson 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 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.EditorPreviewWidget = void 0;
19
+ const browser_1 = require("@theia/core/lib/browser");
20
+ const browser_2 = require("@theia/editor/lib/browser");
21
+ const common_1 = require("@theia/core/lib/common");
22
+ const algorithm_1 = require("@theia/core/shared/@phosphor/algorithm");
23
+ const PREVIEW_TITLE_CLASS = 'theia-editor-preview-title-unpinned';
24
+ class EditorPreviewWidget extends browser_2.EditorWidget {
25
+ constructor(editor, selectionService) {
26
+ super(editor, selectionService);
27
+ this._isPreview = false;
28
+ this.onDidChangePreviewStateEmitter = new common_1.Emitter();
29
+ this.onDidChangePreviewState = this.onDidChangePreviewStateEmitter.event;
30
+ this.toDisposeOnLocationChange = new common_1.DisposableCollection();
31
+ this.toDispose.push(this.onDidChangePreviewStateEmitter);
32
+ this.toDispose.push(this.toDisposeOnLocationChange);
33
+ }
34
+ get isPreview() {
35
+ return this._isPreview;
36
+ }
37
+ initializePreview() {
38
+ const oneTimeListeners = new common_1.DisposableCollection();
39
+ this._isPreview = true;
40
+ this.title.className += ` ${PREVIEW_TITLE_CLASS}`;
41
+ const oneTimeDirtyChangeListener = this.saveable.onDirtyChanged(() => {
42
+ this.convertToNonPreview();
43
+ oneTimeListeners.dispose();
44
+ });
45
+ oneTimeListeners.push(oneTimeDirtyChangeListener);
46
+ const oneTimeTitleChangeHandler = () => {
47
+ if (this.title.className.includes(browser_1.PINNED_CLASS)) {
48
+ this.convertToNonPreview();
49
+ oneTimeListeners.dispose();
50
+ }
51
+ };
52
+ this.title.changed.connect(oneTimeTitleChangeHandler);
53
+ oneTimeListeners.push(common_1.Disposable.create(() => this.title.changed.disconnect(oneTimeTitleChangeHandler)));
54
+ this.toDispose.push(oneTimeListeners);
55
+ }
56
+ convertToNonPreview() {
57
+ if (this._isPreview) {
58
+ this._isPreview = false;
59
+ this.toDisposeOnLocationChange.dispose();
60
+ this.lastTabbar = undefined;
61
+ this.title.className = this.title.className.replace(PREVIEW_TITLE_CLASS, '');
62
+ this.onDidChangePreviewStateEmitter.fire();
63
+ this.onDidChangePreviewStateEmitter.dispose();
64
+ }
65
+ }
66
+ onAfterAttach(msg) {
67
+ super.onAfterAttach(msg);
68
+ if (this._isPreview) {
69
+ this.checkForTabbarChange();
70
+ }
71
+ }
72
+ checkForTabbarChange() {
73
+ const { parent } = this;
74
+ if (parent instanceof browser_1.DockPanel) {
75
+ this.toDisposeOnLocationChange.dispose();
76
+ const newTabbar = (0, algorithm_1.find)(parent.tabBars(), tabbar => !!tabbar.titles.find(title => title === this.title));
77
+ if (this.lastTabbar && this.lastTabbar !== newTabbar) {
78
+ this.convertToNonPreview();
79
+ }
80
+ else {
81
+ this.lastTabbar = newTabbar;
82
+ const listener = () => this.checkForTabbarChange();
83
+ parent.layoutModified.connect(listener);
84
+ this.toDisposeOnLocationChange.push(common_1.Disposable.create(() => parent.layoutModified.disconnect(listener)));
85
+ }
86
+ }
87
+ }
88
+ storeState() {
89
+ var _a;
90
+ if (((_a = this.getResourceUri()) === null || _a === void 0 ? void 0 : _a.scheme) !== common_1.UNTITLED_SCHEME) {
91
+ const { _isPreview: isPreview } = this;
92
+ return { isPreview, editorState: this.editor.storeViewState() };
93
+ }
94
+ }
95
+ restoreState(oldState) {
96
+ if (!oldState.isPreview) {
97
+ this.convertToNonPreview();
98
+ }
99
+ this.editor.restoreViewState(oldState.editorState);
100
+ }
101
+ }
102
+ exports.EditorPreviewWidget = EditorPreviewWidget;
103
103
  //# sourceMappingURL=editor-preview-widget.js.map