Created
February 17, 2015 02:21
-
-
Save robertleeplummerjr/4376c6e13cce938e92a0 to your computer and use it in GitHub Desktop.
Medium.js with Anchor
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title>Medium.js to make an Anchor</title> | |
<script src="bower_components/undo/undo.js"></script> | |
<script src="bower_components/rangy-official/rangy-core.min.js"></script> | |
<script src="bower_components/rangy-official/rangy-classapplier.min.js"></script> | |
<script src="medium.js"></script> | |
<link href="medium.css" rel="stylesheet"> | |
</head> | |
<body> | |
<button id="link">Link (click me first)</button> <button id="kill">Turn Medium.js editor off (click me second)</button> | |
<div id="editor" style="height: 30px;"></div> | |
</body> | |
<script> | |
var link = document.getElementById('link'), | |
kill = document.getElementById('kill'), | |
editor = document.getElementById('editor'), | |
medium = new Medium({ | |
element: editor, | |
mode: Medium.richMode, | |
tags: null, | |
placeholder: 'Test Text', | |
autofocus: true, | |
attributes: null | |
}); | |
link.onmousedown = function(e){ | |
medium.select(); | |
medium.invokeElement('a', { | |
title: "I'm a link! Click me third.", | |
style: "color: #66d9ef", | |
href: "http://github.com", | |
target: "_new" | |
}); | |
return false; | |
}; | |
kill.onmousedown = function() { | |
medium.destroy(); | |
return false; | |
}; | |
medium.value('make a link on me'); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment