Add defintions and tests for EpicEditor

This commit is contained in:
Boris Yankov 2013-01-30 03:59:15 +02:00
parent c8ab7cd45c
commit 2d5a41f4d8
3 changed files with 141 additions and 0 deletions

View File

@ -44,6 +44,7 @@ List of Definitions
* [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton))
* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
* [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
* [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov))
* [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
* [Fabric.js](http://fabricjs.com/) (by [Oliver Klemencic](https://github.com/oklemencic/))
* [Fancybox](http://fancybox.net/) (by [Boris Yankov](https://github.com/borisyankov))

View File

@ -0,0 +1,79 @@
/// <reference path="epiceditor.d.ts" />
var editor = new EpicEditor().load();
editor.load(function () {
console.log("Editor loaded.")
});
editor.unload(function () {
console.log("Editor unloaded.")
});
editor.getElement('editor').body.innerHTML;
if (editor.is('loaded'))
editor.enterFullscreen();
editor.open('some-file');
editor.importFile('some-file', "#Imported markdown\nFancy, huh?");
var theContent = editor.exportFile();
var newName = prompt('What do you want to rename this file to?');
editor.rename('old-filename.md', newName);
editor.save();
editor.remove('example.md');
var files = editor.getFiles();
editor.on('unload', function () {
console.log('Editor was removed');
});
editor.emit('unload');
editor.removeListener('unload');
editor.preview();
editor.edit();
editor.enterFullscreen();
editor.exitFullscreen();
editor.reflow();
editor.reflow('height');
var marked;
var opts = {
container: 'epiceditor',
textarea: null,
basePath: 'epiceditor',
clientSideStorage: true,
localStorageName: 'epiceditor',
useNativeFullsreen: true,
parser: marked,
file: {
name: 'epiceditor',
defaultContent: '',
autoSave: 100
},
theme: {
base: '/themes/base/epiceditor.css',
preview: '/themes/preview/preview-dark.css',
editor: '/themes/editor/epic-dark.css'
},
focusOnLoad: false,
shortcut: {
modifier: 18,
fullscreen: 70,
preview: 80
},
string: {
togglePreview: 'Toggle Preview Mode',
toggleEdit: 'Toggle Edit Mode',
toggleFullscreen: 'Enter Fullscreen'
}
}
var editor2 = new EpicEditor(opts);

61
epiceditor/epiceditor.d.ts vendored Normal file
View File

@ -0,0 +1,61 @@
// Type definitions for EpicEditor 0.2
// Project: http://epiceditor.com/
// Definitions by: Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface EpicEditorOptions {
container?: any;
textarea?: any;
basePath?: string;
clientSideStorage?: bool;
localStorageName?: string;
useNativeFullsreen?: bool;
parser?: any;
file?: {
name: string;
defaultContent: string;
autoSave: any;
};
theme?: {
base: string;
preview: string;
editor: string;
};
focusOnLoad?: bool;
shortcut?: {
modifier: number;
fullscreen: number;
preview: number;
};
string?: {
togglePreview: string;
toggleEdit: string;
toggleFullscreen: string;
};
}
class EpicEditor {
constructor();
constructor(options: EpicEditorOptions);
load(callback?: Function): EpicEditor;
unload(callback?: Function): EpicEditor;
getElement(element: string): any;
is(state: string): bool;
open(filename: string);
importFile(filename?: string, content?: string): void;
exportFile(filename?: string, type?: string): any;
rename(oldName: string, newName: string): void;
save(): void;
remove(filename: string): void;
getFiles(filename?: string): any;
on(event: string, handler: Function): void;
emit(event: string): void;
removeListener(event: string, handler?: Function): void;
preview(): void;
edit(): void;
enterFullscreen(): void;
exitFullscreen(): void;
reflow(type?: string): void;
}