r93853 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93852‎ | r93853 | r93854 >
Date:20:31, 3 August 2011
Author:inez
Status:deferred
Tags:
Comment:
Basic implementation of new demo that contains live preview of generated wikitext
Modified paths:
  • /trunk/parsers/wikidom/demos/es/index2.html (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Block.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Document.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Document.js
@@ -52,6 +52,14 @@
5353 }
5454 };
5555
 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+
5664 /* Inheritance */
5765
5866 es.extend( es.Document, es.Container );
Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js
@@ -179,6 +179,13 @@
180180 );
181181 };
182182
 183+es.ParagraphBlock.prototype.getWikiDom = function() {
 184+ return {
 185+ lines: this.content.getWikiDomLines(),
 186+ type: 'paragraph'
 187+ };
 188+};
 189+
183190 /* Registration */
184191
185192 /**
Index: trunk/parsers/wikidom/lib/es/es.Block.js
@@ -214,6 +214,10 @@
215215 throw 'Block.getSectionBoundaries not implemented in this subclass.';
216216 };
217217
 218+es.Block.prototype.getWikiDom = function() {
 219+ throw 'Block.getWikiDom not implemented in this subclass.';
 220+};
 221+
218222 /* Inheritance */
219223
220224 es.extend( es.Block, es.EventEmitter );
Index: trunk/parsers/wikidom/demos/es/index2.html
@@ -93,7 +93,13 @@
9494 <script type="text/javascript" src="../../lib/es/es.ListBlockItem.js"></script>
9595 <script type="text/javascript" src="../../lib/es/es.ListBlock.js"></script>
9696 <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+
98104 <!-- Demo -->
99105 <script>
100106 $(document).ready( function() {
@@ -138,6 +144,7 @@
139145 { '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." },
140146 ]
141147 },
 148+ /*
142149 {
143150 'type': 'list',
144151 'style': 'number',
@@ -238,13 +245,13 @@
239246 }
240247 ]
241248 },
 249+ */
242250 {
243251 'type': 'paragraph',
244252 'lines': [
245253 { '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.' },
246254 { '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.' },
247255 { '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.' },
249256 { 'text': 'Text might have\ttabs\tin it too. Not all text will end in a line breaking character' }
250257 ]
251258 }
@@ -302,6 +309,19 @@
303310 surface.annotateContent( 'remove', { 'type': 'all' } );
304311 return false;
305312 } );
 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+
306326 } );
307327 </script>
308328 </body>

Status & tagging log