Last active
December 6, 2020 15:39
-
-
Save oliverjam/b0e657666623f2ff184139688e0e71c4 to your computer and use it in GitHub Desktop.
A tiny markdown editor. Paste into your URL bar with `data:text/html,` at the front
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
body { | |
margin: 0; | |
min-height: 100vh; | |
display: grid; | |
grid: none / 1fr 1fr; | |
gap: 1rem; | |
} | |
%23i { | |
outline: 0; | |
padding: 1rem; | |
font-family: Menlo, monospace; | |
background: hsl(220, 10%, 20%); | |
color: hsl(220, 10%, 94%); | |
} | |
</style> | |
<div id="i" contenteditable></div> | |
<div id="o"></div> | |
<script type=module> | |
import m from "https://unpkg.com/[email protected]/dist/snarkdown.es.js"; | |
let s = decodeURI(location.hash.slice(1)); | |
i.innerText = s; | |
o.innerHTML = m(s); | |
i.oninput = ({ target: { innerText: n } }) => { | |
o.innerHTML = m(n); | |
history.pushState(null, null, encodeURI(`%23${n}`)); | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
pushState
explodes in Firefox with a genericNS_ERROR_FAILURE
, so I assume data URLs aren't supposed to mess with the hash fragment. If I load this as an actual HTML file instead Firefox just warns "SecurityError: The operation is insecure." 🤷♂️.At least in works in Chrome?