mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-01 01:57:30 +00:00
20 lines
534 B
TypeScript
20 lines
534 B
TypeScript
export function getHTMLEncodedText(htmlString: string) {
|
|
const div = document.createElement('div')
|
|
div.textContent = htmlString || ''
|
|
return div.innerHTML
|
|
}
|
|
|
|
export const truncateText = (text: string, maxLength = 50) => {
|
|
if (ncIsNullOrUndefined(text)) {
|
|
return ''
|
|
}
|
|
text = `${text}`
|
|
if (text.length <= maxLength) return text
|
|
return `${text.substring(0, maxLength - 3)}...`
|
|
}
|
|
|
|
export const capitalize = (str?: string | null): string => {
|
|
if (!str) return ''
|
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
}
|