JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
comments, function rename
authorJason Woofenden <jason@jasonwoof.com>
Sat, 28 May 2016 17:38:01 +0000 (13:38 -0400)
committerJason Woofenden <jason@jasonwoof.com>
Sat, 28 May 2016 17:38:01 +0000 (13:38 -0400)
editor.coffee

index 238625c..47adbd8 100644 (file)
@@ -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