TinyMCE typings (WIP) (#13728)

* TinyMCE typings

* TinyMCE declaration file

* Update tsconfig.json

Changed `strictNullChecks` to true and added `noImplicitThis`

* Update index.d.ts

Added namespace

* Update index.d.ts
This commit is contained in:
Martin D 2017-01-05 12:26:08 -05:00 committed by Andy
parent a1cbc2a5dc
commit ff2d63b83b
4 changed files with 77 additions and 0 deletions

44
tinymce/index.d.ts vendored Normal file
View File

@ -0,0 +1,44 @@
// Type definitions for TinyMCE 4.5
// Project: https://github.com/tinymce/tinymce
// Definitions by: Martin Duparc <https://github.com/martinduparc/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Work In Progress
declare namespace TinyMCE {
export interface Observable {
off: (name?: string, callback?: () => void) => any;
on: (name: string, callback: () => void) => any;
fire: (name: string, args?: any, bubble?: boolean) => Event;
}
export interface Editor extends Observable {
destroy: (automatic: boolean) => void;
remove: () => void;
hide: () => void;
show: () => void;
getContent: (args?: any) => string;
setContent: (content: string, args?: any) => string;
focus: (skip_focus?: boolean) => void;
undoManager: UndoManager;
settings: any;
getDoc: () => Document;
editorUpload: any;
}
export interface UndoManager {
undo: () => any;
clear: () => void;
hasUndo: () => boolean;
}
export interface Static extends Observable {
init: (settings: any) => void;
execCommand: (c: string, u: boolean, v: string) => boolean;
activeEditor: Editor;
get: (id: string) => Editor;
triggerSave: () => void;
}
}
declare var tinymce: TinyMCE.Static;

12
tinymce/tinymce-tests.ts Normal file
View File

@ -0,0 +1,12 @@
tinymce.init(
{
selector: '.tinymce-editable',
height: 145,
plugins: [
'autolink table contextmenu paste code link textcolor colorpicker image imagetools'
],
menubar: 'edit insert table tools',
toolbar: 'undo redo | styleselect bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | link image',
content_css: 'page.css'
}
);

20
tinymce/tsconfig.json Normal file
View File

@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"tinymce-tests.ts"
]
}

1
tinymce/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "../tslint.json" }