diff --git a/jsoneditoronline/jsoneditoronline-tests.ts b/jsoneditoronline/jsoneditoronline-tests.ts index ea97d9f44..37cf0d2ca 100644 --- a/jsoneditoronline/jsoneditoronline-tests.ts +++ b/jsoneditoronline/jsoneditoronline-tests.ts @@ -1,11 +1,13 @@ // Tests for JSONEditorOnline type definitions /// +var container: HTMLElement; + var options:JSONEditorOptions = { "search": true }; var editor:JSONEditor = new JSONEditor(container, options); -var json:JSON = { +var json = { "Array": [1, 2, 3], "Boolean": true, "Null": null, @@ -16,13 +18,13 @@ var json:JSON = { editor.set(json); editor.expandAll(); -var jsonResult:JSON = editor.get(json); +var jsonResult:JSON = editor.get(); -var options2: JSONformatterOptions = { +var options2: JSONFormatterOptions = { "indentation": 2 }; -var formatter:JSONFormatter = new JSONFormatter(container, options); -var json2:JSON = { +var formatter: JSONFormatter = new JSONFormatter(container, options); +var json2 = { "Array": [1, 2, 3], "Boolean": true, "Null": null, diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts index 0a69fd0f8..9bbb71440 100644 --- a/jsoneditoronline/jsoneditoronline.d.ts +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -9,17 +9,66 @@ interface JSONEditorOptions { history?: bool; mode?: string; name?: string; - search?: bool; + search?: bool; } -interface JSONEditor { - (container:HTMLElement, options?: JSONEditorOptions, json?: JSON): JSONEditor; - set(json: JSON, name?: string): void; +class JSONEditorHistory { + constructor(editor: JSONEditor); + onChange(): void; + add(action: string, params: Object); + clear(): void; + canUndo(): bool; + canRedo(): bool; + undo(): void; + redo(): void; +} + +class JSONEditorNode { + constructor(editor: JSONEditor, params: Object); + setParent(parent: JSONEditorNode): void; + getParent(): JSONEditorNode; + setField(field: string, fieldEditable: bool): void; + getField(): string; + setValue(value: any): void; + getValue(): any; + getLevel(): number; + clone(): JSONEditorNode; + expand(recurse: bool): void; + collapse(recurse: bool): 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): bool; + removeChild(node: JSONEditorNode): JSONEditorNode; + changeType(newType: string): void; + clearDom(): void; + getDom(): HTMLElement; + setHighlight(highlight: bool): void; + updateValue(value: any): void; +} + +class JSONEditor { + constructor(container: HTMLElement, options?: JSONEditorOptions, json?: Object); + set(json: Object, name?: string): void; setName(name?: string): void; - get(): JSON; + get(): Object; getName(): string; + clear(): void; + search(text: string): any[]; expandAll(): void; collapseAll(): void; + onAction(action: string, params: Object); + focus(): void; + scrollTo(top: number): void; + History: JSONEditorHistory; } interface JSONFormatterOptions { @@ -27,9 +76,9 @@ interface JSONFormatterOptions { indentation?: number; } -interface JSONFormatter { - (container:HTMLElement, options?: JSONFormatterOptions, json?: JSON): JSONEditor; - (container:HTMLElement, options?: JSONFormatterOptions, json?: string): JSONEditor; +class JSONFormatter { + constructor(container: HTMLElement, options?: JSONFormatterOptions, json?: Object); + constructor(container: HTMLElement, options?: JSONFormatterOptions, json?: string); set(json: JSON); get(): JSON; setText(jsonString: string);