Turn existing CodeMirror editor into HyperMD
This example is for plain browser environment. Make sure that...
All necessary CodeMirror assets must be loaded already. (scripts, stylesheets... The list can be found here)
The CodeMirror is not protected by closure. Check if
CodeMirrorthe global variable exists.
If a Markdown editor based on CodeMirror is already existing, you can convert it to HyperMD mode!
-
Open Inspector, switch to the console panel
-
Load HyperMD. Copy and run this in console:
// This create element and insert into body function elt(tagName, attrs) { var el = document.createElement(tagName) if (attrs) for (var attr in attrs) el.setAttribute(attr, attrs[attr]) document.body.appendChild(el) return el } elt('link', { rel: "stylesheet", href: "https://laobubu.net/HyperMD/mode/hypermd.css" }) elt('link', { rel: "stylesheet", href: "https://laobubu.net/HyperMD/theme/hypermd-light.css" }) elt('script', { src: "https://laobubu.net/HyperMD/ai1.js" }) .addEventListener('load', function() { console.log('HyperMD is ready!') }, false) -
Wait until
HyperMD is readyappears -
Run this:
HyperMD.switchToHyperMD(editor)