Ghost/ghost/admin/app/helpers/gh-count-down-html-characters.js
Simon Backx bec71d7840 Added maximum signup terms count in HTML
refs https://github.com/TryGhost/Team/issues/2680

- Includes a new helper that is able to count HTML characters
- Prevent saving portal settings when maximum length is exceeded
2023-04-07 17:15:15 +02:00

17 lines
630 B
JavaScript

import {countDownCharacters} from './gh-count-down-characters';
import {helper} from '@ember/component/helper';
export default helper(function (params) {
let [content, maxCharacters] = params;
// Strip HTML-tags and characters from content so we have a reliable character count
content = content.replace(/<[^>]*>?/gm, '');
content = content.replace(/&nbsp;/g, ' ');
content = content.replace(/&amp;/g, '&');
content = content.replace(/&quot;/g, '"');
content = content.replace(/&lt;/g, '<');
content = content.replace(/&gt;/g, '>');
return countDownCharacters([content, maxCharacters]);
});