|
17 | 17 | * under the License. |
18 | 18 | */ |
19 | 19 |
|
20 | | -import { AfterViewInit, Component, ComponentRef, ElementRef, OnDestroy, Type, ViewChild } from "@angular/core"; |
| 20 | +import { AfterViewInit, Component, ComponentRef, ElementRef, OnDestroy, Type, ViewChild, HostListener } from "@angular/core"; |
21 | 21 | import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; |
22 | 22 | import { WorkflowActionService } from "../../service/workflow-graph/model/workflow-action.service"; |
23 | 23 | import { WorkflowVersionService } from "../../../dashboard/service/user/workflow-version/workflow-version.service"; |
@@ -516,6 +516,28 @@ export class CodeEditorComponent implements AfterViewInit, SafeStyle, OnDestroy |
516 | 516 | this.code?.insert(insertOffset, annotations); |
517 | 517 | } |
518 | 518 |
|
| 519 | + @HostListener('window:resize') |
| 520 | + onWindowResize() { |
| 521 | + this.adjustEditorSize(); |
| 522 | + } |
| 523 | + |
| 524 | + private adjustEditorSize(): void { |
| 525 | + const container = this.containerElement.nativeElement; |
| 526 | + const viewportWidth = window.innerWidth; |
| 527 | + const viewportHeight = window.innerHeight; |
| 528 | + |
| 529 | + const rect = container.getBoundingClientRect(); |
| 530 | + |
| 531 | + if (rect.right > viewportWidth) { |
| 532 | + container.style.width = `${viewportWidth - rect.left}px`; |
| 533 | + } |
| 534 | + |
| 535 | + if (rect.bottom > viewportHeight) { |
| 536 | + container.style.height = `${viewportHeight - rect.top}px`; |
| 537 | + } |
| 538 | + |
| 539 | + this.editorWrapper.getEditor()?.layout(); |
| 540 | + } |
519 | 541 | onFocus() { |
520 | 542 | this.workflowActionService.getJointGraphWrapper().highlightOperators(this.currentOperatorId); |
521 | 543 | } |
|
0 commit comments