diff --git a/quill/quill-tests.ts b/quill/quill-tests.ts index dbf8cb466f..5116ace525 100644 --- a/quill/quill-tests.ts +++ b/quill/quill-tests.ts @@ -69,11 +69,24 @@ function test_formatText2() { }); } -function test_formatLine() { +function test_formatLine1() { + var quillEditor = new Quill('#editor'); + quillEditor.formatLine(1, 3, 'api'); +} + +function test_formatLine2() { var quillEditor = new Quill('#editor'); quillEditor.formatLine(1, 3, 'align', 'right'); } +function test_formatLine3() { + var quillEditor = new Quill('#editor'); + quillEditor.formatLine(1, 3, { + 'align': 'right', + 'bold': false, + }); +} + function test_insertEmbed() { var quillEditor = new Quill('#editor'); @@ -151,3 +164,11 @@ function test_addContainer() var quillEditor = new Quill('#editor'); quillEditor.addContainer('ql-custom'); } + +function test_on_EventType1(){ + var quillEditor = new Quill('#editor'); + quillEditor.on('text-change', (newDelta, oldDelta, source)=>{ + // happened + }); + +} diff --git a/quill/quill.d.ts b/quill/quill.d.ts index f1afd4c69f..2ec959ef99 100644 --- a/quill/quill.d.ts +++ b/quill/quill.d.ts @@ -5,6 +5,13 @@ declare namespace QuillJS { + export interface QuillOptionsStatic { + debug?: string, + modules?: {[key: string]: any}, + placeholder?: string, + readOnly?: boolean, + theme?: string + } export interface BoundsStatic { left: number, @@ -28,52 +35,52 @@ declare namespace QuillJS { } export interface QuillStatic { - new (selector: string, options?: Object): QuillStatic; + new (selector: string, options?: QuillOptionsStatic): QuillStatic; - deleteText(start: number, end: number, source?: string): void; + deleteText(start: number, end: number, source?: "api"|"user"|"silent"): void; disable(): void; enable(enabled?: boolean): void; getContents(start?: number, end?: number): DeltaStatic; getLength(): number; getText(start?: number, end?: number): string; - insertEmbed(index: number, type: string, url: string, source?: string): void; - insertText(index: number, text: string, source?: string): void; - insertText(index: number, text: string, format: string, value: string, source?: string): void; - insertText(index: number, text: string, formats: any, source?: string): void; + insertEmbed(index: number, type: string, url: string, source?: "api"|"user"|"silent"): void; + insertText(index: number, text: string, source?: "api"|"user"|"silent"): void; + insertText(index: number, text: string, format: string, value: string, source?: "api"|"user"|"silent"): void; + insertText(index: number, text: string, formats: { [key: string] : any }, source?: "api"|"user"|"silent"): void; pasteHTML(): string; - setContents(delta: DeltaStatic, source?: string): void; - setText(text: string, source?: string): void; + setContents(delta: DeltaStatic, source?: "api"|"user"|"silent"): void; + setText(text: string, source?: "api"|"user"|"silent"): void; update(source?: string): void; - updateContents(delta: DeltaStatic, source?: string): void; + updateContents(delta: DeltaStatic, source?: "api"|"user"|"silent"): void; - format(name: string, value: any, source?: string): void; - formatLine(index: number, length: number, source?: string): void; - formatLine(index: number, length: number, format: string, value: any, source?: string): void; - formatLine(index: number, length: number, formats: any, source?: string): void; - formatText(index: number, length: number, source?: string): void; - formatText(index: number, length: number, format: string, value: any, source?: string): void; - formatText(index: number, length: number, formats: any, source?: string): void; - getFormat(range?: RangeStatic): any; - getFormat(index: number, length?: number): any; - removeFormat(index: Number, length: Number, source?: String): void; + format(name: string, value: any, source?: "api"|"user"|"silent"): void; + formatLine(index: number, length: number, source?: "api"|"user"|"silent"): void; + formatLine(index: number, length: number, format: string, value: any, source?: "api"|"user"|"silent"): void; + formatLine(index: number, length: number, formats: { [key: string] : any }, source?: "api"|"user"|"silent"): void; + formatText(index: number, length: number, source?: "api"|"user"|"silent"): void; + formatText(index: number, length: number, format: string, value: any, source?: "api"|"user"|"silent"): void; + formatText(index: number, length: number, formats: { [key: string] : any }, source?: "api"|"user"|"silent"): void; + getFormat(range?: RangeStatic): {[key: string]: any}; + getFormat(index: number, length?: number): {[key: string]: any}; + removeFormat(index: Number, length: Number, source?: "api"|"user"|"silent"): void; blur(): void; focus(): void; getBounds(index: number, length?: number): BoundsStatic; getSelection(focus?: boolean): RangeStatic; hasFocus(): boolean; - setSelection(index: number, length: number, source?: string): void; - setSelection(range: RangeStatic, source?: string): void; + setSelection(index: number, length: number, source?: "api"|"user"|"silent"): void; + setSelection(range: RangeStatic, source?: "api"|"user"|"silent"): void; - on(eventName: string, callback: (delta: DeltaStatic, oldContents: DeltaStatic, source: String) => void): QuillStatic; - on(eventName: string, callback: (range: RangeStatic, oldRange: RangeStatic, source: String) => void): QuillStatic; + on(eventName: string, callback: ((delta: T, oldContents: T, source: string) => void) | + ((name: string, ...args) => void )): QuillStatic; once(eventName: string, callback: (delta: DeltaStatic, source: string) => void): QuillStatic; off(eventName: string, callback: (delta: DeltaStatic, source: string) => void): QuillStatic; debug(level: string): void; import(path: string): any; register(path: string, def: any, suppressWarning?: boolean): void; - register(defs: any, suppressWarning?: boolean): void; + register(defs: { [key: string] : any }, suppressWarning?: boolean): void; addContainer(className: string, refNode?: any): any; getModule(name: string): any }