From 230982fb61a4d4ec2e57c7e80623e3e14e244b19 Mon Sep 17 00:00:00 2001 From: buqiyuan <1743369777@qq.com> Date: Tue, 12 Jul 2022 18:46:54 +0800 Subject: [PATCH] feat: add codeChange output event --- .../api-script/api-script.component.html | 3 ++- .../components/api-script/api-script.component.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/workbench/browser/src/app/shared/components/api-script/api-script.component.html b/src/workbench/browser/src/app/shared/components/api-script/api-script.component.html index 0f6a7494..0a1e6a03 100644 --- a/src/workbench/browser/src/app/shared/components/api-script/api-script.component.html +++ b/src/workbench/browser/src/app/shared/components/api-script/api-script.component.html @@ -48,7 +48,8 @@
- +
diff --git a/src/workbench/browser/src/app/shared/components/api-script/api-script.component.ts b/src/workbench/browser/src/app/shared/components/api-script/api-script.component.ts index ad3e0cc8..49d90f06 100644 --- a/src/workbench/browser/src/app/shared/components/api-script/api-script.component.ts +++ b/src/workbench/browser/src/app/shared/components/api-script/api-script.component.ts @@ -1,7 +1,7 @@ import { SelectionModel } from '@angular/cdk/collections'; import { FlatTreeControl } from '@angular/cdk/tree'; // import { FlatTreeControl } from 'ng-zorro-antd/node_modules/@angular/cdk/tree'; -import { Component, OnInit, ViewChild } from '@angular/core'; +import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'; import { EoEditorComponent } from 'eo/workbench/browser/src/app/eoui/editor/eo-editor/eo-editor.component'; import { NzTreeFlatDataSource, NzTreeFlattener } from 'ng-zorro-antd/tree-view'; @@ -14,8 +14,11 @@ import { TREE_DATA } from './constant'; styleUrls: ['./api-script.component.scss'], }) export class ApiScriptComponent implements OnInit { + @Output() codeChange = new EventEmitter(); @ViewChild(EoEditorComponent, { static: false }) eoEditor?: EoEditorComponent; + private code = ''; + private transformer = (node: TreeNode, level: number): FlatNode => ({ ...node, expandable: !!node.children && node.children.length > 0, @@ -50,7 +53,16 @@ export class ApiScriptComponent implements OnInit { hasChild = (_: number, node: FlatNode): boolean => node.expandable; + handleChange(code) { + this.code = code; + setTimeout(() => { + this.codeChange.emit(code); + }, 0); + } + insertCode = (node: FlatNode) => { this.eoEditor.handleInsert(node.value); }; + + getCode = () => this.code; }