1.0.2 • Published 2 years ago
@sika7/silver-html-plugin-sanitize v1.0.2
@sika7/silver-html-plugin-sanitize
this package is silver-html plugin
Usage
Step 1: Install plugin:
npm install --save @sika7/silver-html
npm install --save @sika7/silver-html-plugin-sanitize
Step 2: add a functions or plugin.
import { silverHtml } from '@sika7/silver-html'
import { silverHtmlSanitize } from "@sika7/silver-html-plugin-sanitize";
const result = silverHtml("<div><p>test</p><div>test</div></div>", {}, [
silverHtmlSanitize({
allowTags: [
{
tag: "div",
allowAttrs: ["class", "style"],
allowStyle: ["color"],
},
],
})]);
console.log(result)
// # <div><div>test</div></div>
config
const plugin = {
allowTags: [
{
tag: "div", // require
allowAttrs: ["class", "style"], // options
allowStyle: ["color"], // options
},
]
}
setting | description | example |
---|---|---|
tag | allow tag name. | div |
allowAttrs | allow attributes. | 'class','style' |
allowStyle | allow styles. require style in allowAttrs. | 'color','text-align' |