@fsegurai/ngx-codemirror
Version:
Angular library that uses codemirror to create a code editor
121 lines (120 loc) • 6.59 kB
TypeScript
import { OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
import { LanguageDescription } from '@codemirror/language';
import { Extension } from '@codemirror/state';
import * as i0 from "@angular/core";
export type Theme = 'light' | Extension;
export type Setup = 'basic' | 'minimal' | null;
export declare const External: import("@codemirror/state").AnnotationType<boolean>;
export declare class CodeEditorComponent implements OnChanges, OnInit, OnDestroy, ControlValueAccessor {
private _elementRef;
/**
* EditorView's [root](https://codemirror.net/docs/ref/#view.EditorView.root).
*
* Don't support change dynamically!
*/
readonly root: import("@angular/core").InputSignal<Document | ShadowRoot | undefined>;
/**
* Whether focus on the editor after init.
*
* Don't support change dynamically!
*/
readonly autoFocus: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
/** The editor's value. */
readonly value: import("@angular/core").InputSignal<string>;
/** Whether the editor is disabled. */
disabled: boolean;
/** Whether the editor is readonly. */
readonly readonly: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
/** The editor's theme. */
readonly theme: import("@angular/core").InputSignal<Theme>;
/** The editor's placeholder. */
readonly placeholder: import("@angular/core").InputSignal<string>;
/** Whether indent with Tab key. */
readonly indentWithTab: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
/** Should be a string consisting either entirely of the same whitespace character. */
readonly indentUnit: import("@angular/core").InputSignal<number>;
/** Whether the editor wraps lines. */
readonly lineWrapping: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
/** Whether highlight the whitespace. */
readonly highlightWhitespace: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
/**
* An array of language descriptions for known
* [language-data](https://github.com/codemirror/language-data/blob/main/src/language-data.ts).
*
* Don't support change dynamically!
*/
readonly languages: import("@angular/core").InputSignal<LanguageDescription[]>;
/** The editor's language. You should set the `languages` prop at first. */
readonly language: import("@angular/core").InputSignal<string>;
/**
* The editor's built-in setup. The value can be set to
* [`basic`](https://codemirror.net/docs/ref/#codemirror.basicSetup),
* [`minimal`](https://codemirror.net/docs/ref/#codemirror.minimalSetup) or `null`.
*/
readonly setup: import("@angular/core").InputSignal<Setup>;
/**
* It will be appended to the root
* [extensions](https://codemirror.net/docs/ref/#state.EditorStateConfig.extensions).
*/
readonly extensions: import("@angular/core").InputSignal<Extension[]>;
/** Event emitted when the editor's value changes. */
readonly change: import("@angular/core").OutputEmitterRef<string>;
/** Event emitted when focus on the editor. */
readonly focus: import("@angular/core").OutputEmitterRef<void>;
/** Event emitted when the editor has lost focus. */
readonly blur: import("@angular/core").OutputEmitterRef<void>;
private _onChange;
private _onTouched;
/**
* The instance of [EditorView](https://codemirror.net/docs/ref/#view.EditorView).
*/
private view?;
private _updateListener;
private _editableConf;
private _readonlyConf;
private _themeConf;
private _placeholderConf;
private _indentWithTabConf;
private _indentUnitConf;
private _lineWrappingConf;
private _highlightWhitespaceConf;
private _languageConf;
private _getAllExtensions;
ngOnChanges(changes: SimpleChanges): void;
ngOnInit(): void;
ngOnDestroy(): void;
writeValue(value: string): void;
registerOnChange(fn: (value: string) => void): void;
registerOnTouched(fn: () => void): void;
setDisabledState(isDisabled: boolean): void;
/** Sets editor's value. */
private setValue;
/** Sets editor's editable state. */
private setEditable;
/** Sets editor's readonly state. */
private setReadonly;
/** Sets editor's theme. */
private setTheme;
/** Sets editor's placeholder. */
private setPlaceholder;
/** Sets editor' indentWithTab. */
private setIndentWithTab;
/** Sets editor's indentUnit. */
private setIndentUnit;
/** Sets editor's lineWrapping. */
private setLineWrapping;
/** Sets editor's highlightWhitespace. */
private setHighlightWhitespace;
/** Sets the root extensions of the editor. */
private setExtensions;
/** Sets editor's language dynamically. */
private setLanguage;
/** Find the language's extension by its name. Case-insensitive. */
private _findLanguage;
private _dispatchEffects;
private addEventListeners;
static ɵfac: i0.ɵɵFactoryDeclaration<CodeEditorComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<CodeEditorComponent, "ngx-code-editor, code-editor, [code-editor]", never, { "root": { "alias": "root"; "required": false; "isSignal": true; }; "autoFocus": { "alias": "autoFocus"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "indentWithTab": { "alias": "indentWithTab"; "required": false; "isSignal": true; }; "indentUnit": { "alias": "indentUnit"; "required": false; "isSignal": true; }; "lineWrapping": { "alias": "lineWrapping"; "required": false; "isSignal": true; }; "highlightWhitespace": { "alias": "highlightWhitespace"; "required": false; "isSignal": true; }; "languages": { "alias": "languages"; "required": false; "isSignal": true; }; "language": { "alias": "language"; "required": false; "isSignal": true; }; "setup": { "alias": "setup"; "required": false; "isSignal": true; }; "extensions": { "alias": "extensions"; "required": false; "isSignal": true; }; }, { "change": "change"; "focus": "focus"; "blur": "blur"; }, never, never, true, never>;
static ngAcceptInputType_disabled: unknown;
}