sanitize-html.d.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Type definitions for sanitize-html 1.13.0
  2. // Project: https://github.com/punkave/sanitize-html
  3. // Definitions by: Rogier Schouten <https://github.com/rogierschouten>, Afshin Darian <https://github.com/afshin>
  4. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  5. declare function sanitize(dirty: string, options?: sanitize.IOptions): string;
  6. declare namespace sanitize {
  7. type Attributes = { [attr: string]: string };
  8. type Tag = { tagName: string; attribs: Attributes; text?: string; };
  9. type Transformer = (tagName: string, attribs: Attributes) => Tag;
  10. interface IDefaults {
  11. allowedAttributes: { [index: string]: string[] };
  12. allowedSchemes: string[];
  13. allowedSchemesByTag: { [index: string]: string[] };
  14. allowedTags: string[];
  15. selfClosing: string[];
  16. }
  17. interface IFrame {
  18. tag: string;
  19. attribs: { [index: string]: string };
  20. text: string;
  21. tagPosition: number;
  22. }
  23. interface IOptions {
  24. allowedAttributes?: { [index: string]: string[] };
  25. allowedClasses?: { [index: string]: string[] };
  26. allowedSchemes?: string[];
  27. allowedTags?: string[];
  28. exclusiveFilter?: (frame: IFrame) => boolean;
  29. nonTextTags?: string[];
  30. selfClosing?: string[];
  31. transformTags?: { [tagName: string]: string | Transformer };
  32. }
  33. var defaults: IDefaults;
  34. function simpleTransform(tagName: string, attribs: Attributes, merge?: boolean): Transformer;
  35. }
  36. declare module 'sanitize-html' {
  37. export = sanitize;
  38. }