Skip to content

Instantly share code, notes, and snippets.

Working from home

Vihanga nivarthana VihangaN

Working from home
View GitHub Profile
garak / rte.html
Created July 7, 2020 16:21
Pure JS rich text editor
View rte.html
<!doctype html>
<title>Rich Text Editor</title>
<script type="text/javascript">
var oDoc, sDefTxt;
function initDoc() {
oDoc = document.getElementById("textBox");
sDefTxt = oDoc.innerHTML;
nathansmith / [1] convertToMarkup.js
Last active July 4, 2023 13:35
Handy utilities for dealing with `<div contenteditable="true">` areas.
View [1] convertToMarkup.js
// 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>');