Index: trunk/parsers/wikidom/lib/synth/models/es.DocumentModel.js |
— | — | @@ -26,12 +26,10 @@ |
27 | 27 | es.DocumentModel.newFromPlainObject = function( obj ) { |
28 | 28 | var types = es.BlockModel.constructors; |
29 | 29 | return new es.DocumentModel( |
30 | | - // Blocks - if given, convert all plain "block" objects to es.WikiDom* objects |
31 | | - !$.isArray( obj.blocks ) ? [] : $.map( obj.blocks, function( block ) { |
32 | | - return es.BlockModel.newFromPlainObject( block ); |
33 | | - } ), |
34 | | - // Attributes - if given, make a deep copy of attributes |
35 | | - !$.isPlainObject( obj.attributes ) ? {} : $.extend( true, {}, obj.attributes ) |
| 30 | + // children - if given, convert all plain "child" objects to es.WikiDom* objects |
| 31 | + !$.isArray( obj.children ) ? [] : $.map( obj.children, function( child ) { |
| 32 | + return es.BlockModel.newFromPlainObject( child ); |
| 33 | + } ) |
36 | 34 | ); |
37 | 35 | }; |
38 | 36 | |
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockCellModel.js |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | es.TableBlockCellModel.newFromPlainObject = function( obj ) { |
31 | 31 | return new es.TableBlockCellModel( |
32 | 32 | // Blocks - if given, convert all plain "block" objects to es.WikiDom* objects |
33 | | - !$.isArray( obj.blocks ) ? [] : $.map( obj.blocks, function( block ) { |
| 33 | + !$.isArray( obj.children ) ? [] : $.map( obj.children, function( block ) { |
34 | 34 | return es.BlockModel.newFromPlainObject( block ); |
35 | 35 | } ), |
36 | 36 | // Attributes - if given, make a deep copy of attributes |
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockModel.js |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | es.TableBlockModel.newFromPlainObject = function( obj ) { |
35 | 35 | return new es.TableBlockModel( |
36 | 36 | // Cells - if given, convert plain row objects to es.TableBlockRowModel objects |
37 | | - !$.isArray( obj.rows ) ? [] : $.map( obj.rows, function( row ) { |
| 37 | + !$.isArray( obj.children ) ? [] : $.map( obj.children, function( row ) { |
38 | 38 | return !$.isPlainObject( row ) ? null : es.TableBlockRowModel.newFromPlainObject( row ) |
39 | 39 | } ), |
40 | 40 | // Attributes - if given, make a deep copy of attributes |
Index: trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js |
— | — | @@ -36,10 +36,10 @@ |
37 | 37 | if ( !$.isArray( styles ) ) { |
38 | 38 | styles = []; |
39 | 39 | } |
40 | | - styles.push( obj.style || 'bullet' ); |
| 40 | + styles.push( obj.attributes.style || 'bullet' ); |
41 | 41 | var items = []; |
42 | | - if ( $.isArray( obj.items ) ) { |
43 | | - $.each( obj.items, function( i, item ) { |
| 42 | + if ( $.isArray( obj.children ) ) { |
| 43 | + $.each( obj.children, function( i, item ) { |
44 | 44 | if ( $.isPlainObject( item.content ) ) { |
45 | 45 | items.push( |
46 | 46 | new es.ListBlockItemModel( |
— | — | @@ -48,8 +48,8 @@ |
49 | 49 | ) |
50 | 50 | ); |
51 | 51 | } |
52 | | - if ( $.isArray( item.lists ) ) { |
53 | | - $.each( item.lists, function( i, list ) { |
| 52 | + if ( $.isArray( item.children ) ) { |
| 53 | + $.each( item.children, function( i, list ) { |
54 | 54 | items = items.concat( es.ListBlockModel.flattenPlainObject( list, styles ) ); |
55 | 55 | } ); |
56 | 56 | } |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | return new es.ListBlockModel( |
72 | 72 | // Items - if given, convert plain "list" object from a tree structure to a flat array of |
73 | 73 | // es.ListBlockItemModel objects |
74 | | - !$.isArray( obj.items ) ? [] : es.ListBlockModel.flattenPlainObject( obj ) |
| 74 | + !$.isArray( obj.children ) ? [] : es.ListBlockModel.flattenPlainObject( obj ) |
75 | 75 | ); |
76 | 76 | }; |
77 | 77 | |
Index: trunk/parsers/wikidom/lib/synth/models/es.HeadingBlockModel.js |
— | — | @@ -8,10 +8,10 @@ |
9 | 9 | * @property content {es.ContentModel} |
10 | 10 | * @property level {Integer} |
11 | 11 | */ |
12 | | -es.HeadingBlockModel = function( content, level ) { |
| 12 | +es.HeadingBlockModel = function( content, attributes ) { |
13 | 13 | es.BlockModel.call( this, ['hasContent', 'isAnnotatable'] ); |
14 | 14 | this.content = content || new es.ContentModel(); |
15 | | - this.level = level || 0; |
| 15 | + this.attributes = attributes || {}; |
16 | 16 | var model = this; |
17 | 17 | this.content.on( 'change', function() { |
18 | 18 | model.emit( 'update' ); |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | * @param obj {Object} |
30 | 30 | */ |
31 | 31 | es.HeadingBlockModel.newFromPlainObject = function( obj ) { |
32 | | - return new es.HeadingBlockModel( es.ContentModel.newFromPlainObject( obj.content ), obj.level ); |
| 32 | + return new es.HeadingBlockModel( es.ContentModel.newFromPlainObject( obj.content ), obj.attributes ); |
33 | 33 | }; |
34 | 34 | |
35 | 35 | /* Methods */ |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | * @returns obj {Object} |
59 | 59 | */ |
60 | 60 | es.HeadingBlockModel.prototype.getPlainObject = function() { |
61 | | - return { 'type': 'heading', 'content': this.content.getPlainObject(), 'level': this.level }; |
| 61 | + return { 'type': 'heading', 'content': this.content.getPlainObject(), 'attributes': this.attributes }; |
62 | 62 | }; |
63 | 63 | |
64 | 64 | es.HeadingBlockModel.prototype.commit = function( transaction ) { |
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockRowModel.js |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | es.TableBlockRowModel.newFromPlainObject = function( obj ) { |
33 | 33 | return new es.TableBlockRowModel( |
34 | 34 | // Cells - if given, convert plain cell objects to es.TableBlockCellModel objects |
35 | | - !$.isArray( obj.cells ) ? [] : $.map( obj.cells, function( cell ) { |
| 35 | + !$.isArray( obj.children ) ? [] : $.map( obj.children, function( cell ) { |
36 | 36 | return !$.isPlainObject( cell ) ? null |
37 | 37 | : es.TableBlockCellModel.newFromPlainObject( cell ) |
38 | 38 | } ), |
Index: trunk/parsers/wikidom/lib/synth/views/es.HeadingBlockView.js |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | es.HeadingBlockView = function( model ) { |
3 | | - es.BlockView.call( this, model, $('<h' + model.level +'/>') ); |
| 3 | + es.BlockView.call( this, model, $('<h' + model.attributes.level +'/>') ); |
4 | 4 | this.$.addClass( 'editSurface-headingBlock' ); |
5 | 5 | this.contentView = new es.ContentView( this.$, this.model.content ); |
6 | 6 | var view = this; |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | es.TableBlockRowView = function( model ) { |
11 | 11 | es.ViewList.call( this, model, $( '<tr>' ) ); |
12 | 12 | es.ViewListItem.call( this, model, this.$ ); |
13 | | - this.$.attr( this.model.attributes ); |
| 13 | + this.$.attr( 'style', this.model.attributes['html/style'] ); |
14 | 14 | }; |
15 | 15 | |
16 | 16 | /* Methods */ |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | es.TableBlockCellView = function( model ) { |
10 | 10 | es.ViewList.call( this, model, $( '<td>' ) ); |
11 | 11 | es.ViewListItem.call( this, model, this.$ ); |
12 | | - this.$.attr( this.model.attributes ); |
| 12 | + this.$.attr( 'style', this.model.attributes['html/style'] ); |
13 | 13 | }; |
14 | 14 | |
15 | 15 | /* Methods */ |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | es.TableBlockView = function( model ) { |
11 | 11 | es.ViewList.call( this, model, $( '<table>' ) ); |
12 | 12 | es.BlockView.call( this, model, this.$ ); |
13 | | - this.$.attr( this.model.attributes ); |
| 13 | + this.$.attr( 'style', this.model.attributes['html/style'] ); |
14 | 14 | this.$.addClass( 'editSurface-tableBlock' ); |
15 | 15 | }; |
16 | 16 | |