import { ThemeMode, DialogService, DialogRef } from '@alauda/ui'; import * as i0 from '@angular/core'; import { OnInit, AfterContentChecked, OnDestroy, OnChanges, AfterViewInit, EventEmitter, ElementRef, ChangeDetectorRef, SimpleChanges, Optional, EnvironmentProviders, TemplateRef } from '@angular/core'; import { ControlValueAccessor, UntypedFormControl } from '@angular/forms'; import * as monaco_editor from 'monaco-editor'; import { editor } from 'monaco-editor'; import * as rxjs from 'rxjs'; import { Observable, Subject, BehaviorSubject, Subscription } from 'rxjs'; import { SchemasSettings } from 'monaco-yaml'; /** * Colorize a section of code with Monaco Editor. */ declare class CodeColorizeDirective implements OnInit, AfterContentChecked, OnDestroy { ngCodeColorize: string; ngCodeColorizeOptions?: { theme: string; }; private originalDisplay; private lastContent; private destroyed; private readonly element; private readonly monacoProvider; ngOnInit(): void; ngAfterContentChecked(): void; ngOnDestroy(): void; private doColorize; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare const observeResizeOn: (target: T, options?: ResizeObserverOptions) => Observable; type Monaco = typeof monaco_editor; /** * All common option fields for monaco are merged together for ease of config. */ type MonacoEditorOptions = editor.IStandaloneEditorConstructionOptions; type MonacoEditor = editor.IStandaloneCodeEditor; /** * Configuration over monaco editor. */ declare class MonacoEditorConfig { /** * The base URL to monaco editor library assets via AMD (RequireJS). * * e.g., assets/monaco-editor/min */ baseUrl?: string; /** * Use webpack dynamic import function to load monaco assets. * * e.g., () => import('monaco-editor') */ dynamicImport?: () => Promise; /** * Default options when creating editors */ defaultOptions?: MonacoEditorOptions; /** * The interval for re-layout the editors. Default is 100 (ms). * If set to 0, then the editor will never do auto-relayout. */ autoLayoutInterval?: number; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } interface Require { (deps: string[], callback: (result: T) => void): void; config(options: { baseUrl: string; paths: { [key: string]: string; }; }): void; } /** * Provider for monaco editor. */ declare class MonacoProviderService { private _theme; private _monaco?; private _loadingPromise?; private readonly theme$$; theme$: rxjs.Observable; /** * Returns all available themes */ get themes(): string[]; /** * Return the current theme */ get theme(): string; /** * Expose global monaco object */ get monaco(): typeof monaco_editor; /** * Expose global amd require function/object */ get require(): Require | undefined; private readonly monacoEditorConfig; initMonaco(): Promise; /** * Load additional monaco-editor modules. */ loadModule(deps: string[]): Promise; toggleTheme(): void; changeTheme(theme: string): void; getEditorOptions(options?: MonacoEditorOptions): MonacoEditorOptions; /** * Create a code-editor at the given dom element. */ create(domElement: HTMLElement, options?: MonacoEditorOptions): editor.IStandaloneCodeEditor; createDiffEditor(domElement: HTMLElement, options?: editor.IDiffEditorConstructionOptions): editor.IStandaloneDiffEditor; /** * Colorize an arbitrary element: */ colorizeElement(domElement: HTMLElement, options?: editor.IColorizerElementOptions): Promise; /** * Let the monaco-editor returns language information for the given alias. */ getLanguageExtensionPoint(alias: string): monaco_editor.languages.ILanguageExtensionPoint; /** * Currently monaco-editor is loaded via its own loader and it is RequireJs (amd) spec: */ protected configAmdLoader(baseUrl: string): Promise; private assertMonaco; private loadMonaco; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Wraps powerful Monaco Editor for simplicity use in Angular. */ declare abstract class MonacoCommonEditorComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy, ControlValueAccessor { /** * Raw Monaco editor options */ options: MonacoEditorOptions; /** * The URI which will be assigned to monaco-editor's model. * See monaco.Uri */ modelUri?: string; /** * Events emitted when monaco editor changed. */ editorChange: EventEmitter; /** * Events emitted when monaco editor blurs. */ editorBlur: EventEmitter; /** * A helper ID to let the user to see the embedded monaco editor ID. * * E.g., you could use the following to get the embedded value of the editor. * monaco.editor * .getModels() * .find( * model => * model.id === * document.querySelector('[model-id]').attributes[ * 'model-id' * ].value, * ) * .getValue(); */ modelId: string; protected monacoContainer: ElementRef; protected monacoAnchor: ElementRef; private _rootEditor?; protected get rootEditor(): editor.IStandaloneCodeEditor | editor.IStandaloneDiffEditor; protected set rootEditor(editor: editor.IStandaloneCodeEditor | editor.IStandaloneDiffEditor); protected editor?: MonacoEditor | null; protected model?: editor.ITextModel | null; private _monacoLoaded; get monacoLoaded(): boolean; private _destroyed; get destroyed(): boolean; protected destroy$$: Subject; protected get value(): string; private _value; private _prevOptions?; private _disposables; abstract createEditor(): MonacoEditor; protected monacoEditorConfig: MonacoEditorConfig; protected monacoProvider: MonacoProviderService; protected cdr: ChangeDetectorRef; ngOnInit(): void; ngAfterViewInit(): void; ngOnChanges({ modelUri, options }: SimpleChanges): void; ngOnDestroy(): void; dispose(): void; onChange: (_: string) => void; onTouched: () => void; writeValue(value: string): void; registerOnChange(fn: (value: string) => void): void; registerOnTouched(fn: () => void): void; createModel(value: string, uri?: string): editor.ITextModel; private resetEditor; private listenModelChanges; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Wraps powerful Monaco Editor for simplicity usage in Angular. */ declare class MonacoDiffEditorComponent extends MonacoCommonEditorComponent implements OnChanges, OnDestroy { originalValue: string; protected originalModel: editor.ITextModel; createEditor(): MonacoEditor; ngOnChanges(changes: SimpleChanges): void; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Wraps Monaco Editor for simplicity use in Angular. */ declare class MonacoEditorComponent extends MonacoCommonEditorComponent { createEditor(): MonacoEditor; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare function MonacoProviderFactory(parent: MonacoProviderService): MonacoProviderService; declare const MONACO_PROVIDER: { provide: typeof MonacoProviderService; deps: (typeof MonacoEditorConfig | Optional[])[]; useFactory: typeof MonacoProviderFactory; }; declare function provideMonacoEditor(config?: MonacoEditorConfig): EnvironmentProviders; declare const CODE_EDITOR_DEFAULT_LABELS: { copyLabel: string; copiedLabel: string; readonlyLabel: string; readwriteLabel: string; clearLabel: string; recoverLabel: string; findLabel: string; formatLabel: string; foldLabel: string; exportLabel: string; importLabel: string; lightThemeLabel: string; darkThemeLabel: string; autoThemeLabel: string; showDiffLabel: string; previewLabel: string; fullscreenLabel: string; exitFullscreenLabel: string; }; /** * Texts to render on the code editor. */ declare class CodeEditorIntl { labels$: rxjs.Observable<{ copyLabel: string; copiedLabel: string; readonlyLabel: string; readwriteLabel: string; clearLabel: string; recoverLabel: string; findLabel: string; formatLabel: string; foldLabel: string; exportLabel: string; importLabel: string; lightThemeLabel: string; darkThemeLabel: string; autoThemeLabel: string; showDiffLabel: string; previewLabel: string; fullscreenLabel: string; exitFullscreenLabel: string; }>; getLanguageLabel(lang: string): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare function codeEditorIntlProviderFactory(parentIntl: CodeEditorIntl): CodeEditorIntl; /** @docs-private */ declare const CODE_EDITOR_INTL_INTL_PROVIDER: { provide: typeof CodeEditorIntl; deps: Optional[][]; useFactory: typeof codeEditorIntlProviderFactory; }; declare const CODE_EDITOR_THEME_KEY = "code-editor-theme"; declare const CODE_EDITOR_THEME_MODE_KEY = "code-editor-theme-mode"; /** * Provider for monaco editor. * Do not use `providedIn: 'root'` to avoid forcing the loading of Monaco in projects where the editor is not needed. */ declare class AlaudaMonacoProviderService extends MonacoProviderService { private _inited?; readonly themeMode$$: BehaviorSubject; themeMode$: rxjs.Observable; get themeMode(): ThemeMode; /** * Returns all available themes */ get themes(): string[]; get themeModes(): ThemeMode[]; changeTheme(theme: string): void; initMonaco(): Promise; private initTheme; private defineThemes; changeThemeMode(mode?: ThemeMode, theme?: string): void; getCacheThemeMode(): ThemeMode; setCacheThemeMode(mode: ThemeMode): void; getCacheTheme(): string; setCacheTheme(theme: string): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } interface CodeEditorActionsConfig { diffMode?: boolean; recover?: boolean; clear?: boolean; find?: boolean; copy?: boolean; theme?: boolean; fullscreen?: boolean; export?: boolean; import?: boolean; } /** * Code editor. */ declare class CodeEditorComponent implements ControlValueAccessor, OnDestroy { monacoProvider: AlaudaMonacoProviderService; cdr: ChangeDetectorRef; codeEditorIntl: CodeEditorIntl; dialog: DialogService; private editor?; protected _options: {}; protected _actionsConfig: CodeEditorActionsConfig; protected _originalValue: string; protected _diffMode: boolean; protected _previewMode: boolean; protected _modelUri?: string; protected _editorChange: EventEmitter; protected _controlSubscription: Subscription; protected _valueControl: UntypedFormControl; /** * Raw Monaco editor options */ get options(): editor.IStandaloneEditorConstructionOptions; set options(options: editor.IStandaloneEditorConstructionOptions); plain: boolean; showLanguageLabel: boolean; /** * Value input. Optionally, you could access the model via ControlValueAccessor * like ngModel. */ set value(value: string); get value(): string; /** * The original value to recover */ get originalValue(): string; set originalValue(originalValue: string); /** * Configure action buttons display. All actions are enabled by default. */ get actionsConfig(): CodeEditorActionsConfig; set actionsConfig(actionsConfig: CodeEditorActionsConfig); /** * Should show as diff mode or not */ get previewMode(): boolean; set previewMode(previewMode: boolean); get showPreview(): boolean; /** * Should show as diff mode or not */ get diffMode(): boolean; set diffMode(diffMode: boolean); /** * The URI which will be assigned to monaco-editor's model. */ get modelUri(): string; set modelUri(modelUri: string); /** * The FormControl object is shared between this form and its source. */ get valueControl(): UntypedFormControl; /** * Events emitted when monaco editor changed. * User may want to use this to have advanced tunings on the editor. */ get editorChange(): EventEmitter; editorBlur: EventEmitter; /** * The fullscreen dialog. */ fullscreenDialog?: DialogRef; fileUploadInputElementRef: ElementRef; viewTemplateRef: TemplateRef; get langId(): string; get markdownDisplay(): any; constructor(); onMonacoEditorChanged(editor: MonacoEditor): void; onClearClicked(): void; onExportClicked(): void; onImportFileChanged(_event: Event): void; onRecoverClicked(): void; onFindClicked(): Promise; canFullscreen(): boolean; onFoldAllClicked(): Promise; getLanguageExtensions(): string[]; getInputFileAccepts(): string; private checkActionAndRun; private getEditorAction; onCopyClicked(): void; onCvaChange: (_: string) => void; onCvaTouched: () => void; onTouched(): void; writeValue(value: string): void; registerOnChange(fn: (val: string) => void): void; registerOnTouched(fn: () => void): void; toggleFullscreen(): void; ngOnDestroy(): void; /** * Handles user input events: */ private onValueChange; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare function provideCodeEditor(config?: MonacoEditorConfig): EnvironmentProviders; declare class MonacoLanguageService { private yamlSchemaService?; private readonly loader; getYamlSchemaService(): YamlSchemaService; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class YamlSchemaService { private loader; private options; private controller?; constructor(loader: MonacoProviderService); addSchema(schema: SchemasSettings, strategy?: 'merge' | 'replace'): Promise; deleteSchema(uri: string): Promise; private ensureConfigured; } interface ThemeConfig { icon: string; themeMode: ThemeMode; label: Observable; } declare class CodeEditorThemeLabelComponent { [x: string]: any; monacoProvider: AlaudaMonacoProviderService; codeEditorIntl: CodeEditorIntl; themes: ThemeConfig[]; get themeConfig(): ThemeConfig; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * @packageDocumentation * @module code */ type IEditorConstructionOptions = editor.IEditorConstructionOptions & { language?: string; tabSize?: number; }; declare const createActions: CodeEditorActionsConfig; declare const viewActions: CodeEditorActionsConfig; declare const updateActions: CodeEditorActionsConfig; declare const logsActions: CodeEditorActionsConfig; declare const commonOptions: IEditorConstructionOptions; declare const readonlyOptions: IEditorConstructionOptions; declare const yamlReadOptions: IEditorConstructionOptions; declare const yamlWriteOptions: IEditorConstructionOptions; declare const textWriteOptions: IEditorConstructionOptions; declare const yamlWriteMinimapOptions: IEditorConstructionOptions; declare const yamlReadMinimapOptions: IEditorConstructionOptions; export { AlaudaMonacoProviderService, CODE_EDITOR_DEFAULT_LABELS, CODE_EDITOR_INTL_INTL_PROVIDER, CODE_EDITOR_THEME_KEY, CODE_EDITOR_THEME_MODE_KEY, CodeColorizeDirective, CodeEditorComponent, CodeEditorIntl, CodeEditorThemeLabelComponent, MONACO_PROVIDER, MonacoCommonEditorComponent, MonacoDiffEditorComponent, MonacoEditorComponent, MonacoEditorConfig, MonacoLanguageService, MonacoProviderFactory, MonacoProviderService, YamlSchemaService, codeEditorIntlProviderFactory, commonOptions, createActions, logsActions, observeResizeOn, provideCodeEditor, provideMonacoEditor, readonlyOptions, textWriteOptions, updateActions, viewActions, yamlReadMinimapOptions, yamlReadOptions, yamlWriteMinimapOptions, yamlWriteOptions }; export type { CodeEditorActionsConfig, IEditorConstructionOptions, Monaco, MonacoEditor, MonacoEditorOptions, Require, ThemeConfig };