JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
page to test editor html cleanup and serialization
authorJason Woofenden <jason@jasonwoof.com>
Sat, 23 Jan 2016 18:28:51 +0000 (13:28 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Sat, 23 Jan 2016 18:28:51 +0000 (13:28 -0500)
editor.coffee
editor_tests.coffee [new file with mode: 0644]
editor_tests_coffee.html

index 32c1d4d..b608e6b 100644 (file)
@@ -65,14 +65,18 @@ dom_to_html = (dom) ->
                                        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])
diff --git a/editor_tests.coffee b/editor_tests.coffee
new file mode 100644 (file)
index 0000000..4b995bb
--- /dev/null
@@ -0,0 +1,9 @@
+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'
index 3e0a005..b1c00fc 100644 (file)
@@ -3,17 +3,26 @@
 <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">&lt;p&gt;Normal &lt;strong&gt;Bold &lt;em&gt; Italic+Bold&lt;/strong&gt; Italic&lt;/em&gt; Normal&lt;/p&gt;</textarea></p>
+       <p>In:<br><textarea rows="9" cols="22" name="in" id="in">&lt;p&gt;Normal &lt;strong&gt;Bold &lt;em&gt; Italic+Bold&lt;/strong&gt; Italic&lt;/em&gt; Normal&lt;/p&gt;</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>