codex-team / codex-team/editor.js

[Bug] sanitizerConfig works incorrectly

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

Description

## Description

`BlockTool.sanitize` property returns an object with the same shape as Tool's `data` object. `sanitize` object container `SanitizerConfig` as leafs.

Examples:

```
{
text: {
br: true,
},
}
```

```
{
caption: {
text: { br: true }
}
}
```

Internal BlockTool class has `baseSanitizeConfig` and `sanitizeConfig` preoptries.

`baseSanitizerConfig` is merge of sanitize configs of inline tools and tunes used by Block tool

`sanitizeConfig` returns an object with the shape of original `tool.sanitize`, but each with merged `baseSanitizerConfig` to each property.

Example
Tool config: `{ text: { br: true } }`
Inline Tool config: `{ b: true }`
Tune config: `{ sup: true }`

`baseSanitizeConfig` would be `{ b: true, sup: true }`
`sanitizeConfig` would be `{ text: { br: true, b: true, sup: true } }`

## Problems
1. `baseSanitizeConfig` should be renamed so its name reflects it is a merge of Tunes and Inline Tools sanitize configs
2. Return type of `sanitizeConfig` should be changed to reflect shape of the `data` object
3. `sanitizeConfig` should be able to process nested fields of `data` object (also need to check the same in Saver module)

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.