Skip to content

Instantly share code, notes, and snippets.

View VihangaN's full-sized avatar
🏠
Working from home

Vihanga nivarthana VihangaN

🏠
Working from home
View GitHub Profile
@garak
garak / rte.html
Created July 7, 2020 16:21
Pure JS rich text editor
<!doctype html>
<html>
<head>
<title>Rich Text Editor</title>
<script type="text/javascript">
var oDoc, sDefTxt;
function initDoc() {
oDoc = document.getElementById("textBox");
sDefTxt = oDoc.innerHTML;
@nathansmith
nathansmith / [1] convertToMarkup.js
Last active November 16, 2023 12:43
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>');