Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
peach-html5-editor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e3b3962
)
comments, function rename
author
Jason Woofenden
<jason@jasonwoof.com>
Sat, 28 May 2016 17:38:01 +0000
(13:38 -0400)
committer
Jason Woofenden
<jason@jasonwoof.com>
Sat, 28 May 2016 17:38:01 +0000
(13:38 -0400)
editor.coffee
patch
|
blob
|
history
diff --git
a/editor.coffee
b/editor.coffee
index
238625c
..
47adbd8
100644
(file)
--- a/
editor.coffee
+++ b/
editor.coffee
@@
-524,8
+524,10
@@
tree_remove_empty_text_nodes = (tree) ->
n.parent.children.splice i, 1
break
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
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_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
@changed()
changed: ->
@in_el.onchange = null
@@
-1461,10
+1463,18
@@
class PeachHTML5Editor
else
if n.attrs.style?
delete n.attrs.style
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
# 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
text_cleanup: (n) ->
if @is_display_block n
block = n