ListItem now is a branch instead of being leaf. So it contains children - usually it would be just Paragraph, but in some cases Table as well (as Wikitext allows to have HTML table in list item)

This commit is contained in:
Inez Korczynski 2011-11-07 21:30:13 +00:00
parent 02694c630d
commit d01cdd859d
4 changed files with 71 additions and 36 deletions

View file

@ -132,63 +132,84 @@ $(document).ready( function() {
'attributes': {
'styles': ['bullet']
},
'content': {
'text': 'Test 4444'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 4444' }
}
]
},
{
'type': 'listItem',
'attributes': {
'styles': ['bullet', 'bullet']
},
'content': {
'text': 'Test 55555'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 55555' }
}
]
},
{
'type': 'listItem',
'attributes': {
'styles': ['bullet', 'bullet', 'bullet']
},
'content': {
'text': 'Test 666666'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 666666' }
}
]
},
{
'type': 'listItem',
'attributes': {
'styles': ['number']
},
'content': {
'text': 'Test 7777777'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 7777777' }
}
]
},
{
'type': 'listItem',
'attributes': {
'styles': ['number', 'number']
},
'content': {
'text': 'Test 88888888'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 88888888' }
}
]
},
{
'type': 'listItem',
'attributes': {
'styles': ['term']
},
'content': {
'text': 'Test 999999999'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 999999999' }
}
]
},
{
'type': 'listItem',
'attributes': {
'styles': ['definition']
},
'content': {
'text': 'Test 0000000000'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 0000000000' }
}
]
}
]
},
@ -215,27 +236,36 @@ $(document).ready( function() {
'attributes': {
'styles': ['bullet']
},
'content': {
'text': 'Test 4444'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 4444' }
}
]
},
{
'type': 'listItem',
'attributes': {
'styles': ['bullet', 'bullet']
},
'content': {
'text': 'Test 55555'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 55555' }
}
]
},
{
'type': 'listItem',
'attributes': {
'styles': ['number']
},
'content': {
'text': 'Test 666666'
}
'children' : [
{
'type': 'paragraph',
'content': { 'text': 'Test 666666' }
}
]
}
]
}

View file

@ -49,6 +49,10 @@
font-size: 1em;
}
.es-listItemView > .es-paragraphView {
margin: 0;
}
.es-headingView-level1,
.es-headingView-level2 {
border-bottom: 1px solid #AAA;

View file

@ -7,9 +7,9 @@
* @param {Object} element Document data element of this node
* @param {Integer} length Length of document data element
*/
es.ListItemModel = function( element, length ) {
es.ListItemModel = function( element, contents ) {
// Inheritance
es.DocumentModelLeafNode.call( this, 'listItem', element, length );
es.DocumentModelBranchNode.call( this, 'listItem', element, contents );
};
/* Methods */
@ -30,9 +30,9 @@ es.DocumentModel.nodeModels.listItem = es.ListItemModel;
es.DocumentModel.nodeRules.listItem = {
'parents': ['list'],
'children': []
'children': ['paragraph', 'table']
};
/* Inheritance */
es.extendClass( es.ListItemModel, es.DocumentModelLeafNode );
es.extendClass( es.ListItemModel, es.DocumentModelBranchNode );

View file

@ -8,7 +8,7 @@
*/
es.ListItemView = function( model ) {
// Inheritance
es.DocumentViewLeafNode.call( this, model );
es.DocumentViewBranchNode.call( this, model );
// Properties
this.$icon = $( '<div class="es-listItemView-icon"></div>' ).prependTo( this.$ );
@ -23,6 +23,7 @@ es.ListItemView = function( model ) {
this.setClasses();
};
es.ListItemView.prototype.setClasses = function() {
var classes = this.$.attr( 'class' ),
styles = this.model.getElementAttribute( 'styles' );
@ -46,4 +47,4 @@ es.ListItemView.prototype.setNumber = function( number ) {
/* Inheritance */
es.extendClass( es.ListItemView, es.DocumentViewLeafNode );
es.extendClass( es.ListItemView, es.DocumentViewBranchNode );