editor.js/types/configs/sanitizer-config.d.ts
Umang G. Patel f659015be6
fix(tools-api): pasteConfig.tags now supports a sanitize config (#2100)
* event handlers function added

* santization config added

* integrate with paste event

* lint removed

* remove old changes

* object based sanitization configuration support

* paste config updated

* logic updated

* extract tag name from paste-config

* tool tags added

* multi tag sanitization added

* the comments added

* lint removed

* Update types/configs/paste-config.d.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* update the changes

* lint removed\

* return empty array by get tags

* submoduble reset

* Update src/components/modules/paste.ts

Co-authored-by: Jorge <46056498+jorgectf@users.noreply.github.com>

* changelog added

* tool comments added

* chore: docs, code comments updated

* fix: xss in processDataTransfer

* base tests added

* test added

* rm 'only' from test suite

* rm log

* reorder test

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
Co-authored-by: Jorge <46056498+jorgectf@users.noreply.github.com>
2022-11-22 00:28:53 +04:00

44 lines
1.1 KiB
TypeScript

/**
* Sanitizer config of each HTML element
* @see {@link https://github.com/guardian/html-janitor#options}
*/
export type TagConfig = boolean | { [attr: string]: boolean | string };
export type SanitizerRule = TagConfig | ((el: Element) => TagConfig)
export interface SanitizerConfig {
/**
* Tag name and params not to be stripped off
* @see {@link https://github.com/guardian/html-janitor}
*
* @example Save P tags
* p: true
*
* @example Save A tags and do not strip HREF attribute
* a: {
* href: true
* }
*
* @example Save A tags with TARGET="_blank" attribute
* a: function (aTag) {
* return aTag.target === '_black';
* }
*
* @example Save U tags that are not empty
* u: function(el){
* return el.textContent !== '';
* }
*
* @example For blockquote with class 'indent' save CLASS and STYLE attributes
* Otherwise strip all attributes
* blockquote: function(el) {
* if (el.classList.contains('indent')) {
* return { 'class': true, 'style': true };
* } else {
* return {};
* }
* }
*/
[key: string]: SanitizerRule;
}