ret += " \"#{el.system_identifier}\""
return ret
-make_wysiwyg = (el, options = {}) ->
+wysiwyg = (el, options = {}) ->
opt_fragment = options.fragment ? true
parser_opts = {}
if opt_fragment
parser_opts.fragment = 'body'
- dom = wheic_parser.parse(el.value, parser_opts)
- el.value = dom_to_html dom
+ editor_instance = dom: wheic_parser.parse(el.value, parser_opts)
+ # el.value = dom_to_html dom
+ return editor_instance
-window.wheic = make_wysiwyg
+window.wheic = {
+ wysiwyg: wysiwyg
+ dom_to_html: dom_to_html
+}
# test in browser: wheic(document.getElementsByTagName('textarea')[0])
--- /dev/null
+in_el = document.getElementById 'in'
+out_el = document.getElementById 'out'
+button = document.getElementById 'button'
+button.onclick = ->
+ editor = wheic.wysiwyg in_el
+ out_el.value = wheic.dom_to_html editor.dom
+ return false
+button.value="Cleanup"
+button.removeAttribute 'disabled'
<head>
<meta charset="UTF-8">
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
- <title>html parser tester</title>
+ <title>html editor tester</title>
+ <style>
+ textarea {
+ box-sizing: border-box;
+ width: 100%;
+ }
+ </style>
</head>
<body>
<h1>WHEIC editor test page (CoffeeScript version)</h1>
<p>This version of the test page compiles the CoffeeScript files in the browser. This is slower to load, but saves you having to rebuild as you work (or even install CoffeeScript).</p>
<form action="#" method="get">
- <p><textarea rows="9" cols="22" name="test_wysiwyg"><p>Normal <strong>Bold <em> Italic+Bold</strong> Italic</em> Normal</p></textarea></p>
+ <p>In:<br><textarea rows="9" cols="22" name="in" id="in"><p>Normal <strong>Bold <em> Italic+Bold</strong> Italic</em> Normal</p></textarea></p>
+ <p><input id="button" type="submit" value="loading..." disabled></p>
+ <p>Out:<br><textarea rows="9" cols="22" name="out" id="out" readonly></textarea></p>
</form>
<script src="parser.coffee" type="text/coffeescript"></script>
<script src="editor.coffee" type="text/coffeescript"></script>
+ <script src="editor_tests.coffee" type="text/coffeescript"></script>
<script src="coffee-script.js"></script>
</body>
</html>