/
HtmlSanitizerOptions.ts
78 lines (67 loc) · 2.03 KB
/
HtmlSanitizerOptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import type {
AttributeCallbackMap,
CssStyleCallbackMap,
ElementCallbackMap,
PredefinedCssMap,
StringMap,
} from '../type/htmlSanitizerCallbackTypes';
/**
* Options for HtmlSanitizer
*/
export default interface HtmlSanitizerOptions {
/**
* Callbacks for HTML elements
*/
elementCallbacks?: ElementCallbackMap;
/**
* Callbacks for HTML attributes
*/
attributeCallbacks?: AttributeCallbackMap;
/**
* Callbacks for CSS styles
*/
cssStyleCallbacks?: CssStyleCallbackMap;
/**
* Additional tag replacement, to allow replace a tag to another name, or remove it.
*
* The value can be:
* '*': Keep this element with no change
* '<A valid tag name>: Keep this element but change its tag to the given value
* null: Remove this element
*
* For other unknown tags, we will respect the value of unknownTagReplacement with the same meaning
*/
additionalTagReplacements?: Record<string, string | null>;
/**
* Allowed HTML attributes in addition to default attributes, in lower case
*/
additionalAllowedAttributes?: string[];
/**
* Allowed CSS Class names
*/
additionalAllowedCssClasses?: string[];
/**
* CSS style default values in addition to the default value map, style name should be in lower case
*/
additionalDefaultStyleValues?: StringMap;
/**
* Additional global CSS style nodes
*/
additionalGlobalStyleNodes?: HTMLStyleElement[];
/**
* Additional predefined CSS for element
*/
additionalPredefinedCssForElement?: PredefinedCssMap;
/**
* Preserve HTML comments
*/
preserveHtmlComments?: boolean;
/**
* Define a replacement tag name of unknown tags.
* A star "*" means keep as it is, no replacement
* Other valid string means replace the tag name with this string.
* Empty string, undefined means drop such elements and all its children
* @default undefined
*/
unknownTagReplacement?: string | null;
}