Skip to content

Conversation

gohabereg
Copy link
Member

No description provided.

Copy link
Member

@neSpecc neSpecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At example-dev:

image

return block;
}

block.data = this.deepSanitize(block.data, toolConfig) as BlockToolData;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.deepSanitize -> deepSanitize ?

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong section

*
* @example
*
* Sanitizer.clean(yourTaintString, yourConfig);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actualize example

*/
export function sanitizeBlocks(
blocksData: Array<Pick<SavedData, 'data' | 'tool'>>,
sanitizeConfig: (toolName: string) => SanitizerConfig | SanitizerConfig
Copy link
Member

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?

Copy link
Member Author

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 {
});
Copy link
Member

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?

Copy link
Member Author

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] || {};
Copy link
Member

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?

Copy link
Member Author

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
b: true,
a: true,

@gohabereg gohabereg merged commit a88dc8e into next Apr 8, 2021
@gohabereg gohabereg deleted the refactoring/sanitizer branch April 8, 2021 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants