@vanza007/ang-jsoneditor
Version:
fork https://github.com/mariohmol/ang-jsoneditor
192 lines (188 loc) • 6.04 kB
TypeScript
import * as i0 from '@angular/core';
import { OnInit, OnDestroy, ElementRef, EventEmitter } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
type JsonEditorMode = 'tree' | 'view' | 'form' | 'code' | 'text';
interface JsonEditorTreeNode {
field: String;
value: String;
path: String[];
}
interface IError {
path: (string | number)[];
message: string;
}
declare class JsonEditorOptions {
ace: any;
ajv: Object;
/**
* {function} onChange Callback method, triggered
on change of contents.
Does not pass the contents itself.
See also `onChangeJSON` and
`onChangeText`.
*/
onChange: () => void;
/**
* // {function} onChangeJSON Callback method, triggered
// in modes on change of contents,
// passing the changed contents
// as JSON.
// Only applicable for modes
// 'tree', 'view', and 'form'.
*/
onChangeJSON?: () => void;
onNodeName: () => void;
onCreateMenu: (items: Array<any>, node: object) => Array<any>;
onColorPicker: () => void;
/**
// {function} onChangeText Callback method, triggered
// in modes on change of contents,
// passing the changed contents
// as stringified JSON.
*/
onChangeText: (jsonstr: string) => void;
/**
* {function} onSelectionChange Callback method,
triggered on node selection change
Only applicable for modes
'tree', 'view', and 'form'
*/
onSelectionChange: () => void;
/**
* {function} onTextSelectionChange Callback method,
triggered on text selection change
Only applicable for modes
*/
onTextSelectionChange: () => void;
/**
* // {function} onEvent Callback method, triggered
// when an event occurs in
// a JSON field or value.
// Only applicable for
// modes 'form', 'tree' and
// 'view'
*/
onEvent: () => void;
/**
* // * {function} onFocus Callback method, triggered
// when the editor comes into focus,
// passing an object {type, target},
// Applicable for all modes
*/
onFocus: () => void;
onBlur: () => void;
/**
* // * {function} onClassName Callback method, triggered
// when a Node DOM is rendered. Function returns
// a css class name to be set on a node.
// Only applicable for
// modes 'form', 'tree' and
// 'view'
*/
onClassName: (node: JsonEditorTreeNode) => void;
onEditable: (node: JsonEditorTreeNode | {}) => boolean | {
field: boolean;
value: boolean;
};
/**
* {function} onError Callback method, triggered
when an error occurs
*/
onError: (error: any) => void;
onModeChange: (newMode: JsonEditorMode, oldMode: JsonEditorMode) => void;
onValidate: (json: Object) => IError[];
onValidationError: (errors: object[]) => void;
enableSort: boolean;
enableTransform: boolean;
escapeUnicode: boolean;
expandAll?: boolean;
sortObjectKeys: boolean;
history: boolean;
mode: JsonEditorMode;
modes: JsonEditorMode[];
name: String;
schema: Object;
search: boolean;
indentation: Number;
templates: Object;
theme: Number;
language: String;
languages: Object;
limitDragging: boolean;
/**
* Adds main menu bar - Contains format, sort, transform, search etc. functionality. True
* by default. Applicable in all types of mode.
*/
mainMenuBar: boolean;
/**
* Adds navigation bar to the menu - the navigation bar visualize the current position on
* the tree structure as well as allows breadcrumbs navigation.
* True by default.
* Only applicable when mode is 'tree', 'form' or 'view'.
*/
navigationBar: boolean;
/**
* Adds status bar to the bottom of the editor - the status bar shows the cursor position
* and a count of the selected characters.
* True by default.
* Only applicable when mode is 'code' or 'text'.
*/
statusBar: boolean;
constructor();
}
declare class JsonEditorComponent implements ControlValueAccessor, OnInit, OnDestroy {
jsonEditorContainer: ElementRef;
options: JsonEditorOptions;
change: EventEmitter<any>;
jsonChange: EventEmitter<any>;
debug: boolean;
optionsChanged: boolean;
disabled: boolean;
isFocused: boolean;
id: string;
private _data;
private editor;
constructor();
set data(value: Object);
ngOnInit(): void;
ngOnDestroy(): void;
/**
* ngModel
* ControlValueAccessor
*/
writeValue(value: any): void;
registerOnChange(fn: any): void;
registerOnTouched(fn: any): void;
setDisabledState(isDisabled: boolean): void;
onChange: () => void;
onChangeJSON: () => void;
/**
* JSON EDITOR FUNCTIONS
*/
collapseAll(): void;
expandAll(): void;
focus(): void;
get(): JSON;
getMode(): JsonEditorMode;
getName(): string;
getText(): string;
set(json: JSON): void;
setMode(mode: JsonEditorMode): void;
setName(name: string): void;
setSelection(start: any, end: any): void;
getSelection(): any;
getValidateSchema(): any;
setSchema(schema: any, schemaRefs: any): void;
search(query: string): void;
setOptions(newOptions: JsonEditorOptions): void;
update(json: JSON): void;
destroy(): void;
getEditor(): any;
isValidJson(): boolean;
private onTouched;
private onChangeModel;
static ɵfac: i0.ɵɵFactoryDeclaration<JsonEditorComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<JsonEditorComponent, "json-editor", never, { "options": { "alias": "options"; "required": false; }; "debug": { "alias": "debug"; "required": false; }; "data": { "alias": "data"; "required": false; }; }, { "change": "change"; "jsonChange": "jsonChange"; }, never, never, true, never>;
}
export { JsonEditorComponent, JsonEditorOptions };
export type { IError, JsonEditorMode, JsonEditorTreeNode };