Skip to content

Instantly share code, notes, and snippets.

View serbiant's full-sized avatar

Vladimir serbiant

  • Shypple
  • Rotterdam, the Netherlands
View GitHub Profile
@serbiant
serbiant / [1] convertToMarkup.js
Created September 22, 2021 12:36 — forked from nathansmith/[1] convertToMarkup.js
Handy utilities for dealing with `<div contenteditable="true">` areas.
// Helpers.
import { convertToText } from './';
/*
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.
*/
const convertToMarkup = (str = '') => {
return convertToText(str).replace(/\n/g, '<br>');