diff --git a/types/ckeditor/v2/ckeditor-tests.ts b/types/ckeditor/v2/ckeditor-tests.ts index 1a906bc26e..ce93c75eba 100644 --- a/types/ckeditor/v2/ckeditor-tests.ts +++ b/types/ckeditor/v2/ckeditor-tests.ts @@ -1,14 +1,12 @@ - - function test_CKEDITOR() { CKEDITOR.basePath = 'test'; CKEDITOR.replaceClass = 'rich_editor'; CKEDITOR.skinName = 'moono'; CKEDITOR.skinName = 'myskin,/customstuff/myskin/'; var editor = new CKEDITOR.editor(); - if (editor.getSelection().getType() == CKEDITOR.SELECTION_ELEMENT) - if (editor.getSelection().getType() == CKEDITOR.SELECTION_NONE) - if (editor.getSelection().getType() == CKEDITOR.SELECTION_TEXT) + if (editor.getSelection().getType() === CKEDITOR.SELECTION_ELEMENT) + if (editor.getSelection().getType() === CKEDITOR.SELECTION_NONE) + if (editor.getSelection().getType() === CKEDITOR.SELECTION_TEXT) alert(CKEDITOR.basePath); if (CKEDITOR.currentInstance) alert(CKEDITOR.currentInstance.name); @@ -17,7 +15,7 @@ function test_CKEDITOR() { CKEDITOR.loadFullCoreTimeout = 5; alert(CKEDITOR.revision); alert(CKEDITOR.rnd); - if (CKEDITOR.status == 'loaded') { + if (CKEDITOR.status === 'loaded') { CKEDITOR.loadFullCore(); } alert(CKEDITOR.timestamp); @@ -38,7 +36,7 @@ function test_CKEDITOR() { } function test_CKEDITOR_events() { - CKEDITOR.on('instanceCreated', function(event) { + CKEDITOR.on('instanceCreated', (event) => { // $ExpectType editor event.editor; }); @@ -75,7 +73,7 @@ function test_config() { { name: 'styles', groups: [ 'styles' ] }, { name: 'colors', groups: [ 'colors' ] }, ], - } + }; } function test_dom_comment() { @@ -115,7 +113,7 @@ function test_dom_domObject() { var nativeElement = element.$; var doc = new CKEDITOR.dom.document(document); alert(doc.equals(CKEDITOR.document)); - alert(doc == CKEDITOR.document); + alert(doc === CKEDITOR.document); var element2 = new CKEDITOR.dom.element('span'); alert(element.getCustomData('hasCustomData')); alert(element.getCustomData('nonExistingKey')); @@ -136,7 +134,7 @@ function test_dom_element() { var strong = new CKEDITOR.dom.element('strong'); p.append(strong); var em = p.append('em'); - var p = new CKEDITOR.dom.element('p'); + p = new CKEDITOR.dom.element('p'); p.appendText('This is'); p.appendText(' some text'); element.breakParent(strong); @@ -147,7 +145,7 @@ function test_dom_element() { element.focus(); element.focusNext(); element.focusPrevious(); - element.forEach(node=> { + element.forEach(node => { console.log(node); }); var element2 = CKEDITOR.dom.element.createFromHtml(''); @@ -159,7 +157,7 @@ function test_dom_element() { alert(element.getHtml()); alert(element.getId()); alert(element.getName()); - alert('' + element.getNameAtt() + ''); + alert(`${element.getNameAtt()}`); alert(element.getOuterHtml()); alert(element.getTabIndex()); alert(element.getText()); @@ -180,7 +178,7 @@ function test_dom_element() { element.setAttribute('class', 'myClass'); element.setAttribute('title', 'This is an example'); element.setAttributes({ - 'class': 'myClass', + class: 'myClass', title: 'This is an example' }); p.setHtml('Inner HTML'); @@ -196,7 +194,7 @@ function test_dom_element() { element.show(); element.unselectable(); alert(element.getName()); - alert(element == CKEDITOR.dom.element.get(element)); + alert(element === CKEDITOR.dom.element.get(element)); var htmlElement = document.getElementById('myElement'); alert(CKEDITOR.dom.element.get(htmlElement).getName()); } @@ -204,20 +202,20 @@ function test_dom_element() { function test_dom_event() { var event = new CKEDITOR.dom.event(new Event("")); alert(event.getKey()); - alert(event.getKeystroke() == 65); - alert(event.getKeystroke() == CKEDITOR.CTRL + 65); - alert(event.getKeystroke() == CKEDITOR.CTRL + CKEDITOR.SHIFT + 65); + alert(event.getKeystroke() === 65); + alert(event.getKeystroke() === CKEDITOR.CTRL + 65); + alert(event.getKeystroke() === CKEDITOR.CTRL + CKEDITOR.SHIFT + 65); var element = new CKEDITOR.dom.element('div'); - element.on('mousemouse', ev=> { + element.on('mousemouse', ev => { var pageOffset = ev.data.getPageOffset(); alert(pageOffset.x); alert(pageOffset.y); }); - element.on('click', ev=> { + element.on('click', ev => { var domEvent = ev.data; domEvent.getTarget().addClass('clicked'); }); - element.on('click', ev=> { + element.on('click', ev => { var domEvent = ev.data as CKEDITOR.dom.event; domEvent.preventDefault(); }); @@ -298,14 +296,14 @@ function test_adding_command_and_buttons() { var textarea = document.createElement('textarea'); var instance = CKEDITOR.replace(textarea); - instance.addCommand( 'aCommand', { - exec: function( editor: CKEDITOR.editor ) { + instance.addCommand('aCommand', { + exec: (editor: CKEDITOR.editor) => { // empty logic return true; } }); - instance.ui.addButton( 'firstButton', { + instance.ui.addButton('firstButton', { icon: 'http://www.example.com/assets/images/icons.png', iconOffset: -32, label: 'Label 1', @@ -313,7 +311,7 @@ function test_adding_command_and_buttons() { toolbar: 'tools' }); - instance.ui.addButton( 'secondButton', { + instance.ui.addButton('secondButton', { label: 'Label 2', command: 'aCommand', toolbar: 'tools' @@ -321,11 +319,11 @@ function test_adding_command_and_buttons() { } function test_adding_dialog_by_path() { - CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' ); + CKEDITOR.dialog.add('abbrDialog', 'PATH/dialogs/abbr.js'); } function test_adding_dialog_by_definition() { - CKEDITOR.dialog.add( 'abbrDialog', function ( editor: CKEDITOR.editor ) { + CKEDITOR.dialog.add('abbrDialog', (editor: CKEDITOR.editor) => { return { title: 'Abbreviation Properties', minWidth: 400, @@ -339,7 +337,7 @@ function test_adding_dialog_by_definition() { { id: 'tab-basic', label: 'Basic Settings', - elements: [] + elements: [] }, { id: 'tab-adv', @@ -352,8 +350,8 @@ function test_adding_dialog_by_definition() { } function test_plugins() { - CKEDITOR.plugins.add( 'abbr', { - init: function( editor: CKEDITOR.editor ) { + CKEDITOR.plugins.add('abbr', { + init: (editor: CKEDITOR.editor) => { // empty logic } }); @@ -367,7 +365,7 @@ function test_adding_widget() { button: "Activate widgetty", template: "", dialog: "widgetty", - init: function() { + init: () => { // no logic } }); @@ -442,80 +440,80 @@ function test_editor_instance_event() { var textarea = document.createElement('textarea'); var instance = CKEDITOR.replace(textarea, { on: { - activeEnterModeChange: function() {}, - activeFilterChange: function() {}, - afterCommandExec: function() {}, - afterInsertHtml: function() {}, - afterPaste: function() {}, - afterPasteFromWord: function() {}, - afterSetData: function() {}, - afterUndoImage: function() {}, - ariaEditorHelpLabel: function() {}, - ariaWidget: function() {}, - autogrow: function() {}, - beforeCommandExec: function() {}, - beforeDestroy: function() {}, - beforeModeUnload: function() {}, - beforeSetMode: function() {}, - beforeUndoImage: function() {}, - blur: function() {}, - change: function() {}, - configLoaded: function() {}, - contentDirChanged: function() {}, - contentDom: function() {}, - contentDomInvalidated: function() {}, - contentDomUnload: function() {}, - customConfigLoaded: function() {}, - dataFiltered: function() {}, - dataReady: function() {}, - destroy: function() {}, - dialogHide: function() {}, - dialogShow: function() {}, - dirChanged: function() {}, - doubleclick: function() {}, - dragend: function() {}, - dragstart: function() {}, - drop: function() {}, - elementsPathUpdate: function() {}, - fileUploadRequest: function() {}, - fileUploadResponse: function() {}, - floatingSpaceLayout: function() {}, - focus: function() {}, - getData: function() {}, - getSnapshot: function() {}, - insertElement: function() {}, - insertHtml: function() {}, - insertText: function() {}, - instanceReady: function() {}, - key: function() {}, - langLoaded: function() {}, - loadSnapshot: function() {}, - loaded: function() {}, - lockSnapshot: function() {}, - maximize: function() {}, - menuShow: function() {}, - mode: function() {}, - notificationHide: function() {}, - notificationShow: function() {}, - notificationUpdate: function() {}, - paste: function() {}, - pasteFromWord: function() {}, - pluginsLoaded: function() {}, - readOnly: function() {}, - removeFormatCleanup: function() {}, - required: function() {}, - resize: function() {}, - save: function() {}, - saveSnapshot: function() {}, - selectionChange: function() {}, - setData: function() {}, - stylesSet: function() {}, - template: function() {}, - toDataFormat: function() {}, - toHtml: function() {}, - unlockSnapshot: function() {}, - updateSnapshot: function() {}, - widgetDefinition: function() {} + activeEnterModeChange: () => {}, + activeFilterChange: () => {}, + afterCommandExec: () => {}, + afterInsertHtml: () => {}, + afterPaste: () => {}, + afterPasteFromWord: () => {}, + afterSetData: () => {}, + afterUndoImage: () => {}, + ariaEditorHelpLabel: () => {}, + ariaWidget: () => {}, + autogrow: () => {}, + beforeCommandExec: () => {}, + beforeDestroy: () => {}, + beforeModeUnload: () => {}, + beforeSetMode: () => {}, + beforeUndoImage: () => {}, + blur: () => {}, + change: () => {}, + configLoaded: () => {}, + contentDirChanged: () => {}, + contentDom: () => {}, + contentDomInvalidated: () => {}, + contentDomUnload: () => {}, + customConfigLoaded: () => {}, + dataFiltered: () => {}, + dataReady: () => {}, + destroy: () => {}, + dialogHide: () => {}, + dialogShow: () => {}, + dirChanged: () => {}, + doubleclick: () => {}, + dragend: () => {}, + dragstart: () => {}, + drop: () => {}, + elementsPathUpdate: () => {}, + fileUploadRequest: () => {}, + fileUploadResponse: () => {}, + floatingSpaceLayout: () => {}, + focus: () => {}, + getData: () => {}, + getSnapshot: () => {}, + insertElement: () => {}, + insertHtml: () => {}, + insertText: () => {}, + instanceReady: () => {}, + key: () => {}, + langLoaded: () => {}, + loadSnapshot: () => {}, + loaded: () => {}, + lockSnapshot: () => {}, + maximize: () => {}, + menuShow: () => {}, + mode: () => {}, + notificationHide: () => {}, + notificationShow: () => {}, + notificationUpdate: () => {}, + paste: () => {}, + pasteFromWord: () => {}, + pluginsLoaded: () => {}, + readOnly: () => {}, + removeFormatCleanup: () => {}, + required: () => {}, + resize: () => {}, + save: () => {}, + saveSnapshot: () => {}, + selectionChange: () => {}, + setData: () => {}, + stylesSet: () => {}, + template: () => {}, + toDataFormat: () => {}, + toHtml: () => {}, + unlockSnapshot: () => {}, + updateSnapshot: () => {}, + widgetDefinition: () => {} } }); } @@ -580,8 +578,8 @@ function test_tools() { console.log(CKEDITOR.tools.isArray(null)); // false console.log(CKEDITOR.tools.isArray(undefined)); // false - CKEDITOR.tools.override(parseInt, function(_parseInt) { - return function(value: any, radix?: number) { + CKEDITOR.tools.override(parseInt, (_parseInt) => { + return (value: any, radix?: number) => { return _parseInt(value, radix); }; }); @@ -590,9 +588,9 @@ function test_tools() { function test_htmlParser() { var html = '
text
'; var fragment = CKEDITOR.htmlParser.fragment.fromHtml(html); - fragment.forEach(function(node) { + fragment.forEach((node) => { if (node instanceof CKEDITOR.htmlParser.element) { - node.forEach(function(node) { + node.forEach((node) => { console.log(node); }); } diff --git a/types/ckeditor/v2/index.d.ts b/types/ckeditor/v2/index.d.ts index 34d243ae3f..ab7b88bbdd 100644 --- a/types/ckeditor/v2/index.d.ts +++ b/types/ckeditor/v2/index.d.ts @@ -1,16 +1,16 @@ -// Type definitions for CKEditor v2.0.0 +// Type definitions for CKEditor 2.0 // Project: http://ckeditor.com/ // Definitions by: Thomas Wittwer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // WORK-IN-PROGRESS: Any contribution support welcomed. // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/1827 for more informations. + interface Window { CKEDITOR_BASEPATH: string; } declare namespace CKEDITOR { - // Config options var disableAutoInline: boolean; var disableObjectResizing: boolean; @@ -84,16 +84,14 @@ declare namespace CKEDITOR { function add(editor: editor): void; function addCss(css: string): void; function addTemplate(name: string, source: string): template; - function appendTo(element: string, config?: config, data?: string): editor; - function appendTo(element: HTMLElement, config?: config, data?: string): editor; + function appendTo(element: string | HTMLElement, config?: config, data?: string): editor; function domReady(): void; function dialogCommand(dialogName: string): void; function editorConfig(config: config): void; function getCss(): string; function getTemplate(name: string): template; function getUrl(resource: string): string; - function inline(element: string, instanceConfig?: config): editor; - function inline(element: HTMLElement, instanceConfig?: config): editor; + function inline(element: string | HTMLElement, instanceConfig?: config): editor; function inlineAll(): void; function loadFullCore(): void; function replace(element: string | HTMLTextAreaElement, config?: config): editor; @@ -111,12 +109,11 @@ declare namespace CKEDITOR { function removeAllListeners(): void; function removeListener(eventName: string, listenerFunction: (eventInfo: eventInfo) => void): void; - type listenerRegistration = { + interface listenerRegistration { removeListener: () => void; } namespace dom { - interface bookmark { startNode: dom.node | string; endNode: dom.node | string; @@ -125,20 +122,15 @@ declare namespace CKEDITOR { } class comment { - // Properties type: number; // Methods - constructor(comment: string, ownerDocument?: document); - constructor(comment: Object, ownerDocument?: document); + constructor(comment: string | Object, ownerDocument?: document); getOuterHtml(): string; - } - class document extends domObject { - // Properties type: number; @@ -161,24 +153,18 @@ declare namespace CKEDITOR { getSelection(): selection; getWindow(): window; write(html: string): void; - } - class documentFragment { - // Properties type: number; // Methods constructor(nodeOrDoc: Object); insertAfterNode(node: node): void; - } - class domObject extends event { - // Properties $: HTMLElement; @@ -192,21 +178,16 @@ declare namespace CKEDITOR { removeAllListeners(): void; removeCustomData(key: string): Object; setCustomData(key: string, value: Object): domObject; - } - class element extends node { - // Properties type: number; // Methods - constructor(element: string, ownerDocument?: document); - constructor(element: HTMLElement, ownerDocument?: document); + constructor(element: string | HTMLElement, ownerDocument?: document); addClass(className: string): void; - append(node: node, toStart?: boolean): node; - append(node: string, toStart?: boolean): node; + append(node: node | string, toStart?: boolean): node; appendBogus(force: boolean): void; appendHtml(html: string): void; appendText(text: string): node; @@ -214,8 +195,7 @@ declare namespace CKEDITOR { contains(node: node): boolean; copyAttributes(dest: element, skipAttributes: Object): void; data(name: string): string; - data(name: string, value: string): void; - data(name: string, value: boolean): void; + data(name: string, value: string | boolean): void; disableContextMenu(): void; find(selector: string): nodeList; findOne(selector: string): element; @@ -224,9 +204,8 @@ declare namespace CKEDITOR { focusPrevious(ignoreChildren?: boolean, indexToUse?: number): void; forEach(callback: (node: node) => void, type?: number, skipRoot?: boolean): void; getAttribute(name: string): string; - getBogus(): node|false; - getChild(indices: number): node; - getChild(indices: number[]): node; + getBogus(): node | false; + getChild(indices: number | number[]): node; getChildCount(): number; getChildren(): nodeList; getClientRect(): any; @@ -269,8 +248,7 @@ declare namespace CKEDITOR { removeClass(className: string): void; removeStyle(name: string): void; renameNode(newTag: string): void; - scrollIntoParent(parent: element, alignToTop: boolean, hscroll: boolean): void; - scrollIntoParent(parent: window, alignToTop: boolean, hscroll: boolean): void; + scrollIntoParent(parent: element | window, alignToTop: boolean, hscroll: boolean): void; scrollIntoView(alignToTop?: boolean): void; setAttribute(name: string, value: string): element; setAttributes(attributesPairs: Object): element; @@ -285,38 +263,28 @@ declare namespace CKEDITOR { show(): void; unselectable(): void; - //static method + // static method static clearAllMarkers(database: Object): Object; static clearMarkers(database: Object, element: Object, removeFromDatabase: Object): void; static createFromHtml(html: string): element; - static get(element: string): element; - static get(element: any): element; + static get(element: string | any): element; static setMarker(database: Object, element: Object, name: Object, value: Object): domObject; - } - class elementPath { - constructor(startNode: element, root: element); - constructor(startNode: element); + constructor(startNode: element, root?: element); block: element; blockLimit: element; root: element; elements: element[]; compare(otherPath: elementPath): boolean; - contains(query: string, excludeRoot?: boolean, fromTop?: boolean): element; - contains(query: string[], excludeRoot?: boolean, fromTop?: boolean): element; - contains(query: (element: element) => boolean, excludeRoot?: boolean, fromTop?: boolean): element; - contains(query: Object, excludeRoot?: boolean, fromTop?: boolean): element; - contains(query: element, excludeRoot?: boolean, fromTop?: boolean): element; + contains(query: string | string[] | Object | element | ((element: element) => boolean), excludeRoot?: boolean, fromTop?: boolean): element; isContextFor(tag: string): boolean; direction(): string; } - class range { - constructor(root: element); - constructor(root: document); + constructor(root: element | document); startContainer: any; startOffset: number; endContainer: any; @@ -378,10 +346,7 @@ declare namespace CKEDITOR { scrollIntoView(): void; } - - interface rangeListIterator { - - } + interface rangeListIterator {} class selection { document: document; @@ -389,9 +354,7 @@ declare namespace CKEDITOR { isLocked: boolean; rev: number; root: element; - constructor(target: document); - constructor(target: element); - constructor(target: selection); + constructor(target: document | element | selection); createBookmarks(serializable: Object): bookmark[]; createBookmarks2(normalized: Object): Object[]; fake(element: element): void; @@ -413,17 +376,14 @@ declare namespace CKEDITOR { unlock(restore: Object): void; } - class rangeList { - constructor(ranges: range[]); - constructor(range: range); + constructor(ranges: range | range[]); createIterator(): rangeListIterator; createBokmarks(serializable?: boolean): bookmark[]; createBookmarks2(normalized?: boolean): Object[]; moveToBookmark(bookmarks: Object[]): void; } - class iterator { constructor(range: range); getNextParagraph(blockTag?: string): element; @@ -433,7 +393,6 @@ declare namespace CKEDITOR { filter: filter; } - class node extends domObject { constructor(domNode: Node); appendTo(element: element): element; @@ -464,14 +423,12 @@ declare namespace CKEDITOR { isReadOnly(): boolean; } - class nodeList { constructor(nativeList: Object); count(): number; getItem(index: number): node; } - class event { constructor(domEvent: Event); getKey(): number; @@ -484,22 +441,18 @@ declare namespace CKEDITOR { on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: Object, listenerData?: Object, priority?: number): Object; } - interface position { x: number; y: number; } - interface widthAndHeight { width: number; height: number; } - class text extends node { - constructor(text: Text, ownerDocument?: document); - constructor(text: string, ownerDocument?: document); + constructor(text: Text | string, ownerDocument?: document); type: number; getLength(): number; getText(): string; @@ -508,7 +461,6 @@ declare namespace CKEDITOR { substring(indexA: number, indexB: number): void; } - class window extends domObject { constructor(domWindow: Object); focus(): void; @@ -517,7 +469,6 @@ declare namespace CKEDITOR { getFrame(): element; } - class walker { constructor(range: range); end(): void; @@ -528,7 +479,7 @@ declare namespace CKEDITOR { lastForward(): node; lastBackward(): node; reset(): void; - //static methods till the end + // static methods till the end blockBoundary(customNodeNames: Object): Function; listItemBoundary(): Function; bookmark(contentOnly?: boolean, isReject?: boolean): Function; @@ -540,26 +491,17 @@ declare namespace CKEDITOR { ignored(isReject?: boolean): Function; editable(isReject?: boolean): Function; } - } - namespace ajax { - // Methods function load(url: string, callback?: Function): string; function loadXml(url: string, callback?: Function): xml; - - } - - - interface xml { - } + interface xml {} class command extends event { - // Properties contextSensitive: boolean; editorFocus: boolean; @@ -577,10 +519,8 @@ declare namespace CKEDITOR { refresh(editor: editor, path: dom.elementPath): void; setState(newState: number): boolean; toggleState(): void; - } - class focusManager { // Properties currentActive: dom.domObject; @@ -596,9 +536,7 @@ declare namespace CKEDITOR { remove(element: dom.element): void; } - interface keystrokeHandler { - - } + interface keystrokeHandler {} interface toolbarGroups { name?: string; @@ -759,7 +697,7 @@ declare namespace CKEDITOR { linkShowAdvancedTab?: boolean; linkShowTargetTab?: boolean; - magicline_color?: string + magicline_color?: string; magicline_everywhere?: boolean; magicline_holdDistance?: number; magicline_keystrokeNext?: number; @@ -848,10 +786,10 @@ declare namespace CKEDITOR { templates_files?: Object; templates_replaceContent?: boolean; title?: string | boolean; - toolbar?: string | (string | string[] | { name: string, items?: string[], groups?: string[] })[] | null; + toolbar?: string | Array | null; toolbarCanCollapse?: boolean; toolbarGroupCycling?: boolean; - toolbarGroups?: (toolbarGroups | string)[]; + toolbarGroups?: Array; toolbarLocation?: string; toolbarStartupExpanded?: boolean; @@ -869,11 +807,7 @@ declare namespace CKEDITOR { wsc_userDictionaryName?: string; } - - interface feature { - - } - + interface feature {} interface sharedSpace { top?: string | HTMLElement; @@ -897,7 +831,6 @@ declare namespace CKEDITOR { scopeobj?: {}, listenerData?: any, priority?: number): listenerRegistration; } - class menu { constructor(); add(item: any): void; @@ -907,16 +840,13 @@ declare namespace CKEDITOR { show(offsetParent: dom.element, corner?: number, offsetX?: number, offsetY?: number): void; } - namespace plugins { - class contextMenu extends menu { constructor(editor: editor); addTarget(element: dom.element, nativeContextMenuOnCtrl?: boolean): void; open(offsetParent: dom.element, corner?: number, offsetX?: number, offsetY?: number): void; } - namespace link { var emptyAnchorFix: boolean; var fakeAnchor: boolean; @@ -926,9 +856,7 @@ declare namespace CKEDITOR { function tryRestoreFakeAnchor(editor: editor, element: dom.element): dom.element; } - namespace widget { - namespace nestedEditable { interface definition { allowedContent?: any; @@ -948,7 +876,6 @@ declare namespace CKEDITOR { setData(data: string): void; } - interface definition { allowedContent?: any; button?: string; @@ -995,8 +922,7 @@ declare namespace CKEDITOR { fire(eventName: string, data: Object, editor: editor): any; // should be boolean | Object getByElement(element: any, checkWrapperOnly: boolean): CKEDITOR.plugins.widget; hasListeners(eventName: string): boolean; - initOn(element: dom.element, widgetDef?: CKEDITOR.plugins.widget.definition, startupData?: Object): CKEDITOR.plugins.widget; - initOn(element: dom.element, widgetDef?: string, startupData?: Object): CKEDITOR.plugins.widget; + initOn(element: dom.element, widgetDef?: string | CKEDITOR.plugins.widget.definition, startupData?: Object): CKEDITOR.plugins.widget; initOnAll(container?: dom.element): CKEDITOR.plugins.widget[]; instances: { [id: string]: widget }; on(eventName: string, listenerFunction: Function, scopeObj?: Object, listenerData?: Object, priority?: number): any; @@ -1023,7 +949,7 @@ declare namespace CKEDITOR { editables: any; editor: CKEDITOR.editor; element: CKEDITOR.dom.element; - focusedEditable: CKEDITOR.plugins.widget.nestedEditable + focusedEditable: CKEDITOR.plugins.widget.nestedEditable; id: number; init: Function; inited: boolean; @@ -1088,8 +1014,7 @@ declare namespace CKEDITOR { icons?: string; } - function add(name: string, definition: IPluginDefinition): void; - function add(name: string): void; + function add(name: string, definition?: IPluginDefinition): void; function addExternal(name: string, path: string, fileName?: string): void; function get(name: string): any; function getFilePath(name: string): string; @@ -1100,11 +1025,11 @@ declare namespace CKEDITOR { } interface IMenuItemDefinition { - label:string, - command:string, - icon: string - group:string, - order:number + label: string; + command: string; + icon: string; + group: string; + order: number; } class editor extends event { @@ -1144,20 +1069,19 @@ declare namespace CKEDITOR { addFeature(feature: feature): boolean; addMenuGroup(name: string, order?: number): void; addMenuItem(name: string, definition?: IMenuItemDefinition): void; - addMenuItems(definitions: {[id:string]:IMenuItemDefinition}): void; + addMenuItems(definitions: {[id: string]: IMenuItemDefinition}): void; addMode(mode: string, exec: () => void): void; addRemoveFormatFilter(func: Function): void; applyStyle(style: style): void; attachStyleStateChange(style: style, callback: Function): void; checkDirty(): boolean; - commands:any; + commands: any; createFakeElement(realElement: Object, className: Object, realElementType: Object, isResizable: Object): void; createFakeParserElement(realElement: Object, className: Object, realElementType: Object, isResizable: Object): void; createRange(): dom.range; destroy(noUpdate?: boolean): void; editable(): editable | null; - editable(elementOrEditable: dom.element): void; - editable(elementOrEditable: editable): void; + editable(elementOrEditable: dom.element | editable): void; elementPath(startNode?: dom.node): dom.elementPath; execCommand(commandName: string, data?: Object): boolean; focus(): void; @@ -1181,27 +1105,18 @@ declare namespace CKEDITOR { loadSnapshot(snapshot: Object): void; lockSelection(sel?: dom.selection): boolean; openDialog(dialogName: string, callback: Function): dialog; - popup(url: string, width?: number, height?: number, options?: string): void; - popup(url: string, width?: string, height?: number, options?: string): void; - popup(url: string, width?: number, height?: string, options?: string): void; - popup(url: string, width?: string, height?: string, options?: string): void; + popup(url: string, width?: number | string, height?: number | string, options?: string): void; removeMenuItem(name: string): void; removeStyle(style: style): void; resetDirty(): void; resetUndo(): void; - resize(width: number, height: number, isContentHeight?: boolean, resizeInner?: boolean): void; - resize(width: string, height: number, isContentHeight?: boolean, resizeInner?: boolean): void; - resize(width: number, height: string, isContentHeight?: boolean, resizeInner?: boolean): void; - resize(width: string, height: string, isContentHeight?: boolean, resizeInner?: boolean): void; + resize(width: number | string, height: number | string, isContentHeight?: boolean, resizeInner?: boolean): void; restoreRealElement(fakeElement: Object): dom.element; selectionChange(checkNow?: boolean): void; setActiveEnterMode(enterMode: number, shiftEnterMode: number): void; setActiveFilter(filter: filter): void; setData(data: string, options?: { internal?: boolean; callback?: Function; noSnapshot?: boolean; }): void; - setKeystroke(keystroke: number, behavior?: string): void; - setKeystroke(keystroke: any[], behavior?: string): void; - setKeystroke(keystroke: number, behavior?: boolean): void; - setKeystroke(keystroke: any[], behavior?: boolean): void; + setKeystroke(keystroke: number | any[], behavior?: string | boolean): void; setMode(newMode: string, callback: Function): void; setReadOnly(isReadOnly?: boolean): void; setUiColor(color: string): void; @@ -1317,28 +1232,22 @@ declare namespace CKEDITOR { } module filter { - interface allowedContentRules { - - } + interface allowedContentRules {} } class filter { allow(newRules: CKEDITOR.filter.allowedContentRules, featureName?: string, overrideCustom?: boolean): boolean; - } interface buttonDefinition { icon?: string; iconOffset?: number; - label : string; - command : string; - toolbar : string; - } - - interface template { - + label: string; + command: string; + toolbar: string; } + interface template {} interface dataProcessor { toDataFormat(html: string, fixForBody: string): void; @@ -1355,7 +1264,6 @@ declare namespace CKEDITOR { toHtml(data: string, options?: Object): string; } - class event { constructor(); useCapture: boolean; @@ -1371,7 +1279,6 @@ declare namespace CKEDITOR { static implementOn(targetObject: Object): void; } - interface commandDefinition { async?: boolean; canUndo?: boolean; @@ -1385,30 +1292,28 @@ declare namespace CKEDITOR { refresh?(editor: editor, path: dom.elementPath): void; } - interface dtdDefinition { [outerTagName: string]: {[innerTagName: string]: 1}; - $block: {[tagName: string]: 1}; - $blockLimit: {[tagName: string]: 1}; - $cdata: {[tagName: string]: 1}; - $editable: {[tagName: string]: 1}; - $empty: {[tagName: string]: 1}; - $inline: {[tagName: string]: 1}; - $intermediate: {[tagName: string]: 1}; - $list: {[tagName: string]: 1}; - $listItem: {[tagName: string]: 1}; + $block: {[tagName: string]: 1}; + $blockLimit: {[tagName: string]: 1}; + $cdata: {[tagName: string]: 1}; + $editable: {[tagName: string]: 1}; + $empty: {[tagName: string]: 1}; + $inline: {[tagName: string]: 1}; + $intermediate: {[tagName: string]: 1}; + $list: {[tagName: string]: 1}; + $listItem: {[tagName: string]: 1}; $nonBodyContent: {[tagName: string]: 1}; - $nonEditable: {[tagName: string]: 1}; - $object: {[tagName: string]: 1}; - $removeEmpty: {[tagName: string]: 1}; - $tabIndex: {[tagName: string]: 1}; - $tableContent: {[tagName: string]: 1}; - $transparent: {[tagName: string]: 1}; + $nonEditable: {[tagName: string]: 1}; + $object: {[tagName: string]: 1}; + $removeEmpty: {[tagName: string]: 1}; + $tabIndex: {[tagName: string]: 1}; + $tableContent: {[tagName: string]: 1}; + $transparent: {[tagName: string]: 1}; } var dtd: dtdDefinition; - class ui extends event { constructor(editor: editor); add(name: string, type: Object, definition: Object): void; @@ -1417,24 +1322,24 @@ declare namespace CKEDITOR { } class environmentConfig { - air : boolean; - chrome : boolean; - cssClass : string; - edge : boolean; - gecko : boolean; - hc : boolean; - hidpi : boolean; - iOS : boolean; - ie : boolean; - isCompatible : boolean; - mac : boolean; - needsBrFiller : boolean; - needsNbspFiller : boolean; - quirks : boolean; - safari : boolean; - version : number; - webkit : boolean; - secure( ) : boolean; + air: boolean; + chrome: boolean; + cssClass: string; + edge: boolean; + gecko: boolean; + hc: boolean; + hidpi: boolean; + iOS: boolean; + ie: boolean; + isCompatible: boolean; + mac: boolean; + needsBrFiller: boolean; + needsNbspFiller: boolean; + quirks: boolean; + safari: boolean; + version: number; + webkit: boolean; + secure(): boolean; } namespace ui { @@ -1442,7 +1347,16 @@ declare namespace CKEDITOR { class uiElement { eventProcessors: any; - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[], nodeNameArg?: Function | string, stylesArg?: Function | Object, attributesArg?: Function | Object, contentsArg?: Function | string); // Not sure that the htmlList array type is right. + // Not sure that the htmlList array type is right. + constructor( + dialog: CKEDITOR.dialog, + elementDefinition: CKEDITOR.dialog.definition.uiElement, + htmlList: any[], + nodeNameArg?: Function | string, + stylesArg?: Function | Object, + attributesArg?: Function | Object, + contentsArg?: Function | string + ); accessKeyDown(dialog: CKEDITOR.dialog, key: string): void; accessKeyUp(dialog: CKEDITOR.dialog, key: string): void; @@ -1464,7 +1378,6 @@ declare namespace CKEDITOR { // Change event? } - class button extends uiElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); @@ -1473,7 +1386,6 @@ declare namespace CKEDITOR { click(): any; } - class checkbox extends uiElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); @@ -1483,12 +1395,10 @@ declare namespace CKEDITOR { setValue(checked: boolean, noChangeEvent: boolean): any; // returns void according to doc, but cannot override base class like that } - class fieldset extends uiElement { constructor(dialog: CKEDITOR.dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: CKEDITOR.dialog.definition.uiElement); } - class file extends CKEDITOR.ui.dialog.labeledElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); @@ -1500,14 +1410,12 @@ declare namespace CKEDITOR { submit(): CKEDITOR.ui.dialog.file; } - class fileButton extends CKEDITOR.ui.dialog.button { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); // formLoaded event ?? } - class hbox extends uiElement { constructor(dialog: CKEDITOR.dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: CKEDITOR.dialog.definition.uiElement); @@ -1515,17 +1423,11 @@ declare namespace CKEDITOR { getChild(indices: number[]): CKEDITOR.ui.dialog.uiElement[]; } - class html extends uiElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); - - } - - - class iframeElement extends uiElement { - } + class iframeElement extends uiElement {} class labeledElement extends uiElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[], contentHtml: Function); @@ -1534,7 +1436,6 @@ declare namespace CKEDITOR { setlabel(label: string): CKEDITOR.ui.dialog.labeledElement; } - class radio extends CKEDITOR.ui.dialog.labeledElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); @@ -1543,7 +1444,6 @@ declare namespace CKEDITOR { setValue(value: string, noChangeEvent: boolean): any; // returns void according to doc, but cannot override base class like that } - class select extends uiElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); @@ -1553,12 +1453,10 @@ declare namespace CKEDITOR { remove(index: number): CKEDITOR.ui.dialog.select; } - class textarea extends CKEDITOR.ui.dialog.labeledElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); } - class textInput extends CKEDITOR.ui.dialog.labeledElement { constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); @@ -1613,24 +1511,19 @@ declare namespace CKEDITOR { // NOTE: Static methods are added to dialog module } - namespace dialog { - namespace definition { - interface button extends uiElement { disabled?: boolean; label?: string; } - interface checkbox extends uiElement { default?: string; label?: string; validate?: Function; } - interface content { accessKey?: string; elements?: CKEDITOR.dialog.definition.uiElement[]; @@ -1639,14 +1532,12 @@ declare namespace CKEDITOR { title?: string; } - interface file extends labeledElement { action?: string; size?: string; validate?: Function; } - interface fileButton extends uiElement { filebrowser?: string; for?: string; @@ -1654,7 +1545,6 @@ declare namespace CKEDITOR { styles?: string; } - interface hbox extends uiElement { children?: CKEDITOR.ui.dialog.uiElement[]; height?: number; @@ -1663,12 +1553,10 @@ declare namespace CKEDITOR { widths?: number[]; } - interface html extends uiElement { html?: string; } - interface labeledElement extends uiElement { controlStyle?: string; inputStyle?: string; @@ -1678,25 +1566,20 @@ declare namespace CKEDITOR { widths?: number[]; } - interface radio extends labeledElement { default?: string; - items?: string[] | (string[])[]; + items?: string[] | string[][]; validate?: Function; } - - interface select extends labeledElement { default?: string; - items?: string[] | (string[])[]; + items?: string[] | string[][]; multiple?: boolean; size?: number; validate?: Function; } - - interface textarea extends labeledElement { bidi?: boolean; cols?: number; @@ -1705,7 +1588,6 @@ declare namespace CKEDITOR { validate?: Function; } - interface textInput extends labeledElement { bidi?: boolean; default?: string; @@ -1714,7 +1596,6 @@ declare namespace CKEDITOR { validate?: Function; } - interface uiElement { align?: string; className?: string; @@ -1730,7 +1611,6 @@ declare namespace CKEDITOR { type?: string; } - interface vbox extends uiElement { children?: CKEDITOR.ui.dialog.uiElement[]; expand?: boolean; @@ -1758,6 +1638,7 @@ declare namespace CKEDITOR { } function add(name: string, path: string): void; + // tslint:disable-next-line:unified-signatures function add(name: string, dialogDefinition: (editor: CKEDITOR.editor) => IDialogDefinition): void; function addIframe(name: string, title: string, minWidth: number, minHeight: number, onContentLoad?: Function, userDefinition?: Object): void; function addUIElement(typeName: string, builder: Function): void; @@ -1768,9 +1649,7 @@ declare namespace CKEDITOR { function okButton(): void; } - namespace htmlParser { - class basicWriter { constructor(); openTag(tagName: string, attributes: Object): void; @@ -1784,21 +1663,17 @@ declare namespace CKEDITOR { getHtml(reset: boolean): string; } - class node { constructor(); remove(preserveChildren?: boolean): node; replaceWith(node: node): void; insertAfter(node: node): void; insertBefore(node: node): void; - getAscendant(condition: string): element; - getAscendant(condition: Object): element; - getAscendant(condition: Function): element; + getAscendant(condition: string | Object | Function): element; wrapWith(wrapper: element): element; getIndex(): number; } - class filter { constructor(rules?: filterRulesDefinition); id: number; @@ -1809,35 +1684,27 @@ declare namespace CKEDITOR { textRules: filterRulesGroup; commentRules: filterRulesGroup; rootRules: filterRulesGroup; - addRules(rules: filterRulesDefinition, options?: number): void; - addRules(rules: filterRulesDefinition, options?: { priority?: number; applyToAll?: boolean; }): void; + addRules(rules: filterRulesDefinition, options?: number | { priority?: number; applyToAll?: boolean; }): void; applyTo(node: node): void; } - - interface filterRulesDefinition { - - } - + interface filterRulesDefinition {} class filterRulesGroup { rules: Object[]; - add(rule: Function, priority: number, options: Object): void; - add(rule: Object[], priority: number, options: Object): void; + add(rule: Function | Object[], priority: number, options: Object): void; addMany(rules: Object[], priority: number, options: Object): void; findIndex(priority: number): number; exec(currentValue: Object): any; execOnName(currentName: string): string; } - class cdata extends node { constructor(value: string); type: number; writeHtml(writer: basicWriter): void; } - class comment extends node { constructor(value: string); type: number; @@ -1846,7 +1713,6 @@ declare namespace CKEDITOR { writeHtml(writer: basicWriter, filter: filter): void; } - class element extends node { constructor(name: string, attributes: Object); name: string; @@ -1859,14 +1725,12 @@ declare namespace CKEDITOR { clone(): element; filter(filter: filter): boolean; filterChildren(filter: filter): void; - forEach(callback: (node: node, type?: number) => void|false, type?: number, skipRoot?: boolean): void; + forEach(callback: (node: node, type?: number) => void | false, type?: number, skipRoot?: boolean): void; + forEach(callback: (node: node, type?: number) => boolean): void; writeHtml(writer: basicWriter, filter: filter): void; writeChildrenHtml(writer: basicWriter, filter: filter): void; replaceWithChildren(): void; - forEach(callback: (node: node, type?: number) => boolean): void; - getFirst(condition: string): node; - getFirst(condition: Object): node; - getFirst(condition: Function): node; + getFirst(condition: string | Object | Function): node; getHtml(): string; setHtml(html: string): void; getOuterHtml(): string; @@ -1875,44 +1739,34 @@ declare namespace CKEDITOR { hasClass(className: string): boolean; } - class fragment { constructor(); children: any[]; parent: any; type: number; - static fromHtml(fragmentHtml: string): fragment; - static fromHtml(fragmentHtml: string, parent?: element, fixingBlock?: string): fragment | element; - static fromHtml(fragmentHtml: string, parent: null, fixingBlock?: string): fragment; - static fromHtml(fragmentHtml: string, parent?: string, fixingBlock?: string): fragment | element; - static fromHtml(fragmentHtml: string, parent?: element, fixingBlock?: boolean): fragment | element; - static fromHtml(fragmentHtml: string, parent?: string, fixingBlock?: boolean): fragment | element; + static fromHtml(fragmentHtml: string, parent?: null, fixingBlock?: string): fragment; + static fromHtml(fragmentHtml: string, parent?: element | string, fixingBlock?: string | boolean): fragment | element; add(node: node, index?: number): void; filter(filter: filter): void; filterChildren(filter: filter, filterRoot?: boolean): void; - forEach(callback: (node: node, type?: number) => void|false, type?: number, skipRoot?: boolean): void; + forEach(callback: (node: node, type?: number) => void | boolean, type?: number, skipRoot?: boolean): void; writeHtml(writer: basicWriter, filter?: filter): void; writeChildrenHtml(writer: basicWriter, filter?: filter, filterRoot?: boolean): void; - forEach(callback: (node: node, type?: number) => boolean, type?: number, skipRoot?: boolean): void; } - class cssStyle { constructor(element: element); + // tslint:disable-next-line:unified-signatures constructor(styleText: string); - populate(obj: element): void; - populate(obj: dom.element): void; - populate(obj: Object): void; + populate(obj: element | dom.element | Object): void; } - class text extends node { constructor(value: string); type: number; filter(filter: filter): boolean; writeHtml(writer: basicWriter, filter?: filter): void; } - } class htmlWriter extends htmlParser.basicWriter { @@ -1925,20 +1779,18 @@ declare namespace CKEDITOR { setRules(tagName: string, rules: Object): void; } - namespace tools { var callFunction: Function; function clone(source: Object): Object; function copy(source: Object): Object; function enableHtml5Elements(doc: Object, withAppend?: Boolean): void; - function isArray(object: any|null|undefined): object is T[]; + function isArray(object: any | null | undefined): object is T[]; function override(originalFunction: T, functionBuilder: (originalFunction: T) => T): T; - function parseCssText(styleText: string, normalize?: Boolean, nativeNormalize?: Boolean): { [key: string]: string } + function parseCssText(styleText: string, normalize?: Boolean, nativeNormalize?: Boolean): { [key: string]: string }; function prototypedCopy(source: Object): Object; function writeCssText(style: { [key: string]: string }, sort?: Boolean): string; } - namespace lang { var languages: any; var rtl: any; diff --git a/types/ckeditor/v2/tsconfig.json b/types/ckeditor/v2/tsconfig.json index 5cb7f16ad2..24f16bb1b0 100644 --- a/types/ckeditor/v2/tsconfig.json +++ b/types/ckeditor/v2/tsconfig.json @@ -6,7 +6,7 @@ "dom" ], "noImplicitAny": true, - "noImplicitThis": false, + "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, "baseUrl": "../../", diff --git a/types/ckeditor/v2/tslint.json b/types/ckeditor/v2/tslint.json index a41bf5d19a..ecb79fbcb1 100644 --- a/types/ckeditor/v2/tslint.json +++ b/types/ckeditor/v2/tslint.json @@ -1,79 +1,14 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, "no-unnecessary-generics": false, "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "prefer-const": false } }