| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ve.dm.TableRowNode = function VeDmTableRowNode() { |
| 18 |
|
| 19 |
ve.dm.TableRowNode.super.apply( this, arguments ); |
| 20 |
|
| 21 |
|
| 22 |
this.connect( this, { splice: 'onSplice' } ); |
| 23 |
}; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
OO.inheritClass( ve.dm.TableRowNode, ve.dm.BranchNode ); |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
ve.dm.TableRowNode.static.name = 'tableRow'; |
| 32 |
|
| 33 |
ve.dm.TableRowNode.static.childNodeTypes = [ 'tableCell', 'alienTableCell' ]; |
| 34 |
|
| 35 |
ve.dm.TableRowNode.static.parentNodeTypes = [ 'tableSection' ]; |
| 36 |
|
| 37 |
ve.dm.TableRowNode.static.matchTagNames = [ 'tr' ]; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
ve.dm.TableRowNode.static.createData = function ( options ) { |
| 50 |
options = options || {}; |
| 51 |
|
| 52 |
const cellCount = options.cellCount || 1; |
| 53 |
|
| 54 |
const data = []; |
| 55 |
data.push( { type: 'tableRow' } ); |
| 56 |
for ( let i = 0; i < cellCount; i++ ) { |
| 57 |
ve.batchPush( data, ve.dm.TableCellNode.static.createData( { |
| 58 |
style: Array.isArray( options.style ) ? options.style[ i ] : options.style |
| 59 |
} ) ); |
| 60 |
} |
| 61 |
data.push( { type: '/tableRow' } ); |
| 62 |
return data; |
| 63 |
}; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
ve.dm.TableRowNode.prototype.onSplice = function () { |
| 71 |
if ( this.getRoot() ) { |
| 72 |
this.getParent().getParent().getMatrix().invalidate(); |
| 73 |
} |
| 74 |
const nodes = Array.prototype.slice.call( arguments, 2 ); |
| 75 |
for ( let i = 0; i < nodes.length; i++ ) { |
| 76 |
nodes[ i ].connect( this, { |
| 77 |
attributeChange: [ 'onCellAttributeChange', nodes[ i ] ] |
| 78 |
} ); |
| 79 |
} |
| 80 |
}; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
ve.dm.TableRowNode.prototype.onCellAttributeChange = function ( cell ) { |
| 89 |
this.emit( 'cellAttributeChange', cell ); |
| 90 |
}; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
ve.dm.modelRegistry.register( ve.dm.TableRowNode ); |