2018-11-23 17:11:50 +01:00
|
|
|
import Module from '../../__module';
|
2020-06-03 10:17:29 +02:00
|
|
|
import { Sanitizer } from '../../../../types/api';
|
|
|
|
import { SanitizerConfig } from '../../../../types/configs';
|
2018-11-23 17:11:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @class SanitizerAPI
|
2019-02-28 12:01:32 +01:00
|
|
|
* Provides Editor.js Sanitizer that allows developers to clean their HTML
|
2018-11-23 17:11:50 +01:00
|
|
|
*/
|
|
|
|
export default class SanitizerAPI extends Module {
|
|
|
|
/**
|
|
|
|
* Available methods
|
2020-06-03 10:17:29 +02:00
|
|
|
*
|
|
|
|
* @returns {Sanitizer}
|
2018-11-23 17:11:50 +01:00
|
|
|
*/
|
2020-06-03 10:17:29 +02:00
|
|
|
public get methods(): Sanitizer {
|
2018-11-23 17:11:50 +01:00
|
|
|
return {
|
2020-06-03 10:17:29 +02:00
|
|
|
clean: (taintString, config): string => this.clean(taintString, config),
|
2018-11-23 17:11:50 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-06-03 10:17:29 +02:00
|
|
|
/**
|
|
|
|
* Perform sanitizing of a string
|
|
|
|
*
|
|
|
|
* @param {string} taintString - what to sanitize
|
|
|
|
* @param {SanitizerConfig} config - sanitizer config
|
|
|
|
*
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
public clean(taintString: string, config: SanitizerConfig): string {
|
2018-11-23 17:11:50 +01:00
|
|
|
return this.Editor.Sanitizer.clean(taintString, config);
|
|
|
|
}
|
|
|
|
}
|