UNPKG

@storyblok/richtext

Version:
86 lines (85 loc) 1.82 kB
export declare const SELF_CLOSING_TAGS: string[]; /** * Converts an object of attributes to a string. * * @param {Record<string, string>} [attrs] * * @returns {string} The string representation of the attributes. * * @example * * ```typescript * const attrs = { * class: 'text-red', * style: 'color: red', * } * * const attrsString = attrsToString(attrs) * * console.log(attrsString) // 'class="text-red" style="color: red"' * * ``` * */ export declare const attrsToString: (attrs?: Record<string, string>) => string; /** * Converts an object of attributes to a CSS style string. * * @param {Record<string, string>} [attrs] * * @returns {string} The string representation of the CSS styles. * * @example * * ```typescript * const attrs = { * color: 'red', * fontSize: '16px', * } * * const styleString = attrsToStyle(attrs) * * console.log(styleString) // 'color: red; font-size: 16px' * ``` */ export declare const attrsToStyle: (attrs?: Record<string, string>) => string; /** * Escapes HTML entities in a string. * * @param {string} unsafeText * @return {*} {string} * * @example * * ```typescript * const unsafeText = '<script>alert("Hello")</script>' * * const safeText = escapeHtml(unsafeText) * * console.log(safeText) // '&lt;script&gt;alert("Hello")&lt;/script&gt;' * ``` */ export declare function escapeHtml(unsafeText: string): string; /** * Removes undefined values from an object. * * @param {Record<string, any>} obj * @return {*} {Record<string, any>} * * @example * * ```typescript * const obj = { * name: 'John', * age: undefined, * } * * const cleanedObj = cleanObject(obj) * * console.log(cleanedObj) // { name: 'John' } * ``` * */ export declare const cleanObject: (obj: Record<string, any>) => { [k: string]: any; };