mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add typings for sanitize-html
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/// <reference path="sanitize-html.d.ts" />
|
||||
|
||||
import sanitizeHtml = require('sanitize-html');
|
||||
|
||||
var s: string;
|
||||
var t: string;
|
||||
|
||||
t = sanitizeHtml(s);
|
||||
t = sanitizeHtml(s, {
|
||||
});
|
||||
t = sanitizeHtml(s, {
|
||||
allowedTags: ["a", "br"],
|
||||
allowedSchemes: ["http"],
|
||||
allowedAttributes: { "a": ["href"] },
|
||||
allowedClasses: { "a": ["someclass"] },
|
||||
transformTags: {
|
||||
"a": "b",
|
||||
"br": function(tagName: string, attributes: {[index: string]: string}): { tagName: string; attributes: {[index: string]: string};} {
|
||||
return { tagName: tagName, attributes: attributes };
|
||||
}
|
||||
},
|
||||
exclusiveFilter: {
|
||||
"a": function(frame: {
|
||||
tag: string;
|
||||
attribs: { [index: string]: string };
|
||||
text: string;
|
||||
tagPosition: number;
|
||||
}): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for sanitize-html 1.6.0
|
||||
// Project: https://github.com/punkave/sanitize-html
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
declare module "sanitize-html" {
|
||||
|
||||
function sanitizeHtml(s: string, opts?: {
|
||||
allowedTags?: string[];
|
||||
allowedSchemes?: string[];
|
||||
allowedAttributes?: { [index: string]: string[] };
|
||||
allowedClasses?: { [index: string]: string[] };
|
||||
transformTags?: { [index: string]: any };
|
||||
exclusiveFilter?: {
|
||||
[index: string]: (frame: {
|
||||
tag: string;
|
||||
attribs: { [index: string]: string };
|
||||
text: string;
|
||||
tagPosition: number;
|
||||
}) => boolean
|
||||
};
|
||||
|
||||
}): string;
|
||||
|
||||
export = sanitizeHtml;
|
||||
}
|
||||
Reference in New Issue
Block a user