From: Jason Woofenden Date: Sat, 23 Jan 2016 18:28:51 +0000 (-0500) Subject: page to test editor html cleanup and serialization X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-html5-editor.git;a=commitdiff_plain;h=c8370edb3147dad5c8921f6dd4509a3c94658e0c page to test editor html cleanup and serialization --- diff --git a/editor.coffee b/editor.coffee index 32c1d4d..b608e6b 100644 --- a/editor.coffee +++ b/editor.coffee @@ -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 index 0000000..4b995bb --- /dev/null +++ b/editor_tests.coffee @@ -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' diff --git a/editor_tests_coffee.html b/editor_tests_coffee.html index 3e0a005..b1c00fc 100644 --- a/editor_tests_coffee.html +++ b/editor_tests_coffee.html @@ -3,17 +3,26 @@ - html parser tester + html editor tester +

WHEIC editor test page (CoffeeScript version)

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).

-

+

In:

+

+

Out:

+