mirror of
https://github.com/codex-team/editor.js
synced 2024-05-23 00:32:28 +02:00
a88dc8e30b
* refactoring(modules): sanitizer module is util now * Remove Sanitizer from Editor modules signature * Bind context to config composition method * Make sanitizer singletone * Make sanitizer a module instead of class * Fix * Add test cases for default values * Fix inline tools default value * Move inline tools and block tunes to BlockTool instance * Fixes after review & some test cases for sanitisation * Upgrade test case Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
34 lines
880 B
TypeScript
34 lines
880 B
TypeScript
import { Sanitizer as ISanitizer } from '../../../../types/api';
|
|
import { SanitizerConfig } from '../../../../types/configs';
|
|
import Module from '../../__module';
|
|
import { clean } from '../../utils/sanitizer';
|
|
|
|
/**
|
|
* @class SanitizerAPI
|
|
* Provides Editor.js Sanitizer that allows developers to clean their HTML
|
|
*/
|
|
export default class SanitizerAPI extends Module {
|
|
/**
|
|
* Available methods
|
|
*
|
|
* @returns {Sanitizer}
|
|
*/
|
|
public get methods(): ISanitizer {
|
|
return {
|
|
clean: (taintString, config): string => this.clean(taintString, config),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* 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 {
|
|
return clean(taintString, config);
|
|
}
|
|
}
|