mirror of
https://github.com/codex-team/editor.js
synced 2024-06-08 08:52:15 +02:00
f659015be6
* 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>
44 lines
1.1 KiB
TypeScript
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;
|
|
}
|