1
0
Fork 0

updated char counter logic

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-01-19 12:17:07 +05:30
Ursprung 4f70aea729
Commit f27ca60d24

Datei anzeigen

@ -1,9 +1,16 @@
import { registerUnbound } from "discourse-common/lib/helpers";
import I18n from "I18n";
export default registerUnbound("char-counter", function(body) {
export default registerUnbound("char-counter", function(body, maxLength) {
let bodyLength = body ? body.length : 0;
let characterString = bodyLength == 1 ? 'wizard.character' : 'wizard.characters';
let finalString = `<div class="body-length">${bodyLength} ${ I18n.t(characterString)}</div>`;
let length = maxLength || bodyLength;
let characterString = length == 1 ? 'wizard.character' : 'wizard.characters';
let finalString;
if(maxLength) {
finalString = `<div class="body-length">${bodyLength} / ${maxLength} ${ I18n.t(characterString)}</div>`;
} else {
finalString = `<div class="body-length">${bodyLength} ${ I18n.t(characterString)}</div>`;
}
return new Handlebars.SafeString(finalString);
});