@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
70 lines (66 loc) • 3.3 kB
TypeScript
import * as i0 from '@angular/core';
import { AfterViewInit, OnDestroy, OnChanges, EventEmitter, ElementRef, NgZone, SimpleChanges } from '@angular/core';
import { ControlValueAccessor, Validator, AbstractControl, ValidationErrors } from '@angular/forms';
import * as Monaco from 'monaco-editor';
import { ThemeOptions, ThemeSwitcherService } from '@c8y/ngx-components';
declare function initializeMonacoEnvironment(): void;
declare function loadMonacoEditor(): Promise<typeof Monaco>;
/**
* Editor component for displaying and editing code
*
* Based on the monaco editor (the same editor as in VS Code)
* Supports syntax highlighting for various languages (default: JSON)
* and can be extended with additional features like JSON schema validation
*/
declare class EditorComponent implements AfterViewInit, OnDestroy, ControlValueAccessor, OnChanges {
private zone;
private themeSwitcher;
/**
* Options to pass to the monaco editor instance
* Allows to e.g. set a different language.
*/
editorOptions: Monaco.editor.IStandaloneEditorConstructionOptions;
/**
* Overrides application theme. If not set, the theme will be taken from the theme switcher service.
*/
theme: ThemeOptions | null;
/**
* Emits the editor instance once it is initialized
* Can be used to e.g. access the monaco instance and add a JSON schema for validation
*/
editorInit: EventEmitter<Monaco.editor.IStandaloneCodeEditor>;
monaco: typeof Monaco;
editor: Monaco.editor.IStandaloneCodeEditor;
private _readOnly;
private _currentValue;
private _onChanges;
private _onTouched;
_editorContainer: ElementRef;
private themeChanges$;
constructor(zone: NgZone, themeSwitcher: ThemeSwitcherService);
writeValue(obj: string | object): void;
registerOnChange(fn: (value: string) => void): void;
registerOnTouched(fn: () => void): void;
setDisabledState(isDisabled: boolean): void;
ngAfterViewInit(): Promise<void>;
ngOnChanges(changes: SimpleChanges): void;
register(): void;
ngOnDestroy(): void;
private setTheme;
private updateOptionsAndLanguage;
static ɵfac: i0.ɵɵFactoryDeclaration<EditorComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<EditorComponent, "c8y-editor", never, { "editorOptions": { "alias": "editorOptions"; "required": false; }; "theme": { "alias": "theme"; "required": false; }; }, { "editorInit": "editorInit"; }, never, never, true, never>;
}
declare class MonacoEditorMarkerValidatorDirective implements Validator, OnDestroy {
private editorComponent;
private zone;
private editorInitSubscription;
constructor(editorComponent: EditorComponent, zone: NgZone);
ngOnDestroy(): void;
validate(_control: AbstractControl<any, any>): ValidationErrors;
registerOnValidatorChange(fn: () => void): void;
static ɵfac: i0.ɵɵFactoryDeclaration<MonacoEditorMarkerValidatorDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MonacoEditorMarkerValidatorDirective, "c8y-editor [monacoEditorMarkerValidator]", never, {}, {}, never, never, true, never>;
}
export { EditorComponent, MonacoEditorMarkerValidatorDirective, initializeMonacoEnvironment, loadMonacoEditor };
//# sourceMappingURL=index.d.ts.map