sanitize-html.d.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Type definitions for sanitize-html 1.12.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; attributes: Attributes; };
  9. type Transformer = (tagName: string, attributes: 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. attributes: { [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. selfClosing?: string[];
  30. transformTags?: { [tagName: string]: string | Transformer };
  31. }
  32. var defaults: IDefaults;
  33. function simpleTransform(tagName: string, attributes: Attributes, merge?: boolean): Transformer;
  34. }
  35. declare module 'sanitize-html' {
  36. export = sanitize;
  37. }