Skip to content

Commit

Permalink
Feat: new config setting allowLineBreaks: Boolean
Browse files Browse the repository at this point in the history
Allow a Header Tool's text to include break line `<br>` tags when a user presses Shift + Enter.

By default, this is disabled, the developer can choose to enable through the tool's config:

```
config: {
    allowLineBreaks: true,
}
```

Fixes editor-js#73
  • Loading branch information
mrspence authored Dec 17, 2021
1 parent 585bca2 commit f17122e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,14 @@ class Header {
* @public
*/
save(toolsContent) {
return {
text: toolsContent.innerHTML,
const sanitizerConfig = {
br: !(typeof this._settings.allowLineBreaks === 'undefined' || this._settings.allowLineBreaks === false),
}

return Object.assign({}, {
text: this.api.sanitizer.clean(toolsContent.innerHTML, sanitizerConfig),
level: this.currentLevel.number,
};
});
}

/**
Expand All @@ -249,7 +253,9 @@ class Header {
static get sanitize() {
return {
level: false,
text: {},
text: {
br: true,
},
};
}

Expand Down

0 comments on commit f17122e

Please sign in to comment.