str_has_ws_run = (str) ->
return multi_sp_regex.test str
-debug_dot_at = (doc, x, y) ->
- return # disabled
- el = doc.createElement 'div'
- el.setAttribute 'style', "position: absolute; left: #{x}px; top: #{y}px; width: 1px; height: 3px; background-color: red"
- doc.body.appendChild el
- #console.log(new Error().stack)
-
# text nodes don't have getBoundingClientRect(), so use selection api to find
# it.
get_el_bounds = window.bounds = (el) ->
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
@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
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