///
import * as _angular_core from '@angular/core';
import { InjectionToken, EnvironmentProviders, OnDestroy, ElementRef, DestroyRef } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
import { Subscription } from 'rxjs';
interface NuMonacoEditorModel {
value?: string;
language?: string;
uri?: monaco.Uri;
}
interface NuMonacoEditorDiffModel {
code: string;
language?: string;
}
type NuMonacoEditorEventType = 'load-error' | 'init' | 're-init' | 'resize' | 'update-diff' | 'error';
interface NuMonacoEditorEvent {
type?: NuMonacoEditorEventType;
editor?: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor;
error?: string;
/** Just only `nu-monaco-editor-diff` component */
diffValue?: string;
}
declare const NU_MONACO_EDITOR_CONFIG: InjectionToken;
declare function provideNuMonacoEditorConfig(config?: NuMonacoEditorConfig): EnvironmentProviders;
interface NuMonacoEditorConfig {
/**
* The base URL to monaco editor library assets via AMD (RequireJS), Default: `https://cdn.jsdelivr.net/npm/monaco-editor/min`
* You can using local path, e.g.: `assets/monaco-editor/min`.
*/
baseUrl?: string;
/**
* Default options when creating editors
*/
defaultOptions?: monaco.editor.IStandaloneEditorConstructionOptions;
/**
* The event after the first loading of the monaco editor library is completed, use this function to extend monaco editor functionalities.
* - @param `_monaco` equar to `window.monaco`
*/
monacoLoad?: (_monaco: any) => void;
/**
* The event before the first preload of the monaco editor library is completed, use this function to set nls availableLanguages.
*/
monacoPreLoad?: () => void;
/**
* Trigger automatic format delay time, default: `100`
*/
autoFormatTime?: number;
}
declare abstract class NuMonacoEditorBase implements OnDestroy {
protected el: ElementRef;
protected config: NuMonacoEditorConfig | null;
protected doc: Document;
protected destroy$: DestroyRef;
protected _editor?: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor;
protected _resize$: Subscription | null;
protected _config: NuMonacoEditorConfig;
protected _disabled?: boolean;
protected readonly _disposables: monaco.IDisposable[];
readonly height: _angular_core.InputSignal;
readonly delay: _angular_core.InputSignalWithTransform;
readonly disabled: _angular_core.InputSignalWithTransform;
readonly options: _angular_core.InputSignal;
readonly event: _angular_core.OutputEmitterRef;
constructor();
protected abstract initMonaco(_options: monaco.editor.IStandaloneEditorConstructionOptions | undefined, _initEvent: boolean): void;
protected notifyEvent(type: NuMonacoEditorEventType, other?: NuMonacoEditorEvent): void;
protected setDisabled(v: boolean): this;
private init;
protected cleanResize(): this;
protected registerResize(): this;
protected disposeEditor(): this;
updateOptions(v: monaco.editor.IStandaloneEditorConstructionOptions | undefined): void;
ngOnDestroy(): void;
static ɵfac: _angular_core.ɵɵFactoryDeclaration;
static ɵcmp: _angular_core.ɵɵComponentDeclaration;
}
declare class NuMonacoEditorComponent extends NuMonacoEditorBase implements ControlValueAccessor {
private _value;
private _placeholderWidget?;
readonly placeholder: _angular_core.InputSignal;
readonly model: _angular_core.InputSignal;
readonly autoFormat: _angular_core.InputSignalWithTransform;
readonly maxHeight: _angular_core.InputSignalWithTransform;
readonly minHeight: _angular_core.InputSignalWithTransform;
get editor(): monaco.editor.IStandaloneCodeEditor | null | undefined;
constructor();
private togglePlaceholder;
private onChange;
private onTouched;
initMonaco(options: monaco.editor.IStandaloneEditorConstructionOptions, initEvent: boolean): void;
private updateHeight;
format(): Promise | undefined;
writeValue(value: string): void;
registerOnChange(fn: (_: string) => void): void;
registerOnTouched(fn: () => void): void;
setDisabledState(v: boolean): void;
static ɵfac: _angular_core.ɵɵFactoryDeclaration;
static ɵcmp: _angular_core.ɵɵComponentDeclaration;
}
declare class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {
readonly old: _angular_core.InputSignal;
readonly new: _angular_core.InputSignal;
get editor(): monaco.editor.IStandaloneDiffEditor | null | undefined;
initMonaco(options: monaco.editor.IStandaloneEditorConstructionOptions, initEvent: boolean): void;
static ɵfac: _angular_core.ɵɵFactoryDeclaration;
static ɵcmp: _angular_core.ɵɵComponentDeclaration;
}
export { NU_MONACO_EDITOR_CONFIG, NuMonacoEditorComponent, NuMonacoEditorDiffComponent, provideNuMonacoEditorConfig };
export type { NuMonacoEditorConfig, NuMonacoEditorDiffModel, NuMonacoEditorEvent, NuMonacoEditorEventType, NuMonacoEditorModel };