Index: trunk/parsers/wikidom/lib/es/es.Block.js |
— | — | @@ -7,6 +7,21 @@ |
8 | 8 | this.document = null; |
9 | 9 | } |
10 | 10 | |
| 11 | +/** |
| 12 | + * Association between block type name and block class |
| 13 | + * Example: "paragraph" => es.ParagraphBlock |
| 14 | + * |
| 15 | + */ |
| 16 | +es.Block.models = {}; |
| 17 | + |
| 18 | +es.Block.newFromWikidom = function( wikidomBlock ) { |
| 19 | + if ( wikidomBlock.type in es.Block.models ) { |
| 20 | + return es.Block.models[wikidomBlock.type].newFromWikidom( wikidomBlock ); |
| 21 | + } else { |
| 22 | + throw 'Unknown block type: ' + wikidomBlock.type; |
| 23 | + } |
| 24 | +}; |
| 25 | + |
11 | 26 | es.Block.prototype.getLength = function() { |
12 | 27 | throw 'Block.getLength not implemented in this subclass.'; |
13 | 28 | }; |