forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsoneditoronline.d.ts
181 lines (165 loc) · 5.29 KB
/
jsoneditoronline.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Type definitions for JSONEditorOnline
// Project: https://github.com/josdejong/jsoneditoronline
// Definitions by: Vincent Bortone <https://github.com/vbortone/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// JSON Editor Online is a tool to easily edit and format JSON online. JSON is displayed in a clear, editable treeview and in formatted plain text.
interface JSONEditorOptions {
change?: () => void;
history?: boolean;
mode?: string;
name?: string;
search?: boolean;
}
declare class JSONEditorHistory {
constructor(editor: JSONEditor);
onChange(): void;
add(action: string, params: Object);
clear(): void;
canUndo(): boolean;
canRedo(): boolean;
undo(): void;
redo(): void;
}
interface JSONEditorNodeUpdateDomOptions {
recurse?: boolean;
updateIndexes?: boolean;
}
interface JSONEditorNodeType {
value: string;
className: string;
title: string;
}
interface JSONEditorConstructorParams {
field?: string;
fieldEditable?: boolean;
value?: any;
}
declare class JSONEditorNode {
constructor(editor: JSONEditor, params: JSONEditorConstructorParams);
setParent(parent: JSONEditorNode): void;
getParent(): JSONEditorNode;
setField(field: string, fieldEditable: boolean): void;
getField(): string;
setValue(value: any): void;
getValue(): any;
getLevel(): number;
clone(): JSONEditorNode;
expand(recurse: boolean): void;
collapse(recurse: boolean): void;
showChilds(): void;
hide(): void;
hideChilds(): void;
appendChild(node: JSONEditorNode): void;
moveBefore(node: JSONEditorNode, beforeNode: JSONEditorNode): void;
moveTo(node: JSONEditorNode, index: number): void;
insertBefore(node: JSONEditorNode, beforeNode: JSONEditorNode): void;
search(text: string): JSONEditorNode[];
scrollTo(): void;
focus(): void;
blur(): void;
containsNode(node: JSONEditorNode): boolean;
removeChild(node: JSONEditorNode): JSONEditorNode;
changeType(newType: string): void;
clearDom(): void;
getDom(): HTMLElement;
setHighlight(highlight: boolean): void;
updateValue(value: any): void;
updateField(field: string): void;
updateDom(options): void;
onEvent(event: Event): void;
types: JSONEditorNodeType[];
getAppend(): HTMLElement;
}
declare class JSONEditorAppendNode extends JSONEditorNode {
constructor(editor: JSONEditor);
}
interface JSONEditorShowDropDownListParams {
x: number;
y: number;
node: JSONEditorNode;
value: string;
values: Object[];
optionSelectedClassName: string;
optionClassName: string;
callback: (value: any) => void;
}
declare class JSONEditorSearchBox {
constructor(editor: JSONEditor, container: HTMLElement);
next(): void;
previous(): void;
setActiveResult(index: number): void;
focusActiveResult(): void;
clearDelay(): void;
onDelayedSearch(event: Event): void;
onSearch(event: Event, forcedSearch: boolean): void;
onKeyDown(event: Event): void;
onKeyUp(event: Event): void;
}
interface JSONEditorBuffer {
text: string;
flush(): string;
set(text: string): void;
}
interface JSONEditorActionParams {
node?: JSONEditorNode;
oldValue?: string;
newValue?: string;
startParent?: JSONEditorNode;
endParent?: JSONEditorNode;
startIndex?: number;
endIndex?: number;
clone?: JSONEditorNode;
parent?: JSONEditorNode;
index?: number;
oldType?: JSONEditorNodeType;
newType?: JSONEditorNodeType;
}
declare class JSONEditor {
constructor(container: HTMLElement, options?: JSONEditorOptions, json?: any);
set(json: Object, name?: string): void;
setName(name?: string): void;
get(): Object;
getName(): string;
clear(): void;
search(text: string): any[];
expandAll(): void;
collapseAll(): void;
onAction(action: string, params: JSONEditorActionParams);
focus(): void;
scrollTo(top: number): void;
History: JSONEditorHistory;
Node: JSONEditorNode;
SearchBox: JSONEditorSearchBox;
static focusNode: JSONEditorNode;
static freezeHighlight: boolean;
static showDropDownList(params): void;
static getNodeFromTarget(target: HTMLElement): JSONEditorNode;
static getAbsoluteLeft(elem: HTMLElement): number;
static getAbsoluteTop(elem: HTMLElement); number;
static addClassName(elem: HTMLElement, className: string): void;
static removeClassName(elem: HTMLElement, className: string): void;
static stripFormatting(divElement: HTMLElement): void;
static setEndOfContentEditable(contentEditableElement: HTMLElement): void;
static getInnerText(element: HTMLElement, buffer: JSONEditorBuffer): string;
static getInternetExplorerVersion(): number;
Events: {
addEventListener(element: HTMLElement, action: string, listener:(event?: Event) => void, useCapture:boolean): (event?: Event) => void;
removeEventListener(element: HTMLElement, action: string, listener:(event?: Event) => void, useCapture:boolean): void;
stopPropagation(event: Event): void;
preventDefault(event:Event): void;
};
static parse(jsonString: string): Object;
static validate(jsonString: string): string;
}
interface JSONFormatterOptions {
change?: () => void;
indentation?: number;
}
declare class JSONFormatter {
constructor(container: HTMLElement, options?: JSONFormatterOptions, json?: any);
set(json: Object);
get(): Object;
setText(jsonString: string): void;
getText(): string;
onError(err: string): void;
}