Skip to content

Instantly share code, notes, and snippets.

@alaaibrahim
Created July 13, 2011 11:12
Show Gist options
  • Select an option

  • Save alaaibrahim/1080113 to your computer and use it in GitHub Desktop.

Select an option

Save alaaibrahim/1080113 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Editor Test</title>
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
<style>
#editor_cont {
width: 300px;
border: 1px solid #999;
margin: 2em;
background-color: #f2f2f2;
}
#editor_cont p {
margin: .5em;
}
#editor {
height: 350px;
background-color: #fff;
}
</style>
</head>
<body class="yui3-skin-sam yui-skin-sam">
<div id="editor_cont">
<a href='#content' id="showContent">show content</a>
<div id="editor"></div>
</div>
<div id="content"></div>
<div id="html"></div>
<script>
YUI().use('editor', 'node', function(Y) {
//Create the Base Editor
var editor = new Y.EditorBase({
defaultblock : 'p'
});
editor.plug(Y.Plugin.EditorPara);
Y.one('#showContent').on('click', function() {
var innerHTML = document.getElementById('editor').children[0].contentDocument.body.innerHTML;
var content = editor.getContent();
Y.one('#content').set('text',content)
Y.one('#html').set('text',innerHTML);
});
//Rendering the Editor
editor.render('#editor');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment