From 79ae0efebf40a2d02d5954ad8eca51bd4a7412d3 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Mon, 28 Jan 2013 01:55:24 -0500 Subject: [PATCH] Finish initial creation --- jsoneditoronline/jsoneditoronline-tests.ts | 4 +- jsoneditoronline/jsoneditoronline.d.ts | 55 +++++++++++++++++++--- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/jsoneditoronline/jsoneditoronline-tests.ts b/jsoneditoronline/jsoneditoronline-tests.ts index 37cf0d2ca..a5afd2c6c 100644 --- a/jsoneditoronline/jsoneditoronline-tests.ts +++ b/jsoneditoronline/jsoneditoronline-tests.ts @@ -18,7 +18,7 @@ var json = { editor.set(json); editor.expandAll(); -var jsonResult:JSON = editor.get(); +var jsonResult:any = editor.get(); var options2: JSONFormatterOptions = { "indentation": 2 @@ -34,4 +34,4 @@ var json2 = { }; formatter.set(json2); -var jsonResult2:JSON = formatter.get(json2); \ No newline at end of file +var jsonResult2:any = formatter.get(json2); \ No newline at end of file diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts index 0b441bdf1..7bdacf0ac 100644 --- a/jsoneditoronline/jsoneditoronline.d.ts +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -34,8 +34,14 @@ interface JSONEditorNodeType { title: string; } +interface JSONEditorConstructorParams { + field?: string; + fieldEditable?: bool; + value?: any; +} + class JSONEditorNode { - constructor(editor: JSONEditor, params: Object); + constructor(editor: JSONEditor, params: JSONEditorConstructorParams); setParent(parent: JSONEditorNode): void; getParent(): JSONEditorNode; setField(field: string, fieldEditable: bool): void; @@ -89,7 +95,7 @@ interface JSONEditorShowDropDownListParams { class JSONEditorSearchBox { constructor(editor: JSONEditor, container: HTMLElement); next(): void; - previous: void; + previous(): void; setActiveResult(index: number): void; focusActiveResult(): void; clearDelay(): void; @@ -97,7 +103,27 @@ class JSONEditorSearchBox { onSearch(event: Event, forcedSearch: bool): 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; } class JSONEditor { @@ -110,18 +136,33 @@ class JSONEditor { search(text: string): any[]; expandAll(): void; collapseAll(): void; - onAction(action: string, params: Object); + onAction(action: string, params: JSONEditorActionParams); focus(): void; scrollTo(top: number): void; History: JSONEditorHistory; Node: JSONEditorNode; SearchBox: JSONEditorSearchBox; - showDropDownList(): void; - getNodeFromTarget(target: HTMLElement): JSONEditorNode; + static focusNode: JSONEditorNode; + static freezeHighlight: bool; + 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, ) - }; + addEventListener(element: HTMLElement, action: string, listener:(event?: Event) => void, useCapture:bool): (event?: Event) => void; + removeEventListener(element: HTMLElement, action: string, listener:(event?: Event) => void, useCapture:bool): void; + stopPropagation(event: Event): void; + preventDefault(event:Event): void; + }; + static parse(jsonString: string): Object; + static validate(jsonString: string): string; } interface JSONFormatterOptions {