From 6ded0d2fe6e97a230d70e6be46c0ab6fe8d5095c Mon Sep 17 00:00:00 2001 From: Bello Babakolo Date: Mon, 23 Sep 2024 09:16:59 +0100 Subject: [PATCH] refactor: hide 'editor' implementation details for json-editor component --- .../order/src/lib/components/order-edit.component.ts | 2 +- .../organisms/json-editor/json-editor.component.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/modules/order/src/lib/components/order-edit.component.ts b/packages/modules/order/src/lib/components/order-edit.component.ts index 5365c2f5..c46fd7d2 100644 --- a/packages/modules/order/src/lib/components/order-edit.component.ts +++ b/packages/modules/order/src/lib/components/order-edit.component.ts @@ -122,7 +122,7 @@ export class OrderEditComponent { this.update({ items: [ { - ...JSON.parse(this.jsonEditor.editor.getValue()), + ...JSON.parse(this.jsonEditor.getValue()), }, ], mode: ModeType.Update, diff --git a/packages/modules/ui/src/lib/components/organisms/json-editor/json-editor.component.ts b/packages/modules/ui/src/lib/components/organisms/json-editor/json-editor.component.ts index 3aa8a596..f2b3b0e6 100644 --- a/packages/modules/ui/src/lib/components/organisms/json-editor/json-editor.component.ts +++ b/packages/modules/ui/src/lib/components/organisms/json-editor/json-editor.component.ts @@ -7,7 +7,6 @@ import { OnDestroy, } from '@angular/core'; import ace from 'ace-builds'; -// TODO use minified. import 'ace-builds/src-noconflict/mode-json'; import 'ace-builds/src-noconflict/theme-github_light_default'; @@ -18,13 +17,16 @@ import 'ace-builds/src-noconflict/theme-github_light_default'; export class JSONEditorComponent implements AfterViewInit, OnDestroy { @HostBinding('class') classNames = 'col w-100p'; - editor!: ace.Ace.Editor; - // TODO Make this private and provide an external data accessor value + private editor!: ace.Ace.Editor; @Input() value = ''; constructor(private elRef: ElementRef) {} + getValue() { + return this.editor.getValue(); + } + ngAfterViewInit(): void { const containerElement: HTMLDivElement = this.elRef.nativeElement.querySelector('div#container');