codex-team / codex-team/editor.js

[Bug] SanitizerConfig definition does not match documentation.

Open
#1,146 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
31.9k
Forks
2.2k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

Describe a bug.

Steps to reproduce:
1. Create following Tool:

```
export default class CustomTool {
static get sanitize() {
return {
text: {
span: (el: HTMLElement) => el.dataset.keepMe !== undefined,
},
};
}

// ···
}
```

2. Add it to EditorJS

Expected behavior:
`span` tags with attr `data-keep-me` should not be removed, no typescript error should be shown.

Actual behaviour:
span does not get removed, as expected, but console shows the following error message:

```
Type 'typeof CustomTool' is not assignable to type 'ToolConstructable'.
Type 'typeof CustomTool' is not assignable to type 'BaseToolConstructable'.
Types of property 'sanitize' are incompatible.
Type '{ text: { br: boolean; span: (el: HTMLElement) => boolean; }; }' is not assignable to type 'SanitizerConfig'.
Property 'text' is incompatible with index signature.
Type '{ br: boolean; span: (el: HTMLElement) => boolean; }' is not assignable to type 'boolean | { [attr: string]: string | boolean; } | (() => any)'.
Type '{ br: boolean; span: (el: HTMLElement) => boolean; }' is not assignable to type '{ [attr: string]: string | boolean; }'.
Property 'span' is incompatible with index signature.
Type '(el: HTMLElement) => boolean' is not assignable to type 'string | boolean'.
Type '(el: HTMLElement) => boolean' is not assignable to type 'true'.
```

Editor.js version: 2.17.0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.