diff --git a/types/ckeditor/ckeditor-tests.ts b/types/ckeditor/ckeditor-tests.ts index d849b52a4a..a6f9c9cf5c 100644 --- a/types/ckeditor/ckeditor-tests.ts +++ b/types/ckeditor/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(true).getType() == CKEDITOR.SELECTION_ELEMENT) - if (editor.getSelection(false).getType() == CKEDITOR.SELECTION_NONE) - if (editor.getSelection(true).getType() == CKEDITOR.SELECTION_TEXT) + var editor: CKEDITOR.editor = new CKEDITOR.editor(); + if (editor.getSelection(true).getType() === CKEDITOR.SELECTION_ELEMENT) + if (editor.getSelection(false).getType() === CKEDITOR.SELECTION_NONE) + if (editor.getSelection(true).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); @@ -29,15 +27,16 @@ function test_CKEDITOR() { CKEDITOR.inline('content'); if (CKEDITOR.loadFullCore) CKEDITOR.loadFullCore(); - CKEDITOR.replace('myfield'); + var textarea = document.createElement('textarea'); + CKEDITOR.replace('myfield'); CKEDITOR.replace(textarea); CKEDITOR.replaceAll(); CKEDITOR.replaceAll('myClassName'); CKEDITOR.replaceAll((textarea, config) => false); - var editor: CKEDITOR.editor = CKEDITOR.appendTo('append here', CKEDITOR.config, 'data'); - var editor: CKEDITOR.editor = CKEDITOR.appendTo(document.createElement('div')); + editor = CKEDITOR.appendTo('append here', CKEDITOR.config, 'data'); + editor = CKEDITOR.appendTo(document.createElement('div')); CKEDITOR.error('code'); CKEDITOR.error('500', { moreData: true }); CKEDITOR.warn('danger'); @@ -45,7 +44,7 @@ function test_CKEDITOR() { } function test_CKEDITOR_events() { - CKEDITOR.on('instanceCreated', function(event) { + CKEDITOR.on('instanceCreated', (event) => { // $ExpectType editor event.editor; }); @@ -82,7 +81,7 @@ function test_config() { { name: 'styles', groups: [ 'styles' ] }, { name: 'colors', groups: [ 'colors' ] }, ], - } + }; } function test_dom_comment() { @@ -96,13 +95,13 @@ function test_dom_comment() { function test_dom_document() { var document = new CKEDITOR.dom.document(window.document); - var type = CKEDITOR.NODE_DOCUMENT; + var type: number = CKEDITOR.NODE_DOCUMENT; CKEDITOR.document.appendStyleSheet('/mystyles.css'); - var element = CKEDITOR.document.getBody(); + var element: CKEDITOR.dom.element = CKEDITOR.document.getBody(); alert(element.getName()); - var element2 = CKEDITOR.document.getById('myElement'); + element = CKEDITOR.document.getById('myElement'); alert(element.getId()); - var element3 = CKEDITOR.document.getHead(); + element = CKEDITOR.document.getHead(); alert(element.getName()); var selection = CKEDITOR.instances[0].document.getSelection(); alert(selection.getType()); @@ -113,10 +112,10 @@ function test_dom_document() { '' ); var styles: CSSStyleSheet = document.appendStyleText('some styles'); - var element: CKEDITOR.dom.element = document.createElement('div'); - var element2: CKEDITOR.dom.element = document.createElement('div', { styles: { height: '1234' } }); - var element3: CKEDITOR.dom.element = document.createElement('div', { attributes: { id: '1234' } }); - var element4: CKEDITOR.dom.element = document.createElement('div', { attributes: { tabIndex: '1234' }, styles: { width: '1234' } }); + element = document.createElement('div'); + element = document.createElement('div', { styles: { height: '1234' } }); + element = document.createElement('div', { attributes: { id: '1234' } }); + element = document.createElement('div', { attributes: { tabIndex: '1234' }, styles: { width: '1234' } }); } function test_dom_documentFragment() { @@ -130,7 +129,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')); @@ -153,7 +152,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); @@ -164,7 +163,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(''); @@ -177,7 +176,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()); @@ -198,7 +197,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'); @@ -214,20 +213,20 @@ 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()); var dtd: CKEDITOR.dtdDefinition = element.getDtd(); var last: CKEDITOR.dom.node = element.getLast(); var last2: CKEDITOR.dom.node = element.getLast((node: CKEDITOR.dom.node) => node.equals(document.body)); - if (element.isBlockBoundary({ 'div': 1, 'span': 1 })) { + if (element.isBlockBoundary({ div: 1, span: 1 })) { element.setState(1, 'hex', false); } CKEDITOR.dom.element.clearMarkers({}, element, true); var element1: CKEDITOR.dom.element = CKEDITOR.dom.element.get('div'); - var element2: CKEDITOR.dom.element = CKEDITOR.dom.element.get(document.createElement('div')); + var element6: CKEDITOR.dom.element = CKEDITOR.dom.element.get(document.createElement('div')); var element3: CKEDITOR.dom.element = CKEDITOR.dom.element.get(element2); var markedElement: CKEDITOR.dom.element = CKEDITOR.dom.element.setMarker({}, element, 'key', 0); } @@ -242,20 +241,20 @@ function test_dom_elementPath() { 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(); }); @@ -266,7 +265,7 @@ function test_dom_iterator() { var iterator = range.createIterator(); var paragrah1: CKEDITOR.dom.element = iterator.getNextParagraph(); var paragrah2: CKEDITOR.dom.element = iterator.getNextParagraph('div'); - alert(iterator.forceBrBreak === false); + alert(!iterator.forceBrBreak); var itRange: CKEDITOR.dom.range = iterator.range; } @@ -335,7 +334,7 @@ function test_dom_selection() { element = selection.getSelectedElement(); var text: string = selection.getSelectedText(); element = selection.getStartElement(); - + var type: number = selection.getType(); var isSomething: boolean = selection.isCollapsed(); @@ -361,18 +360,18 @@ function test_dom_walker() { var range: CKEDITOR.dom.range = new CKEDITOR.dom.range(element); var walker: CKEDITOR.dom.walker = new CKEDITOR.dom.walker(range); - + var isSomething: boolean = walker.checkBackward(); isSomething = walker.checkForward(); walker.end(); - + var node: CKEDITOR.dom.node = walker.lastBackward(); node = walker.lastForward(); node = walker.next(); node = walker.previous(); walker.reset(); - isSomething = CKEDITOR.dom.walker.blockBoundary({ 'div': 1 })(node); + isSomething = CKEDITOR.dom.walker.blockBoundary({ div: 1 })(node); isSomething = CKEDITOR.dom.walker.bogus()(node); isSomething = CKEDITOR.dom.walker.bogus(isSomething)(node); isSomething = CKEDITOR.dom.walker.bookmark()(node); @@ -471,8 +470,8 @@ function test_dialog() { dialog.showPage('1234'); dialog.updateStyle(); - CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' ); - CKEDITOR.dialog.add( 'abbrDialog', function ( editor: CKEDITOR.editor ) { + CKEDITOR.dialog.add('abbrDialog', 'PATH/dialogs/abbr.js'); + CKEDITOR.dialog.add('abbrDialog', (editor: CKEDITOR.editor) => { return { title: 'Abbreviation Properties', minWidth: 400, @@ -486,7 +485,7 @@ function test_dialog() { { id: 'tab-basic', label: 'Basic Settings', - elements: [] + elements: [] }, { id: 'tab-adv', @@ -566,7 +565,7 @@ function test_fileTools_fileLoader() { var loader: CKEDITOR.fileTools.fileLoader = new CKEDITOR.fileTools.fileLoader(editor, 'data'); loader = new CKEDITOR.fileTools.fileLoader(editor, blob); loader = new CKEDITOR.fileTools.fileLoader(editor, blob, 'name'); - + loader.abort(); var finished: boolean = loader.isFinished(); loader.load(); @@ -582,7 +581,7 @@ function test_fileTools_uploadRepository() { var editor: CKEDITOR.editor; var blob: Blob; var repo: CKEDITOR.fileTools.uploadRepository = new CKEDITOR.fileTools.uploadRepository(editor); - + var loader: CKEDITOR.fileTools.fileLoader = repo.create('data', 'name'); loader = repo.create(blob, 'name', 'type'); @@ -603,7 +602,7 @@ function test_filter() { filter.addElementCallback((el: CKEDITOR.htmlParser.element) => 4); filter.addFeature({ allowedContent: style }); filter.addTransformations([ [ 'transform1', { right: (element: CKEDITOR.htmlParser.element, tools: string | CKEDITOR.filter.transformationTools) => true } ] ]); - + var allowed: boolean = filter.allow(style); allowed = filter.allow([style], 'name'); allowed = filter.allow('rule', 'name', false); @@ -645,7 +644,6 @@ function test_focusManager() { var bool: boolean = focusManager.hasFocus; } - function test_htmlParser_basicWriter() { var writer = new CKEDITOR.htmlParser.basicWriter(); writer.attribute('class', 'MyClass'); @@ -680,12 +678,12 @@ function test_htmlParser_cssStyle() { style.populate(element); style.populate(new CKEDITOR.dom.element('div')); - style.populate({ 'width': 1 }); + style.populate({ width: 1 }); } function test_htmlParser_element() { - var element: CKEDITOR.htmlParser.element = new CKEDITOR.htmlParser.element('el', { 'id': '1'}); - + var element: CKEDITOR.htmlParser.element = new CKEDITOR.htmlParser.element('el', { id: '1'}); + var node: CKEDITOR.htmlParser.node; element.add(node); element.add(node, 5); @@ -703,8 +701,8 @@ function test_htmlParser_element() { element.forEach((el: CKEDITOR.htmlParser.node) => console.log('node'), 1); element.forEach((el: CKEDITOR.htmlParser.node) => false, 2, true); - var node: CKEDITOR.htmlParser.node = element.getFirst('*'); - node = element.getFirst({ 'id': '1' }); + node = element.getFirst('*'); + node = element.getFirst({ id: '1' }); node = element.getFirst((el: CKEDITOR.htmlParser.node) => true); var html: string = element.getHtml(); @@ -728,7 +726,7 @@ function test_htmlParser_filter() { filter = new CKEDITOR.htmlParser.filter(); filter.addRules({ text: 'text' }); - filter.addRules({ attributes: { 'id': '1234' }}, 1); + filter.addRules({ attributes: { id: '1234' }}, 1); filter.addRules({ comment: 'hey', text: 'text' }, { priority: 1 }); filter.addRules({ root: document.body }, { applyToAll: false }); @@ -736,7 +734,6 @@ function test_htmlParser_filter() { filter.applyTo(node); } - function test_htmlParser_filterRulesGroup() { var rules: CKEDITOR.htmlParser.filterRulesGroup = new CKEDITOR.htmlParser.filterRulesGroup(); @@ -786,7 +783,7 @@ function test_htmlParser_node() { var node: CKEDITOR.htmlParser.node = new CKEDITOR.htmlParser.node(); var el: CKEDITOR.htmlParser.element = node.getAscendant('condition'); - el = node.getAscendant({ 'id': '1234' }); + el = node.getAscendant({ id: '1234' }); el = node.getAscendant((node: CKEDITOR.htmlParser.element) => false); var idx: number = node.getIndex(); @@ -795,7 +792,6 @@ function test_htmlParser_node() { node.remove(); node.replaceWith(node); el = node.wrapWith(el); - } function test_htmlParser_text() { @@ -825,9 +821,9 @@ function test_htmlWriter() { 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); }); } @@ -836,13 +832,13 @@ function test_htmlParser() { function test_keystrokeHandler() { var handler: CKEDITOR.keystrokeHandler = new CKEDITOR.keystrokeHandler(CKEDITOR.instances[0]); - handler.attach(new CKEDITOR.dom.domObject(document.body)); + handler.attach(new CKEDITOR.dom.domObject(document.body)); } function test_lang() { var lang: string = CKEDITOR.lang.detect('en'); lang = CKEDITOR.lang.detect('zh', 'sw'); - + CKEDITOR.lang.load('tk', 'pr', (code: string, entries: any) => console.log('loaded')); } @@ -869,8 +865,8 @@ function test_menu() { } function test_plugins() { - CKEDITOR.plugins.add( 'abbr', { - init: function( editor: CKEDITOR.editor ) { + CKEDITOR.plugins.add('abbr', { + init: (editor: CKEDITOR.editor) => { // empty logic } }); @@ -921,7 +917,7 @@ function test_skin() { } function test_style() { - var style: CKEDITOR.style = new CKEDITOR.style({ element: 'div' }, { 'key': 'value '}); + var style: CKEDITOR.style = new CKEDITOR.style({ element: 'div' }, { key: 'value '}); style.apply(CKEDITOR.instances[0]); var el: CKEDITOR.dom.element; @@ -945,7 +941,7 @@ function test_style() { var def: CKEDITOR.style.definition = style.getDefintion(); style.remove(CKEDITOR.instances[0]); style.removeFromRange(range, CKEDITOR.instances[0]); - + var rules: CKEDITOR.filter.allowedContentRules; rules = style.toAllowedContentRules(); rules = style.toAllowedContentRules(CKEDITOR.instances[0]); @@ -955,14 +951,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', @@ -970,7 +966,7 @@ function test_adding_command_and_buttons() { toolbar: 'tools' }); - instance.ui.addButton( 'secondButton', { + instance.ui.addButton('secondButton', { label: 'Label 2', command: 'aCommand', toolbar: 'tools' @@ -983,7 +979,7 @@ function test_adding_widget() { button: "Activate widgetty", template: "", dialog: "widgetty", - init: function() { + init: () => { // no logic } }); @@ -1012,80 +1008,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: () => {} } }); } @@ -1151,7 +1147,7 @@ function test_tools() { var str = CKEDITOR.tools.cssStyleToDomStyle('style'); var prefixes: { [cssClass: string]: string | number } = CKEDITOR.tools.cssVendorPrefix('prop', 'val'); prefixes = CKEDITOR.tools.cssVendorPrefix('prop', 'val', true); - var fn: (param: any) => boolean + var fn: (param: any) => boolean; fn = CKEDITOR.tools.defer<(param: any) => boolean>(fn); CKEDITOR.tools.enableHtml5Elements(document); CKEDITOR.tools.enableHtml5Elements(document.createDocumentFragment(), true); @@ -1172,7 +1168,7 @@ function test_tools() { str = CKEDITOR.tools.htmlEncode(str); str = CKEDITOR.tools.htmlEncodeAttr(str); numb = CKEDITOR.tools.indexOf(['string', 'array'], 'string'); - numb = CKEDITOR.tools.indexOf([true, false], (val: boolean) => false); + numb = CKEDITOR.tools.indexOf([true, false], (val: boolean) => false); console.log(CKEDITOR.tools.isArray([1])); // true console.log(CKEDITOR.tools.isArray(obj)); // false console.log(CKEDITOR.tools.isArray(null)); // false @@ -1186,8 +1182,8 @@ function test_tools() { bool = CKEDITOR.tools.objectCompare(obj, obj); bool = CKEDITOR.tools.objectCompare(obj, obj, true); var strArr: string[] = CKEDITOR.tools.objectKeys(obj); - 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); }; }); diff --git a/types/ckeditor/index.d.ts b/types/ckeditor/index.d.ts index 53760a7610..fb7fe92088 100644 --- a/types/ckeditor/index.d.ts +++ b/types/ckeditor/index.d.ts @@ -6,12 +6,12 @@ // 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 replaceClass: string; @@ -131,12 +131,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; @@ -210,8 +209,7 @@ declare namespace CKEDITOR { readonly $: HTMLElement; readonly type: number; - constructor(element: string, ownerDocument?: document); - constructor(element: HTMLElement, ownerDocument?: document); + constructor(element: string | HTMLElement, ownerDocument?: document); addClass(className: string): void; append(node: node | string, toStart?: boolean): node; appendBogus(force: boolean): void; @@ -273,8 +271,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: { [key: string]: string }): element; @@ -289,7 +286,7 @@ declare namespace CKEDITOR { show(): void; unselectable(): void; - //static method + // static method static clearAllMarkers(database: any): any; static clearMarkers(database: any, element: dom.element, removeFromDatabase: boolean): void; static createFromHtml(html: string): element; @@ -437,8 +434,8 @@ declare namespace CKEDITOR { } interface shrinkOptions { - shrinkOnBlockBoundary?: boolean, - skipBogus?: boolean + shrinkOnBlockBoundary?: boolean; + skipBogus?: boolean; } class rangeList { @@ -449,7 +446,6 @@ declare namespace CKEDITOR { moveToBookmarks(bookmarks: bookmark[]): void; } - interface rangeListIterator { getNextRange(mergeConsequent?: boolean): range; } @@ -481,7 +477,7 @@ declare namespace CKEDITOR { removeAllRanges(): void; reset(): void; scrollIntoView(): void; - selectBookmarks(bookmarks: (bookmark | bookmark2)[]): selection; + selectBookmarks(bookmarks: Array): selection; selectElement(element: element): void; selectRanges(ranges: range[]): void; unlock(restore: boolean): void; @@ -547,14 +543,12 @@ declare namespace CKEDITOR { } } - namespace ajax { function load(url: string, callback?: (data: any) => void): string; function loadXml(url: string, callback?: (data: any) => void): xml; function post(url: string, data: any, contentType?: string, callback?: (data: any) => void): void; } - class command extends event implements commandDefinition { fakeKeystroke: number; previousState: number; @@ -570,7 +564,6 @@ declare namespace CKEDITOR { refresh(editor: editor, path: dom.elementPath): void; setState(newState: number): boolean; toggleState(): void; - } interface commandDefinition { @@ -737,7 +730,7 @@ declare namespace CKEDITOR { jqueryOverrideVal?: boolean; justifyClasses?: string[]; - keystrokes?: [number, string][]; + keystrokes?: Array<[number, string]>; language?: string; language_list?: string[]; @@ -745,7 +738,7 @@ declare namespace CKEDITOR { linkShowAdvancedTab?: boolean; linkShowTargetTab?: boolean; - magicline_color?: string + magicline_color?: string; magicline_everywhere?: boolean; magicline_holdDistance?: number; magicline_keystrokeNext?: number; @@ -822,7 +815,7 @@ declare namespace CKEDITOR { smiley_images?: string[]; smiley_path?: string; sourceAreaTabSize?: number; - specialChars?: (string | [string, string])[]; + specialChars?: Array; startupFocus?: string | boolean; startupMode?: string; startupOutlineBlocks?: boolean; @@ -837,10 +830,10 @@ declare namespace CKEDITOR { templates_files?: { [key: string]: any }; 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; @@ -914,9 +907,7 @@ declare namespace CKEDITOR { } namespace dialog { - namespace definition { - interface button extends uiElement { disabled?: boolean; } @@ -968,13 +959,13 @@ declare namespace CKEDITOR { interface radio extends labeledElement { default?: string; - items?: string[] | (string[])[]; + items?: string[] | string[][]; validate?: () => boolean; } interface select extends labeledElement { default?: string; - items?: string[] | (string[])[]; + items?: string[] | string[][]; multiple?: boolean; size?: number; validate?: () => boolean; @@ -1172,7 +1163,7 @@ declare namespace CKEDITOR { setActiveFilter(filter: filter): void; setData(data: string, options?: { internal?: boolean; callback?: () => void; noSnapshot?: boolean; }): void; setKeystroke(keystroke: number, behavior: string | boolean): void; - setKeystroke(keystroke: [number, string | boolean][]): void; + setKeystroke(keystroke: Array<[number, string | boolean]>): void; setMode(newMode: string, callback: () => void): void; setReadOnly(isReadOnly?: boolean): void; setUiColor(color: string): void; @@ -1432,7 +1423,7 @@ declare namespace CKEDITOR { readonly disabled: boolean; readonly disallowedContent: any[]; readonly editor: editor; - readonly elementCallbacks: ((element: htmlParser.element) => number)[]; + readonly elementCallbacks: Array<(element: htmlParser.element) => number>; readonly id: number; static instances: { [id: string]: filter }; @@ -1441,7 +1432,7 @@ declare namespace CKEDITOR { addContentForms(forms: any[]): void; addElementCallback(callback: (element: htmlParser.element) => number): void; addFeature(feature: feature): boolean; - addTransformations(transformations: (string | filter.transformation)[][]): void; + addTransformations(transformations: Array>): void; allow(newRules: filter.allowedContentRules, featureName?: string, overrideCustom?: boolean): boolean; applyTo(fragment: htmlParser.fragment | htmlParser.element, toHrml: boolean, transformOnly: boolean, enterMode: number): boolean; check(test: filter.contentRule, applyTransformations?: boolean, strictCheck?: boolean): boolean; @@ -1571,10 +1562,10 @@ declare namespace CKEDITOR { } class filterRulesGroup { - rules: { value: rule, priority: number, option: ruleOptions }[]; + rules: Array<{ value: rule, priority: number, option: ruleOptions }>; add(rule: rule, priority: number, options: ruleOptions): void; - addMany(rules: { [key: string]: any }[], priority: number, options: ruleOptions): void; + addMany(rules: Array<{ [key: string]: any }>, priority: number, options: ruleOptions): void; exec(currentValue: htmlParser.node | htmlParser.fragment | string): htmlParser.node | htmlParser.fragment | string; execOnName(currentName: string): string; findIndex(priority: number): number; @@ -1612,8 +1603,8 @@ declare namespace CKEDITOR { type rule = ((value: htmlParser.node | htmlParser.fragment | string) => boolean) | [string, string]; interface ruleOptions { - applyToAll?: boolean, - excludeNestedEditable?: boolean + applyToAll?: boolean; + excludeNestedEditable?: boolean; } class text extends node { @@ -1682,7 +1673,6 @@ declare namespace CKEDITOR { } namespace plugins { - namespace cloudservices { class cloudServicesLoader extends fileTools.fileLoader { customToken: string; @@ -1778,7 +1768,7 @@ declare namespace CKEDITOR { highlighter: (code: string, lang: string, callback: (highlightedCode: string) => void) => void; init: (ready: () => void) => void; languages: { [lang: string]: string }; - readonly queue: ((code: string, lang: string, callback: (highlightedCode: string) => void) => void)[]; + readonly queue: Array<(code: string, lang: string, callback: (highlightedCode: string) => void) => void>; readonly ready: boolean; highlight(code: string, lang: string, callback: (highlightedCode: string) => void): void; @@ -1809,9 +1799,7 @@ declare namespace CKEDITOR { } } - namespace easyimage { - - } + namespace easyimage {} namespace embedBase { function createWidgetBaseDefinition(editor: editor): baseDefinition; @@ -1856,9 +1844,7 @@ declare namespace CKEDITOR { class progressBar extends progressReporter { bar: dom.element; - constructor(); - } class progressReporter { @@ -1922,7 +1908,7 @@ declare namespace CKEDITOR { const synAnchorSelector: boolean; function getEditorAnchors(editor: editor): dom.element[]; - function getLinkAttributes(editor: editor, data: { [key: string]: any }): { set: { [key: string]: string }, removed: string[] } + function getLinkAttributes(editor: editor, data: { [key: string]: any }): { set: { [key: string]: string }, removed: string[] }; function getSelectedLink(editor: editor, returnMultiple?: boolean): dom.element | dom.element[]; function parseLinkAttributes(editor: editor, element: dom.element): { [key: string]: any }; function showDisplayTextForElement(element: dom.element, editor: editor): boolean; @@ -2057,7 +2043,6 @@ declare namespace CKEDITOR { setData(data: string): void; } - interface definition extends feature { button?: string; data?: (evt: eventInfo) => void; @@ -2100,8 +2085,7 @@ declare namespace CKEDITOR { destroyAll(offline?: boolean): void; finalizeCreation(container: any): void; getByElement(element: any, checkWrapperOnly: boolean): plugins.widget; - initOn(element: dom.element, widgetDef?: plugins.widget.definition, startupData?: { [key: string]: any }): plugins.widget; - initOn(element: dom.element, widgetDef?: string, startupData?: { [key: string]: any }): plugins.widget; + initOn(element: dom.element, widgetDef?: string | plugins.widget.definition, startupData?: { [key: string]: any }): plugins.widget; initOnAll(container?: dom.element): plugins.widget[]; parseElementClasses(classes: string): any; wrapElement(element: any, widgetName?: string): any; @@ -2118,7 +2102,7 @@ declare namespace CKEDITOR { readonly definition: plugins.widget.definition; readonly editor: editor; readonly element: dom.element; - readonly focusedEditable: plugins.widget.nestedEditable + readonly focusedEditable: plugins.widget.nestedEditable; readonly id: number; readonly inited: boolean; readonly ready: boolean; @@ -2147,8 +2131,7 @@ declare namespace CKEDITOR { updateDragHandlerPosition(): void; } - function add(name: string, definition: pluginDefinition): void; - function add(name: string): void; + function add(name: string, definition?: pluginDefinition): void; function addExternal(name: string, path: string, fileName?: string): void; function get(name: string): any; function getFilePath(name: string): string; @@ -2182,6 +2165,7 @@ declare namespace CKEDITOR { namespace skin { var icons: { [name: string]: { path: string } }; + // tslint:disable-next-line:no-duplicate-variable var name: string; var ua: { [name: string]: any }; @@ -2209,11 +2193,11 @@ declare namespace CKEDITOR { } interface definition { - attributes?: { [att: string]: string }, - element: string, - name?: string, - styles?: { [att: string]: string }, - type?: string | number + attributes?: { [att: string]: string }; + element: string; + name?: string; + styles?: { [att: string]: string }; + type?: string | number; } interface customHandler { @@ -2414,13 +2398,13 @@ declare namespace CKEDITOR { interface radio { default: any; validate?: () => boolean; - items: ([string, string] | [string])[]; + items: Array<[string, string] | [string]>; } interface select { default: any; validate?: () => boolean; - items: ([string, string] | [string])[]; + items: Array<[string, string] | [string]>; multiple?: boolean; size?: number; } @@ -2462,7 +2446,6 @@ declare namespace CKEDITOR { constructor(dialog: dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: definitions.fieldSet); } - class file extends ui.dialog.labeledElement { constructor(dialog: dialog, elementDefinition: definitions.file, htmlList: any[]); @@ -2473,12 +2456,10 @@ declare namespace CKEDITOR { submit(): file; } - class fileButton extends button { constructor(dialog: dialog, elementDefinition: definitions.fileButton, htmlList: any[]); } - class hbox extends uiElement { constructor(dialog: dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: definitions.hbox); @@ -2486,17 +2467,11 @@ declare namespace CKEDITOR { getChild(indices: number[]): ui.dialog.uiElement[]; } - class html extends uiElement { constructor(dialog: dialog, elementDefinition: definitions.html, htmlList: any[]); - - } - - - class iframeElement extends uiElement { - } + class iframeElement extends uiElement {} class labeledElement extends uiElement { constructor(dialog: dialog, elementDefinition: definitions.labeledElement, htmlList: any[], contentHtml: () => string); @@ -2505,7 +2480,6 @@ declare namespace CKEDITOR { setlabel(label: string): ui.dialog.labeledElement; } - class radio extends ui.dialog.labeledElement { constructor(dialog: dialog, elementDefinition: definitions.radio, htmlList: any[]); @@ -2514,7 +2488,6 @@ declare namespace CKEDITOR { setValue(value: string, noChangeEvent: boolean): undefined; } - class select extends uiElement { constructor(dialog: dialog, elementDefinition: definitions.select, htmlList: any[]); @@ -2523,12 +2496,10 @@ declare namespace CKEDITOR { remove(index: number): select; } - class textarea extends labeledElement { constructor(dialog: dialog, elementDefinition: definitions.textarea, htmlList: any[]); } - class textInput extends ui.dialog.labeledElement { constructor(dialog: dialog, elementDefinition: definitions.textInput, htmlList: any[]); @@ -2544,7 +2515,16 @@ declare namespace CKEDITOR { class uiElement { eventProcessors: any; - constructor(dialog: dialog, elementDefinition: definitions.uiElement, htmlList: any[], nodeNameArg?: () => string | string, stylesArg?: () => { [key: string]: any } | { [key: string]: any }, attributesArg?: () => { [key: string]: any } | { [key: string]: any }, contentsArg?: () => { [key: string]: any } | string); // Not sure that the htmlList array type is right. + // Not sure that the htmlList array type is right. + constructor( + dialog: dialog, + elementDefinition: definitions.uiElement, + htmlList: any[], + nodeNameArg?: () => string | string, + stylesArg?: () => { [key: string]: any } | { [key: string]: any }, + attributesArg?: () => { [key: string]: any } | { [key: string]: any }, + contentsArg?: () => { [key: string]: any } | string + ); accessKeyDown(dialog: dialog, key: string): void; accessKeyUp(dialog: dialog, key: string): void; @@ -2692,9 +2672,7 @@ declare namespace CKEDITOR { create(definition: { [key: string]: any }): T; } - class menuButton extends button { - - } + class menuButton extends button {} class panel { constructor(document: dom.document, definition: { [key: string]: any }); @@ -2713,9 +2691,7 @@ declare namespace CKEDITOR { const handler: handlerDefinition; } - class panelButton extends button { - - } + class panelButton extends button {} class richCombo { static readonly handler: handlerDefinition; @@ -2753,11 +2729,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; } interface buttonDefinition { diff --git a/types/ckeditor/tsconfig.json b/types/ckeditor/tsconfig.json index e845e96c0a..8f9fa0829d 100644 --- a/types/ckeditor/tsconfig.json +++ b/types/ckeditor/tsconfig.json @@ -6,7 +6,7 @@ "dom" ], "noImplicitAny": true, - "noImplicitThis": false, + "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, "baseUrl": "../", diff --git a/types/ckeditor/tslint.json b/types/ckeditor/tslint.json index a41bf5d19a..ecb79fbcb1 100644 --- a/types/ckeditor/tslint.json +++ b/types/ckeditor/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 } } 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 } }