From b93b549ea7d278b06385a1ae7cb30c324080fce7 Mon Sep 17 00:00:00 2001 From: Tomoyuki Hata Date: Thu, 3 Dec 2020 19:33:11 +0900 Subject: [PATCH 1/5] Fix SanitizerConfig type definition --- docs/CHANGELOG.md | 1 + src/types-internal/html-janitor.d.ts | 4 +++- types/configs/sanitizer-config.d.ts | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c1a83d994..733547cd1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -23,6 +23,7 @@ - `Fix` — Fix problem with entering to Editor.js by Tab key [#1393](https://github.com/codex-team/editor.js/issues/1393) - `Fix` - Sanitize pasted block data [#1396](https://github.com/codex-team/editor.js/issues/1396). - `Fix` - Unnecessary block creation after arrow navigation at last non-default block[#1414](https://github.com/codex-team/editor.js/issues/1414) +- `Fix` - Fix SanitizerConfig type definition[#1456](https://github.com/codex-team/editor.js/pull/1456) ### 2.19 diff --git a/src/types-internal/html-janitor.d.ts b/src/types-internal/html-janitor.d.ts index 6f9cc0352..8e507a073 100644 --- a/src/types-internal/html-janitor.d.ts +++ b/src/types-internal/html-janitor.d.ts @@ -3,9 +3,11 @@ * After that we can use it at the TS modules */ declare module 'html-janitor' { + type Option = boolean | { [attr: string]: boolean | string }; + interface Config { tags: { - [key: string]: boolean|{[attr: string]: boolean|string}|(() => any) + [key: string]: Option | ((el: Element) => Option) }; } diff --git a/types/configs/sanitizer-config.d.ts b/types/configs/sanitizer-config.d.ts index dad689271..dc5add8fa 100644 --- a/types/configs/sanitizer-config.d.ts +++ b/types/configs/sanitizer-config.d.ts @@ -1,3 +1,5 @@ +type Option = boolean | { [attr: string]: boolean | string }; + export interface SanitizerConfig { /** * Tag name and params not to be stripped off @@ -31,5 +33,5 @@ export interface SanitizerConfig { * } * } */ - [key: string]: boolean|{[attr: string]: boolean|string}|((el?: Element) => any); + [key: string]: Option | ((el: Element) => Option); } From 2dd8c2aec3957bfceb6fdaeacc3da48342a49d1b Mon Sep 17 00:00:00 2001 From: Tomoyuki Hata Date: Wed, 27 Jan 2021 04:51:32 +0900 Subject: [PATCH 2/5] Update docs/CHANGELOG.md Co-authored-by: Peter Savchenko --- docs/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 733547cd1..b8f8c23a4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -23,7 +23,7 @@ - `Fix` — Fix problem with entering to Editor.js by Tab key [#1393](https://github.com/codex-team/editor.js/issues/1393) - `Fix` - Sanitize pasted block data [#1396](https://github.com/codex-team/editor.js/issues/1396). - `Fix` - Unnecessary block creation after arrow navigation at last non-default block[#1414](https://github.com/codex-team/editor.js/issues/1414) -- `Fix` - Fix SanitizerConfig type definition[#1456](https://github.com/codex-team/editor.js/pull/1456) +- `Fix` - Fix SanitizerConfig type definition [#1456](https://github.com/codex-team/editor.js/pull/1456) ### 2.19 From 2c392af667fd9b090be0ee2ad2eb3a2ae4ca5938 Mon Sep 17 00:00:00 2001 From: Tomoyuki Hata Date: Wed, 27 Jan 2021 05:08:19 +0900 Subject: [PATCH 3/5] Fix CHANGELOG --- docs/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b8f8c23a4..c45265756 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,6 +12,8 @@ - `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) + ### 2.19.1 @@ -23,7 +25,6 @@ - `Fix` — Fix problem with entering to Editor.js by Tab key [#1393](https://github.com/codex-team/editor.js/issues/1393) - `Fix` - Sanitize pasted block data [#1396](https://github.com/codex-team/editor.js/issues/1396). - `Fix` - Unnecessary block creation after arrow navigation at last non-default block[#1414](https://github.com/codex-team/editor.js/issues/1414) -- `Fix` - Fix SanitizerConfig type definition [#1456](https://github.com/codex-team/editor.js/pull/1456) ### 2.19 From 95e0444f13c1cd938947295a144c208675ecae13 Mon Sep 17 00:00:00 2001 From: Tomoyuki Hata Date: Wed, 27 Jan 2021 05:20:13 +0900 Subject: [PATCH 4/5] Add JSDoc to TagConfig --- src/types-internal/html-janitor.d.ts | 8 ++++++-- types/configs/sanitizer-config.d.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/types-internal/html-janitor.d.ts b/src/types-internal/html-janitor.d.ts index 8e507a073..66f1c6a3a 100644 --- a/src/types-internal/html-janitor.d.ts +++ b/src/types-internal/html-janitor.d.ts @@ -3,11 +3,15 @@ * After that we can use it at the TS modules */ declare module 'html-janitor' { - type Option = boolean | { [attr: string]: boolean | string }; + /** + * 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]: Option | ((el: Element) => Option) + [key: string]: TagConfig | ((el: Element) => TagConfig) }; } diff --git a/types/configs/sanitizer-config.d.ts b/types/configs/sanitizer-config.d.ts index dc5add8fa..e15df7f32 100644 --- a/types/configs/sanitizer-config.d.ts +++ b/types/configs/sanitizer-config.d.ts @@ -1,4 +1,8 @@ -type Option = boolean | { [attr: string]: boolean | string }; +/** + * 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 { /** @@ -33,5 +37,5 @@ export interface SanitizerConfig { * } * } */ - [key: string]: Option | ((el: Element) => Option); + [key: string]: TagConfig | ((el: Element) => TagConfig); } From e1f63e8187c789b0309bded10c4fbc46a9ba793e Mon Sep 17 00:00:00 2001 From: Tomoyuki Hata Date: Fri, 19 Feb 2021 23:30:20 +0900 Subject: [PATCH 5/5] yarn lint:fix --- docs/CHANGELOG.md | 1 - src/components/modules/blockManager.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c45265756..8ed07ece4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,7 +14,6 @@ - `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) - ### 2.19.1 - `Improvements` - The [Cypress](https://www.cypress.io) was integrated as the end-to-end testing framework diff --git a/src/components/modules/blockManager.ts b/src/components/modules/blockManager.ts index e2051ed5d..30d392b2d 100644 --- a/src/components/modules/blockManager.ts +++ b/src/components/modules/blockManager.ts @@ -560,7 +560,7 @@ export default class BlockManager extends Module { * 2) Mark it as current * * @param {Node} childNode - look ahead from this node. - * @returns can return undefined in case when the passed child note is not a part of the current editor instance + * @returns {Block | undefined} can return undefined in case when the passed child note is not a part of the current editor instance */ public setCurrentBlockByChildNode(childNode: Node): Block | undefined { /**