mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-15 03:01:37 -05:00
Avoided to store empty plaintext if html does not contain any text
no issue
This commit is contained in:
parent
01419ef8b3
commit
11c910ec8c
1 changed files with 9 additions and 2 deletions
|
@ -343,14 +343,21 @@ Post = ghostBookshelf.Model.extend({
|
|||
}
|
||||
|
||||
if (this.hasChanged('html') || !this.get('plaintext')) {
|
||||
this.set('plaintext', htmlToText.fromString(this.get('html'), {
|
||||
const plaintext = htmlToText.fromString(this.get('html'), {
|
||||
wordwrap: 80,
|
||||
ignoreImage: true,
|
||||
hideLinkHrefIfSameAsText: true,
|
||||
preserveNewlines: true,
|
||||
returnDomByDefault: true,
|
||||
uppercaseHeadings: false
|
||||
}));
|
||||
});
|
||||
|
||||
// CASE: html is e.g. <p></p>
|
||||
// @NOTE: Otherwise we will always update the resource to `plaintext: ''` and Bookshelf thinks that this
|
||||
// value was modified.
|
||||
if (plaintext) {
|
||||
this.set('plaintext', plaintext);
|
||||
}
|
||||
}
|
||||
|
||||
// disabling sanitization until we can implement a better version
|
||||
|
|
Loading…
Add table
Reference in a new issue