Updated sanitize-html type definitions for version 1.18.2 (#27676)

* Updated sanitize-html type definitions for version 1.18.2

* Augemented sanitize-html test file
This commit is contained in:
Rinze
2018-07-30 20:07:58 +02:00
committed by Sheetal Nandi
parent 15ec8386fc
commit d0bd4443df
2 changed files with 15 additions and 2 deletions

View File

@@ -1,8 +1,9 @@
// Type definitions for sanitize-html 1.14.1
// Type definitions for sanitize-html 1.18.2
// Project: https://github.com/punkave/sanitize-html
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Afshin Darian <https://github.com/afshin>
// BehindTheMath <https://github.com/BehindTheMath>
// Rinze de Laat <https://github.com/biermeester>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = sanitize;
@@ -38,9 +39,12 @@ declare namespace sanitize {
interface IOptions {
allowedAttributes?: { [index: string]: string[] } | boolean;
allowedStyles?: { [index: string]: { [index: string]: RegExp[] } };
allowedClasses?: { [index: string]: string[] } | boolean;
allowedIframeHostnames?: string[];
allowedSchemes?: string[] | boolean;
allowedSchemesByTag?: { [index: string]: string[] } | boolean;
allowedSchemesAppliedToAttributes?: string[];
allowProtocolRelative?: boolean;
allowedTags?: string[] | boolean;
exclusiveFilter?: (frame: IFrame) => boolean;

View File

@@ -4,8 +4,17 @@ let options: sanitize.IOptions = {
allowedTags: sanitize.defaults.allowedTags.concat('h1', 'h2', 'img'),
allowedAttributes: {
'a': sanitize.defaults.allowedAttributes['a'].concat('rel'),
'img': ['src', 'height', 'width', 'alt']
'img': ['src', 'height', 'width', 'alt', 'style']
},
allowedStyles: {
'*': {
color: [/^red$/],
background: [/^green$/],
'background-color': [/^#0000FF$/]
}
},
allowedIframeHostnames: ['www.youtube.com'],
allowedSchemesAppliedToAttributes: [ 'href', 'src', 'cite' ],
transformTags: {
'a': sanitize.simpleTransform('a', { 'rel': 'nofollow' }),
'img': (tagName: string, attribs: sanitize.Attributes) => {