@kephas/angular-ace
Version:
Provides the integration of the Ace editor with Kephas and Angular.
195 lines (194 loc) • 5.93 kB
TypeScript
import { ValueEditorBase } from '@kephas/angular';
import { ViewContainerRef, ElementRef, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import { Editor } from 'brace';
import 'brace/theme/monokai';
import 'brace/mode/abap';
import 'brace/mode/lua';
import 'brace/mode/sh';
import 'brace/mode/sql';
import 'brace/mode/powershell';
import 'brace/mode/text';
import 'brace/mode/json';
/**
* Value editor based on Ace.
*
* @export
* @class AceComponent
* @extends {(ValueEditorBase<string | {} | null>)}
*/
export declare class AceComponent extends ValueEditorBase<string | {} | null> implements OnInit, AfterViewInit, OnDestroy {
/**
* Gets or sets the Ace editor.
*
* @type {ace.Editor}
* @memberof AceComponent
*/
editor?: Editor;
private _theme;
private _editorType;
private _valueIsObject;
private _observer?;
/**
* Creates an instance of AceComponent.
*
* @param {ElementRef} elementRef The element reference.
* @param {ViewContainerRef} viewContainerRef The view container reference.
* @memberof AceComponent
*/
constructor(elementRef: ElementRef, viewContainerRef: ViewContainerRef);
/**
* Gets or sets a value indicating
*
* @type {(string | string[])}
* @memberof AceComponent
*/
observeVisibilityOf?: string | string[];
/**
* Gets or sets the editor type.
*
* @type {string}
* @memberof AceComponent
*/
get editorType(): string;
set editorType(value: string);
/**
* Gets or sets the editor options.
*
* @memberof AceComponent
*/
set options(value: any);
get options(): any;
/**
* Gets or sets the editor theme.
*
* @type {string}
* @memberof AceComponent
*/
get theme(): string;
set theme(value: string);
/**
* Gets or sets a value indicating whether the bound value is an object or not.
*
* @readonly
* @type {boolean}
* @memberof AceComponent
*/
get valueIsObject(): boolean;
set valueIsObject(value: boolean);
/**
* A callback method that is invoked immediately after the
* default change detector has checked the directive's
* data-bound properties for the first time,
* and before any of the view or content children have been checked.
* It is invoked only once when the directive is instantiated.
*
* @memberof AceComponent
*/
ngOnInit(): void;
/**
* A callback method that is invoked immediately after
* Angular has completed initialization of a component's view.
* It is invoked only once when the view is instantiated.
*
* @memberof AceComponent
*/
ngAfterViewInit(): void;
/**
* A callback method that performs custom clean-up, invoked immediately
* after a directive, pipe, or service instance is destroyed.
*
* @memberof AceComponent
*/
ngOnDestroy(): void;
/**
* Observes the visibility of the elements in the query string,
* and if they are visible, it will trigger an editor resize.
* This is required to fix a problem in the ACE editor when
* setValue doesn't work if the editor is hidden.
*
* See also https://github.com/ajaxorg/ace/issues/3070.
* See also https://github.com/Starcounter/Content/commit/91a757d8750523431fc1637fdf57409d0fcb13db.
*
* @param {string} queryString
* @memberof ScriptEditorComponent
*/
protected observeVisibility(queryStrings: string | string[]): void;
/**
* Formats the JSON document inside the editor.
*
* @protected
* @returns
* @memberof AceComponent
*/
protected formatDocument(): void;
/**
* Sets the value of the underlying editor.
*
* @protected
* @param {string | {} | null} value
* @memberof ValueEditorBase
*/
protected setEditorValue(value: string | {} | null): void;
/**
* Gets the underlying editor's value.
*
* @protected
* @returns {string | {} | null} The widget value.
* @memberof ValueEditorBase
*/
protected getEditorValue(): string | {} | null;
/**
* When overridden in a derived class, this method is called when the read only state changes.
*
* @protected
* @param {boolean} oldValue The old value.
* @param {boolean} newValue The new value.
*
* @memberof EditorBase
*/
protected onReadOnlyChanged(oldValue: boolean, newValue: boolean): void;
/**
* Sets the readonly state of the editor.
*
* @protected
* @param {boolean} value
* @memberof AceComponent
*/
protected setEditorReadOnly(value: boolean): void;
/**
* Sets the editor theme.
*
* @protected
* @param {string} theme
* @memberof AceComponent
*/
protected setEditorTheme(theme: string): void;
/**
* Sets the editor type.
*
* @protected
* @param {string} editorType
* @memberof AceComponent
*/
protected setEditorType(editorType: string): void;
/**
* Gets the editor mode based on the provided editor type.
*
* @protected
* @param {string} editorType The editor type.
* @returns {string}
* @memberof AceComponent
*/
protected getEditorMode(editorType: string): string;
/**
* Updates the underlying editor with the provided value.
*
* @protected
* @param {TValue} value The value to be set in the underlying component.
* @returns {boolean}
* @memberof AceComponent
*/
protected updateEditor(value: string): boolean;
private _getFormattedJson;
private _isAceVisible;
}