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

View file

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

View file

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

View file

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