Fix SanitizerConfig type definition (#1456)

* Fix SanitizerConfig type definition

* Update docs/CHANGELOG.md

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

* Fix CHANGELOG

* Add JSDoc to TagConfig

* yarn lint:fix

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com>
This commit is contained in:
Tomoyuki Hata 2021-03-02 22:34:23 +09:00 committed by GitHub
parent 2759b25d35
commit a67e699991
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View file

@ -13,6 +13,7 @@
- `Fix` - Fix an unstable block cut process [#1489](https://github.com/codex-team/editor.js/issues/1489).
- `Fix` - Type definition of the Sanitizer config: the sanitize function now contains param definition [#1491](https://github.com/codex-team/editor.js/pull/1491).
- `Fix` - Fix unexpected behavior on an empty link pasting [#1348](https://github.com/codex-team/editor.js/issues/1348).
- `Fix` - Fix SanitizerConfig type definition [#1513](https://github.com/codex-team/editor.js/issues/1513)
- `Refactoring` - The Listeners module now is a util.
- `Fix` - Editor Config now immutable [#1552](https://github.com/codex-team/editor.js/issues/1552).

View file

@ -3,9 +3,15 @@
* After that we can use it at the TS modules
*/
declare module 'html-janitor' {
/**
* Sanitizer config of each HTML element
* @see {@link https://github.com/guardian/html-janitor#options}
*/
type TagConfig = boolean | { [attr: string]: boolean | string };
interface Config {
tags: {
[key: string]: boolean|{[attr: string]: boolean|string}|(() => any)
[key: string]: TagConfig | ((el: Element) => TagConfig)
};
}

View file

@ -1,3 +1,9 @@
/**
* Sanitizer config of each HTML element
* @see {@link https://github.com/guardian/html-janitor#options}
*/
type TagConfig = boolean | { [attr: string]: boolean | string };
export interface SanitizerConfig {
/**
* Tag name and params not to be stripped off
@ -31,5 +37,5 @@ export interface SanitizerConfig {
* }
* }
*/
[key: string]: boolean|{[attr: string]: boolean|string}|((el?: Element) => any);
[key: string]: TagConfig | ((el: Element) => TagConfig);
}