X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=editor.coffee;h=b21d9593cfa687a4dbe3c9f88a83cf7295ac3e9b;hb=5aef791edd38fb3d70a71266ad0b42cf9fb45593;hp=d8e482d31f35867ecb599a992863b063476ed579;hpb=aac46ddccea6bf7604866552730e6da73034ca87;p=peach-html5-editor.git diff --git a/editor.coffee b/editor.coffee index d8e482d..b21d959 100644 --- a/editor.coffee +++ b/editor.coffee @@ -1201,28 +1201,6 @@ class PeachHTML5Editor h = parseInt(@idoc.body.scrollHeight, 10) @iframe.style.height = "#{h}px" @wrap2.scrollTop = s - # does this node have whitespace that would be collapsed by white-space: normal? - # note: this checks direct text children, and does _not_ recurse into child tags - # tag is a node with type:"tag" - # FIXME use new textrun api - has_collapsable_space: (tag) -> - for n in tag.children - if n.type is 'text' - for i in [0...n.text.length] - code = n.text.charCodeAt i - if code isnt 32 and is_space_code code - # tab, return - return true - # check for double spaces that don't surround insert location - continue if i is 0 - if n.text.substr(i - 1, 2) is ' ' - return true - if n.text.length > 0 - if is_space_code n.text.charCodeAt 0 - return true - if is_space_code n.text.charCodeAt n.text.length - 1 - return true - return false # true if n is text node with only one caracter, and the only child of a tag is_only_char_in_tag: (n, i) -> return false unless n.type is 'text' @@ -1300,6 +1278,9 @@ class PeachHTML5Editor # remove whitespace that would be trimmed # replace whitespace that would collapse with a single space # FIXME remove whitespace from after
(but not before) + # FIXME rewrite to + # check computed white-space prop on txt parents + # batch replace txt node contents (ie don't loop for each char) collapse_whitespace: (tree = @tree) -> prev = cur = next = null prev_i = cur_i = next_i = 0