mirror of
https://gitee.com/eolink_admin/postcat.git
synced 2024-12-04 20:58:01 +08:00
feat: add codeChange output event
This commit is contained in:
parent
51f7201004
commit
230982fb61
@ -48,7 +48,8 @@
|
|||||||
</nz-tree-view>
|
</nz-tree-view>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 ">
|
<div class="flex-1 ">
|
||||||
<eo-editor [(code)]="model" editorType="javascript" [eventList]="[ 'format', 'copy', 'search', 'replace']">
|
<eo-editor [(code)]="model" editorType="javascript" [eventList]="[ 'format', 'copy', 'search', 'replace']"
|
||||||
|
(codeChange)="handleChange($event)">
|
||||||
</eo-editor>
|
</eo-editor>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { SelectionModel } from '@angular/cdk/collections';
|
import { SelectionModel } from '@angular/cdk/collections';
|
||||||
import { FlatTreeControl } from '@angular/cdk/tree';
|
import { FlatTreeControl } from '@angular/cdk/tree';
|
||||||
// import { FlatTreeControl } from 'ng-zorro-antd/node_modules/@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 { EoEditorComponent } from 'eo/workbench/browser/src/app/eoui/editor/eo-editor/eo-editor.component';
|
||||||
|
|
||||||
import { NzTreeFlatDataSource, NzTreeFlattener } from 'ng-zorro-antd/tree-view';
|
import { NzTreeFlatDataSource, NzTreeFlattener } from 'ng-zorro-antd/tree-view';
|
||||||
@ -14,8 +14,11 @@ import { TREE_DATA } from './constant';
|
|||||||
styleUrls: ['./api-script.component.scss'],
|
styleUrls: ['./api-script.component.scss'],
|
||||||
})
|
})
|
||||||
export class ApiScriptComponent implements OnInit {
|
export class ApiScriptComponent implements OnInit {
|
||||||
|
@Output() codeChange = new EventEmitter<string>();
|
||||||
@ViewChild(EoEditorComponent, { static: false }) eoEditor?: EoEditorComponent;
|
@ViewChild(EoEditorComponent, { static: false }) eoEditor?: EoEditorComponent;
|
||||||
|
|
||||||
|
private code = '';
|
||||||
|
|
||||||
private transformer = (node: TreeNode, level: number): FlatNode => ({
|
private transformer = (node: TreeNode, level: number): FlatNode => ({
|
||||||
...node,
|
...node,
|
||||||
expandable: !!node.children && node.children.length > 0,
|
expandable: !!node.children && node.children.length > 0,
|
||||||
@ -50,7 +53,16 @@ export class ApiScriptComponent implements OnInit {
|
|||||||
|
|
||||||
hasChild = (_: number, node: FlatNode): boolean => node.expandable;
|
hasChild = (_: number, node: FlatNode): boolean => node.expandable;
|
||||||
|
|
||||||
|
handleChange(code) {
|
||||||
|
this.code = code;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.codeChange.emit(code);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
insertCode = (node: FlatNode) => {
|
insertCode = (node: FlatNode) => {
|
||||||
this.eoEditor.handleInsert(node.value);
|
this.eoEditor.handleInsert(node.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getCode = () => this.code;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user