From 998c004f81244203fade51a4b014ed794f7746cc Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Sat, 28 May 2016 13:38:01 -0400 Subject: [PATCH] comments, function rename --- editor.coffee | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/editor.coffee b/editor.coffee index 238625c..47adbd8 100644 --- a/editor.coffee +++ b/editor.coffee @@ -524,8 +524,10 @@ tree_remove_empty_text_nodes = (tree) -> n.parent.children.splice i, 1 break -# pass a array of nodes (from parser library, ie it should have .el and .text) -tree_dedup_space = (tree) -> +# remove whitespace that would be trimmed +# replace whitespace that would collapse with a single space +# FIXME delete this, use @collapse_whitespace instead +collapse_whitespace = (tree) -> prev = cur = next = null prev_i = cur_i = next_i = 0 prev_pos = pos = next_pos = null @@ -1348,7 +1350,7 @@ class PeachHTML5Editor @tree_parent.el = @idoc.body @clear_dom() instantiate_tree @tree, @tree_parent.el - tree_dedup_space @tree + @collapse_whitespace @tree @changed() changed: -> @in_el.onchange = null @@ -1461,10 +1463,18 @@ class PeachHTML5Editor else if n.attrs.style? delete n.attrs.style + # remove whitespace that would be trimmed + # replace whitespace that would collapse with a single space + collapse_whitespace: (tree = @tree) -> + return collapse_whitespace tree # FIXME CONTINUE + return # call this after you insert or remove inline nodes. It will: # merge consecutive text nodes # remove empty text nodes # adjust white-space property + # note: this assumes that all whitespace in text nodes should be displayed + # (ie not collapse or be trimmed) and will change the white-space property + # as needed to achieve this. text_cleanup: (n) -> if @is_display_block n block = n -- 1.7.10.4