bf57404688246709e79172bc0af742d38b418b88c7d9cfd6124f19eca5cbe394d88773aac52ab7c7458fc1050b571e4c33148878169f5d581fa42a794093fa 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8. 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;
  9. return c > 3 && r && Object.defineProperty(target, key, r), r;
  10. };
  11. var __param = (this && this.__param) || function (paramIndex, decorator) {
  12. return function (target, key) { decorator(target, key, paramIndex); }
  13. };
  14. import * as dom from '../../../base/browser/dom.js';
  15. import { Event } from '../../../base/common/event.js';
  16. import { ILayoutService } from '../../../platform/layout/browser/layoutService.js';
  17. import { ICodeEditorService } from '../../browser/services/codeEditorService.js';
  18. import { registerSingleton } from '../../../platform/instantiation/common/extensions.js';
  19. let StandaloneLayoutService = class StandaloneLayoutService {
  20. constructor(_codeEditorService) {
  21. this._codeEditorService = _codeEditorService;
  22. this.onDidLayout = Event.None;
  23. this.offset = { top: 0, quickPickTop: 0 };
  24. }
  25. get dimension() {
  26. if (!this._dimension) {
  27. this._dimension = dom.getClientArea(window.document.body);
  28. }
  29. return this._dimension;
  30. }
  31. get hasContainer() {
  32. return false;
  33. }
  34. get container() {
  35. // On a page, multiple editors can be created. Therefore, there are multiple containers, not
  36. // just a single one. Please use `ICodeEditorService` to get the current focused code editor
  37. // and use its container if necessary. You can also instantiate `EditorScopedLayoutService`
  38. // which implements `ILayoutService` but is not a part of the service collection because
  39. // it is code editor instance specific.
  40. throw new Error(`ILayoutService.container is not available in the standalone editor!`);
  41. }
  42. focus() {
  43. var _a;
  44. (_a = this._codeEditorService.getFocusedCodeEditor()) === null || _a === void 0 ? void 0 : _a.focus();
  45. }
  46. };
  47. StandaloneLayoutService = __decorate([
  48. __param(0, ICodeEditorService)
  49. ], StandaloneLayoutService);
  50. let EditorScopedLayoutService = class EditorScopedLayoutService extends StandaloneLayoutService {
  51. constructor(_container, codeEditorService) {
  52. super(codeEditorService);
  53. this._container = _container;
  54. }
  55. get hasContainer() {
  56. return false;
  57. }
  58. get container() {
  59. return this._container;
  60. }
  61. };
  62. EditorScopedLayoutService = __decorate([
  63. __param(1, ICodeEditorService)
  64. ], EditorScopedLayoutService);
  65. export { EditorScopedLayoutService };
  66. registerSingleton(ILayoutService, StandaloneLayoutService);