Index: trunk/parsers/wikidom/lib/hype/views/es.ContentView.js |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | this.boundaryTest = /([ \-\t\r\n\f])/g; |
37 | 37 | this.widthCache = {}; |
38 | 38 | this.renderState = {}; |
| 39 | + this.contentCache = null; |
39 | 40 | |
40 | 41 | if ( model ) { |
41 | 42 | // Events |
— | — | @@ -476,7 +477,13 @@ |
477 | 478 | * "boundaries" array. Slices of the "words" array can be joined, producing the escaped HTML of |
478 | 479 | * the words. |
479 | 480 | */ |
480 | | - var text = this.model.getText(); |
| 481 | + // Get and cache a copy of all content, the make a plain-text version of the cached content |
| 482 | + var data = this.contentCache = this.model.getContent(), |
| 483 | + text = ''; |
| 484 | + debugger; |
| 485 | + for ( var i = 0, length = data.length; i < length; i++ ) { |
| 486 | + text += typeof data[i] === 'string' ? data[i] : data[i][0]; |
| 487 | + } |
481 | 488 | // Purge "boundaries" and "words" arrays |
482 | 489 | this.boundaries = [0]; |
483 | 490 | // Reset RegExp object's state |
— | — | @@ -830,7 +837,12 @@ |
831 | 838 | * @param {String} Rendered HTML of data within content model |
832 | 839 | */ |
833 | 840 | es.ContentView.prototype.getHtml = function( range, options ) { |
834 | | - var data = this.model.getContent( range ), |
| 841 | + if ( range ) { |
| 842 | + range.normalize(); |
| 843 | + } else { |
| 844 | + range = { 'start': 0, 'end': undefined }; |
| 845 | + } |
| 846 | + var data = this.contentCache.slice( range.start, range.end ), |
835 | 847 | render = es.ContentView.renderAnnotation, |
836 | 848 | htmlChars = es.ContentView.htmlCharacters; |
837 | 849 | var out = '', |