Index: trunk/parsers/wikidom/lib/es/es.Document.js |
— | — | @@ -52,6 +52,14 @@ |
53 | 53 | } |
54 | 54 | }; |
55 | 55 | |
| 56 | +es.Document.prototype.getWikiDomDocument = function() { |
| 57 | + var wikidom = { blocks: [ ] }; |
| 58 | + for ( var i = 0; i < this.blocks.length; i++ ) { |
| 59 | + wikidom.blocks.push( this.blocks[i].getWikiDom() ); |
| 60 | + } |
| 61 | + return wikidom; |
| 62 | +}; |
| 63 | + |
56 | 64 | /* Inheritance */ |
57 | 65 | |
58 | 66 | es.extend( es.Document, es.Container ); |
Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js |
— | — | @@ -179,6 +179,13 @@ |
180 | 180 | ); |
181 | 181 | }; |
182 | 182 | |
| 183 | +es.ParagraphBlock.prototype.getWikiDom = function() { |
| 184 | + return { |
| 185 | + lines: this.content.getWikiDomLines(), |
| 186 | + type: 'paragraph' |
| 187 | + }; |
| 188 | +}; |
| 189 | + |
183 | 190 | /* Registration */ |
184 | 191 | |
185 | 192 | /** |
Index: trunk/parsers/wikidom/lib/es/es.Block.js |
— | — | @@ -214,6 +214,10 @@ |
215 | 215 | throw 'Block.getSectionBoundaries not implemented in this subclass.'; |
216 | 216 | }; |
217 | 217 | |
| 218 | +es.Block.prototype.getWikiDom = function() { |
| 219 | + throw 'Block.getWikiDom not implemented in this subclass.'; |
| 220 | +}; |
| 221 | + |
218 | 222 | /* Inheritance */ |
219 | 223 | |
220 | 224 | es.extend( es.Block, es.EventEmitter ); |
Index: trunk/parsers/wikidom/demos/es/index2.html |
— | — | @@ -93,7 +93,13 @@ |
94 | 94 | <script type="text/javascript" src="../../lib/es/es.ListBlockItem.js"></script>
|
95 | 95 | <script type="text/javascript" src="../../lib/es/es.ListBlock.js"></script>
|
96 | 96 | <script type="text/javascript" src="../../lib/es/es.Cursor.js"></script>
|
97 | | -
|
| 97 | +
|
| 98 | + <script src="../../lib/wiki.js" type="text/javascript"></script>
|
| 99 | + <script src="../../lib/wiki.util.js" type="text/javascript"></script>
|
| 100 | + <script src="../../lib/wiki.AnnotationRenderer.js" type="text/javascript"></script>
|
| 101 | + <script src="../../lib/wiki.HtmlRenderer.js" type="text/javascript"></script>
|
| 102 | + <script src="../../lib/wiki.WikitextRenderer.js" type="text/javascript"></script>
|
| 103 | +
|
98 | 104 | <!-- Demo -->
|
99 | 105 | <script>
|
100 | 106 | $(document).ready( function() {
|
— | — | @@ -138,6 +144,7 @@ |
139 | 145 | { 'text': "A soft return is the break resulting from line wrap or word wrap, whereas a hard return is an intentional break, creating a new paragraph." },
|
140 | 146 | ]
|
141 | 147 | },
|
| 148 | + /*
|
142 | 149 | {
|
143 | 150 | 'type': 'list',
|
144 | 151 | 'style': 'number',
|
— | — | @@ -238,13 +245,13 @@ |
239 | 246 | }
|
240 | 247 | ]
|
241 | 248 | },
|
| 249 | + */
|
242 | 250 | {
|
243 | 251 | 'type': 'paragraph',
|
244 | 252 | 'lines': [
|
245 | 253 | { 'text': 'The soft returns are usually placed after the ends of complete words, or after the punctuation that follows complete words. However, word wrap may also occur following a hyphen.' },
|
246 | 254 | { 'text': 'Word wrap following hyphens is sometimes not desired, and can be avoided by using a so-called non-breaking hyphen instead of a regular hyphen. On the other hand, when using word processors, invisible hyphens, called soft hyphens, can also be inserted inside words so that word wrap can occur following the soft hyphens.' },
|
247 | 255 | { 'text': 'Sometimes, word wrap is not desirable between words. In such cases, word wrap can usually be avoided by using a hard space or non-breaking space between the words, instead of regular spaces.' },
|
248 | | - { 'text': 'OccasionallyThereAreWordsThatAreSoLongTheyExceedTheWidthOfTheLineAndEndUpWrappingBetweenMultipleLines.' },
|
249 | 256 | { 'text': 'Text might have\ttabs\tin it too. Not all text will end in a line breaking character' }
|
250 | 257 | ]
|
251 | 258 | }
|
— | — | @@ -302,6 +309,19 @@ |
303 | 310 | surface.annotateContent( 'remove', { 'type': 'all' } );
|
304 | 311 | return false;
|
305 | 312 | } );
|
| 313 | +
|
| 314 | + var previewTimeout = null;
|
| 315 | + var wikitextRenderer = new wiki.WikitextRenderer();
|
| 316 | + doc.on( 'update', function() {
|
| 317 | + if ( previewTimeout !== null ) {
|
| 318 | + clearTimeout( previewTimeout );
|
| 319 | + }
|
| 320 | + previewTimeout = setTimeout( function () {
|
| 321 | + console.log(doc.getWikiDomDocument());
|
| 322 | + $( '#wikitext-source' ).text( wikitextRenderer.render( doc.getWikiDomDocument() ) );
|
| 323 | + }, 100 );
|
| 324 | + } );
|
| 325 | +
|
306 | 326 | } );
|
307 | 327 | </script>
|
308 | 328 | </body>
|