Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js |
— | — | @@ -31,20 +31,15 @@ |
32 | 32 | */ |
33 | 33 | ParagraphBlock.prototype.insertContent = function( offset, content ) { |
34 | 34 | var lineOffset = 0; |
35 | | - if ( offset === 0 && this.lines.length ) { |
36 | | - this.lines[0].text = content.toString() + this.lines[0].text; |
37 | | - } else { |
38 | | - for ( var i = 0; i < this.lines.length; i++ ) { |
39 | | - if ( offset >= lineOffset && offset < lineOffset + this.lines[i].text.length ) { |
40 | | - this.lines[i].text = this.lines[i].text.substring( 0, offset - lineOffset ) |
41 | | - + content.toString() |
42 | | - + this.lines[i].text.substring( offset - lineOffset ) |
43 | | - break; |
44 | | - } |
45 | | - lineOffset += this.lines[i].text.length; |
| 35 | + for ( var i = 0; i < this.lines.length; i++ ) { |
| 36 | + if ( offset >= lineOffset && offset < lineOffset + this.lines[i].text.length ) { |
| 37 | + this.lines[i].text = this.lines[i].text.substring( 0, offset - lineOffset ) |
| 38 | + + content.toString() |
| 39 | + + this.lines[i].text.substring( offset - lineOffset ) |
| 40 | + break; |
46 | 41 | } |
| 42 | + lineOffset += this.lines[i].text.length; |
47 | 43 | } |
48 | | - |
49 | 44 | this.updateText(); |
50 | 45 | this.flow.render(); |
51 | 46 | }; |
— | — | @@ -82,6 +77,9 @@ |
83 | 78 | } |
84 | 79 | lineOffset += line.text.length; |
85 | 80 | } |
| 81 | + if ( !( from && to ) ) { |
| 82 | + throw 'FAIL'; |
| 83 | + } |
86 | 84 | if ( from.index === to.index ) { |
87 | 85 | from.line.text = from.line.text.substring( 0, from.line.offset ) |
88 | 86 | + from.line.text.substring( to.line.offset ); |
— | — | @@ -93,6 +91,7 @@ |
94 | 92 | this.lines = this.lines.splice( from.index + 1, to.index - from.index ); |
95 | 93 | } |
96 | 94 | this.updateText(); |
| 95 | + this.flow.render(); |
97 | 96 | }; |
98 | 97 | |
99 | 98 | /** |