@t7/utils
Version:
Utility methods for T7 components.
28 lines (23 loc) • 790 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/*
You would call this when receiving a plain text
value back from an API, and before inserting the
text into the `contenteditable` area on a page.
*/
var contentToMarkup = function contentToMarkup() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
value = value.trim();
value = value.replace(/>/g, '>');
value = value.replace(/</g, '<');
value = value.replace(/\n+\s+\n+/g, '\n\n');
value = value.replace(/\n\n+/g, '\n\n');
value = value.replace(/\n/g, '<br>');
value = value.replace(/\s+/g, ' '); // Expose string.
return value;
}; // Expose function.
var _default = contentToMarkup;
exports.default = _default;
;