Created
October 3, 2009 16:23
-
-
Save jshirley/200735 to your computer and use it in GitHub Desktop.
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 PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<title>Editor Test Suite</title> | |
<link rel="stylesheet" type="text/css" href="../../../build/reset-fonts-grids/reset-fonts-grids.css"> | |
<link type="text/css" rel="stylesheet" href="../../../build/logger/assets/logger.css"> | |
<link type="text/css" rel="stylesheet" href="../../../build/yuitest/assets/testlogger.css"> | |
<link rel="stylesheet" type="text/css" href="../../../build/container/assets/skins/sam/container.css"> | |
<link rel="stylesheet" type="text/css" href="../../../build/menu/assets/skins/sam/menu.css"> | |
<link rel="stylesheet" type="text/css" href="../../../build/button/assets/skins/sam/button.css"> | |
<link rel="stylesheet" type="text/css" href="../../../build/resize/assets/skins/sam/resize.css"> | |
<link rel="stylesheet" type="text/css" href="../../../build/editor/assets/skins/sam/editor.css"> | |
<script type="text/javascript" src="../../../build/utilities/utilities.js"></script> | |
<script type="text/javascript" src="../../../build/event-simulate/event-simulate-min.js"></script> | |
<script type="text/javascript" src="../../../build/logger/logger-min.js"></script> | |
<script type="text/javascript" src="../../../build/container/container_core-min.js"></script> | |
<script type="text/javascript" src="../../../build/menu/menu-min.js"></script> | |
<script type="text/javascript" src="../../../build/button/button-min.js"></script> | |
<script type="text/javascript" src="../../../build/resize/resize-min.js"></script> | |
<script type="text/javascript" src="../../../build/editor/editor.js"></script> | |
<script type="text/javascript" src="../../../build/yuitest/yuitest.js"></script> | |
</head> | |
<body class="yui-skin-sam"> | |
<textarea id="editor"><p>This is a test: <script type="text/javascript" src="http://gist.github.com/198143.js"></script></p></textarea> | |
<input id="submit" type="button" value="Save HTML"> | |
<script type="text/javascript"> | |
(function() { | |
var config = { | |
height: '300px', | |
width: '600px', | |
animate: true, | |
dompath: true, | |
focusAtStart: true, | |
preserveDangerousScriptTags: true | |
}; | |
var myLogReader = new YAHOO.widget.LogReader(); | |
YAHOO.widget.TrustingEditor = function(el, attrs) { | |
YAHOO.widget.TrustingEditor.superclass.constructor.call(this, el, attrs ); | |
}; | |
YAHOO.extend(YAHOO.widget.TrustingEditor, YAHOO.widget.Editor, { | |
_cleanIncomingHTML: function(html) { | |
html = html.replace(/<script([^>]*)>/gi, '<YUI_SCRIPT$1>'); | |
html = html.replace(/<\/script([^>]*)>/gi, '</YUI_SCRIPT>'); | |
html = YAHOO.widget.TrustingEditor.superclass._cleanIncomingHTML.call(this, html); | |
html = html.replace(/<YUI_SCRIPT([^>]*)>/gi, '<script$1>'); | |
html = html.replace(/<\/YUI_SCRIPT([^>]*)>/gi, '</script>'); | |
return html; | |
}, | |
cleanHTML: function(html) { | |
if (!html) | |
html = this.getEditorHTML(); | |
delete this.invalidHTML.script; | |
html = html.replace(/<script([^&>]*)>/g, '<script$1>'); | |
html = html.replace(/<\/script>/g, '<\/script>'); | |
html = YAHOO.widget.TrustingEditor.superclass.cleanHTML.call(this, html); | |
return html; | |
} | |
}); | |
var editor = new YAHOO.widget.TrustingEditor('editor', config); | |
editor.render(); | |
YAHOO.util.Event.on('submit', 'click', function(ev) { | |
YAHOO.util.Event.preventDefault(ev); | |
editor.saveHTML(); | |
YAHOO.log( "Editor HTML: " + editor.get('element').value ); | |
}); | |
//}, editor, true); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment