html_builders.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @license
  3. * SPDX-License-Identifier: Apache-2.0
  4. */
  5. import { SafeHtml } from '../internals/html_impl';
  6. import { TrustedResourceUrl } from '../internals/resource_url_impl';
  7. import { SafeScript } from '../internals/script_impl';
  8. /**
  9. * Returns HTML-escaped text as a `SafeHtml` object.
  10. *
  11. * Available options:
  12. * - `preserveSpaces` turns every second consecutive space character into its
  13. * HTML entity representation (` `).
  14. * - `preserveNewlines` turns newline characters into breaks (`<br>`).
  15. * - `preserveTabs` wraps tab characters in a span with style=white-space:pre.
  16. */
  17. export declare function htmlEscape(text: string, options?: {
  18. preserveNewlines?: boolean;
  19. preserveSpaces?: boolean;
  20. preserveTabs?: boolean;
  21. }): SafeHtml;
  22. /**
  23. * Creates a `SafeHtml` representing a script tag with inline script content.
  24. */
  25. export declare function createScript(script: SafeScript, options?: {
  26. id?: string;
  27. nonce?: string;
  28. type?: string;
  29. }): SafeHtml;
  30. /**
  31. * Creates a `SafeHtml` representing a script tag with the src attribute.
  32. * This also supports CSP nonces and async loading.
  33. */
  34. export declare function createScriptSrc(src: TrustedResourceUrl, async?: boolean, nonce?: string): SafeHtml;
  35. /** Creates a `SafeHtml` value by concatenating multiple `SafeHtml`s. */
  36. export declare function concatHtmls(htmls: readonly SafeHtml[]): SafeHtml;