Files
nocodb/packages/nc-gui/utils/stringUtils.ts
mertmit 69a29568c7 chore: sync
Signed-off-by: mertmit <mertmit99@gmail.com>
2026-01-10 00:21:02 +03:00

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)
}