| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ve.ui.HistoryCommand = function VeUiHistoryCommand( name, method ) { |
| 18 |
method = method || name; |
| 19 |
|
| 20 |
|
| 21 |
ve.ui.HistoryCommand.super.call( this, name, 'history', method ); |
| 22 |
|
| 23 |
this.checkMethod = { |
| 24 |
undo: 'canUndo', |
| 25 |
redo: 'canRedo' |
| 26 |
}[ method ]; |
| 27 |
}; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
OO.inheritClass( ve.ui.HistoryCommand, ve.ui.Command ); |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
ve.ui.HistoryCommand.prototype.isExecutable = function ( fragment ) { |
| 39 |
const surface = fragment.getSurface(); |
| 40 |
|
| 41 |
|
| 42 |
return ve.ui.HistoryCommand.super.prototype.isExecutable.apply( this, arguments ) && |
| 43 |
surface[ this.checkMethod ](); |
| 44 |
}; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
ve.ui.commandRegistry.register( new ve.ui.HistoryCommand( 'undo' ) ); |
| 49 |
|
| 50 |
ve.ui.commandRegistry.register( new ve.ui.HistoryCommand( 'redo' ) ); |