0
Fork 0
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:
kirrg001 2019-01-31 23:14:12 +01:00
parent 01419ef8b3
commit 11c910ec8c

View file

@ -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