From c4e76e648fea8f8b40416c429d7d6d079ace32d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Wed, 12 Oct 2016 15:02:10 +0200 Subject: [PATCH] CKEditor HTML parser typings (#11616) * test(CKEditor): Add missing tests for htmlParser.basicWriter * feat(CKEditor): Add typings for htmlWriter See related documentation at: http://docs.ckeditor.com/#!/api/CKEDITOR.htmlWriter * feat(CKEditor): Add typings for htmlDataProcessor See related documentation at: http://docs.ckeditor.com/#!/api/CKEDITOR.htmlDataProcessor --- ckeditor/ckeditor-tests.ts | 27 +++++++++++++++++++++++++++ ckeditor/ckeditor.d.ts | 20 ++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/ckeditor/ckeditor-tests.ts b/ckeditor/ckeditor-tests.ts index 97a5c73937..fb3e4a132a 100644 --- a/ckeditor/ckeditor-tests.ts +++ b/ckeditor/ckeditor-tests.ts @@ -336,3 +336,30 @@ function test_focusManager() { var object: CKEDITOR.dom.domObject = focusManager.currentActive; var bool: boolean = focusManager.hasFocus; } + +function test_basicWriter() { + var writer = new CKEDITOR.htmlParser.basicWriter(); + writer.openTag('p', {}); + writer.attribute('class', 'MyClass'); + writer.openTagClose('p', false); + writer.text('Hello'); + writer.closeTag('p'); + alert(writer.getHtml(true)); // '

Hello

' +} + +function test_htmlWriter() { + var writer = new CKEDITOR.htmlWriter(); + writer.openTag('p', {}); + writer.attribute('class', 'MyClass'); + writer.openTagClose('p', false); + writer.text('Hello'); + writer.closeTag('p'); + alert(writer.getHtml(true)); // '

Hello

' + + writer.indentationChars = '\t'; + writer.lineBreakChars = '\r\n'; + writer.selfClosingEnd = '>'; + writer.indentation(); + writer.lineBreak(); + writer.setRules('img', {breakBeforeOpen: true, breakAfterOpen: true}); +} diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts index d43446dd83..72e56cd253 100644 --- a/ckeditor/ckeditor.d.ts +++ b/ckeditor/ckeditor.d.ts @@ -1270,6 +1270,16 @@ declare namespace CKEDITOR { toHtml(data: string, fixForBody?: string): void; } + class htmlDataProcessor { + dataFilter: htmlParser.filter; + htmlFilter: htmlParser.filter; + writer: htmlParser.basicWriter; + + constructor(editor: editor); + toDataFormat(html: string, options?: Object): string; + toHtml(data: string, options?: Object): string; + } + class event { constructor(); @@ -1803,6 +1813,16 @@ declare namespace CKEDITOR { } + class htmlWriter extends htmlParser.basicWriter { + indentationChars: string; + lineBreakChars: string; + selfClosingEnd: string; + + indentation(): void; + lineBreak(): void; + setRules(tagName: string, rules: Object): void; + } + namespace tools { var callFunction: Function;