diff options
Diffstat (limited to 'client/src/app/helpers/utils/html.ts')
-rw-r--r-- | client/src/app/helpers/utils/html.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/client/src/app/helpers/utils/html.ts b/client/src/app/helpers/utils/html.ts new file mode 100644 index 000000000..2d520aee9 --- /dev/null +++ b/client/src/app/helpers/utils/html.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | import { immutableAssign } from './object' | ||
2 | |||
3 | function objectLineFeedToHtml (obj: any, keyToNormalize: string) { | ||
4 | return immutableAssign(obj, { | ||
5 | [keyToNormalize]: lineFeedToHtml(obj[keyToNormalize]) | ||
6 | }) | ||
7 | } | ||
8 | |||
9 | function lineFeedToHtml (text: string) { | ||
10 | if (!text) return text | ||
11 | |||
12 | return text.replace(/\r?\n|\r/g, '<br />') | ||
13 | } | ||
14 | |||
15 | export { | ||
16 | objectLineFeedToHtml, | ||
17 | lineFeedToHtml | ||
18 | } | ||