-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
refactoring(modules): sanitizer module is util now #1574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/utils/sanitizer.ts
Outdated
return block; | ||
} | ||
|
||
block.data = this.deepSanitize(block.data, toolConfig) as BlockToolData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.deepSanitize
-> deepSanitize
?
docs/CHANGELOG.md
Outdated
@@ -25,9 +25,11 @@ | |||
- `Refactoring` - The Listeners module now is a util. | |||
- `Refactoring` - The Events module now is a util. | |||
- `Fix` - Editor Config now immutable [#1552](https://github.com/codex-team/editor.js/issues/1552). | |||
- `Refactoring` - The Sanitizer module is util now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong section
src/components/utils/sanitizer.ts
Outdated
* | ||
* @example | ||
* | ||
* Sanitizer.clean(yourTaintString, yourConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actualize example
src/components/utils/sanitizer.ts
Outdated
*/ | ||
export function sanitizeBlocks( | ||
blocksData: Array<Pick<SavedData, 'data' | 'tool'>>, | ||
sanitizeConfig: (toolName: string) => SanitizerConfig | SanitizerConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the sanitizeconfig
is a function? maybe the config should be passed calculated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each block has own sanitize config. We can pass a map name => config but I think function is better. However you can still pass an object which will be applied for all blocks
@@ -42,7 +43,9 @@ export default class Saver extends Module { | |||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just call deepSanitize
here and remove the sanitizeBlocks
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each block has own sanitize config, so we can't
@@ -249,7 +249,7 @@ export default abstract class BaseTool<Type extends Tool = Tool> { | |||
* Returns Tool's sanitizer configuration | |||
*/ | |||
public get sanitizeConfig(): SanitizerConfig { | |||
return this.constructable[CommonInternalSettings.SanitizeConfig]; | |||
return this.constructable[CommonInternalSettings.SanitizeConfig] || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not undefined
by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Block Tools it will be still {} even if we return undefined here, for inline tools it helps us to get rid of unnecessary checks
name: 'inlineTool', | ||
constructable: class { | ||
public static sanitize = { | ||
b: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b: true, | |
a: true, |
No description provided.