import type { HtmlSanitizerOptions, SanitizeHtmlOptions, StringMap } from 'roosterjs-editor-types'; /** * HTML sanitizer class provides two features: * 1. Convert global CSS to inline CSS * 2. Sanitize an HTML document, remove unnecessary/dangerous attribute/nodes */ export default class HtmlSanitizer { /** * @deprecated Use new HtmlSanitizer().convertGlobalCssToInlineCss() instead * Convert global CSS to inline CSS if any * @param html HTML source * @param additionalStyleNodes (Optional) additional HTML STYLE elements used as global CSS */ static convertInlineCss(html: string, additionalStyleNodes?: HTMLStyleElement[]): string; /** * @deprecated Use new HtmlSanitizer().sanitize() instead * Sanitize HTML string, remove any unused HTML node/attribute/CSS. * @param html HTML source string * @param options Options used for this sanitizing process */ static sanitizeHtml(html: string, options?: SanitizeHtmlOptions): string; private elementCallbacks; private styleCallbacks; private attributeCallbacks; private tagReplacements; private allowedAttributes; private allowedCssClassesRegex; private defaultStyleValues; private additionalPredefinedCssForElement; private additionalGlobalStyleNodes; private preserveHtmlComments; private unknownTagReplacement; /** * Construct a new instance of HtmlSanitizer * @param options Options for HtmlSanitizer */ constructor(options?: HtmlSanitizerOptions); /** * @deprecated Use HtmlSanitizer.convertGlobalCssToInlineCss() and HtmlSanitizer.sanitize() instead * Sanitize HTML string * This function will do the following work: * 1. Convert global CSS into inline CSS * 2. Remove dangerous HTML tags and attributes * 3. Remove useless CSS properties * @param html The input HTML * @param convertInlineCssOnly Whether only convert inline css and skip html content sanitizing * @param currentStyles Current inheritable CSS styles */ exec(html: string, convertCssOnly?: boolean, currentStyles?: StringMap): string; /** * Splits CSS selectors, avoiding splits within parentheses * @param selectorText The CSS selector string * @return Array of trimmed selectors */ private splitSelectors; /** * Sanitize an HTML element, remove unnecessary or dangerous elements/attribute/CSS rules * @param rootNode Root node to sanitize * @param currentStyles Current CSS styles. Inheritable styles in the given node which has * the same value with current styles will be ignored. */ sanitize(rootNode: Node, currentStyles?: StringMap): "" | undefined; /** * Convert global CSS into inline CSS * @param rootNode The HTML Document */ convertGlobalCssToInlineCss(rootNode: ParentNode): void; private processNode; private preprocessCss; private processCss; private processAttributes; private processCssClass; }