From a78ed230cdd65f906696480288b7350ffdb1332e Mon Sep 17 00:00:00 2001 From: patrick-mackay Date: Thu, 17 Dec 2015 20:04:14 -0300 Subject: [PATCH 1/2] New definition for ngWYSIWYG Interface definitions for an AngularJS wysiwyg component, developed by https://github.com/psergus. I'm not sure what kind of tests can be created for interface definitions. Let me know if more is needed. --- ngwysiwyg/ngwysiwyg-tests.ts | 16 ++++++++++++++++ ngwysiwyg/ngwysiwyg.d.ts | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 ngwysiwyg/ngwysiwyg-tests.ts create mode 100644 ngwysiwyg/ngwysiwyg.d.ts diff --git a/ngwysiwyg/ngwysiwyg-tests.ts b/ngwysiwyg/ngwysiwyg-tests.ts new file mode 100644 index 000000000..92f33c87f --- /dev/null +++ b/ngwysiwyg/ngwysiwyg-tests.ts @@ -0,0 +1,16 @@ +/// + +//import ngWYSIWYG = require("ngWYSIWYG"); + +var options: ngWYSIWYGConfig = { + sanitize: false, + toolbar: [ + { name: "basicStyling", items: ["bold", "italic", "underline", "strikethrough", "subscript", "superscript", "-", "leftAlign", "centerAlign", "rightAlign", "blockJustify", "-"] }, + { name: "paragraph", items: ["orderedList", "unorderedList", "outdent", "indent", "-"] }, + { name: "doers", items: ["removeFormatting", "undo", "redo", "-"] }, + { name: "colors", items: ["fontColor", "backgroundColor", "-"] }, + { name: "links", items: ["image", "hr", "symbols", "link", "unlink", "-"] }, + { name: "tools", items: ["print", "-"] }, + { name: "styling", items: ["font", "size", "format"] }, + ] +}; diff --git a/ngwysiwyg/ngwysiwyg.d.ts b/ngwysiwyg/ngwysiwyg.d.ts new file mode 100644 index 000000000..0289df60e --- /dev/null +++ b/ngwysiwyg/ngwysiwyg.d.ts @@ -0,0 +1,14 @@ +// Type definitions for Marked +// Project: https://github.com/psergus/ngWYSIWYG +// Definitions by: Patrick Mac Kay +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface ngWYSIWYGToolbar { + name: string; + items: string[]; +} + +interface ngWYSIWYGConfig { + sanitize: boolean; + toolbar: ngWYSIWYGToolbar[] +} From 7ca98f443216e1de7fca8d49f2602e1b6b7affbb Mon Sep 17 00:00:00 2001 From: patrick-mackay Date: Thu, 17 Dec 2015 20:36:32 -0300 Subject: [PATCH 2/2] Organization and minor fix Added a module to organize the interfaces. Fix a problem with an optional parameter. Previously was marked as required. --- ngwysiwyg/ngwysiwyg-tests.ts | 6 +++++- ngwysiwyg/ngwysiwyg.d.ts | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ngwysiwyg/ngwysiwyg-tests.ts b/ngwysiwyg/ngwysiwyg-tests.ts index 92f33c87f..c779e918e 100644 --- a/ngwysiwyg/ngwysiwyg-tests.ts +++ b/ngwysiwyg/ngwysiwyg-tests.ts @@ -2,7 +2,7 @@ //import ngWYSIWYG = require("ngWYSIWYG"); -var options: ngWYSIWYGConfig = { +var complete: ngWYSIWYG.Config = { sanitize: false, toolbar: [ { name: "basicStyling", items: ["bold", "italic", "underline", "strikethrough", "subscript", "superscript", "-", "leftAlign", "centerAlign", "rightAlign", "blockJustify", "-"] }, @@ -14,3 +14,7 @@ var options: ngWYSIWYGConfig = { { name: "styling", items: ["font", "size", "format"] }, ] }; + +var partial: ngWYSIWYG.Config = { + sanitize: false +}; diff --git a/ngwysiwyg/ngwysiwyg.d.ts b/ngwysiwyg/ngwysiwyg.d.ts index 0289df60e..9f5ba18ca 100644 --- a/ngwysiwyg/ngwysiwyg.d.ts +++ b/ngwysiwyg/ngwysiwyg.d.ts @@ -3,12 +3,14 @@ // Definitions by: Patrick Mac Kay // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface ngWYSIWYGToolbar { - name: string; - items: string[]; -} +declare module ngWYSIWYG { + export interface Toolbar { + name: string; + items: string[]; + } -interface ngWYSIWYGConfig { - sanitize: boolean; - toolbar: ngWYSIWYGToolbar[] -} + export interface Config { + sanitize: boolean; + toolbar?: Toolbar[]; + } +} \ No newline at end of file