X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-html5-editor.git;a=blobdiff_plain;f=editor.coffee;h=a932f165d82e49f12aaf72016cba0072b9c6d514;hp=3d3336d3b9d77208f8226af67bb84828039a4d6d;hb=7eeb32ee3882c2a5837a95a2af60ea869ce9e5c8;hpb=7f075c8f4e23d2c49dbfadf8819ca61630466119 diff --git a/editor.coffee b/editor.coffee index 3d3336d..a932f16 100644 --- a/editor.coffee +++ b/editor.coffee @@ -889,15 +889,13 @@ class PeachHTML5Editor @cursor_el.parentNode.removeChild @cursor_el @cursor_visible = false @cursor = null - @matt null + @annotate null move_cursor: (cursor) -> @cursor = cursor - # replace cursor element, to reset blink animation - if @cursor_visible - @cursor_el.parentNode.removeChild @cursor_el - @cursor_el = domify @outer_idoc, div: id: 'cursor' - @overlay.appendChild @cursor_el - @cursor_visible = true + unless @cursor_visible + @cursor_el = domify @outer_idoc, div: id: 'cursor' + @overlay.appendChild @cursor_el + @cursor_visible = true @cursor_el.style.left = "#{cursor.x + overlay_padding - 1}px" if cursor.h < 5 height = 12 @@ -905,8 +903,8 @@ class PeachHTML5Editor height = cursor.h @cursor_el.style.top = "#{cursor.y + overlay_padding + Math.round(height * .07)}px" @cursor_el.style.height = "#{Math.round height * 0.82}px" - @matt cursor.n - matt: (n) -> + @annotate cursor.n + annotate: (n) -> while @matting.length > 0 @overlay.removeChild @matting[0] @matting.shift() @@ -922,12 +920,12 @@ class PeachHTML5Editor if bounds.x is prev_bounds.x and bounds.y is prev_bounds.y and bounds.w is prev_bounds.w and bounds.h is prev_bounds.h n = n.parent continue - matt = domify @outer_idoc, div: class: 'ann_box', style: "left: #{bounds.x - 1 + overlay_padding}px; top: #{bounds.y - 2 + overlay_padding}px; width: #{bounds.w}px; height: #{bounds.h}px" # outline: 1000px solid rgba(0,153,255,#{alpha}); - @overlay.appendChild matt - @matting.push matt - ann = domify @outer_idoc, div: class: 'ann_tag', style: "left: #{bounds.x + 1 + overlay_padding}px; top: #{bounds.y - 7 + overlay_padding}px", children: [domify @outer_idoc, text: " #{n.name} "] - @overlay.appendChild ann - @matting.push ann + ann_box = domify @outer_idoc, div: class: 'ann_box', style: "left: #{bounds.x - 1 + overlay_padding}px; top: #{bounds.y - 2 + overlay_padding}px; width: #{bounds.w}px; height: #{bounds.h}px" # outline: 1000px solid rgba(0,153,255,#{alpha}); + @overlay.appendChild ann_box + @matting.push ann_box + ann_tag = domify @outer_idoc, div: class: 'ann_tag', style: "left: #{bounds.x + 1 + overlay_padding}px; top: #{bounds.y - 7 + overlay_padding}px", children: [domify @outer_idoc, text: " #{n.name} "] + @overlay.appendChild ann_tag + @matting.push ann_tag n = n.parent alpha *= 1.5 pretty_html: (tree, indent = '', parent_flags = pre_ish: false, block: true, want_nl: false) ->